toyon 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CHANGELOG.md +74 -0
- package/dist/bridge.js +1 -1
- package/dist/cli.js +2 -2
- package/dist/daemon.js +2279 -731
- package/dist/shell/assets/{Editor-CU91PIeX.js → Editor--Z8ktewC.js} +3 -3
- package/dist/shell/assets/Editor--Z8ktewC.js.br +0 -0
- package/dist/shell/assets/Editor--Z8ktewC.js.gz +0 -0
- package/dist/shell/assets/Editor-CB2SckMT.css.br +0 -0
- package/dist/shell/assets/Editor-CB2SckMT.css.gz +0 -0
- package/dist/shell/assets/XTerm-6GBZ9nXN.css.br +0 -0
- package/dist/shell/assets/XTerm-6GBZ9nXN.css.gz +0 -0
- package/dist/shell/assets/{XTerm-y7vQoOEu.js → XTerm-DsUQ0Xew.js} +1 -1
- package/dist/shell/assets/XTerm-DsUQ0Xew.js.br +0 -0
- package/dist/shell/assets/XTerm-DsUQ0Xew.js.gz +0 -0
- package/dist/shell/assets/abap-DLDM7-KI.js.br +0 -0
- package/dist/shell/assets/abap-DLDM7-KI.js.gz +0 -0
- package/dist/shell/assets/apex-DNDY2TF8.js.br +0 -0
- package/dist/shell/assets/apex-DNDY2TF8.js.gz +0 -0
- package/dist/shell/assets/bat-BwHxbl9M.js.br +0 -0
- package/dist/shell/assets/bat-BwHxbl9M.js.gz +0 -0
- package/dist/shell/assets/bicep-CFznDFnq.js.br +0 -0
- package/dist/shell/assets/bicep-CFznDFnq.js.gz +0 -0
- package/dist/shell/assets/cameligo-Bf6VGUru.js.br +0 -0
- package/dist/shell/assets/cameligo-Bf6VGUru.js.gz +0 -0
- package/dist/shell/assets/clojure-Dnu-v4kV.js.br +0 -0
- package/dist/shell/assets/clojure-Dnu-v4kV.js.gz +0 -0
- package/dist/shell/assets/coffee-Bd8akH9Z.js.br +0 -0
- package/dist/shell/assets/coffee-Bd8akH9Z.js.gz +0 -0
- package/dist/shell/assets/cpp-BbWJElDN.js.br +0 -0
- package/dist/shell/assets/cpp-BbWJElDN.js.gz +0 -0
- package/dist/shell/assets/csharp-Co3qMtFm.js.br +0 -0
- package/dist/shell/assets/csharp-Co3qMtFm.js.gz +0 -0
- package/dist/shell/assets/csp-D-4FJmMZ.js.br +0 -0
- package/dist/shell/assets/csp-D-4FJmMZ.js.gz +0 -0
- package/dist/shell/assets/css-DdJfP1eB.js.br +0 -0
- package/dist/shell/assets/css-DdJfP1eB.js.gz +0 -0
- package/dist/shell/assets/css.worker-CqwWTjeG.js.br +0 -0
- package/dist/shell/assets/css.worker-CqwWTjeG.js.gz +0 -0
- package/dist/shell/assets/{cssMode-B7sFzM6K.js → cssMode-BjAkCPrp.js} +1 -1
- package/dist/shell/assets/cssMode-BjAkCPrp.js.br +0 -0
- package/dist/shell/assets/cssMode-BjAkCPrp.js.gz +0 -0
- package/dist/shell/assets/cypher-cTPe9QuQ.js.br +0 -0
- package/dist/shell/assets/cypher-cTPe9QuQ.js.gz +0 -0
- package/dist/shell/assets/dart-BOtBlQCF.js.br +0 -0
- package/dist/shell/assets/dart-BOtBlQCF.js.gz +0 -0
- package/dist/shell/assets/dockerfile-BG73LgW2.js.br +0 -0
- package/dist/shell/assets/dockerfile-BG73LgW2.js.gz +0 -0
- package/dist/shell/assets/ecl-BEgZUVRK.js.br +0 -0
- package/dist/shell/assets/ecl-BEgZUVRK.js.gz +0 -0
- package/dist/shell/assets/editor.worker-DCKwvLbM.js.br +0 -0
- package/dist/shell/assets/editor.worker-DCKwvLbM.js.gz +0 -0
- package/dist/shell/assets/elixir-BkW5O-1t.js.br +0 -0
- package/dist/shell/assets/elixir-BkW5O-1t.js.gz +0 -0
- package/dist/shell/assets/flow9-BeJ5waoc.js.br +0 -0
- package/dist/shell/assets/flow9-BeJ5waoc.js.gz +0 -0
- package/dist/shell/assets/{freemarker2-ChTLQoDC.js → freemarker2-BZCFxXwq.js} +1 -1
- package/dist/shell/assets/freemarker2-BZCFxXwq.js.br +0 -0
- package/dist/shell/assets/freemarker2-BZCFxXwq.js.gz +0 -0
- package/dist/shell/assets/fsharp-PahG7c26.js.br +0 -0
- package/dist/shell/assets/fsharp-PahG7c26.js.gz +0 -0
- package/dist/shell/assets/go-acbASCJo.js.br +0 -0
- package/dist/shell/assets/go-acbASCJo.js.gz +0 -0
- package/dist/shell/assets/{grammar-xXcxTc3V.js → grammar-CQ1uaD6_.js} +1 -1
- package/dist/shell/assets/grammar-CQ1uaD6_.js.br +0 -0
- package/dist/shell/assets/grammar-CQ1uaD6_.js.gz +0 -0
- package/dist/shell/assets/graphql-BxJiqAUM.js.br +0 -0
- package/dist/shell/assets/graphql-BxJiqAUM.js.gz +0 -0
- package/dist/shell/assets/{handlebars-DPJSozQx.js → handlebars-G1zJeDLP.js} +1 -1
- package/dist/shell/assets/handlebars-G1zJeDLP.js.br +0 -0
- package/dist/shell/assets/handlebars-G1zJeDLP.js.gz +0 -0
- package/dist/shell/assets/hcl-DtV1sZF8.js.br +0 -0
- package/dist/shell/assets/hcl-DtV1sZF8.js.gz +0 -0
- package/dist/shell/assets/{html-Cog2rLcD.js → html-CUHSCFMy.js} +1 -1
- package/dist/shell/assets/html-CUHSCFMy.js.br +0 -0
- package/dist/shell/assets/html-CUHSCFMy.js.gz +0 -0
- package/dist/shell/assets/html.worker-DhJ4VZMp.js.br +0 -0
- package/dist/shell/assets/html.worker-DhJ4VZMp.js.gz +0 -0
- package/dist/shell/assets/{htmlMode-Xm5_ujKb.js → htmlMode-gpMedtd9.js} +1 -1
- package/dist/shell/assets/htmlMode-gpMedtd9.js.br +0 -0
- package/dist/shell/assets/htmlMode-gpMedtd9.js.gz +0 -0
- package/dist/shell/assets/index-B3Alj0WH.css +1 -0
- package/dist/shell/assets/index-B3Alj0WH.css.br +0 -0
- package/dist/shell/assets/index-B3Alj0WH.css.gz +0 -0
- package/dist/shell/assets/index-VVd_p5tJ.js +278 -0
- package/dist/shell/assets/index-VVd_p5tJ.js.br +0 -0
- package/dist/shell/assets/index-VVd_p5tJ.js.gz +0 -0
- package/dist/shell/assets/java-CXBNlu9o.js.br +0 -0
- package/dist/shell/assets/java-CXBNlu9o.js.gz +0 -0
- package/dist/shell/assets/{javascript-Dcv6lw7b.js → javascript-BHWH8gQN.js} +1 -1
- package/dist/shell/assets/json.worker-BF9eV5mS.js.br +0 -0
- package/dist/shell/assets/json.worker-BF9eV5mS.js.gz +0 -0
- package/dist/shell/assets/{jsonMode-D5_V0TW5.js → jsonMode-DyV5nvVT.js} +1 -1
- package/dist/shell/assets/jsonMode-DyV5nvVT.js.br +0 -0
- package/dist/shell/assets/jsonMode-DyV5nvVT.js.gz +0 -0
- package/dist/shell/assets/julia-cl7-CwDS.js.br +0 -0
- package/dist/shell/assets/julia-cl7-CwDS.js.gz +0 -0
- package/dist/shell/assets/kotlin-s7OhZKlX.js.br +0 -0
- package/dist/shell/assets/kotlin-s7OhZKlX.js.gz +0 -0
- package/dist/shell/assets/less-9HpZscsL.js.br +0 -0
- package/dist/shell/assets/less-9HpZscsL.js.gz +0 -0
- package/dist/shell/assets/lexon-OrD6JF1K.js.br +0 -0
- package/dist/shell/assets/lexon-OrD6JF1K.js.gz +0 -0
- package/dist/shell/assets/{liquid-C_zXIF5F.js → liquid-Dy3tUgRC.js} +1 -1
- package/dist/shell/assets/liquid-Dy3tUgRC.js.br +0 -0
- package/dist/shell/assets/liquid-Dy3tUgRC.js.gz +0 -0
- package/dist/shell/assets/{lspLanguageFeatures-CkiTdLmp.js → lspLanguageFeatures-CB_Ow-w5.js} +1 -1
- package/dist/shell/assets/lspLanguageFeatures-CB_Ow-w5.js.br +0 -0
- package/dist/shell/assets/lspLanguageFeatures-CB_Ow-w5.js.gz +0 -0
- package/dist/shell/assets/lua-Cyyb5UIc.js.br +0 -0
- package/dist/shell/assets/lua-Cyyb5UIc.js.gz +0 -0
- package/dist/shell/assets/m3-B8OfTtLu.js.br +0 -0
- package/dist/shell/assets/m3-B8OfTtLu.js.gz +0 -0
- package/dist/shell/assets/markdown-BFxVWTOG.js.br +0 -0
- package/dist/shell/assets/markdown-BFxVWTOG.js.gz +0 -0
- package/dist/shell/assets/{mdx-gvbILQkr.js → mdx-DD5jgco_.js} +1 -1
- package/dist/shell/assets/mdx-DD5jgco_.js.br +0 -0
- package/dist/shell/assets/mdx-DD5jgco_.js.gz +0 -0
- package/dist/shell/assets/mips-CiqrrVzr.js.br +0 -0
- package/dist/shell/assets/mips-CiqrrVzr.js.gz +0 -0
- package/dist/shell/assets/msdax-DmeGPVcC.js.br +0 -0
- package/dist/shell/assets/msdax-DmeGPVcC.js.gz +0 -0
- package/dist/shell/assets/mysql-C_tMU-Nz.js.br +0 -0
- package/dist/shell/assets/mysql-C_tMU-Nz.js.gz +0 -0
- package/dist/shell/assets/objective-c-BDtDVThU.js.br +0 -0
- package/dist/shell/assets/objective-c-BDtDVThU.js.gz +0 -0
- package/dist/shell/assets/pascal-vHIfCaH5.js.br +0 -0
- package/dist/shell/assets/pascal-vHIfCaH5.js.gz +0 -0
- package/dist/shell/assets/pascaligo-DtZ0uQbO.js.br +0 -0
- package/dist/shell/assets/pascaligo-DtZ0uQbO.js.gz +0 -0
- package/dist/shell/assets/perl-Ub6l9XKa.js.br +0 -0
- package/dist/shell/assets/perl-Ub6l9XKa.js.gz +0 -0
- package/dist/shell/assets/pgsql-BlNEE0v7.js.br +0 -0
- package/dist/shell/assets/pgsql-BlNEE0v7.js.gz +0 -0
- package/dist/shell/assets/php-BBUBE1dy.js.br +0 -0
- package/dist/shell/assets/php-BBUBE1dy.js.gz +0 -0
- package/dist/shell/assets/pla-DSh2-awV.js.br +0 -0
- package/dist/shell/assets/pla-DSh2-awV.js.gz +0 -0
- package/dist/shell/assets/postiats-CocnycG-.js.br +0 -0
- package/dist/shell/assets/postiats-CocnycG-.js.gz +0 -0
- package/dist/shell/assets/powerquery-tScXyioY.js.br +0 -0
- package/dist/shell/assets/powerquery-tScXyioY.js.gz +0 -0
- package/dist/shell/assets/powershell-COWaemsV.js.br +0 -0
- package/dist/shell/assets/powershell-COWaemsV.js.gz +0 -0
- package/dist/shell/assets/protobuf-Brw8urJB.js.br +0 -0
- package/dist/shell/assets/protobuf-Brw8urJB.js.gz +0 -0
- package/dist/shell/assets/pug-8SOpv6rk.js.br +0 -0
- package/dist/shell/assets/pug-8SOpv6rk.js.gz +0 -0
- package/dist/shell/assets/{python-CZTrOkh_.js → python-BvLKUXll.js} +1 -1
- package/dist/shell/assets/python-BvLKUXll.js.br +0 -0
- package/dist/shell/assets/python-BvLKUXll.js.gz +0 -0
- package/dist/shell/assets/qsharp-Bw9ernYp.js.br +0 -0
- package/dist/shell/assets/qsharp-Bw9ernYp.js.gz +0 -0
- package/dist/shell/assets/r-j7ic8hl3.js.br +0 -0
- package/dist/shell/assets/r-j7ic8hl3.js.gz +0 -0
- package/dist/shell/assets/{razor-DowlBj1i.js → razor-B2tUlbzR.js} +1 -1
- package/dist/shell/assets/razor-B2tUlbzR.js.br +0 -0
- package/dist/shell/assets/razor-B2tUlbzR.js.gz +0 -0
- package/dist/shell/assets/redis-Bu5POkcn.js.br +0 -0
- package/dist/shell/assets/redis-Bu5POkcn.js.gz +0 -0
- package/dist/shell/assets/redshift-Bs9aos_-.js.br +0 -0
- package/dist/shell/assets/redshift-Bs9aos_-.js.gz +0 -0
- package/dist/shell/assets/restructuredtext-CqXO7rUv.js.br +0 -0
- package/dist/shell/assets/restructuredtext-CqXO7rUv.js.gz +0 -0
- package/dist/shell/assets/ruby-zBfavPgS.js.br +0 -0
- package/dist/shell/assets/ruby-zBfavPgS.js.gz +0 -0
- package/dist/shell/assets/rust-BzKRNQWT.js.br +0 -0
- package/dist/shell/assets/rust-BzKRNQWT.js.gz +0 -0
- package/dist/shell/assets/sb-BBc9UKZt.js.br +0 -0
- package/dist/shell/assets/sb-BBc9UKZt.js.gz +0 -0
- package/dist/shell/assets/scala-D9hQfWCl.js.br +0 -0
- package/dist/shell/assets/scala-D9hQfWCl.js.gz +0 -0
- package/dist/shell/assets/scheme-BPhDTwHR.js.br +0 -0
- package/dist/shell/assets/scheme-BPhDTwHR.js.gz +0 -0
- package/dist/shell/assets/scss-CBJaRo0y.js.br +0 -0
- package/dist/shell/assets/scss-CBJaRo0y.js.gz +0 -0
- package/dist/shell/assets/shell-DiJ1NA_G.js.br +0 -0
- package/dist/shell/assets/shell-DiJ1NA_G.js.gz +0 -0
- package/dist/shell/assets/solidity-Db0IVjzk.js.br +0 -0
- package/dist/shell/assets/solidity-Db0IVjzk.js.gz +0 -0
- package/dist/shell/assets/sophia-CnS9iZB_.js.br +0 -0
- package/dist/shell/assets/sophia-CnS9iZB_.js.gz +0 -0
- package/dist/shell/assets/sparql-CJmd_6j2.js.br +0 -0
- package/dist/shell/assets/sparql-CJmd_6j2.js.gz +0 -0
- package/dist/shell/assets/sql-ClhHkBeG.js.br +0 -0
- package/dist/shell/assets/sql-ClhHkBeG.js.gz +0 -0
- package/dist/shell/assets/st-CHwy0fLd.js.br +0 -0
- package/dist/shell/assets/st-CHwy0fLd.js.gz +0 -0
- package/dist/shell/assets/swift-Bqt4WxQ4.js.br +0 -0
- package/dist/shell/assets/swift-Bqt4WxQ4.js.gz +0 -0
- package/dist/shell/assets/systemverilog-Bs9z6M-B.js.br +0 -0
- package/dist/shell/assets/systemverilog-Bs9z6M-B.js.gz +0 -0
- package/dist/shell/assets/tcl-Dm6ycUr_.js.br +0 -0
- package/dist/shell/assets/tcl-Dm6ycUr_.js.gz +0 -0
- package/dist/shell/assets/ts.worker-DTZAwq0V.js.br +0 -0
- package/dist/shell/assets/ts.worker-DTZAwq0V.js.gz +0 -0
- package/dist/shell/assets/{tsMode-BNl2cV_K.js → tsMode-DMuNnqM7.js} +1 -1
- package/dist/shell/assets/tsMode-DMuNnqM7.js.br +0 -0
- package/dist/shell/assets/tsMode-DMuNnqM7.js.gz +0 -0
- package/dist/shell/assets/twig-Csy3S7wG.js.br +0 -0
- package/dist/shell/assets/twig-Csy3S7wG.js.gz +0 -0
- package/dist/shell/assets/typespec-Btyra-wh.js.br +0 -0
- package/dist/shell/assets/typespec-Btyra-wh.js.gz +0 -0
- package/dist/shell/assets/vb-Db0cS2oM.js.br +0 -0
- package/dist/shell/assets/vb-Db0cS2oM.js.gz +0 -0
- package/dist/shell/assets/wasm-inlined-CG6Dc4jp.js.br +0 -0
- package/dist/shell/assets/wasm-inlined-CG6Dc4jp.js.gz +0 -0
- package/dist/shell/assets/wgsl-BTesnYfV.js.br +0 -0
- package/dist/shell/assets/wgsl-BTesnYfV.js.gz +0 -0
- package/dist/shell/assets/{xml-DIiuHFHw.js → xml-DdYgb5a2.js} +1 -1
- package/dist/shell/assets/xml-DdYgb5a2.js.br +0 -0
- package/dist/shell/assets/xml-DdYgb5a2.js.gz +0 -0
- package/dist/shell/assets/{yaml-CBnMyn4j.js → yaml-BDujJdoL.js} +1 -1
- package/dist/shell/assets/yaml-BDujJdoL.js.br +0 -0
- package/dist/shell/assets/yaml-BDujJdoL.js.gz +0 -0
- package/dist/shell/index.html +11 -8
- package/dist/shell/manifest.json +13 -0
- package/dist/shell/sw.js +117 -22
- package/package.json +2 -2
- package/dist/shell/assets/index-BpW1Kufz.css +0 -1
- package/dist/shell/assets/index-CdY8WF4P.js +0 -270
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-CU91PIeX.js","assets/grammar-xXcxTc3V.js","assets/Editor-CB2SckMT.css","assets/XTerm-y7vQoOEu.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
var lC=Object.defineProperty;var cC=(e,t,n)=>t in e?lC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $t=(e,t,n)=>cC(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 l1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ip={exports:{}},fc={},$p={exports:{}},tn={};/**
|
|
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 Tv;function uC(){if(Tv)return tn;Tv=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"),p=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function g(F){return F===null||typeof F!="object"?null:(F=m&&F[m]||F["@@iterator"],typeof F=="function"?F:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function _(F,re,Ee){this.props=F,this.context=re,this.refs=b,this.updater=Ee||w}_.prototype.isReactComponent={},_.prototype.setState=function(F,re){if(typeof F!="object"&&typeof F!="function"&&F!=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,F,re,"setState")},_.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function T(){}T.prototype=_.prototype;function x(F,re,Ee){this.props=F,this.context=re,this.refs=b,this.updater=Ee||w}var N=x.prototype=new T;N.constructor=x,y(N,_.prototype),N.isPureReactComponent=!0;var j=Array.isArray,$=Object.prototype.hasOwnProperty,P={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function A(F,re,Ee){var Te,de={},ke=null,ae=null;if(re!=null)for(Te in re.ref!==void 0&&(ae=re.ref),re.key!==void 0&&(ke=""+re.key),re)$.call(re,Te)&&!R.hasOwnProperty(Te)&&(de[Te]=re[Te]);var G=arguments.length-2;if(G===1)de.children=Ee;else if(1<G){for(var ue=Array(G),Le=0;Le<G;Le++)ue[Le]=arguments[Le+2];de.children=ue}if(F&&F.defaultProps)for(Te in G=F.defaultProps,G)de[Te]===void 0&&(de[Te]=G[Te]);return{$$typeof:e,type:F,key:ke,ref:ae,props:de,_owner:P.current}}function O(F,re){return{$$typeof:e,type:F.type,key:re,ref:F.ref,props:F.props,_owner:F._owner}}function D(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function z(F){var re={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(Ee){return re[Ee]})}var X=/\/+/g;function ne(F,re){return typeof F=="object"&&F!==null&&F.key!=null?z(""+F.key):re.toString(36)}function ee(F,re,Ee,Te,de){var ke=typeof F;(ke==="undefined"||ke==="boolean")&&(F=null);var ae=!1;if(F===null)ae=!0;else switch(ke){case"string":case"number":ae=!0;break;case"object":switch(F.$$typeof){case e:case t:ae=!0}}if(ae)return ae=F,de=de(ae),F=Te===""?"."+ne(ae,0):Te,j(de)?(Ee="",F!=null&&(Ee=F.replace(X,"$&/")+"/"),ee(de,re,Ee,"",function(Le){return Le})):de!=null&&(D(de)&&(de=O(de,Ee+(!de.key||ae&&ae.key===de.key?"":(""+de.key).replace(X,"$&/")+"/")+F)),re.push(de)),1;if(ae=0,Te=Te===""?".":Te+":",j(F))for(var G=0;G<F.length;G++){ke=F[G];var ue=Te+ne(ke,G);ae+=ee(ke,re,Ee,ue,de)}else if(ue=g(F),typeof ue=="function")for(F=ue.call(F),G=0;!(ke=F.next()).done;)ke=ke.value,ue=Te+ne(ke,G++),ae+=ee(ke,re,Ee,ue,de);else if(ke==="object")throw re=String(F),Error("Objects are not valid as a React child (found: "+(re==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":re)+"). If you meant to render a collection of children, use an array instead.");return ae}function ie(F,re,Ee){if(F==null)return F;var Te=[],de=0;return ee(F,Te,"","",function(ke){return re.call(Ee,ke,de++)}),Te}function be(F){if(F._status===-1){var re=F._result;re=re(),re.then(function(Ee){(F._status===0||F._status===-1)&&(F._status=1,F._result=Ee)},function(Ee){(F._status===0||F._status===-1)&&(F._status=2,F._result=Ee)}),F._status===-1&&(F._status=0,F._result=re)}if(F._status===1)return F._result.default;throw F._result}var C={current:null},Z={transition:null},Y={ReactCurrentDispatcher:C,ReactCurrentBatchConfig:Z,ReactCurrentOwner:P};function q(){throw Error("act(...) is not supported in production builds of React.")}return tn.Children={map:ie,forEach:function(F,re,Ee){ie(F,function(){re.apply(this,arguments)},Ee)},count:function(F){var re=0;return ie(F,function(){re++}),re},toArray:function(F){return ie(F,function(re){return re})||[]},only:function(F){if(!D(F))throw Error("React.Children.only expected to receive a single React element child.");return F}},tn.Component=_,tn.Fragment=n,tn.Profiler=o,tn.PureComponent=x,tn.StrictMode=r,tn.Suspense=u,tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y,tn.act=q,tn.cloneElement=function(F,re,Ee){if(F==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+F+".");var Te=y({},F.props),de=F.key,ke=F.ref,ae=F._owner;if(re!=null){if(re.ref!==void 0&&(ke=re.ref,ae=P.current),re.key!==void 0&&(de=""+re.key),F.type&&F.type.defaultProps)var G=F.type.defaultProps;for(ue in re)$.call(re,ue)&&!R.hasOwnProperty(ue)&&(Te[ue]=re[ue]===void 0&&G!==void 0?G[ue]:re[ue])}var ue=arguments.length-2;if(ue===1)Te.children=Ee;else if(1<ue){G=Array(ue);for(var Le=0;Le<ue;Le++)G[Le]=arguments[Le+2];Te.children=G}return{$$typeof:e,type:F.type,key:de,ref:ke,props:Te,_owner:ae}},tn.createContext=function(F){return F={$$typeof:l,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},F.Provider={$$typeof:i,_context:F},F.Consumer=F},tn.createElement=A,tn.createFactory=function(F){var re=A.bind(null,F);return re.type=F,re},tn.createRef=function(){return{current:null}},tn.forwardRef=function(F){return{$$typeof:c,render:F}},tn.isValidElement=D,tn.lazy=function(F){return{$$typeof:h,_payload:{_status:-1,_result:F},_init:be}},tn.memo=function(F,re){return{$$typeof:p,type:F,compare:re===void 0?null:re}},tn.startTransition=function(F){var re=Z.transition;Z.transition={};try{F()}finally{Z.transition=re}},tn.unstable_act=q,tn.useCallback=function(F,re){return C.current.useCallback(F,re)},tn.useContext=function(F){return C.current.useContext(F)},tn.useDebugValue=function(){},tn.useDeferredValue=function(F){return C.current.useDeferredValue(F)},tn.useEffect=function(F,re){return C.current.useEffect(F,re)},tn.useId=function(){return C.current.useId()},tn.useImperativeHandle=function(F,re,Ee){return C.current.useImperativeHandle(F,re,Ee)},tn.useInsertionEffect=function(F,re){return C.current.useInsertionEffect(F,re)},tn.useLayoutEffect=function(F,re){return C.current.useLayoutEffect(F,re)},tn.useMemo=function(F,re){return C.current.useMemo(F,re)},tn.useReducer=function(F,re,Ee){return C.current.useReducer(F,re,Ee)},tn.useRef=function(F){return C.current.useRef(F)},tn.useState=function(F){return C.current.useState(F)},tn.useSyncExternalStore=function(F,re,Ee){return C.current.useSyncExternalStore(F,re,Ee)},tn.useTransition=function(){return C.current.useTransition()},tn.version="18.3.1",tn}var jv;function $g(){return jv||(jv=1,$p.exports=uC()),$p.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 Cv;function dC(){if(Cv)return fc;Cv=1;var e=$g(),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,p){var h,m={},g=null,w=null;p!==void 0&&(g=""+p),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(w=u.ref);for(h in u)r.call(u,h)&&!i.hasOwnProperty(h)&&(m[h]=u[h]);if(c&&c.defaultProps)for(h in u=c.defaultProps,u)m[h]===void 0&&(m[h]=u[h]);return{$$typeof:t,type:c,key:g,ref:w,props:m,_owner:o.current}}return fc.Fragment=n,fc.jsx=l,fc.jsxs=l,fc}var Av;function fC(){return Av||(Av=1,Ip.exports=dC()),Ip.exports}var d=fC(),S=$g();const hC=l1(S);var Rp={exports:{}},Qr={},Op={exports:{}},Mp={};/**
|
|
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 Iv;function pC(){return Iv||(Iv=1,(function(e){function t(Z,Y){var q=Z.length;Z.push(Y);e:for(;0<q;){var F=q-1>>>1,re=Z[F];if(0<o(re,Y))Z[F]=Y,Z[q]=re,q=F;else break e}}function n(Z){return Z.length===0?null:Z[0]}function r(Z){if(Z.length===0)return null;var Y=Z[0],q=Z.pop();if(q!==Y){Z[0]=q;e:for(var F=0,re=Z.length,Ee=re>>>1;F<Ee;){var Te=2*(F+1)-1,de=Z[Te],ke=Te+1,ae=Z[ke];if(0>o(de,q))ke<re&&0>o(ae,de)?(Z[F]=ae,Z[ke]=q,F=ke):(Z[F]=de,Z[Te]=q,F=Te);else if(ke<re&&0>o(ae,q))Z[F]=ae,Z[ke]=q,F=ke;else break e}}return Y}function o(Z,Y){var q=Z.sortIndex-Y.sortIndex;return q!==0?q:Z.id-Y.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=[],p=[],h=1,m=null,g=3,w=!1,y=!1,b=!1,_=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,x=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(Z){for(var Y=n(p);Y!==null;){if(Y.callback===null)r(p);else if(Y.startTime<=Z)r(p),Y.sortIndex=Y.expirationTime,t(u,Y);else break;Y=n(p)}}function j(Z){if(b=!1,N(Z),!y)if(n(u)!==null)y=!0,be($);else{var Y=n(p);Y!==null&&C(j,Y.startTime-Z)}}function $(Z,Y){y=!1,b&&(b=!1,T(A),A=-1),w=!0;var q=g;try{for(N(Y),m=n(u);m!==null&&(!(m.expirationTime>Y)||Z&&!z());){var F=m.callback;if(typeof F=="function"){m.callback=null,g=m.priorityLevel;var re=F(m.expirationTime<=Y);Y=e.unstable_now(),typeof re=="function"?m.callback=re:m===n(u)&&r(u),N(Y)}else r(u);m=n(u)}if(m!==null)var Ee=!0;else{var Te=n(p);Te!==null&&C(j,Te.startTime-Y),Ee=!1}return Ee}finally{m=null,g=q,w=!1}}var P=!1,R=null,A=-1,O=5,D=-1;function z(){return!(e.unstable_now()-D<O)}function X(){if(R!==null){var Z=e.unstable_now();D=Z;var Y=!0;try{Y=R(!0,Z)}finally{Y?ne():(P=!1,R=null)}}else P=!1}var ne;if(typeof x=="function")ne=function(){x(X)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,ie=ee.port2;ee.port1.onmessage=X,ne=function(){ie.postMessage(null)}}else ne=function(){_(X,0)};function be(Z){R=Z,P||(P=!0,ne())}function C(Z,Y){A=_(function(){Z(e.unstable_now())},Y)}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(Z){Z.callback=null},e.unstable_continueExecution=function(){y||w||(y=!0,be($))},e.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<Z?Math.floor(1e3/Z):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(Z){switch(g){case 1:case 2:case 3:var Y=3;break;default:Y=g}var q=g;g=Y;try{return Z()}finally{g=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Z,Y){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var q=g;g=Z;try{return Y()}finally{g=q}},e.unstable_scheduleCallback=function(Z,Y,q){var F=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?F+q:F):q=F,Z){case 1:var re=-1;break;case 2:re=250;break;case 5:re=1073741823;break;case 4:re=1e4;break;default:re=5e3}return re=q+re,Z={id:h++,callback:Y,priorityLevel:Z,startTime:q,expirationTime:re,sortIndex:-1},q>F?(Z.sortIndex=q,t(p,Z),n(u)===null&&Z===n(p)&&(b?(T(A),A=-1):b=!0,C(j,q-F))):(Z.sortIndex=re,t(u,Z),y||w||(y=!0,be($))),Z},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(Z){var Y=g;return function(){var q=g;g=Y;try{return Z.apply(this,arguments)}finally{g=q}}}})(Mp)),Mp}var $v;function mC(){return $v||($v=1,Op.exports=pC()),Op.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 Rv;function gC(){if(Rv)return Qr;Rv=1;var e=$g(),t=mC();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,p=/^[: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]*$/,h={},m={};function g(s){return u.call(m,s)?!0:u.call(h,s)?!1:p.test(s)?m[s]=!0:(h[s]=!0,!1)}function w(s,a,f,k){if(f!==null&&f.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return k?!1:f!==null?!f.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function y(s,a,f,k){if(a===null||typeof a>"u"||w(s,a,f,k))return!0;if(k)return!1;if(f!==null)switch(f.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function b(s,a,f,k,v,E,I){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=k,this.attributeNamespace=v,this.mustUseProperty=f,this.propertyName=s,this.type=a,this.sanitizeURL=E,this.removeEmptyString=I}var _={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(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];_[a]=new b(a,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){_[s]=new b(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(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]=new b(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){_[s]=new b(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){_[s]=new b(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){_[s]=new b(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){_[s]=new b(s,5,!1,s.toLowerCase(),null,!1,!1)});var T=/[\-:]([a-z])/g;function x(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(T,x);_[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(T,x);_[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(T,x);_[a]=new b(a,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){_[s]=new b(s,1,!1,s.toLowerCase(),null,!1,!1)}),_.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){_[s]=new b(s,1,!1,s.toLowerCase(),null,!0,!0)});function N(s,a,f,k){var v=_.hasOwnProperty(a)?_[a]:null;(v!==null?v.type!==0:k||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(y(a,f,v,k)&&(f=null),k||v===null?g(a)&&(f===null?s.removeAttribute(a):s.setAttribute(a,""+f)):v.mustUseProperty?s[v.propertyName]=f===null?v.type===3?!1:"":f:(a=v.attributeName,k=v.attributeNamespace,f===null?s.removeAttribute(a):(v=v.type,f=v===3||v===4&&f===!0?"":""+f,k?s.setAttributeNS(k,a,f):s.setAttribute(a,f))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),P=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),z=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),ie=Symbol.for("react.memo"),be=Symbol.for("react.lazy"),C=Symbol.for("react.offscreen"),Z=Symbol.iterator;function Y(s){return s===null||typeof s!="object"?null:(s=Z&&s[Z]||s["@@iterator"],typeof s=="function"?s:null)}var q=Object.assign,F;function re(s){if(F===void 0)try{throw Error()}catch(f){var a=f.stack.trim().match(/\n( *(at )?)/);F=a&&a[1]||""}return`
|
|
35
|
-
`+F+s}var Ee=!1;function Te(s,a){if(!s||Ee)return"";Ee=!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 k=he}Reflect.construct(s,[],a)}else{try{a.call()}catch(he){k=he}s.call(a.prototype)}else{try{throw Error()}catch(he){k=he}s()}}catch(he){if(he&&k&&typeof he.stack=="string"){for(var v=he.stack.split(`
|
|
36
|
-
`),E=k.stack.split(`
|
|
37
|
-
`),I=v.length-1,W=E.length-1;1<=I&&0<=W&&v[I]!==E[W];)W--;for(;1<=I&&0<=W;I--,W--)if(v[I]!==E[W]){if(I!==1||W!==1)do if(I--,W--,0>W||v[I]!==E[W]){var Q=`
|
|
38
|
-
`+v[I].replace(" at new "," at ");return s.displayName&&Q.includes("<anonymous>")&&(Q=Q.replace("<anonymous>",s.displayName)),Q}while(1<=I&&0<=W);break}}}finally{Ee=!1,Error.prepareStackTrace=f}return(s=s?s.displayName||s.name:"")?re(s):""}function de(s){switch(s.tag){case 5:return re(s.type);case 16:return re("Lazy");case 13:return re("Suspense");case 19:return re("SuspenseList");case 0:case 2:case 15:return s=Te(s.type,!1),s;case 11:return s=Te(s.type.render,!1),s;case 1:return s=Te(s.type,!0),s;default:return""}}function ke(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 O:return"Profiler";case A:return"StrictMode";case ne:return"Suspense";case ee:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case z:return(s.displayName||"Context")+".Consumer";case D:return(s._context.displayName||"Context")+".Provider";case X:var a=s.render;return s=s.displayName,s||(s=a.displayName||a.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case ie:return a=s.displayName||null,a!==null?a:ke(s.type)||"Memo";case be:a=s._payload,s=s._init;try{return ke(s(a))}catch{}}return null}function ae(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 ke(a);case 8:return a===A?"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 ue(s){var a=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function Le(s){var a=ue(s)?"checked":"value",f=Object.getOwnPropertyDescriptor(s.constructor.prototype,a),k=""+s[a];if(!s.hasOwnProperty(a)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var v=f.get,E=f.set;return Object.defineProperty(s,a,{configurable:!0,get:function(){return v.call(this)},set:function(I){k=""+I,E.call(this,I)}}),Object.defineProperty(s,a,{enumerable:f.enumerable}),{getValue:function(){return k},setValue:function(I){k=""+I},stopTracking:function(){s._valueTracker=null,delete s[a]}}}}function ge(s){s._valueTracker||(s._valueTracker=Le(s))}function oe(s){if(!s)return!1;var a=s._valueTracker;if(!a)return!0;var f=a.getValue(),k="";return s&&(k=ue(s)?s.checked?"true":"false":s.value),s=k,s!==f?(a.setValue(s),!0):!1}function we(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function Ce(s,a){var f=a.checked;return q({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f??s._wrapperState.initialChecked})}function Se(s,a){var f=a.defaultValue==null?"":a.defaultValue,k=a.checked!=null?a.checked:a.defaultChecked;f=G(a.value!=null?a.value:f),s._wrapperState={initialChecked:k,initialValue:f,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function _e(s,a){a=a.checked,a!=null&&N(s,"checked",a,!1)}function Be(s,a){_e(s,a);var f=G(a.value),k=a.type;if(f!=null)k==="number"?(f===0&&s.value===""||s.value!=f)&&(s.value=""+f):s.value!==""+f&&(s.value=""+f);else if(k==="submit"||k==="reset"){s.removeAttribute("value");return}a.hasOwnProperty("value")?on(s,a.type,f):a.hasOwnProperty("defaultValue")&&on(s,a.type,G(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(s.defaultChecked=!!a.defaultChecked)}function wt(s,a,f){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var k=a.type;if(!(k!=="submit"&&k!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+s._wrapperState.initialValue,f||a===s.value||(s.value=a),s.defaultValue=a}f=s.name,f!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,f!==""&&(s.name=f)}function on(s,a,f){(a!=="number"||we(s.ownerDocument)!==s)&&(f==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+f&&(s.defaultValue=""+f))}var Et=Array.isArray;function Vt(s,a,f,k){if(s=s.options,a){a={};for(var v=0;v<f.length;v++)a["$"+f[v]]=!0;for(f=0;f<s.length;f++)v=a.hasOwnProperty("$"+s[f].value),s[f].selected!==v&&(s[f].selected=v),v&&k&&(s[f].defaultSelected=!0)}else{for(f=""+G(f),a=null,v=0;v<s.length;v++){if(s[v].value===f){s[v].selected=!0,k&&(s[v].defaultSelected=!0);return}a!==null||s[v].disabled||(a=s[v])}a!==null&&(a.selected=!0)}}function Ft(s,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return q({},a,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function Ht(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(Et(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 Me(s,a){var f=G(a.value),k=G(a.defaultValue);f!=null&&(f=""+f,f!==s.value&&(s.value=f),a.defaultValue==null&&s.defaultValue!==f&&(s.defaultValue=f)),k!=null&&(s.defaultValue=""+k)}function St(s){var a=s.textContent;a===s._wrapperState.initialValue&&a!==""&&a!==null&&(s.value=a)}function sn(s){switch(s){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ln(s,a){return s==null||s==="http://www.w3.org/1999/xhtml"?sn(a):s==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var lt,jt=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,f,k,v){MSApp.execUnsafeLocalFunction(function(){return s(a,f,k,v)})}:s})(function(s,a){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=a;else{for(lt=lt||document.createElement("div"),lt.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=lt.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;a.firstChild;)s.appendChild(a.firstChild)}});function Kt(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},Dt=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(s){Dt.forEach(function(a){a=a+s.charAt(0).toUpperCase()+s.substring(1),xn[a]=xn[s]})});function jn(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 Qt(s,a){s=s.style;for(var f in a)if(a.hasOwnProperty(f)){var k=f.indexOf("--")===0,v=jn(f,a[f],k);f==="float"&&(f="cssFloat"),k?s.setProperty(f,v):s[f]=v}}var V=q({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function pe(s,a){if(a){if(V[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 Ye(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 nt=null;function yt(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var Jt=null,ye=null,Ae=null;function Yt(s){if(s=Xl(s)){if(typeof Jt!="function")throw Error(n(280));var a=s.stateNode;a&&(a=Mu(a),Jt(s.stateNode,s.type,a))}}function B(s){ye?Ae?Ae.push(s):Ae=[s]:ye=s}function me(){if(ye){var s=ye,a=Ae;if(Ae=ye=null,Yt(s),a)for(s=0;s<a.length;s++)Yt(a[s])}}function De(s,a){return s(a)}function Xe(){}var Pt=!1;function _t(s,a,f){if(Pt)return s(a,f);Pt=!0;try{return De(s,a,f)}finally{Pt=!1,(ye!==null||Ae!==null)&&(Xe(),me())}}function He(s,a){var f=s.stateNode;if(f===null)return null;var k=Mu(f);if(k===null)return null;f=k[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(k=!k.disabled)||(s=s.type,k=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!k;break e;default:s=!1}if(s)return null;if(f&&typeof f!="function")throw Error(n(231,a,typeof f));return f}var ze=!1;if(c)try{var qe={};Object.defineProperty(qe,"passive",{get:function(){ze=!0}}),window.addEventListener("test",qe,qe),window.removeEventListener("test",qe,qe)}catch{ze=!1}function ht(s,a,f,k,v,E,I,W,Q){var he=Array.prototype.slice.call(arguments,3);try{a.apply(f,he)}catch(Re){this.onError(Re)}}var Ct=!1,Bt=null,qt=!1,vn=null,On={onError:function(s){Ct=!0,Bt=s}};function Cn(s,a,f,k,v,E,I,W,Q){Ct=!1,Bt=null,ht.apply(On,arguments)}function Xn(s,a,f,k,v,E,I,W,Q){if(Cn.apply(this,arguments),Ct){if(Ct){var he=Bt;Ct=!1,Bt=null}else throw Error(n(198));qt||(qt=!0,vn=he)}}function Kn(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 se(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 Ne(s){if(Kn(s)!==s)throw Error(n(188))}function at(s){var a=s.alternate;if(!a){if(a=Kn(s),a===null)throw Error(n(188));return a!==s?null:s}for(var f=s,k=a;;){var v=f.return;if(v===null)break;var E=v.alternate;if(E===null){if(k=v.return,k!==null){f=k;continue}break}if(v.child===E.child){for(E=v.child;E;){if(E===f)return Ne(v),s;if(E===k)return Ne(v),a;E=E.sibling}throw Error(n(188))}if(f.return!==k.return)f=v,k=E;else{for(var I=!1,W=v.child;W;){if(W===f){I=!0,f=v,k=E;break}if(W===k){I=!0,k=v,f=E;break}W=W.sibling}if(!I){for(W=E.child;W;){if(W===f){I=!0,f=E,k=v;break}if(W===k){I=!0,k=E,f=v;break}W=W.sibling}if(!I)throw Error(n(189))}}if(f.alternate!==k)throw Error(n(190))}if(f.tag!==3)throw Error(n(188));return f.stateNode.current===f?s:a}function gt(s){return s=at(s),s!==null?Wt(s):null}function Wt(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var a=Wt(s);if(a!==null)return a;s=s.sibling}return null}var gn=t.unstable_scheduleCallback,kn=t.unstable_cancelCallback,tr=t.unstable_shouldYield,dn=t.unstable_requestPaint,fn=t.unstable_now,Nt=t.unstable_getCurrentPriorityLevel,Pr=t.unstable_ImmediatePriority,pt=t.unstable_UserBlockingPriority,In=t.unstable_NormalPriority,je=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,rt=null,et=null;function cn(s){if(et&&typeof et.onCommitFiberRoot=="function")try{et.onCommitFiberRoot(rt,s,void 0,(s.current.flags&128)===128)}catch{}}var wn=Math.clz32?Math.clz32:K,sr=Math.log,Lr=Math.LN2;function K(s){return s>>>=0,s===0?32:31-(sr(s)/Lr|0)|0}var fe=64,Qe=4194304;function At(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 mt(s,a){var f=s.pendingLanes;if(f===0)return 0;var k=0,v=s.suspendedLanes,E=s.pingedLanes,I=f&268435455;if(I!==0){var W=I&~v;W!==0?k=At(W):(E&=I,E!==0&&(k=At(E)))}else I=f&~v,I!==0?k=At(I):E!==0&&(k=At(E));if(k===0)return 0;if(a!==0&&a!==k&&(a&v)===0&&(v=k&-k,E=a&-a,v>=E||v===16&&(E&4194240)!==0))return a;if((k&4)!==0&&(k|=f&16),a=s.entangledLanes,a!==0)for(s=s.entanglements,a&=k;0<a;)f=31-wn(a),v=1<<f,k|=s[f],a&=~v;return k}function Zt(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,k=s.pingedLanes,v=s.expirationTimes,E=s.pendingLanes;0<E;){var I=31-wn(E),W=1<<I,Q=v[I];Q===-1?((W&f)===0||(W&k)!==0)&&(v[I]=Zt(W,a)):Q<=a&&(s.expiredLanes|=W),E&=~W}}function fr(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function yo(){var s=fe;return fe<<=1,(fe&4194240)===0&&(fe=64),s}function _r(s){for(var a=[],f=0;31>f;f++)a.push(s);return a}function vr(s,a,f){s.pendingLanes|=a,a!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,a=31-wn(a),s[a]=f}function br(s,a){var f=s.pendingLanes&~a;s.pendingLanes=a,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=a,s.mutableReadLanes&=a,s.entangledLanes&=a,a=s.entanglements;var k=s.eventTimes;for(s=s.expirationTimes;0<f;){var v=31-wn(f),E=1<<v;a[v]=0,k[v]=-1,s[v]=-1,f&=~E}}function lo(s,a){var f=s.entangledLanes|=a;for(s=s.entanglements;f;){var k=31-wn(f),v=1<<k;v&a|s[k]&a&&(s[k]|=a),f&=~v}}var Xt=0;function kt(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var ts,Mn,en,Zr,hr,Ie=!1,L=[],H=null,J=null,ve=null,Oe=new Map,Ke=new Map,It=[],bn="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 Nn(s,a){switch(s){case"focusin":case"focusout":H=null;break;case"dragenter":case"dragleave":J=null;break;case"mouseover":case"mouseout":ve=null;break;case"pointerover":case"pointerout":Oe.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ke.delete(a.pointerId)}}function Fn(s,a,f,k,v,E){return s===null||s.nativeEvent!==E?(s={blockedOn:a,domEventName:f,eventSystemFlags:k,nativeEvent:E,targetContainers:[v]},a!==null&&(a=Xl(a),a!==null&&Mn(a)),s):(s.eventSystemFlags|=k,a=s.targetContainers,v!==null&&a.indexOf(v)===-1&&a.push(v),s)}function ns(s,a,f,k,v){switch(a){case"focusin":return H=Fn(H,s,a,f,k,v),!0;case"dragenter":return J=Fn(J,s,a,f,k,v),!0;case"mouseover":return ve=Fn(ve,s,a,f,k,v),!0;case"pointerover":var E=v.pointerId;return Oe.set(E,Fn(Oe.get(E)||null,s,a,f,k,v)),!0;case"gotpointercapture":return E=v.pointerId,Ke.set(E,Fn(Ke.get(E)||null,s,a,f,k,v)),!0}return!1}function $n(s){var a=Ri(s.target);if(a!==null){var f=Kn(a);if(f!==null){if(a=f.tag,a===13){if(a=se(f),a!==null){s.blockedOn=a,hr(s.priority,function(){en(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 ms(s){if(s.blockedOn!==null)return!1;for(var a=s.targetContainers;0<a.length;){var f=Ni(s.domEventName,s.eventSystemFlags,a[0],s.nativeEvent);if(f===null){f=s.nativeEvent;var k=new f.constructor(f.type,f);nt=k,f.target.dispatchEvent(k),nt=null}else return a=Xl(f),a!==null&&Mn(a),s.blockedOn=f,!1;a.shift()}return!0}function $l(s,a,f){ms(s)&&f.delete(a)}function ma(){Ie=!1,H!==null&&ms(H)&&(H=null),J!==null&&ms(J)&&(J=null),ve!==null&&ms(ve)&&(ve=null),Oe.forEach($l),Ke.forEach($l)}function rs(s,a){s.blockedOn===a&&(s.blockedOn=null,Ie||(Ie=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ma)))}function Ms(s){function a(v){return rs(v,s)}if(0<L.length){rs(L[0],s);for(var f=1;f<L.length;f++){var k=L[f];k.blockedOn===s&&(k.blockedOn=null)}}for(H!==null&&rs(H,s),J!==null&&rs(J,s),ve!==null&&rs(ve,s),Oe.forEach(a),Ke.forEach(a),f=0;f<It.length;f++)k=It[f],k.blockedOn===s&&(k.blockedOn=null);for(;0<It.length&&(f=It[0],f.blockedOn===null);)$n(f),f.blockedOn===null&&It.shift()}var Po=j.ReactCurrentBatchConfig,_i=!0;function Rl(s,a,f,k){var v=Xt,E=Po.transition;Po.transition=null;try{Xt=1,Ol(s,a,f,k)}finally{Xt=v,Po.transition=E}}function Nr(s,a,f,k){var v=Xt,E=Po.transition;Po.transition=null;try{Xt=4,Ol(s,a,f,k)}finally{Xt=v,Po.transition=E}}function Ol(s,a,f,k){if(_i){var v=Ni(s,a,f,k);if(v===null)bh(s,a,k,ga,f),Nn(s,k);else if(ns(v,s,a,f,k))k.stopPropagation();else if(Nn(s,k),a&4&&-1<bn.indexOf(s)){for(;v!==null;){var E=Xl(v);if(E!==null&&ts(E),E=Ni(s,a,f,k),E===null&&bh(s,a,k,ga,f),E===v)break;v=E}v!==null&&k.stopPropagation()}else bh(s,a,k,null,f)}}var ga=null;function Ni(s,a,f,k){if(ga=null,s=yt(k),s=Ri(s),s!==null)if(a=Kn(s),a===null)s=null;else if(f=a.tag,f===13){if(s=se(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 ga=s,null}function ka(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(Nt()){case Pr:return 1;case pt:return 4;case In:case je:return 16;case Ve:return 536870912;default:return 16}default:return 16}}var zr=null,Ti=null,ji=null;function pu(){if(ji)return ji;var s,a=Ti,f=a.length,k,v="value"in zr?zr.value:zr.textContent,E=v.length;for(s=0;s<f&&a[s]===v[s];s++);var I=f-s;for(k=1;k<=I&&a[f-k]===v[E-k];k++);return ji=v.slice(s,1<k?1-k:void 0)}function Ps(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 wa(){return!0}function Ml(){return!1}function Fr(s){function a(f,k,v,E,I){this._reactName=f,this._targetInst=v,this.type=k,this.nativeEvent=E,this.target=I,this.currentTarget=null;for(var W in s)s.hasOwnProperty(W)&&(f=s[W],this[W]=f?f(E):E[W]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?wa:Ml,this.isPropagationStopped=Ml,this}return q(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=wa)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=wa)},persist:function(){},isPersistent:wa}),a}var gs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Pl=Fr(gs),Ls=q({},gs,{view:0,detail:0}),Tr=Fr(Ls),ya,va,ks,Ds=q({},Ls,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Na,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!==ks&&(ks&&s.type==="mousemove"?(ya=s.screenX-ks.screenX,va=s.screenY-ks.screenY):va=ya=0,ks=s),ya)},movementY:function(s){return"movementY"in s?s.movementY:va}}),Ci=Fr(Ds),Pn=q({},Ds,{dataTransfer:0}),mu=Fr(Pn),ba=q({},Ls,{relatedTarget:0}),Ai=Fr(ba),xa=q({},gs,{animationName:0,elapsedTime:0,pseudoElement:0}),Ea=Fr(xa),zs=q({},gs,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),gu=Fr(zs),Ll=q({},gs,{data:0}),Sa=Fr(Ll),ku={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Cw={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"},wu={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function _a(s){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(s):(s=wu[s])?!!a[s]:!1}function Na(){return _a}var yu=q({},Ls,{key:function(s){if(s.key){var a=ku[s.key]||s.key;if(a!=="Unidentified")return a}return s.type==="keypress"?(s=Ps(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Cw[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Na,charCode:function(s){return s.type==="keypress"?Ps(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Ps(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),vu=Fr(yu),ir=q({},Ds,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),bu=Fr(ir),Ta=q({},Ls,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Na}),Fs=Fr(Ta),Ii=q({},gs,{propertyName:0,elapsedTime:0,pseudoElement:0}),Dl=Fr(Ii),uh=q({},Ds,{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}),zl=Fr(uh),dh=[9,13,27,32],ja=c&&"CompositionEvent"in window,Bs=null;c&&"documentMode"in document&&(Bs=document.documentMode);var xu=c&&"TextEvent"in window&&!Bs,Fl=c&&(!ja||Bs&&8<Bs&&11>=Bs),ws=" ",Eu=!1;function Bl(s,a){switch(s){case"keyup":return dh.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Su(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Us=!1;function _u(s,a){switch(s){case"compositionend":return Su(a);case"keypress":return a.which!==32?null:(Eu=!0,ws);case"textInput":return s=a.data,s===ws&&Eu?null:s;default:return null}}function Ca(s,a){if(Us)return s==="compositionend"||!ja&&Bl(s,a)?(s=pu(),ji=Ti=zr=null,Us=!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 Fl&&a.locale!=="ko"?null:a.data;default:return null}}var Nu={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 Ul(s){var a=s&&s.nodeName&&s.nodeName.toLowerCase();return a==="input"?!!Nu[s.type]:a==="textarea"}function Hl(s,a,f,k){B(k),a=$u(a,"onChange"),0<a.length&&(f=new Pl("onChange","change",null,f,k),s.push({event:f,listeners:a}))}var Hs=null,Ws=null;function Tu(s){Hw(s,0)}function $i(s){var a=Oa(s);if(oe(a))return s}function U(s,a){if(s==="change")return a}var Ze=!1;if(c){var Lt;if(c){var Gt="oninput"in document;if(!Gt){var Bn=document.createElement("div");Bn.setAttribute("oninput","return;"),Gt=typeof Bn.oninput=="function"}Lt=Gt}else Lt=!1;Ze=Lt&&(!document.documentMode||9<document.documentMode)}function co(){Hs&&(Hs.detachEvent("onpropertychange",Wl),Ws=Hs=null)}function Wl(s){if(s.propertyName==="value"&&$i(Ws)){var a=[];Hl(a,Ws,s,yt(s)),_t(Tu,a)}}function vo(s,a,f){s==="focusin"?(co(),Hs=a,Ws=f,Hs.attachEvent("onpropertychange",Wl)):s==="focusout"&&co()}function fh(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return $i(Ws)}function hh(s,a){if(s==="click")return $i(a)}function ju(s,a){if(s==="input"||s==="change")return $i(a)}function pj(s,a){return s===a&&(s!==0||1/s===1/a)||s!==s&&a!==a}var Lo=typeof Object.is=="function"?Object.is:pj;function Kl(s,a){if(Lo(s,a))return!0;if(typeof s!="object"||s===null||typeof a!="object"||a===null)return!1;var f=Object.keys(s),k=Object.keys(a);if(f.length!==k.length)return!1;for(k=0;k<f.length;k++){var v=f[k];if(!u.call(a,v)||!Lo(s[v],a[v]))return!1}return!0}function Aw(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Iw(s,a){var f=Aw(s);s=0;for(var k;f;){if(f.nodeType===3){if(k=s+f.textContent.length,s<=a&&k>=a)return{node:f,offset:a-s};s=k}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=Aw(f)}}function $w(s,a){return s&&a?s===a?!0:s&&s.nodeType===3?!1:a&&a.nodeType===3?$w(s,a.parentNode):"contains"in s?s.contains(a):s.compareDocumentPosition?!!(s.compareDocumentPosition(a)&16):!1:!1}function Rw(){for(var s=window,a=we();a instanceof s.HTMLIFrameElement;){try{var f=typeof a.contentWindow.location.href=="string"}catch{f=!1}if(f)s=a.contentWindow;else break;a=we(s.document)}return a}function ph(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 mj(s){var a=Rw(),f=s.focusedElem,k=s.selectionRange;if(a!==f&&f&&f.ownerDocument&&$w(f.ownerDocument.documentElement,f)){if(k!==null&&ph(f)){if(a=k.start,s=k.end,s===void 0&&(s=a),"selectionStart"in f)f.selectionStart=a,f.selectionEnd=Math.min(s,f.value.length);else if(s=(a=f.ownerDocument||document)&&a.defaultView||window,s.getSelection){s=s.getSelection();var v=f.textContent.length,E=Math.min(k.start,v);k=k.end===void 0?E:Math.min(k.end,v),!s.extend&&E>k&&(v=k,k=E,E=v),v=Iw(f,E);var I=Iw(f,k);v&&I&&(s.rangeCount!==1||s.anchorNode!==v.node||s.anchorOffset!==v.offset||s.focusNode!==I.node||s.focusOffset!==I.offset)&&(a=a.createRange(),a.setStart(v.node,v.offset),s.removeAllRanges(),E>k?(s.addRange(a),s.extend(I.node,I.offset)):(a.setEnd(I.node,I.offset),s.addRange(a)))}}for(a=[],s=f;s=s.parentNode;)s.nodeType===1&&a.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof f.focus=="function"&&f.focus(),f=0;f<a.length;f++)s=a[f],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var gj=c&&"documentMode"in document&&11>=document.documentMode,Aa=null,mh=null,Zl=null,gh=!1;function Ow(s,a,f){var k=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;gh||Aa==null||Aa!==we(k)||(k=Aa,"selectionStart"in k&&ph(k)?k={start:k.selectionStart,end:k.selectionEnd}:(k=(k.ownerDocument&&k.ownerDocument.defaultView||window).getSelection(),k={anchorNode:k.anchorNode,anchorOffset:k.anchorOffset,focusNode:k.focusNode,focusOffset:k.focusOffset}),Zl&&Kl(Zl,k)||(Zl=k,k=$u(mh,"onSelect"),0<k.length&&(a=new Pl("onSelect","select",null,a,f),s.push({event:a,listeners:k}),a.target=Aa)))}function Cu(s,a){var f={};return f[s.toLowerCase()]=a.toLowerCase(),f["Webkit"+s]="webkit"+a,f["Moz"+s]="moz"+a,f}var Ia={animationend:Cu("Animation","AnimationEnd"),animationiteration:Cu("Animation","AnimationIteration"),animationstart:Cu("Animation","AnimationStart"),transitionend:Cu("Transition","TransitionEnd")},kh={},Mw={};c&&(Mw=document.createElement("div").style,"AnimationEvent"in window||(delete Ia.animationend.animation,delete Ia.animationiteration.animation,delete Ia.animationstart.animation),"TransitionEvent"in window||delete Ia.transitionend.transition);function Au(s){if(kh[s])return kh[s];if(!Ia[s])return s;var a=Ia[s],f;for(f in a)if(a.hasOwnProperty(f)&&f in Mw)return kh[s]=a[f];return s}var Pw=Au("animationend"),Lw=Au("animationiteration"),Dw=Au("animationstart"),zw=Au("transitionend"),Fw=new Map,Bw="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 Ks(s,a){Fw.set(s,a),i(a,[s])}for(var wh=0;wh<Bw.length;wh++){var yh=Bw[wh],kj=yh.toLowerCase(),wj=yh[0].toUpperCase()+yh.slice(1);Ks(kj,"on"+wj)}Ks(Pw,"onAnimationEnd"),Ks(Lw,"onAnimationIteration"),Ks(Dw,"onAnimationStart"),Ks("dblclick","onDoubleClick"),Ks("focusin","onFocus"),Ks("focusout","onBlur"),Ks(zw,"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 ql="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(" "),yj=new Set("cancel close invalid load scroll toggle".split(" ").concat(ql));function Uw(s,a,f){var k=s.type||"unknown-event";s.currentTarget=f,Xn(k,a,void 0,s),s.currentTarget=null}function Hw(s,a){a=(a&4)!==0;for(var f=0;f<s.length;f++){var k=s[f],v=k.event;k=k.listeners;e:{var E=void 0;if(a)for(var I=k.length-1;0<=I;I--){var W=k[I],Q=W.instance,he=W.currentTarget;if(W=W.listener,Q!==E&&v.isPropagationStopped())break e;Uw(v,W,he),E=Q}else for(I=0;I<k.length;I++){if(W=k[I],Q=W.instance,he=W.currentTarget,W=W.listener,Q!==E&&v.isPropagationStopped())break e;Uw(v,W,he),E=Q}}}if(qt)throw s=vn,qt=!1,vn=null,s}function Ln(s,a){var f=a[Th];f===void 0&&(f=a[Th]=new Set);var k=s+"__bubble";f.has(k)||(Ww(a,s,2,!1),f.add(k))}function vh(s,a,f){var k=0;a&&(k|=4),Ww(f,s,k,a)}var Iu="_reactListening"+Math.random().toString(36).slice(2);function Gl(s){if(!s[Iu]){s[Iu]=!0,r.forEach(function(f){f!=="selectionchange"&&(yj.has(f)||vh(f,!1,s),vh(f,!0,s))});var a=s.nodeType===9?s:s.ownerDocument;a===null||a[Iu]||(a[Iu]=!0,vh("selectionchange",!1,a))}}function Ww(s,a,f,k){switch(ka(a)){case 1:var v=Rl;break;case 4:v=Nr;break;default:v=Ol}f=v.bind(null,a,f,s),v=void 0,!ze||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(v=!0),k?v!==void 0?s.addEventListener(a,f,{capture:!0,passive:v}):s.addEventListener(a,f,!0):v!==void 0?s.addEventListener(a,f,{passive:v}):s.addEventListener(a,f,!1)}function bh(s,a,f,k,v){var E=k;if((a&1)===0&&(a&2)===0&&k!==null)e:for(;;){if(k===null)return;var I=k.tag;if(I===3||I===4){var W=k.stateNode.containerInfo;if(W===v||W.nodeType===8&&W.parentNode===v)break;if(I===4)for(I=k.return;I!==null;){var Q=I.tag;if((Q===3||Q===4)&&(Q=I.stateNode.containerInfo,Q===v||Q.nodeType===8&&Q.parentNode===v))return;I=I.return}for(;W!==null;){if(I=Ri(W),I===null)return;if(Q=I.tag,Q===5||Q===6){k=E=I;continue e}W=W.parentNode}}k=k.return}_t(function(){var he=E,Re=yt(f),Pe=[];e:{var $e=Fw.get(s);if($e!==void 0){var Je=Pl,ot=s;switch(s){case"keypress":if(Ps(f)===0)break e;case"keydown":case"keyup":Je=vu;break;case"focusin":ot="focus",Je=Ai;break;case"focusout":ot="blur",Je=Ai;break;case"beforeblur":case"afterblur":Je=Ai;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":Je=Ci;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Je=mu;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Je=Fs;break;case Pw:case Lw:case Dw:Je=Ea;break;case zw:Je=Dl;break;case"scroll":Je=Tr;break;case"wheel":Je=zl;break;case"copy":case"cut":case"paste":Je=gu;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Je=bu}var st=(a&4)!==0,Jn=!st&&s==="scroll",le=st?$e!==null?$e+"Capture":null:$e;st=[];for(var te=he,ce;te!==null;){ce=te;var Ue=ce.stateNode;if(ce.tag===5&&Ue!==null&&(ce=Ue,le!==null&&(Ue=He(te,le),Ue!=null&&st.push(Vl(te,Ue,ce)))),Jn)break;te=te.return}0<st.length&&($e=new Je($e,ot,null,f,Re),Pe.push({event:$e,listeners:st}))}}if((a&7)===0){e:{if($e=s==="mouseover"||s==="pointerover",Je=s==="mouseout"||s==="pointerout",$e&&f!==nt&&(ot=f.relatedTarget||f.fromElement)&&(Ri(ot)||ot[ys]))break e;if((Je||$e)&&($e=Re.window===Re?Re:($e=Re.ownerDocument)?$e.defaultView||$e.parentWindow:window,Je?(ot=f.relatedTarget||f.toElement,Je=he,ot=ot?Ri(ot):null,ot!==null&&(Jn=Kn(ot),ot!==Jn||ot.tag!==5&&ot.tag!==6)&&(ot=null)):(Je=null,ot=he),Je!==ot)){if(st=Ci,Ue="onMouseLeave",le="onMouseEnter",te="mouse",(s==="pointerout"||s==="pointerover")&&(st=bu,Ue="onPointerLeave",le="onPointerEnter",te="pointer"),Jn=Je==null?$e:Oa(Je),ce=ot==null?$e:Oa(ot),$e=new st(Ue,te+"leave",Je,f,Re),$e.target=Jn,$e.relatedTarget=ce,Ue=null,Ri(Re)===he&&(st=new st(le,te+"enter",ot,f,Re),st.target=ce,st.relatedTarget=Jn,Ue=st),Jn=Ue,Je&&ot)t:{for(st=Je,le=ot,te=0,ce=st;ce;ce=$a(ce))te++;for(ce=0,Ue=le;Ue;Ue=$a(Ue))ce++;for(;0<te-ce;)st=$a(st),te--;for(;0<ce-te;)le=$a(le),ce--;for(;te--;){if(st===le||le!==null&&st===le.alternate)break t;st=$a(st),le=$a(le)}st=null}else st=null;Je!==null&&Kw(Pe,$e,Je,st,!1),ot!==null&&Jn!==null&&Kw(Pe,Jn,ot,st,!0)}}e:{if($e=he?Oa(he):window,Je=$e.nodeName&&$e.nodeName.toLowerCase(),Je==="select"||Je==="input"&&$e.type==="file")var ct=U;else if(Ul($e))if(Ze)ct=ju;else{ct=fh;var vt=vo}else(Je=$e.nodeName)&&Je.toLowerCase()==="input"&&($e.type==="checkbox"||$e.type==="radio")&&(ct=hh);if(ct&&(ct=ct(s,he))){Hl(Pe,ct,f,Re);break e}vt&&vt(s,$e,he),s==="focusout"&&(vt=$e._wrapperState)&&vt.controlled&&$e.type==="number"&&on($e,"number",$e.value)}switch(vt=he?Oa(he):window,s){case"focusin":(Ul(vt)||vt.contentEditable==="true")&&(Aa=vt,mh=he,Zl=null);break;case"focusout":Zl=mh=Aa=null;break;case"mousedown":gh=!0;break;case"contextmenu":case"mouseup":case"dragend":gh=!1,Ow(Pe,f,Re);break;case"selectionchange":if(gj)break;case"keydown":case"keyup":Ow(Pe,f,Re)}var bt;if(ja)e:{switch(s){case"compositionstart":var Ot="onCompositionStart";break e;case"compositionend":Ot="onCompositionEnd";break e;case"compositionupdate":Ot="onCompositionUpdate";break e}Ot=void 0}else Us?Bl(s,f)&&(Ot="onCompositionEnd"):s==="keydown"&&f.keyCode===229&&(Ot="onCompositionStart");Ot&&(Fl&&f.locale!=="ko"&&(Us||Ot!=="onCompositionStart"?Ot==="onCompositionEnd"&&Us&&(bt=pu()):(zr=Re,Ti="value"in zr?zr.value:zr.textContent,Us=!0)),vt=$u(he,Ot),0<vt.length&&(Ot=new Sa(Ot,s,null,f,Re),Pe.push({event:Ot,listeners:vt}),bt?Ot.data=bt:(bt=Su(f),bt!==null&&(Ot.data=bt)))),(bt=xu?_u(s,f):Ca(s,f))&&(he=$u(he,"onBeforeInput"),0<he.length&&(Re=new Sa("onBeforeInput","beforeinput",null,f,Re),Pe.push({event:Re,listeners:he}),Re.data=bt))}Hw(Pe,a)})}function Vl(s,a,f){return{instance:s,listener:a,currentTarget:f}}function $u(s,a){for(var f=a+"Capture",k=[];s!==null;){var v=s,E=v.stateNode;v.tag===5&&E!==null&&(v=E,E=He(s,f),E!=null&&k.unshift(Vl(s,E,v)),E=He(s,a),E!=null&&k.push(Vl(s,E,v))),s=s.return}return k}function $a(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function Kw(s,a,f,k,v){for(var E=a._reactName,I=[];f!==null&&f!==k;){var W=f,Q=W.alternate,he=W.stateNode;if(Q!==null&&Q===k)break;W.tag===5&&he!==null&&(W=he,v?(Q=He(f,E),Q!=null&&I.unshift(Vl(f,Q,W))):v||(Q=He(f,E),Q!=null&&I.push(Vl(f,Q,W)))),f=f.return}I.length!==0&&s.push({event:a,listeners:I})}var vj=/\r\n?/g,bj=/\u0000|\uFFFD/g;function Zw(s){return(typeof s=="string"?s:""+s).replace(vj,`
|
|
39
|
-
`).replace(bj,"")}function Ru(s,a,f){if(a=Zw(a),Zw(s)!==a&&f)throw Error(n(425))}function Ou(){}var xh=null,Eh=null;function Sh(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 _h=typeof setTimeout=="function"?setTimeout:void 0,xj=typeof clearTimeout=="function"?clearTimeout:void 0,qw=typeof Promise=="function"?Promise:void 0,Ej=typeof queueMicrotask=="function"?queueMicrotask:typeof qw<"u"?function(s){return qw.resolve(null).then(s).catch(Sj)}:_h;function Sj(s){setTimeout(function(){throw s})}function Nh(s,a){var f=a,k=0;do{var v=f.nextSibling;if(s.removeChild(f),v&&v.nodeType===8)if(f=v.data,f==="/$"){if(k===0){s.removeChild(v),Ms(a);return}k--}else f!=="$"&&f!=="$?"&&f!=="$!"||k++;f=v}while(f);Ms(a)}function Zs(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 Gw(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 Ra=Math.random().toString(36).slice(2),os="__reactFiber$"+Ra,Yl="__reactProps$"+Ra,ys="__reactContainer$"+Ra,Th="__reactEvents$"+Ra,_j="__reactListeners$"+Ra,Nj="__reactHandles$"+Ra;function Ri(s){var a=s[os];if(a)return a;for(var f=s.parentNode;f;){if(a=f[ys]||f[os]){if(f=a.alternate,a.child!==null||f!==null&&f.child!==null)for(s=Gw(s);s!==null;){if(f=s[os])return f;s=Gw(s)}return a}s=f,f=s.parentNode}return null}function Xl(s){return s=s[os]||s[ys],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function Oa(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function Mu(s){return s[Yl]||null}var jh=[],Ma=-1;function qs(s){return{current:s}}function Dn(s){0>Ma||(s.current=jh[Ma],jh[Ma]=null,Ma--)}function Rn(s,a){Ma++,jh[Ma]=s.current,s.current=a}var Gs={},jr=qs(Gs),qr=qs(!1),Oi=Gs;function Pa(s,a){var f=s.type.contextTypes;if(!f)return Gs;var k=s.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===a)return k.__reactInternalMemoizedMaskedChildContext;var v={},E;for(E in f)v[E]=a[E];return k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=a,s.__reactInternalMemoizedMaskedChildContext=v),v}function Gr(s){return s=s.childContextTypes,s!=null}function Pu(){Dn(qr),Dn(jr)}function Vw(s,a,f){if(jr.current!==Gs)throw Error(n(168));Rn(jr,a),Rn(qr,f)}function Yw(s,a,f){var k=s.stateNode;if(a=a.childContextTypes,typeof k.getChildContext!="function")return f;k=k.getChildContext();for(var v in k)if(!(v in a))throw Error(n(108,ae(s)||"Unknown",v));return q({},f,k)}function Lu(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||Gs,Oi=jr.current,Rn(jr,s),Rn(qr,qr.current),!0}function Xw(s,a,f){var k=s.stateNode;if(!k)throw Error(n(169));f?(s=Yw(s,a,Oi),k.__reactInternalMemoizedMergedChildContext=s,Dn(qr),Dn(jr),Rn(jr,s)):Dn(qr),Rn(qr,f)}var vs=null,Du=!1,Ch=!1;function Qw(s){vs===null?vs=[s]:vs.push(s)}function Tj(s){Du=!0,Qw(s)}function Vs(){if(!Ch&&vs!==null){Ch=!0;var s=0,a=Xt;try{var f=vs;for(Xt=1;s<f.length;s++){var k=f[s];do k=k(!0);while(k!==null)}vs=null,Du=!1}catch(v){throw vs!==null&&(vs=vs.slice(s+1)),gn(Pr,Vs),v}finally{Xt=a,Ch=!1}}return null}var La=[],Da=0,zu=null,Fu=0,bo=[],xo=0,Mi=null,bs=1,xs="";function Pi(s,a){La[Da++]=Fu,La[Da++]=zu,zu=s,Fu=a}function Jw(s,a,f){bo[xo++]=bs,bo[xo++]=xs,bo[xo++]=Mi,Mi=s;var k=bs;s=xs;var v=32-wn(k)-1;k&=~(1<<v),f+=1;var E=32-wn(a)+v;if(30<E){var I=v-v%5;E=(k&(1<<I)-1).toString(32),k>>=I,v-=I,bs=1<<32-wn(a)+v|f<<v|k,xs=E+s}else bs=1<<E|f<<v|k,xs=s}function Ah(s){s.return!==null&&(Pi(s,1),Jw(s,1,0))}function Ih(s){for(;s===zu;)zu=La[--Da],La[Da]=null,Fu=La[--Da],La[Da]=null;for(;s===Mi;)Mi=bo[--xo],bo[xo]=null,xs=bo[--xo],bo[xo]=null,bs=bo[--xo],bo[xo]=null}var uo=null,fo=null,Un=!1,Do=null;function ey(s,a){var f=No(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 ty(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=Zs(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=Mi!==null?{id:bs,overflow:xs}:null,s.memoizedState={dehydrated:a,treeContext:f,retryLane:1073741824},f=No(18,null,null,0),f.stateNode=a,f.return=s,s.child=f,uo=s,fo=null,!0):!1;default:return!1}}function $h(s){return(s.mode&1)!==0&&(s.flags&128)===0}function Rh(s){if(Un){var a=fo;if(a){var f=a;if(!ty(s,a)){if($h(s))throw Error(n(418));a=Zs(f.nextSibling);var k=uo;a&&ty(s,a)?ey(k,f):(s.flags=s.flags&-4097|2,Un=!1,uo=s)}}else{if($h(s))throw Error(n(418));s.flags=s.flags&-4097|2,Un=!1,uo=s}}}function ny(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;uo=s}function Bu(s){if(s!==uo)return!1;if(!Un)return ny(s),Un=!0,!1;var a;if((a=s.tag!==3)&&!(a=s.tag!==5)&&(a=s.type,a=a!=="head"&&a!=="body"&&!Sh(s.type,s.memoizedProps)),a&&(a=fo)){if($h(s))throw ry(),Error(n(418));for(;a;)ey(s,a),a=Zs(a.nextSibling)}if(ny(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=Zs(s.nextSibling);break e}a--}else f!=="$"&&f!=="$!"&&f!=="$?"||a++}s=s.nextSibling}fo=null}}else fo=uo?Zs(s.stateNode.nextSibling):null;return!0}function ry(){for(var s=fo;s;)s=Zs(s.nextSibling)}function za(){fo=uo=null,Un=!1}function Oh(s){Do===null?Do=[s]:Do.push(s)}var jj=j.ReactCurrentBatchConfig;function Ql(s,a,f){if(s=f.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(f._owner){if(f=f._owner,f){if(f.tag!==1)throw Error(n(309));var k=f.stateNode}if(!k)throw Error(n(147,s));var v=k,E=""+s;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===E?a.ref:(a=function(I){var W=v.refs;I===null?delete W[E]:W[E]=I},a._stringRef=E,a)}if(typeof s!="string")throw Error(n(284));if(!f._owner)throw Error(n(290,s))}return s}function Uu(s,a){throw s=Object.prototype.toString.call(a),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":s))}function oy(s){var a=s._init;return a(s._payload)}function sy(s){function a(le,te){if(s){var ce=le.deletions;ce===null?(le.deletions=[te],le.flags|=16):ce.push(te)}}function f(le,te){if(!s)return null;for(;te!==null;)a(le,te),te=te.sibling;return null}function k(le,te){for(le=new Map;te!==null;)te.key!==null?le.set(te.key,te):le.set(te.index,te),te=te.sibling;return le}function v(le,te){return le=ri(le,te),le.index=0,le.sibling=null,le}function E(le,te,ce){return le.index=ce,s?(ce=le.alternate,ce!==null?(ce=ce.index,ce<te?(le.flags|=2,te):ce):(le.flags|=2,te)):(le.flags|=1048576,te)}function I(le){return s&&le.alternate===null&&(le.flags|=2),le}function W(le,te,ce,Ue){return te===null||te.tag!==6?(te=_p(ce,le.mode,Ue),te.return=le,te):(te=v(te,ce),te.return=le,te)}function Q(le,te,ce,Ue){var ct=ce.type;return ct===R?Re(le,te,ce.props.children,Ue,ce.key):te!==null&&(te.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===be&&oy(ct)===te.type)?(Ue=v(te,ce.props),Ue.ref=Ql(le,te,ce),Ue.return=le,Ue):(Ue=fd(ce.type,ce.key,ce.props,null,le.mode,Ue),Ue.ref=Ql(le,te,ce),Ue.return=le,Ue)}function he(le,te,ce,Ue){return te===null||te.tag!==4||te.stateNode.containerInfo!==ce.containerInfo||te.stateNode.implementation!==ce.implementation?(te=Np(ce,le.mode,Ue),te.return=le,te):(te=v(te,ce.children||[]),te.return=le,te)}function Re(le,te,ce,Ue,ct){return te===null||te.tag!==7?(te=Wi(ce,le.mode,Ue,ct),te.return=le,te):(te=v(te,ce),te.return=le,te)}function Pe(le,te,ce){if(typeof te=="string"&&te!==""||typeof te=="number")return te=_p(""+te,le.mode,ce),te.return=le,te;if(typeof te=="object"&&te!==null){switch(te.$$typeof){case $:return ce=fd(te.type,te.key,te.props,null,le.mode,ce),ce.ref=Ql(le,null,te),ce.return=le,ce;case P:return te=Np(te,le.mode,ce),te.return=le,te;case be:var Ue=te._init;return Pe(le,Ue(te._payload),ce)}if(Et(te)||Y(te))return te=Wi(te,le.mode,ce,null),te.return=le,te;Uu(le,te)}return null}function $e(le,te,ce,Ue){var ct=te!==null?te.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return ct!==null?null:W(le,te,""+ce,Ue);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:return ce.key===ct?Q(le,te,ce,Ue):null;case P:return ce.key===ct?he(le,te,ce,Ue):null;case be:return ct=ce._init,$e(le,te,ct(ce._payload),Ue)}if(Et(ce)||Y(ce))return ct!==null?null:Re(le,te,ce,Ue,null);Uu(le,ce)}return null}function Je(le,te,ce,Ue,ct){if(typeof Ue=="string"&&Ue!==""||typeof Ue=="number")return le=le.get(ce)||null,W(te,le,""+Ue,ct);if(typeof Ue=="object"&&Ue!==null){switch(Ue.$$typeof){case $:return le=le.get(Ue.key===null?ce:Ue.key)||null,Q(te,le,Ue,ct);case P:return le=le.get(Ue.key===null?ce:Ue.key)||null,he(te,le,Ue,ct);case be:var vt=Ue._init;return Je(le,te,ce,vt(Ue._payload),ct)}if(Et(Ue)||Y(Ue))return le=le.get(ce)||null,Re(te,le,Ue,ct,null);Uu(te,Ue)}return null}function ot(le,te,ce,Ue){for(var ct=null,vt=null,bt=te,Ot=te=0,gr=null;bt!==null&&Ot<ce.length;Ot++){bt.index>Ot?(gr=bt,bt=null):gr=bt.sibling;var mn=$e(le,bt,ce[Ot],Ue);if(mn===null){bt===null&&(bt=gr);break}s&&bt&&mn.alternate===null&&a(le,bt),te=E(mn,te,Ot),vt===null?ct=mn:vt.sibling=mn,vt=mn,bt=gr}if(Ot===ce.length)return f(le,bt),Un&&Pi(le,Ot),ct;if(bt===null){for(;Ot<ce.length;Ot++)bt=Pe(le,ce[Ot],Ue),bt!==null&&(te=E(bt,te,Ot),vt===null?ct=bt:vt.sibling=bt,vt=bt);return Un&&Pi(le,Ot),ct}for(bt=k(le,bt);Ot<ce.length;Ot++)gr=Je(bt,le,Ot,ce[Ot],Ue),gr!==null&&(s&&gr.alternate!==null&&bt.delete(gr.key===null?Ot:gr.key),te=E(gr,te,Ot),vt===null?ct=gr:vt.sibling=gr,vt=gr);return s&&bt.forEach(function(oi){return a(le,oi)}),Un&&Pi(le,Ot),ct}function st(le,te,ce,Ue){var ct=Y(ce);if(typeof ct!="function")throw Error(n(150));if(ce=ct.call(ce),ce==null)throw Error(n(151));for(var vt=ct=null,bt=te,Ot=te=0,gr=null,mn=ce.next();bt!==null&&!mn.done;Ot++,mn=ce.next()){bt.index>Ot?(gr=bt,bt=null):gr=bt.sibling;var oi=$e(le,bt,mn.value,Ue);if(oi===null){bt===null&&(bt=gr);break}s&&bt&&oi.alternate===null&&a(le,bt),te=E(oi,te,Ot),vt===null?ct=oi:vt.sibling=oi,vt=oi,bt=gr}if(mn.done)return f(le,bt),Un&&Pi(le,Ot),ct;if(bt===null){for(;!mn.done;Ot++,mn=ce.next())mn=Pe(le,mn.value,Ue),mn!==null&&(te=E(mn,te,Ot),vt===null?ct=mn:vt.sibling=mn,vt=mn);return Un&&Pi(le,Ot),ct}for(bt=k(le,bt);!mn.done;Ot++,mn=ce.next())mn=Je(bt,le,Ot,mn.value,Ue),mn!==null&&(s&&mn.alternate!==null&&bt.delete(mn.key===null?Ot:mn.key),te=E(mn,te,Ot),vt===null?ct=mn:vt.sibling=mn,vt=mn);return s&&bt.forEach(function(aC){return a(le,aC)}),Un&&Pi(le,Ot),ct}function Jn(le,te,ce,Ue){if(typeof ce=="object"&&ce!==null&&ce.type===R&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case $:e:{for(var ct=ce.key,vt=te;vt!==null;){if(vt.key===ct){if(ct=ce.type,ct===R){if(vt.tag===7){f(le,vt.sibling),te=v(vt,ce.props.children),te.return=le,le=te;break e}}else if(vt.elementType===ct||typeof ct=="object"&&ct!==null&&ct.$$typeof===be&&oy(ct)===vt.type){f(le,vt.sibling),te=v(vt,ce.props),te.ref=Ql(le,vt,ce),te.return=le,le=te;break e}f(le,vt);break}else a(le,vt);vt=vt.sibling}ce.type===R?(te=Wi(ce.props.children,le.mode,Ue,ce.key),te.return=le,le=te):(Ue=fd(ce.type,ce.key,ce.props,null,le.mode,Ue),Ue.ref=Ql(le,te,ce),Ue.return=le,le=Ue)}return I(le);case P:e:{for(vt=ce.key;te!==null;){if(te.key===vt)if(te.tag===4&&te.stateNode.containerInfo===ce.containerInfo&&te.stateNode.implementation===ce.implementation){f(le,te.sibling),te=v(te,ce.children||[]),te.return=le,le=te;break e}else{f(le,te);break}else a(le,te);te=te.sibling}te=Np(ce,le.mode,Ue),te.return=le,le=te}return I(le);case be:return vt=ce._init,Jn(le,te,vt(ce._payload),Ue)}if(Et(ce))return ot(le,te,ce,Ue);if(Y(ce))return st(le,te,ce,Ue);Uu(le,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,te!==null&&te.tag===6?(f(le,te.sibling),te=v(te,ce),te.return=le,le=te):(f(le,te),te=_p(ce,le.mode,Ue),te.return=le,le=te),I(le)):f(le,te)}return Jn}var Fa=sy(!0),iy=sy(!1),Hu=qs(null),Wu=null,Ba=null,Mh=null;function Ph(){Mh=Ba=Wu=null}function Lh(s){var a=Hu.current;Dn(Hu),s._currentValue=a}function Dh(s,a,f){for(;s!==null;){var k=s.alternate;if((s.childLanes&a)!==a?(s.childLanes|=a,k!==null&&(k.childLanes|=a)):k!==null&&(k.childLanes&a)!==a&&(k.childLanes|=a),s===f)break;s=s.return}}function Ua(s,a){Wu=s,Mh=Ba=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&a)!==0&&(Vr=!0),s.firstContext=null)}function Eo(s){var a=s._currentValue;if(Mh!==s)if(s={context:s,memoizedValue:a,next:null},Ba===null){if(Wu===null)throw Error(n(308));Ba=s,Wu.dependencies={lanes:0,firstContext:s}}else Ba=Ba.next=s;return a}var Li=null;function zh(s){Li===null?Li=[s]:Li.push(s)}function ay(s,a,f,k){var v=a.interleaved;return v===null?(f.next=f,zh(a)):(f.next=v.next,v.next=f),a.interleaved=f,Es(s,k)}function Es(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 Ys=!1;function Fh(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ly(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 Ss(s,a){return{eventTime:s,lane:a,tag:0,payload:null,callback:null,next:null}}function Xs(s,a,f){var k=s.updateQueue;if(k===null)return null;if(k=k.shared,(hn&2)!==0){var v=k.pending;return v===null?a.next=a:(a.next=v.next,v.next=a),k.pending=a,Es(s,f)}return v=k.interleaved,v===null?(a.next=a,zh(k)):(a.next=v.next,v.next=a),k.interleaved=a,Es(s,f)}function Ku(s,a,f){if(a=a.updateQueue,a!==null&&(a=a.shared,(f&4194240)!==0)){var k=a.lanes;k&=s.pendingLanes,f|=k,a.lanes=f,lo(s,f)}}function cy(s,a){var f=s.updateQueue,k=s.alternate;if(k!==null&&(k=k.updateQueue,f===k)){var v=null,E=null;if(f=f.firstBaseUpdate,f!==null){do{var I={eventTime:f.eventTime,lane:f.lane,tag:f.tag,payload:f.payload,callback:f.callback,next:null};E===null?v=E=I:E=E.next=I,f=f.next}while(f!==null);E===null?v=E=a:E=E.next=a}else v=E=a;f={baseState:k.baseState,firstBaseUpdate:v,lastBaseUpdate:E,shared:k.shared,effects:k.effects},s.updateQueue=f;return}s=f.lastBaseUpdate,s===null?f.firstBaseUpdate=a:s.next=a,f.lastBaseUpdate=a}function Zu(s,a,f,k){var v=s.updateQueue;Ys=!1;var E=v.firstBaseUpdate,I=v.lastBaseUpdate,W=v.shared.pending;if(W!==null){v.shared.pending=null;var Q=W,he=Q.next;Q.next=null,I===null?E=he:I.next=he,I=Q;var Re=s.alternate;Re!==null&&(Re=Re.updateQueue,W=Re.lastBaseUpdate,W!==I&&(W===null?Re.firstBaseUpdate=he:W.next=he,Re.lastBaseUpdate=Q))}if(E!==null){var Pe=v.baseState;I=0,Re=he=Q=null,W=E;do{var $e=W.lane,Je=W.eventTime;if((k&$e)===$e){Re!==null&&(Re=Re.next={eventTime:Je,lane:0,tag:W.tag,payload:W.payload,callback:W.callback,next:null});e:{var ot=s,st=W;switch($e=a,Je=f,st.tag){case 1:if(ot=st.payload,typeof ot=="function"){Pe=ot.call(Je,Pe,$e);break e}Pe=ot;break e;case 3:ot.flags=ot.flags&-65537|128;case 0:if(ot=st.payload,$e=typeof ot=="function"?ot.call(Je,Pe,$e):ot,$e==null)break e;Pe=q({},Pe,$e);break e;case 2:Ys=!0}}W.callback!==null&&W.lane!==0&&(s.flags|=64,$e=v.effects,$e===null?v.effects=[W]:$e.push(W))}else Je={eventTime:Je,lane:$e,tag:W.tag,payload:W.payload,callback:W.callback,next:null},Re===null?(he=Re=Je,Q=Pe):Re=Re.next=Je,I|=$e;if(W=W.next,W===null){if(W=v.shared.pending,W===null)break;$e=W,W=$e.next,$e.next=null,v.lastBaseUpdate=$e,v.shared.pending=null}}while(!0);if(Re===null&&(Q=Pe),v.baseState=Q,v.firstBaseUpdate=he,v.lastBaseUpdate=Re,a=v.shared.interleaved,a!==null){v=a;do I|=v.lane,v=v.next;while(v!==a)}else E===null&&(v.shared.lanes=0);Fi|=I,s.lanes=I,s.memoizedState=Pe}}function uy(s,a,f){if(s=a.effects,a.effects=null,s!==null)for(a=0;a<s.length;a++){var k=s[a],v=k.callback;if(v!==null){if(k.callback=null,k=f,typeof v!="function")throw Error(n(191,v));v.call(k)}}}var Jl={},ss=qs(Jl),ec=qs(Jl),tc=qs(Jl);function Di(s){if(s===Jl)throw Error(n(174));return s}function Bh(s,a){switch(Rn(tc,a),Rn(ec,s),Rn(ss,Jl),s=a.nodeType,s){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:ln(null,"");break;default:s=s===8?a.parentNode:a,a=s.namespaceURI||null,s=s.tagName,a=ln(a,s)}Dn(ss),Rn(ss,a)}function Ha(){Dn(ss),Dn(ec),Dn(tc)}function dy(s){Di(tc.current);var a=Di(ss.current),f=ln(a,s.type);a!==f&&(Rn(ec,s),Rn(ss,f))}function Uh(s){ec.current===s&&(Dn(ss),Dn(ec))}var Zn=qs(0);function qu(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 Hh=[];function Wh(){for(var s=0;s<Hh.length;s++)Hh[s]._workInProgressVersionPrimary=null;Hh.length=0}var Gu=j.ReactCurrentDispatcher,Kh=j.ReactCurrentBatchConfig,zi=0,qn=null,ar=null,pr=null,Vu=!1,nc=!1,rc=0,Cj=0;function Cr(){throw Error(n(321))}function Zh(s,a){if(a===null)return!1;for(var f=0;f<a.length&&f<s.length;f++)if(!Lo(s[f],a[f]))return!1;return!0}function qh(s,a,f,k,v,E){if(zi=E,qn=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Gu.current=s===null||s.memoizedState===null?Rj:Oj,s=f(k,v),nc){E=0;do{if(nc=!1,rc=0,25<=E)throw Error(n(301));E+=1,pr=ar=null,a.updateQueue=null,Gu.current=Mj,s=f(k,v)}while(nc)}if(Gu.current=Qu,a=ar!==null&&ar.next!==null,zi=0,pr=ar=qn=null,Vu=!1,a)throw Error(n(300));return s}function Gh(){var s=rc!==0;return rc=0,s}function is(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return pr===null?qn.memoizedState=pr=s:pr=pr.next=s,pr}function So(){if(ar===null){var s=qn.alternate;s=s!==null?s.memoizedState:null}else s=ar.next;var a=pr===null?qn.memoizedState:pr.next;if(a!==null)pr=a,ar=s;else{if(s===null)throw Error(n(310));ar=s,s={memoizedState:ar.memoizedState,baseState:ar.baseState,baseQueue:ar.baseQueue,queue:ar.queue,next:null},pr===null?qn.memoizedState=pr=s:pr=pr.next=s}return pr}function oc(s,a){return typeof a=="function"?a(s):a}function Vh(s){var a=So(),f=a.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=s;var k=ar,v=k.baseQueue,E=f.pending;if(E!==null){if(v!==null){var I=v.next;v.next=E.next,E.next=I}k.baseQueue=v=E,f.pending=null}if(v!==null){E=v.next,k=k.baseState;var W=I=null,Q=null,he=E;do{var Re=he.lane;if((zi&Re)===Re)Q!==null&&(Q=Q.next={lane:0,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),k=he.hasEagerState?he.eagerState:s(k,he.action);else{var Pe={lane:Re,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null};Q===null?(W=Q=Pe,I=k):Q=Q.next=Pe,qn.lanes|=Re,Fi|=Re}he=he.next}while(he!==null&&he!==E);Q===null?I=k:Q.next=W,Lo(k,a.memoizedState)||(Vr=!0),a.memoizedState=k,a.baseState=I,a.baseQueue=Q,f.lastRenderedState=k}if(s=f.interleaved,s!==null){v=s;do E=v.lane,qn.lanes|=E,Fi|=E,v=v.next;while(v!==s)}else v===null&&(f.lanes=0);return[a.memoizedState,f.dispatch]}function Yh(s){var a=So(),f=a.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=s;var k=f.dispatch,v=f.pending,E=a.memoizedState;if(v!==null){f.pending=null;var I=v=v.next;do E=s(E,I.action),I=I.next;while(I!==v);Lo(E,a.memoizedState)||(Vr=!0),a.memoizedState=E,a.baseQueue===null&&(a.baseState=E),f.lastRenderedState=E}return[E,k]}function fy(){}function hy(s,a){var f=qn,k=So(),v=a(),E=!Lo(k.memoizedState,v);if(E&&(k.memoizedState=v,Vr=!0),k=k.queue,Xh(gy.bind(null,f,k,s),[s]),k.getSnapshot!==a||E||pr!==null&&pr.memoizedState.tag&1){if(f.flags|=2048,sc(9,my.bind(null,f,k,v,a),void 0,null),mr===null)throw Error(n(349));(zi&30)!==0||py(f,a,v)}return v}function py(s,a,f){s.flags|=16384,s={getSnapshot:a,value:f},a=qn.updateQueue,a===null?(a={lastEffect:null,stores:null},qn.updateQueue=a,a.stores=[s]):(f=a.stores,f===null?a.stores=[s]:f.push(s))}function my(s,a,f,k){a.value=f,a.getSnapshot=k,ky(a)&&wy(s)}function gy(s,a,f){return f(function(){ky(a)&&wy(s)})}function ky(s){var a=s.getSnapshot;s=s.value;try{var f=a();return!Lo(s,f)}catch{return!0}}function wy(s){var a=Es(s,1);a!==null&&Uo(a,s,1,-1)}function yy(s){var a=is();return typeof s=="function"&&(s=s()),a.memoizedState=a.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:oc,lastRenderedState:s},a.queue=s,s=s.dispatch=$j.bind(null,qn,s),[a.memoizedState,s]}function sc(s,a,f,k){return s={tag:s,create:a,destroy:f,deps:k,next:null},a=qn.updateQueue,a===null?(a={lastEffect:null,stores:null},qn.updateQueue=a,a.lastEffect=s.next=s):(f=a.lastEffect,f===null?a.lastEffect=s.next=s:(k=f.next,f.next=s,s.next=k,a.lastEffect=s)),s}function vy(){return So().memoizedState}function Yu(s,a,f,k){var v=is();qn.flags|=s,v.memoizedState=sc(1|a,f,void 0,k===void 0?null:k)}function Xu(s,a,f,k){var v=So();k=k===void 0?null:k;var E=void 0;if(ar!==null){var I=ar.memoizedState;if(E=I.destroy,k!==null&&Zh(k,I.deps)){v.memoizedState=sc(a,f,E,k);return}}qn.flags|=s,v.memoizedState=sc(1|a,f,E,k)}function by(s,a){return Yu(8390656,8,s,a)}function Xh(s,a){return Xu(2048,8,s,a)}function xy(s,a){return Xu(4,2,s,a)}function Ey(s,a){return Xu(4,4,s,a)}function Sy(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 _y(s,a,f){return f=f!=null?f.concat([s]):null,Xu(4,4,Sy.bind(null,a,s),f)}function Qh(){}function Ny(s,a){var f=So();a=a===void 0?null:a;var k=f.memoizedState;return k!==null&&a!==null&&Zh(a,k[1])?k[0]:(f.memoizedState=[s,a],s)}function Ty(s,a){var f=So();a=a===void 0?null:a;var k=f.memoizedState;return k!==null&&a!==null&&Zh(a,k[1])?k[0]:(s=s(),f.memoizedState=[s,a],s)}function jy(s,a,f){return(zi&21)===0?(s.baseState&&(s.baseState=!1,Vr=!0),s.memoizedState=f):(Lo(f,a)||(f=yo(),qn.lanes|=f,Fi|=f,s.baseState=!0),a)}function Aj(s,a){var f=Xt;Xt=f!==0&&4>f?f:4,s(!0);var k=Kh.transition;Kh.transition={};try{s(!1),a()}finally{Xt=f,Kh.transition=k}}function Cy(){return So().memoizedState}function Ij(s,a,f){var k=ti(s);if(f={lane:k,action:f,hasEagerState:!1,eagerState:null,next:null},Ay(s))Iy(a,f);else if(f=ay(s,a,f,k),f!==null){var v=Ur();Uo(f,s,k,v),$y(f,a,k)}}function $j(s,a,f){var k=ti(s),v={lane:k,action:f,hasEagerState:!1,eagerState:null,next:null};if(Ay(s))Iy(a,v);else{var E=s.alternate;if(s.lanes===0&&(E===null||E.lanes===0)&&(E=a.lastRenderedReducer,E!==null))try{var I=a.lastRenderedState,W=E(I,f);if(v.hasEagerState=!0,v.eagerState=W,Lo(W,I)){var Q=a.interleaved;Q===null?(v.next=v,zh(a)):(v.next=Q.next,Q.next=v),a.interleaved=v;return}}catch{}finally{}f=ay(s,a,v,k),f!==null&&(v=Ur(),Uo(f,s,k,v),$y(f,a,k))}}function Ay(s){var a=s.alternate;return s===qn||a!==null&&a===qn}function Iy(s,a){nc=Vu=!0;var f=s.pending;f===null?a.next=a:(a.next=f.next,f.next=a),s.pending=a}function $y(s,a,f){if((f&4194240)!==0){var k=a.lanes;k&=s.pendingLanes,f|=k,a.lanes=f,lo(s,f)}}var Qu={readContext:Eo,useCallback:Cr,useContext:Cr,useEffect:Cr,useImperativeHandle:Cr,useInsertionEffect:Cr,useLayoutEffect:Cr,useMemo:Cr,useReducer:Cr,useRef:Cr,useState:Cr,useDebugValue:Cr,useDeferredValue:Cr,useTransition:Cr,useMutableSource:Cr,useSyncExternalStore:Cr,useId:Cr,unstable_isNewReconciler:!1},Rj={readContext:Eo,useCallback:function(s,a){return is().memoizedState=[s,a===void 0?null:a],s},useContext:Eo,useEffect:by,useImperativeHandle:function(s,a,f){return f=f!=null?f.concat([s]):null,Yu(4194308,4,Sy.bind(null,a,s),f)},useLayoutEffect:function(s,a){return Yu(4194308,4,s,a)},useInsertionEffect:function(s,a){return Yu(4,2,s,a)},useMemo:function(s,a){var f=is();return a=a===void 0?null:a,s=s(),f.memoizedState=[s,a],s},useReducer:function(s,a,f){var k=is();return a=f!==void 0?f(a):a,k.memoizedState=k.baseState=a,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:a},k.queue=s,s=s.dispatch=Ij.bind(null,qn,s),[k.memoizedState,s]},useRef:function(s){var a=is();return s={current:s},a.memoizedState=s},useState:yy,useDebugValue:Qh,useDeferredValue:function(s){return is().memoizedState=s},useTransition:function(){var s=yy(!1),a=s[0];return s=Aj.bind(null,s[1]),is().memoizedState=s,[a,s]},useMutableSource:function(){},useSyncExternalStore:function(s,a,f){var k=qn,v=is();if(Un){if(f===void 0)throw Error(n(407));f=f()}else{if(f=a(),mr===null)throw Error(n(349));(zi&30)!==0||py(k,a,f)}v.memoizedState=f;var E={value:f,getSnapshot:a};return v.queue=E,by(gy.bind(null,k,E,s),[s]),k.flags|=2048,sc(9,my.bind(null,k,E,f,a),void 0,null),f},useId:function(){var s=is(),a=mr.identifierPrefix;if(Un){var f=xs,k=bs;f=(k&~(1<<32-wn(k)-1)).toString(32)+f,a=":"+a+"R"+f,f=rc++,0<f&&(a+="H"+f.toString(32)),a+=":"}else f=Cj++,a=":"+a+"r"+f.toString(32)+":";return s.memoizedState=a},unstable_isNewReconciler:!1},Oj={readContext:Eo,useCallback:Ny,useContext:Eo,useEffect:Xh,useImperativeHandle:_y,useInsertionEffect:xy,useLayoutEffect:Ey,useMemo:Ty,useReducer:Vh,useRef:vy,useState:function(){return Vh(oc)},useDebugValue:Qh,useDeferredValue:function(s){var a=So();return jy(a,ar.memoizedState,s)},useTransition:function(){var s=Vh(oc)[0],a=So().memoizedState;return[s,a]},useMutableSource:fy,useSyncExternalStore:hy,useId:Cy,unstable_isNewReconciler:!1},Mj={readContext:Eo,useCallback:Ny,useContext:Eo,useEffect:Xh,useImperativeHandle:_y,useInsertionEffect:xy,useLayoutEffect:Ey,useMemo:Ty,useReducer:Yh,useRef:vy,useState:function(){return Yh(oc)},useDebugValue:Qh,useDeferredValue:function(s){var a=So();return ar===null?a.memoizedState=s:jy(a,ar.memoizedState,s)},useTransition:function(){var s=Yh(oc)[0],a=So().memoizedState;return[s,a]},useMutableSource:fy,useSyncExternalStore:hy,useId:Cy,unstable_isNewReconciler:!1};function zo(s,a){if(s&&s.defaultProps){a=q({},a),s=s.defaultProps;for(var f in s)a[f]===void 0&&(a[f]=s[f]);return a}return a}function Jh(s,a,f,k){a=s.memoizedState,f=f(k,a),f=f==null?a:q({},a,f),s.memoizedState=f,s.lanes===0&&(s.updateQueue.baseState=f)}var Ju={isMounted:function(s){return(s=s._reactInternals)?Kn(s)===s:!1},enqueueSetState:function(s,a,f){s=s._reactInternals;var k=Ur(),v=ti(s),E=Ss(k,v);E.payload=a,f!=null&&(E.callback=f),a=Xs(s,E,v),a!==null&&(Uo(a,s,v,k),Ku(a,s,v))},enqueueReplaceState:function(s,a,f){s=s._reactInternals;var k=Ur(),v=ti(s),E=Ss(k,v);E.tag=1,E.payload=a,f!=null&&(E.callback=f),a=Xs(s,E,v),a!==null&&(Uo(a,s,v,k),Ku(a,s,v))},enqueueForceUpdate:function(s,a){s=s._reactInternals;var f=Ur(),k=ti(s),v=Ss(f,k);v.tag=2,a!=null&&(v.callback=a),a=Xs(s,v,k),a!==null&&(Uo(a,s,k,f),Ku(a,s,k))}};function Ry(s,a,f,k,v,E,I){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(k,E,I):a.prototype&&a.prototype.isPureReactComponent?!Kl(f,k)||!Kl(v,E):!0}function Oy(s,a,f){var k=!1,v=Gs,E=a.contextType;return typeof E=="object"&&E!==null?E=Eo(E):(v=Gr(a)?Oi:jr.current,k=a.contextTypes,E=(k=k!=null)?Pa(s,v):Gs),a=new a(f,E),s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ju,s.stateNode=a,a._reactInternals=s,k&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=v,s.__reactInternalMemoizedMaskedChildContext=E),a}function My(s,a,f,k){s=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(f,k),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(f,k),a.state!==s&&Ju.enqueueReplaceState(a,a.state,null)}function ep(s,a,f,k){var v=s.stateNode;v.props=f,v.state=s.memoizedState,v.refs={},Fh(s);var E=a.contextType;typeof E=="object"&&E!==null?v.context=Eo(E):(E=Gr(a)?Oi:jr.current,v.context=Pa(s,E)),v.state=s.memoizedState,E=a.getDerivedStateFromProps,typeof E=="function"&&(Jh(s,a,E,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&&Ju.enqueueReplaceState(v,v.state,null),Zu(s,f,v,k),v.state=s.memoizedState),typeof v.componentDidMount=="function"&&(s.flags|=4194308)}function Wa(s,a){try{var f="",k=a;do f+=de(k),k=k.return;while(k);var v=f}catch(E){v=`
|
|
40
|
-
Error generating stack: `+E.message+`
|
|
41
|
-
`+E.stack}return{value:s,source:a,stack:v,digest:null}}function tp(s,a,f){return{value:s,source:null,stack:f??null,digest:a??null}}function np(s,a){try{console.error(a.value)}catch(f){setTimeout(function(){throw f})}}var Pj=typeof WeakMap=="function"?WeakMap:Map;function Py(s,a,f){f=Ss(-1,f),f.tag=3,f.payload={element:null};var k=a.value;return f.callback=function(){id||(id=!0,kp=k),np(s,a)},f}function Ly(s,a,f){f=Ss(-1,f),f.tag=3;var k=s.type.getDerivedStateFromError;if(typeof k=="function"){var v=a.value;f.payload=function(){return k(v)},f.callback=function(){np(s,a)}}var E=s.stateNode;return E!==null&&typeof E.componentDidCatch=="function"&&(f.callback=function(){np(s,a),typeof k!="function"&&(Js===null?Js=new Set([this]):Js.add(this));var I=a.stack;this.componentDidCatch(a.value,{componentStack:I!==null?I:""})}),f}function Dy(s,a,f){var k=s.pingCache;if(k===null){k=s.pingCache=new Pj;var v=new Set;k.set(a,v)}else v=k.get(a),v===void 0&&(v=new Set,k.set(a,v));v.has(f)||(v.add(f),s=Yj.bind(null,s,a,f),a.then(s,s))}function zy(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 Fy(s,a,f,k,v){return(s.mode&1)===0?(s===a?s.flags|=65536:(s.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(a=Ss(-1,1),a.tag=2,Xs(f,a,1))),f.lanes|=1),s):(s.flags|=65536,s.lanes=v,s)}var Lj=j.ReactCurrentOwner,Vr=!1;function Br(s,a,f,k){a.child=s===null?iy(a,null,f,k):Fa(a,s.child,f,k)}function By(s,a,f,k,v){f=f.render;var E=a.ref;return Ua(a,v),k=qh(s,a,f,k,E,v),f=Gh(),s!==null&&!Vr?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,_s(s,a,v)):(Un&&f&&Ah(a),a.flags|=1,Br(s,a,k,v),a.child)}function Uy(s,a,f,k,v){if(s===null){var E=f.type;return typeof E=="function"&&!Sp(E)&&E.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0?(a.tag=15,a.type=E,Hy(s,a,E,k,v)):(s=fd(f.type,null,k,a,a.mode,v),s.ref=a.ref,s.return=a,a.child=s)}if(E=s.child,(s.lanes&v)===0){var I=E.memoizedProps;if(f=f.compare,f=f!==null?f:Kl,f(I,k)&&s.ref===a.ref)return _s(s,a,v)}return a.flags|=1,s=ri(E,k),s.ref=a.ref,s.return=a,a.child=s}function Hy(s,a,f,k,v){if(s!==null){var E=s.memoizedProps;if(Kl(E,k)&&s.ref===a.ref)if(Vr=!1,a.pendingProps=k=E,(s.lanes&v)!==0)(s.flags&131072)!==0&&(Vr=!0);else return a.lanes=s.lanes,_s(s,a,v)}return rp(s,a,f,k,v)}function Wy(s,a,f){var k=a.pendingProps,v=k.children,E=s!==null?s.memoizedState:null;if(k.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},Rn(Za,ho),ho|=f;else{if((f&1073741824)===0)return s=E!==null?E.baseLanes|f:f,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:s,cachePool:null,transitions:null},a.updateQueue=null,Rn(Za,ho),ho|=s,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=E!==null?E.baseLanes:f,Rn(Za,ho),ho|=k}else E!==null?(k=E.baseLanes|f,a.memoizedState=null):k=f,Rn(Za,ho),ho|=k;return Br(s,a,v,f),a.child}function Ky(s,a){var f=a.ref;(s===null&&f!==null||s!==null&&s.ref!==f)&&(a.flags|=512,a.flags|=2097152)}function rp(s,a,f,k,v){var E=Gr(f)?Oi:jr.current;return E=Pa(a,E),Ua(a,v),f=qh(s,a,f,k,E,v),k=Gh(),s!==null&&!Vr?(a.updateQueue=s.updateQueue,a.flags&=-2053,s.lanes&=~v,_s(s,a,v)):(Un&&k&&Ah(a),a.flags|=1,Br(s,a,f,v),a.child)}function Zy(s,a,f,k,v){if(Gr(f)){var E=!0;Lu(a)}else E=!1;if(Ua(a,v),a.stateNode===null)td(s,a),Oy(a,f,k),ep(a,f,k,v),k=!0;else if(s===null){var I=a.stateNode,W=a.memoizedProps;I.props=W;var Q=I.context,he=f.contextType;typeof he=="object"&&he!==null?he=Eo(he):(he=Gr(f)?Oi:jr.current,he=Pa(a,he));var Re=f.getDerivedStateFromProps,Pe=typeof Re=="function"||typeof I.getSnapshotBeforeUpdate=="function";Pe||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(W!==k||Q!==he)&&My(a,I,k,he),Ys=!1;var $e=a.memoizedState;I.state=$e,Zu(a,k,I,v),Q=a.memoizedState,W!==k||$e!==Q||qr.current||Ys?(typeof Re=="function"&&(Jh(a,f,Re,k),Q=a.memoizedState),(W=Ys||Ry(a,f,W,k,$e,Q,he))?(Pe||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(a.flags|=4194308)):(typeof I.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=k,a.memoizedState=Q),I.props=k,I.state=Q,I.context=he,k=W):(typeof I.componentDidMount=="function"&&(a.flags|=4194308),k=!1)}else{I=a.stateNode,ly(s,a),W=a.memoizedProps,he=a.type===a.elementType?W:zo(a.type,W),I.props=he,Pe=a.pendingProps,$e=I.context,Q=f.contextType,typeof Q=="object"&&Q!==null?Q=Eo(Q):(Q=Gr(f)?Oi:jr.current,Q=Pa(a,Q));var Je=f.getDerivedStateFromProps;(Re=typeof Je=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(W!==Pe||$e!==Q)&&My(a,I,k,Q),Ys=!1,$e=a.memoizedState,I.state=$e,Zu(a,k,I,v);var ot=a.memoizedState;W!==Pe||$e!==ot||qr.current||Ys?(typeof Je=="function"&&(Jh(a,f,Je,k),ot=a.memoizedState),(he=Ys||Ry(a,f,he,k,$e,ot,Q)||!1)?(Re||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(k,ot,Q),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(k,ot,Q)),typeof I.componentDidUpdate=="function"&&(a.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof I.componentDidUpdate!="function"||W===s.memoizedProps&&$e===s.memoizedState||(a.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||W===s.memoizedProps&&$e===s.memoizedState||(a.flags|=1024),a.memoizedProps=k,a.memoizedState=ot),I.props=k,I.state=ot,I.context=Q,k=he):(typeof I.componentDidUpdate!="function"||W===s.memoizedProps&&$e===s.memoizedState||(a.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||W===s.memoizedProps&&$e===s.memoizedState||(a.flags|=1024),k=!1)}return op(s,a,f,k,E,v)}function op(s,a,f,k,v,E){Ky(s,a);var I=(a.flags&128)!==0;if(!k&&!I)return v&&Xw(a,f,!1),_s(s,a,E);k=a.stateNode,Lj.current=a;var W=I&&typeof f.getDerivedStateFromError!="function"?null:k.render();return a.flags|=1,s!==null&&I?(a.child=Fa(a,s.child,null,E),a.child=Fa(a,null,W,E)):Br(s,a,W,E),a.memoizedState=k.state,v&&Xw(a,f,!0),a.child}function qy(s){var a=s.stateNode;a.pendingContext?Vw(s,a.pendingContext,a.pendingContext!==a.context):a.context&&Vw(s,a.context,!1),Bh(s,a.containerInfo)}function Gy(s,a,f,k,v){return za(),Oh(v),a.flags|=256,Br(s,a,f,k),a.child}var sp={dehydrated:null,treeContext:null,retryLane:0};function ip(s){return{baseLanes:s,cachePool:null,transitions:null}}function Vy(s,a,f){var k=a.pendingProps,v=Zn.current,E=!1,I=(a.flags&128)!==0,W;if((W=I)||(W=s!==null&&s.memoizedState===null?!1:(v&2)!==0),W?(E=!0,a.flags&=-129):(s===null||s.memoizedState!==null)&&(v|=1),Rn(Zn,v&1),s===null)return Rh(a),s=a.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?((a.mode&1)===0?a.lanes=1:s.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(I=k.children,s=k.fallback,E?(k=a.mode,E=a.child,I={mode:"hidden",children:I},(k&1)===0&&E!==null?(E.childLanes=0,E.pendingProps=I):E=hd(I,k,0,null),s=Wi(s,k,f,null),E.return=a,s.return=a,E.sibling=s,a.child=E,a.child.memoizedState=ip(f),a.memoizedState=sp,s):ap(a,I));if(v=s.memoizedState,v!==null&&(W=v.dehydrated,W!==null))return Dj(s,a,I,k,W,v,f);if(E){E=k.fallback,I=a.mode,v=s.child,W=v.sibling;var Q={mode:"hidden",children:k.children};return(I&1)===0&&a.child!==v?(k=a.child,k.childLanes=0,k.pendingProps=Q,a.deletions=null):(k=ri(v,Q),k.subtreeFlags=v.subtreeFlags&14680064),W!==null?E=ri(W,E):(E=Wi(E,I,f,null),E.flags|=2),E.return=a,k.return=a,k.sibling=E,a.child=k,k=E,E=a.child,I=s.child.memoizedState,I=I===null?ip(f):{baseLanes:I.baseLanes|f,cachePool:null,transitions:I.transitions},E.memoizedState=I,E.childLanes=s.childLanes&~f,a.memoizedState=sp,k}return E=s.child,s=E.sibling,k=ri(E,{mode:"visible",children:k.children}),(a.mode&1)===0&&(k.lanes=f),k.return=a,k.sibling=null,s!==null&&(f=a.deletions,f===null?(a.deletions=[s],a.flags|=16):f.push(s)),a.child=k,a.memoizedState=null,k}function ap(s,a){return a=hd({mode:"visible",children:a},s.mode,0,null),a.return=s,s.child=a}function ed(s,a,f,k){return k!==null&&Oh(k),Fa(a,s.child,null,f),s=ap(a,a.pendingProps.children),s.flags|=2,a.memoizedState=null,s}function Dj(s,a,f,k,v,E,I){if(f)return a.flags&256?(a.flags&=-257,k=tp(Error(n(422))),ed(s,a,I,k)):a.memoizedState!==null?(a.child=s.child,a.flags|=128,null):(E=k.fallback,v=a.mode,k=hd({mode:"visible",children:k.children},v,0,null),E=Wi(E,v,I,null),E.flags|=2,k.return=a,E.return=a,k.sibling=E,a.child=k,(a.mode&1)!==0&&Fa(a,s.child,null,I),a.child.memoizedState=ip(I),a.memoizedState=sp,E);if((a.mode&1)===0)return ed(s,a,I,null);if(v.data==="$!"){if(k=v.nextSibling&&v.nextSibling.dataset,k)var W=k.dgst;return k=W,E=Error(n(419)),k=tp(E,k,void 0),ed(s,a,I,k)}if(W=(I&s.childLanes)!==0,Vr||W){if(k=mr,k!==null){switch(I&-I){case 4:v=2;break;case 16:v=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:v=32;break;case 536870912:v=268435456;break;default:v=0}v=(v&(k.suspendedLanes|I))!==0?0:v,v!==0&&v!==E.retryLane&&(E.retryLane=v,Es(s,v),Uo(k,s,v,-1))}return Ep(),k=tp(Error(n(421))),ed(s,a,I,k)}return v.data==="$?"?(a.flags|=128,a.child=s.child,a=Xj.bind(null,s),v._reactRetry=a,null):(s=E.treeContext,fo=Zs(v.nextSibling),uo=a,Un=!0,Do=null,s!==null&&(bo[xo++]=bs,bo[xo++]=xs,bo[xo++]=Mi,bs=s.id,xs=s.overflow,Mi=a),a=ap(a,k.children),a.flags|=4096,a)}function Yy(s,a,f){s.lanes|=a;var k=s.alternate;k!==null&&(k.lanes|=a),Dh(s.return,a,f)}function lp(s,a,f,k,v){var E=s.memoizedState;E===null?s.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:k,tail:f,tailMode:v}:(E.isBackwards=a,E.rendering=null,E.renderingStartTime=0,E.last=k,E.tail=f,E.tailMode=v)}function Xy(s,a,f){var k=a.pendingProps,v=k.revealOrder,E=k.tail;if(Br(s,a,k.children,f),k=Zn.current,(k&2)!==0)k=k&1|2,a.flags|=128;else{if(s!==null&&(s.flags&128)!==0)e:for(s=a.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&Yy(s,f,a);else if(s.tag===19)Yy(s,f,a);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===a)break e;for(;s.sibling===null;){if(s.return===null||s.return===a)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}k&=1}if(Rn(Zn,k),(a.mode&1)===0)a.memoizedState=null;else switch(v){case"forwards":for(f=a.child,v=null;f!==null;)s=f.alternate,s!==null&&qu(s)===null&&(v=f),f=f.sibling;f=v,f===null?(v=a.child,a.child=null):(v=f.sibling,f.sibling=null),lp(a,!1,v,f,E);break;case"backwards":for(f=null,v=a.child,a.child=null;v!==null;){if(s=v.alternate,s!==null&&qu(s)===null){a.child=v;break}s=v.sibling,v.sibling=f,f=v,v=s}lp(a,!0,f,null,E);break;case"together":lp(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function td(s,a){(a.mode&1)===0&&s!==null&&(s.alternate=null,a.alternate=null,a.flags|=2)}function _s(s,a,f){if(s!==null&&(a.dependencies=s.dependencies),Fi|=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=ri(s,s.pendingProps),a.child=f,f.return=a;s.sibling!==null;)s=s.sibling,f=f.sibling=ri(s,s.pendingProps),f.return=a;f.sibling=null}return a.child}function zj(s,a,f){switch(a.tag){case 3:qy(a),za();break;case 5:dy(a);break;case 1:Gr(a.type)&&Lu(a);break;case 4:Bh(a,a.stateNode.containerInfo);break;case 10:var k=a.type._context,v=a.memoizedProps.value;Rn(Hu,k._currentValue),k._currentValue=v;break;case 13:if(k=a.memoizedState,k!==null)return k.dehydrated!==null?(Rn(Zn,Zn.current&1),a.flags|=128,null):(f&a.child.childLanes)!==0?Vy(s,a,f):(Rn(Zn,Zn.current&1),s=_s(s,a,f),s!==null?s.sibling:null);Rn(Zn,Zn.current&1);break;case 19:if(k=(f&a.childLanes)!==0,(s.flags&128)!==0){if(k)return Xy(s,a,f);a.flags|=128}if(v=a.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),Rn(Zn,Zn.current),k)break;return null;case 22:case 23:return a.lanes=0,Wy(s,a,f)}return _s(s,a,f)}var Qy,cp,Jy,ev;Qy=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}},cp=function(){},Jy=function(s,a,f,k){var v=s.memoizedProps;if(v!==k){s=a.stateNode,Di(ss.current);var E=null;switch(f){case"input":v=Ce(s,v),k=Ce(s,k),E=[];break;case"select":v=q({},v,{value:void 0}),k=q({},k,{value:void 0}),E=[];break;case"textarea":v=Ft(s,v),k=Ft(s,k),E=[];break;default:typeof v.onClick!="function"&&typeof k.onClick=="function"&&(s.onclick=Ou)}pe(f,k);var I;f=null;for(he in v)if(!k.hasOwnProperty(he)&&v.hasOwnProperty(he)&&v[he]!=null)if(he==="style"){var W=v[he];for(I in W)W.hasOwnProperty(I)&&(f||(f={}),f[I]="")}else he!=="dangerouslySetInnerHTML"&&he!=="children"&&he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&he!=="autoFocus"&&(o.hasOwnProperty(he)?E||(E=[]):(E=E||[]).push(he,null));for(he in k){var Q=k[he];if(W=v!=null?v[he]:void 0,k.hasOwnProperty(he)&&Q!==W&&(Q!=null||W!=null))if(he==="style")if(W){for(I in W)!W.hasOwnProperty(I)||Q&&Q.hasOwnProperty(I)||(f||(f={}),f[I]="");for(I in Q)Q.hasOwnProperty(I)&&W[I]!==Q[I]&&(f||(f={}),f[I]=Q[I])}else f||(E||(E=[]),E.push(he,f)),f=Q;else he==="dangerouslySetInnerHTML"?(Q=Q?Q.__html:void 0,W=W?W.__html:void 0,Q!=null&&W!==Q&&(E=E||[]).push(he,Q)):he==="children"?typeof Q!="string"&&typeof Q!="number"||(E=E||[]).push(he,""+Q):he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&(o.hasOwnProperty(he)?(Q!=null&&he==="onScroll"&&Ln("scroll",s),E||W===Q||(E=[])):(E=E||[]).push(he,Q))}f&&(E=E||[]).push("style",f);var he=E;(a.updateQueue=he)&&(a.flags|=4)}},ev=function(s,a,f,k){f!==k&&(a.flags|=4)};function ic(s,a){if(!Un)switch(s.tailMode){case"hidden":a=s.tail;for(var f=null;a!==null;)a.alternate!==null&&(f=a),a=a.sibling;f===null?s.tail=null:f.sibling=null;break;case"collapsed":f=s.tail;for(var k=null;f!==null;)f.alternate!==null&&(k=f),f=f.sibling;k===null?a||s.tail===null?s.tail=null:s.tail.sibling=null:k.sibling=null}}function Ar(s){var a=s.alternate!==null&&s.alternate.child===s.child,f=0,k=0;if(a)for(var v=s.child;v!==null;)f|=v.lanes|v.childLanes,k|=v.subtreeFlags&14680064,k|=v.flags&14680064,v.return=s,v=v.sibling;else for(v=s.child;v!==null;)f|=v.lanes|v.childLanes,k|=v.subtreeFlags,k|=v.flags,v.return=s,v=v.sibling;return s.subtreeFlags|=k,s.childLanes=f,a}function Fj(s,a,f){var k=a.pendingProps;switch(Ih(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ar(a),null;case 1:return Gr(a.type)&&Pu(),Ar(a),null;case 3:return k=a.stateNode,Ha(),Dn(qr),Dn(jr),Wh(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(s===null||s.child===null)&&(Bu(a)?a.flags|=4:s===null||s.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,Do!==null&&(vp(Do),Do=null))),cp(s,a),Ar(a),null;case 5:Uh(a);var v=Di(tc.current);if(f=a.type,s!==null&&a.stateNode!=null)Jy(s,a,f,k,v),s.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!k){if(a.stateNode===null)throw Error(n(166));return Ar(a),null}if(s=Di(ss.current),Bu(a)){k=a.stateNode,f=a.type;var E=a.memoizedProps;switch(k[os]=a,k[Yl]=E,s=(a.mode&1)!==0,f){case"dialog":Ln("cancel",k),Ln("close",k);break;case"iframe":case"object":case"embed":Ln("load",k);break;case"video":case"audio":for(v=0;v<ql.length;v++)Ln(ql[v],k);break;case"source":Ln("error",k);break;case"img":case"image":case"link":Ln("error",k),Ln("load",k);break;case"details":Ln("toggle",k);break;case"input":Se(k,E),Ln("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!E.multiple},Ln("invalid",k);break;case"textarea":Ht(k,E),Ln("invalid",k)}pe(f,E),v=null;for(var I in E)if(E.hasOwnProperty(I)){var W=E[I];I==="children"?typeof W=="string"?k.textContent!==W&&(E.suppressHydrationWarning!==!0&&Ru(k.textContent,W,s),v=["children",W]):typeof W=="number"&&k.textContent!==""+W&&(E.suppressHydrationWarning!==!0&&Ru(k.textContent,W,s),v=["children",""+W]):o.hasOwnProperty(I)&&W!=null&&I==="onScroll"&&Ln("scroll",k)}switch(f){case"input":ge(k),wt(k,E,!0);break;case"textarea":ge(k),St(k);break;case"select":case"option":break;default:typeof E.onClick=="function"&&(k.onclick=Ou)}k=v,a.updateQueue=k,k!==null&&(a.flags|=4)}else{I=v.nodeType===9?v:v.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=sn(f)),s==="http://www.w3.org/1999/xhtml"?f==="script"?(s=I.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof k.is=="string"?s=I.createElement(f,{is:k.is}):(s=I.createElement(f),f==="select"&&(I=s,k.multiple?I.multiple=!0:k.size&&(I.size=k.size))):s=I.createElementNS(s,f),s[os]=a,s[Yl]=k,Qy(s,a,!1,!1),a.stateNode=s;e:{switch(I=Ye(f,k),f){case"dialog":Ln("cancel",s),Ln("close",s),v=k;break;case"iframe":case"object":case"embed":Ln("load",s),v=k;break;case"video":case"audio":for(v=0;v<ql.length;v++)Ln(ql[v],s);v=k;break;case"source":Ln("error",s),v=k;break;case"img":case"image":case"link":Ln("error",s),Ln("load",s),v=k;break;case"details":Ln("toggle",s),v=k;break;case"input":Se(s,k),v=Ce(s,k),Ln("invalid",s);break;case"option":v=k;break;case"select":s._wrapperState={wasMultiple:!!k.multiple},v=q({},k,{value:void 0}),Ln("invalid",s);break;case"textarea":Ht(s,k),v=Ft(s,k),Ln("invalid",s);break;default:v=k}pe(f,v),W=v;for(E in W)if(W.hasOwnProperty(E)){var Q=W[E];E==="style"?Qt(s,Q):E==="dangerouslySetInnerHTML"?(Q=Q?Q.__html:void 0,Q!=null&&jt(s,Q)):E==="children"?typeof Q=="string"?(f!=="textarea"||Q!=="")&&Kt(s,Q):typeof Q=="number"&&Kt(s,""+Q):E!=="suppressContentEditableWarning"&&E!=="suppressHydrationWarning"&&E!=="autoFocus"&&(o.hasOwnProperty(E)?Q!=null&&E==="onScroll"&&Ln("scroll",s):Q!=null&&N(s,E,Q,I))}switch(f){case"input":ge(s),wt(s,k,!1);break;case"textarea":ge(s),St(s);break;case"option":k.value!=null&&s.setAttribute("value",""+G(k.value));break;case"select":s.multiple=!!k.multiple,E=k.value,E!=null?Vt(s,!!k.multiple,E,!1):k.defaultValue!=null&&Vt(s,!!k.multiple,k.defaultValue,!0);break;default:typeof v.onClick=="function"&&(s.onclick=Ou)}switch(f){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return Ar(a),null;case 6:if(s&&a.stateNode!=null)ev(s,a,s.memoizedProps,k);else{if(typeof k!="string"&&a.stateNode===null)throw Error(n(166));if(f=Di(tc.current),Di(ss.current),Bu(a)){if(k=a.stateNode,f=a.memoizedProps,k[os]=a,(E=k.nodeValue!==f)&&(s=uo,s!==null))switch(s.tag){case 3:Ru(k.nodeValue,f,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&Ru(k.nodeValue,f,(s.mode&1)!==0)}E&&(a.flags|=4)}else k=(f.nodeType===9?f:f.ownerDocument).createTextNode(k),k[os]=a,a.stateNode=k}return Ar(a),null;case 13:if(Dn(Zn),k=a.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(Un&&fo!==null&&(a.mode&1)!==0&&(a.flags&128)===0)ry(),za(),a.flags|=98560,E=!1;else if(E=Bu(a),k!==null&&k.dehydrated!==null){if(s===null){if(!E)throw Error(n(318));if(E=a.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(n(317));E[os]=a}else za(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Ar(a),E=!1}else Do!==null&&(vp(Do),Do=null),E=!0;if(!E)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=f,a):(k=k!==null,k!==(s!==null&&s.memoizedState!==null)&&k&&(a.child.flags|=8192,(a.mode&1)!==0&&(s===null||(Zn.current&1)!==0?lr===0&&(lr=3):Ep())),a.updateQueue!==null&&(a.flags|=4),Ar(a),null);case 4:return Ha(),cp(s,a),s===null&&Gl(a.stateNode.containerInfo),Ar(a),null;case 10:return Lh(a.type._context),Ar(a),null;case 17:return Gr(a.type)&&Pu(),Ar(a),null;case 19:if(Dn(Zn),E=a.memoizedState,E===null)return Ar(a),null;if(k=(a.flags&128)!==0,I=E.rendering,I===null)if(k)ic(E,!1);else{if(lr!==0||s!==null&&(s.flags&128)!==0)for(s=a.child;s!==null;){if(I=qu(s),I!==null){for(a.flags|=128,ic(E,!1),k=I.updateQueue,k!==null&&(a.updateQueue=k,a.flags|=4),a.subtreeFlags=0,k=f,f=a.child;f!==null;)E=f,s=k,E.flags&=14680066,I=E.alternate,I===null?(E.childLanes=0,E.lanes=s,E.child=null,E.subtreeFlags=0,E.memoizedProps=null,E.memoizedState=null,E.updateQueue=null,E.dependencies=null,E.stateNode=null):(E.childLanes=I.childLanes,E.lanes=I.lanes,E.child=I.child,E.subtreeFlags=0,E.deletions=null,E.memoizedProps=I.memoizedProps,E.memoizedState=I.memoizedState,E.updateQueue=I.updateQueue,E.type=I.type,s=I.dependencies,E.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),f=f.sibling;return Rn(Zn,Zn.current&1|2),a.child}s=s.sibling}E.tail!==null&&fn()>qa&&(a.flags|=128,k=!0,ic(E,!1),a.lanes=4194304)}else{if(!k)if(s=qu(I),s!==null){if(a.flags|=128,k=!0,f=s.updateQueue,f!==null&&(a.updateQueue=f,a.flags|=4),ic(E,!0),E.tail===null&&E.tailMode==="hidden"&&!I.alternate&&!Un)return Ar(a),null}else 2*fn()-E.renderingStartTime>qa&&f!==1073741824&&(a.flags|=128,k=!0,ic(E,!1),a.lanes=4194304);E.isBackwards?(I.sibling=a.child,a.child=I):(f=E.last,f!==null?f.sibling=I:a.child=I,E.last=I)}return E.tail!==null?(a=E.tail,E.rendering=a,E.tail=a.sibling,E.renderingStartTime=fn(),a.sibling=null,f=Zn.current,Rn(Zn,k?f&1|2:f&1),a):(Ar(a),null);case 22:case 23:return xp(),k=a.memoizedState!==null,s!==null&&s.memoizedState!==null!==k&&(a.flags|=8192),k&&(a.mode&1)!==0?(ho&1073741824)!==0&&(Ar(a),a.subtreeFlags&6&&(a.flags|=8192)):Ar(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function Bj(s,a){switch(Ih(a),a.tag){case 1:return Gr(a.type)&&Pu(),s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 3:return Ha(),Dn(qr),Dn(jr),Wh(),s=a.flags,(s&65536)!==0&&(s&128)===0?(a.flags=s&-65537|128,a):null;case 5:return Uh(a),null;case 13:if(Dn(Zn),s=a.memoizedState,s!==null&&s.dehydrated!==null){if(a.alternate===null)throw Error(n(340));za()}return s=a.flags,s&65536?(a.flags=s&-65537|128,a):null;case 19:return Dn(Zn),null;case 4:return Ha(),null;case 10:return Lh(a.type._context),null;case 22:case 23:return xp(),null;case 24:return null;default:return null}}var nd=!1,Ir=!1,Uj=typeof WeakSet=="function"?WeakSet:Set,tt=null;function Ka(s,a){var f=s.ref;if(f!==null)if(typeof f=="function")try{f(null)}catch(k){Qn(s,a,k)}else f.current=null}function up(s,a,f){try{f()}catch(k){Qn(s,a,k)}}var tv=!1;function Hj(s,a){if(xh=_i,s=Rw(),ph(s)){if("selectionStart"in s)var f={start:s.selectionStart,end:s.selectionEnd};else e:{f=(f=s.ownerDocument)&&f.defaultView||window;var k=f.getSelection&&f.getSelection();if(k&&k.rangeCount!==0){f=k.anchorNode;var v=k.anchorOffset,E=k.focusNode;k=k.focusOffset;try{f.nodeType,E.nodeType}catch{f=null;break e}var I=0,W=-1,Q=-1,he=0,Re=0,Pe=s,$e=null;t:for(;;){for(var Je;Pe!==f||v!==0&&Pe.nodeType!==3||(W=I+v),Pe!==E||k!==0&&Pe.nodeType!==3||(Q=I+k),Pe.nodeType===3&&(I+=Pe.nodeValue.length),(Je=Pe.firstChild)!==null;)$e=Pe,Pe=Je;for(;;){if(Pe===s)break t;if($e===f&&++he===v&&(W=I),$e===E&&++Re===k&&(Q=I),(Je=Pe.nextSibling)!==null)break;Pe=$e,$e=Pe.parentNode}Pe=Je}f=W===-1||Q===-1?null:{start:W,end:Q}}else f=null}f=f||{start:0,end:0}}else f=null;for(Eh={focusedElem:s,selectionRange:f},_i=!1,tt=a;tt!==null;)if(a=tt,s=a.child,(a.subtreeFlags&1028)!==0&&s!==null)s.return=a,tt=s;else for(;tt!==null;){a=tt;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 st=ot.memoizedProps,Jn=ot.memoizedState,le=a.stateNode,te=le.getSnapshotBeforeUpdate(a.elementType===a.type?st:zo(a.type,st),Jn);le.__reactInternalSnapshotBeforeUpdate=te}break;case 3:var ce=a.stateNode.containerInfo;ce.nodeType===1?ce.textContent="":ce.nodeType===9&&ce.documentElement&&ce.removeChild(ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ue){Qn(a,a.return,Ue)}if(s=a.sibling,s!==null){s.return=a.return,tt=s;break}tt=a.return}return ot=tv,tv=!1,ot}function ac(s,a,f){var k=a.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var v=k=k.next;do{if((v.tag&s)===s){var E=v.destroy;v.destroy=void 0,E!==void 0&&up(a,f,E)}v=v.next}while(v!==k)}}function rd(s,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var f=a=a.next;do{if((f.tag&s)===s){var k=f.create;f.destroy=k()}f=f.next}while(f!==a)}}function dp(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 nv(s){var a=s.alternate;a!==null&&(s.alternate=null,nv(a)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(a=s.stateNode,a!==null&&(delete a[os],delete a[Yl],delete a[Th],delete a[_j],delete a[Nj])),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 rv(s){return s.tag===5||s.tag===3||s.tag===4}function ov(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||rv(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 fp(s,a,f){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?f.nodeType===8?f.parentNode.insertBefore(s,a):f.insertBefore(s,a):(f.nodeType===8?(a=f.parentNode,a.insertBefore(s,f)):(a=f,a.appendChild(s)),f=f._reactRootContainer,f!=null||a.onclick!==null||(a.onclick=Ou));else if(k!==4&&(s=s.child,s!==null))for(fp(s,a,f),s=s.sibling;s!==null;)fp(s,a,f),s=s.sibling}function hp(s,a,f){var k=s.tag;if(k===5||k===6)s=s.stateNode,a?f.insertBefore(s,a):f.appendChild(s);else if(k!==4&&(s=s.child,s!==null))for(hp(s,a,f),s=s.sibling;s!==null;)hp(s,a,f),s=s.sibling}var xr=null,Fo=!1;function Qs(s,a,f){for(f=f.child;f!==null;)sv(s,a,f),f=f.sibling}function sv(s,a,f){if(et&&typeof et.onCommitFiberUnmount=="function")try{et.onCommitFiberUnmount(rt,f)}catch{}switch(f.tag){case 5:Ir||Ka(f,a);case 6:var k=xr,v=Fo;xr=null,Qs(s,a,f),xr=k,Fo=v,xr!==null&&(Fo?(s=xr,f=f.stateNode,s.nodeType===8?s.parentNode.removeChild(f):s.removeChild(f)):xr.removeChild(f.stateNode));break;case 18:xr!==null&&(Fo?(s=xr,f=f.stateNode,s.nodeType===8?Nh(s.parentNode,f):s.nodeType===1&&Nh(s,f),Ms(s)):Nh(xr,f.stateNode));break;case 4:k=xr,v=Fo,xr=f.stateNode.containerInfo,Fo=!0,Qs(s,a,f),xr=k,Fo=v;break;case 0:case 11:case 14:case 15:if(!Ir&&(k=f.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){v=k=k.next;do{var E=v,I=E.destroy;E=E.tag,I!==void 0&&((E&2)!==0||(E&4)!==0)&&up(f,a,I),v=v.next}while(v!==k)}Qs(s,a,f);break;case 1:if(!Ir&&(Ka(f,a),k=f.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=f.memoizedProps,k.state=f.memoizedState,k.componentWillUnmount()}catch(W){Qn(f,a,W)}Qs(s,a,f);break;case 21:Qs(s,a,f);break;case 22:f.mode&1?(Ir=(k=Ir)||f.memoizedState!==null,Qs(s,a,f),Ir=k):Qs(s,a,f);break;default:Qs(s,a,f)}}function iv(s){var a=s.updateQueue;if(a!==null){s.updateQueue=null;var f=s.stateNode;f===null&&(f=s.stateNode=new Uj),a.forEach(function(k){var v=Qj.bind(null,s,k);f.has(k)||(f.add(k),k.then(v,v))})}}function Bo(s,a){var f=a.deletions;if(f!==null)for(var k=0;k<f.length;k++){var v=f[k];try{var E=s,I=a,W=I;e:for(;W!==null;){switch(W.tag){case 5:xr=W.stateNode,Fo=!1;break e;case 3:xr=W.stateNode.containerInfo,Fo=!0;break e;case 4:xr=W.stateNode.containerInfo,Fo=!0;break e}W=W.return}if(xr===null)throw Error(n(160));sv(E,I,v),xr=null,Fo=!1;var Q=v.alternate;Q!==null&&(Q.return=null),v.return=null}catch(he){Qn(v,a,he)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)av(a,s),a=a.sibling}function av(s,a){var f=s.alternate,k=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Bo(a,s),as(s),k&4){try{ac(3,s,s.return),rd(3,s)}catch(st){Qn(s,s.return,st)}try{ac(5,s,s.return)}catch(st){Qn(s,s.return,st)}}break;case 1:Bo(a,s),as(s),k&512&&f!==null&&Ka(f,f.return);break;case 5:if(Bo(a,s),as(s),k&512&&f!==null&&Ka(f,f.return),s.flags&32){var v=s.stateNode;try{Kt(v,"")}catch(st){Qn(s,s.return,st)}}if(k&4&&(v=s.stateNode,v!=null)){var E=s.memoizedProps,I=f!==null?f.memoizedProps:E,W=s.type,Q=s.updateQueue;if(s.updateQueue=null,Q!==null)try{W==="input"&&E.type==="radio"&&E.name!=null&&_e(v,E),Ye(W,I);var he=Ye(W,E);for(I=0;I<Q.length;I+=2){var Re=Q[I],Pe=Q[I+1];Re==="style"?Qt(v,Pe):Re==="dangerouslySetInnerHTML"?jt(v,Pe):Re==="children"?Kt(v,Pe):N(v,Re,Pe,he)}switch(W){case"input":Be(v,E);break;case"textarea":Me(v,E);break;case"select":var $e=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!E.multiple;var Je=E.value;Je!=null?Vt(v,!!E.multiple,Je,!1):$e!==!!E.multiple&&(E.defaultValue!=null?Vt(v,!!E.multiple,E.defaultValue,!0):Vt(v,!!E.multiple,E.multiple?[]:"",!1))}v[Yl]=E}catch(st){Qn(s,s.return,st)}}break;case 6:if(Bo(a,s),as(s),k&4){if(s.stateNode===null)throw Error(n(162));v=s.stateNode,E=s.memoizedProps;try{v.nodeValue=E}catch(st){Qn(s,s.return,st)}}break;case 3:if(Bo(a,s),as(s),k&4&&f!==null&&f.memoizedState.isDehydrated)try{Ms(a.containerInfo)}catch(st){Qn(s,s.return,st)}break;case 4:Bo(a,s),as(s);break;case 13:Bo(a,s),as(s),v=s.child,v.flags&8192&&(E=v.memoizedState!==null,v.stateNode.isHidden=E,!E||v.alternate!==null&&v.alternate.memoizedState!==null||(gp=fn())),k&4&&iv(s);break;case 22:if(Re=f!==null&&f.memoizedState!==null,s.mode&1?(Ir=(he=Ir)||Re,Bo(a,s),Ir=he):Bo(a,s),as(s),k&8192){if(he=s.memoizedState!==null,(s.stateNode.isHidden=he)&&!Re&&(s.mode&1)!==0)for(tt=s,Re=s.child;Re!==null;){for(Pe=tt=Re;tt!==null;){switch($e=tt,Je=$e.child,$e.tag){case 0:case 11:case 14:case 15:ac(4,$e,$e.return);break;case 1:Ka($e,$e.return);var ot=$e.stateNode;if(typeof ot.componentWillUnmount=="function"){k=$e,f=$e.return;try{a=k,ot.props=a.memoizedProps,ot.state=a.memoizedState,ot.componentWillUnmount()}catch(st){Qn(k,f,st)}}break;case 5:Ka($e,$e.return);break;case 22:if($e.memoizedState!==null){uv(Pe);continue}}Je!==null?(Je.return=$e,tt=Je):uv(Pe)}Re=Re.sibling}e:for(Re=null,Pe=s;;){if(Pe.tag===5){if(Re===null){Re=Pe;try{v=Pe.stateNode,he?(E=v.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none"):(W=Pe.stateNode,Q=Pe.memoizedProps.style,I=Q!=null&&Q.hasOwnProperty("display")?Q.display:null,W.style.display=jn("display",I))}catch(st){Qn(s,s.return,st)}}}else if(Pe.tag===6){if(Re===null)try{Pe.stateNode.nodeValue=he?"":Pe.memoizedProps}catch(st){Qn(s,s.return,st)}}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:Bo(a,s),as(s),k&4&&iv(s);break;case 21:break;default:Bo(a,s),as(s)}}function as(s){var a=s.flags;if(a&2){try{e:{for(var f=s.return;f!==null;){if(rv(f)){var k=f;break e}f=f.return}throw Error(n(160))}switch(k.tag){case 5:var v=k.stateNode;k.flags&32&&(Kt(v,""),k.flags&=-33);var E=ov(s);hp(s,E,v);break;case 3:case 4:var I=k.stateNode.containerInfo,W=ov(s);fp(s,W,I);break;default:throw Error(n(161))}}catch(Q){Qn(s,s.return,Q)}s.flags&=-3}a&4096&&(s.flags&=-4097)}function Wj(s,a,f){tt=s,lv(s)}function lv(s,a,f){for(var k=(s.mode&1)!==0;tt!==null;){var v=tt,E=v.child;if(v.tag===22&&k){var I=v.memoizedState!==null||nd;if(!I){var W=v.alternate,Q=W!==null&&W.memoizedState!==null||Ir;W=nd;var he=Ir;if(nd=I,(Ir=Q)&&!he)for(tt=v;tt!==null;)I=tt,Q=I.child,I.tag===22&&I.memoizedState!==null?dv(v):Q!==null?(Q.return=I,tt=Q):dv(v);for(;E!==null;)tt=E,lv(E),E=E.sibling;tt=v,nd=W,Ir=he}cv(s)}else(v.subtreeFlags&8772)!==0&&E!==null?(E.return=v,tt=E):cv(s)}}function cv(s){for(;tt!==null;){var a=tt;if((a.flags&8772)!==0){var f=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Ir||rd(5,a);break;case 1:var k=a.stateNode;if(a.flags&4&&!Ir)if(f===null)k.componentDidMount();else{var v=a.elementType===a.type?f.memoizedProps:zo(a.type,f.memoizedProps);k.componentDidUpdate(v,f.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var E=a.updateQueue;E!==null&&uy(a,E,k);break;case 3:var I=a.updateQueue;if(I!==null){if(f=null,a.child!==null)switch(a.child.tag){case 5:f=a.child.stateNode;break;case 1:f=a.child.stateNode}uy(a,I,f)}break;case 5:var W=a.stateNode;if(f===null&&a.flags&4){f=W;var Q=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":Q.autoFocus&&f.focus();break;case"img":Q.src&&(f.src=Q.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&&Ms(Pe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Ir||a.flags&512&&dp(a)}catch($e){Qn(a,a.return,$e)}}if(a===s){tt=null;break}if(f=a.sibling,f!==null){f.return=a.return,tt=f;break}tt=a.return}}function uv(s){for(;tt!==null;){var a=tt;if(a===s){tt=null;break}var f=a.sibling;if(f!==null){f.return=a.return,tt=f;break}tt=a.return}}function dv(s){for(;tt!==null;){var a=tt;try{switch(a.tag){case 0:case 11:case 15:var f=a.return;try{rd(4,a)}catch(Q){Qn(a,f,Q)}break;case 1:var k=a.stateNode;if(typeof k.componentDidMount=="function"){var v=a.return;try{k.componentDidMount()}catch(Q){Qn(a,v,Q)}}var E=a.return;try{dp(a)}catch(Q){Qn(a,E,Q)}break;case 5:var I=a.return;try{dp(a)}catch(Q){Qn(a,I,Q)}}}catch(Q){Qn(a,a.return,Q)}if(a===s){tt=null;break}var W=a.sibling;if(W!==null){W.return=a.return,tt=W;break}tt=a.return}}var Kj=Math.ceil,od=j.ReactCurrentDispatcher,pp=j.ReactCurrentOwner,_o=j.ReactCurrentBatchConfig,hn=0,mr=null,nr=null,Er=0,ho=0,Za=qs(0),lr=0,lc=null,Fi=0,sd=0,mp=0,cc=null,Yr=null,gp=0,qa=1/0,Ns=null,id=!1,kp=null,Js=null,ad=!1,ei=null,ld=0,uc=0,wp=null,cd=-1,ud=0;function Ur(){return(hn&6)!==0?fn():cd!==-1?cd:cd=fn()}function ti(s){return(s.mode&1)===0?1:(hn&2)!==0&&Er!==0?Er&-Er:jj.transition!==null?(ud===0&&(ud=yo()),ud):(s=Xt,s!==0||(s=window.event,s=s===void 0?16:ka(s.type)),s)}function Uo(s,a,f,k){if(50<uc)throw uc=0,wp=null,Error(n(185));vr(s,f,k),((hn&2)===0||s!==mr)&&(s===mr&&((hn&2)===0&&(sd|=f),lr===4&&ni(s,Er)),Xr(s,k),f===1&&hn===0&&(a.mode&1)===0&&(qa=fn()+500,Du&&Vs()))}function Xr(s,a){var f=s.callbackNode;Dr(s,a);var k=mt(s,s===mr?Er:0);if(k===0)f!==null&&kn(f),s.callbackNode=null,s.callbackPriority=0;else if(a=k&-k,s.callbackPriority!==a){if(f!=null&&kn(f),a===1)s.tag===0?Tj(hv.bind(null,s)):Qw(hv.bind(null,s)),Ej(function(){(hn&6)===0&&Vs()}),f=null;else{switch(kt(k)){case 1:f=Pr;break;case 4:f=pt;break;case 16:f=In;break;case 536870912:f=Ve;break;default:f=In}f=bv(f,fv.bind(null,s))}s.callbackPriority=a,s.callbackNode=f}}function fv(s,a){if(cd=-1,ud=0,(hn&6)!==0)throw Error(n(327));var f=s.callbackNode;if(Ga()&&s.callbackNode!==f)return null;var k=mt(s,s===mr?Er:0);if(k===0)return null;if((k&30)!==0||(k&s.expiredLanes)!==0||a)a=dd(s,k);else{a=k;var v=hn;hn|=2;var E=mv();(mr!==s||Er!==a)&&(Ns=null,qa=fn()+500,Ui(s,a));do try{Gj();break}catch(W){pv(s,W)}while(!0);Ph(),od.current=E,hn=v,nr!==null?a=0:(mr=null,Er=0,a=lr)}if(a!==0){if(a===2&&(v=fr(s),v!==0&&(k=v,a=yp(s,v))),a===1)throw f=lc,Ui(s,0),ni(s,k),Xr(s,fn()),f;if(a===6)ni(s,k);else{if(v=s.current.alternate,(k&30)===0&&!Zj(v)&&(a=dd(s,k),a===2&&(E=fr(s),E!==0&&(k=E,a=yp(s,E))),a===1))throw f=lc,Ui(s,0),ni(s,k),Xr(s,fn()),f;switch(s.finishedWork=v,s.finishedLanes=k,a){case 0:case 1:throw Error(n(345));case 2:Hi(s,Yr,Ns);break;case 3:if(ni(s,k),(k&130023424)===k&&(a=gp+500-fn(),10<a)){if(mt(s,0)!==0)break;if(v=s.suspendedLanes,(v&k)!==k){Ur(),s.pingedLanes|=s.suspendedLanes&v;break}s.timeoutHandle=_h(Hi.bind(null,s,Yr,Ns),a);break}Hi(s,Yr,Ns);break;case 4:if(ni(s,k),(k&4194240)===k)break;for(a=s.eventTimes,v=-1;0<k;){var I=31-wn(k);E=1<<I,I=a[I],I>v&&(v=I),k&=~E}if(k=v,k=fn()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*Kj(k/1960))-k,10<k){s.timeoutHandle=_h(Hi.bind(null,s,Yr,Ns),k);break}Hi(s,Yr,Ns);break;case 5:Hi(s,Yr,Ns);break;default:throw Error(n(329))}}}return Xr(s,fn()),s.callbackNode===f?fv.bind(null,s):null}function yp(s,a){var f=cc;return s.current.memoizedState.isDehydrated&&(Ui(s,a).flags|=256),s=dd(s,a),s!==2&&(a=Yr,Yr=f,a!==null&&vp(a)),s}function vp(s){Yr===null?Yr=s:Yr.push.apply(Yr,s)}function Zj(s){for(var a=s;;){if(a.flags&16384){var f=a.updateQueue;if(f!==null&&(f=f.stores,f!==null))for(var k=0;k<f.length;k++){var v=f[k],E=v.getSnapshot;v=v.value;try{if(!Lo(E(),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 ni(s,a){for(a&=~mp,a&=~sd,s.suspendedLanes|=a,s.pingedLanes&=~a,s=s.expirationTimes;0<a;){var f=31-wn(a),k=1<<f;s[f]=-1,a&=~k}}function hv(s){if((hn&6)!==0)throw Error(n(327));Ga();var a=mt(s,0);if((a&1)===0)return Xr(s,fn()),null;var f=dd(s,a);if(s.tag!==0&&f===2){var k=fr(s);k!==0&&(a=k,f=yp(s,k))}if(f===1)throw f=lc,Ui(s,0),ni(s,a),Xr(s,fn()),f;if(f===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=a,Hi(s,Yr,Ns),Xr(s,fn()),null}function bp(s,a){var f=hn;hn|=1;try{return s(a)}finally{hn=f,hn===0&&(qa=fn()+500,Du&&Vs())}}function Bi(s){ei!==null&&ei.tag===0&&(hn&6)===0&&Ga();var a=hn;hn|=1;var f=_o.transition,k=Xt;try{if(_o.transition=null,Xt=1,s)return s()}finally{Xt=k,_o.transition=f,hn=a,(hn&6)===0&&Vs()}}function xp(){ho=Za.current,Dn(Za)}function Ui(s,a){s.finishedWork=null,s.finishedLanes=0;var f=s.timeoutHandle;if(f!==-1&&(s.timeoutHandle=-1,xj(f)),nr!==null)for(f=nr.return;f!==null;){var k=f;switch(Ih(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&Pu();break;case 3:Ha(),Dn(qr),Dn(jr),Wh();break;case 5:Uh(k);break;case 4:Ha();break;case 13:Dn(Zn);break;case 19:Dn(Zn);break;case 10:Lh(k.type._context);break;case 22:case 23:xp()}f=f.return}if(mr=s,nr=s=ri(s.current,null),Er=ho=a,lr=0,lc=null,mp=sd=Fi=0,Yr=cc=null,Li!==null){for(a=0;a<Li.length;a++)if(f=Li[a],k=f.interleaved,k!==null){f.interleaved=null;var v=k.next,E=f.pending;if(E!==null){var I=E.next;E.next=v,k.next=I}f.pending=k}Li=null}return s}function pv(s,a){do{var f=nr;try{if(Ph(),Gu.current=Qu,Vu){for(var k=qn.memoizedState;k!==null;){var v=k.queue;v!==null&&(v.pending=null),k=k.next}Vu=!1}if(zi=0,pr=ar=qn=null,nc=!1,rc=0,pp.current=null,f===null||f.return===null){lr=1,lc=a,nr=null;break}e:{var E=s,I=f.return,W=f,Q=a;if(a=Er,W.flags|=32768,Q!==null&&typeof Q=="object"&&typeof Q.then=="function"){var he=Q,Re=W,Pe=Re.tag;if((Re.mode&1)===0&&(Pe===0||Pe===11||Pe===15)){var $e=Re.alternate;$e?(Re.updateQueue=$e.updateQueue,Re.memoizedState=$e.memoizedState,Re.lanes=$e.lanes):(Re.updateQueue=null,Re.memoizedState=null)}var Je=zy(I);if(Je!==null){Je.flags&=-257,Fy(Je,I,W,E,a),Je.mode&1&&Dy(E,he,a),a=Je,Q=he;var ot=a.updateQueue;if(ot===null){var st=new Set;st.add(Q),a.updateQueue=st}else ot.add(Q);break e}else{if((a&1)===0){Dy(E,he,a),Ep();break e}Q=Error(n(426))}}else if(Un&&W.mode&1){var Jn=zy(I);if(Jn!==null){(Jn.flags&65536)===0&&(Jn.flags|=256),Fy(Jn,I,W,E,a),Oh(Wa(Q,W));break e}}E=Q=Wa(Q,W),lr!==4&&(lr=2),cc===null?cc=[E]:cc.push(E),E=I;do{switch(E.tag){case 3:E.flags|=65536,a&=-a,E.lanes|=a;var le=Py(E,Q,a);cy(E,le);break e;case 1:W=Q;var te=E.type,ce=E.stateNode;if((E.flags&128)===0&&(typeof te.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(Js===null||!Js.has(ce)))){E.flags|=65536,a&=-a,E.lanes|=a;var Ue=Ly(E,W,a);cy(E,Ue);break e}}E=E.return}while(E!==null)}kv(f)}catch(ct){a=ct,nr===f&&f!==null&&(nr=f=f.return);continue}break}while(!0)}function mv(){var s=od.current;return od.current=Qu,s===null?Qu:s}function Ep(){(lr===0||lr===3||lr===2)&&(lr=4),mr===null||(Fi&268435455)===0&&(sd&268435455)===0||ni(mr,Er)}function dd(s,a){var f=hn;hn|=2;var k=mv();(mr!==s||Er!==a)&&(Ns=null,Ui(s,a));do try{qj();break}catch(v){pv(s,v)}while(!0);if(Ph(),hn=f,od.current=k,nr!==null)throw Error(n(261));return mr=null,Er=0,lr}function qj(){for(;nr!==null;)gv(nr)}function Gj(){for(;nr!==null&&!tr();)gv(nr)}function gv(s){var a=vv(s.alternate,s,ho);s.memoizedProps=s.pendingProps,a===null?kv(s):nr=a,pp.current=null}function kv(s){var a=s;do{var f=a.alternate;if(s=a.return,(a.flags&32768)===0){if(f=Fj(f,a,ho),f!==null){nr=f;return}}else{if(f=Bj(f,a),f!==null){f.flags&=32767,nr=f;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{lr=6,nr=null;return}}if(a=a.sibling,a!==null){nr=a;return}nr=a=s}while(a!==null);lr===0&&(lr=5)}function Hi(s,a,f){var k=Xt,v=_o.transition;try{_o.transition=null,Xt=1,Vj(s,a,f,k)}finally{_o.transition=v,Xt=k}return null}function Vj(s,a,f,k){do Ga();while(ei!==null);if((hn&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 E=f.lanes|f.childLanes;if(br(s,E),s===mr&&(nr=mr=null,Er=0),(f.subtreeFlags&2064)===0&&(f.flags&2064)===0||ad||(ad=!0,bv(In,function(){return Ga(),null})),E=(f.flags&15990)!==0,(f.subtreeFlags&15990)!==0||E){E=_o.transition,_o.transition=null;var I=Xt;Xt=1;var W=hn;hn|=4,pp.current=null,Hj(s,f),av(f,s),mj(Eh),_i=!!xh,Eh=xh=null,s.current=f,Wj(f),dn(),hn=W,Xt=I,_o.transition=E}else s.current=f;if(ad&&(ad=!1,ei=s,ld=v),E=s.pendingLanes,E===0&&(Js=null),cn(f.stateNode),Xr(s,fn()),a!==null)for(k=s.onRecoverableError,f=0;f<a.length;f++)v=a[f],k(v.value,{componentStack:v.stack,digest:v.digest});if(id)throw id=!1,s=kp,kp=null,s;return(ld&1)!==0&&s.tag!==0&&Ga(),E=s.pendingLanes,(E&1)!==0?s===wp?uc++:(uc=0,wp=s):uc=0,Vs(),null}function Ga(){if(ei!==null){var s=kt(ld),a=_o.transition,f=Xt;try{if(_o.transition=null,Xt=16>s?16:s,ei===null)var k=!1;else{if(s=ei,ei=null,ld=0,(hn&6)!==0)throw Error(n(331));var v=hn;for(hn|=4,tt=s.current;tt!==null;){var E=tt,I=E.child;if((tt.flags&16)!==0){var W=E.deletions;if(W!==null){for(var Q=0;Q<W.length;Q++){var he=W[Q];for(tt=he;tt!==null;){var Re=tt;switch(Re.tag){case 0:case 11:case 15:ac(8,Re,E)}var Pe=Re.child;if(Pe!==null)Pe.return=Re,tt=Pe;else for(;tt!==null;){Re=tt;var $e=Re.sibling,Je=Re.return;if(nv(Re),Re===he){tt=null;break}if($e!==null){$e.return=Je,tt=$e;break}tt=Je}}}var ot=E.alternate;if(ot!==null){var st=ot.child;if(st!==null){ot.child=null;do{var Jn=st.sibling;st.sibling=null,st=Jn}while(st!==null)}}tt=E}}if((E.subtreeFlags&2064)!==0&&I!==null)I.return=E,tt=I;else e:for(;tt!==null;){if(E=tt,(E.flags&2048)!==0)switch(E.tag){case 0:case 11:case 15:ac(9,E,E.return)}var le=E.sibling;if(le!==null){le.return=E.return,tt=le;break e}tt=E.return}}var te=s.current;for(tt=te;tt!==null;){I=tt;var ce=I.child;if((I.subtreeFlags&2064)!==0&&ce!==null)ce.return=I,tt=ce;else e:for(I=te;tt!==null;){if(W=tt,(W.flags&2048)!==0)try{switch(W.tag){case 0:case 11:case 15:rd(9,W)}}catch(ct){Qn(W,W.return,ct)}if(W===I){tt=null;break e}var Ue=W.sibling;if(Ue!==null){Ue.return=W.return,tt=Ue;break e}tt=W.return}}if(hn=v,Vs(),et&&typeof et.onPostCommitFiberRoot=="function")try{et.onPostCommitFiberRoot(rt,s)}catch{}k=!0}return k}finally{Xt=f,_o.transition=a}}return!1}function wv(s,a,f){a=Wa(f,a),a=Py(s,a,1),s=Xs(s,a,1),a=Ur(),s!==null&&(vr(s,1,a),Xr(s,a))}function Qn(s,a,f){if(s.tag===3)wv(s,s,f);else for(;a!==null;){if(a.tag===3){wv(a,s,f);break}else if(a.tag===1){var k=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(Js===null||!Js.has(k))){s=Wa(f,s),s=Ly(a,s,1),a=Xs(a,s,1),s=Ur(),a!==null&&(vr(a,1,s),Xr(a,s));break}}a=a.return}}function Yj(s,a,f){var k=s.pingCache;k!==null&&k.delete(a),a=Ur(),s.pingedLanes|=s.suspendedLanes&f,mr===s&&(Er&f)===f&&(lr===4||lr===3&&(Er&130023424)===Er&&500>fn()-gp?Ui(s,0):mp|=f),Xr(s,a)}function yv(s,a){a===0&&((s.mode&1)===0?a=1:(a=Qe,Qe<<=1,(Qe&130023424)===0&&(Qe=4194304)));var f=Ur();s=Es(s,a),s!==null&&(vr(s,a,f),Xr(s,f))}function Xj(s){var a=s.memoizedState,f=0;a!==null&&(f=a.retryLane),yv(s,f)}function Qj(s,a){var f=0;switch(s.tag){case 13:var k=s.stateNode,v=s.memoizedState;v!==null&&(f=v.retryLane);break;case 19:k=s.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(a),yv(s,f)}var vv;vv=function(s,a,f){if(s!==null)if(s.memoizedProps!==a.pendingProps||qr.current)Vr=!0;else{if((s.lanes&f)===0&&(a.flags&128)===0)return Vr=!1,zj(s,a,f);Vr=(s.flags&131072)!==0}else Vr=!1,Un&&(a.flags&1048576)!==0&&Jw(a,Fu,a.index);switch(a.lanes=0,a.tag){case 2:var k=a.type;td(s,a),s=a.pendingProps;var v=Pa(a,jr.current);Ua(a,f),v=qh(null,a,k,s,v,f);var E=Gh();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,Gr(k)?(E=!0,Lu(a)):E=!1,a.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,Fh(a),v.updater=Ju,a.stateNode=v,v._reactInternals=a,ep(a,k,s,f),a=op(null,a,k,!0,E,f)):(a.tag=0,Un&&E&&Ah(a),Br(null,a,v,f),a=a.child),a;case 16:k=a.elementType;e:{switch(td(s,a),s=a.pendingProps,v=k._init,k=v(k._payload),a.type=k,v=a.tag=eC(k),s=zo(k,s),v){case 0:a=rp(null,a,k,s,f);break e;case 1:a=Zy(null,a,k,s,f);break e;case 11:a=By(null,a,k,s,f);break e;case 14:a=Uy(null,a,k,zo(k.type,s),f);break e}throw Error(n(306,k,""))}return a;case 0:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:zo(k,v),rp(s,a,k,v,f);case 1:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:zo(k,v),Zy(s,a,k,v,f);case 3:e:{if(qy(a),s===null)throw Error(n(387));k=a.pendingProps,E=a.memoizedState,v=E.element,ly(s,a),Zu(a,k,null,f);var I=a.memoizedState;if(k=I.element,E.isDehydrated)if(E={element:k,isDehydrated:!1,cache:I.cache,pendingSuspenseBoundaries:I.pendingSuspenseBoundaries,transitions:I.transitions},a.updateQueue.baseState=E,a.memoizedState=E,a.flags&256){v=Wa(Error(n(423)),a),a=Gy(s,a,k,f,v);break e}else if(k!==v){v=Wa(Error(n(424)),a),a=Gy(s,a,k,f,v);break e}else for(fo=Zs(a.stateNode.containerInfo.firstChild),uo=a,Un=!0,Do=null,f=iy(a,null,k,f),a.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(za(),k===v){a=_s(s,a,f);break e}Br(s,a,k,f)}a=a.child}return a;case 5:return dy(a),s===null&&Rh(a),k=a.type,v=a.pendingProps,E=s!==null?s.memoizedProps:null,I=v.children,Sh(k,v)?I=null:E!==null&&Sh(k,E)&&(a.flags|=32),Ky(s,a),Br(s,a,I,f),a.child;case 6:return s===null&&Rh(a),null;case 13:return Vy(s,a,f);case 4:return Bh(a,a.stateNode.containerInfo),k=a.pendingProps,s===null?a.child=Fa(a,null,k,f):Br(s,a,k,f),a.child;case 11:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:zo(k,v),By(s,a,k,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(k=a.type._context,v=a.pendingProps,E=a.memoizedProps,I=v.value,Rn(Hu,k._currentValue),k._currentValue=I,E!==null)if(Lo(E.value,I)){if(E.children===v.children&&!qr.current){a=_s(s,a,f);break e}}else for(E=a.child,E!==null&&(E.return=a);E!==null;){var W=E.dependencies;if(W!==null){I=E.child;for(var Q=W.firstContext;Q!==null;){if(Q.context===k){if(E.tag===1){Q=Ss(-1,f&-f),Q.tag=2;var he=E.updateQueue;if(he!==null){he=he.shared;var Re=he.pending;Re===null?Q.next=Q:(Q.next=Re.next,Re.next=Q),he.pending=Q}}E.lanes|=f,Q=E.alternate,Q!==null&&(Q.lanes|=f),Dh(E.return,f,a),W.lanes|=f;break}Q=Q.next}}else if(E.tag===10)I=E.type===a.type?null:E.child;else if(E.tag===18){if(I=E.return,I===null)throw Error(n(341));I.lanes|=f,W=I.alternate,W!==null&&(W.lanes|=f),Dh(I,f,a),I=E.sibling}else I=E.child;if(I!==null)I.return=E;else for(I=E;I!==null;){if(I===a){I=null;break}if(E=I.sibling,E!==null){E.return=I.return,I=E;break}I=I.return}E=I}Br(s,a,v.children,f),a=a.child}return a;case 9:return v=a.type,k=a.pendingProps.children,Ua(a,f),v=Eo(v),k=k(v),a.flags|=1,Br(s,a,k,f),a.child;case 14:return k=a.type,v=zo(k,a.pendingProps),v=zo(k.type,v),Uy(s,a,k,v,f);case 15:return Hy(s,a,a.type,a.pendingProps,f);case 17:return k=a.type,v=a.pendingProps,v=a.elementType===k?v:zo(k,v),td(s,a),a.tag=1,Gr(k)?(s=!0,Lu(a)):s=!1,Ua(a,f),Oy(a,k,v),ep(a,k,v,f),op(null,a,k,!0,s,f);case 19:return Xy(s,a,f);case 22:return Wy(s,a,f)}throw Error(n(156,a.tag))};function bv(s,a){return gn(s,a)}function Jj(s,a,f,k){this.tag=s,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=k,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function No(s,a,f,k){return new Jj(s,a,f,k)}function Sp(s){return s=s.prototype,!(!s||!s.isReactComponent)}function eC(s){if(typeof s=="function")return Sp(s)?1:0;if(s!=null){if(s=s.$$typeof,s===X)return 11;if(s===ie)return 14}return 2}function ri(s,a){var f=s.alternate;return f===null?(f=No(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 fd(s,a,f,k,v,E){var I=2;if(k=s,typeof s=="function")Sp(s)&&(I=1);else if(typeof s=="string")I=5;else e:switch(s){case R:return Wi(f.children,v,E,a);case A:I=8,v|=8;break;case O:return s=No(12,f,a,v|2),s.elementType=O,s.lanes=E,s;case ne:return s=No(13,f,a,v),s.elementType=ne,s.lanes=E,s;case ee:return s=No(19,f,a,v),s.elementType=ee,s.lanes=E,s;case C:return hd(f,v,E,a);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case D:I=10;break e;case z:I=9;break e;case X:I=11;break e;case ie:I=14;break e;case be:I=16,k=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return a=No(I,f,a,v),a.elementType=s,a.type=k,a.lanes=E,a}function Wi(s,a,f,k){return s=No(7,s,k,a),s.lanes=f,s}function hd(s,a,f,k){return s=No(22,s,k,a),s.elementType=C,s.lanes=f,s.stateNode={isHidden:!1},s}function _p(s,a,f){return s=No(6,s,null,a),s.lanes=f,s}function Np(s,a,f){return a=No(4,s.children!==null?s.children:[],s.key,a),a.lanes=f,a.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},a}function tC(s,a,f,k,v){this.tag=a,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=_r(0),this.expirationTimes=_r(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_r(0),this.identifierPrefix=k,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function Tp(s,a,f,k,v,E,I,W,Q){return s=new tC(s,a,f,W,Q),a===1?(a=1,E===!0&&(a|=8)):a=0,E=No(3,null,null,a),s.current=E,E.stateNode=s,E.memoizedState={element:k,isDehydrated:f,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fh(E),s}function nC(s,a,f){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:P,key:k==null?null:""+k,children:s,containerInfo:a,implementation:f}}function xv(s){if(!s)return Gs;s=s._reactInternals;e:{if(Kn(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(Gr(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(Gr(f))return Yw(s,f,a)}return a}function Ev(s,a,f,k,v,E,I,W,Q){return s=Tp(f,k,!0,s,v,E,I,W,Q),s.context=xv(null),f=s.current,k=Ur(),v=ti(f),E=Ss(k,v),E.callback=a??null,Xs(f,E,v),s.current.lanes=v,vr(s,v,k),Xr(s,k),s}function pd(s,a,f,k){var v=a.current,E=Ur(),I=ti(v);return f=xv(f),a.context===null?a.context=f:a.pendingContext=f,a=Ss(E,I),a.payload={element:s},k=k===void 0?null:k,k!==null&&(a.callback=k),s=Xs(v,a,I),s!==null&&(Uo(s,v,I,E),Ku(s,v,I)),I}function md(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 Sv(s,a){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var f=s.retryLane;s.retryLane=f!==0&&f<a?f:a}}function jp(s,a){Sv(s,a),(s=s.alternate)&&Sv(s,a)}function rC(){return null}var _v=typeof reportError=="function"?reportError:function(s){console.error(s)};function Cp(s){this._internalRoot=s}gd.prototype.render=Cp.prototype.render=function(s){var a=this._internalRoot;if(a===null)throw Error(n(409));pd(s,a,null,null)},gd.prototype.unmount=Cp.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var a=s.containerInfo;Bi(function(){pd(null,s,null,null)}),a[ys]=null}};function gd(s){this._internalRoot=s}gd.prototype.unstable_scheduleHydration=function(s){if(s){var a=Zr();s={blockedOn:null,target:s,priority:a};for(var f=0;f<It.length&&a!==0&&a<It[f].priority;f++);It.splice(f,0,s),f===0&&$n(s)}};function Ap(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function kd(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function Nv(){}function oC(s,a,f,k,v){if(v){if(typeof k=="function"){var E=k;k=function(){var he=md(I);E.call(he)}}var I=Ev(a,k,s,0,null,!1,!1,"",Nv);return s._reactRootContainer=I,s[ys]=I.current,Gl(s.nodeType===8?s.parentNode:s),Bi(),I}for(;v=s.lastChild;)s.removeChild(v);if(typeof k=="function"){var W=k;k=function(){var he=md(Q);W.call(he)}}var Q=Tp(s,0,!1,null,null,!1,!1,"",Nv);return s._reactRootContainer=Q,s[ys]=Q.current,Gl(s.nodeType===8?s.parentNode:s),Bi(function(){pd(a,Q,f,k)}),Q}function wd(s,a,f,k,v){var E=f._reactRootContainer;if(E){var I=E;if(typeof v=="function"){var W=v;v=function(){var Q=md(I);W.call(Q)}}pd(a,I,s,v)}else I=oC(f,a,s,v,k);return md(I)}ts=function(s){switch(s.tag){case 3:var a=s.stateNode;if(a.current.memoizedState.isDehydrated){var f=At(a.pendingLanes);f!==0&&(lo(a,f|1),Xr(a,fn()),(hn&6)===0&&(qa=fn()+500,Vs()))}break;case 13:Bi(function(){var k=Es(s,1);if(k!==null){var v=Ur();Uo(k,s,1,v)}}),jp(s,1)}},Mn=function(s){if(s.tag===13){var a=Es(s,134217728);if(a!==null){var f=Ur();Uo(a,s,134217728,f)}jp(s,134217728)}},en=function(s){if(s.tag===13){var a=ti(s),f=Es(s,a);if(f!==null){var k=Ur();Uo(f,s,a,k)}jp(s,a)}},Zr=function(){return Xt},hr=function(s,a){var f=Xt;try{return Xt=s,a()}finally{Xt=f}},Jt=function(s,a,f){switch(a){case"input":if(Be(s,f),a=f.name,f.type==="radio"&&a!=null){for(f=s;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<f.length;a++){var k=f[a];if(k!==s&&k.form===s.form){var v=Mu(k);if(!v)throw Error(n(90));oe(k),Be(k,v)}}}break;case"textarea":Me(s,f);break;case"select":a=f.value,a!=null&&Vt(s,!!f.multiple,a,!1)}},De=bp,Xe=Bi;var sC={usingClientEntryPoint:!1,Events:[Xl,Oa,Mu,B,me,bp]},dc={findFiberByHostInstance:Ri,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},iC={bundleType:dc.bundleType,version:dc.version,rendererPackageName:dc.rendererPackageName,rendererConfig:dc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:j.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=gt(s),s===null?null:s.stateNode},findFiberByHostInstance:dc.findFiberByHostInstance||rC,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 yd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yd.isDisabled&&yd.supportsFiber)try{rt=yd.inject(iC),et=yd}catch{}}return Qr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=sC,Qr.createPortal=function(s,a){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ap(a))throw Error(n(200));return nC(s,a,null,f)},Qr.createRoot=function(s,a){if(!Ap(s))throw Error(n(299));var f=!1,k="",v=_v;return a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(k=a.identifierPrefix),a.onRecoverableError!==void 0&&(v=a.onRecoverableError)),a=Tp(s,1,!1,null,null,f,!1,k,v),s[ys]=a.current,Gl(s.nodeType===8?s.parentNode:s),new Cp(a)},Qr.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=gt(a),s=s===null?null:s.stateNode,s},Qr.flushSync=function(s){return Bi(s)},Qr.hydrate=function(s,a,f){if(!kd(a))throw Error(n(200));return wd(null,s,a,!0,f)},Qr.hydrateRoot=function(s,a,f){if(!Ap(s))throw Error(n(405));var k=f!=null&&f.hydratedSources||null,v=!1,E="",I=_v;if(f!=null&&(f.unstable_strictMode===!0&&(v=!0),f.identifierPrefix!==void 0&&(E=f.identifierPrefix),f.onRecoverableError!==void 0&&(I=f.onRecoverableError)),a=Ev(a,null,s,1,f??null,v,!1,E,I),s[ys]=a.current,Gl(s),k)for(s=0;s<k.length;s++)f=k[s],v=f._getVersion,v=v(f._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[f,v]:a.mutableSourceEagerHydrationData.push(f,v);return new gd(a)},Qr.render=function(s,a,f){if(!kd(a))throw Error(n(200));return wd(null,s,a,!1,f)},Qr.unmountComponentAtNode=function(s){if(!kd(s))throw Error(n(40));return s._reactRootContainer?(Bi(function(){wd(null,null,s,!1,function(){s._reactRootContainer=null,s[ys]=null})}),!0):!1},Qr.unstable_batchedUpdates=bp,Qr.unstable_renderSubtreeIntoContainer=function(s,a,f,k){if(!kd(f))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return wd(s,a,f,!1,k)},Qr.version="18.3.1-next-f1338f8080-20240426",Qr}var Ov;function c1(){if(Ov)return Rp.exports;Ov=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(),Rp.exports=gC(),Rp.exports}var kC=c1(),vd={},Mv;function wC(){if(Mv)return vd;Mv=1;var e=c1();return vd.createRoot=e.createRoot,vd.hydrateRoot=e.hydrateRoot,vd}var yC=wC();const mi="shell",u1="check",xm="ToolSearch",Rg="AskUserQuestion",vC=new Set(["edit","delete","move","execute"]),bC=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function d1(e){return e.kind?vC.has(e.kind):bC.has(e.name)}const xC=["read","edit","delete","move","search","execute","fetch"];function Og(e){return xC.includes(e??"")}function f1(e,t){return(Og(e.kind)||e.name===Rg||e.name===xm)&&Tf(t)}function Tf(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 ru=[{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"}],Qd="auto";function EC(e){return e.branch.startsWith("toyon/")}const Co="shell",Cs="login";function SC(e,t){return`${e}/${t}`}function _C(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 $o=e=>e==="working"||e==="waiting",NC=["use","always","off"];function h1(e){return e.find(t=>t.id==="default")}function TC(e){const t=h1(e);if(t!=null&&t.description)return e.find(n=>n!==t&&n.name===t.description)}function Sn(e){return e.worktree!==void 0}function aa(e){return e.kind==="main"}function ou(e){return e.kind==="spare"}function kr(e){return ou(e)||aa(e)}function Mg(e){return e.kind==="worktree"}function p1(e){return e.kind==="worktree"&&EC(e)}function Xi(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function Bd(e){return e.kind==="worktree"}function jf(e){return!!e.branch&&!e.locked&&!(e.worktree&&kr(e.worktree))}const la=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},jC=e=>kr(e)?0:1,CC=e=>e.variant?`group:${e.variant.group}`:`row:${e.id}`;function AC(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,la(o));continue}const c={tier:jC(o),at:la(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 Pv(e,t){const n=new Map;for(const r of e)n.set(r.id,r.promptedAt??0);for(const r of t){if(!Sn(r)||r.worktree.kind==="spare")continue;const o=r.worktree.repoId;n.set(o,Math.max(n.get(o)??0,la(r.worktree)))}return[...e].sort((r,o)=>(n.get(o.id)??0)-(n.get(r.id)??0))}const Lv="not opened in ";function IC(e){const t=e.lastIndexOf(Lv);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+Lv.length)}}const m1={image:6,paste:4,file:8,pick:8},$C={image:"image",paste:"paste",file:"file",pick:"element"},RC={image:"Image",paste:"Pasted text"},g1=(e,t)=>`${RC[e]} ${t}`,Pg=e=>`at most ${m1[e]} ${$C[e]}s per message`,OC=(e,t)=>e.filter(n=>n.kind===t).length,MC=(e,t)=>Math.max(0,m1[t]-OC(e,t));function Em(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 Lg(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function jc(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function Dg(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const il=e=>`card:${e}`,Ud=[{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"}],PC=new Set(["zen","close","back","forward"]);function k1(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const i=Ud.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=Ud.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 Ud){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 LC(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function w1(e){const t=Ud.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function DC(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function zC(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function FC(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 UC(e,t){const n=w1(e);return!!n.textKeeps&&FC(t)&&!(n.emptyGives&&BC(t))}const HC=["Find","Preview","Panels","Worktrees"],Cc={"quick-open":{label:"jump to file",section:"Find"},commands:{label:"command palette",section:"Find",advertise:{key:"F1",when:"firefox"}},search:{label:"search in files",section:"Find"},chats:{label:"search in chats",section:"Find"},pick:{label:"element to chat",section:"Preview"},inspect:{label:"element to code",section:"Preview"},zen:{label:"full-bleed preview",section:"Preview"},routes:{label:"go to page",section:"Preview"},reload:{label:"reload the preview",section:"Preview"},back:{label:"back in the preview",section:"Preview",hidden:!0},forward:{label:"forward in the preview",section:"Preview",hidden:!0},composer:{label:"chat panel, with the editor's selection",section:"Panels"},changes:{label:"changes panel",section:"Panels"},files:{label:"files panel",section:"Panels"},terminal:{label:"terminal",section:"Panels"},rail:{label:"worktree panel",section:"Panels"},"panel-tab-next":{label:"next panel tab",section:"Panels"},"panel-tab-prev":{label:"previous panel tab",section:"Panels",hidden:!0},"term-tab":{label:"next terminal tab",section:"Panels"},design:{label:"design system",section:"Panels"},keys:{label:"settings & shortcuts",section:"Panels"},close:{label:"close the pane",section:"Panels",hidden:!0},new:{label:"new worktree",section:"Worktrees",advertise:{key:"n",when:"pwa"}},worktree:{label:"switch worktree",section:"Worktrees"},"wt-prev":{label:"previous worktree",section:"Worktrees",advertise:{key:"Tab",when:"pwa"}},"wt-next":{label:"next worktree",section:"Worktrees",advertise:{key:"Tab",when:"pwa"}},"wt-unseen-prev":{label:"previous worktree worth a look",section:"Worktrees",hidden:!0},"wt-unseen-next":{label:"next worktree worth a look",section:"Worktrees"},"wt-archive":{label:"archive worktree",section:"Worktrees"},"mark-unread":{label:"mark worktree unread",section:"Worktrees"},project:{label:"open project",section:"Worktrees"},refs:{label:"open a branch or PR",section:"Worktrees"}},WC={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function KC(e,t={}){var c;const n=w1(e),r=Cc[e],o=r.advertise&&t[r.advertise.when]?r.advertise.key:n.key;if(o===n.bareAlias)return o;const i=o==="1-9"?"1-9":WC[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 ZC(e){return Object.keys(Cc).filter(t=>Cc[t].section===e&&!Cc[t].hidden)}const Dv={m:6e4,h:60*6e4};function qC(e){const[t,n]=GC(e);return`${t}${n.charAt(0)}`}function GC(e){const t=e/Dv.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/Dv.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const Dc={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function y1(e){return typeof e=="string"?e:e.cmd}function VC(e){return typeof e!="string"&&e.from==="trunk"}function YC(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(y1),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function XC(e){return e===Dc.folder.local||e===Dc.root.local}function QC(e){return XC(e)?"local":"shared"}function JC(e,t){return(Object.values(Dc).find(r=>r.shared===e||r.local===e)??Dc.folder)[t]}const eA=e=>`https://${e}/`;function tA(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 rA(n.origin)?n.origin:null}function nA(e){return e.toLowerCase().endsWith(".fly.dev")}function rA(e){let t;try{t=new URL(e)}catch{return!1}return t.origin!==e?!1:t.protocol==="https:"||t.protocol==="http:"&&zg(t.hostname)}const oA="toyon_grant";function zg(e){return e==="127.0.0.1"||e==="::1"||e==="[::1]"||e==="localhost"||e.endsWith(".localhost")}function sA(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const iA=4401,aA=25e4;function lA(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(...cA(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 cA(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)>aA)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 uA=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function zv(e){return e.match(uA)??[]}const dA=.4;function fA(e,t){if(e===t)return null;const n=lA(zv(e),zv(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<dA*Math.max(e.length,t.length)?null:{before:Fv(n,"-"),after:Fv(n,"+")}}function Fv(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 v1(n)}function Bv(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(v1)}function v1(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 hA=[{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"}],pA=[{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"}],mA=[{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)"}],Sm="merge",_m="merge";function fi(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??Sm;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 Cf(e){return e.base??e.defaultBranch}function gA(e){return e.base!==void 0&&e.base!==e.defaultBranch}function kA(e){return!!e.pr&&(e.lands??[]).some(t=>{var n;return t.pr===((n=e.pr)==null?void 0:n.number)})}function wA(e){return{land:"a land",commit:"a commit","sync-main":"a sync","pull-main":"a pull"}[e]}function Af(e){return kA(e)&&!e.landed?void 0:e.pr}function Fg(e,t){const n=Af(t);return e.land==="pr"&&(!n||n.state==="closed")?"create pr":"land"}function Jd(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??_m];switch(e.land){case"merge":return`Commit and ${n} ${t} here`;case"push":return`Commit, ${n} ${t} on origin and push it`;case"pr":return e.automerge?"Commit, push the branch and create a PR that GitHub merges when its rules allow":"Commit, push the branch and create a PR"}}function b1(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 Uv(e,t="|"){return e.map(n=>S1(n)).join(t)}function Nm(e,t){return typeof t=="bigint"?t.toString():t}function If(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function yA(e){return e==null}function Bg(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function vA(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 so(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function vi(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function bA(e){return JSON.stringify(e)}function xA(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const x1="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function zc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const EA=If(()=>{var e;if(Xo.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 Fc(e){if(zc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(zc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function E1(e){return Fc(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const SA=new Set(["string","number","symbol"]);function pl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bi(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 dt(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 S1(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function _A(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const NA={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 TA(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=vi(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]&&so(l,c,n.shape[c])}return so(this,"shape",l),l},checks:[]});return bi(e,i)}function jA(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=vi(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 so(this,"shape",l),l},checks:[]});return bi(e,i)}function CA(e,t){if(!Fc(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=vi(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return so(this,"shape",i),i}});return bi(e,o)}function AA(e,t){if(!Fc(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=vi(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return so(this,"shape",r),r}});return bi(e,n)}function IA(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=vi(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return so(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return bi(e,n)}function Hv(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=vi(t._zod.def,{get shape(){const u=t._zod.def.shape,p={...u};if(n)for(const h of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(u,h))throw new Error(`Unrecognized key: "${String(h)}"`);n[h]&&(p[h]=e?new e({type:"optional",innerType:u[h]}):u[h])}else for(const h of Reflect.ownKeys(u))p[h]=e?new e({type:"optional",innerType:u[h]}):u[h];return so(this,"shape",p),p},checks:[]});return bi(t,c)}function $A(e,t,n){const r=vi(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 so(this,"shape",i),i}});return bi(t,r)}function tl(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 RA(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 hc(e){return typeof e=="string"?e:e==null?void 0:e.message}function Wv(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Sl(e,t,n){var g,w,y,b,_,T,x,N,j,$;var r;const o=(w=(g=e.inst)==null?void 0:g._zod)==null?void 0:w.traits;o!=null&&o.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?(b=(y=e.schema)==null?void 0:y._zod.def)==null?void 0:b.error:void 0,l=e.message?e.message:hc((x=(T=(_=e.inst)==null?void 0:_._zod.def)==null?void 0:T.error)==null?void 0:x.call(T,e))??hc(i==null?void 0:i(e))??hc((N=t==null?void 0:t.error)==null?void 0:N.call(t,e))??hc((j=n.customError)==null?void 0:j.call(n,e))??hc(($=n.localeError)==null?void 0:$.call(n,e))??"Invalid input",{inst:c,schema:u,continue:p,input:h,...m}=e;return m.path??(m.path=[]),m.message=l,t!=null&&t.reportInput&&(m.input=h),m}const OA=/[\uD800-\uDBFF]/;function Ug(e){const t=e.length;if(!OA.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 Hg(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function MA(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Bc(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function PA(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):LA(e,n,r.value)}}function ml(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function _1(e,t,n){return ml(e,t,n,!1)}function LA(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:ml(this,t,n.bind(this))},set(r){ml(this,t,r)}})}function DA(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Pp,ci=!1;const zA={configurable:!0,get(){ci=!0}};function _n(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Pp!==e._zod){Pp=void 0;return}Pp=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,zA);const o=ci;ci=!1;try{const i=n(this);return ci?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ci=ci||o,i}catch(i){throw delete this[t],ci=ci||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function FA(e,t,n,r){const o=DA(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 BA="~constantCatch";function UA(e){const t=()=>e;return t[BA]=!0,t}var Kv;const Lp={value:void 0,enumerable:!1};let Zv="captureStackTrace"in Error?Error:null;function HA(e){const t=Zv;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Zv=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function xe(e,t,n,r){const o={};function i(g){this.def=g,this.constr=m,this.traits=new Set}i.prototype=o;const l=n,c=l&&new WeakSet;function u(g,w){if(!g._zod){Lp.value=new i(w);try{Object.defineProperty(g,"_zod",Lp)}finally{Lp.value=void 0}}if(g._zod.traits.has(e))return;if(g._zod.traits.add(e),t(g,w),c){const b=Object.getPrototypeOf(g),_=g._zod.constr.prototype;let T=b;for(;T&&T!==_;)T=Object.getPrototypeOf(T);const x=T??b;c.has(x)||(c.add(x),PA(x,l))}const y=m.prototype;for(const b in y)Object.prototype.hasOwnProperty.call(y,b)&&(b in g||(g[b]=y[b].bind(g)))}const p=(r==null?void 0:r.Parent)??Object;class h extends p{}Object.defineProperty(h,"name",{value:e});function m(g){var _;const w=r!=null&&r.Parent?HA(h):this;u(w,g);const y=w._zod.deferred;if(y){for(const T of y)T();w._zod.deferred=void 0}const b=(_=globalThis.__zod_globalConfig)==null?void 0:_.postProcessor;return b&&b(w),w}return Object.defineProperty(m,"init",{value:u}),Object.defineProperty(m,Symbol.hasInstance,{value:g=>{var w,y;return r!=null&&r.Parent&&g instanceof r.Parent?!0:(y=(w=g==null?void 0:g._zod)==null?void 0:w.traits)==null?void 0:y.has(e)}}),Object.defineProperty(m,"name",{value:e}),m}class al extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class N1 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Kv=globalThis).__zod_globalConfig??(Kv.__zod_globalConfig={});const Xo=globalThis.__zod_globalConfig;function xi(e){return e&&Object.assign(Xo,e),Xo}function WA(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Nm,2)),e.message}function KA(e){this._zod.message=e}const ZA={get:WA,set:KA,enumerable:!0,configurable:!0},Dp={value:void 0,enumerable:!1},zp={value:void 0,enumerable:!1},qv=new WeakSet([Object.prototype,Error.prototype]),T1=(e,t)=>{e.name="$ZodError",Dp.value=e._zod,Object.defineProperty(e,"_zod",Dp),zp.value=t,Object.defineProperty(e,"issues",zp),Dp.value=void 0,zp.value=void 0,Object.defineProperty(e,"message",ZA);const n=Object.getPrototypeOf(e);qv.has(n)||(qv.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})}}))},j1=xe("$ZodError",T1),C1=xe("$ZodError",T1,void 0,{Parent:Error});function qA(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 GA(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?qA(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function VA(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,p=0;for(;p<c.length;){const h=c[p],m=p===c.length-1;if(h==="_errors"){m&&u._errors.push(t(l)),p++;continue}Object.prototype.hasOwnProperty.call(u,h)||Object.defineProperty(u,h,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const g=u[h];m&&g._errors.push(t(l)),u=g,p++}}}};return r(e),n}function Rf(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const Wg=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 al;if(c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(p=>Sl(p,l,xi())));throw x1(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},Kg=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(p=>Sl(p,l,xi())));throw x1(u,(i==null?void 0:i.callee)??t),u}return c.value};return t},Of=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 al;return i.issues.length?{success:!1,error:new(e??j1)(i.issues.map(l=>Sl(l,o,xi())))}:{success:!0,data:i.value}},YA=Of(C1),Mf=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=>Sl(l,o,xi())))}:{success:!0,data:i.value}},XA=Mf(C1),QA=e=>{const t=Wg(e),n=(r,o,i,l)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,c,Rf(n,l))};return n},JA=e=>{const t=Wg(e),n=(r,o,i,l)=>t(r,o,i,Rf(n,l));return n},eI=e=>{const t=Kg(e),n=async(r,o,i,l)=>{const c=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,c,Rf(n,l))};return n},tI=e=>{const t=Kg(e),n=async(r,o,i,l)=>await t(r,o,i,Rf(n,l));return n},nI=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Of(e)(t,n,o)},rI=e=>(t,n,r)=>Of(e)(t,n,r),oI=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Mf(e)(t,n,o)},sI=e=>async(t,n,r)=>Mf(e)(t,n,r),iI=/^[cC][0-9a-z]{6,}$/,aI=/^[0-9a-z]+$/,lI=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,cI=/^[0-9a-vA-V]{20}$/,uI=/^[A-Za-z0-9]{27}$/,dI=/^[a-zA-Z0-9_-]{21}$/;function fI(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const hI=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,pI=/^([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})$/,Gv=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)$/,mI=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,gI="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function kI(){return new RegExp(gI,"u")}const wI=/^(?:(?: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])$/,yI=/^(([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}|:))$/,vI=/^((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])$/,bI=/^(([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])$/,xI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,A1=/^[A-Za-z0-9_-]*$/,EI=/^https?$/,SI=/^\+[1-9]\d{6,14}$/,I1="(?:(?:\\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 _I(e){return new RegExp(`^${e}$`)}const NI=_I(I1);function Tm(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 TI(e){return new RegExp(`^${Tm(e)}$`)}function jI(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Tm({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Tm({precision:e.precision})}`:n;return new RegExp(`^${I1}T(?:${r})$`)}const CI=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}$`)},AI=/^-?\d+$/,II=/^-?\d+(?:\.\d+)?$/,$I=/^(?:true|false)$/i,RI=/^[^A-Z]*$/,OI=/^[^a-z]*$/,io=xe("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Zg=e=>{const t=e.value;return!yA(t)&&t.length!==void 0},ef={number:"number",bigint:"bigint",object:"date"},$1=xe("$ZodCheckLessThan",(e,t)=>{io.init(e,t);const n=ef[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:ef[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})}}),R1=xe("$ZodCheckGreaterThan",(e,t)=>{io.init(e,t);const n=ef[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:ef[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})}}),MI=xe("$ZodCheckMultipleOf",(e,t)=>{io.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):vA(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})}}),PI=xe("$ZodCheckNumberFormat",(e,t)=>{var l;io.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]=NA[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=AI)}),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})}}),LI=xe("$ZodCheckMaxLength",(e,t)=>{var n;io.init(e,t),(n=e._zod.def).when??(n.when=Zg),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?Ug(o):i)<=t.maximum)return;const c=Hg(o);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),DI=xe("$ZodCheckMinLength",(e,t)=>{var n;io.init(e,t),(n=e._zod.def).when??(n.when=Zg),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?Ug(o):i)>=t.minimum)return;const c=Hg(o);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),zI=xe("$ZodCheckLengthEquals",(e,t)=>{var n;io.init(e,t),(n=e._zod.def).when??(n.when=Zg),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?Ug(o):i;if(l===t.length)return;const c=Hg(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})}}),Pf=xe("$ZodCheckStringFormat",(e,t)=>{var n,r;io.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=()=>{})}),FI=xe("$ZodCheckRegex",(e,t)=>{Pf.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})}}),BI=xe("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=RI),Pf.init(e,t)}),UI=xe("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=OI),Pf.init(e,t)}),HI=xe("$ZodCheckIncludes",(e,t)=>{io.init(e,t);const n=pl(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})}}),WI=xe("$ZodCheckStartsWith",(e,t)=>{io.init(e,t);const n=new RegExp(`^${pl(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})}}),KI=xe("$ZodCheckEndsWith",(e,t)=>{io.init(e,t);const n=new RegExp(`.*${pl(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})}}),ZI=xe("$ZodCheckOverwrite",(e,t)=>{io.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class qI{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 GI={major:4,minor:5,patch:4},Hn=xe("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=GI;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,p,h)=>{if(u.memo)return u;let m=tl(u),g;for(const w of p){if(w._zod.def.when){if(RA(u)||!w._zod.def.when(u))continue}else if(m)continue;const y=u.issues.length,b=w._zod.check(u);if(b instanceof Promise&&(h==null?void 0:h.async)===!1)throw new al;if(g||b instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await b,u.issues.length!==y&&(Wv(u.issues,y,e),m||(m=tl(u,y)))});else{if(u.issues.length===y)continue;Wv(u.issues,y,e),m||(m=tl(u,y))}}return g?g.then(()=>u):u},c=(u,p,h)=>{if(tl(u))return u.aborted=!0,u;const m=l(p,o,h);if(m instanceof Promise){if(h.async===!1)throw new al;return m.then(g=>e._zod.parse(g,h))}return e._zod.parse(m,h)};e._zod.run=(u,p)=>{if(p.skipChecks)return e._zod.parse(u,p);if(p.direction==="backward"){const m=e._zod.parse({value:u.value,issues:[]},{...p,skipChecks:!0});return m instanceof Promise?m.then(g=>c(g,u,p)):c(m,u,p)}const h=e._zod.parse(u,p);if(h instanceof Promise){if(p.async===!1)throw new al;return h.then(m=>l(m,o,p))}return l(h,o,p)}}},{get"~standard"(){return _1(this,"~standard",O1(this))},set"~standard"(e){ml(this,"~standard",e)}}),Vv=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function O1(e){return{validate:t=>{try{return Vv(YA(e,t))}catch{return XA(e,t).then(Vv)}},vendor:"zod",version:1}}const qg=xe("$ZodString",(e,t)=>{var n;Hn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??CI(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}}),Wn=xe("$ZodStringFormat",(e,t)=>{Pf.init(e,t),qg.init(e,t)}),VI=xe("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=pI),Wn.init(e,t)}),YI=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=Gv(r))}else t.pattern??(t.pattern=Gv());Wn.init(e,t)}),XI=xe("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=mI),Wn.init(e,t)}),M1=1,P1=2;function QI(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===EI.source&&!/^https?:\/\//i.test(e))return M1;try{return new URL(e)}catch{return P1}}const JI=/[\t\n\r]/g;function e$(e){return e.replace(JI,"")}function t$(e,t){return t.lastIndex=0,t.test(e.hostname)}function n$(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const r$=xe("$ZodURL",(e,t)=>{Wn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=QI(r,t);if(o===M1){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===P1){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!t$(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&&!n$(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:e$(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),o$=xe("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=kI()),Wn.init(e,t)}),s$=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?dI:fI(t.length)),Wn.init(e,t)}),i$=xe("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=iI),Wn.init(e,t)}),a$=xe("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=aI),Wn.init(e,t)}),l$=xe("$ZodULID",(e,t)=>{t.pattern??(t.pattern=lI),Wn.init(e,t)}),c$=xe("$ZodXID",(e,t)=>{t.pattern??(t.pattern=cI),Wn.init(e,t)}),u$=xe("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=uI),Wn.init(e,t)}),d$=xe("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=jI(t)),Wn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),f$=xe("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=NI),Wn.init(e,t)}),h$=xe("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=TI(t)),Wn.init(e,t)}),p$=xe("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=hI),Wn.init(e,t)}),m$=xe("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=wI),Wn.init(e,t),e._zod.bag.format="ipv4"}),g$=/^[0-9a-fA-F:.]+$/;function L1(e){if(!g$.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const k$=xe("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=yI),Wn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{L1(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),w$=xe("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=vI),Wn.init(e,t)});function y$(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:L1(n)}const v$=xe("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=bI),Wn.init(e,t),e._zod.check=n=>{y$(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function D1(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const b$=xe("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xI),Wn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{D1(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function x$(e){if(!A1.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return D1(n)}const E$=xe("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=A1),Wn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{x$(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),S$=xe("$ZodE164",(e,t)=>{t.pattern??(t.pattern=SI),Wn.init(e,t)});function _$(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 N$=xe("$ZodJWT",(e,t)=>{Wn.init(e,t),e._zod.check=n=>{_$(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),z1=xe("$ZodNumber",(e,t)=>{Hn.init(e,t),e._zod.pattern=e._zod.bag.pattern??II,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}}),T$=xe("$ZodNumberFormat",(e,t)=>{PI.init(e,t),z1.init(e,t)}),j$=xe("$ZodBoolean",(e,t)=>{Hn.init(e,t),e._zod.pattern=$I,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}}),C$=xe("$ZodUnknown",(e,t)=>{Hn.init(e,t),e._zod.parse=n=>n}),A$=xe("$ZodNever",(e,t)=>{Hn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Yv(e,t,n){e.issues.length&&t.issues.push(...$f(n,e.issues)),t.value[n]=e.value}const I$=xe("$ZodArray",(e,t)=>{Hn.init(e,t);const n=Xo.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],p=t.element._zod.run({value:u,issues:[]},o);p instanceof Promise?l.push(p.then(h=>Yv(h,r,c))):Yv(p,r,c)}return l.length?Promise.all(l).then(()=>r):r}});function tf(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 $$=[];function F1(e){var l,c,u,p;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:$$,o=r.length?[...t,...r]:t;for(const h of o)if(!((p=(u=(c=(l=e.shape)==null?void 0:l[h])==null?void 0:c._zod)==null?void 0:u.traits)!=null&&p.has("$ZodType")))throw new Error(`Invalid element at key "${String(h)}": expected a Zod schema`);const i=_A(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function B1(e,t,n,r,o,i){const l=[],c=o.keySet,u=o.catchall._zod,p=u.def.type,h=u.optin,m=u.optout;for(const g in t){if(c.has(g))continue;if(g==="__proto__"){p==="never"&&l.push(g);continue}if(p==="never"){l.push(g);continue}const w=u.run({value:t[g],issues:[]},r);w instanceof Promise?e.push(w.then(y=>tf(y,n,g,t,h,m))):tf(w,n,g,t,h,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 jm=new WeakMap,R$=xe("$ZodObject",(e,t)=>{Hn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;jm.set(t,u),Object.defineProperty(t,"shape",{get:()=>{const p={...u};return Object.defineProperty(t,"shape",{value:p}),jm.set(t,p),p}})}const r=If(()=>F1(t));_n(e,"propValues",u=>{const p=u.def.shape,h={};for(const m in p){const g=p[m]._zod;if(g.values){Object.prototype.hasOwnProperty.call(h,m)||so(h,m,new Set);for(const w of g.values)h[m].add(w);g.optin!==void 0&&h[m].add(void 0)}}return h});const o=zc,i=t.catchall;let l;const c=Xo.memoizer;c==null||c.attach(e),e._zod.parse=(u,p)=>{l??(l=r.value);const h=u.value;if(!o(h))return u.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),u;u.value=c?c.alloc(e,u,{},p):{};const m=[],g=l.shape;for(const w of l.allKeys){if(w==="__proto__")continue;const y=g[w],b=y._zod.optin,_=y._zod.optout,T=y._zod.run({value:h[w],issues:[]},p);T instanceof Promise?m.push(T.then(x=>tf(x,u,w,h,b,_))):tf(T,u,w,h,b,_)}return i?B1(m,h,u,p,r.value,e):m.length?Promise.all(m).then(()=>u):u}}),O$=xe("$ZodObjectJIT",(e,t)=>{R$.init(e,t);const n=e._zod.parse,r=If(()=>F1(t)),o=Xo.memoizer,i=w=>{var $,P;const y=r.value,b=y.symbolKeys,_=new qI(["payload","ctx"],{shape:w,inst:e,memo:o,syms:b}),T=R=>`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`,x=(R,A)=>`
|
|
47
|
-
for (let i = 0; i < ${R}.issues.length; i++) {
|
|
48
|
-
const iss = ${R}.issues[i];
|
|
49
|
-
iss.path = iss.path ? [${A}, ...iss.path] : [${A}];
|
|
50
|
-
payload.issues.push(iss);
|
|
51
|
-
}`;_.write("const input = payload.value;");const N=Object.create(null);let j=0;for(const R of y.allKeys)N[R]=`key_${j++}`;_.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const R of y.allKeys){if(R==="__proto__")continue;const A=N[R],O=typeof R=="symbol"?`syms[${b.indexOf(R)}]`:bA(R),D=`${O} in input`,z=w[R],X=($=z==null?void 0:z._zod)==null?void 0:$.optin,ne=X!==void 0,ee=((P=z==null?void 0:z._zod)==null?void 0:P.optout)==="optional";if(_.write(`const ${A} = ${T(O)};`),ne&&ee){const ie=X==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;_.write(`
|
|
52
|
-
const ${A}_present = ${D};
|
|
53
|
-
if (!${A}.issues.length || ${A}_present) {
|
|
54
|
-
if (${A}.issues.length) {${x(A,O)}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (${ie}) {
|
|
58
|
-
newResult[${O}] = ${A}.value;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
`)}else ne?_.write(`
|
|
63
|
-
if (${A}.issues.length) {${x(A,O)}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (${A}.value === undefined) {
|
|
67
|
-
if (${D}) {
|
|
68
|
-
newResult[${O}] = undefined;
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
newResult[${O}] = ${A}.value;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
`):_.write(`
|
|
75
|
-
const ${A}_present = ${D};
|
|
76
|
-
if (${A}.issues.length) {${x(A,O)}
|
|
77
|
-
}
|
|
78
|
-
if (!${A}_present && !${A}.issues.length) {
|
|
79
|
-
payload.issues.push({
|
|
80
|
-
code: "invalid_type",
|
|
81
|
-
expected: "nonoptional",
|
|
82
|
-
input: undefined,
|
|
83
|
-
path: [${O}]
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (${A}_present) {
|
|
88
|
-
newResult[${O}] = ${A}.value;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
`)}return _.write("payload.value = newResult;"),_.write("return payload;"),_.compile()};let l;const c=zc,u=!Xo.jitless,h=u&&EA.value,m=t.catchall;let g;e._zod.parse=(w,y)=>{g??(g=r.value);const b=w.value;return c(b)?u&&h&&(y==null?void 0:y.async)===!1&&y.jitless!==!0?(l||(l=i(t.shape)),w=l(w,y),m?B1([],b,w,y,g,e):w):n(w,y):(w.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),w)}});function Xv(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=>!tl(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=>Sl(l,r,xi())))}),t)}const U1=xe("$ZodUnion",(e,t)=>{Hn.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=>Bg(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=>Xv(c,r,e,o)):Xv(l,r,e,o)}}),M$=xe("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,U1.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,p]of Object.entries(c)){Object.prototype.hasOwnProperty.call(i,u)||so(i,u,new Set);for(const h of p)i[u].add(h)}}return i}),t.options.forEach((o,i)=>{const l=jm.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=If(()=>{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 p of u){if(i.has(p))throw new Error(`Duplicate discriminator value "${String(p)}"`);i.set(p,c)}}return i});e._zod.parse=(o,i)=>{const l=o.value;if(!zc(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)}}),P$=xe("$ZodIntersection",(e,t)=>{Hn.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,p])=>Qv(n,u,p)):Qv(n,i,l)}});function Cm(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(Fc(e)&&Fc(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=Cm(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=Cm(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 Qv(e,t,n){const r=new Map;let o;const i=new Map,l=(p,h)=>{var g,w;let m;if(p.code==="unrecognized_keys"&&!((g=p.path)!=null&&g.length))o??(o=p),m=p.keys;else if(p.code==="invalid_key"&&p.origin==="record"&&((w=p.path)==null?void 0:w.length)===1){const y=String(p.path[0]);i.has(y)||i.set(y,p),m=[y]}else return!1;for(const y of m)r.has(y)||r.set(y,{}),r.get(y)[h]=!0;return!0};for(const p of t.issues)l(p,"l")||e.issues.push(p);for(const p of n.issues)l(p,"r")||e.issues.push(p);const c=[...r].filter(([,p])=>p.l&&p.r).map(([p])=>p);if(c.length){const p=o?c.filter(h=>o.keys.includes(h)):[];p.length&&e.issues.push({...o,keys:p});for(const h of c)!p.includes(h)&&i.has(h)&&e.issues.push(i.get(h))}const u=Cm(t.value,n.value);if(!u.valid){if(tl(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const L$=xe("$ZodTuple",(e,t)=>{Hn.init(e,t);const n=t.items,r=Xo.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=Jv(n,"optin"),p=Jv(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 h=new Array(n.length);for(let m=0;m<n.length;m++){const g=n[m]._zod.run({value:l[m],issues:[]},i);g instanceof Promise?c.push(g.then(w=>{h[m]=w})):h[m]=g}if(t.rest){let m=n.length-1;const g=l.slice(n.length);for(const w of g){m++;const y=t.rest._zod.run({value:w,issues:[]},i);y instanceof Promise?c.push(y.then(b=>e0(b,o,m))):e0(y,o,m)}}return c.length?Promise.all(c).then(()=>t0(h,o,n,l,p)):t0(h,o,n,l,p)}});function Jv(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 e0(e,t,n){e.issues.length&&t.issues.push(...$f(n,e.issues)),t.value[n]=e.value}function t0(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 D$=xe("$ZodEnum",(e,t)=>{Hn.init(e,t);const n=b1(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(i=>SA.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>pl(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}}),z$=xe("$ZodLiteral",(e,t)=>{Hn.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"?pl(r):r?pl(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}}),F$=xe("$ZodTransform",(e,t)=>{var n;Hn.init(e,t),e._zod.optin="optional",(n=Xo.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new N1(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 al;return r.value=i,r}});function n0(e,t){return e.value=t.issues.length?void 0:t.value,e}const H1=xe("$ZodOptional",(e,t)=>{Hn.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(`^(${Bg(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=>n0(n,i)):n0(n,o)}return t.innerType._zod.run(n,r)}}),B$=xe("$ZodExactOptional",(e,t)=>{H1.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)}),U$=xe("$ZodNullable",(e,t)=>{Hn.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(`^(${Bg(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)}),H$=xe("$ZodDefault",(e,t)=>{Hn.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=>r0(i,t)):r0(o,t)}});function r0(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const W$=xe("$ZodPrefault",(e,t)=>{Hn.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))}),K$=xe("$ZodNonOptional",(e,t)=>{Hn.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=>o0(i,e)):o0(o,e)}});function o0(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 s0(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Sl(o,r,xi()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Z$=xe("$ZodCatch",(e,t)=>{Hn.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=>s0(n,i,t,r)):s0(n,o,t,r)}}),q$=xe("$ZodPipe",(e,t)=>{Hn.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=>bd(l,t.in,r)):bd(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>bd(i,t.out,r)):bd(o,t.out,r)}});function bd(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 G$=xe("$ZodReadonly",(e,t)=>{Hn.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(i0):i0(o)}});function i0(e){return e.memo||(e.value=Object.freeze(e.value)),e}const V$=xe("$ZodCustom",(e,t)=>{io.init(e,t),Hn.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=>a0(i,n,r,e));a0(o,n,r,e)}});function a0(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Bc(o))}}class Y$ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Am="~memo",l0=[];function Fp(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const c0=new WeakMap;function W1(e,t){const n=c0.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)&&W1(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 p=u.value;if(!(!p||typeof p!="object")){if(p._zod)o(p);else if(Array.isArray(p))for(const h of p)o(h)}}}return t.delete(e),c0.set(e,r),r}function X$(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let xd;const Ed=[],Q$={alloc(e,t,n){const r=xd;if(!r)return n;xd=void 0;const o={value:n,issues:null};return r.set(t.value,o),Ed.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"&&eR(i,o.value))throw new Y$;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=W1(e,new Set),!n))return e._zod.parse=i,e._zod.run===l&&(e._zod.run=i),i(c,u);const p=c.value;if(p===null||typeof p!="object")return i(c,u);let h=u[Am];h||(h={buckets:new Map,backEdges:void 0},u[Am]=h);let m;r===u?m=o:(m=X$(h,e),r=u,o=m);const g=m.get(p);if(g)return c.value=g.value,g.issues?g.issues.length&&c.issues.push(...Fp(g.issues)):(c.memo=!0,h.backEdges??(h.backEdges=new Set),h.backEdges.add(g.value)),c;xd=m;const w=Ed.length,y=i(c,u);xd=void 0;const b=Ed.length>w?Ed.pop():void 0;return y instanceof Promise?y.then(_=>(b&&(b.issues=_.issues.length?Fp(_.issues):l0),_)):(b&&(b.issues=y.issues.length?Fp(y.issues):l0),y)};e._zod.parse=l,e._zod.run===i&&(e._zod.run=l)})}};function J$(){return Q$}function eR(e,t){var r;const n=(r=e[Am])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const tR=()=>{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=MA(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 ${S1(i.values[0])}`:`Invalid option: expected one of ${Uv(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":""}: ${Uv(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 nR(){return{localeError:tR()}}var u0;class rR{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 oR(){return new rR}(u0=globalThis).__zod_globalRegistry??(u0.__zod_globalRegistry=oR());const vc=globalThis.__zod_globalRegistry;function sR(e,t){return new e({type:"string",...dt(t)})}function iR(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...dt(t)})}function aR(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...dt(t)})}function lR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...dt(t)})}function cR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...dt(t)})}function uR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...dt(t)})}function dR(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...dt(t)})}function fR(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...dt(t)})}function hR(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...dt(t)})}function pR(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...dt(t)})}function mR(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...dt(t)})}function gR(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...dt(t)})}function kR(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...dt(t)})}function wR(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...dt(t)})}function yR(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...dt(t)})}function vR(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...dt(t)})}function bR(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...dt(t)})}function xR(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...dt(t)})}function ER(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...dt(t)})}function SR(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...dt(t)})}function _R(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...dt(t)})}function NR(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...dt(t)})}function TR(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...dt(t)})}function jR(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...dt(t)})}function CR(e,t){return new e({type:"string",format:"date",check:"string_format",...dt(t)})}function AR(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...dt(t)})}function IR(e,t){return new e({type:"string",format:"duration",check:"string_format",...dt(t)})}function $R(e,t){return new e({type:"number",checks:[],...dt(t)})}function RR(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...dt(t)})}function OR(e,t){return new e({type:"boolean",...dt(t)})}function MR(e){return new e({type:"unknown"})}function PR(e,t){return new e({type:"never",...dt(t)})}function d0(e,t){return new $1({check:"less_than",...dt(t),value:e,inclusive:!1})}function Bp(e,t){return new $1({check:"less_than",...dt(t),value:e,inclusive:!0})}function f0(e,t){return new R1({check:"greater_than",...dt(t),value:e,inclusive:!1})}function Up(e,t){return new R1({check:"greater_than",...dt(t),value:e,inclusive:!0})}function h0(e,t){return new MI({check:"multiple_of",...dt(t),value:e})}function K1(e,t){return new LI({check:"max_length",...dt(t),maximum:e})}function nf(e,t){return new DI({check:"min_length",...dt(t),minimum:e})}function Z1(e,t){return new zI({check:"length_equals",...dt(t),length:e})}function LR(e,t){return new FI({check:"string_format",format:"regex",...dt(t),pattern:e})}function DR(e){return new BI({check:"string_format",format:"lowercase",...dt(e)})}function zR(e){return new UI({check:"string_format",format:"uppercase",...dt(e)})}function FR(e,t){return new HI({check:"string_format",format:"includes",...dt(t),includes:e})}function BR(e,t){return new WI({check:"string_format",format:"starts_with",...dt(t),prefix:e})}function UR(e,t){return new KI({check:"string_format",format:"ends_with",...dt(t),suffix:e})}function _l(e){return new ZI({check:"overwrite",tx:e})}function HR(e){return _l(t=>t.normalize(e))}function WR(){return _l(e=>e.trim())}function KR(){return _l(e=>e.toLowerCase())}function ZR(){return _l(e=>e.toUpperCase())}function qR(){return _l(e=>xA(e))}function GR(e,t,n){return new e({type:"array",element:t,...dt(n)})}function VR(e,t,n){return new e({type:"custom",check:"custom",fn:t,...dt(n)})}function YR(e,t){const n=XR(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Bc(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(Bc(i))}},e(r.value,r)),t);return n}function XR(e,t){const n=new io({check:"custom",...dt(t)});return n._zod.check=e,n}function Ac(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&so(e,r,n[r]);return e}function q1(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)??vc,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 gi(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 ur(e,t,n={path:[],schemaPath:[]}){var h,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=(h=e._zod).toJSONSchema)==null?void 0:m.call(h);if(c)l.schema=c;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,g);else{const y=l.schema,b=t.processors[o.type];if(!b)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);b(e,t,y,g)}const w=e._zod.parent;w&&(l.ref||(l.ref=w),ur(w,t,g),t.seen.get(w).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Ac(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 p0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function G1(e,t){var l,c,u,p;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 h of e.seen.entries()){const m=(l=e.metadataRegistry.get(h[0]))==null?void 0:l.id;if(m){const g=r.get(m);if(g&&g!==h[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,h[0])}}const o=h=>{var b;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const _=(b=e.external.registry.get(h[0]))==null?void 0:b.id,T=e.external.uri??(N=>N);if(_)return{ref:T(_)};const x=h[1].defId??h[1].schema.id??`schema${e.counter++}`;return h[1].defId=x,{defId:x,ref:`${T("__shared")}#/${m}/${p0(x)}`}}const g="#",w=`${g}/${m}/`;if(h[1]===n&&!h[1].schema.id)return{ref:g};const y=h[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:w+p0(y)}},i=h=>{if(h[1].schema.$ref)return;const m=h[1],{ref:g,defId:w}=o(h);m.def={...m.schema},w&&(m.defId=w);const y=m.schema;for(const b in y)delete y[b];y.$ref=g};if(e.cycles==="throw")for(const h of e.seen.entries()){const m=h[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 h of e.seen.entries()){const m=h[1];if(t===h[0]){i(h);continue}if(e.external){const w=(u=e.external.registry.get(h[0]))==null?void 0:u.id;if(t!==h[0]&&w){i(h);continue}}if((p=e.metadataRegistry.get(h[0]))==null?void 0:p.id){i(h);continue}if(m.cycle){i(h);continue}if(m.count>1&&e.reused==="ref"){i(h);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function V1(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;V1(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 Y1=new Set(["type","properties","required","additionalProperties"]),m0=["oneOf","anyOf"];function g0(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Im(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(!Y1.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 h of t){const m=((i=h.properties)==null?void 0:i[c])??g0(h);m!=null&&(u.some(g=>JSON.stringify(g)===JSON.stringify(m))||u.push(m))}const p=u.length===1?u[0]:Im(u)??{allOf:u};so(n,c,p)}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=g0(c);u&&!l.some(p=>JSON.stringify(p)===JSON.stringify(u))&&l.push(u)}l.length===1?o.additionalProperties=l[0]:l.length>1&&(o.additionalProperties={allOf:l})}return o}function QR(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of Y1)if(o in e)return;const n=t.filter(o=>m0.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=Im(t);else{const o=n[0],i=m0.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=>Im([...l,u]));if(c.some(u=>!u))return;r={[i]:c}}r&&(delete e.allOf,Ac(e,r))}function X1(e,t){var c,u,p,h;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const g=e.seen.get(m);if(g.ref===null)return;const w=g.def??g.schema,y={...w},b=g.ref;if(g.ref=null,b){r(b);const T=e.seen.get(b),x=T.schema;if(x.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(w.allOf=w.allOf??[],w.allOf.push(x)):Ac(w,x),Ac(w,y),m._zod.parent===b)for(const j in w)j==="$ref"||j==="allOf"||j in y||delete w[j];if(x.$ref&&T.def)for(const j in w)j==="$ref"||j==="allOf"||j in T.def&&JSON.stringify(w[j])===JSON.stringify(T.def[j])&&delete w[j]}const _=m._zod.parent;if(_&&_!==b){r(_);const T=e.seen.get(_);if(T!=null&&T.schema.$ref&&(w.$ref=T.schema.$ref,T.def))for(const x in w)x==="$ref"||x==="allOf"||x in T.def&&JSON.stringify(w[x])===JSON.stringify(T.def[x])&&delete w[x]}e.override({zodSchema:m,jsonSchema:w,path:g.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const m of[...e.seen.entries()].reverse())r(m[0]);if(e.target!=="openapi-3.0")for(const m of e.seen.entries())V1(m[1].def??m[1].schema);for(const m of e.deferred)m();if(e.intersections.length){const m=new Map;for(const g of e.seen.values())for(const w of[g.schema,g.def]){const y=w==null?void 0:w.allOf;if(!Array.isArray(y))continue;const b=m.get(y);b?b.push(w):m.set(y,[w])}for(const g of e.intersections)for(const w of m.get(g)??[])QR(w)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,(c=e.external)!=null&&c.uri){const m=(u=e.external.registry.get(t))==null?void 0:u.id;if(!m)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(m)}Ac(o,n.defId?n.schema:n.def??n.schema);const i=(p=e.metadataRegistry.get(t))==null?void 0:p.id;i!==void 0&&o.id===i&&delete o.id;const l=((h=e.external)==null?void 0:h.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const m of e.seen.entries()){const g=m[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,so(l,g.defId,g.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?o.$defs=l:o.definitions=l);try{const m=JSON.parse(JSON.stringify(o));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:rf(t,"input",e.processors),output:rf(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 JR=(e,t={})=>n=>{const r=q1({...n,processors:t});return ur(e,r),G1(r,e),X1(r,e)},rf=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},l=q1({...o??{},target:i,io:t,processors:n});return ur(e,l),G1(l,e),X1(l,e)},eO={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},tO=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:l,format:c,patterns:u,contentEncoding:p,laxFormat:h}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof l=="number"&&(o.maxLength=l),c&&(o.format=eO[c]??c,o.format===""&&delete o.format,(c==="time"||h)&&delete o.format),p&&(o.contentEncoding=p),u&&u.size>0){const m=[...u];m.length===1?o.pattern=m[0].source:m.length>1&&(o.allOf=[...m.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},nO=(e,t,n,r)=>{const o=n,{minimum:i,maximum:l,format:c,multipleOf:u,exclusiveMaximum:p,exclusiveMinimum:h}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";const m=typeof h=="number"&&h>=(i??Number.NEGATIVE_INFINITY),g=typeof p=="number"&&p<=(l??Number.POSITIVE_INFINITY),w=t.target==="draft-04"||t.target==="openapi-3.0";m?w?(o.minimum=h,o.exclusiveMinimum=!0):o.exclusiveMinimum=h:typeof i=="number"&&(o.minimum=i),g?w?(o.maximum=p,o.exclusiveMaximum=!0):o.exclusiveMaximum=p:typeof l=="number"&&(o.maximum=l),typeof u=="number"&&(Number.isFinite(u)&&u!==0?o.multipleOf=Math.abs(u):gi(e,t,o,r,`A multipleOf divisor of ${u} cannot be represented in JSON Schema`))},rO=(e,t,n,r)=>{n.type="boolean"},oO=(e,t,n,r)=>{n.not={}},sO=(e,t,n,r)=>{},iO=(e,t,n,r)=>{const o=e._zod.def,i=b1(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},aO=(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(gi(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof l=="bigint"){if(gi(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},lO=(e,t,n,r)=>{gi(e,t,n,r,"Custom types cannot be represented in JSON Schema")},cO=(e,t,n,r)=>{gi(e,t,n,r,"Transforms cannot be represented in JSON Schema")},uO=(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=ur(i.element,t,{...r,path:[...r.path,"items"]})};function of(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?of(t.out):t.type==="catch"?of(t.innerType):e._zod.optin}const dO=(e,t,n,r)=>{var h;const o=n,i=e._zod.def,l=i.shape;if(Object.getOwnPropertySymbols(l).length&&gi(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const m in l)so(o.properties,m,ur(l[m],t,{...r,path:[...r.path,"properties",m]}));const u=new Set(Object.keys(l)),p=new Set([...u].filter(m=>{const g=i.shape[m];return t.io==="input"?of(g)===void 0:g._zod.optout===void 0}));p.size>0&&(o.required=Array.from(p)),((h=i.catchall)==null?void 0:h._zod.def.type)==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=ur(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},fO=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,l=o.options.map((c,u)=>ur(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",u]}));i?n.oneOf=l:n.anyOf=l},hO=(e,t,n,r)=>{const o=e._zod.def,i=ur(o.left,t,{...r,path:[...r.path,"allOf",0]}),l=ur(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=p=>"allOf"in p&&Object.keys(p).length===1,u=[...c(i)?i.allOf:[i],...c(l)?l.allOf:[l]];n.allOf=u,t.intersections.push(u)},pO=(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,_)=>ur(b,t,{...r,path:[...r.path,l,_]})),p=i.rest?ur(i.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;let h=i.items.length;for(;h>0;){const b=i.items[h-1];if(!(t.io==="input"?of(b)!==void 0:b._zod.optout==="optional"))break;h--}const m=i.items.length,g=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=u,g?o.items=!1:p&&(o.items=p),h>0&&(o.minItems=h),g&&(o.maxItems=m)):t.target==="openapi-3.0"?(o.items={anyOf:u},p&&o.items.anyOf.push(p),h>0&&(o.minItems=h),g&&(o.maxItems=m)):(o.items=u,g?o.additionalItems=!1:p&&(o.additionalItems=p),h>0&&(o.minItems=h),g&&(o.maxItems=m));const{minimum:w,maximum:y}=e._zod.bag;typeof w=="number"&&(o.minItems=w),typeof y=="number"&&(o.maxItems=y)},mO=(e,t,n,r)=>{const o=e._zod.def,i=ur(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"}]},gO=(e,t,n,r)=>{const o=e._zod.def;ur(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Gg=Symbol();function Q1(e,t,n,r,o){let i=!1;const l=JSON.stringify(e,(c,u)=>typeof u!="bigint"?u:(i=!0,null));return i?(gi(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),Gg):JSON.parse(l)}const kO=(e,t,n,r)=>{const o=e._zod.def;ur(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const l=Q1(o.defaultValue,e,t,n,r);l!==Gg&&(n.default=l)},wO=(e,t,n,r)=>{const o=e._zod.def;ur(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const l=Q1(o.defaultValue,e,t,n,r);l!==Gg&&(n._prefault=l)},yO=(e,t,n,r)=>{const o=e._zod.def;ur(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let l;try{l=o.catchValue(void 0)}catch{gi(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=l},vO=(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;ur(l,t,r);const c=t.seen.get(e);c.ref=l},bO=(e,t,n,r)=>{const o=e._zod.def;ur(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},J1=(e,t,n,r)=>{const o=e._zod.def;ur(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},k0=new WeakSet([Object.prototype,Error.prototype]);function Sd(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 xO=(e,t)=>{j1.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);k0.has(n)||(k0.add(n),Sd(n,"format",r=>o=>VA(r,o)),Sd(n,"flatten",r=>o=>GA(r,o)),Sd(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,Nm,2)}),Sd(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,Nm,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Mo=xe("ZodError",xO,void 0,{Parent:Error}),EO=Wg(Mo),SO=Kg(Mo),_O=Of(Mo),NO=Mf(Mo),TO=QA(Mo),jO=JA(Mo),CO=eI(Mo),AO=tI(Mo),IO=nI(Mo),$O=rI(Mo),RO=oI(Mo),OO=sI(Mo);function MO(){Xo.localeError||xi(nR())}function Lf(){Xo.memoizer||xi({memoizer:J$()})}const Gn=xe("ZodType",(e,t)=>(MO(),Hn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(vi(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 bi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(R2(e,t))},superRefine(e,t){return this.check(O2(e,t))},overwrite(e){return this.check(_l(e))},optional(){return v0(this)},exactOptional(){return b2(this)},nullable(){return b0(this)},nullish(){return v0(b0(this))},nonoptional(e){return T2(this,e)},array(){return ra(this)},or(e){return f2([this,e])},and(e){return g2(this,e)},transform(e){return x0(this,v2(e))},default(e){return S2(this,e)},prefault(e){return N2(this,e)},catch(e){return C2(this,e)},pipe(e){return x0(this,e)},readonly(){return $2(this)},describe(e){const t=this.clone();return vc.add(t,{description:e}),t},meta(...e){if(e.length===0)return vc.get(this);const t=this.clone();return vc.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 _1(this,"~standard",{...O1(this),jsonSchema:{input:rf(this,"input"),output:rf(this,"output")}})},set"~standard"(e){ml(this,"~standard",e)},parse:function e(t,n){return EO(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await SO(this,t,n,{callee:e})},safeParse(e,t){return _O(this,e,t)},async safeParseAsync(e,t){return NO(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){ml(this,"spa",e)},encode:function e(t,n){return TO(this,t,n,{callee:e})},decode:function e(t,n){return jO(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await CO(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await AO(this,t,n,{callee:e})},safeEncode(e,t){return IO(this,e,t)},safeDecode(e,t){return $O(this,e,t)},async safeEncodeAsync(e,t){return RO(this,e,t)},async safeDecodeAsync(e,t){return OO(this,e,t)},toJSONSchema(e){return JR(this,{})(e)},get description(){var e;return(e=vc.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),eE=xe("_ZodString",(e,t)=>{qg.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>tO(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(LR(...e))},includes(...e){return this.check(FR(...e))},startsWith(...e){return this.check(BR(...e))},endsWith(...e){return this.check(UR(...e))},min(...e){return this.check(nf(...e))},max(...e){return this.check(K1(...e))},length(...e){return this.check(Z1(...e))},nonempty(...e){return this.check(nf(1,...e))},lowercase(e){return this.check(DR(e))},uppercase(e){return this.check(zR(e))},trim(){return this.check(WR())},normalize(...e){return this.check(HR(...e))},toLowerCase(){return this.check(KR())},toUpperCase(){return this.check(ZR())},slugify(){return this.check(qR())}}),PO=xe("ZodString",(e,t)=>{qg.init(e,t),eE.init(e,t)},{email(e){return this.check(iR(BO,e))},url(e){return this.check(fR(HO,e))},jwt(e){return this.check(TR(o2,e))},emoji(e){return this.check(hR(WO,e))},guid(e){return this.check(aR(UO,e))},uuid(e){return this.check(lR(_d,e))},uuidv4(e){return this.check(cR(_d,e))},uuidv6(e){return this.check(uR(_d,e))},uuidv7(e){return this.check(dR(_d,e))},nanoid(e){return this.check(pR(KO,e))},cuid(e){return this.check(mR(ZO,e))},cuid2(e){return this.check(gR(qO,e))},ulid(e){return this.check(kR(GO,e))},base64(e){return this.check(SR(t2,e))},base64url(e){return this.check(_R(n2,e))},xid(e){return this.check(wR(VO,e))},ksuid(e){return this.check(yR(YO,e))},ipv4(e){return this.check(vR(XO,e))},ipv6(e){return this.check(bR(QO,e))},cidrv4(e){return this.check(xR(JO,e))},cidrv6(e){return this.check(ER(e2,e))},e164(e){return this.check(NR(r2,e))},datetime(e){return this.check(jR(LO,e))},date(e){return this.check(CR(DO,e))},time(e){return this.check(AR(zO,e))},duration(e){return this.check(IR(FO,e))}});function Tn(e){return sR(PO,e)}const Vn=xe("ZodStringFormat",(e,t)=>{Wn.init(e,t),eE.init(e,t)}),LO=xe("ZodISODateTime",(e,t)=>{d$.init(e,t),Vn.init(e,t)}),DO=xe("ZodISODate",(e,t)=>{f$.init(e,t),Vn.init(e,t)}),zO=xe("ZodISOTime",(e,t)=>{h$.init(e,t),Vn.init(e,t)}),FO=xe("ZodISODuration",(e,t)=>{p$.init(e,t),Vn.init(e,t)}),BO=xe("ZodEmail",(e,t)=>{XI.init(e,t),Vn.init(e,t)}),UO=xe("ZodGUID",(e,t)=>{VI.init(e,t),Vn.init(e,t)}),_d=xe("ZodUUID",(e,t)=>{YI.init(e,t),Vn.init(e,t)}),HO=xe("ZodURL",(e,t)=>{r$.init(e,t),Vn.init(e,t)}),WO=xe("ZodEmoji",(e,t)=>{o$.init(e,t),Vn.init(e,t)}),KO=xe("ZodNanoID",(e,t)=>{s$.init(e,t),Vn.init(e,t)}),ZO=xe("ZodCUID",(e,t)=>{i$.init(e,t),Vn.init(e,t)}),qO=xe("ZodCUID2",(e,t)=>{a$.init(e,t),Vn.init(e,t)}),GO=xe("ZodULID",(e,t)=>{l$.init(e,t),Vn.init(e,t)}),VO=xe("ZodXID",(e,t)=>{c$.init(e,t),Vn.init(e,t)}),YO=xe("ZodKSUID",(e,t)=>{u$.init(e,t),Vn.init(e,t)}),XO=xe("ZodIPv4",(e,t)=>{m$.init(e,t),Vn.init(e,t)}),QO=xe("ZodIPv6",(e,t)=>{k$.init(e,t),Vn.init(e,t)}),JO=xe("ZodCIDRv4",(e,t)=>{w$.init(e,t),Vn.init(e,t)}),e2=xe("ZodCIDRv6",(e,t)=>{v$.init(e,t),Vn.init(e,t)}),t2=xe("ZodBase64",(e,t)=>{b$.init(e,t),Vn.init(e,t)}),n2=xe("ZodBase64URL",(e,t)=>{E$.init(e,t),Vn.init(e,t)}),r2=xe("ZodE164",(e,t)=>{S$.init(e,t),Vn.init(e,t)}),o2=xe("ZodJWT",(e,t)=>{N$.init(e,t),Vn.init(e,t)}),tE=xe("ZodNumber",(e,t)=>{z1.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>nO(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(f0(e,t))},gte(e,t){return this.check(Up(e,t))},min(e,t){return this.check(Up(e,t))},lt(e,t){return this.check(d0(e,t))},lte(e,t){return this.check(Bp(e,t))},max(e,t){return this.check(Bp(e,t))},int(e){return this.check(w0(e))},safe(e){return this.check(w0(e))},positive(e){return this.check(f0(0,e))},nonnegative(e){return this.check(Up(0,e))},negative(e){return this.check(d0(0,e))},nonpositive(e){return this.check(Bp(0,e))},multipleOf(e,t){return this.check(h0(e,t))},step(e,t){return this.check(h0(e,t))},finite(){return this}});function na(e){return $R(tE,e)}const s2=xe("ZodNumberFormat",(e,t)=>{T$.init(e,t),tE.init(e,t)});function w0(e){return RR(s2,e)}const i2=xe("ZodBoolean",(e,t)=>{j$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rO(e,n,r)});function To(e){return OR(i2,e)}const a2=xe("ZodUnknown",(e,t)=>{C$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sO()});function y0(){return MR(a2)}const l2=xe("ZodNever",(e,t)=>{A$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>oO(e,n,r)});function c2(e){return PR(l2,e)}const u2=xe("ZodArray",(e,t)=>{Lf(),I$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>uO(e,n,r,o),e.element=t.element},{min(e,t){return this.check(nf(e,t))},nonempty(e){return this.check(nf(1,e))},max(e,t){return this.check(K1(e,t))},length(e,t){return this.check(Z1(e,t))},unwrap(){return this.element}});function ra(e,t){return GR(u2,e,t)}const d2=xe("ZodObject",(e,t)=>{Lf(),O$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dO(e,n,r,o),FA(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Ic(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:y0()})},loose(){return this.clone({...this._zod.def,catchall:y0()})},strict(){return this.clone({...this._zod.def,catchall:c2()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return CA(this,e)},safeExtend(e){return AA(this,e)},merge(e){return IA(this,e)},pick(e){return TA(this,e)},omit(e){return jA(this,e)},partial(...e){return Hv(Vg,this,e[0])},exactPartial(...e){return Hv(oE,this,e[0],"exactPartial")},required(...e){return $A(sE,this,e[0])}});function Sr(e,t){const n={type:"object",shape:e??{},...dt(t)};return new d2(n)}const nE=xe("ZodUnion",(e,t)=>{U1.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fO(e,n,r,o),e.options=t.options});function f2(e,t){return new nE({type:"union",options:e,...dt(t)})}const h2=xe("ZodDiscriminatedUnion",(e,t)=>{nE.init(e,t),M$.init(e,t)});function p2(e,t,n){return new h2({type:"union",options:t,discriminator:e,...dt(n)})}const m2=xe("ZodIntersection",(e,t)=>{P$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hO(e,n,r,o)});function g2(e,t){return new m2({type:"intersection",left:e,right:t})}const k2=xe("ZodTuple",(e,t)=>{Lf(),L$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pO(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 Vg({type:"optional",innerType:n}))})}});function rE(e,t,n){const r=t instanceof Hn,o=r?n:t,i=r?t:null;return new k2({type:"tuple",items:e,rest:i,...dt(o)})}const $m=xe("ZodEnum",(e,t)=>{D$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(r,o,i)=>iO(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 $m({...t,checks:[],...dt(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 $m({...t,checks:[],...dt(o),entries:i})}});function Ic(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new $m({type:"enum",entries:n,...dt(t)})}const w2=xe("ZodLiteral",(e,t)=>{z$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>aO(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 Jr(e,t){return new w2({type:"literal",values:Array.isArray(e)?e:[e],...dt(t)})}const y2=xe("ZodTransform",(e,t)=>{Lf(),F$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cO(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new N1(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Bc(i,n.value,t));else{const l=i;l.fatal&&(l.continue=!1),l.code??(l.code="custom"),"input"in l||(l.input=n.value),l.inst??(l.inst=e),n.issues.push(Bc(l))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function v2(e){return new y2({type:"transform",transform:e})}const Vg=xe("ZodOptional",(e,t)=>{H1.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>J1(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function v0(e){return new Vg({type:"optional",innerType:e})}const oE=xe("ZodExactOptional",(e,t)=>{B$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>J1(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function b2(e){return new oE({type:"optional",innerType:e})}const x2=xe("ZodNullable",(e,t)=>{U$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function b0(e){return new x2({type:"nullable",innerType:e})}const E2=xe("ZodDefault",(e,t)=>{H$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function S2(e,t){return new E2({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():E1(t)}})}const _2=xe("ZodPrefault",(e,t)=>{W$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function N2(e,t){return new _2({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():E1(t)}})}const sE=xe("ZodNonOptional",(e,t)=>{K$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function T2(e,t){return new sE({type:"nonoptional",innerType:e,...dt(t)})}const j2=xe("ZodCatch",(e,t)=>{Z$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function C2(e,t){return new j2({type:"catch",innerType:e,catchValue:typeof t=="function"?t:UA(t)})}const A2=xe("ZodPipe",(e,t)=>{q$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vO(e,n,r,o),e.in=t.in,e.out=t.out});function x0(e,t){return new A2({type:"pipe",in:e,out:t})}const I2=xe("ZodReadonly",(e,t)=>{G$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bO(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function $2(e){return new I2({type:"readonly",innerType:e})}const iE=xe("ZodCustom",(e,t)=>{V$.init(e,t),Gn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lO(e,n,r,o)});function R2(e,t={}){return VR(iE,e,t)}function O2(e,t){return YR(e,t)}function M2(e,t={}){const n=new iE({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...dt(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 P2=["off","tailscale","any"],L2={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};Sr({updates:To().optional(),deploy:To().optional(),remote:Ic(P2).optional(),agents:ra(Tn()).optional(),customAgents:To().optional(),brandedListener:To().optional(),planSignIn:To().optional()});const D2={...L2,source:null,problem:null};function z2(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 Hp=6e3,E0=1500;function F2(e){if(e.length<=Hp)return e;const t=e.length-Hp;return`${e.slice(0,E0)}
|
|
94
|
-
[${t} characters cut here]
|
|
95
|
-
${e.slice(e.length-(Hp-E0))}`}const Nd=119,B2=2e3,sf=5e6,U2=["image/png","image/jpeg","image/gif","image/webp"],S0=2576,Wp=5*1024*1024,H2=1200,W2=10,K2=1e5,_0=100*1024*1024,Z2="pasted-text.txt";function q2(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function G2(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const V2=80;function Yg(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,V2)}}function aE(e){return e.length>=H2||e.split(`
|
|
97
|
-
`).length>=W2}function Y2({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function X2(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${Y2(e)})`}const Q2=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function J2(e){return e.replace(Q2,"")}const lE="Projects";function eM(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function Uc(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":eM(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 tM=/^(?:https?|ssh|git|file):\/\/\S+$/i,cE=/^[\w.-]+@[\w.-]+:\S+$/;function nM(e){const t=e.trim();if(!tM.test(t)&&!cE.test(t))return null;const n=rM(t);return n&&!Uc(n)?{url:t,name:n}:null}function rM(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((cE.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const oM=Sr({component:Tn().nullable(),file:Tn().nullable(),line:na().nullable(),callFile:Tn().nullable().default(null),callLine:na().nullable().default(null),tag:Tn(),selector:Tn()}),sM=Sr({tag:Tn().max(40),id:Tn().max(200),classes:ra(Tn().max(120)).max(16),text:Tn().max(200),attrs:ra(rE([Tn().max(40),Tn().max(200)])).max(12)}),iM=rE([na(),na()]),aM=oM.extend({classes:Tn(),text:Tn(),html:Tn(),route:Tn(),element:sM}),lM=p2("type",[Sr({type:Jr("loaded"),url:Tn(),title:Tn()}),Sr({type:Jr("navigated"),url:Tn(),title:Tn().optional()}),Sr({type:Jr("traversed"),dir:Ic(["back","forward"]).optional()}),Sr({type:Jr("title"),title:Tn()}),Sr({type:Jr("links"),links:ra(Sr({path:Tn().max(2048),text:Tn().max(120)})).max(200)}),Sr({type:Jr("hmr")}),Sr({type:Jr("page-error"),message:Tn(),source:Tn().optional(),line:na().optional()}),aM.extend({type:Jr("picked"),verb:Ic(["chat","code"]).default("chat"),site:Ic(["call","source"]).default("source")}),Sr({type:Jr("pick-cancel")}),Sr({type:Jr("highlight-miss"),path:Tn(),fileMatched:na(),withSource:na(),ranges:ra(iM).nullable()}),Sr({type:Jr("drag-files"),over:To().default(!0)}),Sr({type:Jr("drop-files"),files:ra(M2(File))}),Sr({type:Jr("focus"),gesture:To()}),Sr({type:Jr("key"),key:Tn(),code:Tn().optional(),meta:To(),ctrl:To().optional(),shift:To().optional(),alt:To().optional(),up:To().optional()})]);function uE(e){const t=lM.safeParse(e);return t.success?t.data:null}const cM=/["“”]([^"“”]*)["“”]?|(\S+)/g;function dE(e){const t=new Set;for(const n of e.matchAll(cM)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const uM="now",dM="http://preview.invalid",fM=200;function N0(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,fM).trim();return t||void 0}function Df(e){let t;try{t=new URL(e,dM)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=T0(t.pathname)||"/",r=t.hash.startsWith("#/")?T0(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const T0=e=>e.replace(/\/+$/,""),hM={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},af=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function fE(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 p of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const h=e.slice(c,p.index);h&&(i.push({text:h}),l+=af(h)),i.push({name:p[1]??p[2]??"param"}),l+="[^/]+?",c=(p.index??0)+p[0].length}const u=e.slice(c);if(u&&(i.push({text:u}),l+=af(u)),i.some(p=>"name"in p))return{kind:"mixed",pattern:l,parts:i}}return{kind:"static",text:e}}function pM(e){const t=e.split("/").filter(Boolean).map(fE);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${af(r.text)}`:r.kind==="optional-static"?n+=`(?:/${af(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+hM[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function mM(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 zf(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(fE))if(t+="/",o.kind==="static"||o.kind==="optional-static")t+=o.text;else if(o.kind==="mixed")for(const i of o.parts)"name"in i?r(i.name):t+=i.text;else r(o.name);return t||(t="/"),{text:t,params:n,literal:n.length>0?t.slice(0,n[0][0]):t}}const su={id:"toyon-dark",family:"Toyon",name:"Toyon Dark",kind:"dark",source:"builtin",pair:"toyon-light",colors:{surface0:"#32302d",surface1:"#3d3835",surface2:"#504943",element0:"#504943",element1:"#675c55",border0:"#504943",border1:"#675c55",text0:"#e6dcb6",text1:"#9e927e",text2:"#6a6055",red:"#ff4929",orange:"#fa891e",yellow:"#fcbe03",green:"#78c945",aqua:"#4dc7a7",blue:"#69a9e8",purple:"#ca94ca",diffAdd:"#6fae5f29",diffDel:"#c07f6a29"},syntax:{comment:"#6a6055",keyword:"#df714e",string:"#a5bd4d",number:"#ca94ca",type:"#f5bf3a",function:"#6bc198",variable:"#81a99d"}},hE={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"}},gM={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"}},kM={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"}},wM={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"}},yM={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"}},vM={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"}},bM={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"}},xM={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"}},EM={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"}},SM={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"}},_M={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"}},NM={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"}},TM={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"}},jM={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"}},CM={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"}},AM={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"}},IM={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"}},$M={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"}},RM=[xM,EM,SM,_M,NM,TM,jM,CM,AM,IM,$M],Hd=[su,hE,gM,kM,wM,yM,vM,bM,...RM],OM={mode:"dark",light:hE.id,dark:su.id},MM=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function PM(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function j0(e){const t=gE(e);return t>.008856?116*t**(1/3)-16:903.3*t}function pE(e,t){const n=j0(e)+t,r=ca(e);if(!r)return e;let o=0,i=2;for(let l=0;l<24;l++){const c=(o+i)/2,u=gl(Math.min(255,r[0]*c),Math.min(255,r[1]*c),Math.min(255,r[2]*c));j0(u)<n?o=c:i=c}return gl(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function LM(e){return pE(e.colors.surface1,-4)}function DM(e){return pE(e.colors.surface0,-4)}function C0(e){return qM(e,.55)}function zM(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 FM(e){const t={};for(const n of MM)t[PM(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(zM(e)))t[`--syntax-${n}`]=r;return t["--accent"]=Xg(e),t["--fault"]=BM(e),t["--sunken"]=LM(e),t["--sunken-floor"]=DM(e),t["--scrim"]=ZM(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=C0(e.colors.diffAdd),t["--diff-del-word"]=C0(e.colors.diffDel),t}function Xg(e){return mE(e.accent??"")??e.colors.orange}function BM(e){return Xg(e)===mE(e.colors.orange)?e.colors.red:e.colors.orange}function UM(e){return e==="system"||e==="daylight"}function Qg(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function Ff(e,t,n){const r=Qg(e,n);return t.find(o=>o.id===e[r])??Hd.find(o=>o.kind===r)??su}function HM(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 WM(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=HM(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 KM(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!UM(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function ca(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 mE(e){const t=ca(e);return t?gl(t[0],t[1],t[2],t[3]):null}function gl(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 ZM(e,t){const n=ca(e);return n?gl(n[0],n[1],n[2],t):e}function qM(e,t){const n=ca(e);return n?gl(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function fK(e,t){const n=ca(e),r=ca(t);if(!n||!r)return e;const o=n[3];return gl(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function gE(e){const t=ca(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 GM(e){return gE(e)>.179?"#1d2021":"#fbf1c7"}function Rm(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function kE(e,t){const n=A0(e),r=A0(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 A0(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 VM=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function YM(e){var t;return((t=VM.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const XM=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function Bf(e){var t;return((t=XM.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const Ge={active:"toyon-active",phoneRow:"toyon-phone-row",repo:"toyon-repo",lastActive:"toyon-last",discoveredOpen:"toyon-disc",archivedOpen:"toyon-arch",committedShut:"toyon-committed-shut",turnOpen:"toyon-turn-open",treeOpen:"toyon-tree",token:"toyon-token",theme:"toyon-theme",daylight:"toyon-sun",changesWidth:"toyon-changes-w",chatWidth:"toyon-chat-w",editorHeight:"toyon-dh",editorFull:"toyon-dfull",editorWrap:"toyon-dwrap",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",railWidth:"toyon-rail-w",chatSide:"toyon-chat-side",clipboardOffer:"toyon-clipboard-offer",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"},QM=[Ge.active,Ge.repo,Ge.lastActive,Ge.discoveredOpen,Ge.archivedOpen,Ge.committedShut,Ge.turnOpen,Ge.treeOpen,Ge.profilePrefix,Ge.modePrefix,Ge.modelPrefix,Ge.effortPrefix,Ge.phoneRow,Ge.version],JM=[Ge.profilePrefix,Ge.modePrefix,Ge.modelPrefix,Ge.effortPrefix],Wd=(e,t)=>`${e}@${t}`;function eP(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(Wd(c,e)))??null}catch{return null}},set(c,u){try{l==null||l.setItem(Wd(c,e),u)}catch{}},remove(c){try{l==null||l.removeItem(Wd(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 wE(l).filter(u=>u.endsWith(`@${e}`)))try{l==null||l.removeItem(c)}catch{}}}}function wE(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 tP="orch-";function nP(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=Ge[i],c=tP+l.slice(6);I0(r,c,l)}for(const[r,o]of[[t,QM.filter(i=>i!==Ge.phoneRow)],[n,[Ge.phoneRow]]]){const i=wE(r).filter(l=>!l.includes("@"));for(const l of o){const c=JM.includes(l)?i.filter(u=>u.startsWith(l)):i.filter(u=>u===l);for(const u of c)I0(r,u,Wd(u,e))}}}function I0(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 yE(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1])return vE(e[1]),e[1];try{return localStorage.getItem(Ge.token)??sessionStorage.getItem(Ge.token)??""}catch{return""}}function vE(e){try{localStorage.setItem(Ge.token,e)}catch{}}function Jg(){return yE()!==""}function ek(e,t){const n=new URL(e),r=`token=${t}`,o=i=>`&v=${encodeURIComponent(i??"")}`;return{origin:n.origin,host:n.hostname,token:t,ws:`${n.protocol==="https:"?"wss":"ws"}://${n.host}/ws?${r}`,attachment:(i,l)=>`${n.origin}/attachments/${i}/${l}?${r}`,attachmentWhere:(i,l)=>`${n.origin}/attachments/${i}/${l}?${r}&where`,upload:i=>`${n.origin}/uploads/${i}?${r}`,worktreeFile:(i,l,c)=>`${n.origin}/files/${i}/${l.split("/").map(encodeURIComponent).join("/")}?${r}${o(c)}`,loose:(i,l)=>`${n.origin}/loose/${encodeURIComponent(i)}?${r}${o(l)}`,health:`${n.origin}/health`,restart:i=>`${n.origin}/restart?${r}${i?`&${uM}`:""}`,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 Nl=e=>({authorization:`Bearer ${e.token}`});async function rP(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",Nl(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 oP(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 bE(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 sP(e){var t;try{const n=await fetch(e.changelog,{headers:Nl(e)});return!n.ok||!((t=n.headers.get("content-type"))!=null&&t.startsWith("text/markdown"))?null:await n.text()}catch{return null}}async function iP(e,t){try{const n=await fetch(t,{headers:Nl(e)});return n.ok?await n.json():null}catch{return null}}async function Uf(e,t,n,r){try{const o=await fetch(t,{method:"POST",headers:{...Nl(e),"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?null:await o.text()||`refused (${o.status})`}catch{return r}}const aP=e=>iP(e,e.tailnet),lP=e=>Uf(e,e.remote,{tailscale:!0},"Toyon is not answering; try again once it is back."),cP=e=>Uf(e,e.remote,{off:!0},"Toyon is not answering; try again once it is back.");async function xE(e,t,n){try{const r=await fetch(t,{method:"POST",headers:{...Nl(e),"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():null}catch{return null}}const EE="Toyon is not answering; try again once it is back.",uP=async e=>{const t=await xE(e,e.tailscale,{up:!0});return t===null?EE:t.refused},dP=async e=>await xE(e,e.tailscale,{login:!0})??{why:EE},fP=(e,t,n)=>Uf(e,e.machines,{origin:t,token:n},"Toyon here is not answering; the machine is not listed yet."),hP=(e,t,n)=>Uf(e,e.knockAnswer(t),{letIn:n},"Toyon is not answering");async function SE(e){try{const t=await fetch(e.previewGrant,{method:"POST",headers:Nl(e)});return t.ok?await t.json():null}catch{return null}}const pP=2e3;async function _E(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,pP))}return"gone"}async function Om(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 mP=1e3,gP=3e4,kP=1500,wP=5e3,$0=50,yP=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree"||e.t==="batch-worktrees";class vP{constructor(t,n,r,o={}){$t(this,"ws",null);$t(this,"queue",[]);$t(this,"closed",!1);$t(this,"attempt",0);$t(this,"timer",null);$t(this,"downAt",null);$t(this,"downCode",0);$t(this,"sayTimer",null);$t(this,"sentDown",new Set);$t(this,"drops",0);$t(this,"urls");$t(this,"suspended",!1);$t(this,"connectDeadline");$t(this,"settle");$t(this,"backoffMin");$t(this,"wake",()=>{var n;if(this.closed||this.suspended||document.visibilityState!=="visible"||((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN)return;this.timer&&clearTimeout(this.timer),this.timer=null,this.attempt=0,this.drops=0,this.downAt!==null&&(this.downAt=Date.now(),this.onStatus(!1,null),this.armSay());const t=this.ws;this.connect(),t==null||t.close()});this.onMsg=n,this.onStatus=r,this.connectDeadline=o.connectDeadline??wP,this.settle=o.settle??kP,this.backoffMin=o.backoffMin??mP,this.urls=ek(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===iA)return"unauthorized";if(this.drops<2)return null;try{return(await fetch(this.urls.health,{signal:AbortSignal.timeout(2e3)})).ok?"blocked":"down"}catch{return"down"}}say(t){this.downAt??(this.downAt=Date.now()),this.downCode=t,this.armSay()}armSay(){if(this.downAt===null)return;const t=this.downAt,n=()=>!this.closed&&this.downAt===t&&document.visibilityState==="visible";this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=setTimeout(()=>{n()&&this.diagnose(this.downCode).then(r=>{n()&&this.onStatus(!1,r)})},Math.max(0,t+this.settle-Date.now()))}connect(){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.drops=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.drops++,this.say(o.code);const i=Math.min(gP,this.backoffMin*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)),yP(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>$0&&this.queue.splice(0,this.queue.length-$0)}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 tk(e){return e==="cancelled"||e==="expired"}function NE(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:tk(t.outcome)?t:null}function bP(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 xP(e){return e.map(()=>({selected:[]}))}function R0(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 lf(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 O0(e,t,n,r){return e.map((o,i)=>i!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function Kd(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?lf(e,t,void 0):e}function EP(e){return e?e.options.length+(e.note?1:0):0}function SP(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function TE(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function ll(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function Td(e,t){return e.every((n,r)=>!n.required||ll(t[r]))}function _P(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return rk(((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 NP(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(i=>{var l;return rk(((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 nk(e,t){return e.map((n,r)=>{const o=_P(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function TP(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function jP(e){if(e.outcome!=="answered")return null;const t=(e.answers??[]).map(n=>{var r;return((r=n.note)==null?void 0:r.trim())??""}).filter(Boolean);return t.length>0?t.join(`
|
|
98
|
-
`):null}function CP(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 nl(e,t){if(!e)return 0;if(TE(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 AP(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function IP(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const i=(n+o)%r;if(!ll(t[i]))return i}return-1}function $c(e){return e.length>1?e.length:-1}function $P(e){return e.length+($c(e)===-1?0:1)}function M0(e,t,n){const r=IP(e,t,n);if(r!==-1)return{current:r,cursor:nl(e[r],t[r]),send:!1};const o=$c(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:nl(e[n],t[n]),send:!0}}const jE=/\s*\(recommended\)\s*$/i;function RP(e){return jE.test(e)}function rk(e){return e.replace(jE,"")}const OP={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function CE(e,t,n,r){return n!==null&&r===n.host?`${sA(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:zg(r)?`http://${r==="localhost"?"127.0.0.1":r}:${t}/`:`https://${r}:${t}/`}function P0(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function AE(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 MP(e){var r;const t=(r=e.source)==null?void 0:r.replace(/[?#].*$/,""),n=t?` (${AE(t)}:${e.line??"?"})`:"";return`${e.message}${n}`.slice(0,B2)}function jd(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function Is(e){var t,n,r;return e.agent==="waiting"?"waiting":e.agent==="working"&&e.stopping?"stopping":e.agent==="working"?"working":e.agent==="error"||((n=(t=e.worktree)==null?void 0:t.lastTurn)==null?void 0:n.end)==="failed"?"failed":(r=e.worktree)!=null&&r.landed?"landed":e.procs.some(o=>o.status==="crashed"||o.status==="unreachable")?"crashed":e.procs.some(o=>o.status==="running")?"running":e.procs.some(o=>o.status==="starting")?"starting":e.procs.some(o=>o.status==="asleep")?"asleep":"idle"}const PP={waiting:"Waiting for you",stopping:"Agent stopping",working:"Agent working",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function ok(e,t=!1){const n=Is(e);return n==="idle"&&t?"Not set up":PP[n]}const LP={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function DP(e){return LP[e]}function IE(e,t){return t&&Is(e)!=="waiting"?t:null}const zP={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function sk(e){return zP[e]}function $E(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 RE(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const OE=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function cf(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function ME(e){const t=new Set;for(const n of e)for(const r of cf(n))t.add(r);return[...t].sort(OE)}function ik(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function ak(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 FP=/Firefox\//.test(navigator.userAgent);function lk(){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 BP=/Chrome\//.test(navigator.userAgent)&&lk(),zt=e=>KC(e,{firefox:FP,pwa:BP});function ck(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function Mm(e,t){return e.worktree&&kr(e.worktree)&&t?t.defaultBranch:e.name}function uk(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 wr(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 Qi(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function UP(e,t,n,r){var l;if(!t)return null;const o=e.filter(Sn).filter(c=>c.repoId===t&&(c.worktree.agent??r)===n);return((l=o.find(c=>kr(c.worktree))??o[0])==null?void 0:l.id)??null}const HP=200;function WP(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=HP)break;const o=Df(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function PE(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const ki=e=>"uploading"in e&&e.uploading===!0;function cl(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 dk=e=>e.filter(t=>!ki(t)).map(cl);let KP=0;function Pm(e,t){const n=new Map(t.filter(o=>!ki(o)).map(o=>[JSON.stringify(cl(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${++KP}`;return o.kind==="paste"?{...o,key:c,...Yg(o.text)}:{...o,key:c}}),...t.filter(ki)]}const Lm="out:",ZP=(e,t,n)=>`${Lm}${e}:${t}:${n}`;function ds(e){if(!e.startsWith(Lm))return null;const t=e.slice(Lm.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 bc(e,t,n,r){const o=r.length?dk(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 qP(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(ki)){n.add(o.log);continue}r.push(o.id)}return r}const LE=e=>e.flatMap(t=>"upload"in t&&t.upload?[t.upload]:[]);function GP(e){const t=n=>LE(n.items).some(r=>!n.before.includes(r));return[...e.filter(t),...e.filter(n=>!t(n))]}const Zd=["files","changes","history"],VP=e=>Zd.includes(e),DE=e=>!!(e!=null&&e.carry)&&!e.batch&&e.variants===1,Tl=e=>(e==null?void 0:e.worktree.id)??null,kl="new-project",fa=Object.freeze({chat:[],log:[],queue:[],page:{},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:Co}),fk=e=>({...e,phase:"editing",repoId:null}),L0=()=>fk({mode:"create",name:"",parent:`~/${lE}`}),YP=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function XP(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&VP(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function eo(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 hk(e,t){return{...e,layout:t,changesAuto:!1}}const wi=e=>Bf(e)?"preview":"file",QP=(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),pc=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function zE(e,t,n,r){var i;if(!r.fiber)return r;const o=(i=Ro(e,t).changedRanges[n])==null?void 0:i.offset;return o===void 0?r:{n:r.n-o}}function JP(e){const t=e.cached??su,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],lent:null,archiving:[],shipping:{},visibleDiscovered:[],discoveredOpen:e.storedDiscoveredOpen??{},archivedOpen:e.storedArchivedOpen??{},committedShut:e.storedCommittedShut??{},turnOpen:e.storedTurnOpen??{},treeOpen:e.storedTreeOpen??{},treeReveal:null,refs:{},chats:{},archived:{},archivedPage:null,lastActive:e.storedLastActive??{},pendingOpen:!1,activeId:null,carryTo:null,clientId:e.clientId,storedActive:e.storedActive??null,storedRepo:e.storedRepo??null,heard:!1,local:{},editor:null,openUrl:null,reloadReq:null,dragFiles:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:YP,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:Hd.some(o=>o.id===t.id)?Hd:[...Hd,t],themePrefs:{...OM,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:D2,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?hk(n,r):n}function FE(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function eL(e){return e.previewTheme??Ff(e.themePrefs,e.themes,FE(e))}function Ro(e,t){return t&&e.local[t]||fa}function wo(e,t){return t&&e.rows.find(n=>n.id===t)||null}function BE(e,t){const n=wo(e,t);return n?$o(n.agent)||!!e.shipping[n.id]||(n.queued??0)>0:!1}function un(e,t){const n=wo(e,t);return n&&Sn(n)?n:null}function UE(e){var o;const t=un(e,e.activeId);if(!t||!aa(t.worktree)||t.agent!=="idle"||!((o=wl(e,t.repoId))!=null&&o.empty))return!1;const n=Ei(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&&Ro(e,t.id).chat.length===0}function Hf(e){return e.newProject!==null||UE(e)}function tL(e){return e.incompatible||Hf(e)}function nL(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function uf(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function pk(e){const t=e.archivedPage?null:wo(e,e.activeId);return(t==null?void 0:t.repoId)??e.activeRepoId}function Ao(e){const t=Ei(e,pk(e));return!!t&&nL(t)}function HE(e){return e.layout.chat&&!Ao(e)&&!e.archivedPage&&!VE(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function WE(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 Ko(e){return Ao(e)?e:eo(e,{chat:!0})}function Ei(e,t){return t&&e.repos.find(n=>n.id===t)||null}function KE(e,t){if(!t)return null;const n=e.rows.filter(Sn).filter(r=>r.repoId===t);return n.find(r=>ou(r.worktree))??n.find(r=>aa(r.worktree))??null}function wl(e,t){return t&&e.trunks[t]||null}function xc(e){return Ao(e)||e.archivedPage||e.notesPage?null:e.activeId}function mk(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function df(e){if(e.archivedPage||e.notesPage)return null;const t=un(e,e.activeId);return t&&mk(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function gk(e,t,n){const r=e.worktree.from;if(e.repoId===t||(r==null?void 0:r.kind)!=="worktree"||r.origin.repoId!==t)return null;const o=n.find(i=>i.id===r.origin.id);return o&&Sn(o)&&o.repoId===t?o:null}function ZE(e,t){return e.repoId!==t&&(e.agent==="waiting"||!!e.unseen)}function Wf(e,t,n,r){return e.repoId===t||gk(e,t,n)!==null||ZE(e,t)||e.id===r}function qE(e,t,n){return!e||!t||!Sn(e)||e.repoId===t||gk(e,t,n)?null:ZE(e,t)?e.id:null}function GE(e,t){return t.length?e.filter(n=>!t.includes(n.id)):e}function rL(e,t,n,r){const o=GE(e,n).filter(Sn);return AC(t?o.filter(i=>Wf(i,t,o,r)):o)}function oL(e,t){const n=e.filter(r=>!Sn(r));return t?n.filter(r=>r.repoId===t):n}function ul(e,t,n=e.rows){var c;const r=n.filter(Sn),o=e.archiving.length?r.filter(u=>!e.archiving.includes(u.id)):r,i=t?e.lastActive[t]:void 0;if(i&&o.some(u=>u.id===i))return i;const l=t?o.filter(u=>u.repoId===t):o;return((c=l.find(u=>ou(u.worktree))??l.find(u=>aa(u.worktree))??l[0])==null?void 0:c.id)??null}function D0(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function z0(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)||eS({trunks:n},l))&&(r[l]=c);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(l=>sL(e[l],r[l]))?e:r}const sL=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function rl(e,t){var m;const n=wo(e,t),r=!!n&&Sn(n)&&!!e.activeRepoId&&Wf(n,e.activeRepoId,e.rows,e.lent),o=r&&e.lent!==t?qE(n,e.activeRepoId,e.rows):r?e.lent:null,i=r?e.activeRepoId:(n==null?void 0:n.repoId)??e.activeRepoId,l=n&&Sn(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,c=e.activeId!==t?e.activeId:null,u=c?e.local[c]:void 0,p=u&&((m=u.mark)==null?void 0:m.by)==="reveal"?ol(u,"reveal"):null,h=c&&p?{...e.local,[c]:p}:e.local;return{...e,activeId:t,activeRepoId:i,lent:o,lastActive:l,editor:null,archivedPage:null,notesPage:!1,local:h}}function yl(e){return Oo(e)?"history":e.layout.changesTab}function iL(e,t){const n=yl(e);if(Oo(e))return n;const r=Zd.length;return Zd[(Zd.indexOf(n)+t+r)%r]??"changes"}function VE(e){if(e.archivedPage)return null;const t=wo(e,e.activeId);return t&&!Sn(t)?t:null}function aL(e){return e.notesSeen||e.ranBefore===null||!kE(e.version,e.ranBefore)?null:e.version}function Oo(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 ol(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const YE=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 lL=0;function Hc(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function cL(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]=Hc(r[o]);return{...e,local:r}}function uL(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]??fa,u=c.chat.some(p=>p.kind==="user")?{at:i.at}:i;o={...o,[n]:Hc(o[n]),[r]:{...c,sending:u}}}for(const c of t){const u=o[c.id];u!=null&&u.sending&&!u.sending.message&&$o(c.agent)&&(o={...o,[c.id]:Hc(u)})}return o}function xt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??fa)}}}function F0(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 dL(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"&&tk(t.outcome),i=t.type==="agent-ask-end"&&t.outcome==="expired"?t.id:null,{card:l,cardParked:c,askRevived:u,...p}=e;return{...p,...l&&!n&&(l.id!==r||o)?{card:l}:{},...c&&!n&&c!==r?{cardParked:c}:{},...i?{askRevived:i}:u&&!n?{askRevived:u}:{}}}function fL(e,t,n){return xt(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function XE(e,t,n){return fL(Ko(e),t,{kind:"error",text:n})}function Dm(e,t){const n=Tl(un(e,e.activeId));return n?xt(Ko(e),n,r=>({...r,notice:t})):e}function B0(e,t,n){return un(e,t)?XE(e,t,n):Dm(e,n)}function hL(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function pL(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?hk(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function mL(e){return e.a==="server"&&e.msg.t==="git-status"}function gL(e){return{variants:1,batch:!1,agent:e.defaultAgent}}function kL(e){const t=un(e,e.activeId);return!!t&&kr(t.worktree)&&!e.archivedPage&&!Hf(e)?e.draft?e:{...e,draft:gL(e)}:e.draft?{...e,draft:null}:e}function QE(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&un(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function wL(e){const t=e.activeRepoId;if(!t)return e;const n=un(e,e.activeId);return!n||n.repoId===t||Wf(n,t,GE(e.rows,e.archiving),e.lent)?e:rl(e,ul(e,t))}function U0(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?hi(o,{a:"open",overlay:{kind:"devices"}}):o}const yL=e=>{var t;return e.frame==="desk"&&(e.remote!==null||((t=e.tailscale)==null?void 0:t.state)==="ready")};function hi(e,t){let n=kL(wL(vL(e,t)));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(Oo(n)===null||un(n,n.archivedPage)!==null)&&(n=QE(n)),n.activeRepoId!==e.activeRepoId?n=pL(n):n.frame==="desk"&&n.activeRepoId&&!mL(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:rL(n.rows,n.activeRepoId,n.archiving,n.lent),visibleDiscovered:oL(n.rows,n.activeRepoId)}}function vL(e,t){var n,r,o,i,l,c,u,p;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure===void 0?e.connectFailure:t.failure,local:t.v?e.local:_L(e.local)};case"activate":return{...rl(e,t.id),carryTo:null,screen:t.id?"chat":"home"};case"open-draft":{if(Hf(e))return e;const h=((n=KE(e,e.activeRepoId))==null?void 0:n.id)??null;return h?Ko({...rl(e,h),carryTo:h,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 WE(e,t.id);case"close-archived":return e.archivedPage?QE(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,h=>({...h,sending:{message:t.message,at:Date.now()}}));case"sent-box":return xt(e,t.id,({notice:h,...m})=>({...ol(m,"walk"),draft:"",attachments:[],sent:(m.sent??0)+1}));case"answered":return xt(e,t.id,h=>({...h,sent:(h.sent??0)+1}));case"hold-send":{const h=e.local[t.id];if(!h)return e;const m=ZP(e.clientId,++lL,t.id),g={...fa,draft:t.text,attachments:h.attachments,outgoing:{frame:t.frame,log:t.log}},w=xt(e,t.id,({notice:y,...b})=>({...ol(b,"walk"),draft:"",attachments:[]}));return{...w,local:{...w.local,[m]:g},outbox:[...e.outbox,{id:m,log:t.log,kinds:h.attachments.map(y=>y.kind)}]}}case"sent-out":{const h=e.local[t.id],m=h==null?void 0:h.outgoing;if(!h||!m)return e;const{[t.id]:g,...w}=e.local,y={...e,local:w,outbox:e.outbox.filter(N=>N.id!==t.id)},b=h.draft,_=h.attachments.length?dk(h.attachments):void 0,T=N=>({...N,sent:(N.sent??0)+1});if(m.frame.t==="restore-worktree"||m.frame.t==="adopt-worktree")return xt(y,m.log,N=>({...T(N),sending:{message:{text:b,attachments:_},at:Date.now()}}));if(m.frame.t==="agent-answer")return xt(y,m.log,T);const x=m.frame.t==="chat"&&BE(e,m.log);return xt(y,m.log,N=>x?T(N):{...T(N),sending:{message:{text:b,attachments:_},at:Date.now()}})}case"unsend":{const h=e.local[t.id],m=(r=ds(t.id))==null?void 0:r.source;if(!(h!=null&&h.outgoing)||!m)return e;const{[t.id]:g,...w}=e.local,y={...e,local:w,outbox:e.outbox.filter(b=>b.id!==t.id)};return xt(Ko(y),m,b=>({...b,draft:b.draft||h.draft,attachments:[...h.attachments,...b.attachments],...t.notice?{notice:t.notice}:{}}))}case"drop-out":{if(!((o=e.local[t.id])!=null&&o.outgoing))return e;const{[t.id]:h,...m}=e.local;return{...e,local:m,outbox:e.outbox.filter(g=>g.id!==t.id)}}case"archive-worktrees":{const h=t.ids.filter(N=>!e.archiving.includes(N)&&un(e,N));if(h.length===0)return e;const m={...e,archiving:[...e.archiving,...h]};if(!e.activeId||!h.includes(e.activeId))return m;const g=e.visible.filter(N=>N.id===e.activeId||!m.archiving.includes(N.id)),w=g.findIndex(N=>N.id===e.activeId),y=[N=>N.agent==="waiting",N=>Mg(N.worktree)&&!!N.worktree.landed&&N.agent==="idle",N=>!!N.unseen,N=>N.agent==="working",N=>!kr(N.worktree)&&Is(N)==="running"],b=N=>{for(const j of y){const $=N(j);if($)return $.id}},_=b(N=>g.findLast((j,$)=>$<w&&N(j))),x=rl(m,_??b(N=>g.find((j,$)=>$>w&&N(j)))??ul(m,e.activeRepoId));return e.frame==="phone"?{...x,screen:"home"}:x}case"shipping":return e.shipping[t.id]||!(wo(e,t.id)||eS(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!Ei(e,t.id))return e;const h=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return h;const m=ul(h,t.id);return{...rl(h,m),carryTo:null,activeRepoId:t.id,lent:null,pendingOpen:!1}}case"open-repo":return{...e,pendingOpen:!0};case"new-project":return{...e,newProject:t.v,overlay:null,paletteReturn:null,previewTheme:null,editor:null,notesPage:!1};case"new-project-set":{if(!e.newProject)return e;const h="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:m,...g}=e.newProject;return{...e,newProject:{...h?g:e.newProject,...t.v}}}case"close-new-project":return e.newProject&&e.repos.length>0?{...e,newProject:null,choosingFolder:!1}:e;case"auto-sent":return e.autoSend?{...e,autoSend:null}:e;case"watch-import":return{...e,activeImportId:t.id};case"close-editor":return{...e,editor:null};case"open-file":{const h=t.v,m=e.editor,g=m&&pc(m,h)?m:null,w=h.line&&zE(e,h.worktreeId,h.path,h.line);return{...e,editor:{worktreeId:h.worktreeId,path:h.path,...h.ref?{ref:h.ref}:{},...h.since?{since:h.since}:{},view:h.view??(g==null?void 0:g.view)??null,seq:h.seq,disk:(g==null?void 0:g.disk)??null,...w?{line:w}:{},focus:h.focus,conflict:(g==null?void 0:g.conflict)??null,blame:(g==null?void 0:g.blame)??null}}}case"open-loose":{const h=t.v,m={before:h.text,after:h.text,version:null,writable:h.source.kind!=="bytes"&&!h.tooLarge&&!h.binary,binary:h.binary,tooLarge:h.tooLarge};return{...e,editor:{worktreeId:h.worktreeId,path:h.name,view:wi(h.name),seq:h.seq,disk:m,focus:!0,conflict:null,blame:null,loose:{source:h.source}}}}case"editor-read":{const h=e.editor;if(!h||h.loose||!pc(h,t.file))return e;const m=t.disk;if(!m){const y=XE(e,h.worktreeId,t.error??`could not read ${h.path}`);return h.disk?y:{...y,editor:null}}const g=wi(h.path),w=m.before===""?h.view&&h.view!=="diff"?h.view:g:h.view??(m.before===m.after?g:"diff");return{...e,editor:{...h,view:w,disk:m}}}case"editor-conflict":{const h=e.editor;return h&&!h.loose&&pc(h,t.file)?{...e,editor:{...h,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 h=e.editor;if(!h||!pc(h,t.file))return e;const m=h.loose&&h.disk?{...h.disk,writable:!1}:h.disk;return{...e,editor:{...h,refused:t.message,disk:m}}}case"editor-blame":{const h=e.editor;return h&&!h.loose&&pc(h,t.file)?{...e,editor:{...h,blame:t.blame}}:e}case"notice":return xt(Ko(e),((i=ds(t.id))==null?void 0:i.source)??t.id,h=>({...h,notice:t.text}));case"link-refused":return xt(e,t.id,({refusedLink:h,...m})=>t.v?{...m,refusedLink:t.v}:m);case"card-draft":return xt(e,t.id,h=>({...h,card:t.card}));case"card-park":return xt(e,t.id,h=>({...h,cardParked:t.cardId}));case"card-unpark":return xt(e,t.id,({cardParked:h,...m})=>m);case"ask-revive":return xt(e,t.id,({askRevived:h,...m})=>t.askId?{...m,askRevived:t.askId}:m);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return xt(e,t.id,h=>{const{notice:m,...g}=ol(h,"walk");return{...g,draft:t.text,...m!==void 0&&t.text===""?{notice:m}:{}}});case"move-box":return JE(e,t.from,t.to);case"walk":return xt(e,t.id,h=>({...ol(h,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return xt(Ko(e),t.id,h=>{var m;return{...h,mark:{by:"reveal",seq:t.seq,n:((m=h.mark)==null?void 0:m.by)==="reveal"?h.mark.n+1:1}}});case"attach":return xt(Ko(e),t.id,({notice:h,...m})=>({...m,attachments:[...m.attachments,...t.items]}));case"upload-progress":return(l=e.local[t.id])!=null&&l.attachments.some(h=>h.key===t.key&&ki(h))?xt(e,t.id,h=>({...h,attachments:h.attachments.map(m=>m.key===t.key?{...m,progress:t.progress}:m)})):e;case"attached":return(c=e.local[t.id])!=null&&c.attachments.some(h=>h.key===t.key)?xt(e,t.id,h=>({...h,attachments:h.attachments.map(m=>m.key===t.key?t.item:m)})):e;case"detach":{const h=xt(e,t.id,({notice:m,...g})=>({...g,attachments:g.attachments.filter(w=>w.key!==t.key)}));return(u=e.local[t.id])!=null&&u.outgoing?hi(h,{a:"unsend",id:t.id}):h}case"clear-attachments":return xt(e,t.id,({notice:h,...m})=>m.attachments.length?{...m,attachments:[]}:m);case"hmr":return xt(e,t.id,h=>({...h,turn:{...h.turn,hmr:!0}}));case"page":return xt(e,t.id,h=>({...h,page:{url:t.url??h.page.url,title:t.title??h.page.title}}));case"links":return xt(e,t.id,h=>{const m=WP(h.links??[],t.links);return m===h.links?h:{...h,links:m}});case"drag-files":return QP(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:YE(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...hL(e,t.back)};case"toggle":return((p=e.overlay)==null?void 0:p.kind)===t.overlay.kind?hi(e,{a:"close"}):hi(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...eo(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...eo(e,{changes:!0,changesTab:t.tab&&!Oo(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return eo(e,{changesTab:t.v});case"edit-commit":return{...eo(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return Ao(e)?e:eo(e,{chat:!e.layout.chat});case"focus-chat":return{...Ko(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Ko(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"?eo(e,{changesTab:"changes"}):e,screen:t.to,editor:null};case"frame":{if(e.frame===t.v)return e;const h={...e,frame:t.v};if(t.v!=="desk"||!h.activeRepoId)return h;const m=h.layouts[h.activeRepoId];return m?hk(h,m):h}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 h=e.activeRepoId;return h?{...e,discoveredOpen:{...e.discoveredOpen,[h]:!e.discoveredOpen[h]}}:e}case"toggle-archived":{const h=e.activeRepoId;return h?{...e,archivedOpen:{...e.archivedOpen,[h]:!e.archivedOpen[h]}}:e}case"toggle-committed":{const h=e.activeRepoId;return h?{...e,committedShut:{...e.committedShut,[h]:!e.committedShut[h]}}:e}case"toggle-turn":{const h=e.activeRepoId;return h?{...e,turnOpen:{...e.turnOpen,[h]:!e.turnOpen[h]}}:e}case"tree-folder":{const h=e.treeOpen[t.worktreeId]??[];if(h.includes(t.path)===t.open)return e;const m=t.open?[...h,t.path]:h.filter(w=>w!==t.path),g={...e.treeOpen};return m.length>0?g[t.worktreeId]=m:delete g[t.worktreeId],{...e,treeOpen:g}}case"tree-reveal":{const h=e.treeOpen[t.worktreeId]??[],m=[];for(let y=t.path.indexOf("/");y!==-1;y=t.path.indexOf("/",y+1))m.push(t.path.slice(0,y));m.push(t.path);const g=m.filter(y=>!h.includes(y)),w=g.length?{...e.treeOpen,[t.worktreeId]:[...h,...g]}:e.treeOpen;return{...eo(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:w,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return xt(e,t.worktreeId,h=>({...h,filesFor:t.key}));case"toggle-zen":return Ao(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return eo(e,{term:!e.layout.term});case"focus-terminal":return{...eo(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return Ao(e)?e:eo(e,{design:!e.layout.design});case"term-stream":return xt({...eo(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,h=>({...h,termStream:t.stream}));case"term-run":return xt({...eo(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,h=>({...h,termStream:Co}));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 CL(e,t.msg)}}function H0(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 W0(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 bL(e,t,n){var o;let r=e;for(const i of n){if(!((o=i.worktree)!=null&&o.landed)||t.some(p=>{var h;return p.id===i.id&&((h=p.worktree)==null?void 0:h.landed)}))continue;const l=r[i.id];if(!(l!=null&&l.git)||l.git.files.length===0)continue;r===e&&(r={...e});const{extras:c,...u}=l.git;r[i.id]={...l,git:{...u,files:[]}}}return r}function xL(e,t){const{version:n,files:r,ahead:o,behind:i,unpushed:l,head:c}=t,u={version:n,files:r,...o===void 0?{}:{ahead:o},...i===void 0?{}:{behind:i},...l===void 0?{}:{unpushed:l},...c===void 0?{}:{head:c}};if(t.extras)return{...u,extras:t.extras};const p=new Map(e==null?void 0:e.files.map(w=>[w.path,w])),h=r.map(w=>{const y=p.get(w.path);return y&&y.xy===w.xy&&y.add!==void 0?{...w,add:y.add,del:y.del}:w}),m=e!=null&&e.extras&&e.head===c?e.extras:void 0,g=m&&r.length===0&&m.turn?{committed:m.committed}:m;return{...u,files:h,...g?{extras:g}:{}}}function EL(e,t,n){if(!e||e.head!==t.head)return{};if(e.version===t.version)return n;const r=new Set([...e.files,...t.files].map(i=>i.path));let o=n;for(const i of Object.keys(n))r.has(i)&&(o===n&&(o={...n}),delete o[i]);return o}function SL(e){let t=e;for(const[n,r]of Object.entries(e))!r.git||r.git.version===0||(t===e&&(t={...e}),t[n]={...r,git:{...r.git,version:0}});return t}function _L(e){let t=e;for(const[n,r]of Object.entries(e)){if(r.filesFor===void 0)continue;t===e&&(t={...e});const{filesFor:o,...i}=r;t[n]=i}return t}function NL(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.draft||ds(r)||(n===e&&(n={...e}),n[r]={...i??fa,draft:o})}return n}function TL(e,t){let n=e;for(const[r,o]of Object.entries(t)){const i=n[r];i!=null&&i.attachments.length||ds(r)||(n===e&&(n={...e}),n[r]={...i??fa,attachments:Pm(o,[])})}return n}function jL(e,t){const n=new Set(t.map(r=>r.id));return Object.values(e).every(r=>n.has(r))?e:Object.fromEntries(Object.entries(e).filter(([,r])=>n.has(r)))}function Ki(e,t){const n=new Set(t.map(r=>r.id));return Object.keys(e).every(r=>n.has(r))?e:Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function K0(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=KE(e,t.repoId);if(!n)return e;const r=Ro(e,kl);return!r.draft.trim()&&r.attachments.length===0?{...e,newProject:null}:{...JE(e,kl,n.id),newProject:null,autoSend:n.id}}function JE(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 eS(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function CL(e,t){var n,r,o,i,l,c,u,p,h,m,g,w,y,b,_,T;switch(t.t){case"hello":{const x=O=>!!O&&t.rows.some(D=>D.id===O),N=O=>!!O&&t.repos.some(D=>D.id===O),j=N(e.activeRepoId)?e.activeRepoId:N(e.storedRepo)?e.storedRepo:null,$=x(e.activeId)?e.activeId:x(e.storedActive)?e.storedActive:ul(e,j,t.rows),P=t.rows.find(O=>O.id===$),R=!!j&&!!P&&Sn(P)&&Wf(P,j,t.rows,e.lent),A={...e,heard:!0,repos:t.repos,rows:t.rows,activeId:$,lent:R?e.lent===$?e.lent:qE(P??null,j,t.rows):null,activeRepoId:R?j:(P==null?void 0:P.repoId)??j??((n=t.repos[0])==null?void 0:n.id)??null,trunks:t.trunks,archiving:e.archiving.length?[]:e.archiving,shipping:z0({},t.rows,t.trunks),local:SL(W0(TL(NL(e.local,t.drafts),t.attachments),t.rows,e.archivedPage)),lastActive:jL(e.lastActive,t.rows),treeOpen:H0(e.treeOpen,t.rows),discoveredOpen:Ki(e.discoveredOpen,t.repos),archivedOpen:Ki(e.archivedOpen,t.repos),committedShut:Ki(e.committedShut,t.repos),turnOpen:Ki(e.turnOpen,t.repos),refs:Ki(e.refs,t.repos),chats:Ki(e.chats,t.repos),archived:Ki(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?L0():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(O=>O.id===e.activeImportId)?e.activeImportId:null};return U0(A,t.knocks,t.letIn)}case"self":{const x=((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||x&&((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 U0(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"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:x,...N}=t;return{...e,agentConfigs:{...e.agentConfigs,[N.agent]:N}}}case"pending-repos":{const x=new Set(e.pending.map(R=>R.id)),N=t.pending.find(R=>!x.has(R.id)),j=N&&e.pendingOpen?N.id:e.activeImportId,$=t.pending.some(R=>R.id===j),P=t.pending.some(R=>R.id===j&&R.error);return{...e,pending:t.pending,activeImportId:$?j: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||ds(t.boxId)?e:xt(e,t.boxId,x=>{var N;return x.draft===t.text||((N=x.mark)==null?void 0:N.by)==="walk"?x:{...x,draft:t.text}});case"attachments":return t.clientId===e.clientId||ds(t.boxId)?e:xt(e,t.boxId,x=>({...x,attachments:Pm(t.items,x.attachments)}));case"repos":{const x=new Set(e.repos.map(A=>A.id)),N=t.repos.find(A=>!x.has(A.id));let j=e.activeRepoId,$=e.pendingOpen,P=e.newProject;N&&($||!j)?(j=N.id,$=!1,P&&P.phase!=="unmaking"&&(P={...P,phase:"creating",repoId:N.id})):t.repos.some(A=>A.id===j)||(j=((u=t.repos[0])==null?void 0:u.id)??null),(P==null?void 0:P.phase)==="unmaking"&&!t.repos.some(A=>A.id===(P==null?void 0:P.repoId))&&(P={...P,phase:"editing",repoId:null}),t.repos.length===0&&!P&&(P=L0());const R=e.gitIdentity||t.repos.some(A=>A.made&&!x.has(A.id));return j===e.activeRepoId?{...e,repos:t.repos,pendingOpen:$,newProject:P,gitIdentity:R}:K0({...e,repos:t.repos,pendingOpen:$,newProject:P,gitIdentity:R,activeRepoId:j,activeId:ul(e,j),editor:null})}case"worktrees":{let x=e.activeId;(!x||!t.rows.some(A=>A.id===x))&&(x=ul(e,e.activeRepoId,t.rows));const N=new Set(e.rows.map(A=>A.id)),j=A=>{var O;return((O=A.worktree)==null?void 0:O.kind)==="worktree"&&A.worktree.createdBy===e.clientId},$=t.rows.find(A=>!N.has(A.id)&&j(A)),P=!!x&&e.rows.some(A=>{var O;return A.id===x&&((O=A.worktree)==null?void 0:O.kind)==="spare"})&&t.rows.some(A=>A.id===x&&j(A));$&&e.rows.length>0&&!P&&(x=$.id);const R=e.archiving.filter(A=>t.rows.some(O=>O.id===A));return K0({...rl({...e,rows:t.rows,trunks:t.trunks,archiving:R.length===e.archiving.length?e.archiving:R,shipping:z0(e.shipping,t.rows,t.trunks),local:W0(uL(bL(e.local,e.rows,t.rows),t.rows,e.activeId,x===($==null?void 0:$.id)?$.id:void 0),t.rows,e.archivedPage),treeOpen:H0(e.treeOpen,t.rows)},x),editor:x===e.activeId?e.editor:null,...$&&x===$.id?{carryTo:$.id}:{},...x===e.activeId?{activeRepoId:e.activeRepoId}:{},archivedPage:$?null:e.archivedPage,notesPage:$?!1:e.notesPage})}case"proc":{const x=e.rows.map(N=>N.id===t.worktreeId?{...N,procs:AL(N.procs,t.proc)}:N);return{...e,rows:x}}case"log":return xt(e,t.worktreeId,x=>({...x,log:_C(x.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const x=t.event,N=t.worktreeId;let j=xt(e,N,$=>{const P=q0($.chat,x,t.seq),R=x.type==="turn-end",A=R||x.type==="agent-error"||x.type==="agent-auth-required",D=x.type==="tool-start"||x.type==="tool-end"||R||x.type==="tool-update"&&x.background?F0(P,$.running):$.running;let z=$.turn;x.type==="turn-start"?z={edits:!1,hmr:!1}:x.type==="tool-start"&&d1(x)&&(z={...z,edits:!0});const X=x.type==="session-info"&&x.model?x.model:$.model,ne=x.type==="session-info"&&x.effort?x.effort:$.effort,ee=x.type==="usage"?{...Z0(x),heard:Date.now()}:$.usage,ie=e.rows.find(Y=>Y.id===N),be=$o(ie==null?void 0:ie.agent),C=$.sending?be?Hc($):{...$,sending:{at:$.sending.at}}:$,Z=dL(x.type==="user-message"?C:A?Hc($):$,x);return{...x.type==="user-message"?ol(Z,"reveal"):Z,chat:P,...P!==$.chat?{chatAt:Date.now()}:{},...D!==$.running?{running:D}:{},turn:z,...X!==$.model?{model:X}:{},...ne!==$.effort?{effort:ne}:{},...ee!==$.usage?{usage:ee}:{}}});if(x.type==="agent-ask-end"&&!tk(x.outcome)&&((p=j.local[il(x.id)])!=null&&p.attachments.length)&&(j=xt(j,il(x.id),$=>({...$,attachments:[]}))),x.type==="user-message"){const $=NE(((h=e.local[N])==null?void 0:h.chat)??[]),P=$?il($.id):null,R=P?((m=j.local[P])==null?void 0:m.attachments)??[]:[];P&&R.length&&(j=xt(j,P,A=>({...A,attachments:[]})),j=xt(j,N,A=>({...A,attachments:[...A.attachments,...R]})))}if(x.type==="turn-end"){const $=j.local[N].turn;$.edits&&!$.hmr&&(j={...j,reloadReq:{id:N,n:(((g=j.reloadReq)==null?void 0:g.n)??0)+1}})}return(x.type==="agent-question"||x.type==="agent-permission"||x.type==="handoff-proposed")&&N===e.activeId&&(j=Ko(j)),j}case"backfill":{let x=[],N;for(const{seq:$,event:P}of t.events)x=q0(x,P,$),P.type==="usage"&&(N=Z0(P));const j=$=>t.events.some(({event:P})=>P.type==="user-message"&&P.text===$);return xt(e,t.worktreeId,({sending:$,...P})=>({...P,...$&&!($.message&&j($.message.text))?{sending:$}:{},chat:x,chatAt:Date.now(),running:F0(x,P.running),log:t.log??P.log,...N?{usage:N}:{}}))}case"git-status":{const x=(w=e.local[t.worktreeId])==null?void 0:w.git;if(t.version>0&&x&&t.version<x.version||t.version>0&&x&&t.version===x.version&&!t.extras)return e;let N=e.layout.changes,j=e.changesAuto;const $=((y=t.extras)==null?void 0:y.committed.length)??0;e.changesAuto&&t.worktreeId===e.activeId&&!N&&(t.files.length>0||$>0)&&(N=!0,j=!1);const P=t.worktreeId===e.archivedPage?Oo(e):null;P&&(t.files.length>0||$>0||P.landed)&&(N=!0);const R=xt(e,t.worktreeId,A=>{const O=xL(A.git,t);return{...A,git:O,changedRanges:EL(A.git,O,A.changedRanges)}});return{...eo(R,{changes:N}),changesAuto:j}}case"changed-ranges":{const x=xt(e,t.worktreeId,j=>({...j,changedRanges:{...j.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),N=x.editor;return!((b=N==null?void 0:N.line)!=null&&b.fiber)||N.worktreeId!==t.worktreeId||N.path!==t.path?x:{...x,editor:{...N,line:zE(x,N.worktreeId,N.path,N.line)}}}case"shipped":{const x=t.worktreeId,N={...e,shipping:D0(e.shipping,j=>{var $;return j===x&&(($=e.shipping[j])==null?void 0:$.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?x?B0(N,x,t.message):Dm(N,t.message):N}case"files":return xt(e,t.worktreeId,x=>({...x,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return xt(e,t.worktreeId,x=>({...x,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[x]=t.hits;if(!x)return xt(e,t.worktreeId,j=>({...j,notice:"nothing in the source matches this element"}));if(!t.sure)return hi(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const N=hi(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:x.path,view:"file",line:{n:x.line},focus:!0,seq:t.seq}});return N.layout.changes?N:hi(N,{a:"toggle-changes"})}case"design-index":return xt(e,t.worktreeId,x=>({...x,design:t.index}));case"routes":return xt(e,t.worktreeId,x=>({...x,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return xt(e,t.worktreeId,x=>({...x,queue:t.items}));case"agent-commands":return xt(e,t.worktreeId,x=>({...x,commands:t.commands}));case"git-log":return xt(e,t.worktreeId,x=>({...x,commits:t.commits}));case"git-commit":return xt(e,t.worktreeId,x=>({...x,commitFiles:{...x.commitFiles,[t.sha]:t.files}}));case"error":{const x=t.worktreeId,N=e.newProject,j=(N==null?void 0:N.phase)==="creating"&&!N.repoId,$={...cL(e,x),archiving:x?e.archiving.includes(x)?e.archiving.filter(P=>P!==x):e.archiving:e.archiving.length?[]:e.archiving,shipping:D0(e.shipping,P=>!x||P===x),newProject:j?{...N,phase:"editing",error:t.message}:(N==null?void 0:N.phase)==="unmaking"?null:N,pendingOpen:j?!1:e.pendingOpen,updateCheck:!x&&e.updateCheck==="asking"?null:e.updateCheck};return j?$:x?B0($,x,t.message):Dm($,t.message)}case"unsent":{const x=((_=ds(t.boxId))==null?void 0:_.source)??t.boxId,N=!wo(e,x)&&!!e.activeRepoId&&((T=e.archived[e.activeRepoId])==null?void 0:T.some(j=>j.id===x));return xt(Ko(N?WE(e,x):e),x,({sending:j,...$})=>({...$,draft:$.draft||t.text,attachments:[...Pm(t.items,[]),...$.attachments],notice:t.message}))}default:return e}}function AL(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 IL(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function q0(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:RL(e,t.messageId);if(u!==-1){const p=e.slice(),h=p[u];return p[u]={...h,text:h.text+t.text},p}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(h=>h.kind==="tool"&&h.id===t.toolId);if(c===-1)return e;const u=e.slice(),p=u[c];return u[c]={...p,...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(h=>h.kind==="tool"&&h.id===t.toolId);if(c===-1)return e;const u=e.slice(),p=u[c];return u[c]={...p,output:(p.output??"")+t.text},u}case"tool-end":{const c=e.findLastIndex(h=>h.kind==="tool"&&h.id===t.toolId);if(c===-1)return e;const u=e.slice(),p=u[c];return u[c]={...p,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":return(r==null?void 0:r.kind)==="assistant"&&IL(t.message,r.text)?[...e.slice(0,-1),{kind:"error",text:t.message,...o}]:[...e,{kind:"error",text:t.message,...o}];case"agent-blocked":return[...e,{kind:"blocked",tool:t.tool,path:t.path,reason:t.reason}];case"grafted":return[...e,{kind:"grafted",title:t.title,branch:t.branch}];case"landed":return[...e,{kind:"landed",text:t.message,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=Kp(e,t.id);if(c===-1)return e;const u=e.slice(),p=u[c];return u[c]={...p,state:"starting"},u}case"handoff":{const c=Kp(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:Qd,state:"continued",worktreeId:t.worktreeId,ts:t.ts}];const u=e.slice(),p=u[c];return u[c]={...p,state:"continued",worktreeId:t.worktreeId,title:t.title},u}case"handoff-declined":{const c=Kp(e,t.id);if(c===-1)return e;const u=e.slice(),p=u[c];return u[c]={...p,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}:{},...t.provider?{provider:t.provider}:{},...t.detail?{detail:t.detail}:{},...t.refresh?{refresh:t.refresh}:{},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 G0(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(p=>p.kind==="tool"&&p.id===t.toolId);return(u==null?void 0:u.kind)!=="tool"||t.plan||u.toolKind==="switch_mode"?G0(e,t.toolId,c):[...e,{...c,toolId:u.id}]}case"agent-ask-end":{const c=e.findLastIndex(h=>h.kind==="ask"&&h.id===t.id&&!h.outcome);if(c===-1)return e;const u=e[c];if(u.toolId&&OL(u,t.choiceId))return[...e.slice(0,c),...e.slice(c+1)];const p=e.slice();return p[c]={...p[c],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},p}case"turn-end":{const c=$L(e);return t.stopReason==="interrupted"?[...c,{kind:"stopped",...o}]:c}default:return e}}function $L(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 RL(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 Kp(e,t){return e.findLastIndex(n=>n.kind==="handoff"&&n.id===t&&(n.state==="proposed"||n.state==="starting"))}function OL(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 G0(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 ML(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=hi(t,r);if(o!==t){t=o;for(const i of n)i()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const tS=S.createContext(null),kk=S.createContext(null),nS=S.createContext(null);function PL({store:e,sock:t,files:n,children:r}){return d.jsx(tS.Provider,{value:e,children:d.jsx(kk.Provider,{value:t,children:d.jsx(nS.Provider,{value:n,children:r})})})}const rS=S.createContext(null),oS=S.createContext(null);function LL({machines:e,children:t}){const n=S.useSyncExternalStore(e.subscribe,e.active);return d.jsx(rS.Provider,{value:e,children:d.jsx(oS.Provider,{value:n,children:d.jsx(PL,{store:n.store,sock:n.sock,files:n.files,children:d.jsx(S.Fragment,{children:t},n.origin)})})})}function es(){const e=S.useContext(rS);if(!e)throw new Error("useMachines outside <MachinesProvider>");return e}function ao(){const e=S.useContext(oS);if(!e)throw new Error("useMachine outside <MachinesProvider>");return e}function wk(){const e=es();return S.useSyncExternalStore(e.subscribe,e.list)}function Ja(e,t){return S.useSyncExternalStore(e.store.subscribe,()=>t(e.store.getState()))}const zm=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function sS(){const e=es(),t=ao(),n=wk(),r=S.useMemo(()=>n.filter(c=>c!==t),[n,t]),o=S.useRef(null),i=S.useCallback(c=>{const u=r.map(p=>p.store.subscribe(c));return()=>{for(const p of u)p()}},[r]),l=S.useCallback(()=>{const c=r.map(m=>e.displayName(m.origin)),u=r.map(m=>m.store.getState().repos),p=o.current;if(p&&p.others===r&&zm(p.names,c)&&zm(p.repos,u))return p.value;const h=r.map((m,g)=>({origin:m.origin,name:c[g]??m.origin,repos:u[g]??[]}));return o.current={others:r,names:c,repos:u,value:h},h},[r,e]);return S.useSyncExternalStore(i,l)}function iS(){const e=ao(),t=wk(),n=S.useMemo(()=>t.filter(l=>l!==e),[t,e]),r=S.useRef(null),o=S.useCallback(l=>{const c=n.map(u=>u.store.subscribe(l));return()=>{for(const u of c)u()}},[n]),i=S.useCallback(()=>{const l=n.map(p=>{const h=p.store.getState();return h.connected&&!h.incompatible?h.rows:V0}),c=r.current;if(c&&c.others===n&&zm(c.rows,l))return c.value;const u=n.map((p,h)=>({origin:p.origin,rows:(l[h]??V0).filter(Sn)}));return r.current={others:n,rows:l,value:u},u},[n]);return S.useSyncExternalStore(o,i)}const V0=[];function hK(){return ao().terminals}function Yn(){const e=S.useContext(tS);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function M(e){const t=Yn();return S.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function yk(){const e=M(n=>n.systemDark),t=M(n=>{var r;return(r=n.daylight)==null?void 0:r.dark});return{system:e,daylight:t??e}}function ut(){return Yn().dispatch}function it(){return S.useContext(kk)}function Kr(){const e=S.useContext(kk);return(e==null?void 0:e.urls)??ek(location.origin,"")}function vk(){return S.useContext(nS)}function DL(e=!1,t=!0){const n=S.useRef(null);return S.useEffect(()=>{if(!t)return;const r=()=>{const i=n.current;!i||document.activeElement===i||(i.focus(),e&&i instanceof HTMLInputElement&&i.select())};r();const o=requestAnimationFrame(r);return()=>cancelAnimationFrame(o)},[e,t]),n}function go(e,t,n,r=zL){const o=()=>{try{return n(r.get(e))??t}catch{return t}},[i,l]=S.useState(()=>({key:e,value:o()}));return i.key!==e&&l({key:e,value:o()}),[i.key===e?i.value:o(),p=>{l({key:e,value:p});try{r.set(e,typeof p=="boolean"?p?"1":"0":String(p))}catch{}}]}const zL={get:e=>localStorage.getItem(e),set:(e,t)=>localStorage.setItem(e,t)};function dl(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 aS(e,t){const[n,r]=S.useState(!1);return S.useEffect(()=>{if(!e){r(!1);return}const o=setTimeout(()=>r(!0),t);return()=>clearTimeout(o)},[e,t]),n}function bk(e,t){const[n,r]=S.useState(void 0);return S.useEffect(()=>{if(e===void 0){r(void 0);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}const xk=1500;function oa(e){const[t,n]=S.useState(()=>Date.now()),r=e!==void 0;return S.useEffect(()=>{if(!r)return;n(Date.now());const o=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(o)},[r]),r?Math.max(0,Math.floor((t-e)/1e3)):0}function FL(){const[e,t]=S.useState(window.innerWidth);return S.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}function BL(e){const t=S.useRef(null);return S.useLayoutEffect(()=>{const n=t.current;if(!n)return;t.current=null;const r=n.closest(e);if(!r)return;const o=r.getBoundingClientRect(),i=n.getBoundingClientRect(),l=i.bottom-o.bottom;if(l<=0)return;const c=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(l,Math.max(0,i.top-o.top-c))}),n=>{t.current=n}}const qd=40,UL=1200,HL=150,WL=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);function lS(e,t){const n=S.useRef(!0),r=S.useRef(Number.NEGATIVE_INFINITY),o=S.useRef(!1),[i,l]=S.useState(!1),[c,u]=S.useState(!1),[p,h]=S.useState(!1),[m,g]=S.useState(null),w=S.useCallback(j=>{n.current=j,e.current&&(e.current.style.overflowAnchor=j?"none":"")},[e]),y=S.useRef(null),b=S.useRef(null);ft([t],()=>{n.current||h(!0)});const _=S.useCallback(()=>{const j=e.current;j&&(w(j.scrollHeight-j.scrollTop-j.clientHeight<qd),l(!n.current),u(j.scrollTop>=qd),n.current&&h(!1))},[e,w]),T=S.useCallback(j=>{j!==0&&(g(j<0?"up":"down"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>g(null),UL))},[]),x=S.useCallback(()=>{const j=e.current;j&&(j.scrollTop=j.scrollHeight,w(!0),l(!1),h(!1))},[e,w]),N=S.useCallback(()=>{const j=e.current;j&&(r.current=performance.now(),j.scrollTop=0)},[e]);return S.useEffect(()=>{const j=e.current;if(!j)return;w(n.current);const $=()=>o.current||performance.now()-r.current<HL,P=()=>{n.current&&!$()?u(j.scrollTop>=qd):_()};j.addEventListener("scroll",P,{passive:!0});const R=()=>{r.current=performance.now()},A=C=>{R(),T(C.deltaY)},O=C=>{var Z;R(),y.current=((Z=C.touches[0])==null?void 0:Z.clientY)??null},D=C=>{var Y;R();const Z=(Y=C.touches[0])==null?void 0:Y.clientY;Z===void 0||y.current===null||(T(y.current-Z),y.current=Z)},z=()=>{o.current=!0},X=()=>{o.current=!1},ne=C=>{if(!WL.has(C.key))return;const Z=C.target;(Z===document.body||Z instanceof Node&&j.contains(Z))&&R()};j.addEventListener("wheel",A,{passive:!0}),j.addEventListener("touchstart",O,{passive:!0}),j.addEventListener("touchmove",D,{passive:!0}),j.addEventListener("pointerdown",z,{passive:!0}),window.addEventListener("pointerup",X,{passive:!0}),window.addEventListener("pointercancel",X,{passive:!0}),document.addEventListener("keydown",ne);const ee=()=>{j.scrollTop=j.scrollHeight},ie=new ResizeObserver(()=>{n.current&&ee()});ie.observe(j);for(const C of j.children)ie.observe(C);const be=new MutationObserver(C=>{for(const Z of C){for(const Y of Z.addedNodes)Y instanceof Element&&ie.observe(Y);for(const Y of Z.removedNodes)Y instanceof Element&&ie.unobserve(Y)}n.current&&ee()});return be.observe(j,{childList:!0}),()=>{j.removeEventListener("scroll",P),j.removeEventListener("wheel",A),j.removeEventListener("touchstart",O),j.removeEventListener("touchmove",D),j.removeEventListener("pointerdown",z),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),document.removeEventListener("keydown",ne),be.disconnect(),ie.disconnect(),b.current&&clearTimeout(b.current)}},[e,_,T,w]),{offEnd:i,offStart:c,away:p,moving:m,pinned:()=>n.current,jump:x,start:N,read:_}}function Y0(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function X0(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 cS(e,t){S.useLayoutEffect(()=>{const n=e.current;if(!n)return;const r=window.getSelection(),o=g=>!!g&&n.contains(g),i=r&&r.rangeCount>0&&o(r.anchorNode)?Y0(n,r.anchorNode,r.anchorOffset):null,l=r&&r.rangeCount>0&&o(r.focusNode)?Y0(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,p]=i===null?[c[0],c[1]]:X0(n,i),[h,m]=l===null?[c[2],c[3]]:X0(n,l);u&&h&&r.setBaseAndExtent(u,p,h,m)},[e,t])}function ft(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function uS(e){const[t,n]=S.useState({left:0,right:0});return S.useLayoutEffect(()=>{if(!e)return;const r=()=>{const i=e.getBoundingClientRect();let{left:l,right:c}=i;const u=e.closest("[data-pinned]");if(u){const h=u.getBoundingClientRect(),m=u.offsetWidth/h.width;l=u.offsetLeft+(l-h.left)*m,c=u.offsetLeft+(c-h.left)*m}const p={left:Math.round(l),right:Math.round(c)};n(h=>h.left===p.left&&h.right===p.right?h:p)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function Q0(){const[e,t]=S.useState(null);return[t,uS(e)]}function pK(e){e.ctrlKey&&e.stopPropagation()}function dS(e,t){return e.defaultPrevented||e.ctrlKey?!1:t<1.01}function mK(e){S.useEffect(()=>{const t=e.current;if(!t)return;const n=r=>{var o;dS(r,((o=window.visualViewport)==null?void 0:o.scale)??1)&&r.preventDefault()};return t.addEventListener("wheel",n,{passive:!1}),()=>t.removeEventListener("wheel",n)},[e])}const fS={axis:null,dx:0,dy:0,at:Number.NEGATIVE_INFINITY},KL=2,ZL=4,qL=300;function GL(e,t,n){const r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),i=r>o?"x":"y",l=n-e.at<=qL?e:fS;if(l.axis===null){const u=l.dx+r,p=l.dy+o,h=Math.max(u,p)>=KL?u>p?"x":"y":null;return{scrolls:h!==null&&h===i,next:{axis:h,dx:u,dy:p,at:n}}}return i===l.axis?{scrolls:!0,next:{...l,at:n}}:(i==="x"?r:o)>=ZL?{scrolls:!0,next:{...l,axis:i,at:n}}:{scrolls:!1,next:{...l,at:n}}}function gK(e){S.useEffect(()=>{const t=e.current;if(!t)return;let n=fS;const r=o=>{var c;if(o.ctrlKey)return;const{scrolls:i,next:l}=GL(n,o,o.timeStamp);n=l,!i&&(o.stopPropagation(),dS(o,((c=window.visualViewport)==null?void 0:c.scale)??1)&&o.preventDefault())};return t.addEventListener("wheel",r,{capture:!0,passive:!1}),()=>t.removeEventListener("wheel",r,{capture:!0})},[e])}function VL(e){S.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;r&&(t.scale<1.01?delete r.dataset.zoomed:r.dataset.zoomed="")};return n(),t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)},[e])}function YL(e){S.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{var r;(r=e.current)==null||r.style.setProperty("--visible-height",`${Math.round(t.height)}px`)};return n(),t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)},[e])}function XL(e){S.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;if(r){if(t.scale<1.01){delete r.dataset.pinned;return}r.dataset.pinned="",r.style.setProperty("--pin-x",`${t.offsetLeft}px`),r.style.setProperty("--pin-y",`${t.offsetTop}px`),r.style.setProperty("--pin-scale",String(1/t.scale))}};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n)}},[e])}function QL(e,t,n){const[r,o]=S.useState(),i=S.useRef(e);return i.current=e,S.useEffect(()=>{if(!n)return;let l=!0,c;const u=()=>void i.current().then(p=>{l&&(o(p),c=setTimeout(u,t))});return u(),()=>{l=!1,clearTimeout(c)}},[t,n]),r}const jl=()=>M(e=>e.activeId),hS=()=>aS(!M(e=>e.connected),900),$s=()=>M(e=>un(e,e.activeId)),Ek=()=>M(e=>wo(e,e.activeId)),pS=()=>M(e=>e.rows),Sk=()=>M(e=>e.visible),JL=()=>M(e=>e.visibleDiscovered),e4=()=>M(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),J0=[],t4=()=>M(e=>e.activeRepoId?e.archived[e.activeRepoId]??J0:J0),n4=()=>M(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),r4=()=>M(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),o4=()=>M(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),ha=()=>M(Oo),_k=()=>M(VE),s4=()=>M(e=>Ei(e,e.activeRepoId)),Cl=()=>M(e=>Ei(e,pk(e))),mS=e=>M(t=>Ro(t,e)),Rt=(e,t)=>M(n=>Ro(n,e)[t]),i4=()=>M(e=>e.overlay),Kf=()=>M(eL),gS=()=>M(UE),iu=()=>M(tL),au=()=>M(Ao),a4=()=>M(e=>e.newProject),Si=()=>M(e=>e.touch),l4=()=>M(e=>e.draft),Nk=()=>M(xc),c4=()=>M(e=>{const t=wo(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return uf(n)?n:null});function u4(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&aE(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function d4(){try{return localStorage.getItem(Ge.clipboardOffer)==="1"}catch{return!1}}let As={access:"none",on:typeof localStorage<"u"&&d4(),offer:null},Fm="";const Bm=new Set;function Zf(e){As={...As,...e};for(const t of Bm)t()}async function f4(){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 u4({image:e,text:t})}async function qf({taken:e=!1,asking:t=!1}={}){if(!As.on||!(As.access==="granted"||t&&As.access==="prompt"))return;let n;try{n=await f4()}catch{return}e&&(Fm=(n==null?void 0:n.sig)??""),Zf({offer:n&&n.sig!==Fm?n:null})}const h4=()=>void qf();let eb=!1;function p4(){var e,t;eb||(eb=!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",h4),document.hasFocus()&&qf()},()=>{}))}function m4(e){return Bm.add(e),p4(),()=>{Bm.delete(e)}}const g4=()=>As;function k4(e){try{localStorage.setItem(Ge.clipboardOffer,e?"1":"0")}catch{}Zf({on:e,offer:null}),e&&qf({asking:!0})}function kS(){As.offer&&(Fm=As.offer.sig),Zf({offer:null})}const w4=()=>void qf({taken:!0});function y4(){return S.useSyncExternalStore(m4,()=>As.offer)}const wS="application/x-toyon-source";function kK(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function v4(e,t){e.setData(wS,JSON.stringify(t))}const tb=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function b4(e,t){const n=e.getData(wS);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!tb(o)||!tb(i)||i<o?null:{path:r.path,startLine:o,endLine:i,...typeof l=="string"?{ref:l}:{}}}const yS=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function x4(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const E4=new Set(["top","bottom"]),Zp={top:"bottom",bottom:"top",left:"right",right:"left"};function qp(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 nb(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function Gp(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 rb(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const ob=(e,t,n,r)=>n||!r?e:t,sb=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function S4(e,t,n,r){const{offset:o=0,alignOffset:i=0,cover:l=!1,flip:c="none",margin:u=8}=r,p=E4.has(r.side),h=p?{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=p?{a:{start:e.left,end:e.right},size:t.w,limit:n.w}:{a:{start:e.top,end:e.bottom},size:t.h,limit:n.h};let g=r.side;if(c==="side"||c==="both"){const _=qp(h.a,h.size,g,o,l),T=qp(h.a,h.size,Zp[g],o,l);g=ob(g,Zp[g],nb(_,h.size,g,h.limit,u),nb(T,h.size,Zp[g],h.limit,u))}let w=r.align??"center";if((c==="align"||c==="both")&&w!=="center"){const _=w==="start"?"end":"start",T=Gp(m.a,m.size,w,i),x=Gp(m.a,m.size,_,i);w=ob(w,_,rb(T,m.size,w,m.limit,u),rb(x,m.size,_,m.limit,u))}const y=sb(qp(h.a,h.size,g,o,l),h.size,h.limit,u),b=sb(Gp(m.a,m.size,w,i),m.size,m.limit,u);return p?{x:b,y,side:g,align:w}:{x:y,y:b,side:g,align:w}}function _4(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 vS={sep:!0},fs=e=>!("sep"in e);function Gf(e){const t=[];for(const n of e)(fs(n)||t.length>0&&fs(t[t.length-1]))&&t.push(n);for(;t.length>0&&!fs(t[t.length-1]);)t.pop();return t}const zn=e=>Gf(e.flatMap((t,n)=>n?[vS,...t]:t));let Va=null,N4=0;const Um=new Set,ib=()=>{for(const e of Um)e()},oo={get:()=>Va,subscribe(e){return Um.add(e),()=>{Um.delete(e)}},open(e){const t=Gf(e.items);if(t.length===0)return oo.close();Va={...e,items:t,id:++N4},ib()},close(){Va&&(Va=null,ib())},toggle(e){Va&&Va.target===e.target?oo.close():oo.open(e)}};function Tk(){return S.useSyncExternalStore(oo.subscribe,oo.get)}function bS(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function T4(e,t){return bS(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function j4(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:yS(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function yn(e){return S.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=Gf(t(bS(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const i=r.currentTarget;oo.open({items:o,owner:e,key:n,target:i,...T4(r,i)})}}},dropdown(t,n="left",r,o){return{"aria-haspopup":"menu",onClick:i=>{i.stopPropagation();const l=i.currentTarget;oo.toggle({items:t(),...o?{head:o()}:{},owner:e,key:r,target:l,toggles:!0,anchor:l.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){oo.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const xS=e=>({id:"open-out",label:lk()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),nn=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function ES(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(nn,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const SS=e=>ES("text/plain",fetch(e).then(t=>t.blob())),C4=e=>ES("image/png",A4(e));async function A4(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 I4(e){return zg(e)}function Qo(e){return(e==null?void 0:e.urls.host)??(typeof location=="object"?location.hostname:"127.0.0.1")}function Jo(e,t,n="reveal in Finder"){return!e||!I4(t)?[]:[{id:"reveal",label:n,onClick:e}]}function $4(e,t){const n=[];for(const r of t)r.xy.includes("D")?n.push(`-${r.path}`):/[?ARC]/.test(r.xy)&&n.push(`+${r.path}`);return`${e??""}
|
|
99
|
-
${n.sort().join(`
|
|
100
|
-
`)}`}function Vf(e,t,{sock:n,dispatch:r}){var l,c;if(!n)return;const o=t.local[e]??fa,i=$4((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 R4=["diff","file","preview"],_S=(e,t)=>R4.filter(n=>!(n==="preview"&&!Bf(e))&&!(n==="diff"&&t));let O4=0;const Vo=()=>++O4;function er({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:Vo()}})}const Hm=new Map;function NS(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=Vo();return new Promise(i=>{Hm.set(o,l=>{l.ok?(er(e,{...t,view:wi(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 M4(e){const t=Hm.get(e.seq);return t?(Hm.delete(e.seq),t(e),!0):!1}function P4({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},p){const{sock:h,dispatch:m}=p,g=_S(t,l).filter(x=>x!==i).map(x=>({id:`view:${x}`,label:`view ${x}`,onClick:()=>i?m({a:"editor-view",v:x}):er(p,{worktreeId:e.id,path:t,view:x,ref:r,since:o})})),w=`${e.dir}/${t}`,y=c?[]:Jo(()=>h==null?void 0:h.send({t:"reveal",worktreeId:e.id,path:t}),Qo(h));return zn([g,[{id:"copy-path",label:"copy path",onClick:()=>nn(w)}],y,u?[{id:"select",label:"select…",onClick:()=>u(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(TS([t]))&&(h==null||h.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function TS(e){if(e.length===1)return`Discard uncommitted changes to ${e[0]}?`;const t=e.slice(0,12),n=e.length-t.length,r=[...t,...n>0?[`and ${n} more`]:[]].join(`
|
|
101
|
-
`);return`Discard uncommitted changes to ${e.length} files?
|
|
102
|
-
|
|
103
|
-
${r}`}const ko=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function Yf(e,t,n){var o;const r=MC(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&ko(e,t,Pg(n)),r}const L4=1e3,D4=1e4,jS=new WeakMap;function z4(e,t){jS.set(e,t)}async function CS(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 _;return(_=Object.entries(e.getState().local).find(([,T])=>T.attachments.some(x=>x.key===n.key)))==null?void 0:_[0]},c=jS.get(e);let u=-1;const p=_=>{const T=Math.min(99,Math.floor(_*100)),x=l();T===u||x===void 0||(u=T,e.dispatch({a:"upload-progress",id:x,key:n.key,progress:T}))},h=()=>(u=-1,c?rP(c,n.kind,r,p):Promise.resolve(null));let m=await h();const g=m===null;g&&ko(e,l()??t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let _=L4;m===null&&l()!==void 0;_=Math.min(_*2,D4))await new Promise(T=>setTimeout(T,_)),l()!==void 0&&(m=await h());const w=l();if(!(m===null||w===void 0))if(typeof m=="string")e.dispatch({a:"detach",id:w,key:n.key}),ko(e,w,`${n.name}: ${m}`);else{const _=i.kind==="file"?{...i,...m}:{...i,upload:m.upload,bytes:m.bytes};e.dispatch({a:"attached",id:w,key:n.key,item:_});const T=(b=e.getState().local[((y=ds(w))==null?void 0:y.source)??w])==null?void 0:b.notice;g&&(T!=null&&T.startsWith(`${n.name}: Toyon is not answering`))&&ko(e,w,"")}o&&URL.revokeObjectURL(o)}function jk(e,t,n){if(!t||n.length===0)return;const r=Yf(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const i=o.name||"file";if(o.size>_0){ko(e,t,`${i}: larger than ${Dg(_0)}`);continue}const l={kind:"file",key:crypto.randomUUID(),upload:"",name:i,bytes:o.size,text:!1};CS(e,t,l,o)}n.length>r&&ko(e,t,`kept ${r} of ${n.length}: ${Pg("file")}`)}}function Ck(e,t,n,r={}){if(!t)return;const o=J2(r.source?n.replace(/\r?\n$/,""):n);if(o.length>K2)return r.source?ko(e,t,"that paste is too large; save it in the worktree and reference it with @path"):jk(e,t,[new File([o],Z2,{type:"text/plain"})]);Yf(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...Yg(o)}]})}function AS(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 ab(e,t){var i;const n=e.getState(),r=un(n,n.activeId),o=Tl(r);if(t&&o&&t.worktreeId===(r==null?void 0:r.worktree.id)&&t.text.trim()){const l="source"in t?{source:t.source}:{name:t.name};(((i=n.local[o])==null?void 0:i.attachments)??[]).some(u=>{var w;if(u.kind!=="paste")return!1;if(!("source"in t))return u.name===t.name&&u.text===t.text;const{path:p,startLine:h,endLine:m,ref:g}=t.source;return((w=u.source)==null?void 0:w.path)===p&&u.source.startLine===h&&u.source.endLine===m&&u.source.ref===g})||Ck(e,o,t.text,l)}e.dispatch(t?{a:"focus-chat"}:HE(n))}function Xf(e,t){return t!==e.activeId?null:Tl(un(e,t))}const Ak=(e,t)=>`@${e}${t?"/":""}`;function Ik(e,t,n){var c;const r=e.getState(),o=Xf(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 IS(e,t,n,r){Ik(e,t,`${Ak(n,r)} `)}function F4(e,t,n){n.length!==0&&Ik(e,t,`${n.map(r=>Ak(r,!1)).join(" ")} `)}function lb(e,t,n){Ik(e,t,n)}function B4(e,t){return un(e,t)?t:null}function U4(e,t){var r;const n=(r=un(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function cb(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function H4(e,t,n){var g;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=B4(r,t);if(!o)return;const{classes:i,route:l,element:c,...u}=n,p=U4(r,t),h={...u,file:cb(u.file,p),callFile:cb(u.callFile,p)};!(((g=r.local[o])==null?void 0:g.attachments)??[]).some(w=>w.kind==="pick"&&w.selector===h.selector)&&Yf(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...h}]}),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 p=o.get(u);if(p)return p;const h=u.lastIndexOf("/"),m={path:u,name:u.slice(h+1),kind:"folder",children:[],ignored:!1};return i(h===-1?"":u.slice(0,h)).children.push(m),o.set(u,m),m},l=(u,p,h=!1)=>{const m=u.lastIndexOf("/");i(m===-1?"":u.slice(0,m)).children.push({path:u,name:u.slice(m+1),kind:p,children:[],ignored:h})};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 p=h=>h.kind==="file"?1:0;u.children.sort((h,m)=>p(h)-p(m)||OE(h.name,m.name));for(const h of u.children)h.kind==="folder"&&c(h)};return c(r),r.children}function K4(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 $S=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function Z4(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 q4(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 cf(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 G4(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:il(t.id)}function ub(e){return e.kind==="ask"?bP(e):`Continue in ${e.repo.name}?`}function V4(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 Y4(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),p=u.length>0?u:t.filter(m=>m.name.toLowerCase().startsWith(c));if(p.length===0)return{error:`no open project named "${i}"`};if(p.length>1)return{error:`"${i}" names more than one project`};const h=p[0];return h.id===n?{error:`this worktree is already in ${h.name}`}:{repo:h,...l?{text:l}:{}}}const RS=new Set(U2),X4=/^image\.[a-z0-9]+$/i,Q4=e=>X4.test(e.name),J4=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function eD(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=>J4(l,i))||n.push(i);const r=n.filter(i=>!Q4(i));if(r.length>0)return r;const o=n.find(i=>RS.has(i.type))??n[0];return o?[o]:[]}function tD(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 nD(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 rD(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function db(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 oD(e){const t=await rD(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,i=t.width,l=t.height;if(!RS.has(o)||n>S0||e.size>Wp){const c=o==="image/jpeg"?"image/jpeg":"image/png";let u=Math.min(1,S0/n);for(r=await db(t,u,c);r.size>Wp&&u>.1;)u*=.7,r=await db(t,u,c);if(r.size>Wp)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 Rc={el:null},sD=80,iD=2e3;let hs=null,Wm;const OS=(e,t)=>{clearTimeout(Wm),Wm=setTimeout(()=>Ok(e),t)};function Rk(e,t){hs??(hs={refused:!1}),e.dispatch({a:"drag-files",v:hs.refused?null:t}),OS(e,iD)}function MS(e){hs&&OS(e,sD)}function Ok(e){clearTimeout(Wm),hs=null,e.dispatch({a:"drag-files",v:null})}function aD(e){hs&&(hs.refused=!0,e.dispatch({a:"drag-files",v:null}))}const PS="application/x-toyon-path";let Ji=null;function lD(e){Ji=e}function LS(e){Ji=null,hs&&Ok(e)}const fb=e=>Ji!==null&&Array.from(e.dataTransfer.types).includes(PS);function cD(e){return{onDragOver:t=>{if(!fb(t)||!Ji)return;t.preventDefault();const n=Xf(e.getState(),Ji.worktreeId)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&Rk(e,{at:"chat"})},onDrop:t=>{if(!fb(t)||!Ji)return;t.preventDefault();const{worktreeId:n,path:r,folder:o}=Ji;LS(e),IS(e,n,r,o)}}}let uD=0;function dD(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++uD}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function Qf(e,t,n){var l;if(!t||n.length===0)return;const r=Yf(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(oD));for(const c of o)c.status==="fulfilled"&&CS(e,t,dD(c.value),c.value.blob);const i=o.find(c=>c.status==="rejected");i?ko(e,t,String(((l=i.reason)==null?void 0:l.message)??i.reason)):n.length>r&&ko(e,t,`kept ${r} of ${n.length}: ${Pg("image")}`)}function fD(e,t,n){n.kind==="image"?Qf(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):Ck(e,t,n.text),kS()}function DS(e,t,n){const r=o=>o.type.startsWith("image/");Qf(e,t,n.filter(r)),jk(e,t,n.filter(o=>!r(o)))}function zS(e,t,{images:n=!1}={}){const r=document.createElement("input");r.type="file",r.multiple=!0,n&&(r.accept="image/*"),r.onchange=()=>DS(e,t,Array.from(r.files??[])),r.click()}function lu(e){const t=e.getState();if(t.newProject)return kl;const n=un(t,t.activeId);return G4(n?t.local[n.worktree.id]:void 0)??Tl(n)}function FS(e,t,n=lu(e)){DS(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&ko(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const Km=Promise.resolve(null);function hD(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))??Km;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:Km});return t}const pD=e=>e.map(t=>({file:t,handle:Km}));async function BS(e){const t=sf*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await nD(e,t);return n===null?null:n.length>sf?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function mD(e,t){const n=lu(e),r=e.getState().activeId,o=h=>n&&ko(e,n,h),i=t.filter(h=>h.file.type.startsWith("image/")).map(h=>h.file);i.length&&Qf(e,n,i);const l=t.filter(h=>!h.file.type.startsWith("image/")),c=l[0];if(!c||!r)return;const u=await BS(c.file);if(!u)return void o(`${c.file.name}: not a text file`);const p=await c.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:c.file.name,...u,binary:!1,source:p?{kind:"handle",handle:p}:{kind:"bytes"},seq:Vo()}}),l.length>1&&o(`opened ${c.file.name}; one file opens at a time`)}async function gD(e,t,n,r){const o=Xf(e.getState(),n.worktreeId)??lu(e),i=c=>o&&ko(e,o,c),l={sock:t,dispatch:c=>e.dispatch(c)};for(const{file:c}of r){const u=await BS(c);if(!u){i(`${c.name}: not a text file`);continue}if(u.tooLarge){i(`${c.name}: too large to add here`);continue}const p=n.dir?`${n.dir}/${c.name}`:c.name,h=await NS(l,{worktreeId:n.worktreeId,path:p},u.text);h&&i(`${c.name}: ${h}`)}}function kD(e){const t=lu(e);t&&ko(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 US(e,t,n,r){const o=(hs==null?void 0:hs.refused)??!1;Ok(e),!(o||r.length===0)&&(n?n.at==="chat"||n.at==="centre"&&e.getState().newProject?FS(e,r):n.at==="centre"?mD(e,r):n.at==="rail"?wD(e,n,r):gD(e,t,n,r):kD(e))}function wD(e,t,n){const r=un(e.getState(),t.worktreeId);r&&(e.dispatch(kr(r.worktree)?{a:"open-draft"}:{a:"activate",id:r.worktree.id}),FS(e,n,Tl(r)))}const Zm=e=>!!e&&Array.from(e.types).includes("Files");function hb(e,t){var c,u;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((c=Rc.el)!=null&&c.contains(n))return lu(e)?{at:"chat"}:null;const r=(u=n.closest(".rail [data-wt]"))==null?void 0:u.dataset.wt;if(r)return un(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 p=n.closest("[data-path]"),h=p==null?void 0:p.dataset.kind;if(h==="submodule")return null;const m=(p==null?void 0:p.dataset.path)??"";return{at:"tree",worktreeId:i,dir:h==="file"?$S(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 yD(){const e=Yn(),t=it();S.useEffect(()=>{const n=l=>{l.defaultPrevented||!Zm(l.dataTransfer)||(l.preventDefault(),Rk(e,hb(e,l.target)),l.dataTransfer&&(l.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=l=>{l.defaultPrevented||!Zm(l.dataTransfer)||(l.preventDefault(),US(e,t,hb(e,l.target),hD(l.dataTransfer)))},o=()=>MS(e),i=l=>{l.key==="Escape"&&aD(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 HS(e,t){const n=Yn(),r=S.useRef(!1);return{onPaste:c=>{w4();const u=eD(c.clipboardData);if(u.length>0)return c.preventDefault(),void Qf(n,e,u);const p=tD(c.clipboardData);if(p.length>0)return c.preventDefault(),jk(n,e,p);if(r.current)return;const h=c.clipboardData.getData("text/plain"),m=h.trim()?b4(c.clipboardData,t):null;!(m&&h.includes(`
|
|
104
|
-
`))&&!aE(h)||(c.preventDefault(),Ck(n,e,h,m?{source:m}:{}))},onPasteKey:c=>{r.current=(c.metaKey||c.ctrlKey)&&c.shiftKey&&c.key.toLowerCase()==="v"},onPasteKeyUp:()=>{r.current=!1}}}const WS=(e,t)=>{const n=e.indexOf("#"),[r,o]=n===-1?[e,""]:[e.slice(0,n),e.slice(n)];return`${r}${r.includes("?")?"&":"?"}${oA}=${encodeURIComponent(t)}${o}`},qm=(e,t)=>!e.serving&&t!==null,vD=3e3;function KS(e,t,n){const[r,o]=S.useState(()=>new Map),i=S.useRef(new Set),l=S.useRef(t);l.current=t;const c=S.useRef(new Map),u=S.useCallback((p,h)=>{i.current.has(p)||(i.current.add(p),SE(e.sock.urls).then(m=>{if(i.current.delete(p),!!l.current.some(w=>w.id===p&&w.url===h)){if(!m){c.current.set(p,setTimeout(()=>{c.current.delete(p),l.current.some(w=>w.id===p&&w.url===h)&&u(p,h)},vD));return}o(w=>new Map(w).set(p,{url:h,src:WS(h,m.code)}))}}))},[e]);return S.useEffect(()=>{const p=c.current;return()=>{for(const h of p.values())clearTimeout(h);p.clear()}},[]),S.useEffect(()=>{var h;if(!n)return;for(const m of t)((h=r.get(m.id))==null?void 0:h.url)!==m.url&&u(m.id,m.url);const p=new Set(t.map(m=>m.id));[...r.keys()].some(m=>!p.has(m))&&o(m=>new Map([...m].filter(([g])=>p.has(g))))},[n,t,r,u]),{urlOf:p=>{var h,m;return n?((h=r.get(p))==null?void 0:h.src)??null:((m=t.find(g=>g.id===p))==null?void 0:m.url)??null},renew:p=>{const h=t.find(m=>m.id===p);!h||!n||(o(m=>{const g=new Map(m);return g.delete(p),g}),u(p,h.url))}}}function bD(e,t,n){var o;const r=S.useRef([]);return t===null?r.current.length>0&&(r.current=[]):((o=r.current[0])==null?void 0:o.url)!==t&&(r.current=[{id:"one",url:t}]),KS(e,r.current,n).urlOf("one")}function xD(e,t,n){if(!n){window.open(t,"_blank");return}const r=window.open("","_blank");SE(e.sock.urls).then(o=>{const i=o?WS(t,o.code):t;r?r.location.href=i:window.open(i,"_blank")})}function We(...e){return e.filter(Boolean).join(" ")}const ED={branch:"M4.5 5.1v5.8 M11.5 6.6c0 2.6-7 1.6-7 4.3 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 3.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",chat:"M2.5 3.5a1.5 1.5 0 0 1 1.5-1.5h8a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H7l-3.2 2.6V11H4a1.5 1.5 0 0 1-1.5-1.5z",settings:"M12.38 6.99 14.05 7.26 14.05 8.74 12.38 9.01 11.82 10.38 12.81 11.76 11.76 12.81 10.38 11.82 9.01 12.38 8.74 14.05 7.26 14.05 6.99 12.38 5.62 11.82 4.24 12.81 3.19 11.76 4.18 10.38 3.62 9.01 1.95 8.74 1.95 7.26 3.62 6.99 4.18 5.62 3.19 4.24 4.24 3.19 5.62 4.18 6.99 3.62 7.26 1.95 8.74 1.95 9.01 3.62 10.38 4.18 11.76 3.19 12.81 4.24 11.82 5.62z M8 6.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",zen:"M2 6V3a1 1 0 0 1 1-1h3 M10 2h3a1 1 0 0 1 1 1v3 M14 10v3a1 1 0 0 1-1 1h-3 M6 14H3a1 1 0 0 1-1-1v-3",back:"M9.5 3.5 5 8l4.5 4.5",forward:"M6.5 3.5 11 8l-4.5 4.5",reload:"M13.5 2.5v3.5H10 M12.4 9.2a4.8 4.8 0 1 1-1-4.9l2.1 1.7",pick:"M8 4.2a3.8 3.8 0 1 0 0 7.6 3.8 3.8 0 1 0 0-7.6z M8 1.5v2.7 M8 11.8v2.7 M1.5 8h2.7 M11.8 8h2.7",inspect:"M6.5 13.5h-3a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v3 M8.2 8.2l5.3 2-2.3.9-.9 2.3z",terminal:"M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z M4.8 5.6 7.4 8l-2.6 2.4 M8.6 10.6h2.8",close:"M4.2 4.2 11.8 11.8 M11.8 4.2 4.2 11.8",edit:"M10.6 2.6 13.4 5.4 5.8 13H3v-2.8z M9.2 4l2.8 2.8 M3 10.2l2.8 2.8",check:"M3.4 8.4 6.4 11.4 12.6 4.6",split:"M2.5 2.5h11v11h-11z M2.5 8h11",full:"M2.5 2.5h11v11h-11z",more:"M3.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M7.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M11.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",caret:"M4.5 6.5 8 10l3.5-3.5","caret-up":"M4.5 9.5 8 6l3.5 3.5",stop:"M4.5 4.5h7v7h-7z",send:"M8 13V3.2 M4 7.2 8 3.2l4 4",external:"M9 3h4v4 M13 3 8 8 M11.5 9.5V13H3V4.5h3.5",plus:"M8 3.5v9 M3.5 8h9",download:"M8 2.5v7.4 M4.9 6.8 8 9.9l3.1-3.1 M3 13h10",copy:"M5.5 5.5h8v8h-8z M10.5 5.5v-3h-8v8h3",pull:"M8 3.2v7.4 M4.9 7.4 8 10.6l3.1-3.2",layers:"M6 2.5h7.5V10 M2.5 6h8v7.5h-8z",text:"M3.5 3.5h9 M3.5 6.5h9 M3.5 9.5h9 M3.5 12.5h5",wrap:"M3.5 4h9 M3.5 8h7a2 2 0 0 1 0 4H8 M9.5 10.5 8 12l1.5 1.5 M3.5 12h2.5",file:"M4.5 2.5h4.5l2.5 2.5v8.5h-7z M9 2.5V5h2.5",diff:"M8 2.8v5 M5.5 5.3h5 M5.5 11.2h5",folder:"M2.2 3.9a1 1 0 0 1 1-1h2.9l1.5 1.7h5.2a1 1 0 0 1 1 1v5.9a1 1 0 0 1-1 1H3.2a1 1 0 0 1-1-1z",book:"M8 4.6c-1.2-1-2.7-1.4-4.4-1.3v7.6c1.7-.1 3.2.3 4.4 1.3 1.2-1 2.7-1.4 4.4-1.3V3.3c-1.7-.1-3.2.3-4.4 1.3z M8 4.6v8.6",eye:"M2 8c1.6-2.9 3.6-4.3 6-4.3s4.4 1.4 6 4.3c-1.6 2.9-3.6 4.3-6 4.3S3.6 10.9 2 8z M8 6.1a1.9 1.9 0 1 0 0 3.8 1.9 1.9 0 1 0 0-3.8z",trash:"M3.6 4.6h8.8 M6.4 4.6V3.2a.7.7 0 0 1 .7-.7h1.8a.7.7 0 0 1 .7.7v1.4 M5 4.6l.55 8.1a.9.9 0 0 0 .9.84h3.1a.9.9 0 0 0 .9-.84L11 4.6",move:"M2.8 8h9.2 M8.9 4.9 12 8l-3.1 3.1",search:"M7.2 2.6a4.6 4.6 0 1 0 0 9.2 4.6 4.6 0 1 0 0-9.2z M10.5 10.5 13.5 13.5",run:"M3.4 4.2 7.6 8l-4.2 3.8 M9 11.8h4",bulb:"M4.8 8.8a4 4 0 1 1 6.4 0L9.5 10.6v1.4H6.5v-1.4z M6.7 13.8h2.6",spawn:"M2.5 8h3.3 M5.8 8c2.2 0 2.2-3.6 4.4-3.6h1.5 M5.8 8c2.2 0 2.2 3.6 4.4 3.6h1.5 M12.05 4.4a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M12.05 11.6a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",globe:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M2.2 8h11.6 M8 2.2c-3 3.4-3 8.2 0 11.6 3-3.4 3-8.2 0-11.6z",worktrees:"M3.8 2.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 4h5.4 M3.8 6.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 8h5.4 M3.8 10.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 12h5.4",swap:"M3 6.2h9.2 M9.7 3.7 12.2 6.2 9.7 8.7 M13 10.2H3.8 M6.3 7.7 3.8 10.2l2.5 2.5",palette:"M2.3 8.4C2.3 4.7 5 2.2 8.5 2.2c3.4 0 5.2 2.2 5.2 4.6 0 1.9-1.4 2.6-2.7 2.8-.9.15-1.3.7-1.1 1.4.2.9-.5 2.2-2.1 2.2-3.2 0-5.5-2-5.5-4.8z M5 6.2a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M7.8 4.9a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M11 5.8a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z",lock:"M4.4 7.3h7.2v6.1H4.4z M6.2 7.3V5.5a1.8 1.8 0 0 1 3.6 0v1.8",phone:"M5.4 2.2h5.2a1.2 1.2 0 0 1 1.2 1.2v9.2a1.2 1.2 0 0 1-1.2 1.2H5.4a1.2 1.2 0 0 1-1.2-1.2V3.4a1.2 1.2 0 0 1 1.2-1.2z M7.1 11.6h1.8",laptop:"M3.4 3.4h9.2a1 1 0 0 1 1 1v6.2H2.4V4.4a1 1 0 0 1 1-1z M1.5 12.6h13",devices:"M8.8 11.2H3.2a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1h8.8a1 1 0 0 1 1 1v1.3 M4.6 13.6h4.2 M10.6 6.9h3a.9.9 0 0 1 .9.9v5a.9.9 0 0 1-.9.9h-3a.9.9 0 0 1-.9-.9v-5a.9.9 0 0 1 .9-.9z M11.6 12.1h1",pr:"M4.5 5.1v5.8 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9V6.6a2 2 0 0 0-2-2H8 M9.6 2.9 7.9 4.6l1.7 1.7",clock:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M8 4.8V8l2.2 1.4",archive:"M2.4 3.2h11.2v2.8H2.4z M3.4 6v6.1a.9.9 0 0 0 .9.9h7.4a.9.9 0 0 0 .9-.9V6 M6.6 8.6h2.8",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 Tt({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:ED[e]})})}function vl({size:e="inline",variant:t="ring",className:n}){return d.jsx("span",{className:We("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 SD='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function pb(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,SD))??t??null}function _D(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 ND(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(_D(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const jD=e=>{setTimeout(e,0)};function CD({schedule:e=jD}={}){let t=[],n=null,r=!1;const o=new Set,i=()=>{for(const c of[...o])c()},l=c=>{var u;for(const p of[...t].reverse())(u=p.dismiss)==null||u.call(p,c)};return{register(c){const u=c.trigger??(c.from===void 0?n:null),p={box:c.box,trigger:u,parent:ND(t,c.from??u),dismiss:c.dismiss,onKey:c.onKey,back:c.back};return t=[...t,p],i(),p},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,p=b=>{var x;const _=b.target,T=_?TD(t,_):[];for(const N of T)(x=N.dismiss)==null||x.call(N,"outside");r=T.length>0&&b.pointerType==="touch",r&&b.preventDefault(),n=pb(b.target)},h=()=>e(()=>n=null),m=()=>{r=!1,h()},g=b=>{if(r){r=!1,b.preventDefault(),b.stopPropagation();return}n||(n=pb(b.target),h())},w=b=>{var T;const _=t[t.length-1];(T=_==null?void 0:_.onKey)==null||T.call(_,b)},y=()=>e(()=>{var b;((b=u.activeElement)==null?void 0:b.tagName)==="IFRAME"&&l("frame")});return u.addEventListener("pointerdown",p,!0),u.addEventListener("pointerup",h,!0),u.addEventListener("pointercancel",m,!0),u.addEventListener("click",g,!0),c.addEventListener("keydown",w,!0),c.addEventListener("blur",y),()=>{u.removeEventListener("pointerdown",p,!0),u.removeEventListener("pointerup",h,!0),u.removeEventListener("pointercancel",m,!0),u.removeEventListener("click",g,!0),c.removeEventListener("keydown",w,!0),c.removeEventListener("blur",y)}}}}const bl=CD(),AD=()=>bl.open().some(e=>!!e.dismiss);function ID(){return S.useSyncExternalStore(bl.watch,AD,()=>!1)}const Vp=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,mb=e=>(e==null?void 0:e.getBoundingClientRect())??null;function $D(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 Rs({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:i,onDismiss:l,onKey:c,onBack:u,trigger:p,from:h,boxRef:m,handle:g,children:w,...y}){const b=S.useRef(null),_=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,onBack:u,trigger:p,from:h});_.current={anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:c,onBack:u,trigger:p,from:h};const T=S.useCallback(()=>{const N=b.current,{anchor:j,placement:$,coverBy:P}=_.current;if(!N||!j||!$)return;const R=j==="parent"?mb(N.parentElement):j();if(!R)return;const A=x4(R,$);A!==void 0&&(N.style.width=`${A}px`);for(let O=0;O<2;O++){const D=P?$D(N,P,N.dataset.side??"",N.dataset.align??""):null,z=S4(R,{w:N.offsetWidth,h:N.offsetHeight},{w:window.innerWidth,h:window.innerHeight},D?{...$,...D}:$);N.style.left=`${z.x}px`,N.style.top=`${z.y}px`;const X=N.dataset.side!==z.side||N.dataset.align!==z.align;if(N.dataset.side=z.side,N.dataset.align=z.align,!X)break}},[]);S.useImperativeHandle(g,()=>({update:T}),[T]),S.useLayoutEffect(()=>{const N=b.current;if(!N)return;m&&(m.current=N),Vp&&(N.popover="manual",N.matches(":popover-open")||N.showPopover());const{onDismiss:j,onKey:$,onBack:P,trigger:R,from:A}=_.current,O=j||$?bl.register({box:N,trigger:R,from:A,dismiss:j?D=>{var z,X;return(X=(z=_.current).onDismiss)==null?void 0:X.call(z,D)}:void 0,onKey:$?D=>{var z,X;return(X=(z=_.current).onKey)==null?void 0:X.call(z,D)}:void 0,back:P?()=>{var D,z;return(z=(D=_.current).onBack)==null?void 0:z.call(D)}:void 0}):null;return()=>{O&&bl.unregister(O),m&&(m.current=null),Vp&&N.isConnected&&N.matches(":popover-open")&&N.hidePopover()}},[m]),S.useLayoutEffect(T),S.useLayoutEffect(()=>{if(!o)return;let N=0,j="";const $=()=>{const P=b.current,{anchor:R}=_.current,A=P&&R?R==="parent"?mb(P.parentElement):R():null;if(P&&A){const O=`${A.left},${A.top},${A.right},${A.bottom},${P.offsetWidth},${P.offsetHeight},${window.innerWidth},${window.innerHeight}`;O!==j&&(j=O,T())}N=requestAnimationFrame($)};return N=requestAnimationFrame($),()=>cancelAnimationFrame(N)},[o,T]);const x=S.useRef(!0);return ft([i],()=>{if(x.current){x.current=!1;return}const N=b.current;!Vp||!(N!=null&&N.matches(":popover-open"))||(N.hidePopover(),N.showPopover(),T())}),d.jsx("div",{ref:b,className:We("float",e),...y,children:w})}const RD=/^[⌘⇧⌥⌃]+/;function Yo({k:e,chip:t=!1,className:n}){var l;const r=(l=e.match(RD))==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 p=l?`${e}: ${l}`:e,h=(Array.isArray(r)?r:[r]).filter(g=>!!g),m=[p,...h,...c??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":h.length?h.join(`
|
|
105
|
-
`):void 0,"data-tip-card":o||l||c!=null&&c.length?"":void 0,"data-tip-dot":i,"data-tip-name":l,"data-tip-aside":c!=null&&c.length?c.join(`
|
|
106
|
-
`):void 0,"data-tip-also":u==null?void 0:u.text,"data-tip-also-key":u==null?void 0:u.key,"aria-label":t?`${m} (${t})`:m}}const OD=120,MD=600,PD=150,gb=6,LD=18,Yp=8;function kb(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function ZS(e){return e==="follow"?{side:"bottom",align:"start",offset:LD,alignOffset:-12,flip:"both",margin:Yp}:e==="left"||e==="right"?{side:e,align:"start",offset:gb,flip:"both",margin:Yp}:{side:e,align:"center",offset:gb,flip:"side",margin:Yp}}function DD(e,t){return e.placement==="follow"?yS(t):e.el.getBoundingClientRect()}function qS(){var u;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),o=S.useRef({x:0,y:0}),i=Si();if(S.useEffect(()=>{if(i)return;let p=0,h=0,m=null,g=!1,w=0;const y=()=>{window.clearTimeout(p),window.clearTimeout(h)},b=()=>{y(),g&&(w=Date.now()),g=!1,m=null,t(null)},_=(A,O)=>{var z,X;const D=A.dataset.tip;if(!D)return b();y(),g=!0,t({el:A,text:D,key:A.dataset.tipKey,detail:(z=A.dataset.tipDetail)==null?void 0:z.split(`
|
|
107
|
-
`),card:A.dataset.tipCard!==void 0,dot:A.dataset.tipDot,name:A.dataset.tipName,aside:(X=A.dataset.tipAside)==null?void 0:X.split(`
|
|
108
|
-
`),also:A.dataset.tipAlso&&A.dataset.tipAlsoKey?{text:A.dataset.tipAlso,key:A.dataset.tipAlsoKey}:void 0,placement:O})},T=A=>{const O=A.target;if(!(O instanceof Element))return null;const D=O.closest("[data-tip], .float");return(D==null?void 0:D.dataset.tip)!==void 0?D:null},x=A=>{o.current={x:A.clientX,y:A.clientY};const O=T(A);if(O===m)return;if(y(),m=O,!O){g&&(h=window.setTimeout(b,PD));return}const D=kb(O);if(g||Date.now()-w<MD)return _(O,D);p=window.setTimeout(()=>_(O,D),OD)},N=A=>{A.relatedTarget||b()},j=A=>{const O=T(A);if(O!=null&&O.matches(":focus-visible")){y(),m=O;const D=kb(O);_(O,D==="follow"?"bottom":D)}},$=()=>b(),P=A=>{A.key!=="Shift"&&A.key!=="Control"&&A.key!=="Alt"&&A.key!=="Meta"&&b()},R=A=>{m&&A.target instanceof Node&&A.target.contains(m)&&b()};return document.addEventListener("mouseover",x),document.addEventListener("mouseout",N),document.addEventListener("mousedown",b),document.addEventListener("keydown",P),document.addEventListener("scroll",R,!0),document.addEventListener("focusin",j),document.addEventListener("focusout",$),window.addEventListener("blur",b),()=>{y(),document.removeEventListener("mouseover",x),document.removeEventListener("mouseout",N),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",P),document.removeEventListener("scroll",R,!0),document.removeEventListener("focusin",j),document.removeEventListener("focusout",$),window.removeEventListener("blur",b)}},[i]),S.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),S.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const p=h=>{var m;o.current={x:h.clientX,y:h.clientY},(m=r.current)==null||m.update()};return document.addEventListener("mousemove",p),()=>document.removeEventListener("mousemove",p)},[e]),!e)return null;const l=d.jsxs(d.Fragment,{children:[e.dot==="spinner"?d.jsx(vl,{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(Yo,{k:e.key,className:"tooltip-key"})]});return d.jsxs(Rs,{className:We("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>DD(e,o.current),placement:ZS(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(Yo,{k:e.key,className:"tooltip-key"}):d.jsx("span",{}),d.jsx("span",{className:"tooltip-also",children:e.also.text}),d.jsx(Yo,{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((p,h)=>d.jsx("div",{className:"tooltip-detail",children:p},h)),e.aside&&d.jsx("div",{className:"tooltip-foot",children:e.aside.map(p=>d.jsx("span",{children:p},p))})]})}const zD={sm:"",md:"btn-md",lg:"btn-lg"},FD={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},GS={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function Fe({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:i,className:l,type:c="button",disabled:u,children:p,...h}){const m=We("btn",FD[e],zD[t],n&&GS[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,...h,children:[i&&d.jsx(vl,{}),p]})}function Mt({icon:e,label:t,hint:n,detail:r,also:o,silent:i,badge:l,tone:c,on:u,className:p,type:h="button",...m}){const g=We("btn-icon",c&&GS[c],u&&"on",p),w=Ut(t,n,{detail:r,also:o});return d.jsxs("button",{className:g,type:h,...i?{"aria-label":w["aria-label"]}:w,...m,children:[typeof e=="string"?d.jsx(Tt,{name:e}):e,l]})}function cu(e,t,n){return n===0?0:(e+t+n)%n}function wb(e,t,n){return e>=0?cu(e,t,n):n===0?-1:t>0?0:n-1}function VS(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 Xp(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function BD(e,t){if(e==null)return null;if(typeof e=="string"){const o=Xp(e,t);return o?{text:o,accept:o,params:[]}:null}const n=Xp(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:Xp(e.accept,t),params:r}}function YS(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:i,onActive:l,onSide:c,completionOf:u,narrowTo:p,setQ:h,tabPicks:m,onIdlePick:g}=e,[w,y]=S.useState(()=>{var P;return e.idle?-1:Math.max(0,((P=e.initialIndex)==null?void 0:P.call(e,t))??0)}),b=w>=0&&t[w]?n(t[w]):null,_=S.useRef(l);_.current=l,ft([b],()=>{var P,R,A;(R=(P=i.current)==null?void 0:P.querySelector('.picker-item[data-state~="cursor"]'))==null||R.scrollIntoView({block:"nearest"}),(A=_.current)==null||A.call(_,w>=0?t[w]??null:null)});const T=w<0?-1:Math.min(w,Math.max(0,t.length-1)),x=T>=0?t[T]??null:null,N=x?BD(u==null?void 0:u(x,r),r):null,j=P=>{const R=p==null?void 0:p(P,r);if(R==null)return o(P,r);h==null||h(R),y(0)};return{index:T,active:x,ghost:N,setIndex:y,pick:j,onKeyDown:P=>{if(P.key==="ArrowDown")P.preventDefault(),y(wb(T,1,t.length));else if(P.key==="ArrowUp")P.preventDefault(),y(wb(T,-1,t.length));else if((P.key==="ArrowLeft"||P.key==="ArrowRight")&&c&&x)P.preventDefault(),c(x,P.key==="ArrowLeft"?-1:1);else if(P.key==="Tab"&&(N!=null&&N.accept))P.preventDefault(),h==null||h(r+N.accept),y(0);else if(P.key==="Tab"&&m&&x)P.preventDefault(),j(x);else if(P.key==="Enter"&&x)P.preventDefault(),j(x);else if(P.key==="Enter"&&T<0&&g)P.preventDefault(),g(r);else return!1;return!0}}}function dr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const UD=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function XS(){const e=Tk(),t=Yn();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||oo.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(HD,{spec:e},e.id):null}function HD({spec:e}){const t=e.items,n=t.filter(fs),[r,o]=S.useState(-1),i=S.useRef({idx:r,items:n});i.current={idx:r,items:n};const l=S.useRef(null),c=m=>{var g,w;{const y=()=>oo.close(),{idx:b,items:_}=i.current;if(UD.has(m.key))return;if(m.key==="ArrowDown"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const T=m.key==="ArrowDown"?1:-1;o(_4(_,b,T));return}if((m.key==="Enter"||m.key===" ")&&b>=0&&_[b]&&!_[b].disabled){m.preventDefault(),m.stopPropagation(),_[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 T=Array.from(((g=l.current)==null?void 0:g.querySelectorAll(".menu-label"))??[],N=>N.textContent??""),x=VS(T,b,m.key);x>=0&&!((w=_[x])!=null&&w.disabled)&&o(x);return}y()}};S.useEffect(()=>{const m=()=>oo.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:p}=j4(e),h=n.some(m=>m.checked);return d.jsxs(Rs,{className:We("menu",e.head!==void 0&&"menu-headed"),role:"menu",boxRef:l,anchor:()=>u,placement:p,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>oo.close(),onKey:c,onContextMenu:m=>m.preventDefault(),children:[e.head!==void 0&&d.jsx("div",{className:"menu-head",children:e.head}),t.map((m,g)=>{if(!fs(m))return d.jsx("hr",{className:"menu-sep"},`sep-${g}`);const w=n.indexOf(m);return d.jsx(WD,{item:m,gutter:h,cursor:w===r,onEnter:()=>o(w)},m.id)})]})}function WD({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:We("row row-keyed",e.danger&&"danger",i!==void 0&&"row-tall",o&&"disabled"),"data-state":dr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),oo.close())},children:[t&&d.jsx("span",{className:"menu-check",children:e.checked&&d.jsx(Tt,{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(Yo,{k:e.key,className:"menu-key row-dim"})]})}function Jf({items:e,current:t,onPick:n,fill:r,font:o,segmented:i,quiet:l,end:c,label:u,owner:p}){const h=yn(p),m=S.useRef(null),g=Math.max(0,e.findIndex(y=>y.id===t)),w=y=>{var T,x;if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault();const b=e.findIndex(N=>N.id===t),_=e[cu(b,y.key==="ArrowRight"?1:-1,e.length)];_&&(n(_.id),(x=(T=m.current)==null?void 0:T.querySelectorAll('[role="tab"]')[e.indexOf(_)])==null||x.focus())};return d.jsxs("div",{className:We("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",i&&"tabs-segmented",l&&"tabs-quiet"),children:[d.jsx("div",{className:"tabs-list",role:"tablist","aria-label":u,ref:m,onKeyDown:w,style:i?{"--tabs-at":g,"--tabs-count":e.length}:void 0,children:e.map(y=>{const b=y.id===t;return d.jsxs("div",{className:We("tab",b&&!!y.trail&&"tab-trailed",y.fit&&"tab-fit",y.far&&"tab-far"),"data-state":dr({current:b}),...y.menu?h.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 ps({anchor:e="top",wide:t,foot:n,children:r}){const o=d.jsx("div",{className:We("view",e==="line"&&"view-anchored",t&&"view-wide"),children:r});return n?d.jsxs("div",{className:"view-stack",children:[o,n]}):o}const QS=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,KD=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function ZD(e,t,n){const r=[...t],o=[...n],i=(c,u)=>{const p=c.indexOf(u);return p===-1?!1:(c.splice(p,1),!0)};return[...e.map(c=>i(r,c)?{name:c,dot:"working",note:null}:i(o,c)?{name:c,dot:"waiting",note:"asking you"}:{name:c,dot:"idle",note:"finished"}),...o.map(c=>({name:c,dot:"waiting",note:"asking you"}))]}function qD(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 GD(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:QS(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 Gm=!1;function VD(){Gm=!0}function Wc({title:e,body:t,action:n,pane:r,children:o}){return d.jsxs("div",{className:We("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 yb={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class Mk extends S.Component{constructor(){super(...arguments);$t(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(Wc,{pane:this.props.pane,title:Gm?yb.title:"Toyon hit an error",body:Gm?yb.body:n.message||String(n),action:d.jsx(Fe,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}const Vm={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.`},YD=1e3,vb={held:[],asking:[],seen:[]};async function bb(e,t,n){for(;;){await new Promise(i=>setTimeout(i,YD));const[r,o]=await Promise.all([Om(e),bE(e)]);if(r!==null&&r!==t)break;n(o??{waiting:[],asking:[]})}window.location.reload()}function JS({foreign:e}={}){return e?d.jsx(XD,{name:e}):d.jsx(QD,{})}function XD({name:e}){const t=es(),n=t.list()[0];return d.jsx(Wc,{title:`Toyon on ${e} was updated`,body:Vm.foreign(e),action:n&&d.jsxs(Fe,{variant:"outline",onClick:()=>t.activate(n.origin),children:["back to ",t.displayName(n.origin)]})})}function QD(){const e=Kr(),[t,n]=S.useState(!0),[r,o]=S.useState(null),[i,l]=S.useState(vb),c=S.useRef(null),u=S.useCallback(y=>l(b=>({held:y.waiting,asking:y.asking,seen:KD(b.seen,y.waiting)})),[]),p=S.useCallback(async y=>{n(!0),o(null);const b=c.current??{pid:await Om(e)},_=await oP(e,y);if(_){n(c.current!==null),o(_);return}y&&l(vb),!c.current&&(c.current=b,bb(e,b.pid,u))},[u,e]);S.useEffect(()=>{let y=!0;return(async()=>{const[b,_]=await Promise.all([Om(e),bE(e)]);if(!(!y||c.current)){if(_===null){p(!1);return}c.current={pid:b},u(_),bb(e,b,u)}})(),()=>{y=!1}},[u,p,e]);const h=t&&i.held.length>0,m=h?ZD(i.seen,i.held,i.asking):[],g=m.filter(y=>y.dot==="working").length,w=m.filter(y=>y.dot!=="waiting").length;return d.jsx(Wc,{title:Vm.title,body:r??(h?qD(g,w):Vm.waiting),action:h?d.jsx(Fe,{variant:"outline",onClick:()=>void p(!0),children:"restart now"}):d.jsx(Fe,{variant:"outline",busy:t,onClick:()=>void p(!1),children:"restart"}),children:m.length>0&&d.jsx("ul",{className:"crash-list",children:m.map((y,b)=>d.jsxs("li",{className:We("crash-row",y.dot!=="working"&&"row-dim"),children:[d.jsx("span",{className:We("dot",y.dot)}),d.jsx("span",{className:"crash-row-name",children:y.name}),y.note&&d.jsx("span",{className:"crash-row-note",children:y.note})]},b))})})}const ea=(e,t=!1)=>({text:e,live:t}),JD={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"},ez={probing:e=>`connecting to ${e}`,down:e=>`Toyon on ${e} is not answering.
|
|
109
|
-
is Tailscale on here, and is Toyon running there?`,blocked:e=>`Toyon on ${e} is up, but this page's websocket to it never connected.
|
|
110
|
-
a proxy, VPN or browser extension is the usual cause`,unauthorized:e=>`this page's token for ${e} is not the one running there.
|
|
111
|
-
forget ${e} here and pair it again`},tz="no access token for this address.\nrun `toyon` or `toyon open` in your repo to get a signed-in page";function e_(e){if(!e.connected&&(!e.heard||e.connectFailure)){const t=e.connectFailure===null;return e.machine?ea(ez[e.connectFailure??"probing"](e.machine),t):e.hasToken?ea(JD[e.connectFailure??"probing"],t):ea(tz)}return e.title===null?ea(e.heard?`nothing open yet.
|
|
112
|
-
press ${e.projectChord} to open a project, or type a name there to start a new one`:""):null}function nz(e){const t=e_(e);return t!==null?t:e.needsSetup&&e.busy?ea(`building in ${e.title}; the preview appears once it starts`,!0):e.needsSetup&&e.treeEmpty?ea(`${e.title} is empty so far; say what to build`):e.treeEmpty&&e.landsFrom?ea(`nothing runs on main until ${e.landsFrom} lands`):null}const an={post:(e,t)=>{},broadcast:e=>{}};function Kc(e,t,n,r){const o=t===r;an.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function t_(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>nn(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>nn(e.subject)}]}function eh(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 th(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function n_(e,t){const n=th(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const rz=e=>Jd(fi((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function pi(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const r_=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function sa(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 o_(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function Pk(e,t){return{rename(n){if(!p1(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?
|
|
113
|
-
|
|
114
|
-
What they hold that main's do not (a database of their own) is not carried over.`)&&(e==null||e.send({t:"share-procs",worktreeId:n.worktree.id}))},archive(n){if(!Mg(n.worktree))return;if(!r_(n))return sa(e,t,[n.worktree.id]);window.confirm(`Archive worktree "${n.worktree.title}"?
|
|
115
|
-
|
|
116
|
-
Its directory and branch (${n.worktree.branch}) go. The chat, the commits and any uncommitted changes are kept, and the project menu can restore it.`)&&sa(e,t,[n.worktree.id])}}}function s_(e,t,n,{sock:r,dispatch:o},i){var P,R;const l=e.worktree.id,c=Pk(r,o),u=[],p=[],h=[],m=[],g=[],w=[],y=[],b=[];$o(e.agent)&&u.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:l})});const _=!n.shipping[l],T=n.frame==="phone";((e.dirty??0)>0||(e.ahead??0)>0||!T&&!n.layout.changes)&&p.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{o({a:"activate",id:l}),T?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),T||p.push({id:"terminal",label:"open terminal",onClick:()=>{o({a:"activate",id:l}),o({a:"focus-terminal"})}}),p.push(...Jo(()=>r==null?void 0:r.send({t:"reveal",worktreeId:l}),i.hostname)),T||h.push({id:"copy-path",label:"copy path",onClick:()=>nn(e.path)}),h.push({id:"copy-branch",label:"copy branch name",onClick:()=>nn(e.worktree.branch)});const{transcript:x,sessionId:N}=e;!T&&x&&!kr(e.worktree)&&h.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>nn(x)}),!T&&N&&h.push({id:"copy-session",label:"copy session id",onClick:()=>nn(N)});const j=n_(e.worktree,t);for(const A of ou(e.worktree)?[]:th(t))m.push({id:`profile:${A}`,label:`run with ${A}`,checked:A===j,onClick:()=>c.setProfile(e,A)});if(!aa(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)}),!aa(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)}),p1(e.worktree)&&g.push({id:"rename",label:"rename…",onClick:()=>c.rename(e)}),e.worktree.variant&&g.push({id:"keep",label:"keep this variant…",onClick:()=>c.pickVariant(e)}),i.graft&&Bd(e.worktree)){const A=i.graft;g.push({id:"graft",label:"graft with…",onClick:()=>A(l)})}g.push({id:"unread",label:"mark as unread",key:zt("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>o_(r,o,l)});const $=_?void 0:"waiting on the one in progress";if(e.syncQueued)w.push({id:"sync",label:"call off the sync from main",onClick:()=>r==null?void 0:r.send({t:"unqueue-sync",worktreeId:l})});else if(jf(e)&&(e.behind??0)>0){const A=$o(e.agent)&&(e.dirty??0)>0;w.push({id:"sync",label:`sync from main${A?" after the turn":""} (${e.behind} behind)`,disabled:$,onClick:()=>pi(r,o,{t:"sync-main",worktreeId:l})})}return Xi(e.worktree)&&!(e.worktree.landed&&e.dirty===0)&&w.push({id:"land",label:Fg(fi((t==null?void 0:t.config)??{}),e.worktree),detail:rz(t),disabled:$,onClick:()=>pi(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}})}),Mg(e.worktree)&&b.push({id:"archive",label:r_(e)?"archive…":"archive",key:zt("wt-archive"),danger:!0,onClick:()=>c.archive(e)}),zn([u,p,h,m,g,w,y,b])}function oz(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 jf(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(...Jo(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),zn([c,i,l?[]:[{id:"copy-path",label:"copy path",onClick:()=>nn(e.path)}]])}const sz={sm:"",md:"field-md",lg:"field-lg"};function i_({size:e="sm",font:t,bare:n,rule:r,className:o}){const i=t??(e==="lg"?"ui":"mono");return We("field",sz[e],i==="ui"&&"field-ui",i==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const Io=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},c){return d.jsx("input",{ref:c,className:i_({size:t,font:n,bare:r,rule:o,className:i}),...l})}),Zc=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:i,...l},c){return d.jsx("textarea",{ref:c,className:i_({size:t,font:n,bare:r,rule:o,className:i}),...l})});function iz(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function a_(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function l_(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${a_(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 az(e){return e.stale!=="diverged"}const Wr=e=>/[.!?…]$/.test(e)?e:`${e}.`,c_=160;function nh(e,t=c_){const n=e.replace(/\s+/g," ").trim();if(n.length<=t)return n;const r=n.slice(0,t);return`${r.slice(0,Math.max(r.lastIndexOf(" "),1)).trimEnd()}…`}function u_(e){return e.subjects.length?nh(e.subjects.join("; ")):void 0}function Lk(e){const t=u_(e);if(t)return e.pr===void 0?t:nh(`PR #${e.pr}: ${t}`)}function Dk(e,t=3){const n=[];for(const l of e??[]){const c=Lk(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?Wr(c):`${zk(Zo(wr(l)))}: ${Wr(c)}`);return o>0?[`${o} earlier landing${o===1?"":"s"}.`,...i]:i}const lz="checks running",cz="checks failed",d_="preview up";function uz(e){if(e.state!=="open")return[];const t=[];return(e.checks==="pending"||e.checks==="fail")&&t.push({text:e.checks==="fail"?cz:lz,url:`${e.url}/checks`,tip:"Open the checks on GitHub",open:"open the checks"}),e.preview&&t.push({text:d_,url:e.preview,tip:`Open the branch on ${new URL(e.preview).hostname}`,open:"open the preview"}),t}function dz(e,t){const n=[];let r=e;for(const o of t){const i=new RegExp(`(^|; |, )${o.text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=;|\\.|$)`).exec(r);if(!i)continue;const l=i.index+(i[1]??"").length;l>0&&n.push(r.slice(0,l)),n.push(o),r=r.slice(l+o.text.length)}return r&&n.push(r),n}function Ts(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?`; ${d_}.`:".";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 f_(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 zk=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function Fk(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 h_(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 fz(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 Cd(e,t=0,n=!0,r){var o,i;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const l=(i=(o=e.checkTail)==null?void 0:o.split(`
|
|
117
|
-
`).find(c=>c.trim()))==null?void 0:i.trim();return`Check failed${l?`: ${Wr(l)}`:"."}`}return Fk(e,t,n)==="unasked"?fz(r):null}function xb(e,t){const n=hz(e,t);return n?Wr(zk(n)):""}function hz(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 p_=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function pz(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function mz(e){return e>0?Wr(zk(`${e} ${e===1?"file":"files"} changed`)):""}function gz(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: ${Wr(p_(e.why))}`:null}function Ad(e){return Wr(e)}const Zo=e=>e==="now"?"just now":`${e} ago`;function kz(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${Wr(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${Zo(n)}: not logged in.`:t.error?`Failed ${Zo(n)}: ${Wr(t.error)}`:`Failed ${Zo(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${Zo(n)}. Say what to change.`:`Stopped ${Zo(n)}.`;case"done":return t.cut?`Ended early ${Zo(n)} (${t.cut}).`:`Finished ${Zo(n)}.`}}function Bk(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?Wr(t):kz(e.end,e.facts,wr(e.at))}function wz(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${Zo(wr(e.at))}: ${Wr(p_(t))}`:void 0}function qc(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 Uk(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function m_(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=bk(t,xk);return t!==void 0&&n===t?e:void 0}function g_(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${Qi(t)} of ${qC(e.timeoutMs)}`];case"detached":return[...n,Qi(t),"detached"];case"terminated":return[e.why??"stopped"]}}function ff(e,t,n){return[e,...g_(t,n)].join(" · ")}const Ym={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 k_(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 yz({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var sn,ln,lt;const i=it(),l=ut(),c=yn("changes"),u=Sn(e)?e.worktree:null,p=e.id,h=M(jt=>{var Kt;return(Kt=jt.shipping[p])==null?void 0:Kt.op}),m=M(jt=>{var Kt;return(Kt=jt.shipping[p])==null?void 0:Kt.step}),g=bk(m,xk),w=qc(e,"commit"),y=qc(e,"check"),b=h?w:y,_=m_(b),T=oa(Uk(_)?_==null?void 0:_.since:void 0),[x,N]=S.useState("");ft([p],()=>N("")),ft([o],()=>{o||N("")});const j=S.useRef(null),$=(sn=u==null?void 0:u.landing)!=null&&sn.subject?u.landing.body?`${u.landing.subject}
|
|
118
|
-
|
|
119
|
-
${u.landing.body}`:u.landing.subject:null,P=()=>{x===""&&$&&N($);const jt=j.current;jt&&(jt.focus(),requestAnimationFrame(()=>jt.setSelectionRange(jt.value.length,jt.value.length)))},R=M(jt=>jt.editCommit);ft([R],()=>{R&&P()});const A=x.trim()||void 0,O=M(jt=>{var Kt;return!!((Kt=jt.agents.find(xn=>xn.id===((u==null?void 0:u.agent)??jt.defaultAgent)))!=null&&Kt.quick)}),D=u==null?void 0:u.landing,z=A?null:Fk(D,o?1:0,O),X=(D==null?void 0:D.check)==="pending",ne=!!(D!=null&&D.stale),ee=()=>{h||i==null||i.send({t:"judge",worktreeId:p})},ie=()=>{h||!A&&!$||pi(i,l,{t:"commit",worktreeId:p,message:A??$??""})},be=()=>{h||pi(i,l,{t:"land",worktreeId:p,...A?{message:A}:{}})},C=((ln=u==null?void 0:u.landing)==null?void 0:ln.check)==="fail",Z=!!(u!=null&&u.landed)&&!o,Y=u?Af({...u,landed:Z}):void 0,q=(Y==null?void 0:Y.state)==="open",F=q&&(o||r>0),re=X||ne||!!z,Ee=!!u&&Xi(u)&&!Z&&(o||t>0)&&!C&&!q&&!re,Te=!!u&&F&&!C&&!re,de=!!u&&Xi(u)&&!X&&(ne||z==="unwritten"||z==="unanswered")&&!$o(e.agent),ke=M(jt=>jt.repos.find(Kt=>Kt.id===e.repoId)??null),ae=fi((ke==null?void 0:ke.config)??{}),G=Jd(ae,ke==null?void 0:ke.defaultBranch),ue=Fg(ae,u??{}),Le=ke?Cf(ke):"main",ge=jf(e)?iz(Le,n):null,oe=$o(e.agent),we=o&&!u?"commit or discard the changes here first":void 0,Ce=!!e.syncQueued,Se=o&&oe?`Merge ${Le} into this worktree once the turn ends, uncommitted changes kept`:`Merge ${Le} into this worktree${o?", uncommitted changes kept":""}`,_e=q&&!F&&f_(Y),Be=Ee?ue:Te?"update":_e?"land":(Y==null?void 0:Y.state)==="merged"?"pull":"land",wt=h==="commit"?g??"commit":h==="land"?g?`${Be}: ${g}`:Be:null,on=wt&&_?ff(wt,_,T):wt,Et=S.useRef(!1);on?o&&(Et.current=!0):Et.current=!1;const Vt=!!u&&(o||Et.current),Ft=Vt&&!!on,Ht=h?null:b?_?g_(_,T).join(" · "):null:X?"writing the message":null,Me=_&&(_.status==="running"||_.status==="detached")?_:null,St=Me&&d.jsx(Mt,{icon:"stop",tone:"danger",label:k_(Me.kind),onClick:()=>i==null?void 0:i.send({t:"run-stop",worktreeId:p,kind:Me.kind})});return d.jsxs("div",{className:"composer commit-box",children:[Vt&&d.jsx("div",{className:"composer-field",children:Ft?d.jsx("div",{className:"commit-running live-text","data-tip":_?Ym[_.status]:void 0,children:on}):d.jsx(Zc,{size:"lg",bare:!0,ref:j,value:x,onChange:jt=>N(jt.target.value),onKeyDown:jt=>{jt.key==="Enter"&&(jt.metaKey||jt.ctrlKey)?(jt.preventDefault(),ie()):jt.key==="Tab"&&!jt.shiftKey&&x===""&&$&&(jt.preventDefault(),P())},placeholder:$??(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(Tt,{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 ${Le}`,children:[t," ahead"]}),(u==null?void 0:u.landed)&&d.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${Le}`,children:[d.jsx(Tt,{name:"check",className:"icon-inline"})," landed"]})]}),d.jsxs("span",{className:"commit-acts",children:[on?d.jsxs(d.Fragment,{children:[!Ft&&d.jsx("span",{className:"live-text",children:on}),St]}):d.jsxs(d.Fragment,{children:[u&&o&&d.jsx(Fe,{disabled:!A&&!$||!!h,onClick:ie,...Ut($&&!A?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&Ee&&d.jsx(Fe,{tone:"primary",disabled:!!h,"data-tip":G,onClick:be,children:ue}),de&&d.jsx(Fe,{tone:"primary",disabled:!!h,"data-tip":h_(D,!!((lt=ke==null?void 0:ke.config.check)!=null&<.trim()),z),onClick:ee,children:"check"}),X&&d.jsx("span",{className:"live-text",children:"check"}),Te&&Y&&d.jsx(Fe,{tone:"primary",disabled:!!h,"data-tip":`Commit, take ${Le} in and push the branch; PR #${Y.number} takes the new commits`,onClick:be,children:"update"}),_e&&d.jsx(Fe,{tone:"primary",disabled:!!h,"data-tip":"Merge the PR now, by the method the repo allows",onClick:be,children:"land"})]}),Y&&d.jsxs(Fe,{"data-tip":`Open PR #${Y.number} on GitHub`,onClick:()=>window.open(Y.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(Y.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>nn(Y.url)}]),children:["view ",d.jsx(Tt,{name:"external",className:"icon-inline"})]}),(Y==null?void 0:Y.preview)&&d.jsxs(Fe,{"data-tip":`Open the branch on ${new URL(Y.preview).hostname}`,onClick:()=>window.open(Y.preview,"_blank"),...c.contextMenu(()=>[{id:"open-preview",label:"open the preview",onClick:()=>window.open(Y.preview,"_blank")},{id:"copy-preview",label:"copy link",onClick:()=>nn(Y.preview??"")}]),children:["preview ",d.jsx(Tt,{name:"external",className:"icon-inline"})]})]})]}),(ge||Ht)&&d.jsxs("div",{className:"composer-notes",children:[Ht&&d.jsxs("div",{className:"hint composer-note","data-tip":_?Ym[_.status]:void 0,children:[d.jsx("span",{children:Ht}),St]}),ge&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:ge}),h==="sync-main"?d.jsx("span",{className:"live-text",children:g?`sync: ${g}`:"sync"}):Ce?d.jsx("span",{className:"live-text","data-tip":"Runs once the turn ends, the uncommitted changes kept. The row's menu calls it off",children:"syncing after next turn"}):d.jsx(Fe,{variant:"outline",disabled:!!h||!!we,"data-tip":we??Se,onClick:()=>pi(i,l,{t:"sync-main",worktreeId:p}),children:"sync"})]})]})]})}const vz=S.memo(function({c:t,id:n,selected:r,onToggle:o}){const i=yn("changes"),l=M(c=>c.chatSide);return d.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":dr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...i.contextMenu(()=>t_(t)),"data-tip":`${t.subject}
|
|
120
|
-
${t.short} · ${t.author}`,"data-tip-placement":l,children:[d.jsx("span",{className:"subject",children:t.subject}),d.jsx("span",{className:"at row-dim",children:wr(t.at)})]})});function bz(e,t){const n=wo(e,t);if(!n||!Sn(n))return"take this worktree over to change files here";if(aa(n.worktree))return"start a worktree to change files"}function w_(e,t,n,r){return{id:"new-file",label:"new file…",disabled:bz(e.getState(),t),onClick:()=>r(n)}}function xz(e,t,n,r){const{worktreeId:o,dir:i,path:l,folder:c,newIn:u}=e,p=Xf(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",h=Ak(l,c),m=[...c?[]:[{id:"open",label:"open",onClick:()=>er(n,{worktreeId:o,path:l,view:wi(l)})}],{id:"add-to-chat",label:"add to chat",disabled:p,onClick:()=>IS(t,o,l,c)}],g=[w_(t,o,u,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:p,onClick:()=>lb(t,o,`Rename ${h} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:p,onClick:()=>lb(t,o,`Delete ${h} and update whatever still uses it`)}],w=[...Jo(()=>{var y;return(y=n.sock)==null?void 0:y.send({t:"reveal",worktreeId:o,path:l})},Qo(n.sock)),{id:"copy-path",label:"copy path",onClick:()=>nn(`${i}/${l}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>nn(l)}];return zn([m,w,g])}function Ez(e,t,n,r){return zn([[w_(t,e.worktreeId,"",r)],Jo(()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})},Qo(n.sock))])}const Id=[],Sz=[],Eb=new Set,Sb=e=>`tree-row-${e}`;function _z({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const i=Yn(),l=it(),c=ut(),u=Rt(e,"files"),p=Rt(e,"submodules"),h=Rt(e,"ignored"),m=Rt(e,"git"),g=(m==null?void 0:m.files)??Sz,w=m==null?void 0:m.version,y=M(oe=>oe.connected);ft([e,w,y,l],()=>Vf(e,i.getState(),{sock:l,dispatch:c}));const b=M(oe=>{var we;return((we=oe.dragFiles)==null?void 0:we.at)==="tree"&&oe.dragFiles.worktreeId===e?oe.dragFiles.dir:null}),_=M(oe=>oe.treeOpen[e]??Id),T=S.useMemo(()=>new Set(_),[_]),[x,N]=S.useState(Eb);ft([e,n,r],()=>N(n&&!r?new Set(cf(n).filter(oe=>!T.has(oe))):Eb));const j=S.useCallback(oe=>T.has(oe)||x.has(oe),[T,x]),$=S.useCallback(oe=>{const we=T.has(oe)||x.has(oe);if(we&&x.has(oe)){const Ce=new Set(x);Ce.delete(oe),N(Ce)}c({a:"tree-folder",worktreeId:e,path:oe,open:!we})},[T,x,e,c]),P=S.useMemo(()=>W4(u??Id,p??Id,h??Id),[u,p,h]),R=S.useMemo(()=>K4(P,j),[P,j]),A=S.useMemo(()=>q4(g),[g]),O=M(oe=>oe.treeReveal),D=O&&O.worktreeId===e?O:null,[z,X]=S.useState(()=>(D==null?void 0:D.path)??null),[ne,ee]=S.useState({worktreeId:e,linked:D});(ne.worktreeId!==e||ne.linked!==D)&&(ee({worktreeId:e,linked:D}),X((D==null?void 0:D.path)??null));const[ie,be]=S.useState(!1),C=S.useMemo(()=>{if(z===null)return-1;const oe=R.findIndex(we=>we.path===z);if(oe>=0)return oe;for(const we of cf(z).reverse()){const Ce=R.findIndex(Se=>Se.path===we);if(Ce>=0)return Ce}return-1},[R,z]);ft([C,ie],()=>{var oe,we;ie&&((we=(oe=o.current)==null?void 0:oe.querySelector('[data-state~="cursor"]'))==null||we.scrollIntoView({block:"nearest"}))});const Z=S.useCallback((oe,we)=>er({dispatch:c},{worktreeId:e,path:oe,view:wi(oe),focus:we}),[e,l,c]),Y=S.useCallback(oe=>{X(oe.path),oe.kind==="folder"?$(oe.path):oe.kind==="file"&&Z(oe.path,!1)},[$,Z]),q=oe=>{var Se;if(oe.metaKey||oe.ctrlKey||oe.altKey)return;const we=R[C],Ce=_e=>{const Be=R[_e];Be&&(X(Be.path),Be.kind==="file"&&Z(Be.path,!1))};switch(oe.key){case"ArrowDown":case"ArrowUp":oe.preventDefault(),Ce(C<0?0:cu(C,oe.key==="ArrowDown"?1:-1,R.length));return;case" ":oe.preventDefault(),(we==null?void 0:we.kind)==="file"?Z(we.path,!1):(we==null?void 0:we.kind)==="folder"&&$(we.path);return;case"Enter":oe.preventDefault(),(we==null?void 0:we.kind)==="file"?Z(we.path,!0):(we==null?void 0:we.kind)==="folder"&&$(we.path);return;case"ArrowRight":case"ArrowLeft":{oe.preventDefault();const _e=R.map(wt=>wt.kind==="folder"?{depth:wt.depth,open:wt.open}:{depth:wt.depth}),Be=eh(_e,C,oe.key);(Be==null?void 0:Be.do)==="to"?Ce(Be.at):Be&&we&&$(we.path);return}case"Escape":oe.stopPropagation(),n!==null?c({a:"close-editor"}):(Se=document.activeElement)==null||Se.blur();return}if(oe.key.length===1){const _e=VS(R.map(Be=>Be.name),C,oe.key);_e>=0&&(oe.preventDefault(),Ce(_e))}},[F,re]=S.useState(null),Ee=S.useRef(0),Te=S.useCallback(oe=>{oe&&!j(oe)&&$(oe),Ee.current++,re({dir:oe,error:null,busy:!1})},[j,$]),de=S.useCallback(()=>{Ee.current++,re(null)},[]),ke=S.useCallback(oe=>{if(!F||F.busy)return;const we=Z4(F.dir,oe);if("error"in we){re({...F,error:we.error});return}const Ce=++Ee.current;re({...F,error:null,busy:!0}),NS({sock:l,dispatch:c},{worktreeId:e,path:we.path}).then(Se=>{Se===null&&X(we.path),Ce===Ee.current&&re(Se===null?null:{...F,error:Se,busy:!1})})},[F,e,l,c]),ae=yn("tree"),G=S.useCallback(oe=>xz({worktreeId:e,dir:t,path:oe.path,folder:oe.kind!=="file",newIn:oe.kind==="folder"||oe.kind==="ignored"?oe.path:$S(oe.path)},i,{sock:l,dispatch:c},Te),[e,t,i,l,c,Te]),ue=S.useCallback((oe,we)=>{oe.kind==="file"&&an.post(e,we?{type:"highlight-file",path:oe.path,ranges:null}:{type:"highlight-clear"})},[e]),Le=S.useCallback((oe,we)=>{we.dataTransfer.setData(PS,oe.path),we.dataTransfer.setData("text/plain",oe.path),we.dataTransfer.effectAllowed="copy",lD({worktreeId:e,path:oe.path,folder:oe.kind!=="file"})},[e]),ge=S.useCallback(()=>LS(i),[i]);return d.jsx("div",{className:We("tree",b===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":ie&&C>=0?Sb(C):void 0,tabIndex:0,ref:o,onKeyDown:q,onFocus:()=>{var oe;be(!0),z===null&&X(n&&R.some(we=>we.path===n)?n:((oe=R[0])==null?void 0:oe.path)??null)},onBlur:oe=>!oe.currentTarget.contains(oe.relatedTarget)&&be(!1),onMouseDown:oe=>{if(oe.button!==0)return;const we=oe.target.closest("[data-path]");(we==null?void 0:we.dataset.path)!==void 0&&X(we.dataset.path)},...ae.contextMenu(oe=>{const we=R[C];return oe==="keyboard"&&we?G(we):Ez({worktreeId:e},i,{sock:l},Te)}),children:u===void 0?d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"listing files"})}):R.length===0&&!F?d.jsx("div",{className:"empty",children:"no files"}):Nz(R.map((oe,we)=>d.jsx(jz,{row:oe,id:Sb(we),status:A.files.get(oe.path),changedInside:oe.kind!=="file"&&A.folders.has(oe.path),current:ie?we===C:!r&&oe.path===n,cursor:ie&&we===C,dropOver:b===oe.path,onPress:Y,menu:G,onHover:ue,onDragStart:Le,onDragEnd:ge},oe.path)),F&&(()=>{var we;const oe=F.dir===""?-1:R.findIndex(Ce=>Ce.path===F.dir);return{at:oe,node:d.jsx(Tz,{depth:oe>=0?(((we=R[oe])==null?void 0:we.depth)??0)+1:0,error:F.error,onSubmit:ke,onCancel:de},"new-file")}})())})}function Nz(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function Tz({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,i]=S.useState(""),l={"--tree-depth":e},c=e===0||void 0;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"row row-sm tree-row row-rails","data-kind":"file","data-root":c,style:l,children:[d.jsx("span",{className:"tree-caret row-dim"}),d.jsx(Io,{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 jz=S.memo(function({row:t,id:n,status:r,changedInside:o,current:i,cursor:l,dropOver:c,onPress:u,menu:p,onHover:h,onDragStart:m,onDragEnd:g}){const w=yn("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:We("row row-sm tree-row row-rails row-edge",c&&"drop-over"),"data-state":dr({current:i,cursor:l}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!y,onDragStart:_=>m(t,_),onDragEnd:g,onClick:()=>u(t),onMouseEnter:()=>h(t,!0),onMouseLeave:()=>h(t,!1),...w.contextMenu(()=>p(t)),...b?Ut(b):{},children:[d.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&d.jsx(Tt,{name:"caret",className:We("icon-inline disc-caret",!t.open&&"shut")})}),d.jsx("span",{className:We("tree-name",(y||t.ignored)&&"row-dim"),children:t.name}),r?d.jsx("span",{className:`xy ${ik(r.xy)}`,children:ak(r.xy)}):o&&d.jsx("span",{className:"dot tree-changed"})]})});function y_({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 $d=S.memo(function({f:t,id:n,active:r,selected:o,checking:i=!1,checked:l=!1,onOpen:c,onCheck:u,menu:p,onHover:h}){const m=yn("changes"),{name:g,dir:w}=RE(t.path);return d.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":dr({current:r,cursor:o,checked:l}),role:"option","aria-selected":o,tabIndex:-1,onClick:y=>u&&(i||y.shiftKey)?u(t.path):c(t.path),...m.contextMenu(()=>p(t.path)),onMouseEnter:()=>h(t.path,!0),onMouseLeave:()=>h(t.path,!1),children:[i&&d.jsx("input",{type:"checkbox",className:"changes-check",checked:l,readOnly:!0,tabIndex:-1}),d.jsx("span",{className:`xy ${ik(t.xy)}`,children:ak(t.xy)}),d.jsxs("span",{className:"path","data-tip":w?t.path:void 0,children:[d.jsx("span",{className:"name",children:g}),w&&d.jsx("span",{className:"dir row-dim",children:w})]}),d.jsx(y_,{f:t})]})}),Cz={added:"A",changed:"M",removed:"D"},Az={added:"added",changed:"",removed:"deleted"},Iz=S.memo(function({tests:t,id:n,cursor:r,onPick:o}){return t.map((i,l)=>d.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${l}`,"data-state":dr({current:r===l,cursor:r===l}),"data-sub":!0,role:"option","aria-selected":r===l,tabIndex:-1,onClick:()=>o(l),"data-tip":[...i.group,i.name].join(" · "),"data-tip-placement":"follow",children:[d.jsx("span",{className:`xy ${Az[i.change]}`,children:Cz[i.change]}),d.jsx("span",{className:"name",children:i.name})]},l))}),_b=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),$z=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function hf(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&_b.has(n.toLowerCase())?!0:t.some(r=>_b.has(r.toLowerCase()))||$z.test(n)}function Rd(e){const t=e.filter(n=>!hf(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>hf(n.path))],source:t.length}}const Xm="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",Nb={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Xm}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Xm}`)]},Rz={js:Nb,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*${Xm}`),/^\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*\(/,...Nb.tests]}},Oz={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"},Mz=3,Pz=/^\s*(?:[)}\]]|end\b)/,Qp=e=>e.length-e.trimStart().length;function Tb(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 jb(e,t){const n=t.split(`
|
|
121
|
-
`),r=[],o=[];let i=Number.NEGATIVE_INFINITY;return n.forEach((l,c)=>{var g,w,y;if(l.trim()==="")return;const u=Qp(l);for(;o.length>0&&(((g=o.at(-1))==null?void 0:g.indent)??0)>=u;)o.pop();(w=e.mark)!=null&&w.test(l)&&(i=c);const h=!e.mark||c-i<=Mz?Tb(l,e.tests):null,m=h??Tb(l,e.groups);if(m!==null){if(h!==null){i=Number.NEGATIVE_INFINITY;let b=c+1;for(;b<n.length&&(((y=n[b])==null?void 0:y.trim())===""||Qp(n[b]??"")>u);)b++;b<n.length&&Qp(n[b]??"")===u&&Pz.test(n[b]??"")&&b++;const _=n.slice(c,b).map(T=>T.trim()).join(`
|
|
122
|
-
`).trim();r.push({group:o.map(T=>T.name),name:m,line:c,end:b,body:_})}o.push({indent:u,name:m})}}),r}function Cb(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
|
|
123
|
-
`);let o=0;for(;t.has(`${r}
|
|
124
|
-
${o}`);)o++;t.set(`${r}
|
|
125
|
-
${o}`,n)}return t}function Lz(e,t,n){const r=Rz[Oz[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=Cb(jb(r,t)),i=Cb(jb(r,n)),l=[];for(const[h,m]of i){const g=o.get(h);(g==null?void 0:g.body)!==m.body&&l.push({name:m.name,group:m.group,change:g?"changed":"added",line:m.line+1})}const c=n.split(`
|
|
126
|
-
`).length;let u=1;for(const[h,m]of o){const g=i.get(h);g?u=Math.min(g.end+1,c):l.push({name:m.name,group:m.group,change:"removed",line:u})}const p=h=>h.change==="removed"?0:1;return l.sort((h,m)=>h.line-m.line||p(h)-p(m))}const Od=[];function Dz(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=wr(r.at);return`${o}, last commit ${i==="now"?"just now":`${i} ago`}`}const Ab='[role="option"]:not([data-sub])',Ib=[];function v_({width:e,placement:t="dock"}){var sr,Lr;const n=t==="screen",r=it(),o=ut(),i=Yn(),l=jl(),c=ha(),u=(c==null?void 0:c.id)??l,p=$s(),h=M(K=>K.layout.changes),m=iu(),g=M(K=>K.focusChanges),w=Rt(u,"git"),y=M(K=>K.editor&&K.editor.worktreeId===u?K.editor.path:null),b=M(K=>K.editor&&K.editor.worktreeId===u?K.editor.ref??null:null),_=M(K=>K.editor&&K.editor.worktreeId===u?K.editor.since??null:null),T=(w==null?void 0:w.files)??Od,x=((sr=w==null?void 0:w.extras)==null?void 0:sr.committed)??Od,{files:N,source:j}=S.useMemo(()=>Rd(T),[T]),$=x.length>0,P=r4(),{files:R,source:A}=S.useMemo(()=>Rd(P?x:Od),[x,P]),O=(Lr=w==null?void 0:w.extras)==null?void 0:Lr.turn,D=O==null?void 0:O.base,z=o4(),{files:X,source:ne}=S.useMemo(()=>Rd(O&&z?O.files:Od),[O,z]),ee=N.length,ie=N.length+X.length,be=M(K=>K.editor&&K.editor.worktreeId===u?K.editor.disk:null),C=S.useMemo(()=>y!==null&&be&&hf(y)?Lz(y,be.before,be.after):Ib,[y,be]),[Z,Y]=S.useState(!1);ft([y,b,_],()=>Y(!1));const q=j>0?N.length-j:0,F=A>0?R.length-A:0,re=ne>0?X.length-ne:0,Ee=N.length===0,Te=S.useMemo(()=>{if(N.length===0)return;const K=N.reduce((mt,Zt)=>mt+(Zt.add??0),0),fe=N.reduce((mt,Zt)=>mt+(Zt.del??0),0),Qe=[K>0&&`+${K}`,fe>0&&`−${fe}`].filter(Boolean).join(" "),At=`${N.length} uncommitted ${N.length===1?"file":"files"}`;return Qe?`${At}, ${Qe}`:At},[N]),de=!!w&&Ee&&(w.ahead??0)===0,ke=M(yl),ae=c!==null||ke==="changes",G=c!==null||ke==="history",ue=S.useCallback(K=>o({a:"changes-tab",v:K}),[o]),Le=S.useRef(ke);Le.current=ke;const ge=S.useRef(null),oe=Ek(),we=M(K=>{const fe=Ei(K,oe==null?void 0:oe.repoId);return fe?Cf(fe):"main"}),Ce=Rt(u,"commits"),Se=Rt(u,"commitFiles"),[_e,Be]=S.useState(null),wt=S.useRef(null);wt.current=_e;const on=S.useRef(null),Et=Rt(u,"changedRanges"),Vt=S.useCallback((K,fe)=>{if(!u||c)return;if(!fe){on.current=null,an.post(u,{type:"highlight-clear"});return}on.current=K;const Qe=Et[K];Qe?an.post(u,{type:"highlight-file",path:K,ranges:P0(Qe)}):r==null||r.send({t:"changed-ranges",worktreeId:u,path:K})},[u,c,Et,r]);S.useEffect(()=>{const K=on.current;if(!K||!u)return;const fe=Et[K];fe&&an.post(u,{type:"highlight-file",path:K,ranges:P0(fe)})},[Et,u]);const Ft=c&&N.length>0?(w==null?void 0:w.head)??null:null,Ht=S.useCallback((K,fe=!1,Qe)=>u&&er({dispatch:o},{worktreeId:u,path:K,focus:fe,ref:Ft??void 0,since:Qe}),[u,Ft,r,o]),Me=S.useMemo(()=>c?N:[...N,...X,...R],[c,N,X,R]),St=S.useMemo(()=>{const K=[];for(const fe of Ce??[])if(K.push({commit:fe}),fe.sha===_e)for(const Qe of Rd(Se[fe.sha]??[]).files)K.push({commit:fe,file:Qe});return K},[Ce,_e,Se]),sn=S.useMemo(()=>St.filter(K=>!K.file&&K.commit.ahead).length,[St]),ln=S.useMemo(()=>St.findIndex(K=>!K.file&&!K.commit.ahead),[St]),lt=c?Me.length:0,jt=(ae?Me.length:0)+(G?St.length:0),Kt=S.useMemo(()=>{const K=new Map;if(!c||N.length===0&&St.every(Qe=>Qe.commit.landedAt))return K;let fe;return St.forEach((Qe,At)=>{const mt=!!Qe.commit.landedAt;mt!==fe&&(fe=mt,K.set(At,mt?"landed":"not landed"))}),K},[c,N,St]),xn=S.useRef(null),[{row:Dt,at:jn},Qt]=S.useReducer((K,fe)=>typeof fe=="number"?{row:fe,at:-1}:fe,{row:0,at:-1}),[V,pe]=S.useState(!1),Ye=(K,fe)=>V?Xn(K):fe,nt=K=>`changes-row-${K}`,[yt,Jt]=S.useState(!1),[ye,Ae]=S.useState([]),Yt=S.useCallback(()=>{Jt(!1),Ae([])},[]),B=S.useCallback(K=>{Jt(!0),Ae(fe=>fe.includes(K)?fe.filter(Qe=>Qe!==K):[...fe,K])},[]),me=S.useMemo(()=>N.filter(K=>ye.includes(K.path)).map(K=>K.path),[N,ye]);ft([N],()=>Ae(K=>{const fe=K.filter(Qe=>N.some(At=>At.path===Qe));return fe.length===K.length?K:fe})),ft([yt],()=>{if(!yt)return;const K=fe=>fe.key==="Escape"&&Yt();return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)}),ft([u,ke],()=>{Qt(0),Yt()});const De=w==null?void 0:w.head,Xe=S.useRef("");S.useEffect(()=>{if(!(G||de)||!u)return;const K=`${u}:${De??""}`;Xe.current!==K&&(Xe.current=K,r==null||r.send({t:"git-log",worktreeId:u}))},[G,de,u,De,r]);const Pt=S.useCallback(K=>{Be(fe=>fe===K?null:K),u&&!Se[K]&&(r==null||r.send({t:"git-commit",worktreeId:u,sha:K}))},[u,Se,r]);ft([Dt,jn,V],()=>{var K,fe;V&&((fe=(K=xn.current)==null?void 0:K.querySelector('[data-state~="cursor"]'))==null||fe.scrollIntoView({block:"nearest"}))});const _t=S.useRef(-1),He=K=>K>=ee&&K<ie?D:void 0,ze=K=>{var fe;return((fe=Me[K])==null?void 0:fe.path)===y&&(_??void 0)===He(K)&&(K<ee?b===Ft:!b)};_t.current=ae?Me.findIndex((K,fe)=>ze(fe)):-1,S.useEffect(()=>{if(!g)return;const K=Le.current==="files";_t.current>=0&&Qt(_t.current);const fe=requestAnimationFrame(()=>{var Qe;return(Qe=(K?ge:xn).current)==null?void 0:Qe.focus()});return()=>cancelAnimationFrame(fe)},[g]);const qe=S.useCallback((K,fe=!1)=>{const Qe=Me[K];Qe&&(Qt(K),Ht(Qe.path,fe,K>=ee&&K<ie?D:void 0),Vt(Qe.path,!0))},[Me,Ht,Vt,ee,ie,D]),ht=S.useCallback((K,fe=!1)=>{const Qe=wt.current;u&&Qe&&er({dispatch:o},{worktreeId:u,path:K,ref:Qe,focus:fe})},[u,r,o]),Ct=S.useCallback(K=>{const fe=St[K-lt];fe&&(Qt(K),fe.file&&ht(fe.file.path))},[St,lt,ht]),Bt=S.useCallback(K=>{const fe=St[K-lt];fe&&(Qt(K),fe.file?ht(fe.file.path,!0):Pt(fe.commit.sha))},[St,lt,ht,Pt]),qt=K=>G&&K>=lt,vn=K=>{if(y===null)return!1;if(ae&&K<Me.length)return ze(K);const fe=qt(K)?St[K-lt]:void 0;return!!(fe!=null&&fe.file)&&b===fe.commit.sha&&fe.file.path===y},On=K=>vn(K)&&!Z?C:Ib,Cn=jn<On(Dt).length?jn:-1,Xn=K=>V&&Dt===K&&Cn<0,Kn=()=>{var fe,Qe;const K=[];for(let At=0;At<jt;At++){const mt=qt(At)?St[At-lt]:void 0,Zt=mt?(fe=mt.file)==null?void 0:fe.path:(Qe=Me[At])==null?void 0:Qe.path,Dr=mt!=null&&mt.file?1:0,fr=On(At);mt&&!mt.file?K.push({row:At,at:-1,depth:Dr,open:mt.commit.sha===_e}):Zt!==void 0&&hf(Zt)?K.push({row:At,at:-1,depth:Dr,open:fr.length>0}):K.push({row:At,at:-1,depth:Dr});for(let yo=0;yo<fr.length;yo++)K.push({row:At,at:yo,depth:Dr+1})}return K},se=(K,fe=!1)=>{const Qe=C[K];!Qe||!u||y===null||er({dispatch:o},{worktreeId:u,path:y,ref:b??void 0,since:_??void 0,line:{n:Qe.line},focus:fe})},Ne=K=>On(K).length>0&&d.jsx(Iz,{tests:C,id:nt(K),cursor:V&&Dt===K?Cn:-1,onPick:fe=>{Qt({row:K,at:fe}),se(fe)}}),at=K=>{var fe;if(yt&&K.key==="Escape")K.preventDefault(),K.stopPropagation(),Yt();else if(yt&&K.key===" "){K.preventDefault();const Qe=ae&&Dt<N.length?N[Dt]:void 0;Qe&&B(Qe.path)}else if(K.key==="ArrowDown"&&Cn+1<On(Dt).length)K.preventDefault(),Qt({row:Dt,at:Cn+1}),se(Cn+1);else if(K.key==="ArrowUp"&&Cn>=0)K.preventDefault(),Cn===0?Qt(Dt):(Qt({row:Dt,at:Cn-1}),se(Cn-1));else if(K.key==="Enter"&&Cn>=0)K.preventDefault(),se(Cn,!0);else if(K.key==="ArrowDown"||K.key==="ArrowUp"){K.preventDefault();const Qe=cu(Dt,K.key==="ArrowDown"?1:-1,jt);qt(Qe)?Ct(Qe):qe(Qe)}else if(K.key==="Enter")K.preventDefault(),qt(Dt)?Bt(Dt):qe(Dt,!0);else if(K.key==="ArrowRight"||K.key==="ArrowLeft"){K.preventDefault();const Qe=Kn(),At=eh(Qe,Qe.findIndex(Dr=>Dr.row===Dt&&Dr.at===Cn),K.key),mt=At&&Qe[At.at];if(!At||!mt)return;const Zt=qt(mt.row)?St[mt.row-lt]:void 0;At.do==="to"?mt.at>=0?(Qt({row:mt.row,at:mt.at}),se(mt.at)):Zt!=null&&Zt.file&&mt.row>Dt?Ct(mt.row):Qt(mt.row):Zt&&!Zt.file?Pt(Zt.commit.sha):At.do==="close"?Y(!0):vn(mt.row)?Y(!1):Zt!=null&&Zt.file?Ct(mt.row):qe(mt.row)}else K.key==="Escape"&&(K.stopPropagation(),y!==null?o({a:"close-editor"}):(fe=document.activeElement)==null||fe.blur())},gt=c?c.id:p==null?void 0:p.worktree.id,Wt=c?c.path:p?p.worktree.path:"",gn=c!==null,kn=S.useCallback(K=>gt?js({id:gt,dir:Wt},K,{discard:!gn,kept:gn,ref:Ft??void 0,select:gn?void 0:B},{sock:r,dispatch:o}):[],[gt,Wt,gn,Ft,B,r,o]),tr=S.useCallback(K=>gt?js({id:gt,dir:Wt},K,{kept:gn},{sock:r,dispatch:o}):[],[gt,Wt,gn,r,o]),dn=S.useCallback(K=>gt?js({id:gt,dir:Wt},K,{kept:gn,since:D},{sock:r,dispatch:o}):[],[gt,Wt,gn,D,r,o]),fn=S.useCallback(K=>gt?js({id:gt,dir:Wt},K,{ref:wt.current??void 0,kept:gn},{sock:r,dispatch:o}):[],[gt,Wt,gn,r,o]),Nt=yn("changes"),Pr=()=>{if(ae&&Dt<Me.length){const fe=Me[Dt];return fe?(Dt<ee?kn:Dt<ie?dn:tr)(fe.path):[]}const K=qt(Dt)?St[Dt-lt]:void 0;return K?K.file?fn(K.file.path):t_(K.commit):[]},pt=(K,fe)=>{const Qe=Me.findIndex((At,mt)=>mt>=K&&At.path===fe);Qt(Qe),ze(Qe)&&C.length>0?Y(At=>!At):Ht(fe,!1,He(Qe))},In=S.useRef(pt);In.current=pt;const je=S.useCallback(K=>In.current(0,K),[]),Ve=S.useCallback(K=>In.current(ee,K),[ee]),rt=S.useCallback(K=>In.current(ie,K),[ie]),et=S.useCallback(K=>{Qt(lt+St.findIndex(fe=>!fe.file&&fe.commit.sha===K)),Pt(K)},[St,lt,Pt]),cn=S.useCallback(K=>{Qt(lt+St.findIndex(fe=>{var Qe;return((Qe=fe.file)==null?void 0:Qe.path)===K})),K===y&&b===wt.current&&C.length>0?Y(fe=>!fe):ht(K)},[St,lt,ht,y,b,C]),wn=S.useCallback(()=>{},[]);return d.jsxs("div",{className:We("changes-dock",n&&"changes-screen",!n&&(!h||m)&&"collapsed"),style:n?void 0:{width:e},children:[!c&&d.jsx(Jf,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:d.jsx(Tt,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:Ut("files",zt("files"))},{id:"changes",label:"changes",tip:Ut("changes",zt("changes"),{detail:Te})},{id:"history",label:"history"}],current:ke,onPick:ue}),ke==="files"&&u?d.jsx(_z,{worktreeId:u,dir:p?p.worktree.path:(oe==null?void 0:oe.path)??"",openPath:y,openRef:b,rootRef:ge}):d.jsxs("div",{className:We("changes-list",G&&"history"),role:"listbox","aria-label":c?"kept work":G?"commits":"changed files","aria-activedescendant":V&&Dt>=0&&Dt<jt?Cn<0?nt(Dt):`${nt(Dt)}-t${Cn}`:void 0,tabIndex:0,ref:xn,onKeyDown:at,onFocus:()=>pe(!0),onMouseDown:K=>{var At;if(K.button!==0)return;K.preventDefault();const fe=K.target.closest(Ab),Qe=fe?Array.from(K.currentTarget.querySelectorAll(Ab)).indexOf(fe):-1;Qe>=0&&Qt(Qe),(At=xn.current)==null||At.focus()},onBlur:K=>!K.currentTarget.contains(K.relatedTarget)&&pe(!1),...Nt.contextMenu(K=>K==="keyboard"?Pr():[]),children:[ae&&N.length>0&&d.jsxs(d.Fragment,{children:[($||((w==null?void 0:w.ahead)??0)>0||c)&&d.jsx("div",{className:"section-title section-row",children:"uncommitted"}),N.map((K,fe)=>d.jsxs(S.Fragment,{children:[q>0&&fe===j&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx($d,{f:K,id:nt(fe),active:Ye(fe,vn(fe)),selected:Xn(fe),checking:yt,checked:ye.includes(K.path),onOpen:je,onCheck:gn?void 0:B,menu:kn,onHover:Vt}),Ne(fe)]},`${K.xy}:${K.path}`))]}),ae&&!c&&O&&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:K=>(K.key==="Enter"||K.key===" ")&&K.stopPropagation(),children:["last turn",d.jsx(Tt,{name:"caret",className:We("icon-inline disc-caret",!z&&"shut")})]}),X.map((K,fe)=>d.jsxs(S.Fragment,{children:[re>0&&fe===ne&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx($d,{f:K,id:nt(ee+fe),active:Ye(ee+fe,vn(ee+fe)),selected:Xn(ee+fe),onOpen:Ve,menu:dn,onHover:Vt}),Ne(ee+fe)]},`t-${K.path}`))]}),ae&&!c&&$&&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 ${we}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:K=>(K.key==="Enter"||K.key===" ")&&K.stopPropagation(),children:["committed",d.jsx(Tt,{name:"caret",className:We("icon-inline disc-caret",!P&&"shut")})]}),R.map((K,fe)=>d.jsxs(S.Fragment,{children:[F>0&&fe===A&&d.jsx("div",{className:"section-title changes-sub",children:"tests"}),d.jsx($d,{f:K,id:nt(ie+fe),active:Ye(ie+fe,vn(ie+fe)),selected:Xn(ie+fe),onOpen:rt,menu:tr,onHover:Vt}),Ne(ie+fe)]},`c-${K.path}`))]}),ae&&!c&&de&&d.jsx("div",{className:"empty",children:Dz(we,!!oe&&jf(oe),(w==null?void 0:w.behind)??0,Ce==null?void 0:Ce[0])}),G&&St.map((K,fe)=>d.jsxs(S.Fragment,{children:[c&&Kt.has(fe)&&d.jsx("div",{className:"section-title section-row",children:Kt.get(fe)}),!c&&sn>0&&fe===0&&d.jsx("div",{className:"section-title section-row",children:"on this branch"}),!c&&sn>0&&fe===ln&&d.jsx("div",{className:"section-title section-row",children:we}),K.file?d.jsxs(d.Fragment,{children:[d.jsx($d,{f:K.file,id:nt(lt+fe),active:Ye(lt+fe,vn(lt+fe)),selected:Xn(lt+fe),onOpen:cn,menu:fn,onHover:wn}),Ne(lt+fe)]}):d.jsx(vz,{c:K.commit,id:nt(lt+fe),selected:Xn(lt+fe),onToggle:et})]},K.file?`${K.commit.sha}:${K.file.path}`:K.commit.sha)),G&&Ce===void 0&&d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading history"})}),G&&(Ce==null?void 0:Ce.length)===0&&N.length===0&&d.jsx("div",{className:"empty",children:"no commits yet"})]}),yt&&d.jsxs("div",{className:"changes-pick",children:[d.jsxs(Fe,{size:"md",tone:"danger",disabled:me.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!gt||me.length===0||window.confirm(TS(me))&&(r==null||r.send({t:"discard-files",worktreeId:gt,paths:me}),Yt())},children:["discard ",me.length,"…"]}),d.jsx(Fe,{size:"md",disabled:me.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{gt&&F4(i,gt,me),Yt()},children:"add to chat"}),d.jsx(Mt,{icon:"close",label:"Cancel",hint:"esc",onClick:Yt})]}),oe&&!c&&d.jsx(yz,{active:oe,ahead:(w==null?void 0:w.ahead)??oe.ahead??0,behind:(w==null?void 0:w.behind)??oe.behind??0,unpushed:(w==null?void 0:w.unpushed)??oe.unpushed??0,dirty:!Ee})]})}function zz(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 $b(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 uu(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function Fz(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 Bz(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}const b_=["five_hour","seven_day","seven_day_overage_included"],Uz={five_hour:"the 5-hour window",seven_day:"the week",seven_day_overage_included:"the Fable week"},Hz={five_hour:"5-hour",seven_day:"this week",seven_day_overage_included:"Fable week"};function x_(e,t){return b_.flatMap(n=>{const r=e.windows[n];return r&&r.resetsAt>t?[{key:n,used:r.used,resetsAt:r.resetsAt}]:[]})}function Wz(e,t){return Math.min(1,Math.max(0,...x_(e,t).map(n=>n.used)))}const Kz=e=>`${Math.round(100*e)}%`;function Rb(e,t){const n=x_(e,t).map(r=>`${Kz(r.used)} of ${Uz[r.key]}`);return n.length?n.join(", "):"plan windows reset"}function Zz(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 qz(e,t,n=r=>Zz(r,t)){return b_.flatMap(r=>{const o=e.windows[r];if(!o)return[];const i=Hz[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 Gz(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 E_(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(uu(e.cost)),t.push(wr(e.archivedAt)),t.filter(Boolean).join(" · ")}function S_({sock:e},t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function Gd(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{S_({sock:n},e.id,t.clientId),r({a:"close"})}}],i=[{id:"copy-branch",label:"copy branch name",onClick:()=>nn(e.branch)}],{sessionId:l}=e;return t.frame!=="phone"&&(i.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>nn(e.transcript)}),l&&i.push({id:"copy-session",label:"copy session id",onClick:()=>nn(l)})),zn([o,i,[{id:"delete",label:"delete…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}"?
|
|
127
|
-
|
|
128
|
-
Its chat, attachments and kept commits go with it, and it cannot be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}const Vz=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function __(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${uk(t-e)} ago`}function no({icon:e,word:t,tone:n,at:r,below:o,children:i,...l}){const c=r!==void 0?{"data-tip":`${t} ${Vz.format(r)}`,"data-tip-placement":"top"}:null;return d.jsxs("div",{...l,className:"daemon-row row-edge","data-tone":n,children:[d.jsxs("div",{className:"daemon-head",children:[d.jsxs("span",{...c,className:"daemon-tag",children:[d.jsx(Tt,{name:e,className:"icon-inline"}),t]}),i]}),o]})}function Yz({item:e}){const t=it(),n=M(u=>u.clientId),r=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",o=e.cost!==void 0?`; the session cost ${uu(e.cost)}`:"",i=e.restorable?`Toyon kept ${r}${o}. A message sent below restores it first.`:`Its commits were not kept, so there is nothing to restore${o}; its row's menu on the rail can delete it.`,l=__(e.archivedAt),c=Dk(e.lands);return d.jsxs(no,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:d.jsxs(d.Fragment,{children:[c.map((u,p)=>d.jsx("div",{className:"daemon-below row-dim",children:u},p)),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(Fe,{variant:"inline",tone:"strong",onClick:()=>S_({sock:t},e.id,n),children:"restore"})]})}function ia(e,t,n,r,o){const{layout:i}=e.getState();er({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),i.changes||e.dispatch({a:"toggle-changes"})}function Xz(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function Qz(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 Ob(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 Jz(e,t){return{from:Ob(e,t.start,!1),to:Ob(e,t.end,!0)}}function Mb(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function e3(e,t,n){return t===0?-1:(e+n+t)%t}function Hk(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function t3({label:e,query:t,onQuery:n,seed:r,seq:o,status:i,none:l,onStep:c,onClose:u}){const p=S.useRef(null);return ft([o],()=>{var h,m;r&&n(r),(h=p.current)==null||h.focus(),(m=p.current)==null||m.select()}),d.jsxs("div",{className:"find",children:[d.jsx(Io,{ref:p,autoFocus:!0,value:t,onChange:h=>n(h.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:h=>{if(h.key==="Escape"){h.preventDefault(),h.stopPropagation(),u();return}if(h.key==="Enter"){h.preventDefault(),c(h.shiftKey?-1:1);return}if(Hk(h)){h.preventDefault(),h.stopPropagation(),h.currentTarget.select();return}h.key.toLowerCase()==="g"&&(h.metaKey||h.ctrlKey)&&!h.altKey&&(h.preventDefault(),h.stopPropagation(),c(h.shiftKey?-1:1))}}),d.jsx("span",{className:"find-count","aria-live":"polite",children:i}),d.jsx(Mt,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:l,onClick:()=>c(-1)}),d.jsx(Mt,{icon:"caret",label:"Next match",hint:"↩",disabled:l,onClick:()=>c(1)}),d.jsx(Mt,{icon:"close",label:"Close",hint:"esc",onClick:u})]})}const N_="find",T_="find-current",j_=typeof CSS<"u"&&"highlights"in CSS;function n3(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function r3(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&&n3(o)&&n.push(o)}return n}const Qm={matches:[],ranges:[]};function o3(e,t){if(!t)return Qm;const n=r3(e),r=Qz(n.map(l=>l.data).join(""),t),o=Xz(n.map(l=>l.data.length)),i=r.map(l=>{const{from:c,to:u}=Jz(o,l),p=document.createRange();return p.setStart(n[c.i],c.at),p.setEnd(n[u.i],u.at),p});return{matches:r,ranges:i}}function s3(e,t){j_&&(CSS.highlights.set(N_,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(T_,new Highlight(...e[t]?[e[t]]:[])))}function i3(){j_&&(CSS.highlights.delete(N_),CSS.highlights.delete(T_))}function a3(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 Pb=48;function l3(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.top>=r.top+Pb&&n.bottom<=r.bottom-Pb||(e.scrollTop+=n.top-r.top-r.height/3)}function C_({root:e,body:t,seed:n,seq:r,onClose:o,onReveal:i}){const[l,c]=S.useState(n),[u,p]=S.useState(Qm),[h,m]=S.useState(-1),g=S.useRef({found:Qm,at:-1}),w=S.useRef(""),y=S.useRef(!1),[b,_]=S.useState(0);S.useLayoutEffect(()=>{const j=t.current;if(!j)return;let $=0;const P=new MutationObserver(()=>{$||($=requestAnimationFrame(()=>{$=0,_(R=>R+1)}))});return P.observe(j,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{P.disconnect(),$&&cancelAnimationFrame($)}},[t]),S.useLayoutEffect(()=>{const j=t.current;if(!j)return;const $=o3(j,l),P=l!==w.current;w.current=l,P&&(y.current=!0);const{found:R,at:A}=g.current;let O;P?R.matches[A]?O=Mb($.matches,R.matches[A].start):O=e.current?a3($.ranges,e.current):Mb($.matches,0):O=Math.min(A,$.matches.length-1),g.current={found:$,at:O},p($),m(O)},[l,b]),S.useLayoutEffect(()=>{s3(u.ranges,h);const j=u.ranges[h];j&&(y.current&&e.current&&(l3(e.current,j),i==null||i()),y.current=!1)},[u,h,e,i]),S.useLayoutEffect(()=>i3,[]);const T=u.matches.length,x=j=>{if(T===0)return;y.current=!0;const $=e3(g.current.at,T,j);g.current={...g.current,at:$},m($)},N=()=>o(u.ranges[h]??null);return d.jsx(t3,{label:"find in this document",query:l,onQuery:c,seed:n,seq:r,status:l?T===0?"no matches":`${h+1}/${T}`:"",none:T===0,onStep:x,onClose:N})}function A_(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function I_(e,t,n,r){S.useEffect(()=>{let o=!1;const i=c=>{o=!!e.current&&c.target instanceof Node&&e.current.contains(c.target)},l=c=>{const u=e.current;if(!u||c.defaultPrevented||!t(c))return;const p=document.activeElement;!(p&&p!==document.body?u.contains(p):o)&&!(r!=null&&r(p))||(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 c3(e){I_(e,A_,$_)}function Jm(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 $_(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}function u3(e){return e.shiftKey||e.altKey||e.metaKey||e.ctrlKey?null:e.key==="ArrowLeft"?-1:e.key==="ArrowRight"?1:null}function d3(e,t,n){const r=e+n;return r<0||r>=t?null:r}const R_=S.createContext(null),f3="input, textarea, [contenteditable]";function Lb(e){return[...e.values()].filter(t=>{var n;return(n=t.el())==null?void 0:n.isConnected}).sort((t,n)=>{const r=t.el(),o=n.el();return!r||!o||r===o?0:r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1})}function rh({children:e}){const t=S.useRef(new Map),[n,r]=S.useState(null),o=S.useRef(n);o.current=n;const i=S.useMemo(()=>{const c=u=>{const p=Lb(t.current),h=p.findIndex(m=>m.id===u);r(h<0?null:{id:u,at:h,of:p.length})};return{register(u){return t.current.set(u.id,u),()=>{var p;t.current.delete(u.id),((p=o.current)==null?void 0:p.id)===u.id&&r(null)}},open:c,step(u){const p=o.current;if(!p)return;const h=Lb(t.current),m=h.findIndex(y=>y.id===p.id),g=m<0?null:d3(m,h.length,u),w=g===null?void 0:h[g];w&&c(w.id)},close(){var h,m,g;const u=o.current;if(r(null),!u)return;const p=document.activeElement;p!=null&&p.matches(f3)||(g=(m=(h=t.current.get(u.id))==null?void 0:h.el())==null?void 0:m.querySelector(".chip-link"))==null||g.focus({preventScroll:!0})}}},[]),l=S.useMemo(()=>({api:i,shown:n}),[i,n]);return d.jsx(R_.Provider,{value:l,children:e})}function h3(e,t){const n=S.useContext(R_),r=S.useId(),[o,i]=S.useState(!1),l=n==null?void 0:n.api;if(S.useLayoutEffect(()=>{if(!(!l||!t))return l.register({id:r,el:()=>e.current})},[l,r,t,e]),!l)return{open:o,show:()=>i(!0),close:()=>i(!1),nav:void 0};const c=(n==null?void 0:n.shown)??null,u=(c==null?void 0:c.id)===r;return{open:u,show:()=>l.open(r),close:l.close,nav:u&&c?{at:c.at,of:c.of,step:l.step}:void 0}}const p3=e=>e.t==="open-path"||e.t==="open-loose",ta=new Map,m3=16;function eg({sock:e,dispatch:t},n,r){const o=O_({worktreeId:n,href:r.href});t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:o})}function g3(e,t){e==null||e.send({t:"open-by-path",path:t,seq:O_(null)})}function O_(e){const t=Vo();ta.set(t,e);for(const n of ta.keys()){if(ta.size<=m3)break;ta.delete(n)}return t}function k3(e,t){if(!ta.has(t.seq))return;const n=ta.get(t.seq);ta.delete(t.seq),n?e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}):e.dispatch({a:"server",msg:{t:"error",message:t.message}})}function w3(e,t,n){var i;const r=e.getState();if(n.t==="open-path"){const l={dispatch:u=>e.dispatch(u)};if(wo(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),er(l,{worktreeId:n.worktreeId,path:n.path});return}const c=Object.keys(r.trunks).find(u=>{var p;return((p=r.trunks[u])==null?void 0:p.id)===n.worktreeId});if(!c)return;if(((i=wo(r,r.activeId))==null?void 0:i.repoId)!==c){const u=r.rows.find(p=>p.repoId===c);if(!u)return;e.dispatch({a:"activate",id:u.id})}er(l,{worktreeId:n.worktreeId,path:n.path});return}const o=r.activeId;if(!o){e.dispatch({a:"server",msg:{t:"error",message:`open a project first; ${n.name} needs a window to open in`}});return}e.dispatch({a:"open-loose",v:{worktreeId:o,name:n.name,text:n.text,binary:n.binary,tooLarge:n.tooLarge,source:{kind:"grant",id:n.id,path:n.path,version:n.version},seq:Vo()}})}function Wk({open:e,remove:t},n){const r=n==null?void 0:n.sock,o=n&&r?()=>r.send({t:"reveal-attachment",worktreeId:n.worktreeId,file:n.file}):void 0,i=n&&r?r.urls.attachmentWhere(n.worktreeId,n.file):void 0;return[[...e?[{id:"open",label:"open full size",onClick:e}]:[],...Jo(o,Qo(r),"reveal the copy")],i?[{id:"copy-path",label:"copy path",onClick:()=>SS(i)}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]]}function Gc(e,t={},n){return zn([[{id:"copy-image",label:"copy image",onClick:()=>C4(e)}],...Wk(t,n)])}function M_({text:e,href:t}){return e!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>nn(e)}]:t?[{id:"copy-text",label:"copy text",onClick:()=>SS(t)}]:[]}function y3(e,t={}){return zn([M_(e),...Wk(t)])}function v3(e,t={},n){return zn([M_(e),...Wk(t,n)])}function b3(e){return[xS(e),{id:"copy-link",label:"copy link",onClick:()=>nn(e)}]}function P_(e,t,n){if(!t)return null;if(e.kind==="outside")return()=>eg(n,t,e);if(e.kind==="path")return()=>eg(n,t,{href:e.path,path:e.path});if(e.kind!=="file")return null;const r=e.file;return r.folder?()=>P4(n,{worktreeId:t,path:r.path}):()=>er(n,{worktreeId:t,path:r.path,...r.line?{line:{n:r.line}}:{}})}function x3(e,t,n){const r=P_(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}]:[],...Jo(i,Qo(o))],[{id:"copy-path",label:"copy path",onClick:()=>nn(l)}]]}function tg(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>nn(e)}]:[]}function Zi(e,t,n,r={}){const{dispatch:o,sock:i}=n,l=r.link,c=l?l.kind==="out"?[b3(l.href)]:x3(l,t,n):[],u=[{id:"copy",label:"copy message",onClick:()=>nn(e.text)}],p=[];return e.kind==="user"&&t&&p.push({id:"draft",label:"edit in composer",onClick:()=>{const h=e.seq;if(h===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:h})}}),zn([tg(r.code),...c,u,p])}function L_(e,t,n){return[Jo(t,n),[{id:"copy-path",label:"copy path",onClick:()=>nn(e)}]]}function Kk(e,t,n){return zn(L_(e,t,n))}function E3(e,t){const n=e.callFile??e.file,r=n?L_(n,void 0,t.host):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return zn([...r,o])}const Db=8,S3=.7,_3=100,N3=400,T3=260,j3=80,C3=220;function zb({dx:e,dy:t}){return Math.abs(e)<Db&&Math.abs(t)<Db?null:Math.abs(t)>Math.abs(e)?"away":"other"}function A3(e,t){const n=e.filter(i=>t-i.t<=_3),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 I3=e=>Math.abs(e)>=S3;function $3(e,t){return Math.min(C3,Math.max(j3,e/Math.abs(t)))}function R3(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;let i=null,l=!1,c=[],u=0;const p=(b,_,T)=>{T!==void 0&&o.style.setProperty("--swipe-ms",`${T}ms`),o.dataset.swipe!==_&&(o.dataset.swipe=_,o.offsetWidth),o.style.setProperty("--swipe-y",`${b}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(b)/(window.innerHeight/2))}`)},h=()=>{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&&(p(0,"settle"),u=window.setTimeout(h,T3))},g=b=>{var x;const _=b.touches[0],T=b.target;if(b.touches.length!==1||!_||(((x=window.visualViewport)==null?void 0:x.scale)??1)>1.01)return m();o.dataset.swipe==="leave"||!(T===o||T!=null&&T.closest(t))||(window.clearTimeout(u),i={x:_.clientX,y:_.clientY,at:b.timeStamp},c=[{y:_.clientY,t:b.timeStamp}])},w=b=>{const _=b.touches[0];if(!i||!_)return;const T=_.clientX-i.x,x=_.clientY-i.y;if(!l){const N=zb({dx:T,dy:x});if(N==="other"&&(i=null),N!=="away")return;l=!0}b.preventDefault(),c.push({y:_.clientY,t:b.timeStamp}),c.length>16&&c.shift(),p(x,"drag")},y=b=>{const _=b.changedTouches[0];if(!i||!_)return;const T=_.clientY-i.y,x=b.timeStamp-i.at;if(!l&&x<N3&&b.target!==o&&zb({dx:_.clientX-i.x,dy:T})===null){b.preventDefault(),i=null,r.current();return}const j=A3(c,b.timeStamp);if(!l||!I3(j))return m();i=null,l=!1,c=[];const $=Math.sign(j)*window.innerHeight,P=$3(Math.abs($-T),j);p($,"leave",P),u=window.setTimeout(()=>r.current(),P)};return o.addEventListener("touchstart",g,{passive:!0}),o.addEventListener("touchmove",w,{passive:!1}),o.addEventListener("touchend",y),o.addEventListener("touchcancel",m),()=>{window.clearTimeout(u),o.removeEventListener("touchstart",g),o.removeEventListener("touchmove",w),o.removeEventListener("touchend",y),o.removeEventListener("touchcancel",m)}},[e,t])}function Zk({owner:e,onClose:t,menu:n,nav:r,children:o}){const i=yn(e),l=S.useRef(null);return R3(l,"img",t),d.jsxs(Rs,{className:"attach-full scrim",boxRef:l,onDismiss:t,onKey:c=>{if(c.key==="Escape"){c.stopPropagation(),t();return}const u=r&&u3(c);u&&(c.preventDefault(),c.stopPropagation(),r.step(u))},onClick:c=>{c.target===c.currentTarget&&t()},...n&&i.contextMenu(n),children:[o,d.jsxs("div",{className:"attach-head",children:[r&&r.of>1&&d.jsxs("span",{className:"attach-count",children:[r.at+1," of ",r.of]}),d.jsx(Mt,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})]})}function O3({item:e}){if(!e.outcome)return null;const t=OP[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 qk(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 D_=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function z_(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(h=>h===".."))return null;if(l)return{path:c,folder:!0};const u=(r==null?void 0:r[1])??(o==null?void 0:o[1]),p=u?Number.parseInt(u,10):void 0;return p&&p>0?{path:c,line:p}:{path:c}}function F_(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 M3(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function Gk(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?z_(t,o):null;if(i)return{kind:"file",file:i};const l=F_(o);return l?{kind:"outside",href:o,...l}:{kind:"out",href:o}}function Vk(e,t,n,r){const o=Gk(e.target,t),i=o&&o.kind!=="path"?P_(o,n,r):null;i&&(e.preventDefault(),i())}const P3=150,L3=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function B_({chip:e,className:t,children:n}){const[r,o]=S.useState(!1),i=M(c=>c.chatSide);S.useEffect(()=>{const c=e.current;if(!c)return;let u=0;const p=()=>{window.clearTimeout(u),o(!1)},h=()=>{window.clearTimeout(u),u=window.setTimeout(()=>o(!0),P3)};return c.addEventListener("mouseenter",h),c.addEventListener("mouseleave",p),c.addEventListener("mousedown",p),()=>{window.clearTimeout(u),c.removeEventListener("mouseenter",h),c.removeEventListener("mouseleave",p),c.removeEventListener("mousedown",p)}},[e]);const l=()=>{var h;const c=e.current;if(!c)return null;const u=c.getBoundingClientRect(),p=((h=c.closest(".chat-log"))==null?void 0:h.getBoundingClientRect())??u;return{left:p.left,right:p.right,top:u.top,bottom:u.bottom}};return r?d.jsx(Rs,{className:We("chip-peek",t),anchor:l,placement:L3(i==="left"?"right":"left"),track:!0,children:n}):null}function Yk({className:e,label:t,tip:n,peek:r,full:o,menu:i,removeLabel:l,onRemove:c}){const u=S.useRef(null),p=yn("chat"),h=o!==void 0,m=h3(u,h);return d.jsxs("div",{ref:u,className:We("pick-chip row row-sm",e),"data-tip":h?"Open full size":n,"data-tip-placement":"follow",...p.contextMenu(()=>i({open:h?m.show:void 0,remove:c})),children:[h?d.jsx("button",{type:"button",className:"chip-link",onClick:m.show,children:t}):t,c&&d.jsx(Mt,{icon:"close",label:l,tone:"quiet",onClick:c}),h&&r!==void 0&&d.jsx(B_,{chip:u,children:r}),m.open&&h&&d.jsx(Zk,{owner:"chat",onClose:m.close,menu:()=>i(),nav:m.nav,children:o})]})}/*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE */function Fb(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 D3(e){if(Array.isArray(e))return e}function z3(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,p=!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(h){p=!0,o=h}finally{try{if(!u&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(p)throw o}}return c}}function F3(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
129
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function B3(e,t){return D3(e)||z3(e,t)||U3(e,t)||F3()}function U3(e,t){if(e){if(typeof e=="string")return Fb(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)?Fb(e,t):void 0}}const U_=Object.entries,Bb=Object.setPrototypeOf,H3=Object.isFrozen,W3=Object.getPrototypeOf,K3=Object.getOwnPropertyDescriptor;let cr=Object.freeze,yr=Object.seal,el=Object.create,H_=typeof Reflect<"u"&&Reflect,ng=H_.apply,rg=H_.construct;cr||(cr=function(t){return t});yr||(yr=function(t){return t});ng||(ng=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)});rg||(rg=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 Gi=or(Array.prototype.forEach),Z3=or(Array.prototype.lastIndexOf),Ub=or(Array.prototype.pop),mc=or(Array.prototype.push),q3=or(Array.prototype.splice),fl=Array.isArray,Ec=or(String.prototype.toLowerCase),Jp=or(String.prototype.toString),Hb=or(String.prototype.match),gc=or(String.prototype.replace),Wb=or(String.prototype.indexOf),G3=or(String.prototype.trim),V3=or(Number.prototype.toString),Y3=or(Boolean.prototype.toString),Kb=typeof BigInt>"u"?null:or(BigInt.prototype.toString),Zb=typeof Symbol>"u"?null:or(Symbol.prototype.toString),to=or(Object.prototype.hasOwnProperty),kc=or(Object.prototype.toString),$r=or(RegExp.prototype.test),qi=X3(TypeError);function or(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 ng(e,t,r)}}function X3(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return rg(e,n)}}function pn(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ec;if(Bb&&Bb(e,null),!fl(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(H3(t)||(t[r]=i),o=i)}e[o]=!0}return e}function Q3(e){for(let t=0;t<e.length;t++)to(e,t)||(e[t]=null);return e}function mo(e){const t=el(null);for(const r of U_(e)){var n=B3(r,2);const o=n[0],i=n[1];to(e,o)&&(fl(i)?t[o]=Q3(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=mo(i):t[o]=i)}return t}function J3(e){switch(typeof e){case"string":return e;case"number":return V3(e);case"boolean":return Y3(e);case"bigint":return Kb?Kb(e):"0";case"symbol":return Zb?Zb(e):"Symbol()";case"undefined":return kc(e);case"function":case"object":{if(e===null)return kc(e);const t=e,n=Wo(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:kc(r)}return kc(e)}default:return kc(e)}}function Wo(e,t){for(;e!==null;){const r=K3(e,t);if(r){if(r.get)return or(r.get);if(typeof r.value=="function")return or(r.value)}e=W3(e)}function n(){return null}return n}function e5(e){try{return $r(e,""),!0}catch{return!1}}const qb=cr(["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"]),em=cr(["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"]),tm=cr(["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"]),t5=cr(["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"]),nm=cr(["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"]),n5=cr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Gb=cr(["#text"]),Vb=cr(["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"]),rm=cr(["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"]),Yb=cr(["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"]),Md=cr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),r5=yr(/{{[\w\W]*|^[\w\W]*}}/g),o5=yr(/<%[\w\W]*|^[\w\W]*%>/g),s5=yr(/\${[\w\W]*/g),i5=yr(/^data-[\-\w.\u00B7-\uFFFF]+$/),a5=yr(/^aria-[\-\w]+$/),Xb=yr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),l5=yr(/^(?:\w+script|data):/i),c5=yr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),u5=yr(/^html$/i),d5=yr(/^[a-z][.\w]*(-[.\w]+)+$/i),Qb=yr(/<[/\w!]/g),Jb=yr(/<[/\w]/g),f5=yr(/<\/no(script|embed|frames)/i),h5=yr(/\/>/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},W_=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],p5=cr(pn({},W_)),m5=(function(){const e={};return Gi(W_,t=>{e[t]=yr(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),cr(e)})(),g5=function(){return typeof window>"u"?null:window},k5=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}},ex=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},si=function(t,n,r,o){return to(t,n)&&fl(t[n])?pn(o.base?mo(o.base):{},t[n],o.transform):r},om=function(t,n,r){const o=to(t,n)?t[n]:void 0;return o&&typeof o=="object"?mo(o):r()};function K_(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:g5();const t=Ie=>K_(Ie);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,p=e.NamedNodeMap;p===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,m=e.trustedTypes,g=c.prototype,w=Wo(g,"cloneNode"),y=Wo(g,"remove"),b=Wo(g,"nextSibling"),_=Wo(g,"childNodes"),T=Wo(g,"parentNode"),x=Wo(g,"shadowRoot"),N=Wo(g,"attributes"),j=l&&l.prototype?Wo(l.prototype,"nodeType"):null,$=l&&l.prototype?Wo(l.prototype,"nodeName"):null,P=l&&l.prototype?Wo(l.prototype,"ownerDocument"):null,R=function(L){return j?j(L):L.nodeType},A=function(L){return $?$(L):L.nodeName};if(typeof i=="function"){const Ie=n.createElement("template");Ie.content&&Ie.content.ownerDocument&&(n=Ie.content.ownerDocument)}let O,D="",z,X=!1,ne=0;const ee=function(){if(ne>0)throw qi('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.')},ie=function(L){ee(),ne++;try{return O.createHTML(L)}finally{ne--}},be=function(L){ee(),ne++;try{return O.createScriptURL(L)}finally{ne--}},C=function(){return X||(z=k5(m,o),X=!0),z},Z=n,Y=Z.implementation,q=Z.createNodeIterator,F=Z.createDocumentFragment,re=Z.getElementsByTagName,Ee=r.importNode;let Te=ex();t.isSupported=typeof U_=="function"&&typeof T=="function"&&Y&&Y.createHTMLDocument!==void 0;const de=r5,ke=o5,ae=s5,G=i5,ue=a5,Le=l5,ge=c5,oe=d5;let we=Xb,Ce=null;const Se=pn({},[...qb,...em,...tm,...nm,...Gb]);let _e=null;const Be=pn({},[...Vb,...rm,...Yb,...Md]);let wt=Object.seal(el(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}})),on=null,Et=null;const Vt=Object.seal(el(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ft=!0,Ht=!0,Me=!1,St=!0,sn=!1,ln=!0,lt=!1,jt=!1,Kt=null,xn=null,Dt=!1,jn=!1,Qt=!1,V=!1,pe=!0,Ye=!1;const nt="user-content-";let yt=!0,Jt=!1,ye={},Ae=null;const Yt=pn({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let B=null;const me=pn({},["audio","video","img","source","image","track"]);let De=null;const Xe=pn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Pt="http://www.w3.org/1998/Math/MathML",_t="http://www.w3.org/2000/svg",He="http://www.w3.org/1999/xhtml";let ze=He,qe=!1,ht=null;const Ct=pn({},[Pt,_t,He],Jp),Bt=cr(["mi","mo","mn","ms","mtext"]);let qt=pn({},Bt);const vn=cr(["annotation-xml"]);let On=pn({},vn);const Cn=pn({},["title","style","font","a","script"]);let Xn=null;const Kn=["application/xhtml+xml","text/html"],se="text/html";let Ne=null,at=null;const gt=n.createElement("form"),Wt=function(L){return L instanceof RegExp||L instanceof Function},gn=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(at&&at===L)return;(!L||typeof L!="object")&&(L={}),L=mo(L),Xn=Kn.indexOf(L.PARSER_MEDIA_TYPE)===-1?se:L.PARSER_MEDIA_TYPE,Ne=Xn==="application/xhtml+xml"?Jp:Ec,Ce=si(L,"ALLOWED_TAGS",Se,{transform:Ne}),_e=si(L,"ALLOWED_ATTR",Be,{transform:Ne}),ht=si(L,"ALLOWED_NAMESPACES",Ct,{transform:Jp}),De=si(L,"ADD_URI_SAFE_ATTR",Xe,{transform:Ne,base:Xe}),B=si(L,"ADD_DATA_URI_TAGS",me,{transform:Ne,base:me}),Ae=si(L,"FORBID_CONTENTS",Yt,{transform:Ne}),on=si(L,"FORBID_TAGS",mo({}),{transform:Ne}),Et=si(L,"FORBID_ATTR",mo({}),{transform:Ne}),ye=to(L,"USE_PROFILES")?L.USE_PROFILES&&typeof L.USE_PROFILES=="object"?mo(L.USE_PROFILES):L.USE_PROFILES:!1,Ft=L.ALLOW_ARIA_ATTR!==!1,Ht=L.ALLOW_DATA_ATTR!==!1,Me=L.ALLOW_UNKNOWN_PROTOCOLS||!1,St=L.ALLOW_SELF_CLOSE_IN_ATTR!==!1,sn=L.SAFE_FOR_TEMPLATES||!1,ln=L.SAFE_FOR_XML!==!1,lt=L.WHOLE_DOCUMENT||!1,jn=L.RETURN_DOM||!1,Qt=L.RETURN_DOM_FRAGMENT||!1,V=L.RETURN_TRUSTED_TYPE||!1,Dt=L.FORCE_BODY||!1,pe=L.SANITIZE_DOM!==!1,Ye=L.SANITIZE_NAMED_PROPS||!1,yt=L.KEEP_CONTENT!==!1,Jt=L.IN_PLACE||!1,we=e5(L.ALLOWED_URI_REGEXP)?L.ALLOWED_URI_REGEXP:Xb,ze=typeof L.NAMESPACE=="string"?L.NAMESPACE:He,qt=om(L,"MATHML_TEXT_INTEGRATION_POINTS",()=>pn({},Bt)),On=om(L,"HTML_INTEGRATION_POINTS",()=>pn({},vn));const H=om(L,"CUSTOM_ELEMENT_HANDLING",()=>el(null));if(wt=el(null),to(H,"tagNameCheck")&&Wt(H.tagNameCheck)&&(wt.tagNameCheck=H.tagNameCheck),to(H,"attributeNameCheck")&&Wt(H.attributeNameCheck)&&(wt.attributeNameCheck=H.attributeNameCheck),to(H,"allowCustomizedBuiltInElements")&&typeof H.allowCustomizedBuiltInElements=="boolean"&&(wt.allowCustomizedBuiltInElements=H.allowCustomizedBuiltInElements),yr(wt),sn&&(Ht=!1),Qt&&(jn=!0),ye&&(Ce=pn({},Gb),_e=el(null),ye.html===!0&&(pn(Ce,qb),pn(_e,Vb)),ye.svg===!0&&(pn(Ce,em),pn(_e,rm),pn(_e,Md)),ye.svgFilters===!0&&(pn(Ce,tm),pn(_e,rm),pn(_e,Md)),ye.mathMl===!0&&(pn(Ce,nm),pn(_e,Yb),pn(_e,Md))),Vt.tagCheck=null,Vt.attributeCheck=null,to(L,"ADD_TAGS")&&(typeof L.ADD_TAGS=="function"?Vt.tagCheck=L.ADD_TAGS:fl(L.ADD_TAGS)&&(Ce===Se&&(Ce=mo(Ce)),pn(Ce,L.ADD_TAGS,Ne))),to(L,"ADD_ATTR")&&(typeof L.ADD_ATTR=="function"?Vt.attributeCheck=L.ADD_ATTR:fl(L.ADD_ATTR)&&(_e===Be&&(_e=mo(_e)),pn(_e,L.ADD_ATTR,Ne))),to(L,"ADD_FORBID_CONTENTS")&&fl(L.ADD_FORBID_CONTENTS)&&(Ae===Yt&&(Ae=mo(Ae)),pn(Ae,L.ADD_FORBID_CONTENTS,Ne)),yt&&(Ce["#text"]=!0),lt&&pn(Ce,["html","head","body"]),Ce.table&&(pn(Ce,["tbody"]),delete on.tbody),L.TRUSTED_TYPES_POLICY){if(typeof L.TRUSTED_TYPES_POLICY.createHTML!="function")throw qi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof L.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw qi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const J=O;O=L.TRUSTED_TYPES_POLICY;try{D=ie("")}catch(ve){throw O=J,ve}}else L.TRUSTED_TYPES_POLICY===null?(O=void 0,D=""):(O===void 0&&(O=C()),O&&typeof D=="string"&&(D=ie("")));cr&&cr(L),at=L},kn=pn({},[...em,...tm,...t5]),tr=pn({},[...nm,...n5]),dn=function(L,H,J){return H.namespaceURI===He?L==="svg":H.namespaceURI===Pt?L==="svg"&&(J==="annotation-xml"||qt[J]):!!kn[L]},fn=function(L,H,J){return H.namespaceURI===He?L==="math":H.namespaceURI===_t?L==="math"&&On[J]:!!tr[L]},Nt=function(L,H,J){return H.namespaceURI===_t&&!On[J]||H.namespaceURI===Pt&&!qt[J]?!1:!tr[L]&&(Cn[L]||!kn[L])},Pr=function(L){let H=T(L);(!H||!H.tagName)&&(H={namespaceURI:ze,tagName:"template"});const J=Ec(L.tagName),ve=Ec(H.tagName);return ht[L.namespaceURI]?L.namespaceURI===_t?dn(J,H,ve):L.namespaceURI===Pt?fn(J,H,ve):L.namespaceURI===He?Nt(J,H,ve):!!(Xn==="application/xhtml+xml"&&ht[L.namespaceURI]):!1},pt=function(L){mc(t.removed,{element:L});try{T(L).removeChild(L)}catch{if(y(L),!T(L))throw qi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},In=function(L,H,J){try{L.removeAttributeNode(H)}catch{try{L.removeAttribute(J)}catch{}}},je=function(L){et(L);const H=_(L);if(H){const ve=[];Gi(H,Oe=>{mc(ve,Oe)}),Gi(ve,Oe=>{try{y(Oe)}catch{}})}const J=N(L);if(J)for(let ve=J.length-1;ve>=0;--ve){const Oe=J[ve],Ke=Oe&&Oe.name;typeof Ke=="string"&&In(L,Oe,Ke)}},Ve=function(L,H,J){if(!J)try{J=H.getAttributeNode(L)}catch{J=null}mc(t.removed,{attribute:J||null,from:H});try{J?H.removeAttributeNode(J):H.removeAttribute(L)}catch{try{H.removeAttribute(L)}catch{}}if(L==="is")if(jn||Qt)try{pt(H)}catch{}else try{H.setAttribute(L,"")}catch{}},rt=function(L){const H=N(L);if(H)for(let J=H.length-1;J>=0;--J){const ve=H[J],Oe=ve&&ve.name;typeof Oe!="string"||_e[Ne(Oe)]||In(L,ve,Oe)}},et=function(L){const H=[L];for(;H.length>0;){const J=H.pop();R(J)===po.element&&rt(J);const Oe=_(J);if(Oe)for(let Ke=Oe.length-1;Ke>=0;--Ke)H.push(Oe[Ke])}},cn=function(L,H){return ln?L==="patchsrc"?!0:L==="for"&&H!=="label"&&H!=="output":!1},wn=function(L){if(!ln)return;const H=[L];for(;H.length>0;){const J=H.pop(),ve=R(J);if(ve===po.processingInstruction||ve===po.comment&&$r(Jb,J.data)){try{y(J)}catch{}continue}if(ve===po.element){const Ke=J,It=Ne(A(J));try{Ke.hasAttribute&&Ke.hasAttribute("patchsrc")&&Ke.removeAttribute("patchsrc"),Ke.hasAttribute&&Ke.hasAttribute("for")&&cn("for",It)&&Ke.removeAttribute("for")}catch{}}const Oe=_(J);if(Oe)for(let Ke=Oe.length-1;Ke>=0;--Ke)H.push(Oe[Ke])}},sr=function(L){let H=null,J=null;if(Dt)L="<remove></remove>"+L;else{const Ke=Hb(L,/^[\r\n\t ]+/);J=Ke&&Ke[0]}Xn==="application/xhtml+xml"&&ze===He&&(L='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+L+"</body></html>");const ve=O?ie(L):L;if(ze===He)try{H=new h().parseFromString(ve,Xn)}catch{}if(!H||!H.documentElement){H=Y.createDocument(ze,"template",null);try{H.documentElement.innerHTML=qe?D:ve}catch{}}const Oe=H.body||H.documentElement;return L&&J&&Oe.insertBefore(n.createTextNode(J),Oe.childNodes[0]||null),ze===He?re.call(H,lt?"html":"body")[0]:lt?H.documentElement:Oe},Lr=function(L){const H=P?P(L):L.ownerDocument;return q.call(H||L,L,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},K=function(L){return L=gc(L,de," "),L=gc(L,ke," "),L=gc(L,ae," "),L},fe=function(L){var H;L.normalize();const J=P?P(L):L.ownerDocument,ve=q.call(J||L,L,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let Oe=ve.nextNode();for(;Oe;)Oe.data=K(Oe.data),Oe=ve.nextNode();const Ke=(H=L.querySelectorAll)===null||H===void 0?void 0:H.call(L,"template");Ke&&Gi(Ke,It=>{At(It.content)&&fe(It.content)})},Qe=function(L){const H=$?$(L):null;return typeof H!="string"||Ne(H)!=="form"?!1:typeof L.nodeName!="string"||typeof L.textContent!="string"||typeof L.removeChild!="function"||L.attributes!==N(L)||typeof L.removeAttribute!="function"||typeof L.setAttribute!="function"||typeof L.namespaceURI!="string"||typeof L.insertBefore!="function"||typeof L.hasChildNodes!="function"||L.nodeType!==j(L)||L.childNodes!==_(L)},At=function(L){if(!j||typeof L!="object"||L===null)return!1;try{return j(L)===po.documentFragment}catch{return!1}},mt=function(L){if(!j||typeof L!="object"||L===null)return!1;try{return typeof j(L)=="number"}catch{return!1}};function Zt(Ie,L,H){Ie.length!==0&&Gi(Ie,J=>{J.call(t,L,H,at)})}const Dr=function(L,H){return!!(ln&&L.hasChildNodes()&&!mt(L.firstElementChild)&&$r(Qb,L.textContent)&&$r(Qb,L.innerHTML)||ln&&L.namespaceURI===He&&p5[H]&&(mt(L.firstElementChild)||typeof L.textContent=="string"&&$r(m5[H],L.textContent))||L.nodeType===po.processingInstruction||ln&&L.nodeType===po.comment&&$r(Jb,L.data))},fr=function(L,H){if(L instanceof RegExp)return $r(L,H);if(L instanceof Function){for(var J=arguments.length,ve=new Array(J>2?J-2:0),Oe=2;Oe<J;Oe++)ve[Oe-2]=arguments[Oe];return!!L(H,...ve)}return!1},yo=function(L,H,J){if(!on[H]&&kt(H)&&fr(wt.tagNameCheck,H))return!1;if(yt&&!Ae[H]){const ve=T(L),Oe=_(L);if(Oe&&ve){const Ke=Oe.length;for(let It=Ke-1;It>=0;--It){const bn=L===J?w(Oe[It],!0):Oe[It];ve.insertBefore(bn,b(L))}}}return pt(L),!0},_r=function(L,H,J,ve){return L.length===0?H:H===J||H===ve?mo(H):H},vr=function(L,H){return L===H||T(L)!==null?!1:(Jt&&et(L),!0)},br=function(L,H){if(Zt(Te.beforeSanitizeElements,L,null),vr(L,H))return!0;if(Qe(L))return pt(L),!0;const J=Ne(A(L));if(Ce=_r(Te.uponSanitizeElement,Ce,Se,Kt),Zt(Te.uponSanitizeElement,L,{tagName:J,allowedTags:Ce}),vr(L,H))return!0;if(Dr(L,J))return pt(L),!0;if(on[J]||!(Vt.tagCheck instanceof Function&&Vt.tagCheck(J))&&!Ce[J]){const Oe=yo(L,J,H);return Oe===!1&&Zt(Te.afterSanitizeElements,L,null),Oe}if(R(L)===po.element&&!Pr(L)||(J==="noscript"||J==="noembed"||J==="noframes")&&$r(f5,L.innerHTML))return pt(L),!0;if(sn&&L.nodeType===po.text){const Oe=K(L.textContent);L.textContent!==Oe&&(mc(t.removed,{element:L.cloneNode()}),L.textContent=Oe)}return Zt(Te.afterSanitizeElements,L,null),!1},lo=function(L,H,J){if(Et[H]||cn(H,L)||pe&&(H==="id"||H==="name")&&(J in n||J in gt))return!1;const ve=_e[H]||Vt.attributeCheck instanceof Function&&Vt.attributeCheck(H,L);return Ht&&$r(G,H)||Ft&&$r(ue,H)?!0:ve?De[H]||$r(we,gc(J,ge,""))||(H==="src"||H==="xlink:href"||H==="href")&&L!=="script"&&Wb(J,"data:")===0&&B[L]||Me&&!$r(Le,gc(J,ge,""))?!0:!J:kt(L)&&fr(wt.tagNameCheck,L)&&fr(wt.attributeNameCheck,H,L)||H==="is"&&wt.allowCustomizedBuiltInElements&&fr(wt.tagNameCheck,J)},Xt=pn({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),kt=function(L){return!Xt[Ec(L)]&&$r(oe,L)},ts=function(L,H,J,ve){if(O&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!J)switch(m.getAttributeType(L,H)){case"TrustedHTML":return ie(ve);case"TrustedScriptURL":return be(ve)}return ve},Mn=function(L,H,J,ve){try{J?L.setAttributeNS(J,H,ve):L.setAttribute(H,ve),Qe(L)?pt(L):Ub(t.removed)}catch{Ve(H,L)}},en=function(L){Zt(Te.beforeSanitizeAttributes,L,null);const H=L.attributes;if(!H||Qe(L))return;_e=_r(Te.uponSanitizeAttribute,_e,Be,xn);const J={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:_e,forceKeepAttr:void 0};let ve=H.length;const Oe=Ne(L.nodeName);for(;ve--;){const Ke=H[ve],It=Ke.name,bn=Ke.namespaceURI,Nn=Ke.value,Fn=Ne(It),ns=Nn;let $n=It==="value"?ns:G3(ns);if(J.attrName=Fn,J.attrValue=$n,J.keepAttr=!0,J.forceKeepAttr=void 0,Zt(Te.uponSanitizeAttribute,L,J),$n=J.attrValue,Ye&&(Fn==="id"||Fn==="name")&&Wb($n,nt)!==0&&(Ve(It,L,Ke),$n=nt+$n),ln&&$r(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,$n)){Ve(It,L,Ke);continue}if(Fn==="attributename"&&Hb($n,"href")){Ve(It,L,Ke);continue}if(!J.forceKeepAttr){if(!J.keepAttr){Ve(It,L,Ke);continue}if(!St&&$r(h5,$n)){Ve(It,L,Ke);continue}if(sn&&($n=K($n)),!lo(Oe,Fn,$n)){Ve(It,L,Ke);continue}$n=ts(Oe,Fn,bn,$n),$n!==ns&&Mn(L,It,bn,$n)}}Zt(Te.afterSanitizeAttributes,L,null)},Zr=function(L){let H=null;const J=Lr(L);for(Zt(Te.beforeSanitizeShadowDOM,L,null);H=J.nextNode();)if(Zt(Te.uponSanitizeShadowNode,H,null),br(H,L),en(H),At(H.content)&&Zr(H.content),R(H)===po.element){const ve=x(H);At(ve)&&(hr(ve),Zr(ve))}Zt(Te.afterSanitizeShadowDOM,L,null)},hr=function(L){const H=[{node:L,shadow:null}];for(;H.length>0;){const J=H.pop();if(J.shadow){Zr(J.shadow);continue}const ve=J.node,Ke=R(ve)===po.element,It=_(ve);if(It)for(let bn=It.length-1;bn>=0;--bn)H.push({node:It[bn],shadow:null});if(Ke){const bn=$?$(ve):null;if(typeof bn=="string"&&Ne(bn)==="template"){const Nn=ve.content;At(Nn)&&H.push({node:Nn,shadow:null})}}if(Ke){const bn=x(ve);At(bn)&&H.push({node:null,shadow:bn},{node:bn,shadow:null})}}};return t.sanitize=function(Ie){let L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},H=null,J=null,ve=null,Oe=null;if(qe=!Ie,qe&&(Ie="<!-->"),typeof Ie!="string"&&!mt(Ie)&&(Ie=J3(Ie),typeof Ie!="string"))throw qi("dirty is not a string, aborting");if(!t.isSupported)return Ie;jt?(Ce=Kt,_e=xn):gn(L),(Te.uponSanitizeElement.length>0||Te.uponSanitizeAttribute.length>0)&&(Ce=mo(Ce)),Te.uponSanitizeAttribute.length>0&&(_e=mo(_e)),t.removed=[];const Ke=Jt&&typeof Ie!="string"&&mt(Ie);if(Ke){wn(Ie);const Nn=A(Ie);if(typeof Nn=="string"){const Fn=Ne(Nn);if(!Ce[Fn]||on[Fn])throw je(Ie),qi("root node is forbidden and cannot be sanitized in-place")}if(Qe(Ie))throw je(Ie),qi("root node is clobbered and cannot be sanitized in-place");try{hr(Ie)}catch(Fn){throw je(Ie),Fn}}else if(mt(Ie))H=sr("<!---->"),J=H.ownerDocument.importNode(Ie,!0),J.nodeType===po.element&&J.nodeName==="BODY"||J.nodeName==="HTML"?H=J:H.appendChild(J),hr(J);else{if(!jn&&!sn&&!lt&&Ie.indexOf("<")===-1)return O&&V?ie(Ie):Ie;if(H=sr(Ie),!H)return jn?null:V?D:""}H&&Dt&&pt(H.firstChild);const It=Ke?Ie:H;try{const Nn=Lr(It);for(;ve=Nn.nextNode();)br(ve,It),en(ve),At(ve.content)&&Zr(ve.content)}catch(Nn){throw Ke&&(je(Ie),Gi(t.removed,Fn=>{Fn.element&&et(Fn.element)})),Nn}if(Ke)return Gi(t.removed,Nn=>{Nn.element&&et(Nn.element)}),sn&&fe(Ie),Ie;if(jn){if(sn&&fe(H),Qt)for(Oe=F.call(H.ownerDocument);H.firstChild;)Oe.appendChild(H.firstChild);else Oe=H;return(_e.shadowroot||_e.shadowrootmode)&&(Oe=Ee.call(r,Oe,!0)),Oe}let bn=lt?H.outerHTML:H.innerHTML;return lt&&Ce["!doctype"]&&H.ownerDocument&&H.ownerDocument.doctype&&H.ownerDocument.doctype.name&&$r(u5,H.ownerDocument.doctype.name)&&(bn="<!DOCTYPE "+H.ownerDocument.doctype.name+`>
|
|
130
|
-
`+bn),sn&&(bn=K(bn)),O&&V?ie(bn):bn},t.setConfig=function(){let Ie=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};gn(Ie),jt=!0,Kt=Ce,xn=_e},t.clearConfig=function(){at=null,jt=!1,Kt=null,xn=null,O=z,D=""},t.isValidAttribute=function(Ie,L,H){at||gn({});const J=Ne(Ie),ve=Ne(L);return lo(J,ve,H)},t.addHook=function(Ie,L){typeof L=="function"&&to(Te,Ie)&&mc(Te[Ie],L)},t.removeHook=function(Ie,L){if(to(Te,Ie)){if(L!==void 0){const H=Z3(Te[Ie],L);return H===-1?void 0:q3(Te[Ie],H,1)[0]}return Ub(Te[Ie])}},t.removeHooks=function(Ie){to(Te,Ie)&&(Te[Ie]=[])},t.removeAllHooks=function(){Te=ex()},t}var w5=K_();function Xk(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pa=Xk();function Z_(e){pa=e}var Yi={exec:()=>null};function Ya(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 rn(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(Or.caret,"$1"),n=n.replace(o,l),r},getRegex:()=>new RegExp(n,t)};return r}var y5=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Or={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:Ya(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Ya(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Ya(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Ya(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Ya(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Ya(e=>new RegExp(`^ {0,${e}}>`))},v5=/^(?:[ \t]*(?:\n|$))+/,b5=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,x5=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,du=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,E5=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Qk=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,q_=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,G_=rn(q_).replace(/bull/g,Qk).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(),S5=rn(q_).replace(/bull/g,Qk).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(),Jk=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,_5=/^[^\n]+/,ew=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,N5=rn(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ew).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),T5=rn(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Qk).getRegex(),oh="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",tw=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,j5=rn("^ {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",tw).replace("tag",oh).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),V_=e=>rn(Jk).replace("hr",du).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",oh).getRegex(),C5=V_(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),A5=V_(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),I5=rn(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",A5).getRegex(),nw={blockquote:I5,code:b5,def:N5,fences:x5,heading:E5,hr:du,html:j5,lheading:G_,list:T5,newline:v5,paragraph:C5,table:Yi,text:_5},tx=rn("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",du).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",oh).getRegex(),$5={...nw,lheading:S5,table:tx,paragraph:rn(Jk).replace("hr",du).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",tx).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",oh).getRegex()},R5={...nw,html:rn(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",tw).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:Yi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rn(Jk).replace("hr",du).replace("heading",` *#{1,6} *[^
|
|
131
|
-
]`).replace("lheading",G_).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},O5=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,M5=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Y_=/^( {2,}|\\)\n(?!\s*$)/,P5=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Os=/[\p{P}\p{S}]/u,Al=/[\s\p{P}\p{S}]/u,fu=/[^\s\p{P}\p{S}]/u,L5=rn(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Al).getRegex(),D5=/[\p{Pi}\p{Ps}"']/u,X_=/(?!~)[\p{P}\p{S}]/u,z5=/(?!~)[\s\p{P}\p{S}]/u,F5=/(?:[^\s\p{P}\p{S}]|~)/u,B5=rn(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",y5?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Q_=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,U5=rn(Q_,"u").replace(/punct/g,Os).getRegex(),H5=rn(Q_,"u").replace(/punct/g,X_).getRegex(),W5=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,K5=rn(W5,"u").replace(/openQuote/g,D5).replace(/punct/g,Os).getRegex(),J_="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Z5=rn(J_,"gu").replace(/notPunctSpace/g,fu).replace(/punctSpace/g,Al).replace(/punct/g,Os).getRegex(),q5=rn(J_,"gu").replace(/notPunctSpace/g,F5).replace(/punctSpace/g,z5).replace(/punct/g,X_).getRegex(),G5="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",V5=rn(G5,"gu").replace(/notPunctSpace/g,fu).replace(/punctSpace/g,Al).replace(/punct/g,Os).getRegex(),Y5=rn("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,fu).replace(/punctSpace/g,Al).replace(/punct/g,Os).getRegex(),X5="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Q5=rn(X5,"gu").replace(/notPunctSpace/g,fu).replace(/punctSpace/g,Al).replace(/punct/g,Os).getRegex(),J5=rn(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Os).getRegex(),e6="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",t6=rn(e6,"gu").replace(/notPunctSpace/g,fu).replace(/punctSpace/g,Al).replace(/punct/g,Os).getRegex(),n6=rn(/\\(punct)/,"gu").replace(/punct/g,Os).getRegex(),r6=rn(/^<(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(),o6=rn(tw).replace("(?:-->|$)","-->").getRegex(),s6=rn("^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",o6).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),pf=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,i6=rn(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",pf).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),eN=rn(/^!?\[(label)\]\[(ref)\]/).replace("label",pf).replace("ref",ew).getRegex(),tN=rn(/^!?\[(ref)\](?:\[\])?/).replace("ref",ew).getRegex(),a6=rn("reflink|nolink(?!\\()","g").replace("reflink",eN).replace("nolink",tN).getRegex(),nx=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,rw={_backpedal:Yi,anyPunctuation:n6,autolink:r6,blockSkip:B5,br:Y_,code:M5,del:Yi,delLDelim:Yi,delRDelim:Yi,emStrongLDelim:U5,emStrongRDelimAst:Z5,emStrongRDelimUnd:Y5,escape:O5,link:i6,nolink:tN,punctuation:L5,reflink:eN,reflinkSearch:a6,tag:s6,text:P5,url:Yi},l6={...rw,emStrongLDelim:K5,emStrongRDelimAst:V5,emStrongRDelimUnd:Q5,link:rn(/^!?\[(label)\]\((.*?)\)/).replace("label",pf).getRegex(),reflink:rn(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pf).getRegex()},og={...rw,emStrongRDelimAst:q5,emStrongLDelim:H5,delLDelim:J5,delRDelim:t6,url:rn(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",nx).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:rn(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",nx).getRegex()},c6={...og,br:rn(Y_).replace("{2,}","*").getRegex(),text:rn(og.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Pd={normal:nw,gfm:$5,pedantic:R5},wc={normal:rw,gfm:og,breaks:c6,pedantic:l6},u6={"&":"&","<":"<",">":">",'"':""","'":"'"},rx=e=>u6[e];function ls(e,t){if(t){if(Or.escapeTest.test(e))return e.replace(Or.escapeReplace,rx)}else if(Or.escapeTestNoEncode.test(e))return e.replace(Or.escapeReplaceNoEncode,rx);return e}function ox(e){try{e=encodeURI(e).replace(Or.percentDecode,"%")}catch{return null}return e}function sx(e,t){var i;let n=e.replace(Or.findPipe,(l,c,u)=>{let p=!1,h=c;for(;--h>=0&&u[h]==="\\";)p=!p;return p?"|":" |"}),r=n.split(Or.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(Or.slashPipe,"|");return r}function ii(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 ix(e){let t=e.split(`
|
|
132
|
-
`),n=t.length-1;for(;n>=0&&Or.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
133
|
-
`)}function d6(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 f6(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 ax(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 p=r.state.linkEmitted,h=r.state.inRawBlock;r.state.linkEmitted=!1;let m=r.inlineTokens(c),g=r.state.linkEmitted;if(r.state.linkEmitted=p,r.state.inLink=!1,!u){if(g){r.state.inRawBlock=h;return}r.state.linkEmitted=!0}return{type:u?"image":"link",raw:n,href:i,title:l,text:c,tokens:m}}function h6(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
|
|
134
|
-
`).map(i=>{let l=i.match(n.other.beginningSpace);if(l===null)return i;let[c]=l;return c.length>=o.length?i.slice(o.length):i}).join(`
|
|
135
|
-
`)}var mf=class{constructor(e){$t(this,"options");$t(this,"rules");$t(this,"lexer");this.options=e||pa}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]:ix(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=h6(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=ii(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:ii(t[0],`
|
|
136
|
-
`),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ii(t[0],`
|
|
137
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=ii(t[0],`
|
|
138
|
-
`).split(`
|
|
139
|
-
`),r="",o="",i=[];for(;n.length>0;){let l=!1,c=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))c.push(n[u]),l=!0;else if(!l)c.push(n[u]);else break;n=n.slice(u);let p=c.join(`
|
|
140
|
-
`),h=p.replace(this.rules.other.blockquoteSetextReplace,`
|
|
141
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
142
|
-
${p}`:p,o=o?`${o}
|
|
143
|
-
${h}`:h;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=m,n.length===0)break;let g=i.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let w=g,y=n.join(`
|
|
144
|
-
`),b=w.raw+`
|
|
145
|
-
`+y.replace(this.rules.other.blockquoteSetextReplace2,""),_=this.blockquote(b);i[i.length-1]=_,r=`${r}
|
|
146
|
-
${y}`,o=o.substring(0,o.length-w.text.length)+_.text;break}else if((g==null?void 0:g.type)==="list"){let w=g,y=w.raw+`
|
|
147
|
-
`+n.join(`
|
|
148
|
-
`),b=this.list(y);i[i.length-1]=b,r=r.substring(0,r.length-g.raw.length)+b.raw,o=o.substring(0,o.length-w.raw.length)+b.raw,n=y.substring(i.at(-1).raw.length).split(`
|
|
149
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let i=this.rules.other.listItemRegex(n),l=!1;for(;e;){let u=!1,p="",h="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let m=f6(t[2].split(`
|
|
150
|
-
`,1)[0],t[1].length),g=e.split(`
|
|
151
|
-
`,1)[0],w=!m.trim(),y=0;if(this.options.pedantic?(y=2,h=m.trimStart()):w?y=t[1].length+1:(y=m.search(this.rules.other.nonSpaceChar),y=y>4?1:y,h=m.slice(y),y+=t[1].length),w&&this.rules.other.blankLine.test(g)&&(p+=g+`
|
|
152
|
-
`,e=e.substring(g.length+1),u=!0),!u){let b=this.rules.other.nextBulletRegex(y),_=this.rules.other.hrRegex(y),T=this.rules.other.fencesBeginRegex(y),x=this.rules.other.headingBeginRegex(y),N=this.rules.other.htmlBeginRegex(y),j=this.rules.other.blockquoteBeginRegex(y);for(;e;){let $=e.split(`
|
|
153
|
-
`,1)[0],P;if(g=$,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),P=g):P=g.replace(this.rules.other.tabCharGlobal," "),T.test(g)||x.test(g)||N.test(g)||j.test(g)||b.test(g)||_.test(g))break;if(P.search(this.rules.other.nonSpaceChar)>=y||!g.trim())h+=`
|
|
154
|
-
`+P.slice(y);else{if(w||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||T.test(m)||x.test(m)||_.test(m))break;h+=`
|
|
155
|
-
`+g}w=!g.trim(),p+=$+`
|
|
156
|
-
`,e=e.substring($.length+1),m=P.slice(y)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(l=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),o.raw+=p}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 p=u.tokens.filter(m=>m.type==="space"),h=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.raw));o.loose=h}for(let u of o.items){let p=u.tokens[0];if(u.task&&((p==null?void 0:p.type)==="text"||(p==null?void 0:p.type)==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),p.raw=p.raw.replace(this.rules.other.listReplaceTask,""),p.text=p.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 h=this.rules.other.listTaskCheckbox.exec(u.raw);if(h){let m={type:"checkbox",raw:h[0]+" ",checked:h[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 p of u.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=ix(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:ii(t[0],`
|
|
157
|
-
`),href:r,title:o}}}table(e){var l;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=sx(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=(l=t[3])!=null&&l.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
158
|
-
`):[],i={type:"table",raw:ii(t[0],`
|
|
159
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let c of r)this.rules.other.tableAlignRight.test(c)?i.align.push("right"):this.rules.other.tableAlignCenter.test(c)?i.align.push("center"):this.rules.other.tableAlignLeft.test(c)?i.align.push("left"):i.align.push(null);for(let c=0;c<n.length;c++)i.header.push({text:n[c],tokens:this.lexer.inline(n[c]),header:!0,align:i.align[c]});for(let c of o)i.rows.push(sx(c,i.header.length).map((u,p)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:i.align[p]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:ii(t[0],`
|
|
160
|
-
`),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
161
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=ii(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=d6(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)),ax(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 ax(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,p=r[0][0],h=n===p,m=p==="*"?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(h)break}if(c-=l,c>0)continue;l=Math.min(l,l+c+u);let g=[...r[0]][0].length,w=e.slice(0,o+r.index+g+l);if(Math.min(o,l)%2){let b=w.slice(1,-1);return{type:"em",raw:w,text:b,tokens:this.lexer.inlineTokens(b)}}let y=w.slice(2,-2);return{type:"strong",raw:w,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,i,l,c=o,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(r=u.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(l=[...i].length,l!==o))continue;if(r[3]||r[4]){c+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c);let p=[...r[0]][0].length,h=e.slice(0,o+r.index+p+l),m=h.slice(o,-o);return{type:"del",raw:h,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}}}},qo=class sg{constructor(t){$t(this,"tokens");$t(this,"options");$t(this,"state");$t(this,"inlineQueue");$t(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||pa,this.options.tokenizer=this.options.tokenizer||new mf,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:Or,block:Pd.normal,inline:wc.normal};this.options.pedantic?(n.block=Pd.pedantic,n.inline=wc.pedantic):this.options.gfm&&(n.block=Pd.gfm,this.options.breaks?n.inline=wc.breaks:n.inline=wc.gfm),this.tokenizer.rules=n}static get rules(){return{block:Pd,inline:wc}}static lex(t,n){return new sg(n).lex(t)}static lexInline(t,n){return new sg(n).inlineTokens(t)}lex(t){t=t.replace(Or.carriageReturn,`
|
|
162
|
-
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var i,l,c;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Or.tabCharGlobal," ").replace(Or.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(h=>(u=h.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 h=n.at(-1);u.raw.length===1&&h!==void 0?h.raw+=`
|
|
163
|
-
`:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
|
|
164
|
-
`)?"":`
|
|
165
|
-
`)+u.raw,h.text+=`
|
|
166
|
-
`+u.text,this.inlineQueue.at(-1).src=h.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 h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
|
|
167
|
-
`)?"":`
|
|
168
|
-
`)+u.raw,h.text+=`
|
|
169
|
-
`+u.raw,this.inlineQueue.at(-1).src=h.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 p=t;if((c=this.options.extensions)!=null&&c.startBlock){let h=1/0,m=t.slice(1),g;this.options.extensions.startBlock.forEach(w=>{g=w.call({lexer:this},m),typeof g=="number"&&g>=0&&(h=Math.min(h,g))}),h<1/0&&h>=0&&(p=t.substring(0,h+1))}if(this.state.top&&(u=this.tokenizer.paragraph(p))){let h=n.at(-1);r&&(h==null?void 0:h.type)==="paragraph"?(h.raw+=(h.raw.endsWith(`
|
|
170
|
-
`)?"":`
|
|
171
|
-
`)+u.raw,h.text+=`
|
|
172
|
-
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(u),r=p.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
|
|
173
|
-
`)?"":`
|
|
174
|
-
`)+u.raw,h.text+=`
|
|
175
|
-
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.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,p,h,m;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let g=this.tokenizer.rules.inline.reflinkSearch,w=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 _=y.slice(1,b-1);if(this.linkInText(_))return"["+_.replace(g,w)+"]["+"a".repeat(y.length-b-2)+"]"}return"["+"a".repeat(y.length-2)+"]"};r=r.replace(g,w)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,g=>"+".repeat(g.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(g,w,y)=>{let b=y?y.length:0;return g.slice(0,b)+"["+"a".repeat(g.length-b-2)+"]"}),r=((u=(c=this.options.hooks)==null?void 0:c.emStrongMask)==null?void 0:u.call({lexer:this},r))??r;let o=!1,i="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(i=""),o=!1;let g;if((h=(p=this.options.extensions)==null?void 0:p.inline)!=null&&h.some(y=>(g=y.call({lexer:this},t,n))?(t=t.substring(g.raw.length),n.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let y=n.at(-1);g.type==="text"&&(y==null?void 0:y.type)==="text"?(y.raw+=g.raw,y.text+=g.text):n.push(g);continue}if(g=this.tokenizer.emStrong(t,r,i)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.del(t,r,i)){t=t.substring(g.raw.length),n.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),n.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),n.push(g);continue}let w=t;if((m=this.options.extensions)!=null&&m.startInline){let y=1/0,b=t.slice(1),_;this.options.extensions.startInline.forEach(T=>{_=T.call({lexer:this},b),typeof _=="number"&&_>=0&&(y=Math.min(y,_))}),y<1/0&&y>=0&&(w=t.substring(0,y+1))}if(g=this.tokenizer.inlineText(w)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(i=g.raw.slice(-1)),o=!0;let y=n.at(-1);(y==null?void 0:y.type)==="text"?(y.raw+=g.raw,y.text+=g.text):n.push(g);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Vc=class{constructor(e){$t(this,"options");$t(this,"parser");this.options=e||pa}space(e){return""}code({text:e,lang:t,escaped:n}){var i;let r=(i=(t||"").match(Or.notSpaceStart))==null?void 0:i[0],o=e.replace(Or.endingNewline,"")+`
|
|
176
|
-
`;return r?'<pre><code class="language-'+ls(r)+'">'+(n?o:ls(o,!0))+`</code></pre>
|
|
177
|
-
`:"<pre><code>"+(n?o:ls(o,!0))+`</code></pre>
|
|
178
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
179
|
-
${this.parser.parse(e)}</blockquote>
|
|
180
|
-
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
181
|
-
`}hr(e){return`<hr>
|
|
182
|
-
`}list(e){let t=e.ordered,n=e.start,r="";for(let l=0;l<e.items.length;l++){let c=e.items[l];r+=this.listitem(c)}let o=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+o+i+`>
|
|
183
|
-
`+r+"</"+o+`>
|
|
184
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
185
|
-
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
186
|
-
`}table(e){let t="",n="";for(let o=0;o<e.header.length;o++)n+=this.tablecell(e.header[o]);t+=this.tablerow({text:n});let r="";for(let o=0;o<e.rows.length;o++){let i=e.rows[o];n="";for(let l=0;l<i.length;l++)n+=this.tablecell(i[l]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
187
|
-
<thead>
|
|
188
|
-
`+t+`</thead>
|
|
189
|
-
`+r+`</table>
|
|
190
|
-
`}tablerow({text:e}){return`<tr>
|
|
191
|
-
${e}</tr>
|
|
192
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
193
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ls(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=ox(e);if(o===null)return r;e=o;let i='<a href="'+e+'"';return t&&(i+=' title="'+ls(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=ox(e);if(o===null)return ls(n);e=o;let i=`<img src="${e}" alt="${ls(n)}"`;return t&&(i+=` title="${ls(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ls(e.text)}},ow=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}},Go=class ig{constructor(t){$t(this,"options");$t(this,"renderer");$t(this,"textRenderer");this.options=t||pa,this.options.renderer=this.options.renderer||new Vc,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ow}static parse(t,n){return new ig(n).parse(t)}static parseInline(t,n){return new ig(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,p=this.options.extensions.renderers[u.type].call({parser:this},u);if(p!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(u.type)){n+=p||"";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 p=this.options.extensions.renderers[c.type].call({parser:this},c);if(p!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(c.type)){r+=p||"";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 p='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return r}},Fd,Sc=(Fd=class{constructor(e){$t(this,"options");$t(this,"block");this.options=e||pa}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?qo.lex:qo.lexInline}provideParser(e=this.block){return e?Go.parse:Go.parseInline}},$t(Fd,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),$t(Fd,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Fd),p6=class{constructor(...e){$t(this,"defaults",Xk());$t(this,"options",this.setOptions);$t(this,"parse",this.parseMarkdown(!0));$t(this,"parseInline",this.parseMarkdown(!1));$t(this,"Parser",Go);$t(this,"Renderer",Vc);$t(this,"TextRenderer",ow);$t(this,"Lexer",qo);$t(this,"Tokenizer",mf);$t(this,"Hooks",Sc);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 Vc(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]=(...p)=>{let h=c.apply(o,p);return h===!1&&(h=u.apply(o,p)),h||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new mf(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]=(...p)=>{let h=c.apply(o,p);return h===!1&&(h=u.apply(o,p)),h}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new Sc;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];Sc.passThroughHooks.has(i)?o[l]=p=>{if(this.defaults.async&&Sc.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await c.call(o,p);return u.call(o,m)})();let h=c.call(o,p);return u.call(o,h)}:o[l]=(...p)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(o,p);return m===!1&&(m=await u.apply(o,p)),m})();let h=c.apply(o,p);return h===!1&&(h=u.apply(o,p)),h}}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 qo.lex(e,t??this.defaults)}parser(e,t){return Go.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?qo.lex:qo.lexInline)(l,o),u=o.hooks?await o.hooks.processAllTokens(c):c;o.walkTokens&&await Promise.all(this.walkTokens(u,o.walkTokens));let p=await(o.hooks?await o.hooks.provideParser(e):e?Go.parse:Go.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(p):p})().catch(i);try{o.hooks&&(t=o.hooks.preprocess(t));let l=(o.hooks?o.hooks.provideLexer(e):e?qo.lex:qo.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?Go.parse:Go.parseInline)(l,o);return o.hooks&&(c=o.hooks.postprocess(c)),c}catch(l){return i(l)}}}onError(e,t){return n=>{if(n.message+=`
|
|
194
|
-
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+ls(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},ua=new p6;function En(e,t){return ua.parse(e,t)}En.options=En.setOptions=function(e){return ua.setOptions(e),En.defaults=ua.defaults,Z_(En.defaults),En};En.getDefaults=Xk;En.defaults=pa;function m6(...e){return ua.use(...e),En.defaults=ua.defaults,Z_(En.defaults),En}En.use=m6;En.walkTokens=function(e,t){return ua.walkTokens(e,t)};En.parseInline=ua.parseInline;En.Parser=Go;En.parser=Go.parse;En.Renderer=Vc;En.TextRenderer=ow;En.Lexer=qo;En.lexer=qo.lex;En.Tokenizer=mf;En.Hooks=Sc;En.parse=En;En.options;En.setOptions;En.walkTokens;En.parseInline;Go.parse;qo.lex;const da=100,g6=e=>e.type==="text-delta"||e.type==="thinking-delta"||e.type==="tool-delta";function k6(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 w6={now:()=>performance.now(),after:(e,t)=>void setTimeout(t,e)};function y6(e,t=w6){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"&&g6(l.event)){const c={...l,event:{...l.event}},u=t.now();if(n.length===0&&u-o>=da){o=u,e(c);return}const p=n[n.length-1];p&&k6(p,c)?p.event={...p.event,text:p.event.text+c.event.text}:n.push(c),r||(r=!0,t.after(Math.max(0,o+da-u),i));return}i(),e(l)}}const nN="#toyon-link-pending",v6=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function b6(e){const t=e.lastIndexOf(`
|
|
195
|
-
`)+1,n=e.slice(t),r=v6.exec(n);return!r||x6(e.slice(0,t))||E6(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${nN})`}function x6(e){let t=!1;for(const n of e.split(`
|
|
196
|
-
`))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function E6(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const sm="__[a-z][a-z0-9_]*[a-z0-9]__",S6=new RegExp(`^(?:${sm}\\.)+${sm}|^${sm}(?=\\.\\w|\\(|["'])`),_6={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=S6.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text},ag=e=>e.replace(/[&<>]/g,t=>t==="&"?"&":t==="<"?"<":">");function N6({text:e}){return ag(e)}function T6(e){return`<div class="md-table">${j6.call(this,e)}</div>
|
|
197
|
-
`}function j6(e){if(e.header.some(n=>n.text.trim()))return Vc.prototype.table.call(this,e);let t="";for(const n of e.rows){let r="";for(const o of n)r+=this.tablecell(o);t+=this.tablerow({text:r})}return`<table>
|
|
198
|
-
<tbody>${t}</tbody></table>
|
|
199
|
-
`}const C6=4*da;function A6(e,t,n){if(!e)return{from:t,to:t,at:n,span:da};const r=Math.min(rN(e,n),t),o=Math.min(Math.max(n-e.at,da),C6);return{from:r,to:t,at:n,span:o}}function rN(e,t){const n=t-e.at;return n>=e.span?e.to:e.from+Math.floor((e.to-e.from)*Math.max(0,n)/e.span)}function I6(e,t){if(t>=e.length)return e;const n=e.charCodeAt(t);return e.slice(0,n>=56320&&n<=57343?t+1:t)}function $6(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:/\\"/},p={className:"string",begin:/'/,end:/'/},h={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],w=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),y={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},b=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],_=["true","false"],T={match:/(\/[a-z._-]+)+/},x=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],N=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],j=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],$=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:b,literal:_,built_in:[...x,...N,"set","shopt",...j,...$]},contains:[w,e.SHEBANG(),y,m,i,l,T,c,u,p,h,n]}}const R6=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_-]*/}}),O6=["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"],M6=["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"],P6=[...O6,...M6],L6=["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(),D6=["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(),z6=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),F6=["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 B6(e){const t=e.regex,n=R6(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:":("+D6.join("|")+")"},{begin:":(:)?("+z6.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+F6.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:L6.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+P6.join("|")+")\\b"}]}}function U6(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 H6(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_-]+/,p=/"(\\"|[^"])*"/,h=/'[^']*'/,m=t.either(u,p,h),g=t.concat(m,"(\\s*\\.\\s*",m,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:g,className:"attr",starts:{end:/$/,contains:[r,c,i,o,l,n]}}]}}const lx="[A-Za-z$_][0-9A-Za-z$_]*",W6=["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"],K6=["true","false","null","undefined","NaN","Infinity"],oN=["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"],sN=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],iN=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Z6=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],q6=[].concat(iN,oN,sN);function G6(e){const t=e.regex,n=(Z,{after:Y})=>{const q="</"+Z[0].slice(1);return Z.input.indexOf(q,Y)!==-1},r=lx,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Z,Y)=>{const q=Z[0].length+Z.index,F=Z.input[q];if(F==="<"||F===","){Y.ignoreMatch();return}F===">"&&(n(Z,{after:q})||Y.ignoreMatch());let re;const Ee=Z.input.substring(q);if(re=Ee.match(/^\s*=/)){Y.ignoreMatch();return}if((re=Ee.match(/^\s+extends\s+/))&&re.index===0){Y.ignoreMatch();return}}},c={$pattern:lx,keyword:W6,literal:K6,built_in:q6,"variable.language":Z6},u="[0-9](_?[0-9])*",p=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${p})|\\.)?|(${p}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\b((${p})\\b|\\.)?|(${p})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},x={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,b,_,{match:/\$\d+/},m];g.contains=N.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(N)});const j=[].concat(x,g.contains),$=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$},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"}}]},A={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:{_:[...oN,...sN]}},O={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 X(Z){return t.concat("(?!",Z.join("|"),")")}const ne={match:t.concat(/\b/,X([...iN,"super","import","await"].map(Z=>`${Z}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ee={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ie={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},be="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",C={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(be)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:A},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),O,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,b,_,x,{match:/\$\d+/},m,A,{scope:"attr",match:r+t.lookahead(":"),relevance:0},C,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[x,e.REGEXP_MODE,{className:"function",begin:be,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},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},ee,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},ne,z,R,ie,{match:/\$[(.]/}]}}const V6="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",Y6={scope:"number",match:V6,relevance:0};function X6(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,Y6,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function Q6(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}]},p={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(p,{contains:[]}),g=e.inherit(h,{contains:[]});p.contains.push(g),h.contains.push(m);let w=[n,u];return[p,h,m,g].forEach(T=>{T.contains=T.contains.concat(w)}),w=w.concat(p,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:w},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:w}]}]},n,i,r,p,h,{className:"quote",begin:"^>\\s+",contains:w,end:"$"},o,u,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function J6(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:/^(>>>|\.\.\.) /},p={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},h={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,h,p]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,h,p]},{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,h,p]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,p]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",w=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,y=`\\b|${r.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${w}))[eE][+-]?(${g})[jJ]?(?=${y})`},{begin:`(${w})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${y})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${y})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${y})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${y})`},{begin:`\\b(${g})[jJ](?=${y})`}]},_={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},T={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 p.contains=[m,b,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,b,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,_,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[T]},{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,T,m]}]}}function eF(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"],p=["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!"],h=["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:h,keyword:c,literal:u,built_in:p},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:p,type:h}},{scope:"punctuation",begin:"->"},i]}}const gf="[A-Za-z$_][0-9A-Za-z$_]*",aN=["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"],lN=["true","false","null","undefined","NaN","Infinity"],cN=["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"],uN=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],dN=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],fN=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],hN=[].concat(dN,cN,uN);function tF(e){const t=e.regex,n=(Z,{after:Y})=>{const q="</"+Z[0].slice(1);return Z.input.indexOf(q,Y)!==-1},r=gf,o={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Z,Y)=>{const q=Z[0].length+Z.index,F=Z.input[q];if(F==="<"||F===","){Y.ignoreMatch();return}F===">"&&(n(Z,{after:q})||Y.ignoreMatch());let re;const Ee=Z.input.substring(q);if(re=Ee.match(/^\s*=/)){Y.ignoreMatch();return}if((re=Ee.match(/^\s+extends\s+/))&&re.index===0){Y.ignoreMatch();return}}},c={$pattern:gf,keyword:aN,literal:lN,built_in:hN,"variable.language":fN},u="[0-9](_?[0-9])*",p=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${p})|\\.)?|(${p}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\b((${p})\\b|\\.)?|(${p})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},x={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,b,_,{match:/\$\d+/},m];g.contains=N.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(N)});const j=[].concat(x,g.contains),$=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(j)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$},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"}}]},A={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:{_:[...cN,...uN]}},O={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 X(Z){return t.concat("(?!",Z.join("|"),")")}const ne={match:t.concat(/\b/,X([...dN,"super","import","await"].map(Z=>`${Z}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},ee={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ie={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},be="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",C={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(be)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:A},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),O,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,y,b,_,x,{match:/\$\d+/},m,A,{scope:"attr",match:r+t.lookahead(":"),relevance:0},C,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[x,e.REGEXP_MODE,{className:"function",begin:be,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},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},ee,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},ne,z,R,ie,{match:/\$[(.]/}]}}function nF(e){const t=e.regex,n=tF(e),r=gf,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"],p={$pattern:gf,keyword:aN.concat(u),literal:lN,built_in:hN.concat(o),"variable.language":fN},h={className:"meta",begin:"@"+r},m=(b,_,T)=>{const x=b.contains.findIndex(N=>N.label===_);if(x===-1)throw new Error("can not find mode to replace");b.contains.splice(x,1,T)};Object.assign(n.keywords,p),n.exports.PARAMS_CONTAINS.push(h);const g=n.contains.find(b=>b.scope==="attr"),w=Object.assign({},g,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,w]),n.contains=n.contains.concat([h,i,l,w]),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 rF(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"}),p={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:[p],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[p],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:p}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function oF(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},o={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},c=e.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},w={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},y={begin:/\{/,end:/\}/,contains:[w],illegal:"\\n",relevance:0},b={begin:"\\[",end:"\\]",contains:[w],illegal:"\\n",relevance:0},_=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},g,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,b,i,l],T=[..._];return T.pop(),T.push(c),w.contains=T,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:_}}var im,cx;function sF(){if(cx)return im;cx=1;function e(B){return B instanceof Map?B.clear=B.delete=B.set=function(){throw new Error("map is read-only")}:B instanceof Set&&(B.add=B.clear=B.delete=function(){throw new Error("set is read-only")}),Object.freeze(B),Object.getOwnPropertyNames(B).forEach(me=>{const De=B[me],Xe=typeof De;(Xe==="object"||Xe==="function")&&!Object.isFrozen(De)&&e(De)}),B}class t{constructor(me){me.data===void 0&&(me.data={}),this.data=me.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(B){return B.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(B,...me){const De=Object.create(null);for(const Xe in B)De[Xe]=B[Xe];return me.forEach(function(Xe){for(const Pt in Xe)De[Pt]=Xe[Pt]}),De}const o="</span>",i=B=>!!B.scope,l=(B,{prefix:me})=>{if(B.startsWith("language:"))return B.replace("language:","language-");if(B.includes(".")){const De=B.split(".");return[`${me}${De.shift()}`,...De.map((Xe,Pt)=>`${Xe}${"_".repeat(Pt+1)}`)].join(" ")}return`${me}${B}`};class c{constructor(me,De){this.buffer="",this.classPrefix=De.classPrefix,me.walk(this)}addText(me){this.buffer+=n(me)}openNode(me){if(!i(me))return;const De=l(me.scope,{prefix:this.classPrefix});this.span(De)}closeNode(me){i(me)&&(this.buffer+=o)}value(){return this.buffer}span(me){this.buffer+=`<span class="${me}">`}}const u=(B={})=>{const me={children:[]};return Object.assign(me,B),me};class p{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(me){this.top.children.push(me)}openNode(me){const De=u({scope:me});this.add(De),this.stack.push(De)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(me){return this.constructor._walk(me,this.rootNode)}static _walk(me,De){return typeof De=="string"?me.addText(De):De.children&&(me.openNode(De),De.children.forEach(Xe=>this._walk(me,Xe)),me.closeNode(De)),me}static _collapse(me){typeof me!="string"&&me.children&&(me.children.every(De=>typeof De=="string")?me.children=[me.children.join("")]:me.children.forEach(De=>{p._collapse(De)}))}}class h extends p{constructor(me){super(),this.options=me}addText(me){me!==""&&this.add(me)}startScope(me){this.openNode(me)}endScope(){this.closeNode()}__addSublanguage(me,De){const Xe=me.root;De&&(Xe.scope=`language:${De}`),this.add(Xe)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(B){return B?typeof B=="string"?B:B.source:null}function g(B){return b("(?=",B,")")}function w(B){return b("(?:",B,")*")}function y(B){return b("(?:",B,")?")}function b(...B){return B.map(De=>m(De)).join("")}function _(B){const me=B[B.length-1];return typeof me=="object"&&me.constructor===Object?(B.splice(B.length-1,1),me):{}}function T(...B){return"("+(_(B).capture?"":"?:")+B.map(Xe=>m(Xe)).join("|")+")"}function x(B){return new RegExp(B.toString()+"|").exec("").length-1}function N(B,me){const De=B&&B.exec(me);return De&&De.index===0}const j=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function $(B,{joinWith:me}){let De=0;return B.map(Xe=>{De+=1;const Pt=De;let _t=m(Xe),He="";for(;_t.length>0;){const ze=j.exec(_t);if(!ze){He+=_t;break}He+=_t.substring(0,ze.index),_t=_t.substring(ze.index+ze[0].length),ze[0][0]==="\\"&&ze[1]?He+="\\"+String(Number(ze[1])+Pt):(He+=ze[0],ze[0]==="("&&De++)}return He}).map(Xe=>`(${Xe})`).join(me)}const P=/\b\B/,R="[a-zA-Z]\\w*",A="[a-zA-Z_]\\w*",O="\\b\\d+(\\.\\d+)?",D="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",z="\\b(0b[01]+)",X="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ne=(B={})=>{const me=/^#![ ]*\//;return B.binary&&(B.begin=b(me,/.*\b/,B.binary,/\b.*/)),r({scope:"meta",begin:me,end:/$/,relevance:0,"on:begin":(De,Xe)=>{De.index!==0&&Xe.ignoreMatch()}},B)},ee={begin:"\\\\[\\s\\S]",relevance:0},ie={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[ee]},be={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[ee]},C={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Z=function(B,me,De={}){const Xe=r({scope:"comment",begin:B,end:me,contains:[]},De);Xe.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Pt=T("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return Xe.contains.push({begin:b(/[ ]+/,"(",Pt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Xe},Y=Z("//","$"),q=Z("/\\*","\\*/"),F=Z("#","$"),re={scope:"number",begin:O,relevance:0},Ee={scope:"number",begin:D,relevance:0},Te={scope:"number",begin:z,relevance:0},de={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[ee,{begin:/\[/,end:/\]/,relevance:0,contains:[ee]}]},ke={scope:"title",begin:R,relevance:0},ae={scope:"title",begin:A,relevance:0},G={begin:"\\.\\s*"+A,relevance:0};var Le=Object.freeze({__proto__:null,APOS_STRING_MODE:ie,BACKSLASH_ESCAPE:ee,BINARY_NUMBER_MODE:Te,BINARY_NUMBER_RE:z,COMMENT:Z,C_BLOCK_COMMENT_MODE:q,C_LINE_COMMENT_MODE:Y,C_NUMBER_MODE:Ee,C_NUMBER_RE:D,END_SAME_AS_BEGIN:function(B){return Object.assign(B,{"on:begin":(me,De)=>{De.data._beginMatch=me[1]},"on:end":(me,De)=>{De.data._beginMatch!==me[1]&&De.ignoreMatch()}})},HASH_COMMENT_MODE:F,IDENT_RE:R,MATCH_NOTHING_RE:P,METHOD_GUARD:G,NUMBER_MODE:re,NUMBER_RE:O,PHRASAL_WORDS_MODE:C,QUOTE_STRING_MODE:be,REGEXP_MODE:de,RE_STARTERS_RE:X,SHEBANG:ne,TITLE_MODE:ke,UNDERSCORE_IDENT_RE:A,UNDERSCORE_TITLE_MODE:ae});function ge(B,me){B.input[B.index-1]==="."&&me.ignoreMatch()}function oe(B,me){B.className!==void 0&&(B.scope=B.className,delete B.className)}function we(B,me){me&&B.beginKeywords&&(B.begin="\\b("+B.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",B.__beforeBegin=ge,B.keywords=B.keywords||B.beginKeywords,delete B.beginKeywords,B.relevance===void 0&&(B.relevance=0))}function Ce(B,me){Array.isArray(B.illegal)&&(B.illegal=T(...B.illegal))}function Se(B,me){if(B.match){if(B.begin||B.end)throw new Error("begin & end are not supported with match");B.begin=B.match,delete B.match}}function _e(B,me){B.relevance===void 0&&(B.relevance=1)}const Be=(B,me)=>{if(!B.beforeMatch)return;if(B.starts)throw new Error("beforeMatch cannot be used with starts");const De=Object.assign({},B);Object.keys(B).forEach(Xe=>{delete B[Xe]}),B.keywords=De.keywords,B.begin=b(De.beforeMatch,g(De.begin)),B.starts={relevance:0,contains:[Object.assign(De,{endsParent:!0})]},B.relevance=0,delete De.beforeMatch},wt=["of","and","for","in","not","or","if","then","parent","list","value"],on="keyword";function Et(B,me,De=on){const Xe=Object.create(null);return typeof B=="string"?Pt(De,B.split(" ")):Array.isArray(B)?Pt(De,B):Object.keys(B).forEach(function(_t){Object.assign(Xe,Et(B[_t],me,_t))}),Xe;function Pt(_t,He){me&&(He=He.map(ze=>ze.toLowerCase())),He.forEach(function(ze){const qe=ze.split("|");Xe[qe[0]]=[_t,Vt(qe[0],qe[1])]})}}function Vt(B,me){return me?Number(me):Ft(B)?0:1}function Ft(B){return wt.includes(B.toLowerCase())}const Ht={},Me=B=>{console.error(B)},St=(B,...me)=>{console.log(`WARN: ${B}`,...me)},sn=(B,me)=>{Ht[`${B}/${me}`]||(console.log(`Deprecated as of ${B}. ${me}`),Ht[`${B}/${me}`]=!0)},ln=new Error;function lt(B,me,{key:De}){let Xe=0;const Pt=B[De],_t={},He={};for(let ze=1;ze<=me.length;ze++)He[ze+Xe]=Pt[ze],_t[ze+Xe]=!0,Xe+=x(me[ze-1]);B[De]=He,B[De]._emit=_t,B[De]._multi=!0}function jt(B){if(Array.isArray(B.begin)){if(B.skip||B.excludeBegin||B.returnBegin)throw Me("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ln;if(typeof B.beginScope!="object"||B.beginScope===null)throw Me("beginScope must be object"),ln;lt(B,B.begin,{key:"beginScope"}),B.begin=$(B.begin,{joinWith:""})}}function Kt(B){if(Array.isArray(B.end)){if(B.skip||B.excludeEnd||B.returnEnd)throw Me("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ln;if(typeof B.endScope!="object"||B.endScope===null)throw Me("endScope must be object"),ln;lt(B,B.end,{key:"endScope"}),B.end=$(B.end,{joinWith:""})}}function xn(B){B.scope&&typeof B.scope=="object"&&B.scope!==null&&(B.beginScope=B.scope,delete B.scope)}function Dt(B){xn(B),typeof B.beginScope=="string"&&(B.beginScope={_wrap:B.beginScope}),typeof B.endScope=="string"&&(B.endScope={_wrap:B.endScope}),jt(B),Kt(B)}function jn(B){function me(He,ze){return new RegExp(m(He),"m"+(B.case_insensitive?"i":"")+(B.unicodeRegex?"u":"")+(ze?"g":""))}class De{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(ze,qe){qe.position=this.position++,this.matchIndexes[this.matchAt]=qe,this.regexes.push([qe,ze]),this.matchAt+=x(ze)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const ze=this.regexes.map(qe=>qe[1]);this.matcherRe=me($(ze,{joinWith:"|"}),!0),this.lastIndex=0}exec(ze){this.matcherRe.lastIndex=this.lastIndex;const qe=this.matcherRe.exec(ze);if(!qe)return null;const ht=qe.findIndex((Bt,qt)=>qt>0&&Bt!==void 0),Ct=this.matchIndexes[ht];return qe.splice(0,ht),Object.assign(qe,Ct)}}class Xe{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(ze){if(this.multiRegexes[ze])return this.multiRegexes[ze];const qe=new De;return this.rules.slice(ze).forEach(([ht,Ct])=>qe.addRule(ht,Ct)),qe.compile(),this.multiRegexes[ze]=qe,qe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(ze,qe){this.rules.push([ze,qe]),qe.type==="begin"&&this.count++}exec(ze){const qe=this.getMatcher(this.regexIndex);qe.lastIndex=this.lastIndex;let ht=qe.exec(ze);if(this.resumingScanAtSamePosition()&&!(ht&&ht.index===this.lastIndex)){const Ct=this.getMatcher(0);Ct.lastIndex=this.lastIndex+1,ht=Ct.exec(ze)}return ht&&(this.regexIndex+=ht.position+1,this.regexIndex===this.count&&this.considerAll()),ht}}function Pt(He){const ze=new Xe;return He.contains.forEach(qe=>ze.addRule(qe.begin,{rule:qe,type:"begin"})),He.terminatorEnd&&ze.addRule(He.terminatorEnd,{type:"end"}),He.illegal&&ze.addRule(He.illegal,{type:"illegal"}),ze}function _t(He,ze){const qe=He;if(He.isCompiled)return qe;[oe,Se,Dt,Be].forEach(Ct=>Ct(He,ze)),B.compilerExtensions.forEach(Ct=>Ct(He,ze)),He.__beforeBegin=null,[we,Ce,_e].forEach(Ct=>Ct(He,ze)),He.isCompiled=!0;let ht=null;return typeof He.keywords=="object"&&He.keywords.$pattern&&(He.keywords=Object.assign({},He.keywords),ht=He.keywords.$pattern,delete He.keywords.$pattern),ht=ht||/\w+/,He.keywords&&(He.keywords=Et(He.keywords,B.case_insensitive)),qe.keywordPatternRe=me(ht,!0),ze&&(He.begin||(He.begin=/\B|\b/),qe.beginRe=me(qe.begin),!He.end&&!He.endsWithParent&&(He.end=/\B|\b/),He.end&&(qe.endRe=me(qe.end)),qe.terminatorEnd=m(qe.end)||"",He.endsWithParent&&ze.terminatorEnd&&(qe.terminatorEnd+=(He.end?"|":"")+ze.terminatorEnd)),He.illegal&&(qe.illegalRe=me(He.illegal)),He.contains||(He.contains=[]),He.contains=[].concat(...He.contains.map(function(Ct){return V(Ct==="self"?He:Ct)})),He.contains.forEach(function(Ct){_t(Ct,qe)}),He.starts&&_t(He.starts,ze),qe.matcher=Pt(qe),qe}if(B.compilerExtensions||(B.compilerExtensions=[]),B.contains&&B.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return B.classNameAliases=r(B.classNameAliases||{}),_t(B)}function Qt(B){return B?B.endsWithParent||Qt(B.starts):!1}function V(B){return B.variants&&!B.cachedVariants&&(B.cachedVariants=B.variants.map(function(me){return r(B,{variants:null},me)})),B.cachedVariants?B.cachedVariants:Qt(B)?r(B,{starts:B.starts?r(B.starts):null}):Object.isFrozen(B)?r(B):B}var pe="11.11.2";class Ye extends Error{constructor(me,De){super(me),this.name="HTMLInjectionError",this.html=De}}const nt=n,yt=r,Jt=Symbol("nomatch"),ye=7,Ae=function(B){const me=Object.create(null),De=Object.create(null),Xe=[];let Pt=!0;const _t="Could not find the language '{}', did you forget to load/include a language module?",He={disableAutodetect:!0,name:"Plain text",contains:[]};let ze={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function qe(je){return ze.noHighlightRe.test(je)}function ht(je){let Ve=je.className+" ";Ve+=je.parentNode?je.parentNode.className:"";const rt=ze.languageDetectRe.exec(Ve);if(rt){const et=kn(rt[1]);return et||(St(_t.replace("{}",rt[1])),St("Falling back to no-highlight mode for this block.",je)),et?rt[1]:"no-highlight"}return Ve.split(/\s+/).find(et=>qe(et)||kn(et))}function Ct(je,Ve,rt){let et="",cn="";typeof Ve=="object"?(et=je,rt=Ve.ignoreIllegals,cn=Ve.language):(sn("10.7.0","highlight(lang, code, ...args) has been deprecated."),sn("10.7.0",`Please use highlight(code, options) instead.
|
|
200
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),cn=je,et=Ve),rt===void 0&&(rt=!0);const wn={code:et,language:cn};pt("before:highlight",wn);const sr=wn.result?wn.result:Bt(wn.language,wn.code,rt);return sr.code=wn.code,pt("after:highlight",sr),sr}function Bt(je,Ve,rt,et){const cn=Object.create(null);function wn(H,J){return H.keywords[J]}function sr(){if(!kt.keywords){Mn.addText(en);return}let H=0;kt.keywordPatternRe.lastIndex=0;let J=kt.keywordPatternRe.exec(en),ve="";for(;J;){ve+=en.substring(H,J.index);const Oe=br.case_insensitive?J[0].toLowerCase():J[0],Ke=wn(kt,Oe);if(Ke){const[It,bn]=Ke;if(Mn.addText(ve),ve="",cn[Oe]=(cn[Oe]||0)+1,cn[Oe]<=ye&&(Zr+=bn),It.startsWith("_"))ve+=J[0];else{const Nn=br.classNameAliases[It]||It;fe(J[0],Nn)}}else ve+=J[0];H=kt.keywordPatternRe.lastIndex,J=kt.keywordPatternRe.exec(en)}ve+=en.substring(H),Mn.addText(ve)}function Lr(){if(en==="")return;let H=null;if(typeof kt.subLanguage=="string"){if(!me[kt.subLanguage]){Mn.addText(en);return}H=Bt(kt.subLanguage,en,!0,ts[kt.subLanguage]),ts[kt.subLanguage]=H._top}else H=vn(en,kt.subLanguage.length?kt.subLanguage:null);kt.relevance>0&&(Zr+=H.relevance),Mn.__addSublanguage(H._emitter,H.language)}function K(){kt.subLanguage!=null?Lr():sr(),en=""}function fe(H,J){H!==""&&(Mn.startScope(J),Mn.addText(H),Mn.endScope())}function Qe(H,J){let ve=1;const Oe=J.length-1;for(;ve<=Oe;){if(!H._emit[ve]){ve++;continue}const Ke=br.classNameAliases[H[ve]]||H[ve],It=J[ve];Ke?fe(It,Ke):(en=It,sr(),en=""),ve++}}function At(H,J){return H.scope&&typeof H.scope=="string"&&Mn.openNode(br.classNameAliases[H.scope]||H.scope),H.beginScope&&(H.beginScope._wrap?(fe(en,br.classNameAliases[H.beginScope._wrap]||H.beginScope._wrap),en=""):H.beginScope._multi&&(Qe(H.beginScope,J),en="")),kt=Object.create(H,{parent:{value:kt}}),kt}function mt(H,J,ve){let Oe=N(H.endRe,ve);if(Oe){if(H["on:end"]){const Ke=new t(H);H["on:end"](J,Ke),Ke.isMatchIgnored&&(Oe=!1)}if(Oe){for(;H.endsParent&&H.parent;)H=H.parent;return H}}if(H.endsWithParent)return mt(H.parent,J,ve)}function Zt(H){return kt.matcher.regexIndex===0?(en+=H[0],1):(L=!0,0)}function Dr(H){const J=H[0],ve=H.rule,Oe=new t(ve),Ke=[ve.__beforeBegin,ve["on:begin"]];for(const It of Ke)if(It&&(It(H,Oe),Oe.isMatchIgnored))return Zt(J);return ve.skip?en+=J:(ve.excludeBegin&&(en+=J),K(),!ve.returnBegin&&!ve.excludeBegin&&(en=J)),At(ve,H),ve.returnBegin?0:J.length}function fr(H){const J=H[0],ve=Ve.substring(H.index),Oe=mt(kt,H,ve);if(!Oe)return Jt;const Ke=kt;kt.endScope&&kt.endScope._wrap?(K(),fe(J,kt.endScope._wrap)):kt.endScope&&kt.endScope._multi?(K(),Qe(kt.endScope,H)):Ke.skip?en+=J:(Ke.returnEnd||Ke.excludeEnd||(en+=J),K(),Ke.excludeEnd&&(en=J));do kt.scope&&Mn.closeNode(),!kt.skip&&!kt.subLanguage&&(Zr+=kt.relevance),kt=kt.parent;while(kt!==Oe.parent);return Oe.starts&&At(Oe.starts,H),Ke.returnEnd?0:J.length}function yo(){const H=[];for(let J=kt;J!==br;J=J.parent)J.scope&&H.unshift(J.scope);H.forEach(J=>Mn.openNode(J))}let _r={};function vr(H,J){const ve=J&&J[0];if(en+=H,ve==null)return K(),0;if(_r.type==="begin"&&J.type==="end"&&_r.index===J.index&&ve===""){if(en+=Ve.slice(J.index,J.index+1),!Pt){const Oe=new Error(`0 width match regex (${je})`);throw Oe.languageName=je,Oe.badRule=_r.rule,Oe}return 1}if(_r=J,J.type==="begin")return Dr(J);if(J.type==="illegal"&&!rt){const Oe=new Error('Illegal lexeme "'+ve+'" for mode "'+(kt.scope||"<unnamed>")+'"');throw Oe.mode=kt,Oe}else if(J.type==="end"){const Oe=fr(J);if(Oe!==Jt)return Oe}if(J.type==="illegal"&&ve==="")return J.index===Ve.length||(en+=`
|
|
201
|
-
`),1;if(Ie>1e5&&Ie>J.index*3)throw new Error("potential infinite loop, way more iterations than matches");return en+=ve,ve.length}const br=kn(je);if(!br)throw Me(_t.replace("{}",je)),new Error('Unknown language: "'+je+'"');const lo=jn(br);let Xt="",kt=et||lo;const ts={},Mn=new ze.__emitter(ze);yo();let en="",Zr=0,hr=0,Ie=0,L=!1;try{if(br.__emitTokens)br.__emitTokens(Ve,Mn);else{for(kt.matcher.considerAll();;){Ie++,L?L=!1:kt.matcher.considerAll(),kt.matcher.lastIndex=hr;const H=kt.matcher.exec(Ve);if(!H)break;const J=Ve.substring(hr,H.index),ve=vr(J,H);hr=H.index+ve}vr(Ve.substring(hr))}return Mn.finalize(),Xt=Mn.toHTML(),{language:je,value:Xt,relevance:Zr,illegal:!1,_emitter:Mn,_top:kt}}catch(H){if(H.message&&H.message.includes("Illegal"))return{language:je,value:nt(Ve),illegal:!0,relevance:0,_illegalBy:{message:H.message,index:hr,context:Ve.slice(hr-100,hr+100),mode:H.mode,resultSoFar:Xt},_emitter:Mn};if(Pt)return{language:je,value:nt(Ve),illegal:!1,relevance:0,errorRaised:H,_emitter:Mn,_top:kt};throw H}}function qt(je){const Ve={value:nt(je),illegal:!1,relevance:0,_top:He,_emitter:new ze.__emitter(ze)};return Ve._emitter.addText(je),Ve}function vn(je,Ve){Ve=Ve||ze.languages||Object.keys(me);const rt=qt(je),et=Ve.filter(kn).filter(dn).map(K=>Bt(K,je,!1));et.unshift(rt);const cn=et.sort((K,fe)=>{if(K.relevance!==fe.relevance)return fe.relevance-K.relevance;if(K.language&&fe.language){if(kn(K.language).supersetOf===fe.language)return 1;if(kn(fe.language).supersetOf===K.language)return-1}return 0}),[wn,sr]=cn,Lr=wn;return Lr.secondBest=sr,Lr}function On(je,Ve,rt){const et=Ve&&De[Ve]||rt;je.classList.add("hljs"),je.classList.add(`language-${et}`)}function Cn(je){let Ve=null;const rt=ht(je);if(qe(rt))return;if(pt("before:highlightElement",{el:je,language:rt}),je.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",je);return}if(je.children.length>0&&(ze.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(je)),ze.throwUnescapedHTML))throw new Ye("One of your code blocks includes unescaped HTML.",je.innerHTML);Ve=je;const et=Ve.textContent,cn=rt?Ct(et,{language:rt,ignoreIllegals:!0}):vn(et);je.innerHTML=cn.value,je.dataset.highlighted="yes",On(je,rt,cn.language),je.result={language:cn.language,re:cn.relevance,relevance:cn.relevance},cn.secondBest&&(je.secondBest={language:cn.secondBest.language,relevance:cn.secondBest.relevance}),pt("after:highlightElement",{el:je,result:cn,text:et})}function Xn(je){ze=yt(ze,je)}const Kn=()=>{at(),sn("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function se(){at(),sn("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Ne=!1;function at(){function je(){at()}if(document.readyState==="loading"){Ne||window.addEventListener("DOMContentLoaded",je,!1),Ne=!0;return}document.querySelectorAll(ze.cssSelector).forEach(Cn)}function gt(je,Ve){let rt=null;try{rt=Ve(B)}catch(et){if(Me("Language definition for '{}' could not be registered.".replace("{}",je)),Pt)Me(et);else throw et;rt=He}rt.name||(rt.name=je),me[je]=rt,rt.rawDefinition=Ve.bind(null,B),rt.aliases&&tr(rt.aliases,{languageName:je})}function Wt(je){delete me[je];for(const Ve of Object.keys(De))De[Ve]===je&&delete De[Ve]}function gn(){return Object.keys(me)}function kn(je){return je=(je||"").toLowerCase(),me[je]||me[De[je]]}function tr(je,{languageName:Ve}){typeof je=="string"&&(je=[je]),je.forEach(rt=>{De[rt.toLowerCase()]=Ve})}function dn(je){const Ve=kn(je);return Ve&&!Ve.disableAutodetect}function fn(je){je["before:highlightBlock"]&&!je["before:highlightElement"]&&(je["before:highlightElement"]=Ve=>{je["before:highlightBlock"](Object.assign({block:Ve.el},Ve))}),je["after:highlightBlock"]&&!je["after:highlightElement"]&&(je["after:highlightElement"]=Ve=>{je["after:highlightBlock"](Object.assign({block:Ve.el},Ve))})}function Nt(je){fn(je),Xe.push(je)}function Pr(je){const Ve=Xe.indexOf(je);Ve!==-1&&Xe.splice(Ve,1)}function pt(je,Ve){const rt=je;Xe.forEach(function(et){et[rt]&&et[rt](Ve)})}function In(je){return sn("10.7.0","highlightBlock will be removed entirely in v12.0"),sn("10.7.0","Please use highlightElement now."),Cn(je)}Object.assign(B,{highlight:Ct,highlightAuto:vn,highlightAll:at,highlightElement:Cn,highlightBlock:In,configure:Xn,initHighlighting:Kn,initHighlightingOnLoad:se,registerLanguage:gt,unregisterLanguage:Wt,listLanguages:gn,getLanguage:kn,registerAliases:tr,autoDetection:dn,inherit:yt,addPlugin:Nt,removePlugin:Pr}),B.debugMode=function(){Pt=!1},B.safeMode=function(){Pt=!0},B.versionString=pe,B.regex={concat:b,lookahead:g,either:T,optional:y,anyNumberOfTimes:w};for(const je in Le)typeof Le[je]=="object"&&e(Le[je]);return Object.assign(B,Le),B},Yt=Ae({});return Yt.newInstance=()=>Ae({}),im=Yt,Yt.HighlightJS=Yt,Yt.default=Yt,im}var iF=sF();const aF=l1(iF),ux={},lF="hljs-";function cF(e){const t=aF.newInstance();return e&&i(e),{highlight:n,highlightAuto:r,listLanguages:o,register:i,registerAlias:l,registered:c};function n(u,p,h){const m=h||ux,g=typeof m.prefix=="string"?m.prefix:lF;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:uF,classPrefix:g});const w=t.highlight(p,{ignoreIllegals:!0,language:u});if(w.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:w.errorRaised});const y=w._emitter.root,b=y.data;return b.language=w.language,b.relevance=w.relevance,y}function r(u,p){const m=(p||ux).subset||o();let g=-1,w=0,y;for(;++g<m.length;){const b=m[g];if(!t.getLanguage(b))continue;const _=n(b,u,p);_.data&&_.data.relevance!==void 0&&_.data.relevance>w&&(w=_.data.relevance,y=_)}return y||{type:"root",children:[],data:{language:void 0,relevance:w}}}function o(){return t.listLanguages()}function i(u,p){if(typeof u=="string")t.registerLanguage(u,p);else{let h;for(h in u)Object.hasOwn(u,h)&&t.registerLanguage(h,u[h])}}function l(u,p){if(typeof u=="string")t.registerAliases(typeof p=="string"?p:[...p],{languageName:u});else{let h;for(h in u)if(Object.hasOwn(u,h)){const m=u[h];t.registerAliases(typeof m=="string"?m:[...m],{languageName:h})}}}function c(u){return!!t.getLanguage(u)}}class uF{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 pN=cF({bash:$6,css:B6,go:U6,ini:H6,javascript:G6,json:X6,markdown:Q6,python:J6,rust:eF,typescript:nF,xml:rF,yaml:oF}),dx={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 sw(e,t){const n=e&&(dx[e]??(pN.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?dx[o]:null)??null}const dF=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function fF(e){const t=new Set;for(const n of e.matchAll(dF)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const hF={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 mN(e,t){const n=[[]],r=(i,l)=>{const c=i.split(`
|
|
202
|
-
`);for(const[u,p]of c.entries()){if(u>0&&n.push([]),!p)continue;const h=n[n.length-1],m=h[h.length-1];m&&m.scope===l?m.text+=p:h.push({text:p,scope:l})}},o=(i,l)=>{for(const c of i)c.type==="text"?r(c.value,l):c.type==="element"&&o(c.children,pF(c)??l)};try{o(pN.highlight(t,e).children,"")}catch{return e.split(`
|
|
203
|
-
`).map(i=>i?[{text:i,scope:""}]:[])}return n}function pF(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const i=hF[o.startsWith("hljs-")?o.slice(5):o];i&&(n=i)}return n}const fx=/^\d+\t/;function iw(e,t){if(!t)return[];const n=e.split(`
|
|
204
|
-
`),r=fx.test(n[0]??""),o=r?n.map(l=>{var c;return((c=fx.exec(l))==null?void 0:c[0])??""}):[],i=r?n.map((l,c)=>l.slice(o[c].length)).join(`
|
|
205
|
-
`):e;return mN(i,t).map((l,c)=>{const u=l.map(h=>({text:h.text,changed:!1,scope:h.scope})),p=o[c];return p?[{text:p,changed:!1,scope:""},...u]:u})}function mF(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"||(gF(e,o,i,t,n),o=i+1)}}return e.map((o,i)=>kF(o.spans,n[i],o.text))}function gF(e,t,n,r,o){var i,l;for(const c of["del","add"]){const u=[];for(let m=t;m<n;m++){const g=(i=e[m])==null?void 0:i.kind;(g===""||g===c)&&u.push(m)}if(u.length===0)continue;const p=u.map(m=>{var g;return((g=e[m])==null?void 0:g.text)??""}).join(`
|
|
206
|
-
`),h=mN(p,r);for(const[m,g]of u.entries())(c==="add"||((l=e[g])==null?void 0:l.kind)==="del")&&(o[g]=h[m])}}function kF(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,p=0;for(;l<o.length&&c<i.length;){const h=o[l],m=i[c],g=Math.min(h.text.length-u,m.text.length-p);if(g>0){const w={text:h.text.slice(u,u+g),changed:h.changed,scope:m.scope},y=r[r.length-1];y&&y.changed===w.changed&&y.scope===w.scope?y.text+=w.text:r.push(w)}u+=g,p+=g,u>=h.text.length&&(l++,u=0),p>=m.text.length&&(c++,p=0)}return r}En.use({extensions:[_6],renderer:{code({text:e,lang:t}){const n=sw((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${iw(e,n).map(o=>o.map(i=>i.scope?`<span class="sy-${i.scope}">${ag(i.text)}</span>`:ag(i.text)).join("")).join(`
|
|
207
|
-
`)}</code></pre>
|
|
208
|
-
`:!1},html(e){return jo!=null&&jo.keepHtml?!1:N6(e)},table:T6}});const gN=w5(window);let jo=null;gN.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===nN){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=jo!=null&&jo.fileRoot?z_(jo.fileRoot,t):null,r=n?null:F_(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=M3(e.textContent??"");i&&e.setAttribute("data-path",i)}const o=jo==null?void 0:jo.base;if(e.tagName==="IMG"&&o){const i=qk(o.dir,e.getAttribute("src")??"");i&&e.setAttribute("src",o.urls.worktreeFile(o.worktreeId,i,o.version))}});function hl(e,t){jo=t??null;const n=t!=null&&t.streaming?b6(e):e;try{return gN.sanitize(En.parse(n,{async:!1}))}finally{jo=null}}function wF(e,t){const[n,r]=S.useState(e),o=S.useRef(null);return S.useEffect(()=>{if(!t){o.current=null;return}o.current=A6(o.current,e.length,performance.now());let i=0;const l=()=>{const c=o.current;if(!c)return;const u=rN(c,performance.now());r(I6(e,u)),u<c.to&&(i=requestAnimationFrame(l))};return l(),()=>cancelAnimationFrame(i)},[e,t]),t?n:e}function sh(e,t){var w,y,b,_;const[n,r]=S.useState(()=>hl(e,t)),o=S.useRef(0),i=(w=t==null?void 0:t.base)==null?void 0:w.worktreeId,l=(y=t==null?void 0:t.base)==null?void 0:y.dir,c=(b=t==null?void 0:t.base)==null?void 0:b.version,u=(_=t==null?void 0:t.base)==null?void 0:_.urls,p=t==null?void 0:t.fileRoot,h=!!(t!=null&&t.keepHtml),m=!!(t!=null&&t.streaming),g=wF(e,m);return S.useEffect(()=>{const T=i!==void 0&&l!==void 0&&u!==void 0?{worktreeId:i,dir:l,version:c??null,urls:u}:void 0,x=T||p||h||m?{base:T,fileRoot:p,keepHtml:h,streaming:m}:void 0,N=performance.now()-o.current;if(m||N>=da){o.current=performance.now(),r(hl(g,x));return}const j=setTimeout(()=>{o.current=performance.now(),r(hl(g,x))},da-N);return()=>clearTimeout(j)},[g,i,l,c,u,p,h,m]),n}const yF=/^ {0,3}(`{3,}|~{3,})/,vF=/^#{1,6} \S/,bF=/^\s*(?:[-*+]|\d+[.)]) \S/,xF=/^> ?\S/,EF=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,SF=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,_F=/\*\*[^\s*][^*\n]*\*\*/;function NF(e){var i,l;const t=e.split(`
|
|
209
|
-
`),n=new Set;let r=null,o=0;for(let c=0;c<t.length;c++){const u=t[c],p=(i=yF.exec(u))==null?void 0:i[1];if(r){p!=null&&p.startsWith(r)&&(r=null,n.add("fence"));continue}if(p){r=p;continue}vF.test(u)&&!((l=t[c+1])!=null&&l.trim())&&n.add("heading"),bF.test(u)&&++o===2&&n.add("list"),xF.test(u)&&n.add("quote"),EF.test(u)&&n.add("table"),SF.test(u)&&n.add("link"),_F.test(u)&&n.add("bold")}return n.size}function TF(e,t){if(t)return Bf(t)==="markdown"?"rendered":"plain";const n=NF(e);return n>=2?"rendered":n===1?"source":"plain"}function aw({n:e,name:t,source:n,lines:r,chars:o,preview:i,text:l,href:c,onRemove:u,className:p=""}){const h=(n==null?void 0:n.path)??t??"",m=h.includes("/")?h.slice(0,h.lastIndexOf("/")):"",g=n?[m,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[m,`${r} ${r===1?"line":"lines"}`,`${o.toLocaleString()} chars`,i].filter(Boolean).join(" · "),w=d.jsxs(d.Fragment,{children:[d.jsx(Tt,{name:"text",className:"icon-inline"}),d.jsxs("span",{className:"pick-target",children:[d.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?X2(n):g1("paste",e)}),g&&d.jsxs("span",{className:"pick-file row-dim",children:[" · ",g]})]})]}),y=l!==void 0||c!==void 0;return d.jsx(Yk,{className:We("paste-chip",p),label:w,tip:i||void 0,peek:y?d.jsx(yN,{text:l,href:c}):void 0,full:y?d.jsx(wN,{text:l,href:c,path:h||void 0}):void 0,menu:b=>y3({text:l,href:c},b),removeLabel:"Remove attachment",onRemove:u})}function kN(e,t){const[n,r]=S.useState(e??null),[o,i]=S.useState(!1);return S.useEffect(()=>{if(e!==void 0||!t)return;let l=!0;return fetch(t).then(c=>c.ok?c.text():Promise.reject(new Error(String(c.status)))).then(c=>{l&&r(c)}).catch(()=>{l&&i(!0)}),()=>{l=!1}},[e,t]),{text:e??n,failed:o}}function wN({text:e,href:t,path:n}){const{text:r,failed:o}=kN(e,t),i=S.useMemo(()=>r?TF(r,n):"plain",[r,n]),[l,c]=S.useState(null);if(o)return d.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||i==="plain")return d.jsx("pre",{className:"paste-full paste-text",children:r});const u=l??i==="rendered";return d.jsxs("div",{className:"paste-full paste-doc",children:[d.jsx("div",{className:"paste-doc-head",children:d.jsxs(Fe,{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(Tt,{name:u?"text":"book",className:"icon-inline"})," ",u?"text":"preview"]})}),u?d.jsx(jF,{text:r}):d.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function jF({text:e}){const t=S.useMemo(()=>hl(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 CF=2e4;function yN({text:e,href:t}){const{text:n}=kN(e,t);return n?d.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,CF)}):null}function lw({name:e,bytes:t,href:n,kept:r,uploading:o,progress:i,onRemove:l,className:c=""}){const u=it();return d.jsx(Yk,{className:We("file-chip",c),label:d.jsxs(d.Fragment,{children:[d.jsx(Tt,{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:[" ","· ",Dg(t),i!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[i,"%"]})]}):o&&" · uploading"]})]})]}),tip:e,peek:n?d.jsx(yN,{href:n}):void 0,full:n?d.jsx(wN,{href:n,path:e}):void 0,menu:p=>v3({href:n},p,r&&{...r,sock:u}),removeLabel:"Remove attachment",onRemove:l})}function vN(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const bN=120,AF=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function xN(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=AF.exec(i))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!l||l.length>bN)return[];t.push(l)}return t}function EN(e){const t=xN(e);if(t.length)return t.at(-1);const n=vN(e).trim().replace(/`/g,"");return n&&!n.includes(`
|
|
210
|
-
`)&&n.length<=bN?n:""}const IF={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},hx={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},SN="Skill",am=new Map([[Rg,"chat"],["Monitor","clock"],["TaskOutput","terminal"],[SN,"layers"]]);function $F(e){if(e.name!==SN)return"";const t=ro(e,"skill").trim();if(!t)return"";const n=ro(e,"args").trim();return n?`/${t} ${n}`:`/${t}`}const lg={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"},RF=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,px=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,mx=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${px}\s*(?:&&|;)|mkdir(?:\s+${px})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),OF=/^python[\d.]*$/,MF=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function _N(e){let t=e;for(let n=t.replace(mx,"");n!==t;n=t.replace(mx,""))t=n;return t}const PF=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),NN=/&&|;|\n|\|/;function LF(e){return e.split(NN).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&RF.test(t))}function DF(e){return e.split(/&&|;|\n/).map(t=>_N(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>lg[t.slice(t.lastIndexOf("/")+1)]==="trash")}function zF(e){const t=_N(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?LF(e)?void 0:"book":lg[r];if(o==="book"||o==="search"){const i=t.split(NN)[0]??"";if(PF.test(i))return r==="cat"&&i.includes("<<")?"edit":void 0}if(!(o==="trash"&&!DF(t)))return o||(OF.test(r)?t.includes("<<")&&MF.test(t)?"edit":void 0:lg[r])}function ro(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const FF=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function TN(e){const t=FF.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const BF="Guardian Review";function jN(e){return e.toolKind==="think"&&e.title===BF}function UF(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 Yc(e,t=[]){const n=TN(ro(e,"command")),r=e.name===xm?"":ro(e,"query"),i=CN(e)||n||ro(e,"path")||ro(e,"pattern")||r||$F(e)||(e.title&&e.title!==e.name?e.title:""),l=ih(ro(e,"description")||i,t),c=e.toolKind&&e.toolKind in hx?e.toolKind:"other",u=IF[c],p=e.name===Rg,h=c!=="other"||am.has(e.name),m=e.name===e.title||e.name===mi||e.name===u1,g=l&&(h||m||e.name===xm)?"":e.name,w=g&&g.toLowerCase()!==u?g:l?"":u,y=(c==="execute"||c==="other")&&n?zF(n):void 0;return{label:p?"ask":u,name:w,icon:am.get(e.name)??am.get(e.title??"")??y??hx[c],hint:l===w?"":l,command:n&&n!==l?n:""}}const HF=/^Async agent launched/m;function WF(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&HF.test(e.output)}const KF={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 ZF(e){const t=e.toolKind;return e.subagent?ro(e,"prompt")?"":"writing the brief":!Tf(e.input)||!f1({name:e.name,kind:t},e.input)?"":Og(t)?KF[t]:"writing the question"}function cg(e,t){const n=AN(t),r=n[0],o=ro(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function xl(e){return CN(e)||ro(e,"path")}function qF(e){return ro(e,"description")}function CN(e){return ro(e,"file_path")||ro(e,"filepath")||ro(e,"filePath")||GF(e)}function GF(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 ih(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 VF=/^(`{3,})([\w+#.-]*)\s*$/;function AN(e){var c;const t=[];let n=[],r="",o=!1,i=0;const l=()=>{const u=n.join(`
|
|
211
|
-
`).replace(/^\n+|\n+$/g,"");u.trim()&&t.push({code:o,diff:YF(u,r),lang:o?r:"",text:u}),n=[]};for(const u of e.split(`
|
|
212
|
-
`)){const p=VF.exec(u),h=((c=p==null?void 0:p[1])==null?void 0:c.length)??0;if(!p||o&&(h<i||p[2])){n.push(u);continue}l(),o=!o,i=o?h:0,r=o?(p[2]??"").toLowerCase():""}return l(),t}function YF(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const XF=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function QF(e){const t=[];for(const n of e.split(`
|
|
213
|
-
`)){const r=e8(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 JF(t),t}function JF(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),p=e.slice(l,c),h=u.length>0&&p.length>0?fA(u.map(m=>m.text).join(`
|
|
214
|
-
`),p.map(m=>m.text).join(`
|
|
215
|
-
`)):null;h&&(gx(u,Bv(h.before)),gx(p,Bv(h.after)));for(const m of[...u,...p])m.spans??(m.spans=[]);i=c}}function gx(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function e8(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||XF.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function t8(e){const t=e.tools.at(-1);return t.done||t.parentToolId?!1:t.name===mi?!t.background:!!t.background}const IN=new Set(["read","edit","fetch"]);function cw(e,t){if(e.isError||!e.toolKind||!IN.has(e.toolKind)||Og(e.toolKind)&&Tf(e.input))return"";const{hint:n}=Yc(e,t);return n?`${e.parentToolId??""}
|
|
216
|
-
${e.toolKind}
|
|
217
|
-
${e.name}
|
|
218
|
-
${n}`:""}function kx(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!IN.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.name===e.name&&r.parentToolId===e.parentToolId&&cw(r,n)!==""}function n8(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:cw(o,t)?n:-1}function $N(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 r8(e){return e.done&&!e.output&&!e.isError&&f1({name:e.name,kind:e.toolKind},e.input)}function o8(e,t){const n=$N(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(r8(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=cw(c,t),p=c.parentToolId?o.get(c.parentToolId):void 0;if(p){const m=p.entry.run,g=m.at(-1);u&&u===p.key&&g?g.tools.push(c):!u&&kx(c,g,t)?g.next=c:m.push({at:l,tools:[c]}),p.key=u,p.entry.end=l;continue}const h=r.at(-1);if(u&&u===i&&h&&"tools"in h){h.tools.push(c);continue}if(!u&&kx(c,h,t)){h.next=c;continue}i=u,r.push({at:l,tools:[c]})}return r}function s8(e){return e.reduce((t,n)=>t+n.tools.length,0)}function i8(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?WF(l)?o&&!n.has(l.id)&&t.add(l.id):t.delete(l.id):t.add(l.id))}return t}function a8(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&&t8(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 l8(e){const t=$N(e);return e.some(n=>n.kind==="tool"&&!n.done&&!n.parentToolId&&!n.background&&(!t.has(n.id)||Tf(n.input)))}function RN(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===mi)return;const u=d1({name:c.name,kind:c.toolKind});(o||r&&u)&&n.add(l),r=!0,o||(o=u)}),n}function c8(e){return e.findIndex(t=>!t.tools.at(-1).done)}function uw(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function ON(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)&&uw(n.tools,t[r].tools)})}function u8(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&&d8(c,i)?c:i;return u!==e[l]&&(r=!1),u});return r?e:o}function d8(e,t){return"spawn"in e?"spawn"in t&&e.spawn===t.spawn&&e.end===t.end&&ON(e.run,t.run):"tools"in e?"tools"in t&&e.next===t.next&&uw(e.tools,t.tools):"item"in t&&e.item===t.item}function f8(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"&&!jN(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return EN(n.item.text)?-1:t}if(h8(n.item))return-1}}return-1}function h8(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function p8(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 m8({item:e}){const t=ut(),n=M(r=>un(r,e.worktreeId)!==null);return e.state==="proposed"?null:e.state==="starting"?d.jsx(no,{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(no,{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(no,{icon:"spawn",word:"continued",tone:"accent",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["in ",e.repo.name,":"," ",d.jsx(Fe,{variant:"inline",tone:"strong",disabled:!n,onClick:()=>e.worktreeId&&t({a:"activate",id:e.worktreeId}),children:e.title??e.repo.name})]})})}function g8({item:e}){return d.jsxs(no,{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(Fe,{variant:"inline",tone:"strong",onClick:()=>window.open(e.url,"_blank"),children:"view PR"})]})}function dw({src:e,n:t,name:n,width:r,height:o,bytes:i,kept:l,uploading:c,progress:u,onRemove:p,className:h=""}){const m=it();return d.jsx(Yk,{className:We("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:g1("image",t)}),d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",Dg(i),u!==void 0?d.jsxs(d.Fragment,{children:[" ","· ",d.jsxs("span",{className:"pick-progress",children:[u,"%"]})]}):c&&" · uploading"]})]})]}),peek:d.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:d.jsx("img",{src:e,alt:n}),menu:g=>Gc(e,g,l&&{...l,sock:m}),removeLabel:"Remove image",onRemove:p})}function k8({img:e,worktreeId:t,src:n}){return d.jsx(dw,{className:"in-chat",src:n,...e,kept:{worktreeId:t,file:e.file}})}function ug(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 MN(e,t,n){const r=p=>e.map((h,m)=>p(h)&&h.id!==t?m:-1).filter(h=>h>=0),i=[()=>r(p=>p.agent==="waiting"),()=>r(p=>!!p.unseen),()=>r(p=>p.agent==="working")].reduce((p,h)=>p.length>0?p:h(),[]),l=e.findIndex(p=>p.id===t),c=n>0?i.find(p=>p>l)??i[0]:i.findLast(p=>p<l)??i[i.length-1],u=c===void 0?void 0:e[c];return u?{activate:u.id}:null}function fw(e,t,n){const r=MN(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function w8(e,t,n){const r=[ug(e,t),...n.map(o=>ug(o.rows,null))].filter(o=>o!==null);return r.length===0?null:{n:r.reduce((o,i)=>o+i.n,0),tier:r.some(o=>o.tier==="waiting")?"waiting":"unseen"}}function y8(e,t,n){const r=[i=>i.agent==="waiting",i=>!!i.unseen];for(const i of r){if(e.some(l=>i(l)&&l.id!==t)){const l=MN(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=fw(e,t,1);return o&&{origin:null,activate:o.activate}}function PN(e,{sock:t,dispatch:n}){var m,g;const r=w=>w?"hide":"show",o=e.repos.some(w=>w.id===e.activeRepoId),i=(m=un(e,e.activeId))==null?void 0:m.worktree.id,l=[];o&&(l.push({id:"new",label:"new worktree…",key:zt("new"),onClick:()=>n({a:"open-draft"})}),l.push({id:"refs",label:"open a branch or PR…",key:zt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),i&&(l.push({id:"jump",label:"jump to file…",key:zt("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),l.push({id:"search",label:"search in files…",key:zt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),df(e)&&l.push({id:"routes",label:"go to page…",key:zt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&l.push({id:"chats",label:"search chats…",key:zt("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const c=fw(e.visible,e.activeId,1);c&&l.push({id:"wt-unseen-next",label:"next that needs you",key:zt("wt-unseen-next"),onClick:()=>n({a:"activate",id:c.activate})}),l.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:zt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:zt("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&yl(e)==="files")} files`,key:zt("files"),onClick:()=>n(e.layout.changes&&yl(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:zt("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:zt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:zt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:zt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:zt("zen"),onClick:()=>n({a:"toggle-zen"})}],p=[{id:"commands",label:"command palette",key:zt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:zt("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];(g=e.self)!=null&&g.restart&&p.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),p.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 h=Ao(e)?new Set(["chat","design","zen"]):null;return zn([l,h?u.filter(w=>!h.has(w.id)):u,p])}function dg(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}?
|
|
219
|
-
|
|
220
|
-
It leaves your list, here and in every browser Toyon on this machine serves, and this browser forgets what it had selected there. Toyon on that machine is not touched; pair again to list it.`)&&e.serving().sock.send({t:"forget-machine",origin:t})}}];return zn([o,i])}function hw(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 LN(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:Co})}]}function v8(e,t,n,r){return zn([[...e.flatMap(o=>hw(o,t,r)),...LN(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}const Xc=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function pw(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 b8(e,t,n){const r=e.map(p=>p.path.slice(0,p.path.lastIndexOf("/"))).filter(Boolean),o=e.find(p=>p.id===t),i=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),l=new Map;for(const p of r)l.set(p,(l.get(p)??0)+1);let c="",u=0;for(const[p,h]of[...l].sort(([m],[g])=>m.localeCompare(g)))(h>u||h===u&&p===i)&&(c=p,u=h);return c?DN(c,n):`~/${lE}`}function DN(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function zN(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function x8(e){const t=e.query.trim(),n=()=>e.entries.map(l=>({kind:l.isFile?"file":"dir",entry:l}));if(!Xc(t)){const l=e.repos.filter(g=>cs(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),c=e.pending.filter(g=>cs(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),u=[...l,...c],p=(e.others??[]).flatMap(g=>g.repos.length===0?cs(t,g.name)?[{kind:"machine",machine:g}]:[]:g.repos.filter(w=>cs(t,w.name,w.path,g.name)).map(w=>({kind:"repo",repo:w,machine:g})));if(!t){const g=l.find(y=>y.kind==="repo"&&y.repo.id===e.current);return[...g?[g,...l.filter(y=>y!==g)]:l,...c,{kind:"new"},{kind:"disk"},{kind:"add-machine"},...p]}const h=nM(t);if(h)return u.length>0?u:[{kind:"clone",url:h.url,name:h.name}];const m=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>m(g.name))||e.pending.some(g=>m(g.name))?[...u,...p]:Uc(t)?[...u,...p]:[...u,{kind:"create",name:t,parent:null},...p]}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=El(l,e.home);return c==="/"||c===e.home||e.repos.some(p=>p.path.startsWith(`${c}/`))?n():[...n(),{kind:"init",path:l}]}if(t.endsWith("/"))return n();if(!r.parentExists)return[];const{parent:o,name:i}=pw(t);return Uc(i)?n():[...n(),{kind:"create",name:i,parent:o}]}function El(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function FN(e,t){const n=El(e,t).replace(/\/+$/,"");return n.startsWith("/")?DN(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function fg(e,t){const n=El(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function E8(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=El(r,e.home);if(!Xc(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(h=>{if(h.isRepo||h.isFile)return!1;const m=El(h.path,e.home);return(m.slice(0,m.lastIndexOf("/"))||"/")===o&&h.name.toLowerCase().startsWith(i)}),p=FN(r,e.home);return[...c?[{kind:"here",path:r}]:[],...p?[{kind:"up",path:p}]:[],...u.map(h=>({kind:"dir",entry:h}))]}function Qc({sock:e,dispatch:t},n){t({a:"open-repo"}),e==null||e.send(n)}function BN(e,t){const{parent:n,name:r}=pw(t);Qc(e,{t:"create-repo",mode:"init",parent:n,name:r})}function S8(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 ah(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}?
|
|
221
|
-
|
|
222
|
-
Its procs stop, it leaves the project list, and the chat on main is deleted. The checkout is not touched, and archived worktrees come back when you open it again.`)&&(n==null||n.send({t:"forget-repo",repoId:e.id}))}}];return zn([o,i])}const kf={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},wf={use:"while in use",always:"always",off:"off"};function _8(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 UN(e,{sock:t,dispatch:n}){var l;const r=e.themePrefs,o=c=>{var u;return((u=e.themes.find(p=>p.id===c))==null?void 0:u.name)??c},i=g4();return zn([[{id:"theme",label:"theme…",detail:Ff(r,e.themes,FE(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:kf[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((l=e.agents.find(c=>c.id===e.defaultAgent))==null?void 0:l.name)??e.defaultAgent,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"agent"}})}],[{id:"chat-side",label:"chat side",detail:e.chatSide,onClick:()=>n({a:"toggle-chat-side"})},...i.access==="none"?[]:[{id:"clipboard-offer",label:"offer what is copied",detail:i.access==="denied"?"blocked in site settings":i.on?"on":"off",onClick:()=>k4(!i.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep awake…",detail:wf[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>_8((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 N8(e,t,n,r,o,i={machines:[],switchTo:()=>{},forget:()=>{}}){const l=[],c=(g,w,y,b,_)=>l.push({id:g,label:w,hint:b,run:y,sub:_}),u=(g,w)=>{for(const y of g){if(!fs(y)||y.disabled!==void 0||y.checked)continue;const b=y.key??(typeof y.detail=="string"?y.detail:void 0),_=w?`${w.scope}:${y.id}`:y.id,T=y.topic?`${y.topic}: ${y.label}`:y.label;c(_,w?`${T} · ${w.name}`:T,y.onClick,b,y.sub)}},p={sock:n,dispatch:t},h=r,m=h==null?void 0:h.worktree.id;if(u(PN(e,p).filter(g=>!fs(g)||g.id!=="commands")),o&&u(ah(o,o.id,p),{scope:"project",name:o.name}),m&&!Ao(e)&&(c("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>Kc(m,e.picking,t,"chat"),zt("pick")),c("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>Kc(m,e.picking,t,"code"),zt("inspect")),c("reload","reload preview",()=>an.post(m,{type:"reload"}))),u(UN(e,p)),h&&m){const g=e.repos.find(w=>w.id===h.worktree.repoId)??null;u(s_(h,g,e,p,{hostname:e.hostname}),{scope:"wt",name:Mm(h,g)});for(const w of h.procs)u(hw(w,m,p))}e.visible.forEach((g,w)=>{var T;if(g.worktree.id===m)return;const y=g.worktree.variant,_=!!e.activeRepoId&&g.repoId!==e.activeRepoId?` in ${((T=e.repos.find(x=>x.id===g.repoId))==null?void 0:T.name)??g.repoId}`:"";c(`go:${g.worktree.id}`,`switch to ${Mm(g,o)}${y?` (v${y.index}/${y.of})`:""}${_}`,()=>t({a:"activate",id:g.worktree.id}),DC(w,e.visible.length))});for(const g of e.repos)g.id!==(o==null?void 0:o.id)&&c(`repo:${g.id}`,`switch to project ${g.name}`,()=>t({a:"activate-repo",id:g.id}));for(const g of i.machines){for(const w of g.repos)c(`machine:${g.origin}:${w.id}`,`switch to project ${w.name} on ${g.name}`,()=>i.switchTo(g.origin,w.id));c(`forget-machine:${g.origin}`,`forget ${g.name}`,()=>i.forget(g.origin))}return l}function HN(){const e=ut(),t=it(),{host:n}=Kr(),r=es(),o=sS(),i=M(ee=>ee.picking),l=M(ee=>ee.layout),c=M(ee=>ee.chatSide),u=M(ee=>ee.keepAwake),p=M(ee=>ee.railOpen),h=M(ee=>ee.themePrefs),m=M(ee=>ee.themes),g=M(ee=>ee.systemDark),w=M(ee=>ee.daylight),y=M(ee=>ee.rows),b=M(ee=>ee.visible),_=M(ee=>ee.activeId),T=M(ee=>ee.activeRepoId),x=M(ee=>ee.repos),N=M(ee=>ee.agents),j=M(ee=>ee.defaultAgent),$=M(ee=>ee.shipping),P=M(ee=>ee.remote),R=M(ee=>ee.managed),A=M(ee=>ee.frame),O=M(ee=>ee.self),D=M(ee=>ee.archivedPage),z=M(ee=>ee.archived),X=M(ee=>ee.knocks),ne=M(ee=>ee.tailscale);return S.useMemo(()=>{const ee={picking:i,layout:l,chatSide:c,keepAwake:u,railOpen:p,themePrefs:h,themes:m,systemDark:g,daylight:w,rows:y,visible:b,activeId:_,activeRepoId:T,repos:x,agents:N,defaultAgent:j,shipping:$,frame:A,self:O,archivedPage:D,archived:z,knocks:X,hostname:n},ie={machines:o,switchTo:(be,C)=>{var Z;(Z=r.get(be))==null||Z.store.dispatch({a:"activate-repo",id:C}),r.activate(be)},forget:be=>{const C=dg(r,be).find(Z=>fs(Z)&&Z.id.startsWith("forget-machine:"));C&&fs(C)&&C.onClick()}};return N8(ee,e,t,un(ee,_),Ei(ee,T),ie)},[i,l,c,u,p,h,m,g,w,y,b,_,T,x,N,j,$,P,R,A,O,D,z,X,ne,e,t,n,r,o])}function WN(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const i=hg(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 hg(e,t){const n=mw(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+(KN(e,l)?3:0),i=l;return r+Math.max(0,40-e.length/4)}const KN=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function mw(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(KN(n,c)){l=c;break}if(l===-1)return null;r.push(l),o=l+1}return r}const cs=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},T8=/^[^\s]*$/,j8=e=>e.split(/\s+/).slice(1).every(t=>!t||/[a-z0-9]/i.test(t));function wx(e,t,n){if(e.startsWith("!"))return null;if(e.startsWith("/")){const l=e.indexOf(" "),c=l===-1?e.length:l;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<c)&&t<=c)return{kind:"command",query:e.slice(1,t),from:0,to:c}}const r=e.lastIndexOf("@",Math.max(0,t-1));if(r===-1||r>=t||r>0&&!/\s/.test(e[r-1]??""))return null;const o=e.slice(r+1,t);if(!T8.test(o)&&!(j8(o)&&(n!=null&&n(o))))return null;let i=t;for(;i<e.length&&!/\s/.test(e[i]??"");)i++;return{kind:"file",query:o,from:r,to:i}}const _c=new Map,yx={files:new Set,folders:new Set,worktrees:_c},vx=new WeakMap;function C8(e,t=_c){if(!e)return t===_c?yx:{...yx,worktrees:t};let n=vx.get(e);return n||(n={files:new Set(e),folders:new Set(ME(e)),worktrees:_c},vx.set(e,n)),t===_c?n:{...n,worktrees:t}}const A8=/(^|\s)(@\S+)/g,I8=/[.,;:!?)\]}'"]$/;function bx(e,t){if(e==="changes")return{kind:"changes",text:"@changes"};if(t.files.has(e))return{kind:"file",text:`@${e}`,path:e};const n=e.replace(/\/+$/,"");if(n&&t.folders.has(n))return{kind:"folder",text:`@${e}`,path:n};const r=t.worktrees.get(e);return r?{kind:"worktree",text:`@${e}`,id:r.id,title:r.title}:null}function $8(e,t){const n=[];let r=0;const o=i=>{if(!i)return;const l=n.at(-1);(l==null?void 0:l.kind)==="text"?l.text+=i:n.push({kind:"text",text:i})};for(const i of e.matchAll(A8)){const l=i.index+(i[1]??"").length;let c=(i[2]??"").slice(1),u=bx(c,t);for(;!u&&I8.test(c);)c=c.slice(0,-1),u=c?bx(c,t):null;u&&(o(e.slice(r,l)),n.push(u),r=l+u.text.length)}return o(e.slice(r)),n}function R8(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function O8(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=>hg(i.name,n));return o.length>0?o:r(i=>hg(i.description,n))}function ZN(e,t,n){if(!t)return[];const r=[];for(const o of e){const i=o.worktree;i.repoId!==t||i.id===n||i.kind!=="worktree"||r.push({id:i.id,title:i.title,branch:i.branch,dir:i.path.slice(i.path.lastIndexOf("/")+1),dot:Is(o),at:la(i)})}return r}const xx=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function Ex(e,t){const n=xx(e);if(!n)return!0;const r=/\s$/.test(e);return[t.title,t.branch,t.id,t.dir].some(o=>{const i=xx(o);return i.includes(n)&&(!r||!i.endsWith(n))})}const M8=/(^|\s)@\S/;function qN({text:e,worktreeId:t,root:n,inField:r}){const o=Yn(),i=it(),l=M(w=>{var y;return t?(y=w.local[t])==null?void 0:y.files:void 0}),c=M(w=>w.visible),u=M(w=>{var y;return(y=un(w,t))==null?void 0:y.worktree.repoId}),p=S.useMemo(()=>{const w=new Map;for(const y of ZN(c,u,t))w.set(y.branch,{id:y.id,title:y.title});return w},[c,u,t]),h=S.useMemo(()=>C8(l,p),[l,p]),m=S.useMemo(()=>$8(e,h),[e,h]),g=l===void 0&&t&&M8.test(e)?t:null;return S.useEffect(()=>{g&&Vf(g,o.getState(),{sock:i,dispatch:o.dispatch})},[g,o,i]),d.jsx(d.Fragment,{children:m.map((w,y)=>{if(w.kind==="text")return w.text;if(w.kind==="changes"){const x=Ut("this worktree's uncommitted files",void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-changes":"",...x,children:w.text},y)}if(w.kind==="worktree"){const x=Ut(`the chat of "${w.title}"`,void 0,{placement:"follow"});return d.jsx("span",{className:"chat-mention","data-worktree":w.id,...x,children:w.text},y)}if(!n||!t)return w.text;const b=w.kind==="folder",_=`${n}/${w.path}${b?"/":""}`,T=Ut(b?`${w.path}/`:w.path,void 0,{placement:"follow"});return d.jsx("a",{className:"chat-mention",href:_,tabIndex:r?-1:void 0,...T,children:w.text},y)})})}function GN(e,t,n,r){var l;const o=e.target;if(o.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}const i=(l=o.closest("[data-worktree]"))==null?void 0:l.getAttribute("data-worktree");if(i){r.dispatch({a:"activate",id:i});return}Vk(e,t,n,r)}function P8(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:D8(e.map(t=>t[0].text))}const L8=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function D8(e,t=3){let n=[];for(const r of e){const o=z8(r);if(!o)return null;const i=F8(n,o);if(!i)return null;n=i}return n.some(r=>r.kind!=="same")?B8(n,t):null}function z8(e){const t=[];let n=null;for(const r of e.split(`
|
|
223
|
-
`)){const o=L8.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 F8(e,t){const n=[];let r=0,o=0,i=0,l=0;const c=h=>{h.kind==="same"?o=h.a-h.c:h.kind==="add"?o-=1:o+=1},u=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),c(e[r]),r++},p=h=>{for(let m=h;m<e.length;m++){const g=e[m];if(g.kind!=="del")return g.c}return Number.POSITIVE_INFINITY};for(const h of t){if(h.oldStart<=l)return null;for(;r<e.length;){const w=e[r];if((w.kind==="del"?p(r):w.c)>=h.oldStart)break;n.push(w.kind==="del"?w:{...w,c:w.c+i}),c(w),r++}let m=h.oldStart,g=h.newStart;for(const w of h.ops){if(u(),w.mark==="+"){n.push({kind:"add",c:g,text:w.text}),g++;continue}const y=e[r],b=y&&y.kind!=="del"&&y.c===m?y:void 0;if(b){if(b.text!==w.text)return null;r++,c(b),w.mark===" "?n.push({...b,c:g}):b.kind==="same"&&n.push({kind:"del",a:b.a,text:b.text})}else w.mark===" "?n.push({kind:"same",a:m+o,c:g,text:w.text}):n.push({kind:"del",a:m+o,text:w.text});w.mark===" "&&g++,m++}i=g-m,l=m-1}for(;r<e.length;r++){const h=e[r];n.push(h.kind==="del"?h:{...h,c:h.c+i})}return n}function B8(e,t){const n=[];for(const r of H8(e))for(const[o,i]of W8(r.rows,t)){const l=U8(r.rows.slice(o,i)),c=l.filter(m=>m.kind!=="add").length,u=l.filter(m=>m.kind!=="del").length,p=l.find(m=>m.kind!=="add"),h=l.find(m=>m.kind!=="del");n.push(`@@ -${p?p.a:r.oldAt[o]},${c} +${h?h.c:r.newAt[o]},${u} @@`,...l.map(m=>`${m.kind==="add"?"+":m.kind==="del"?"-":" "}${m.text}`))}return n.join(`
|
|
224
|
-
`)}function U8(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 H8(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 W8(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 pg({pieces:e}){return d.jsx(d.Fragment,{children:e.map((t,n)=>{const r=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return r?d.jsx("span",{className:r,children:t.text},n):d.jsx(S.Fragment,{children:t.text},n)})})}function gw({pick:e,worktreeId:t,tipText:n,onHover:r,onOpen:o,onRemove:i,className:l=""}){const c=e.callFile,u=e.file,p=c?{path:c,line:e.callLine}:u?{path:u,line:e.line}:null,h=c&&u?{path:u,line:e.line}:null,m=(x,N)=>`${x}${N?`:${N}`:""}`,g=x=>x.split("/").pop()??x,w=(x,N,j,$)=>o?d.jsx("button",{className:"pick-open","data-tip":$,onClick:()=>o(x,N??1),children:j}):j,y=yn("chat"),{host:b}=Kr(),_=S.useRef(null),T=i?()=>{r==null||r(!1),i()}:void 0;return d.jsxs("div",{ref:_,className:We("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(()=>E3(e,{remove:T,host:b})),children:[d.jsxs("span",{className:"pick-target",children:[d.jsx(Tt,{name:"pick",className:"icon-inline"})," ",ck(e),p&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",w(p.path,p.line,m(g(p.path),p.line),`Open ${m(p.path,p.line)}`)]}),h&&d.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",w(h.path,h.line,m(h.path.split("/").pop()??h.path,h.line),`Open the component: ${m(h.path,h.line)}`)]})]}),T&&d.jsx(Mt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:T}),t&&(p==null?void 0:p.line)&&d.jsx(B_,{chip:_,children:d.jsx(q8,{worktreeId:t,path:p.path,line:p.line})})]})}const K8=6,Z8=16;function q8({worktreeId:e,path:t,line:n}){const r=vk(),o=it(),i=M(m=>{var g;return((g=Oo(m))==null?void 0:g.id)===e}),l=M(m=>{var g;return i?0:(g=Ro(m,e).changedRanges[t])==null?void 0:g.offset}),[c,u]=S.useState(null);S.useEffect(()=>{let m=!0;return i||o==null||o.send({t:"changed-ranges",worktreeId:e,path:t}),r==null||r.look(e,t).then(g=>{m&&u(g)}),()=>{m=!1}},[r,o,e,t,i]);const p=S.useMemo(()=>{if(c===null||l===void 0)return null;const m=c.split(`
|
|
225
|
-
`),g=n-l,w=Math.max(1,g-K8),y=Math.min(m.length,g+Z8);if(w>y)return null;const b=m.slice(w-1,y);return{from:w,at:g,slice:b,painted:iw(b.join(`
|
|
226
|
-
`),sw("",t))}},[c,l,n,t]);if(!p)return null;const h=String(p.from+p.slice.length-1).length;return d.jsx("pre",{className:"pick-peek",children:p.slice.map((m,g)=>{const w=p.from+g,y=p.painted[g];return d.jsxs("span",{className:"pick-peek-line","data-state":w===p.at?"current":void 0,children:[d.jsx("span",{className:"pick-peek-n",children:String(w).padStart(h)}),y!=null&&y.length?d.jsx(pg,{pieces:y}):m||" "]},w)})})}function G8(e){return e.startsWith("!")?e.slice(1).trim():null}function kw(e){if(e.kind!=="tool"||e.name!==mi&&e.name!==u1)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function VN(e){var t;return e.kind!=="tool"||e.name!==mi||(t=e.input)!=null&&t.landing?null:kw(e)}function V8(e){return e.length>0&&e.every(t=>t.kind==="tool"&&VN(t)!==null&&t.done&&!t.isError)}function Y8(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=kw(o);if(i===null)continue;const l=AN(o.output??"").map(u=>u.text).join(`
|
|
227
|
-
`),c=F2(l);t.unshift(`$ ${i}${c?`
|
|
228
|
-
${c}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
|
|
229
|
-
${t.join(`
|
|
230
|
-
`)}`}const Sx={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 YN(e,t,n,r){const o=e[0];if(!o||!n)return[];const i=ih(xl(o),t);return i?i.startsWith("/")?[{label:"open",tip:Sx.file,open:()=>eg(r,n.id,{href:i,path:i})}]:[...wi(i)==="preview"?["preview"]:[],...o.toolKind==="edit"?["diff"]:[],"file"].map(c=>({label:`open ${c}`,tip:Sx[c],open:()=>er(r,{worktreeId:n.id,path:i,view:c})})):[]}const X8=(...e)=>YN(...e)[0]??null;function Q8(e,t,n,r,o){const{sock:i}=r,l=e[0];if(!l)return[];const c=[],u=ih(xl(l),t),p=YN(e,t,n,r).map(_=>({id:_.label.replace(" ","-"),label:_.label,onClick:_.open}));u&&!u.startsWith("/")&&n?c.push(...p,...Jo(()=>i==null?void 0:i.send({t:"reveal",worktreeId:n.id,path:u}),Qo(i))):u.startsWith("/")&&c.push(...p,...Jo(()=>i==null?void 0:i.send({t:"reveal-path",path:u}),Qo(i)));const h=[],m=xl(l);u&&m&&h.push({id:"copy-path",label:"copy path",onClick:()=>nn(m)});const g=Yc(l,t).command,w=qF(l);w&&w!==g&&h.push({id:"copy-description",label:"copy description",onClick:()=>nn(w)}),g&&h.push({id:"copy-command",label:"copy command",onClick:()=>nn(g)});const y=e.map(_=>_.output??"").filter(Boolean).join(`
|
|
231
|
-
`);y&&h.push({id:"copy-output",label:"copy output",onClick:()=>nn(y)});const b=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return zn([c,h,b])}const XN=e=>e.replace(/\n$/,""),J8=1500,_x=4;function QN(e){return e.closest(".md pre, .card-code pre")}function mg(e){const t=QN(e);return t?XN(t.textContent??""):null}function e9(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+_x,right:n.left+e.clientLeft+e.clientWidth-r.right+_x}}function ww(e){const[t,n]=S.useState(null),[r,o]=S.useState(null);if(S.useEffect(()=>{const p=e.current;if(!p)return;const h=g=>{if(!(g.target instanceof Element)||g.target.closest(".code-copy"))return;const w=QN(g.target);n(w&&p.contains(w)?e9(p,w):null)},m=()=>n(null);return p.addEventListener("pointerover",h),p.addEventListener("pointerleave",m),()=>{p.removeEventListener("pointerover",h),p.removeEventListener("pointerleave",m)}},[e]),S.useEffect(()=>{if(!r)return;const p=setTimeout(()=>o(null),J8);return()=>clearTimeout(p)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:i,top:l,right:c}=t,u=r===i;return d.jsx(Mt,{className:"code-copy",style:{top:l,right:c},icon:u?"check":"copy",label:u?"Copied":"Copy code",onClick:()=>{nn(XN(i.textContent??"")),o(i)}})}function t9(e){for(const t of e.split(`
|
|
232
|
-
`)){const n=/^#{1,6}\s+(.+?)\s*#*\s*$/.exec(t);if(n)return n[1];if(t.trim()&&!t.startsWith("<!--"))return null}return null}function n9(e){return e.slice(e.lastIndexOf("/")+1).replace(/\.md$/,"")}function JN(e,t){var c;const n=vk(),r=(c=Rt(e,"git"))==null?void 0:c.version,[o,i]=S.useState(null);return ft([n,e,t,r],()=>{if(!n||!e||!t)return;let u=!0;return n.look(e,t).then(p=>{u&&i({plan:t,title:p?t9(p):null})}),()=>{u=!1}}),(o&&o.plan===t?o.title:null)??(t?n9(t):"")}function lm({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:i}){const l=sh(e,{fileRoot:o,streaming:i}),c=it(),u=ut(),p=yn("chat"),h=S.useRef(null);cS(h,l);const m=M(y=>{var b;return r?(b=y.local[r])==null?void 0:b.refusedLink:void 0});ft([l,m],()=>{var b;const y=h.current;if(y)for(const _ of y.querySelectorAll("a.file-link, code[data-path]")){const T=_.getAttribute("href")??_.dataset.path,x=m!==void 0&&T===m.href;_.classList.toggle("file-link-refused",x),x?((b=_.dataset).tipWas??(b.tipWas=_.dataset.tip??""),_.dataset.tip=m.message,_.dataset.tipPlacement="bottom",_.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):_.dataset.tipWas!==void 0&&(_.dataset.tipWas?(_.dataset.tip=_.dataset.tipWas,_.dataset.tipPlacement="follow"):(delete _.dataset.tip,delete _.dataset.tipPlacement),delete _.dataset.tipWas)}});const g=S.useRef(null),w=ww(g);return d.jsxs("div",{ref:g,className:"msg-assistant md row-edge","data-state":dr({cursor:n}),...p.contextMenu((y,b)=>t(Gk(b,o),mg(b))),onClick:y=>Vk(y,o,r,{sock:c,dispatch:u}),children:[d.jsx("div",{ref:h}),w]})}const cm=40;function eT(e,t){return e.map(n=>{const r=sw(n.lang,t||(n.diff?fF(n.text):""));if(n.diff){const o=QF(n.text);return{...n,lines:o,painted:mF(o,r)}}return{...n,lines:[],painted:n.code?iw(n.text,r):[]}})}function tT({blocks:e,path:t,worktreeId:n}){it();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,cm).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(pg,{pieces:o.painted[c]}):l.text||" "},c)}),o.lines.length>cm&&d.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&er({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-cm," more lines"]})]},i):o.code?d.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((l,c)=>d.jsxs(S.Fragment,{children:[c>0?`
|
|
233
|
-
`:null,d.jsx(pg,{pieces:l})]},c)):o.text},i):d.jsx("p",{className:"tool-note",children:o.text},i))})}function r9({image:e,worktreeId:t}){const n=Kr().attachment(t,e.file),r={worktreeId:t,file:e.file,sock:it()},[o,i]=S.useState(!1),l=yn("chat");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"tool-image","data-tip":"Open full size","data-tip-placement":"follow",onClick:()=>i(!0),...l.contextMenu(()=>Gc(n,{open:()=>i(!0)},r)),children:d.jsx("img",{src:n,alt:e.file})}),o&&d.jsx(Zk,{owner:"chat",onClose:()=>i(!1),menu:()=>Gc(n,{},r),children:d.jsx("img",{src:n,alt:e.file})})]})}const o9=S.memo(function({item:t,roots:n,worktreeId:r}){const o=S.useMemo(()=>eT(cg(t,t.output??""),xl(t)),[t]),i=Yc(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(tT,{blocks:o,path:nT(t,n),worktreeId:r}),l.length>0&&r&&d.jsx("div",{className:"tool-out",children:l.map(c=>d.jsx(r9,{image:c,worktreeId:r},c.file))})]})});function nT(e,t){const n=ih(xl(e),t??[]);return n.startsWith("/")?"":n}const s9=S.memo(function({text:t,item:n,roots:r,worktreeId:o}){const i=xl(n),l=S.useMemo(()=>eT([{code:!0,diff:!0,lang:"diff",text:t}],i),[t,i]);return d.jsx("div",{className:"tool-part",children:d.jsx(tT,{blocks:l,path:nT(n,r),worktreeId:o})})});function gg({className:e,state:t,auto:n,leaf:r,growing:o,label:i,summary:l,menu:c,children:u}){const[p,h]=S.useState(null),m=S.useRef(null),g=S.useRef(null),w=lS(g),y=BL(".chat-log"),b=!r&&(p??n),_=()=>{r||(b||y(m.current),h(!b))},T=yn("chat");return d.jsxs("details",{ref:m,className:We(e,r&&"leaf"),"data-state":t,open:b,onToggle:x=>{if(!x.currentTarget.open||o)return;const N=g.current;N&&(N.scrollTop=0,w.read())},...T.contextMenu((x,N)=>c({open:b,leaf:!!r,toggle:_},N)),tabIndex:-1,onPointerDown:()=>{var x;return(x=m.current)==null?void 0:x.focus({preventScroll:!0})},onKeyDown:x=>{if((x.key==="ArrowLeft"||x.key==="ArrowRight")&&!r){if(x.shiftKey||x.altKey||x.metaKey||x.ctrlKey)return;eh([{depth:0,open:b}],0,x.key)&&_();return}x.key!=="Escape"||!b||(x.stopPropagation(),h(!1))},children:[d.jsx("summary",{"aria-label":i,tabIndex:r?-1:void 0,onClick:x=>{x.preventDefault(),_()},children:l}),d.jsx("div",{className:"tool-body",ref:g,children:u})]})}const i9=S.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:i}){const l=xN(t.text),c=l.slice(0,-1),u=sh(l.length?c.join(`
|
|
234
|
-
|
|
235
|
-
`):vN(t.text),i||r?{fileRoot:i,streaming:r}:void 0),p=it(),h=ut(),m=r?"Thinking":"Thought",g=S.useRef(null);cS(g,u);const w=S.useRef(null),y=ww(w),b=d.jsx("div",{className:"tool-part",children:d.jsxs("div",{ref:w,className:"tool-out thought-out md",onClick:T=>Vk(T,i,o,{sock:p,dispatch:h}),children:[d.jsx("div",{ref:g}),y]})}),_=l.at(-1)??(r?"":EN(t.text));if(_){const T=c.length===0;return d.jsx(gg,{className:"tool-row",auto:!1,leaf:T,growing:r,label:_,menu:(x,N)=>zn([tg(mg(N)),[{id:"copy",label:"copy thought",onClick:()=>nn(t.text)}],...T?[]:[[{id:"fold",label:x.open?"collapse":"expand",onClick:x.toggle}]]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(Tt,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:We("tool-hint thought-line",r&&"live-text"),children:_})]}),children:T?null:b})}return d.jsx(gg,{className:"tool-row",auto:!!n,growing:r,label:m,menu:(T,x)=>zn([tg(mg(x)),[{id:"copy",label:"copy thought",onClick:()=>nn(t.text)}],[{id:"fold",label:T.open?"collapse":"expand",onClick:T.toggle}]]),summary:d.jsxs(d.Fragment,{children:[d.jsx(Tt,{name:"bulb",className:"tool-icon"}),d.jsx("span",{className:We("tool-name",r&&"live-text"),children:m})]}),children:b})}),Vi=6,a9={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},Ld=S.memo(function e({tools:t,run:n,next:r,live:o,working:i,held:l,since:c,queued:u,roots:p,worktreeId:h,marked:m}){const g=t[0],w=S.useMemo(()=>P8(t.map(ke=>cg(ke,ke.output??""))),[t]),y=t.at(-1)??g,b=!y.done,_=b&&!!y.background,x=(b||!!r||!!l)&&!u||!!i,N=b&&!!u,j=oa(b||i?c:void 0),$=n?c8(n):-1,P=S.useMemo(()=>n?RN(n,!0):void 0,[n]),R=!!o,A=Yc(g,p),O=b?ZF(g):"",{label:D,icon:z}=A,X=jN(g),ne=O?"":X?"Guardian":A.name,ee=O&&g.subagent?A.hint:"",ie=ee||O||(X?UF(g.output??""):A.hint),be=!(n&&n.length>0)&&!w&&t.every(ke=>{var ae;return!Yc(ke,p).command&&cg(ke,ke.output??"").length===0&&!((ae=ke.images)!=null&&ae.length)}),C=n?s8(n):0,Z=V8(t),Y=[D,ie].filter(Boolean).join(" ")+(_?", in the background":"")+(N?", queued":"")+(Z?", done":""),q=O?"":n?`${C} ${C===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",F=Yn(),re=it(),Ee=M(ke=>{var ae;return h?(ae=ke.shipping[h])==null?void 0:ae.op:void 0}),Te=b&&g.name===mi&&h?{worktreeId:h,toolId:y.id}:null,de=b?null:(()=>{const ke=un(F.getState(),h);return X8(t,p??[],ke?{id:ke.worktree.id}:null,{sock:re,dispatch:F.dispatch})})();return d.jsxs(gg,{className:We("tool-row",t.some(ke=>ke.isError)&&"error",g.parentToolId&&"nested",n&&"spawn",N&&"queued"),state:dr({cursor:m}),auto:R,leaf:be,growing:x,label:n&&q?`${Y}, ${q}`:t.length>1?`${Y}, ${t.length} calls`:Y,menu:ke=>{const ae=un(F.getState(),h),G=ae?{id:ae.worktree.id}:null;return Q8(t,p??[],G,{sock:re,dispatch:F.dispatch},ke)},summary:d.jsxs(d.Fragment,{children:[d.jsx(Tt,{name:n?"spawn":z,className:"tool-icon"}),ne&&d.jsx("span",{className:We("tool-name",x&&!ie&&"live-text"),children:ne}),O&&!ee?d.jsx("span",{className:"tool-writing","data-tip":ie,children:d.jsx(vl,{variant:"squares"})}):ie&&d.jsx("span",{className:We("tool-hint",x&&"live-text"),children:ie}),_&&d.jsx("span",{className:"tool-status",children:"in the background"}),N&&d.jsx("span",{className:"tool-status",children:"queued"}),Z&&d.jsx(Tt,{name:"check",className:"tool-done"}),j>=Vi&&d.jsx("span",{className:We("tool-age",$>=0&&"tool-age-folded"),children:Qi(j)}),q&&d.jsx("span",{className:"tool-count",children:q}),ee&&d.jsx("span",{className:"tool-writing","data-tip":O,children:d.jsx(vl,{variant:"squares"})}),Te&&d.jsx(Mt,{icon:"stop",className:"tool-stop",label:Ee?`Stop ${a9[Ee]}: this step is killed, and what it printed so far stays`:_?"Kill what the command left running; what it printed so far stays":"Kill the command and everything it started; what it printed so far stays",onClick:ke=>{ke.preventDefault(),ke.stopPropagation(),re==null||re.send({t:"exec-stop",...Te})}}),de&&d.jsx(Mt,{icon:"eye",className:"tool-open",label:de.tip,onClick:ke=>{ke.preventDefault(),ke.stopPropagation(),de.open()}})]}),children:[n&&n.length>0&&d.jsx("div",{className:"spawn-run",children:n.map((ke,ae)=>d.jsx(e,{tools:ke.tools,next:ke.next,since:ae===$?c:void 0,queued:P==null?void 0:P.has(ae),roots:p,worktreeId:h},ke.at))}),w?d.jsx(s9,{text:w,item:g,roots:p,worktreeId:h}):t.map(ke=>d.jsx(o9,{item:ke,roots:p,worktreeId:h},ke.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&&uw(e.tools,t.tools)&&ON(e.run,t.run));function l9({item:e}){const t=it(),n=ut(),r=M(b=>b.activeId),o=M(b=>b.layout.term),i=M(b=>{var _;return((_=b.rows.find(T=>T.id===b.activeId))==null?void 0:_.login)??!1}),l=M(b=>b.managed.problem),[c,u]=S.useState(""),[p,h]=S.useState(null),m=S.useRef(!1);if(ft([i],()=>{i&&m.current&&r&&n({a:"term-stream",id:r,stream:Cs,tall:!0})}),ft([e.done],()=>{e.done&&m.current&&o&&n({a:"toggle-terminal"}),m.current=!1}),!r)return null;const g=e.provider==="aws",w=(b,_)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:b,..._?{apiKey:_}:{}})},y=e.methods.find(b=>b.id===p);return d.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[d.jsx("div",{className:"auth-title","data-tip":e.done?void 0:e.detail,children:e.done?`${e.agentName} is logged in`:e.provider==="aws"?`${e.agentName}'s AWS session expired`:e.rejected?`${e.agentName}'s credentials were refused`:`${e.agentName} is not logged in`}),!e.done&&d.jsxs("div",{className:"auth-methods",children:[e.methods.map((b,_)=>b.needsKey?d.jsx(Fe,{variant:"outline",on:p===b.id,"data-tip":b.description,onClick:()=>h(p===b.id?null:b.id),children:b.name},b.id):d.jsx(Fe,{variant:"outline",tone:g&&_===0?"primary":void 0,"data-tip":b.kind==="terminal"&&!b.description?"opens in the terminal pane":b.description,onClick:()=>{w(b.id),b.kind==="terminal"&&(m.current=!0)},children:b.name},b.id)),d.jsx(Fe,{variant:g?"ghost":"outline",tone:g?"quiet":void 0,"data-tip":"after logging in elsewhere (the terminal, another window)",onClick:()=>t==null?void 0:t.send({t:"agent-retry",worktreeId:r}),children:"send again"})]}),!e.done&&i&&d.jsx("div",{className:"hint auth-hint",children:e.provider==="aws"?"the login tab below opens the browser to sign in. Your message sends once you are in.":"paste the code into the login tab below and press Enter; it stays hidden as you paste. Your message sends once you are in."}),!e.done&&e.refresh&&d.jsxs("div",{className:"hint auth-hint",children:["your Claude settings refresh it with ",d.jsx("code",{children:e.refresh}),", which got no session this time"]}),!e.done&&e.withheld&&d.jsx("div",{className:"hint auth-hint",children:l?"the policy file on this machine is invalid, so signing in with a Claude plan is off until it is fixed; toyon doctor says why":"signing in with a Claude plan is managed by your organization"}),!e.done&&y&&d.jsxs("form",{className:"auth-key",onSubmit:b=>{b.preventDefault(),c.trim()&&(w(y.id,c.trim()),u(""),h(null))},children:[d.jsx(Io,{type:"password",autoFocus:!0,placeholder:`${y.name} for ${e.agentName}`,value:c,onChange:b=>u(b.target.value)}),d.jsx(Fe,{type:"submit",children:"use key"})]})]})}const c9=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:i}){const l=Yn(),c=it(),u=Kr(),p=yn("chat"),h={sock:c,dispatch:l.dispatch},m=()=>{var g;return(g=un(l.getState(),n))==null?void 0:g.worktree.path};switch(t.kind){case"user":{const g=m();return d.jsxs("div",{className:"msg-user row-edge","data-state":dr({cursor:o}),...p.contextMenu((w,y)=>Zi(t,n??null,h,{link:Gk(y,g)})),onClick:w=>GN(w,g,n,h),children:[t.attachments&&n&&d.jsx(rh,{children:d.jsx("div",{className:"msg-attachments",children:t.attachments.map(w=>w.kind==="image"?d.jsx(k8,{img:w,worktreeId:n,src:u.attachment(n,w.file)},`${w.kind}-${w.n}`):w.kind==="file"?d.jsx(lw,{className:"in-chat",name:w.name,bytes:w.bytes,href:w.text?u.attachment(n,w.file):void 0,kept:{worktreeId:n,file:w.file}},`${w.kind}-${w.n}`):w.kind==="paste"?d.jsx(aw,{className:"in-chat",n:w.n,name:w.name,source:w.source,lines:w.lines,chars:w.chars,preview:w.preview,href:u.attachment(n,w.file)},`${w.kind}-${w.n}`):d.jsx(gw,{pick:w,className:"in-chat",tipText:"Hover to highlight on the page",onHover:y=>r==null?void 0:r(w,y),worktreeId:n,onOpen:(y,b)=>ia(l,c,n,y,b)},`${w.kind}-${w.n}`))})}),d.jsx(qN,{text:t.text,worktreeId:n,root:g})]})}case"assistant":return d.jsx(lm,{text:t.text,menu:(g,w)=>Zi(t,n??null,h,{link:g,code:w}),marked:o,worktreeId:n,fileRoot:m(),streaming:i});case"error":return d.jsx("div",{className:"msg-assistant msg-error",...p.contextMenu(()=>Zi(t,n??null,h)),children:t.text});case"auth":return d.jsx(l9,{item:t});case"ask":{const g=TP(t);if(g){const _=nk(g.questions,g.answers).join(`
|
|
236
|
-
`),T={kind:"assistant",text:_};return d.jsxs(d.Fragment,{children:[d.jsx(lm,{text:g.message,menu:(x,N)=>Zi({kind:"assistant",text:g.message},n??null,h,{link:x,code:N}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user row-edge","data-state":dr({cursor:o}),...p.contextMenu(()=>Zi(T,n??null,h)),children:_})]})}const w=CP(t);if(!w)return d.jsx(O3,{item:t});const y=w.file,b={kind:"assistant",text:w.choice};return d.jsxs(d.Fragment,{children:[y?d.jsx(u9,{file:y,worktreeId:n}):w.text&&d.jsx(lm,{text:w.text,menu:(_,T)=>Zi({kind:"assistant",text:w.text},n??null,h,{link:_,code:T}),worktreeId:n,fileRoot:m()}),d.jsx("div",{className:"msg-user",...p.contextMenu(()=>Zi(b,n??null,h)),children:w.choice})]})}case"blocked":return d.jsxs(no,{icon:"lock",word:"blocked",tone:"red",below:d.jsx("div",{className:"daemon-below row-dim",children:t.reason}),...p.contextMenu(()=>Kk(t.path,void 0,Qo(h.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(no,{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(no,{icon:"send",word:"asked",tone:"quiet",children:d.jsx("span",{className:"daemon-text",children:t.why})});case"stopped":return d.jsx(no,{icon:"stop",word:"stopped",tone:"quiet"});case"landed":return d.jsx(f9,{item:t});case"handoff":return d.jsx(m8,{item:t});case"handoff-landed":return d.jsx(g8,{item:t});case"restored":return d.jsx(d9,{item:t});case"adopted":return d.jsx(no,{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 u9({file:e,worktreeId:t}){const n=it(),r=ut(),o=yn("chat"),i=JN(t??void 0,e);return d.jsx(no,{icon:"file",word:"plan",tone:"quiet",...o.contextMenu(()=>Kk(e,t?()=>n==null?void 0:n.send({t:"reveal",worktreeId:t,path:e}):void 0,Qo(n))),children:d.jsx("span",{className:"daemon-text",children:d.jsx(Fe,{variant:"inline",tone:"strong","data-tip":e,onClick:()=>t&&er({dispatch:r},{worktreeId:t,path:e,view:"preview"}),children:i})})})}function d9({item:e}){return d.jsx(no,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:d.jsxs("span",{className:"daemon-text",children:["after ",uk(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function f9({item:e}){const t=it(),n=ut(),r=M(l=>e.archiveIds.filter(c=>un(l,c)!==null).length),o=__(e.ts),i=e.mark&&Lk(e.mark);return d.jsxs(no,{icon:"check",word:"landed",tone:"aqua",at:e.ts,below:i?d.jsx("div",{className:"daemon-below row-dim",children:Wr(i)}):void 0,children:[d.jsxs("span",{className:"daemon-text",children:[e.text,", ",o]}),r>0&&d.jsx(Fe,{variant:"inline",tone:"strong",onClick:()=>sa(t,n,e.archiveIds),children:r>1?`archive ${r} worktrees`:"archive the other worktree"})]})}const rT=e=>e===""||e==="!";function Nx(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const i=e[o],l=VN(i),c=l!==null?`!${l}`:t?null:i.kind==="user"?i.text:i.kind==="ask"?jP(i):null;c===null||!c.trim()||n.has(c)||(n.add(c),r.push({text:c,at:o}))}return r}function h9(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!rT(n))return null;const c=Nx(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=Nx(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 p9(e,t,n,r){const o=new Map;return{rows:t.map((l,c)=>{const u=n(l,c),p=e.get(l.at),h=p&&p.row.kind===u.kind&&m9(p.row.props,u.props)?p.el:r(l,u);return o.set(l.at,{row:u,el:h}),h}),cache:o}}function m9(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 Tx={get current(){return Rc.el}};function kg({items:e,next:t,worktreeId:n,onOpen:r}){const o=Kr();return d.jsx(rh,{children:d.jsx("div",{className:"msg-attachments",children:Lg(e,t).map(([i,l])=>i.kind==="image"?d.jsx(dw,{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(lw,{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(aw,{className:"in-chat",n:l,name:i.name,source:i.source,...Yg(i.text),text:i.text},`paste-${l}`):d.jsx(gw,{className:"in-chat",pick:i,worktreeId:n,onOpen:r},`pick-${l}`))})})}function g9({entry:e,next:t,worktreeId:n,onOpen:r}){const o=ut(),i=Rt(e.id,"draft"),l=Rt(e.id,"attachments");return d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(Tt,{name:"clock",className:"icon-inline"}),d.jsx("span",{className:"live-text",children:"uploading"})]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Mt,{icon:"edit",label:"Edit: puts it back in the input",onClick:()=>o({a:"unsend",id:e.id})}),d.jsx(Mt,{icon:"close",label:"Remove: it is not sent",onClick:()=>o({a:"drop-out",id:e.id})})]}),d.jsxs("div",{className:"queued-text",children:[l.length>0&&d.jsx(kg,{items:l,next:t,worktreeId:n,onOpen:r}),i]})]})}const k9=new Set,w9=90;function um({active:e,archived:t,found:n,lead:r,tail:o}){var Jt;const i=it(),l=Yn(),c=ut(),u=M(ye=>ye.frame==="phone"),p=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,h=Rt(p,"chat"),m=Rt(p,"queue"),g=Rt(p,"sending"),w=S.useMemo(()=>Em(h.map(ye=>ye.kind==="user"?ye.attachments:void 0)),[h]),y=S.useMemo(()=>{let ye=w;return m.map(Ae=>{const Yt=ye;return ye=jc(ye,Ae.attachments??[]),Yt})},[m,w]),b=M(ye=>ye.outbox),_=S.useMemo(()=>{let ye=m.reduce((Ae,Yt)=>jc(Ae,Yt.attachments??[]),w);return b.filter(Ae=>Ae.log===p).map(Ae=>{const Yt=ye;return ye=jc(ye,Ae.kinds.map(B=>({kind:B}))),{entry:Ae,next:Yt}})},[b,p,m,w]),T=g!=null&&g.message?m.findIndex(ye=>{var Ae;return ye.text===((Ae=g.message)==null?void 0:Ae.text)}):-1,x=S.useRef(null);c3(x);const[N,j]=S.useState(null),$=S.useCallback(()=>{const ye=(x.current&&Jm(x.current))??"";j(Ae=>({seed:ye||(Ae==null?void 0:Ae.seed)||"",seq:((Ae==null?void 0:Ae.seq)??0)+1}))},[]),P=S.useCallback(ye=>!(ye!=null&&ye.closest("[data-pane]"))&&!l.getState().overlay,[l]);I_(Tx,Hk,$,P);const R=ye=>{if(j(null),ye){const Ae=window.getSelection();Ae==null||Ae.removeAllRanges(),Ae==null||Ae.addRange(ye)}},A=lS(x,h);ft([p],()=>A.jump());const O=A.offStart&&A.moving==="up",D=A.offEnd&&(A.moving==="down"||A.away),z=ye=>ye.preventDefault(),X=(O||D)&&d.jsxs("div",{className:We("jump",A.away&&"jump-news"),children:[O&&d.jsx("button",{className:"jump-up",onMouseDown:z,onClick:A.start,"data-tip":"Jump to start",children:d.jsx(Tt,{name:"caret-up",className:"icon-inline"})}),D&&d.jsxs("button",{className:"jump-down",onMouseDown:z,onClick:A.jump,"data-tip":"Jump to latest",children:[d.jsx(Tt,{name:"caret",className:"icon-inline"}),A.away&&" new messages"]})]});S.useEffect(()=>{const ye=x.current;if(!u||!A.offEnd||!ye){c({a:"reading",on:!1});return}const Ae=()=>{var B,me;const Yt=((me=(B=Tx.current)==null?void 0:B.querySelector(":scope > .chat-input"))==null?void 0:me.offsetHeight)??0;ye.scrollHeight-ye.scrollTop-ye.clientHeight<=Yt+qd+w9||(c({a:"reading",on:!0}),ye.removeEventListener("scroll",Ae))};return Ae(),ye.addEventListener("scroll",Ae,{passive:!0}),()=>ye.removeEventListener("scroll",Ae)},[u,A.offEnd,c]),S.useEffect(()=>()=>c({a:"reading",on:!1}),[c]);const ne=Rt(p,"mark"),ee=(ne==null?void 0:ne.by)==="walk"?ne.at:void 0,ie=S.useRef(null),be=()=>{const ye=x.current,Ae=ye==null?void 0:ye.querySelector(':scope > [data-state~="cursor"]');if(!ye||!Ae)return;const Yt=parseFloat(getComputedStyle(ye).paddingTop)||0;ye.scrollTop+=Ae.getBoundingClientRect().top-ye.getBoundingClientRect().top-Yt,A.read()};ft([ee],()=>{const ye=x.current;if(ye){if(ee===void 0){const Ae=ie.current;if(ie.current=null,!Ae||!rT(Ro(l.getState(),p).draft))return;Ae.bottom?A.jump():(ye.scrollTop=Ae.top,A.read());return}ie.current??(ie.current={bottom:A.pinned(),top:ye.scrollTop}),be()}});const C=Rt(p,"sent");ft([C],()=>{C&&A.jump()});const Z=_.length,Y=S.useRef(Z);ft([Z],()=>{Z>Y.current&&A.jump(),Y.current=Z});const q=(ne==null?void 0:ne.by)==="reveal"?ne:void 0,F=S.useMemo(()=>q?p8(h,q.seq):-1,[h,q]),re=ee??(F>=0?F:void 0);ft([q==null?void 0:q.n,F],()=>{F>=0&&be()});const Ee=S.useCallback((ye,Ae)=>{p&&(Ae?an.post(p,{type:"highlight-selector",selector:ye.selector,label:ck(ye)}):an.post(p,{type:"highlight-clear"}))},[p]),Te=$o(e==null?void 0:e.agent),de=Rt(p,"cardParked"),ke=S.useMemo(()=>{const ye=$k(h);return!!ye&&de!==ye.id},[h,de]),ae=e==null?void 0:e.worktree,G=(ae==null?void 0:ae.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),ue=S.useMemo(()=>G?[G]:[],[G]),Le=S.useMemo(()=>o8(h,ue),[h,ue]),ge=S.useMemo(()=>Te?i8(h):k9,[Te,h]),oe=S.useMemo(()=>a8(Le,ge),[Le,ge]),we=oe.floating,Ce=S.useRef([]),Se=S.useMemo(()=>(Ce.current=u8(Ce.current,oe.flow),Ce.current),[oe]),_e=(e==null?void 0:e.agent)==="working",Be=_e||(e==null?void 0:e.agent)==="waiting",wt=S.useMemo(()=>Be?f8(Se):-1,[Be,Se]),on=Se.at(-1),Et=_e&&on&&"item"in on&&(on.item.kind==="thinking"||on.item.kind==="assistant")?Se.length-1:-1,Vt=(Jt=Le.findLast(ye=>{var Ae;return"tools"in ye&&((Ae=ye.tools[0])==null?void 0:Ae.name)===mi}))==null?void 0:Jt.at,Ft=Rt(p,"chatAt"),Ht=oa(Te?Ft:void 0),Me=Rt(p,"usage"),St=(Me==null?void 0:Me.heard)!==void 0&&Ft!==void 0&&Me.heard>Ft?Me.heard:void 0,sn=oa(Te?St:void 0),ln=oa(g&&!Te?g.at:void 0),lt=l8(h),jt=we.length>0,Kt=Et>=0||lt||jt,xn=_e&&!Kt&&Ht<Vi?n8(Se,ue):-1,Dt=S.useMemo(()=>RN(Se),[Se]),jn=Rt(p,"running"),Qt=ye=>jn&&ye.tools.some(Ae=>Ae.id===jn.id)?jn.at:void 0,V=e==null?void 0:e.worktree.path,pe=ye=>`${p??""}:${ye}`,Ye=(ye,Ae)=>"spawn"in ye?{kind:"tool",props:{tools:[ye.spawn],run:ye.run,roots:ue,worktreeId:p}}:"tools"in ye?{kind:"tool",props:{tools:ye.tools,next:ye.next,live:Ae===wt||ye.at===Vt,held:Ae===xn,since:Qt(ye),queued:Dt.has(Ae),roots:ue,worktreeId:p,marked:ye.at===re}}:ye.item.kind==="thinking"?{kind:"thought",props:{item:ye.item,open:Ae===wt,streaming:Ae===Et,worktreeId:p,fileRoot:V}}:{kind:"item",props:{item:ye.item,worktreeId:p,onPickHover:Ee,marked:ye.at===re,streaming:_e&&Ae===Se.length-1}},nt=S.useRef(new Map),yt=p9(nt.current,Se,Ye,(ye,Ae)=>Ae.kind==="tool"?d.jsx(Ld,{...Ae.props},pe(ye.at)):Ae.kind==="thought"?d.jsx(i9,{...Ae.props},pe(ye.at)):d.jsx(c9,{...Ae.props},pe(ye.at)));return nt.current=yt.cache,d.jsxs("div",{className:"chat-wrap",children:[d.jsxs("div",{className:"chat-log",ref:x,children:[r,yt.rows,we.map(ye=>{var Ae;return"spawn"in ye?d.jsx(Ld,{tools:[ye.spawn],run:ye.run,working:!0,since:Ft,roots:ue,worktreeId:p},pe(ye.at)):((Ae=ye.tools[0])==null?void 0:Ae.name)===mi?d.jsx(Ld,{tools:ye.tools,live:ye.at===Vt,since:Qt(ye),roots:ue,worktreeId:p,marked:ye.at===re},pe(ye.at)):d.jsx(Ld,{tools:ye.tools,since:Ft,roots:ue,worktreeId:p},pe(ye.at))}),p&&(g==null?void 0:g.message)&&d.jsxs("div",{className:"msg-user",children:[g.message.attachments&&d.jsx(kg,{items:g.message.attachments,next:w,worktreeId:p,onOpen:(ye,Ae)=>ia(l,i,p,ye,Ae)}),g.message.text]}),e&&(g||Te&&!(e.agent==="waiting"&&ke)&&!lt&&!jt&&xn<0&&!(Kt&&Ht<Vi))&&d.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":Kt?Ht>=Vi&&d.jsxs("span",{children:["quiet for",d.jsx("span",{className:"working-num",children:Qi(Ht)})]}):d.jsxs("span",{className:"working-mark",children:[d.jsx(vl,{variant:"squares"}),!Te&&g?ln>=Vi&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the agent"}),d.jsx("span",{className:"working-num",children:Qi(ln)})]}):St!==void 0?sn>=Vi&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"thinking"}),d.jsx("span",{className:"working-num",children:Qi(sn)})]}):Ht>=Vi&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"working-word",children:"waiting for the model"}),d.jsx("span",{className:"working-num",children:Qi(Ht)})]})]})}),p&&m.map((ye,Ae)=>Ae===T?null:d.jsxs("div",{className:"msg-user queued-msg",children:[d.jsxs("span",{className:"queued-tag",children:[d.jsx(Tt,{name:"clock",className:"icon-inline"}),"queued"]}),d.jsxs("span",{className:"queued-actions",children:[d.jsx(Mt,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>AS(l,i,p,Ae)}),d.jsx(Mt,{icon:"close",label:"Remove from queue",onClick:()=>i==null?void 0:i.send({t:"unqueue",worktreeId:p,index:Ae})})]}),d.jsxs("div",{className:"queued-text",children:[ye.attachments&&d.jsx(kg,{items:ye.attachments,next:y[Ae]??w,worktreeId:p,onOpen:(Yt,B)=>ia(l,i,p,Yt,B)}),ye.text]})]},`q-${Ae}`)),p&&_.map(({entry:ye,next:Ae})=>d.jsx(g9,{entry:ye,next:Ae,worktreeId:p,onOpen:(Yt,B)=>ia(l,i,p,Yt,B)},ye.id)),o]}),N&&d.jsx(C_,{root:x,body:x,seed:N.seed,seq:N.seq,onClose:R,onReveal:A.read}),X]})}function y9(){try{return localStorage.getItem(Ge.installOffered)==="1"}catch{return!1}}let yf={prompt:null,offered:typeof localStorage<"u"&&y9()};const wg=new Set;function yg(e){yf={...yf,...e};for(const t of wg)t()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),yg({prompt:e})}),window.addEventListener("appinstalled",()=>yg({prompt:null})));function oT(e){return wg.add(e),()=>{wg.delete(e)}}function sT(){return S.useSyncExternalStore(oT,()=>yf.prompt)}function v9(){return S.useSyncExternalStore(oT,()=>yf.offered)}function jx(){try{localStorage.setItem(Ge.installOffered,"1")}catch{}yg({offered:!0})}function b9(e){return!e.prompt||e.offered||e.agent!=="idle"?!1:e.chat.some(t=>t.kind==="assistant")}function iT({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(Yo,{k:r}),o]},r)),t&&d.jsx("span",{className:"key-note",children:t})]})}const x9={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function E9({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:i,empty:l,note:c,groupOf:u,groupHead:p}){const h=new Set(u?e.map(u):[]);return d.jsxs(Rs,{className:"inline-picker",anchor:"parent",placement:x9,children:[d.jsxs("div",{className:"picker-list",ref:i,children:[e.map((m,g)=>{const w=u==null?void 0:u(m),y=w!==void 0&&h.size>1&&(g===0||(u==null?void 0:u(e[g-1]))!==w)?d.jsx("div",{className:"picker-group",children:(p==null?void 0:p(w))??w}):null;return d.jsxs(S.Fragment,{children:[y,d.jsx("button",{className:We("picker-item",r==null?void 0:r(m)),"data-state":dr({cursor:g===o.index}),onMouseMove:()=>g!==o.index&&o.setIndex(g),onMouseDown:b=>b.preventDefault(),onClick:()=>o.pick(m),children:n(m,g===o.index)})]},t(m))}),e.length===0&&d.jsx("div",{className:"empty",children:l})]}),d.jsx(iT,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]],note:c})]})}const Cx=e=>Math.max(0,Math.min(1,Number.isFinite(e)?e:0));function S9({fraction:e,level:t,className:n}){const o=2*Math.PI*5.5,i=Cx(e),l=S.useId(),c=3.5,u=2*c*Cx(t);return d.jsxs("svg",{className:We("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 _9(e,t=Dc.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 yw(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=aT(e);return r&&n.push({id:"install",label:r,onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}function aT(e){return e.install?e.install==="missing"?"install":"install again":null}const lh=e=>e.reason??"not installed",us="";function N9(e){var p;const t=j9(e.name);if(t){const h=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:h}}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]??((p=e.name.match(/\(([^)]*)\)$/))==null?void 0:p[1]),...o].filter(Boolean).join(" · ");return{label:i,version:l[2],...u?{description:u}:{}}}const T9=/(?:^|[./])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 j9(e){const t=e.match(T9),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 lT(e,t,n,r){const o=h1(e),i=TC(e),l=y=>i&&y===(o==null?void 0:o.id)?i.id:y,c=l(t||n||(o==null?void 0:o.id)||us),u=l(t||(o==null?void 0:o.id)||us),p=i?e.filter(y=>y!==o):e,h=p.some(y=>y.id===c),m=p.map(y=>({c:y,words:N9(y)})),g=y=>[y.label,y.version].filter(Boolean).join(" "),w=[...o?[]:[{id:us,label:r.label,description:r.description}],...m.map(({c:y,words:b})=>{const _=m.filter(x=>g(x.words)===g(b)).length===1?b:void 0,T=_?_.description:y.description;return{id:y.id,label:_?_.label:y.name,..._!=null&&_.version?{suffix:_.version}:{},..._!=null&&_.version&&m.some(x=>x.c!==y&&x.words.label===_.label)?{chip:g(_)}:{},description:y===i?["recommended",T].filter(Boolean).join(" · "):T}}),...c&&!h?[{id:c,label:c}]:[]];if(c!==u){const y=w.find(T=>T.id===c),b=w.findIndex(T=>T.id===u),_=w[b];if(_){const T=(y==null?void 0:y.chip)??(y==null?void 0:y.label)??c;w[b]={..._,description:[`${T} now`,_.description].filter(Boolean).join(" · ")}}}return{rows:w,shown:c,picked:u}}const yc=(e,t)=>`${e} ${t}`;function C9(e){const t=e.indexOf(" ");return t<0?{agent:e,model:us}:{agent:e.slice(0,t),model:e.slice(t+1)}}function A9(e,t,n){const r=e.length>1;let o=yc(t,n);return{rows:e.flatMap(l=>{var h;const c=l.short??l.name,u=l.id===t;if(!l.available||!((h=l.models)!=null&&h.length))return u&&(o=yc(l.id,us)),[{id:yc(l.id,us),label:c,description:l.available?l.checkFailed??"its own default model; the rest are listed once it has run":lh(l),disabled:!l.available}];const p=lT(l.models,u?n:us,void 0,{label:`${c} default`,description:`whatever ${l.name} runs when nothing is asked for`});return u&&(o=yc(l.id,p.shown)),p.rows.map(m=>({...m,id:yc(l.id,m.id),...r&&m.id!==us?{prefix:c}:{}}))}),shown:o}}function Jc({anchored:e=!1,...t}){return e?d.jsx(I9,{...t,anchored:e===!0?{}:e}):d.jsx($9,{...t})}function I9({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:i,id:l,children:c}){const{onKey:u,back:p}=cT(t);return d.jsx(Rs,{className:We(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:()=>p()||(e==null?void 0:e()),children:c})}function $9({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:i}){const{onKey:l,back:c}=cT(t);return d.jsx(Rs,{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:We(r?"":"overlay-box",n),children:i})})}function cT(e){const t=Yn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:YE(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function R9(e){const t=e.value.length;e.setSelectionRange(t,t)}function O9({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 Mr({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:i,onPick:l,onBack:c,onActive:u,onSide:p,onTab:h,onQuery:m,completionOf:g,narrowTo:w,placeholder:y,initialQuery:b="",initialIndex:_,selectOnMount:T=!1,idleWhen:x,onIdlePick:N,anchored:j=!1,onEscape:$,lead:P,trailing:R,empty:A="no matches",footer:O,keys:D,rowMenu:z,groupOf:X,groupHead:ne,headAlone:ee=!1,field:ie}){const be=yn("picker"),[C,Z]=S.useState(b),Y=S.useMemo(()=>t(e,C),[e,C,t]),q=S.useRef(null),F=Si(),re=DL(T,!F&&!ie);S.useEffect(()=>{if(!m)return;const Ce=setTimeout(()=>m(C),150);return()=>clearTimeout(Ce)},[C,m]);const Ee=YS({results:Y,keyOf:n,q:C,onPick:l,listRef:q,onActive:u,onSide:p,completionOf:g,narrowTo:w,setQ:Z,initialIndex:_,idle:(x==null?void 0:x(b))??!1,onIdlePick:N}),{index:Te,ghost:de}=Ee,ke=ie?ie.open:!0;ft([ke,b],()=>{!ie||ke||(Z(b),Ee.setIndex(x!=null&&x(b)?-1:0))}),ft([ke],()=>{if(!ie||!ke||F)return;const Ce=()=>{const _e=re.current;!_e||document.activeElement===_e||(_e.focus(),T&&_e.select())};Ce();const Se=requestAnimationFrame(Ce);return()=>cancelAnimationFrame(Se)});const ae=S.useRef(!1),G=typeof D=="function"?D(Ee.active,C):D,ue=[];G!=null&&G.nav&&ue.push(["↑↓",G.nav]),G!=null&&G.side&&p&&ue.push(["←→",G.side]),G!=null&&G.complete&&(de!=null&&de.accept)&&ue.push(["tab",G.complete]),G!=null&&G.tab&&h&&ue.push(["tab",G.tab]),G!=null&&G.pick&&ue.push(["enter",G.pick]),G!=null&&G.back&&ue.push(["esc",G.back]);const Le=Ce=>d.jsxs("div",{...ie==null?void 0:ie.attrs,className:We("picker-input",ie&&"picker-field",ie==null?void 0:ie.className),"data-open":(ie==null?void 0:ie.open)||void 0,onMouseDown:Se=>{var _e;Se.target.closest("input, .float")||(Se.preventDefault(),(_e=re.current)==null||_e.focus())},children:[P,d.jsxs("div",{className:"picker-caret",children:[d.jsx(Io,{font:"mono",bare:!0,ref:re,value:C,spellCheck:!1,"aria-controls":ie==null?void 0:ie.id,"aria-expanded":ie?ie.open:void 0,onFocus:()=>{ie&&!ie.open&&ie.onOpen()},onBlur:Se=>{const _e=Se.relatedTarget;ie!=null&&ie.open&&_e instanceof Element&&!_e.closest(".float")&&c()},onMouseDown:Se=>{const _e=document.activeElement!==Se.currentTarget;if(ae.current=_e,ie&&_e){const Be=document.getSelection();Be&&(!Be.isCollapsed||Be.toString()!=="")&&Be.removeAllRanges()}},onClick:Se=>{if(!ie||!ae.current)return;ae.current=!1;const _e=Se.currentTarget;setTimeout(()=>{document.activeElement===_e&&_e.selectionStart===_e.selectionEnd&&_e.select()},0)},onChange:Se=>{Z(Se.target.value),Ee.setIndex(x!=null&&x(Se.target.value)?-1:0),ie&&!ie.open&&ie.onOpen()},onKeyDown:Se=>{var _e;if(ie&&!ie.open){if(Se.key==="ArrowDown"||Se.key==="ArrowUp")ie.onOpen();else if(Se.key==="Escape"){R9(Se.currentTarget),Se.currentTarget.blur();return}}if(z&&Ee.active&&(Se.key==="ContextMenu"||Se.key==="F10"&&Se.shiftKey)){const Be=(_e=q.current)==null?void 0:_e.querySelector('[data-state~="cursor"]');if(Be){Se.preventDefault(),Se.stopPropagation(),oo.open({items:z(Ee.active),owner:"picker",target:Be,anchor:Be.getBoundingClientRect()});return}}Ee.onKeyDown(Se)||!h||Se.key!=="Tab"||Se.shiftKey||(Se.preventDefault(),h())},placeholder:y}),de&&d.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:C}),O9(de)]})]}),R,Ce]}),ge=new Map;if(X)for(const Ce of Y)ge.set(X(Ce),(ge.get(X(Ce))??0)+1);const oe=d.jsxs("div",{className:"picker-list",ref:q,onMouseDown:Ce=>{ie&&Ce.target!==Ce.currentTarget&&Ce.preventDefault()},children:[Y.map((Ce,Se)=>{const _e=X==null?void 0:X(Ce),Be=_e!==void 0&&(ee||ge.size>1)&&(Se===0||(X==null?void 0:X(Y[Se-1]))!==_e)?d.jsx("div",{className:"picker-group",children:(ne==null?void 0:ne(_e,ge.get(_e)??0))??_e}):null;return d.jsxs(S.Fragment,{children:[Be,d.jsx("button",{className:We("picker-item",o==null?void 0:o(Ce)),"data-state":dr({cursor:Se===Te}),title:i==null?void 0:i(Ce),onMouseMove:()=>Se!==Te&&Ee.setIndex(Se),onClick:()=>{var wt;Ee.pick(Ce),(wt=re.current)==null||wt.focus()},...be.contextMenu(()=>(z==null?void 0:z(Ce))??[]),children:r(Ce,Se===Te,C)})]},n(Ce))}),Y.length===0&&d.jsx("div",{className:"empty",children:typeof A=="function"?A(C):A}),O==null?void 0:O(C,Y)]}),we=ue.length>0&&d.jsx(iT,{hints:ue});return ie?Le(ie.open&&d.jsxs(Jc,{onClose:c,onEscape:$,boxClass:"picker",anchored:j,id:ie.id,children:[oe,we]})):d.jsxs(Jc,{onClose:c,onEscape:$,boxClass:"picker",anchored:j,coverBy:P?".picker-input > *:first-child":R?".picker-input > *:last-child":void 0,children:[Le(),oe,we]})}function di({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:i,className:l,onClose:c}){const[u,p]=S.useState(!1),h=()=>{p(!1),c==null||c()},m=t??e,g=n.find(y=>y.id===m),w=(g==null?void 0:g.chip)??(g==null?void 0:g.label)??m;return d.jsxs("span",{className:"chip-picker",children:[d.jsx(Fe,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:We("chip-picker-btn",l),...Ut(i),onClick:()=>u?h():p(!0),children:w}),u&&d.jsx(Mr,{anchored:{flip:"both",margin:0},onEscape:h,items:n,filter:(y,b)=>{const _=b.trim().toLowerCase().split(/\s+/).filter(Boolean);return y.filter(T=>{const x=`${T.prefix??""} ${T.label??T.id} ${T.suffix??""} ${T.id}`.toLowerCase();return _.every(N=>x.includes(N))})},keyOf:y=>y.id,initialIndex:y=>Math.max(0,y.findIndex(b=>b.id===e)),lead:d.jsx(Fe,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:h,children:w}),placeholder:o,rowClass:()=>"picker-row",row:y=>d.jsxs(d.Fragment,{children:[y.id===e&&d.jsx("span",{className:"row-current","aria-hidden":"true"}),d.jsxs("span",{className:We("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),h())},onBack:h})]})}function uT({choices:e,value:t,current:n,what:r,defaultLabel:o,defaultDescription:i,placeholder:l,className:c,onChange:u,onClose:p}){const{rows:h,shown:m,picked:g}=S.useMemo(()=>lT(e,t,n,{label:o,description:i}),[e,t,n,o,i]);if(e.length===0)return null;const w=h.find(b=>b.id===m),y=(w==null?void 0:w.chip)??(w==null?void 0:w.label)??m;return d.jsx(di,{value:g,reads:m,options:h,onChange:u,onClose:p,className:c,hint:t?`asked for ${y}; click to change`:`${y}, the agent's choice; click to pick ${r}`,placeholder:l})}function M9(e){const[t,n]=go(Ge.effortPrefix+(e??""),us,r=>r??"",ao().storage);return[t,n]}function Ax({efforts:e,value:t,current:n,onChange:r,onClose:o}){return d.jsx(uT,{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 P9(e){const[t,n]=go(Ge.modePrefix+((e==null?void 0:e.id)??""),Qd,r=>ru.some(o=>o.id===r)?r:Qd,ao().storage);return[t,n]}const L9=e=>{var t;return((t=ru.find(n=>n.id===e))==null?void 0:t.description)??""};function Ix({value:e,onChange:t,onClose:n}){return d.jsx(di,{value:e,options:ru.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:We("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${L9(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function D9(e){const[t,n]=go(Ge.modelPrefix+(e??""),us,r=>r??"",ao().storage);return[t,n]}function z9(e,t,n){e.set(Ge.modelPrefix+t,n)}function $x({models:e,value:t,current:n,onChange:r,onClose:o}){return d.jsx(uT,{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 F9({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:i,shown:l}=S.useMemo(()=>A9(e,t,n),[e,t,n]);if(i.length===0)return null;const c=i.find(p=>p.id===l),u=c?[c.prefix,c.label,c.suffix].filter(Boolean).join(" "):n;return d.jsx(di,{value:l,options:i,onChange:p=>{const h=C9(p);r(h.agent,h.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 dT(e){const t=th(e),[n,r]=go(Ge.profilePrefix+((e==null?void 0:e.id)??""),(e==null?void 0:e.config.defaultProfile)??"",i=>i??void 0,ao().storage);return[t.length===0?void 0:t.includes(n)?n:e==null?void 0:e.config.defaultProfile,r]}function B9({repo:e,value:t,onChange:n,onClose:r}){const o=th(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 p=((m=i[u])==null?void 0:m.run)??[],h=p.length>0?`runs ${p.join(", ")}`:"runs nothing";return u===(e==null?void 0:e.config.defaultProfile)?`${h}; the default in ${l}`:h};return d.jsx(di,{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 eu(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 U9({c:e,query:t}){const n=t.trim();return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"picker-name",children:["/",eu(e.name,n?mw(e.name,n):null,0)]}),d.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function An({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 H9(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 W9=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,K9=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,Z9=/^[[:$*{]|\[/;function q9(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(W9).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 p;return(((p=o.get(u))==null?void 0:p.size)??0)<2});c.length>0&&t.set(i,c.join(" "))}return t}function vw(e){const t=e.replace(/\?[^#]*/,"").split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let r=t[n];try{r=decodeURIComponent(r)}catch{}if(K9.test(r)||Z9.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const dm=8,G9=3,V9=50,Y9=3;function X9(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?pM(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:q9(e),links:new Map(n.map(l=>[l.path,l.text]))}}function Q9(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function J9(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function eB(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const fT=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),Nc=e=>fT(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),tB=e=>zf(`/${e}`).text.slice(1),bw=e=>e.split("/").filter(Boolean);function xw(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=bw(e);let i="";const l=[],c=m=>{const g=tB(m);l.push([i.length,i.length+g.length]),i+=g};for(let m=0;m<r.length;m++){const g=r[m],w=o[m];if(w===void 0)return null;if(m<r.length-1){if(fT(w))return{show:t,accept:t};if(Nc(w)){if(!g)return null}else if(g.toLowerCase()!==w.toLowerCase())return null;i+=`${Nc(w)?g:w}/`;continue}if(Nc(w))g?i+=g:c(w);else{if(!w.toLowerCase().startsWith(g.toLowerCase()))return null;i+=w}}for(const m of o.slice(r.length))i+="/",Nc(m)?c(m):i+=m;const u=n?1:0,p=(n?"/":"")+i,h=l[0];return{show:p,accept:h?p.slice(0,h[0]+u):p,params:l.map(([m,g])=>[m+u,g+u])}}function nB(e,t){const n=xw(e,t);return n?n.accept.length>t.length?n.accept:t:zf(e).literal}function hT(e,t){if(e.kind==="go")return null;if(e.template){const n=xw(e.path,t);return n&&n.show.length>t.length?n:null}return eB(e.path,t)}const rB=e=>e.trim().replace(/^\//,"").toLowerCase();function pT(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function oB(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:pT(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 sB(e,t){const{text:n,literal:r}=zf(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:xw(e,t)?70:pT(n.replace(/^\//,"").toLowerCase(),t)?60:0}function iB(e,t){const n=bw(e).findIndex(Nc);return n>=0&&t.split("/").length>n}function Oc(e,t,n){var c;const r=e.statics.get(t),o=r?null:mM(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)||vw(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 mT(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:vw(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function Vd({rank:e,group:t,score:n,...r}){return r}const vf=e=>bw(e).length,bf=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function aB(e,t){const n=new Set,r=[];e.history.forEach((h,m)=>{if(h.path===t)return;const g=Oc(e,h.path,m);n.has(g.group)||(n.add(g.group),r.push(g))});const o=new Set(r.map(h=>h.path)),i=r.filter(h=>h.badge);for(const[h,m]of e.statics)e.unseen[m.file]&&h!==t&&!o.has(h)&&i.push(Oc(e,h,Number.POSITIVE_INFINITY));for(const h of e.templateRoutes.values())e.unseen[h.file]&&!n.has(h.path)&&i.push(mT(e,h));i.sort((h,m)=>bf(h)-bf(m)||h.rank-m.rank);const l=r.filter(h=>!h.badge),c=i.slice(0,dm-Math.min(G9,l.length));for(const h of l)c.length<dm&&c.push(h);const u=new Set(c.map(h=>h.path)),p=[...e.statics.keys(),...[...e.links.keys()].filter(h=>!e.statics.has(h))].filter(h=>h!==t&&!u.has(h)&&!o.has(h)).sort((h,m)=>vf(h)-vf(m)||(h<m?-1:h>m?1:0));for(const h of p){if(c.length>=dm)break;c.push(Oc(e,h,Number.POSITIVE_INFINITY))}return c.map(Vd)}function lB(e,t,n){const r=rB(t),o=J9(t),i=new Map;e.history.forEach((w,y)=>{w.path!==n&&i.set(w.path,Oc(e,w.path,y))});for(const w of[...e.statics.keys(),...e.links.keys()])w!==n&&!i.has(w)&&i.set(w,Oc(e,w,Number.POSITIVE_INFINITY));const l=[];for(const w of i.values()){const y=oB(w.path,w.title,r);y>0&&l.push({...w,score:y})}let c=null;for(const w of e.templates){const y=e.templateRoutes.get(w.path);if(!c&&!e.statics.has(o)&&w.re.test(o)){c=y;continue}const b=sB(w.path,r);b>=60&&l.push({...mT(e,y),score:b})}l.sort((w,y)=>y.score-w.score||w.rank-y.rank||bf(w)-bf(y)||vf(w.path)-vf(y.path)||(w.path<y.path?-1:w.path>y.path?1:0));const u=new Map,p=[];for(const w of l){if(!w.template&&w.group!==w.path){const y=u.get(w.group)??0;if(y>=Y9&&!iB(w.group,r))continue;u.set(w.group,y+1)}if(p.push(w),p.length>=V9)break}if(p.some(w=>w.score===100))return p.map(Vd);const h={kind:"go",path:o,...c?{title:vw(c.path)}:{}},m=p[0];return!c&&m!==void 0&&m.score>=80&&cB(m.path,r)?[...p.map(Vd),h]:[h,...p.map(Vd)]}function cB(e,t){const n=e.replace(/^\//,"").toLowerCase().slice(t.length);return!t.endsWith("/")&&n.length>0&&!/^[/?#]/.test(n)}function gT(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?aB(e,r):lB(e,t,r)}const uB=[],dB=[];function kT(e,t){const n=M(i=>(t?i.visits[t]:void 0)??uB),r=Rt(e,"pages"),o=Rt(e,"links");return ft([e],()=>{PE(r)&&an.post(e,{type:"links"})}),S.useMemo(()=>X9(n,r,o),[n,r,o])}function fB({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}=zf(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 wT({row:e}){return e.kind==="go"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.path}),e.title?d.jsx("span",{className:"bar-route-path row-dim",children:e.title}):null,d.jsx("span",{className:"picker-hint row-dim",children:"as typed"})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"picker-label",children:e.title}),d.jsx(fB,{row:e}),e.badge?d.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const yT=e=>e.kind==="page"&&e.file?e.file:e.path,vT=(e,t)=>e.kind==="page"&&e.template?nB(e.path,t):null,bT=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function xT(e,t,n){return e.kind!=="page"?[]:Gf([...e.file&&t.dir?js({id:t.worktreeId,dir:t.dir},e.file,{},n):[],vS,...e.visited?H9(t.repoId,e.path,n):[]])}function hB({worktreeId:e,repoId:t,url:n,open:r}){const o=ut(),i=it(),l=M(y=>{const b=un(y,e);return b?b.worktree.path:null}),c=kT(e,t),u=Q9(n),p=n?Df(n):null,h=S.useCallback((y,b)=>gT(c,{query:b,current:u,here:p}),[c,u,p]),m=S.useCallback(y=>y===u||y.trim()==="",[u]),g=()=>o({a:"close"}),w=S.useMemo(()=>({open:r,onOpen:()=>o({a:"open",overlay:{kind:"routes"}}),id:"routes",className:"bar-path",attrs:Ut("Go to a page",zt("routes"))}),[r,o]);return d.jsx(Mr,{anchored:{matchWidth:0,cover:!1,offset:-1},field:w,items:dB,filter:h,initialQuery:u,selectOnMount:!0,idleWhen:m,onIdlePick:y=>{y.trim()===""?an.post(e,{type:"navigate",path:"/"}):an.post(e,{type:"reload"}),g()},keyOf:y=>`${y.kind}:${y.path}`,rowClass:()=>"picker-row",rowTitle:yT,completionOf:(y,b)=>m(b)?null:hT(y,b),narrowTo:vT,onPick:y=>{an.post(e,{type:"navigate",path:y.path}),g()},onBack:g,rowMenu:y=>xT(y,{worktreeId:e,repoId:t,dir:l},{sock:i,dispatch:o}),placeholder:"type a path",keys:(y,b)=>({complete:"completes the path",pick:y?bT(y):b.trim()===""?"goes to the root":"reloads",back:"closes"}),empty:"no pages yet; type a path",row:y=>d.jsx(wT,{row:y})})}function ET(e,t){const n=t.trim();return d.jsx(An,{label:eu(e.label,n?mw(e.label,n):null,0),hint:e.hint&&d.jsx(Yo,{k:e.hint})})}function ST({anchored:e,trailing:t}){const n=ut(),r=HN(),o=M(i=>{var l;return((l=i.paletteReturn)==null?void 0:l.mode)==="commands"?i.paletteReturn.q:""});return d.jsx(Mr,{anchored:e,trailing:t,items:r,filter:WN,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)=>ET(i,c)})}function _T(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 Rx(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 NT(e,t,n,r=50){const o=_T(e,t),i=n.trim().toLowerCase();if(!i){const c=new Map(t.map((m,g)=>[m.path,g])),u=m=>{var g;return c.get(((g=m.status)==null?void 0:g.path)??"")??c.get(m.path)??Number.MAX_SAFE_INTEGER},p=o.filter(m=>m.status).sort((m,g)=>u(m)-u(g)||Rx(m.path,g.path)),h=o.filter(m=>!m.status).sort((m,g)=>Rx(m.path,g.path));return{rows:[...p,...h].slice(0,r),changed:Math.min(p.length,r)}}const l=jT(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 TT(e,t){const n=e.toLowerCase(),r=Ox(n,t);return r<=0?0:Ox(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function jT(e,t){const n=[];for(const r of e){const o=TT(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function pB(e,t,n,r,o){const i=r.trim().toLowerCase();if(!i)return NT(e,n,r,o).rows.map(u=>({kind:"file",path:u.path,status:u.status}));const l=jT(_T(e,n),i).map(({row:u,score:p})=>({row:{kind:"file",path:u.path,status:u.status},score:p}));for(const u of t){const p=TT(u,i);p>0&&l.push({row:{kind:"folder",path:u},score:p})}const c=u=>u.kind==="folder"?1:0;return l.sort((u,p)=>p.score-u.score||c(u.row)-c(p.row)||u.row.path.localeCompare(p.row.path)),l.slice(0,o).map(u=>u.row)}function mB(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 Ox(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 gB(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const Mx=[],kB=[],wB=[];function yB({worktreeId:e}){var _;const t=ut(),n=it(),r=Yn(),o=M(T=>T.connected);ft([e,o,n],()=>Vf(e,r.getState(),{sock:n,dispatch:t}));const i=mS(e),l=i.files??kB,c=((_=i.git)==null?void 0:_.files)??wB,u=HN(),p=M(T=>{var x;return((x=T.paletteReturn)==null?void 0:x.mode)==="quick-open"?T.paletteReturn.q:""}),h=M(T=>{var N;const x=(N=un(T,e))==null?void 0:N.worktree;return x?x.path:null}),m=M(T=>{var x;return((x=un(T,e))==null?void 0:x.repoId)??null}),g=M(T=>{var x;return((x=df(T))==null?void 0:x.worktreeId)===e}),w=kT(e,m),y=i.page.url?Df(i.page.url):null,b=S.useCallback((T,x)=>x.startsWith(">")?WN(u,x.slice(1)).map(N=>({kind:"cmd",c:N})):x.startsWith("/")?g?gT(w,{query:x,current:"/",here:y}).map(N=>({kind:"page",page:N})):Mx:NT(l,c,x).rows.map(N=>({kind:"file",path:N.path,status:N.status})),[u,l,c,g,w,y]);return d.jsx(Mr,{items:Mx,filter:b,keyOf:T=>T.kind==="cmd"?`c:${T.c.id}`:T.kind==="page"?`p:${T.page.kind}:${T.page.path}`:`f:${T.path}`,rowClass:T=>T.kind==="file"?"qo-file":"picker-row",rowTitle:T=>T.kind==="page"?yT(T.page):void 0,completionOf:(T,x)=>T.kind==="page"?hT(T.page,x):null,narrowTo:(T,x)=>T.kind==="page"?vT(T.page,x):null,onPick:(T,x)=>{T.kind==="cmd"?(T.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:x}}):t({a:"close"}),T.c.run()):T.kind==="page"?(an.post(e,{type:"navigate",path:T.page.path}),t({a:"close"})):(er({dispatch:t},{worktreeId:e,path:T.path,view:wi(T.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:T=>T.kind==="file"&&h?js({id:e,dir:h},T.path,{},{sock:n,dispatch:t}):T.kind==="page"&&m?xT(T.page,{worktreeId:e,repoId:m,dir:h},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(T,x)=>x.startsWith("/")?{complete:"completes the path",pick:(T==null?void 0:T.kind)==="page"?bT(T.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:p,empty:T=>T.startsWith(">")?"no matching command":T.startsWith("/")?g?"no pages yet; type a path":"no preview running":"no matches",row:(T,x,N)=>T.kind==="cmd"?ET(T.c,N.slice(1)):T.kind==="page"?d.jsx(wT,{row:T.page}):vg(T.path,T.status,N,{gutter:c.length>0})})}function vg(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[i,l]=gB(e),c=n.trim()?mB(e,n.trim()):null;return d.jsxs(d.Fragment,{children:[o&&d.jsx("span",{className:`xy ${t?ik(t.xy):""}`,children:t?ak(t.xy):""}),d.jsxs("span",{className:"name",children:[eu(i,c,l.length),r&&"/"]}),d.jsx("span",{className:"dir row-dim",children:l&&d.jsxs(d.Fragment,{children:["",eu(l,c,0),""]})}),t&&d.jsx(y_,{f:t})]})}function vB(e,t,n){var l;if(!e)return null;if(e.available)return e.checkFailed?{kind:"unready",text:e.checkFailed,retry:null}:((l=e.auth)==null?void 0:l.kind)==="none"?{kind:"unready",text:e.loginHint??`${e.name} is not logged in`,retry:null}:null;const r=n?t.find(c=>c.available&&c.id!==e.id):void 0,o=r?{other:r}:{};return e.installing?{kind:"installing",text:`${e.name} is installing`,retry:null,...o}:{kind:"failed",text:typeof e.install=="object"?`${e.name} did not install: ${e.install.failed}`:`${e.name} is not ready: ${lh(e)}`,retry:aT(e),...o}}function Xa({icon:e,verb:t,tip:n,onPress:r,onDismiss:o,children:i}){return d.jsxs("div",{className:"composer-offer",children:[d.jsx(Tt,{name:e,className:"icon-inline"}),d.jsxs("span",{className:"composer-offer-line",children:[d.jsx(Fe,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," ",i]}),o&&d.jsx(Mt,{icon:"close",tone:"quiet",className:"composer-offer-close",label:"Not this one",onClick:o})]})}function CT({item:e,n:t,onRemove:n}){const r=Kr();return e.kind==="image"?d.jsx(dw,{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(lw,{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(aw,{n:t,name:e.name,source:e.source,lines:e.lines,chars:e.chars,preview:e.preview,text:e.text,onRemove:n})}const Px=8,bB=104,xB=.25,AT=220;function EB({dx:e,dy:t}){return Math.abs(e)<Px&&Math.abs(t)<Px?null:Math.abs(e)>Math.abs(t)&&e<0?"slide":"other"}function SB(e,t,n=bB){const r=Math.max(0,-e),o=t*n,i=Math.min(t,Math.floor(r/n)),l=r<=o?r:o+(r-o)*xB,c=Math.min(1,r/(n/2));return{step:i,x:-l,well:c}}function IT(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>{const r=e.current;if(!r)return;let o=null,i=null,l=!1,c=0,u=0,p=0;const h=(x,N,j,$)=>{x.el.dataset.slide!==$&&(x.el.dataset.slide=$,x.el.offsetWidth),x.el.style.setProperty("--slide-x",`${N}px`),x.el.style.setProperty("--slide-well",`${Math.round(j*100)}%`)},m=x=>{x.el.style.removeProperty("--slide-x"),x.el.style.removeProperty("--slide-well"),delete x.el.dataset.slide},g=()=>{const x=o,N=l,j=c;o=null,i=null,l=!1,c=0,!(!x||!N)&&(h(x,0,0,"settle"),j>0&&n.current.onPick(x.key,j),u=window.setTimeout(()=>{m(x),n.current.onSlide(null)},AT))};let w=null;const y=x=>{if(!x.isPrimary||x.pointerType==="mouse"&&x.button!==0)return g();const N=x.target instanceof Element?n.current.rowOf(x.target):null;!N||N.el.dataset.slide||(window.clearTimeout(u),o=N,w=x.pointerId,i={x:x.clientX,y:x.clientY})},b=x=>{var R;const N=o;if(!N||!i||x.pointerId!==w)return;const j=x.clientX-i.x,$=x.clientY-i.y;if(!l){const A=EB({dx:j,dy:$});if(A==="other"&&(o=null,i=null,w=null),A!=="slide")return;l=!0;try{N.el.setPointerCapture(x.pointerId)}catch{}n.current.onSlide({key:N.key,step:0})}const P=SB(j,N.rungs,N.rung);h(N,P.x,P.well,"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)))},_=x=>{x.pointerId===w&&(l&&(p=x.timeStamp+400),w=null,g())},T=x=>{x.timeStamp>=p||(x.preventDefault(),x.stopPropagation())};return r.addEventListener("pointerdown",y),r.addEventListener("pointermove",b),r.addEventListener("pointerup",_),r.addEventListener("pointercancel",_),r.addEventListener("click",T,!0),()=>{window.clearTimeout(u),r.removeEventListener("pointerdown",y),r.removeEventListener("pointermove",b),r.removeEventListener("pointerup",_),r.removeEventListener("pointercancel",_),r.removeEventListener("click",T,!0)}},[e])}function xf({rows:e,cursor:t,onCursor:n,onPick:r,onHint:o,hover:i=!1}){const l=Si(),c=S.useRef(null),[u,p]=S.useState(null),h=l&&!!o;IT(c,{rowOf:g=>{if(!h||g.closest("textarea"))return null;const w=g.closest(".slide"),y=w==null?void 0:w.dataset.row,b=y===void 0?void 0:e[Number(y)];return w&&y!==void 0&&(b!=null&&b.hint)&&!b.field?{el:w,key:y,rungs:1,rung:120}:null},onSlide:p,onPick:g=>o==null?void 0:o(Number(g))});const m=g=>{var w;g.target instanceof HTMLTextAreaElement||(g.preventDefault(),(w=g.currentTarget.querySelector("textarea"))==null||w.focus())};return d.jsx("div",{className:We("choices",i&&"choices-hover",l&&"choices-touch"),ref:c,children:e.map((g,w)=>{const y=!l&&t===w,b=dr({cursor:y,checked:g.checked}),_=g.tone==="deny"&&"choice-deny",T=()=>n&&t!==w&&n(w),x=j=>{var R;if(!h)return j;const $=(u==null?void 0:u.key)===String(w)?u.step:null,P=$!==null&&$>0&&((R=g.hint)==null?void 0:R.on)!==!1;return d.jsxs("div",{className:"slide","data-row":w,children:[j,$!==null&&g.hint&&d.jsxs("span",{className:"slide-verb","data-rung":P?"hint":void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:g.hint.label}),d.jsx(Tt,{name:g.hint.icon})]})]},w)},N=d.jsxs(d.Fragment,{children:[!l&&d.jsx(Yo,{k:String(w+1),className:"choice-num row-dim"}),d.jsx("span",{className:"choice-label",children:g.label}),!l&&g.hint&&d.jsxs("span",{className:We("choice-hint row-dim",y&&g.hint.on!==!1&&"on"),children:[d.jsx(Yo,{k:g.hint.k})," ",g.hint.label]}),g.description&&d.jsx("span",{className:"choice-desc",children:g.description}),g.sample&&d.jsx("pre",{className:"choice-sample",children:g.sample})]});return g.field?x(d.jsxs("div",{className:We("picker-item choice row-edge",_),"data-state":b,onMouseMove:T,onMouseDown:m,children:[N,d.jsx(Zc,{ref:g.field.ref,bare:!0,font:"ui",rows:1,className:"choice-field",enterKeyHint:g.field.enterKeyHint,placeholder:g.field.placeholder,value:g.field.value,onChange:j=>{var $;return($=g.field)==null?void 0:$.onChange(j.target.value)}})]},w)):x(d.jsx("button",{type:"button",className:We("picker-item choice row-edge",_),"data-state":b,disabled:g.disabled,onMouseMove:T,onClick:()=>r(w),children:N},w))})})}function $T(e){return Yd(e.key)&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}const RT=e=>e.length===1&&e>="1"&&e<="9",Yd=e=>e==="Enter"||e==="NumpadEnter";function _B(e,t,n){const r=Yd(e.key)&&(e.metaKey||e.ctrlKey);return t?e.key==="Escape"||e.key==="Tab"&&!e.shiftKey?{kind:"field-leave"}:r?{kind:"submit"}:Yd(e.key)&&!e.shiftKey?{kind:"field-enter"}:{kind:"typing"}:$T(e)?{kind:"chord"}:e.key==="Escape"?{kind:"escape"}:r?{kind:"submit"}:Yd(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:cu(n.cursor,e.key==="ArrowUp"?-1:1,n.count)}:RT(e.key)&&Number(e.key)<=n.count?{kind:"pick",at:Number(e.key)-1,by:"digit"}:null}function Ew(e,t){var o,i,l,c;const n=e.target instanceof HTMLTextAreaElement,r=_B(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 NB(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function TB(e,t){ft([t],()=>{const o=requestAnimationFrame(()=>{var i;NB(document.activeElement)||(i=e.current)==null||i.focus()});return()=>cancelAnimationFrame(o)});const n=S.useRef(!1),r=S.useCallback(()=>{requestAnimationFrame(()=>{var o;document.activeElement===document.body&&((o=e.current)==null||o.focus())})},[e]);return S.useEffect(()=>{const o=()=>{n.current=!0},i=()=>{n.current=!1,r()};return window.addEventListener("pointerdown",o,!0),window.addEventListener("pointerup",i,!0),window.addEventListener("pointercancel",i,!0),()=>{window.removeEventListener("pointerdown",o,!0),window.removeEventListener("pointerup",i,!0),window.removeEventListener("pointercancel",i,!0)}},[r]),o=>{!o.relatedTarget&&!n.current&&r()}}function Sw({root:e,id:t,onKeyDown:n,onKeyUp:r,onPaste:o,children:i}){const l=TB(e,t);return d.jsx("div",{ref:e,className:"card",tabIndex:-1,onKeyDown:n,onKeyUp:r,onPaste:o,onBlur:l,children:i})}function Ef({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 bg(e){const t=S.useRef(null),n=ww(t);return"html"in e?d.jsxs("div",{ref:t,className:"card-band md",children:[d.jsx("div",{dangerouslySetInnerHTML:{__html:e.html}}),n]}):d.jsxs("div",{ref:t,className:"card-band card-code",children:[d.jsx("pre",{children:e.code}),n]})}function jB({children:e}){return d.jsx("div",{className:"card-foot",children:e})}const CB=[{selected:[]}],fm=0,AB=2;function IB({item:e,worktreeId:t,rootRef:n}){var R;const r=it(),o=ut(),i=Rt(t,"card"),l=(i==null?void 0:i.id)===e.id?i.draft:CB,c=(R=l[0])==null?void 0:R.note,u=c!==void 0,p=A=>o({a:"card-draft",id:t,card:{id:e.id,draft:A,current:0}}),h=S.useRef(null),[m,g]=S.useState(fm),[w,y]=S.useState(!1),b=S.useMemo(()=>hl(e.message),[e.message]),_=A=>{w||!r||(r.send(V4(e,t,A,c)),A&&y(!0),o({a:"answered",id:t}))},T=()=>{u||p(lf(l,0,"")),g(fm),requestAnimationFrame(()=>{var A;return(A=h.current)==null?void 0:A.focus()})},x=A=>_(A===fm),N=()=>o({a:"card-park",id:t,cardId:e.id}),j=()=>{var O;const A=Kd(l,0);A!==l&&p(A),(O=n.current)==null||O.focus()},$=A=>{Ew(A,{count:AB,cursor:m,onCursor:g,onPick:x,onEscape:N,onFieldEnter:()=>_(!0),onFieldLeave:j})||A.key==="n"&&(A.preventDefault(),T())},P=[{label:"go",hint:{k:"n",label:"add context",icon:"edit",on:!u},checked:u,field:u?{ref:h,value:c??"",placeholder:"a note for the agent there, sent with go",enterKeyHint:"send",onChange:A=>p(lf(l,0,A))}:void 0,description:w?"starting":void 0,disabled:w},{label:"not now",tone:"deny",disabled:w}];return d.jsxs(Sw,{root:n,id:e.id,onKeyDown:$,children:[d.jsxs(Ef,{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(bg,{html:b}),d.jsx(xf,{rows:P,cursor:m,onCursor:g,onPick:x})]})}function $B(e,t){if(t.queued>0||t.sending||t.card)return null;const n=e.at(-1);if(!n)return null;if(n.kind==="stopped"||n.kind==="error"){if(n.seq===void 0)return null;const o=`${n.kind}:${n.seq}`;return t.dismissed.has(o)?null:n.kind==="stopped"?{verb:"continue",key:o,after:"stop"}:{verb:"continue",key:o,after:"error",...RB(e)?{again:!0}:{}}}if(n.kind!=="tool"||!n.done||!n.fixable||t.dismissed.has(n.id)||e.some(o=>o.kind==="asked"&&o.toolId===n.id))return null;const r=kw(n);return r===null?null:{verb:"fix",key:n.id,toolId:n.id,command:r}}function RB(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 xg=new Set;const Eg=new Set;function OB(e){return Eg.add(e),()=>{Eg.delete(e)}}function Lx(e){xg=new Set(xg).add(e);for(const t of Eg)t()}function MB(){return S.useSyncExternalStore(OB,()=>xg)}const PB=e=>ru.some(t=>t.id===e);function LB(e){return[...ru.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 OT(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 DB(e,t){const n=OT(e,t);return[...n.yours,...n.own,...n.rest]}function Dx(e,t){const n=OT(e,t);return{rows:[...n.yours,...n.own],more:n.rest.length}}function zB(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 FB(e){const t=e.findIndex(n=>n.kind.startsWith("reject"));return t<0?null:t}function BB(e){const{key:t}=e;return t.length!==1||t===" "||t==="n"||RT(t)||$T(e)?null:t}const zx=[{selected:[]}];function UB({item:e,ask:t,worktreeId:n,rootRef:r}){var O;const o=it(),i=ut(),l=M(D=>D.activeId),c=Rt(n,"card"),u=(c==null?void 0:c.id)===e.id?c.draft:zx,p=(O=u[0])==null?void 0:O.note,h=p!==void 0,m=h?t.choices.findIndex(D=>{var z;return D.id===((z=u[0])==null?void 0:z.selected[0])}):-1,g=S.useRef(null),[w,y]=S.useState(0),b=t.plan,_=S.useMemo(()=>t.detail&&!b?hl(t.detail):"",[t.detail,b]),T=()=>{b&&l===n&&er({dispatch:i},{worktreeId:n,path:b,view:"preview",focus:!1})};ft([e.id,b],T);const x=D=>i({a:"card-draft",id:n,card:{id:e.id,draft:D,current:0}}),N=(D,z)=>{const X=t.choices[D];X&&(x([{selected:[X.id],note:z}]),y(D),requestAnimationFrame(()=>{const ne=g.current;ne&&(ne.focus(),ne.setSelectionRange(ne.value.length,ne.value.length))}))},j=D=>{const z=t.choices[D];if(!z)return;const X=p==null?void 0:p.trim();o==null||o.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:z.id,...X?{note:X}:{}}),i({a:"answered",id:n})},$=()=>i({a:"card-park",id:n,cardId:e.id}),P=()=>{var D;p!=null&&p.trim()||x(zx),(D=r.current)==null||D.focus()},R=D=>{if(Ew(D,{count:t.choices.length,cursor:w,onCursor:y,onPick:j,onEscape:$,onFieldEnter:()=>j(m),onFieldLeave:P}))return;if(D.key==="n"){D.preventDefault(),N(w,p??"");return}const z=BB(D);z!==null&&(D.preventDefault(),N(h?m:FB(t.choices)??w,(p??"")+z))},A=t.choices.map((D,z)=>{const X=D.kind.startsWith("reject"),ne=h&&z===m;return{label:D.name,tone:X?"deny":void 0,hint:{k:"n",label:"add context",icon:"edit",on:!h},checked:ne,field:ne?{ref:g,value:p,placeholder:X?"what to change, sent with your no":"a note for the work, sent with your yes",enterKeyHint:"send",onChange:ee=>x([{selected:[D.id],note:ee}])}:void 0}});return d.jsxs(Sw,{root:r,id:e.id,onKeyDown:R,children:[d.jsx(Ef,{children:t.title}),t.command&&d.jsx(bg,{code:TN(t.command)}),_&&d.jsx(bg,{html:_}),d.jsx(xf,{rows:A,cursor:w,onCursor:y,onPick:j,onHint:D=>N(D,p??"")})]})}function HB({item:e,ask:t,worktreeId:n,rootRef:r,numbers:o,onScreen:i,onAnswer:l}){const c=it(),u=ut(),p=Yn(),h=M(G=>G.clientId),m=Si(),{message:g,questions:w}=t,y=il(e.id),b=Rt(y,"attachments"),_=HS(y,n),T=Rt(n,"card"),x=S.useMemo(()=>(T==null?void 0:T.id)===e.id?T:{id:e.id,draft:xP(w),current:0},[T,e.id,w]),{draft:N,current:j}=x,$=j===$c(w),P=w[j],R=N[j],A=!!(P!=null&&P.multi),[O,D]=S.useState(()=>nl(P,R)),z=S.useRef(null);S.useEffect(()=>{const G=window.visualViewport;if(!G)return;const ue=()=>{z.current&&z.current===document.activeElement&&z.current.scrollIntoView({block:"nearest"})};return G.addEventListener("resize",ue),()=>G.removeEventListener("resize",ue)},[]);const X=(G,ue)=>u({a:"card-draft",id:n,card:{id:e.id,draft:G,current:ue}}),ne=G=>{if(l){G&&l(G);return}const ue=G?b:[],Le={t:"agent-answer",worktreeId:n,askId:e.id,...G?{answers:G}:{}};ue.some(ki)?u({a:"hold-send",id:y,log:n,text:nk(w,G).join(`
|
|
237
|
-
`),frame:Le}):(c==null||c.send({...Le,...ue.length?{attachments:ue.map(cl),boxId:y,clientId:h}:{}}),ue.length&&u({a:"clear-attachments",id:y})),u({a:"answered",id:n})},ee=()=>u(l?{a:"ask-revive",id:n}:{a:"card-park",id:n,cardId:e.id}),ie=()=>{Td(w,N)&&ne(N)},be=G=>{D(nl(w[G],N[G])),X(N,G)},C=G=>{P!=null&&P.note&&(X(O0(N,j,G,A),j),requestAnimationFrame(()=>{var ue;return(ue=z.current)==null?void 0:ue.focus()}))},Z=G=>{if(!(P!=null&&P.note))return;const ue=P.options[G];if(D(G),!ue||A)return C(!ue);X(O0(R0(N,j,ue.value,!1),j,!1,!1),j),requestAnimationFrame(()=>{var Le;return(Le=z.current)==null?void 0:Le.focus()})},Y=()=>Z(O),q=G=>{if(SP(P,G))return D(G),C(!0);const ue=P==null?void 0:P.options[G];if(!P||!ue)return;const Le=R0(Kd(N,j),j,ue.value,A);if(A){D(G),X(Le,j);return}const ge=M0(w,Le,j);D(ge.cursor),X(Le,ge.current),ge.send&&Td(w,Le)&&ne(Le)},F=()=>{var ue;const G=Kd(N,j);G!==N&&(X(G,j),D(nl(P,G[j]))),(ue=r.current)==null||ue.focus()},re=()=>{var Le;const G=Kd(N,j);if((Le=r.current)==null||Le.focus(),!ll(G[j])){G!==N&&(X(G,j),D(nl(P,G[j])));return}const ue=M0(w,G,j);D(ue.cursor),X(G,ue.current),ue.send&&Td(w,G)&&ne(G)},Ee=G=>{if(_.onPasteKey(G),!Ew(G,{count:$?w.length:EP(P),cursor:$?void 0:O,spacePicks:A,onCursor:D,onPick:ue=>$?be(ue):q(ue),onSubmit:ie,onEscape:ee,onFieldEnter:re,onFieldLeave:F})){if(G.key==="ArrowLeft"||G.key==="ArrowRight"||G.key==="Tab"){G.preventDefault();const ue=G.key==="ArrowLeft"||G.key==="Tab"&&G.shiftKey;return be(AP(j,ue?-1:1,$P(w)))}if(G.key==="n"&&(P!=null&&P.note))return G.preventDefault(),Y();if(G.key==="s"&&!l)return G.preventDefault(),ne()}},Te=G=>w.length===1&&!G.multi,de=(G,ue)=>d.jsxs(jB,{children:[(!G||!Te(G)||m&&(ue==null?void 0:ue.note)!==void 0)&&d.jsx(Fe,{variant:"outline",size:"md",disabled:!Td(w,N),onClick:ie,children:"send"}),(G==null?void 0:G.note)&&ue&&ue.selected.length>0&&ue.note===void 0&&d.jsxs(Fe,{tone:"quiet",size:"md",onClick:()=>C(!1),children:[d.jsx(Yo,{k:"n",chip:!0}),"add a note"]}),!l&&d.jsxs(Fe,{tone:"quiet",size:"md",onClick:()=>ne(),children:[d.jsx(Yo,{k:"s",chip:!0}),"skip"]}),d.jsx(Mt,{className:"card-attach",icon:"attach",tone:"chrome",label:i?"Attach a picture":"Attach a picture or a file",onClick:()=>zS(p,y,{images:i})})]}),ke=b.length>0&&d.jsx(rh,{children:d.jsx("div",{className:"card-chips",children:Lg(b,o).map(([G,ue])=>{const Le=()=>u({a:"detach",id:y,key:G.key});return G.kind==="pick"?null:d.jsx(CT,{item:G,n:ue,onRemove:Le},G.key)})})}),ae=(G,ue)=>{const Le=ue===j,ge=N[ue],oe=TE(ge,!!G.multi),we=Se=>({ref:Le?z:void 0,value:(ge==null?void 0:ge.note)??"",placeholder:Se,enterKeyHint:$c(w)===-1?"send":"next",onChange:_e=>X(lf(N,ue,_e),ue)}),Ce=G.options.map(Se=>{const _e=!!(ge!=null&&ge.selected.includes(Se.value));return{label:d.jsxs(d.Fragment,{children:[rk(Se.label),RP(Se.label)&&d.jsx("span",{className:"badge-recommended",children:"recommended"})]}),description:Se.description,sample:Se.preview,hint:G.note&&!G.multi?{k:"n",label:"add a note",icon:"edit",on:(ge==null?void 0:ge.note)===void 0}:void 0,checked:_e,field:_e&&!oe&&(ge==null?void 0:ge.note)!==void 0?we("a note for the agent, sent with your pick"):void 0}});return G.note&&Ce.push({label:G.note.label,description:oe?void 0:"your own answer",checked:oe,field:oe?we("your own answer"):void 0}),d.jsxs("div",{className:We("card-page",!Le&&"card-page-off"),children:[d.jsx(Ef,{children:G.text||g}),Le&&ke,d.jsx(xf,{rows:Ce,cursor:Le?O:void 0,onCursor:D,onPick:Se=>{var _e;q(Se),(_e=r.current)==null||_e.focus()},onHint:Z}),de(G,ge)]},G.id)};return d.jsxs(Sw,{root:r,id:e.id,onKeyDown:Ee,onKeyUp:_.onPasteKeyUp,onPaste:_.onPaste,children:[w.length>1&&d.jsx("div",{className:"card-tabs",children:d.jsx(Jf,{label:"questions",owner:"ask",items:[...w.map((G,ue)=>({id:String(ue),label:G.header||`question ${ue+1}`,lead:d.jsx("span",{className:We("dot card-step",ll(N[ue])&&"answered")})})),{id:String(w.length),label:"send",far:!0}],current:String(j),onPick:G=>{var ue;be(Number(G)),(ue=r.current)==null||ue.focus()}})}),d.jsxs("div",{className:"card-pages",children:[w.map(ae),$c(w)!==-1&&d.jsxs("div",{className:We("card-page",!$&&"card-page-off"),children:[d.jsx(Ef,{children:"Send these answers?"}),$&&ke,d.jsx(xf,{hover:!0,rows:w.map((G,ue)=>{const Le=ll(N[ue])?NP(G,N[ue]):void 0;return{label:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"row-dim",children:G.header||`question ${ue+1}`})," ",d.jsx("span",{className:We(!Le&&"row-dim"),children:Le?Le.pick:"no answer yet"})]}),description:Le==null?void 0:Le.note}}),onPick:G=>{var ue;be(G),(ue=r.current)==null||ue.focus()}}),de()]})]})]})}const WB=ZS("top"),KB=5*6e4;function MT({usage:e,limits:t,auth:n,now:r}){const o=t?qz(t,r):[],i=o.length?zz(n):void 0,l=t&&r-t.at>KB?uk(r-t.at):null,c=(e==null?void 0:e.cost)!==void 0?` · ${uu(e.cost)}`:"";return d.jsxs("div",{className:"usage-figures",children:[e&&d.jsx(Fx,{name:"context",used:e.used/e.size,sub:`${$b(e.used)} of ${$b(e.size)}${c}`}),i&&d.jsx("div",{className:"usage-who section-title",children:i}),o.map(u=>d.jsx(Fx,{name:u.name,used:u.used,sub:u.sub},u.key)),l&&d.jsxs("div",{className:"usage-stale hint",children:["read ",l," ago"]})]})}function ZB({onClose:e,...t}){return d.jsx(Rs,{className:"usage-panel",anchor:"parent",placement:WB,onDismiss:e,onKey:n=>{n.key==="Escape"&&(n.stopPropagation(),e())},children:d.jsx(MT,{...t})})}function Fx({name:e,used:t,sub:n}){const r=Math.max(0,Math.min(1,t));return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"usage-row",children:[d.jsx("span",{className:"usage-name",children:e}),d.jsx("span",{className:"meter",children:d.jsx("span",{className:"meter-fill",style:{"--meter":r}})}),d.jsxs("span",{className:"usage-fig",children:[Math.round(100*t),"%"]})]}),d.jsx("div",{className:"usage-sub hint",children:n})]})}function PT(e,t,n){const r=S.useRef(n);r.current=n,ft([e,t,n==null?void 0:n.id],()=>{if(!e||!t)return;const o=()=>{const i=r.current;i!=null&&i.available&&e.send({t:"agent-check",agent:i.id})};return o(),window.addEventListener("focus",o),()=>window.removeEventListener("focus",o)})}const Bx=[],qB=[],GB=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),VB=150,YB=3,Ux=e=>({kind:"cmd",c:e});function XB(e,t,n,r){return e==="command"?r?n===0?d.jsx("span",{className:"live-text",children:"starting the agent to see what it offers"}):"no matching command":"no session has run this agent yet, so it has offered no commands":t?"no matches":d.jsx("span",{className:"live-text",children:"listing files"})}function QB(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="worktree"?`@${e.branch} `:e.kind==="changes"?"@changes ":`@${e.path} `}function Mc({active:e,draft:t,archived:n,found:r,project:o,greenfield:i,placement:l="dock"}){var Nu,Ul,Hl,Hs,Ws,Tu,$i;const c=l==="screen",u=ut(),p=it(),{storage:h}=ao(),m=Yn(),g=!!t,w=(e==null?void 0:e.worktree.id)??null,y=e==null?void 0:e.worktree.repoId,b=o?kl:n?n.id:r?r.id:Tl(e),_=!!n||!!r,T=n?n.restorable:!!r&&!r.locked,x=Rt(b,"draft"),N=Rt(b,"attachments"),j=Rt(b,"notice"),$=((Nu=e==null?void 0:e.worktree.owns)==null?void 0:Nu.join(", "))??"",P=S.useRef({id:w,owns:$});ft([w,$],()=>{const U=P.current;P.current={id:w,owns:$},!(U.id!==w||U.owns===$||!$||!b||n)&&u({a:"notice",id:b,text:`Running its own ${$} here now: this branch changed it.`})});const R=Rt(b,"mark"),A=(R==null?void 0:R.by)==="walk"?R:void 0,O=Rt(w,"chat"),D=Rt(w,"queue"),z=S.useMemo(()=>w&&!g?$k(O):null,[w,g,O]),X=Rt(w,"cardParked"),ne=Rt(w,"sending"),ee=S.useMemo(()=>w&&!g&&!ne?NE(O):null,[w,g,ne,O]),ie=Rt(w,"askRevived"),be=!z&&ee&&ie===ee.id?ee:null,C=z&&X!==z.id?z:be,Z=be?il(be.id):null,Y=Rt(Z,"attachments"),q=z?X===z.id?z:null:ee&&!be?ee:null,F=S.useRef(null),re=Si(),Ee=Nk(),Te=Rt(Ee,"page"),de=au(),{onPaste:ke,onPasteKey:ae,onPasteKeyUp:G}=HS(b,w),ue=y4(),Le=sT(),ge=v9(),oe=MB(),we=S.useMemo(()=>w&&!g?$B(O,{queued:D.length,sending:!!ne,card:!!(C||q),dismissed:oe}):null,[w,g,O,D.length,ne,C,q,oe]),Ce=U=>b&&u({a:"set-draft",id:b,text:U}),Se=M(U=>U.clientId),_e=M(U=>U.repos),Be=M(U=>U.repos.find(Ze=>Ze.id===(e==null?void 0:e.worktree.repoId))??null),wt=M(U=>U.defaultAgent),on=M(U=>U.agentChosen),Et=g||!!i||!!o,Vt=!Et&&!!e&&!e.worktree.agent,Ft=Et||Vt,Ht=(t==null?void 0:t.agent)??wt,Me=M(U=>U.agents.find(Ze=>Ze.id===(Ft?Ht:e==null?void 0:e.worktree.agent)));PT(p,w??(Et?"new":null),Me);const St=!!(Me!=null&&Me.quick),sn=(Me==null?void 0:Me.models)??Bx,ln=(Me==null?void 0:Me.efforts)??Bx,[lt,jt]=D9(Ht),[Kt,xn]=M9(Ht),Dt=M(U=>U.agents),jn=(U,Ze)=>{if(U===Ht){jt(Ze);return}z9(h,U,Ze),Qt(U)},Qt=U=>{g?u({a:"draft-agent",id:U}):p==null||p.send({t:"set-default-agent",agent:U})},V=vB(Me,Dt,Ft),pe=V==null?void 0:V.other,Ye=Rt(w,"model"),nt=Rt(w,"effort"),yt=Rt(w,"usage")??(e==null?void 0:e.usage),[Jt]=dT(Be),ye=(t==null?void 0:t.profile)??Jt,[Ae,Yt]=P9(Be),B=(e==null?void 0:e.worktree.mode)??Qd,me=M(U=>U.picking),De=M(U=>U.layout.term),Xe=$E((e==null?void 0:e.procs)??[]),Pt=yn("composer"),_t=Rt(w,"files"),He=S.useMemo(()=>ME(_t??qB),[_t]),ze=M(U=>U.visible),qe=S.useMemo(()=>ZN(ze,y,w),[ze,y,w]),ht=Rt(w,"git"),Ct=(ht==null?void 0:ht.files.length)??(e==null?void 0:e.dirty)??0,Bt=(ht==null?void 0:ht.unpushed)??(e==null?void 0:e.unpushed)??0,qt=M(U=>{var Ze;return w?(Ze=U.shipping[w])==null?void 0:Ze.op:void 0}),vn=M(U=>{var Ze;return w?(Ze=U.shipping[w])==null?void 0:Ze.step:void 0}),On=M(U=>wl(U,y)),Cn=M(U=>{var Ze;return On?(Ze=U.shipping[On.id])==null?void 0:Ze.op:void 0}),Xn=On&&Be&&Et?l_(Be.defaultBranch,On):null,Kn=M(U=>g?UP(U.rows,y,Ht,wt):w),se=Rt(Kn,"commands"),Ne=se.some(U=>U.name==="compact"),at=$o(e==null?void 0:e.agent),gt=M(U=>BE(U,w)),Wt=at&&!!w&&!g,gn=e==null?void 0:e.worktree.lastTurn,kn=!x.trim()&&N.length===0,tr=!g&&!i&&kn&&!at?gn:void 0,dn=!g&&!i&&e&&Xi(e.worktree)?e.worktree.landing:void 0,fn=!!(dn!=null&&dn.ready)&&!dn.stale&&!Cd(dn,Ct,St,Me==null?void 0:Me.name),Nt=kn&&(!at||fn)?dn:void 0,Pr=Ct>0&&!!(Nt!=null&&Nt.subject),pt=Ct||(((Ul=ht==null?void 0:ht.extras)==null?void 0:Ul.committed.length)??0),In=!g&&!i&&kn&&!at&&!!e,je=!!(e!=null&&e.worktree.landed)&&Ct===0,Ve=In&&je,rt=e?Af({...e.worktree,landed:je}):void 0,et=In&&!Ve?rt:void 0,cn=!je&&(rt==null?void 0:rt.state)==="open"?rt:void 0,wn=!!cn&&(Ct>0||Bt>0),sr=(rt==null?void 0:rt.state)==="closed",Lr=fi((Be==null?void 0:Be.config)??{}),K=S.useMemo(()=>LB(Jd(fi((Be==null?void 0:Be.config)??{}),Be==null?void 0:Be.defaultBranch)),[Be]),fe=()=>w&&(p==null?void 0:p.send({t:"chat",worktreeId:w,text:"/compact"})),Qe=Et?"nothing to compact until the first reply":Ne?at?"wait for the turn to end":void 0:"this agent offers no compact command",At=Ne&&yt?Bz(yt.used/yt.size):void 0,mt=Me==null?void 0:Me.limits,Zt=Et?void 0:yt,Dr=(!!w||Et)&&!!(Zt||mt),fr=Date.now(),[yo,_r]=S.useState(!1),vr=S.useRef(0),br=re?()=>d.jsx(MT,{usage:Zt,limits:mt,auth:Me==null?void 0:Me.auth,now:Date.now()}):void 0,lo=()=>{window.clearTimeout(vr.current),_r(!1)};ft([w],lo);const Xt=Tk(),kt=(Xt==null?void 0:Xt.owner)==="composer"&&Xt.key==="usage";ft([kt],()=>{kt&&lo()});const ts=()=>[{id:"compact",label:"compact the context",detail:Qe||!yt?void 0:Fz(yt.used/yt.size),disabled:Qe,onClick:fe}],[Mn,en]=S.useState(0),[Zr,hr]=S.useState(null),[Ie,L]=S.useState(null),H=S.useRef(null),J=b&&!_&&!o?wx(x,Mn,U=>qe.some(Ze=>Ex(U,Ze))):null,ve=J!==null&&J.from!==Zr&&!A,Oe=J==null?void 0:J.kind,Ke=J==null?void 0:J.query,It=S.useMemo(()=>{if(Ke===void 0)return[];if(Oe==="command")return Ke.trim()?O8(DB(K,se),Ke).slice(0,8).map(Ux):Dx(K,se).rows.map(Ux);const U=[],Ze=(ht==null?void 0:ht.files.length)??0;Ze>0&&"changes".startsWith(Ke.toLowerCase())&&U.push({kind:"changes",n:Ze});const Lt=Ke.trim(),Gt=Lt?qe.filter(Bn=>Ex(Lt,Bn)):qe.slice(0,YB);return U.push(...Gt.map(Bn=>({kind:"worktree",...Bn}))),U.push(...pB(_t??[],He,(ht==null?void 0:ht.files)??[],Ke,8)),U},[Oe,Ke,_t,He,ht,se,K,qe]),bn=Oe==="command"&&Ke!==void 0&&!Ke.trim()?Dx(K,se).more:0,Nn=S.useRef(null),Fn=S.useRef(null),ns=()=>{var U;return(U=F.current??Nn.current)==null?void 0:U.focus()},$n=ns;ft([i?e==null?void 0:e.worktree.id:null],()=>{if(!i)return;const U=requestAnimationFrame(()=>{var Lt;const Ze=document.activeElement;(!Ze||Ze===document.body)&&((Lt=Nn.current)==null||Lt.focus())});return()=>cancelAnimationFrame(U)});const ms=M(U=>U.focusChat),$l=S.useRef(ms),ma=!!gS();ft([ms],()=>{if(ms===$l.current||($l.current=ms,ma!==!!i))return;const U=requestAnimationFrame(ns);return()=>cancelAnimationFrame(U)});const rs=C==null?void 0:C.id,Ms=S.useRef({id:w,cardUpId:rs});ft([w,rs],()=>{const U=Ms.current;if(Ms.current={id:w,cardUpId:rs},rs||!U.cardUpId||U.id!==w||ma!==!!i||re&&!q)return;const Ze=requestAnimationFrame(()=>{var Gt;const Lt=document.activeElement;(!Lt||Lt===document.body)&&((Gt=Nn.current)==null||Gt.focus())});return()=>cancelAnimationFrame(Ze)});const Po=M(U=>U.walked),_i=S.useRef(Po);ft([Po],()=>{if(Po===_i.current||(_i.current=Po,ma!==!!i))return;const U=requestAnimationFrame(()=>{const Ze=document.activeElement;(!Ze||Ze===document.body||Ze.closest(".rail"))&&ns()});return()=>cancelAnimationFrame(U)});const Rl=YS({results:It,keyOf:U=>U.kind==="cmd"?`c:${U.c.name}`:U.kind==="changes"?"changes":U.kind==="worktree"?`w:${U.id}`:`f:${U.path}`,q:(J==null?void 0:J.query)??"",listRef:H,tabPicks:!0,onPick:U=>{if(!J)return;const{text:Ze,caret:Lt}=R8(x,J,QB(U));Ce(Ze),hr(J.from),L(U.kind==="cmd"&&U.c.hint?{name:U.c.name,hint:U.c.hint}:null),requestAnimationFrame(()=>{const Gt=Nn.current;Gt&&(Gt.focus(),Gt.setSelectionRange(Lt,Lt),en(Lt))})}}),Nr=w||_?G8(x):null,Ol=Ie&&x===`/${Ie.name} `?Ie.hint:null,ga=Nr===""&&e?g?" a command to run in the new worktree's terminal":` a command to run in ${e.worktree.title}; the agent sees its output with your next message`:null,Ni=Ol??ga,ka=(e==null?void 0:e.worktree.title)??"untitled",zr=(Hl=gn==null?void 0:gn.recap)==null?void 0:Hl.text,Ti=()=>{w&&pi(p,u,{t:"land",worktreeId:w})},ji=U=>{w&&(p==null||p.send({t:"judge",worktreeId:w,...U?{note:U}:{}}))},pu=!!((Hs=Be==null?void 0:Be.config.check)!=null&&Hs.trim()),Ps=Fk(dn,Ct,St),wa=In&&!qt&&!Et&&Xi(e.worktree)&&!je&&!sr&&pt>0&&(!dn||!!dn.stale||Ps==="unanswered"),Ml="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",Fr=wn?"update":Fg(Lr,(e==null?void 0:e.worktree)??{}),gs=Be?Cf(Be):"main",Pl=wn&&cn?`Commit, take ${gs} in and push the branch; PR #${cn.number} takes the new commits.`:`${Jd(Lr,Be==null?void 0:Be.defaultBranch)}.`,Ls=et&&!zr?{links:uz(et)}:{},Tr=w?Ve?{word:"archive",kind:"archive",line:(rt==null?void 0:rt.state)==="merged"?Ts(rt):`landed on ${(Be==null?void 0:Be.defaultBranch)??"main"}.`,tip:Ml,run:()=>sa(p,u,[w])}:(et==null?void 0:et.state)==="open"&&!wn?f_(et)?{word:"land",kind:"merge",line:Ad(zr??Ts(et)),tip:`${Ts(et)} Merge the PR now, by the method the repo allows.`,...Ls,run:Ti,ships:!0}:{word:"view",kind:"view",line:Ad(zr??Ts(et)),tip:`${Ts(et)} Open the PR on GitHub.`,...Ls,run:()=>window.open(et.url,"_blank")}:(et==null?void 0:et.state)==="closed"?{word:"archive",kind:"archive",line:Ts(et),tip:`${Ts(et)} ${Ml}`,run:()=>sa(p,u,[w])}:wa?{word:"check",kind:"check",line:(dn==null?void 0:dn.subject)??Ad(zr??mz(pt)),tip:h_(dn,pu,Ps),run:ji}:Nt!=null&&Nt.ready&&!Cd(Nt,Ct,St,Me==null?void 0:Me.name)?{word:Fr,kind:"ship",line:Nt.subject??Ad(zr??(xb(Nt,pt)||"ready")),tip:[xb(Nt,pt),pz(gs,e==null?void 0:e.behind),Pl,Nt.subject&&Ct>0?"Tab from the word edits the message first.":""].filter(Boolean).join(" "),run:Ti,ships:!0}:null:null,ya=(Ws=e==null?void 0:e.worktree.lands)==null?void 0:Ws.at(-1),va=ya&&u_(ya),ks=((Tr==null?void 0:Tr.kind)==="ship"||(Tr==null?void 0:Tr.kind)==="check")&&Nt?gz(Nt,Ps):(Tr==null?void 0:Tr.word)==="archive"&&va?Wr(va):null,Ds=S.useRef(null);qt!=="land"&&(Ds.current=w&&(Tr!=null&&Tr.ships)?{id:w,verb:Tr,under:ks}:null);const Ci=qt==="land"&&kn&&((Tu=Ds.current)==null?void 0:Tu.id)===w?Ds.current:null,Pn=Ci?Ci.verb:Tr,mu=($i=Pn==null?void 0:Pn.links)!=null&&$i.length?dz(Pn.line,Pn.links):null,ba=!!(Pn!=null&&Pn.ships)&&qt==="land",Ai=bk(vn,xk),xa=qc(e,"commit"),Ea=qc(e,"check"),zs=m_(ba?xa:Ea),gu=oa(Uk(zs)?zs==null?void 0:zs.since:void 0),Ll=Nt?Nt.check==="pending"&&Ea&&zs===Ea?ff("Checking the work",Ea,gu):Cd(Nt,Ct,St,Me==null?void 0:Me.name):null,Sa=Pn&&ba?Ai?`${Pn.word}: ${Ai}`:`${Pn.word} ${Pn.line}`:null,ku=Sa&&xa&&zs===xa?ff(Sa,xa,gu):Sa,wu=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?Pn?"":Ll||(et?Ts(et):tr?Bk(tr):i?`describe ${ka}…`:Et?"describe a change":c?`message agent on ${ka}`:`message agent on ${ka}; / for a command, ! for a shell command`):"no worktree selected",_a=x!==""||Ni||!e?null:ba?Ai?null:Ci?Ci.under:ks:Pn?ks:et||Ll?zr??(Nt==null?void 0:Nt.subject)??null:null,Na=S.useRef(!1);S.useEffect(()=>{const U=ve&&!Na.current;Na.current=ve,U&&((J==null?void 0:J.kind)==="file"&&w?Vf(w,m.getState(),{sock:p,dispatch:u}):(J==null?void 0:J.kind)==="command"&&Kn&&se.length===0&&(p==null||p.send({t:"list-commands",worktreeId:Kn})))},[ve,J==null?void 0:J.kind,se.length,w,Kn,p,m,u]);const yu=()=>{if(!e)return;const U=[],Ze=Te;if(Ze.url)try{const Bn=new URL(Ze.url);U.push(`current route: ${Bn.pathname}${Bn.search}`)}catch{}Ze.title&&U.push(`page title: ${Ze.title}`);const Lt=[];i&&Lt.push(_9(e.worktree.title,Be==null?void 0:Be.configFile)),U.length>0&&Lt.push(`What the user is looking at right now:
|
|
238
|
-
${U.join(`
|
|
239
|
-
`)}`);const Gt=Y8(O);return Gt&&Lt.push(Gt),Lt.length>0?Lt:void 0},vu=U=>{Et?Yt(U):w&&U!==B&&(p==null||p.send({t:"set-worktree-mode",worktreeId:w,mode:U}))},ir=U=>b&&u({a:"notice",id:b,text:U}),bu=(U,Ze="")=>{if(!e||!w)return;if(U==="handoff"){if(Et)return ir("a new worktree has nothing to continue yet");const Gt=Y4(Ze,_e,e.worktree.repoId);"pick"in Gt?u({a:"open",overlay:{kind:"handoff",worktreeId:w}}):"error"in Gt?ir(Gt.error):p==null||p.send({t:"handoff-ask",worktreeId:w,repoId:Gt.repo.id,...Gt.text?{text:Gt.text}:{}});return}if(U==="archive"){je||sr?sa(p,u,[w]):ir("archive is for a landed worktree; this one has not landed");return}if(U==="check"){Et||!Xi(e.worktree)?ir("nothing to check from here"):at?ir("wait for the turn to end"):pt===0?ir("nothing to check: no changes here"):ji(Ze||void 0);return}const Lt=dn?Cd(dn,Ct,St,Me==null?void 0:Me.name):null;Et||!Xi(e.worktree)?ir("nothing to land from here"):je?ir(`already landed on ${(Be==null?void 0:Be.defaultBranch)??"main"}`):Lt?ir(Lt):at&&(!dn||dn.stale)?ir("wait for the turn to end"):dn!=null&&dn.stale?ir("the work changed since this was checked; check again first"):Ti()},Ta=N.some(ki),Fs=()=>{b&&(p==null||p.send({t:"set-draft",boxId:b,text:x,clientId:Se}))},Ii=(U,Ze,Lt,Gt)=>u({a:"hold-send",id:U,log:Ze,text:Lt,frame:Gt}),Dl=()=>{if(!b)return;const U=zB(x,K),Ze=U&&PB(U.name)?U.name:void 0;if(o){if(o.busy)return;if(o.why)return ir(o.why);(Ht!==wt||!on)&&(p==null||p.send({t:"set-default-agent",agent:Ht})),Fs(),o.create();return}if(kn)return;const Lt=Nr===null&&(!U||!!Ze&&!!U.args);if(V&&V.kind!=="unready"&&Me&&Lt){ir(V.kind==="installing"?`${Me.name} is still installing`:V.retry?`nothing runs here until ${Me.name} is installed`:V.text);return}const Gt=()=>({text:x.trim(),attachments:N.length?N.map(cl):void 0});if(n){if(!n.restorable)return;if(Nr!==null){ir("nothing runs here until it is restored");return}const vo={t:"restore-worktree",archiveId:n.id,clientId:Se};if(Ta)return Ii(b,b,x.trim(),vo);Fs(),p==null||p.send(bc(vo,b,x.trim(),N)),u({a:"sending",id:b,message:Gt()}),u({a:"sent-box",id:b});return}if(r){if(r.locked)return;if(Nr!==null){ir("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}const vo={t:"adopt-worktree",worktreeId:r.id,clientId:Se};if(Ta)return Ii(b,b,x.trim(),vo);Fs(),p==null||p.send(bc(vo,b,x.trim(),N)),u({a:"sending",id:b,message:Gt()}),u({a:"sent-box",id:b});return}if(!e||!w)return;if(Nr!==null){if(Nr&&qt&&!g){ir(`${wA(qt)} is running here; run the command once it is done`);return}Nr&&g?u({a:"term-run",id:w,command:Nr}):Nr&&(p==null||p.send({t:"exec",worktreeId:w,command:Nr})),Ce("");return}if(U&&!Ze){bu(U.name,U.args),Ce("");return}if(Ze&&!(U!=null&&U.args)){vu(Ze),Ce("");return}if(t!=null&&t.batch&&N.length){ir("a batch takes no attachments; remove them or turn batch off");return}const Bn=U?U.args:x.trim(),co=yu(),Wl=N.length?N.map(cl):void 0;if(Ze&&vu(Ze),Et){const vo=ou(e.worktree)?{worktreeId:w}:{},fh={clientId:Se,repoId:e.worktree.repoId,context:co,agent:Ht,profile:ye,mode:Ze??Ae,...lt?{model:lt}:{},...Kt?{effort:Kt}:{},...DE(t)?{carry:!0}:{}};if((Ht!==wt||!on)&&(p==null||p.send({t:"set-default-agent",agent:Ht})),t!=null&&t.batch)Fs(),p==null||p.send({t:"batch-worktrees",repoId:e.worktree.repoId,prompt:Bn,agent:Ht,...lt?{model:lt}:{},...Kt?{effort:Kt}:{},boxId:b}),u({a:"sent-box",id:b});else{const hh=t&&t.variants>1?{variants:t.variants}:{},ju={t:"create-worktree",...fh,...vo,...hh};Ta?Ii(b,b,Bn,ju):(Fs(),p==null||p.send(bc(ju,b,Bn,N)),u({a:"sending",id:b,message:{text:Bn,attachments:Wl}}),u({a:"sent-box",id:b}))}}else{Vt&&(p==null||p.send({t:"set-worktree-model",worktreeId:w,model:lt}),p==null||p.send({t:"set-worktree-effort",worktreeId:w,effort:Kt}));const vo={t:"chat",worktreeId:w,clientId:Se,context:co};Ta?Ii(b,w,Bn,vo):(Fs(),p==null||p.send(bc(vo,b,Bn,N)),gt||u({a:"sending",id:w,message:{text:Bn,attachments:Wl}}),u({a:"sent-box",id:b}))}i&&u({a:"show-chat"})},uh=U=>{if(!w||(be==null?void 0:be.ask.kind)!=="question")return;if(!U.some(ll))return u({a:"ask-revive",id:w});const Ze=nk(be.ask.questions,U).join(`
|
|
240
|
-
`),Lt={t:"chat",worktreeId:w,clientId:Se,context:yu()};if(Z&&Y.some(ki))Ii(Z,w,Ze,Lt);else{const Gt=Y.length?Y.map(cl):void 0,Bn=Gt&&Z?{attachments:Gt,boxId:Z}:{};p==null||p.send({...Lt,text:Ze,...Bn}),Gt&&Z&&u({a:"clear-attachments",id:Z}),u({a:"sending",id:w,message:{text:Ze,attachments:Gt}})}u({a:"answered",id:w}),u({a:"ask-revive",id:w})},zl=M(U=>U.autoSend);ft([zl,w],()=>{!zl||zl!==w||kn||ma!==!!i||(u({a:"auto-sent"}),Dl())});const dh=()=>{const U=N[N.length-1];return!b||!U?!1:(u({a:"detach",id:b,key:U.key}),!0)},ja=U=>{b&&(u({a:"walk",id:b,walk:U.walk,text:U.text}),requestAnimationFrame(()=>{var Ze;(Ze=Nn.current)==null||Ze.setSelectionRange(U.text.length,U.text.length),en(U.text.length)}))},Bs=()=>{b&&A&&u({a:"walk",id:b,walk:null,text:x})},xu=Et?[]:O.map(U=>U.kind==="user"?U.attachments:void 0),Fl=Et?[]:D.flatMap(U=>U.attachments??[]),ws=e==null?void 0:e.worktree.plan,Eu=JN(e==null?void 0:e.worktree.id,ws),Bl=Wt&&!C,Su=M(U=>U.reading),[Us,_u]=S.useState(!1),Ca=c&&Su&&!q&&(C?!Us:kn&&!ue);return ft([Ca],()=>{if(Ca||!C)return;const U=requestAnimationFrame(()=>{var Ze;document.activeElement===document.body&&((Ze=F.current)==null||Ze.focus())});return()=>cancelAnimationFrame(U)}),d.jsxs("div",{className:We("composer chat-input",Bl&&"stopping",Ca&&"lean"),onFocus:U=>_u(U.target instanceof HTMLTextAreaElement),onBlur:()=>_u(!1),children:[ws&&e&&d.jsxs("div",{className:"composer-plan",...Pt.contextMenu(()=>Kk(ws,()=>p==null?void 0:p.send({t:"reveal",worktreeId:e.worktree.id,path:ws}),Qo(p))),children:[d.jsx(Tt,{name:"text",className:"icon-inline"}),d.jsx(Fe,{variant:"inline",className:"composer-plan-path","data-tip":ws,onClick:()=>er({dispatch:u},{worktreeId:e.worktree.id,path:ws,view:"preview"}),children:Eu})]}),q&&w&&d.jsx(Xa,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(q.kind==="ask"&&q.outcome?{a:"ask-revive",id:w,askId:q.id}:{a:"card-unpark",id:w}),u({a:"focus-chat"})},children:ub(q)}),(we==null?void 0:we.verb)==="fix"&&"toolId"in we&&w&&d.jsxs(Xa,{icon:"run",verb:we.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>p==null?void 0:p.send({t:"fix",worktreeId:w,toolId:we.toolId}),onDismiss:()=>Lx(we.key),children:["what failed in ",d.jsx("code",{children:we.command})]}),(we==null?void 0:we.verb)==="continue"&&w&&d.jsx(Xa,{icon:"send",verb:we.verb,tip:we.after==="stop"?"Send the agent on from where its turn stopped":we.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:()=>p==null?void 0:p.send({t:"continue",worktreeId:w}),onDismiss:()=>Lx(we.key),children:we.after==="stop"?"where it stopped":we.again?"after the same error again":"after the error"}),ue&&b&&!C&&(e||T||o)&&d.jsx(Xa,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{fD(m,b,ue),ns()},onDismiss:kS,children:ue.kind==="image"?"the image you copied":`the text you copied, ${ue.text.split(`
|
|
241
|
-
`).length} lines`}),Le&&w&&!g&&!C&&b9({prompt:Le,offered:ge,agent:e==null?void 0:e.agent,chat:O})&&d.jsx(Xa,{icon:"download",verb:"install",tip:"Install Toyon as an app: a window of its own, with a Dock icon and no browser bar",onPress:()=>{jx(),Le.prompt()},onDismiss:jx,children:"Toyon as a window of its own, with a Dock icon and no browser bar"}),b&&!C&&Nr===null&&d.jsx(rh,{children:Lg(N,jc(Em(xu),Fl)).map(([U,Ze])=>{const Lt=()=>u({a:"detach",id:b,key:U.key});return U.kind!=="pick"?d.jsx(CT,{item:U,n:Ze,onRemove:Lt},U.key):d.jsx(gw,{pick:U,tipText:U.html,onHover:Gt=>Ee&&an.post(Ee,Gt?{type:"highlight-selector",selector:U.selector,label:ck(U)}:{type:"highlight-clear"}),worktreeId:w,onOpen:(Gt,Bn)=>w&&ia(m,p,w,Gt,Bn),onRemove:Lt},U.key)})}),ve&&J&&d.jsx(E9,{results:It,keyOf:U=>U.kind==="cmd"?`c:${U.c.name}`:U.kind==="changes"?"changes":U.kind==="worktree"?`w:${U.id}`:U.kind==="folder"?`d:${U.path}`:`f:${U.path}`,rowClass:U=>U.kind==="file"||U.kind==="folder"?"qo-file":U.kind==="changes"||U.kind==="worktree"?"picker-row":"picker-row picker-cmd",nav:Rl,listRef:H,empty:XB(J.kind,_t,se.length,Kn!==null),note:bn>0?`type to find ${bn} more`:void 0,groupOf:U=>U.kind==="worktree"?"worktrees":U.kind==="cmd"?"commands":"files",row:U=>{const Ze=((ht==null?void 0:ht.files.length)??0)>0;return U.kind==="file"?vg(U.path,U.status,J.query,{gutter:Ze}):U.kind==="folder"?vg(U.path,void 0,J.query,{folder:!0,gutter:Ze}):U.kind==="changes"?d.jsx(An,{label:"@changes",hint:`${U.n} uncommitted ${U.n===1?"file":"files"}`}):U.kind==="worktree"?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${U.dot}`}),d.jsx(An,{label:U.title,hint:wr(U.at)})]}):d.jsx(U9,{c:U.c,query:J.query})}}),C&&Ca&&w&&d.jsx(Xa,{icon:"chat",verb:"answer",tip:"Back to the question",onPress:()=>u({a:"answered",id:w}),children:ub(C)}),C&&w?C.kind==="handoff"?d.jsx(IB,{item:C,worktreeId:w,rootRef:F},C.id):C.ask.kind==="question"?d.jsx(HB,{item:C,ask:C.ask,worktreeId:w,rootRef:F,numbers:jc(Em(xu),Fl),onScreen:c,onAnswer:be?uh:void 0},C.id):d.jsx(UB,{item:C,ask:C.ask,worktreeId:w,rootRef:F},C.id):d.jsxs("div",{className:We("composer-field",Nr!==null&&"shell",A&&"recalled"),children:[d.jsx(Zc,{size:"lg",bare:!0,font:Nr!==null?"mono":"ui",ref:Nn,value:x,onChange:U=>{var co;const Ze=U.target.value,Lt=U.target.selectionStart??Ze.length;Ce(Ze),en(Lt),Rl.setIndex(0);const{inputType:Gt}=U.nativeEvent;hr(Gt==="insertFromPaste"||Gt==="insertFromDrop"?((co=wx(Ze,Lt))==null?void 0:co.from)??null:null)},onKeyUp:U=>{G(),en(U.currentTarget.selectionStart??0)},onClick:U=>{en(U.currentTarget.selectionStart??0),Bs()},onPaste:ke,onScroll:U=>{Fn.current&&(Fn.current.scrollTop=U.currentTarget.scrollTop)},onKeyDown:U=>{var Ze;if(ae(U),!U.nativeEvent.isComposing){if(ve){if(U.key==="Escape"){U.preventDefault(),U.stopPropagation(),hr((J==null?void 0:J.from)??null);return}if(Rl.onKeyDown(U))return}if((U.key==="ArrowUp"||U.key==="ArrowDown")&&!U.altKey&&!U.ctrlKey){const Lt=U.key==="ArrowUp",Gt=D.at(-1);if(Lt&&!U.metaKey&&!A&&x===""&&w&&!g&&Gt!==void 0){U.preventDefault(),AS(m,p,w,D.length-1);return}const Bn=U.metaKey?Lt?"first":"box":Lt?"up":"down",co=w?h9(O,A??null,x,Bn):null;if(co){U.preventDefault(),(co.walk!==A||co.text!==x)&&ja(co);return}}if(A&&U.key==="Escape"){U.preventDefault(),U.stopPropagation(),ja({walk:null,text:A.from});return}if(U.key==="Escape"&&at&&w&&!g){U.preventDefault(),U.stopPropagation(),p==null||p.send({t:"stop-agent",worktreeId:w});return}if(A&&GB.has(U.key)&&Bs(),U.key==="Tab"&&!U.shiftKey&&x===""){const Lt=(Ze=U.currentTarget.closest(".composer"))==null?void 0:Ze.querySelector(".composer-verb");if(Lt&&!Lt.disabled){U.preventDefault(),Lt.focus();return}if(Pr){U.preventDefault(),u({a:"edit-commit"});return}}U.key==="Enter"&&(re?U.metaKey||U.ctrlKey:!U.shiftKey)?(U.preventDefault(),Dl()):U.key==="Backspace"&&x===""&&dh()&&U.preventDefault()}},placeholder:_a||Pn?"":wu,disabled:o?o.busy:!e&&!T}),Ni&&d.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[d.jsx("span",{className:"picker-typed",children:x}),Ni]}),w&&Nr===null&&x.includes("@")&&d.jsx("div",{ref:Fn,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:U=>GN(U,e==null?void 0:e.worktree.path,w,{sock:p,dispatch:u}),children:d.jsx(qN,{text:x,worktreeId:w,root:e==null?void 0:e.worktree.path,inField:!0})}),(_a||Pn)&&d.jsxs("div",{className:"composer-ghost composer-standing","aria-hidden":Pn?void 0:"true",children:[d.jsx("span",{className:We("composer-placeholder",ba&&"live-text"),children:ku||(Pn?d.jsxs(d.Fragment,{children:[d.jsx(Fe,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!Pn.ships&&!!qt,...Ut(Pn.tip,void 0,{placement:"top"}),onClick:()=>{var U;Pn.run(),re||(U=Nn.current)==null||U.focus()},onKeyDown:U=>{U.key==="Tab"&&!U.shiftKey&&Pr&&(U.preventDefault(),u({a:"edit-commit"}))},children:Pn.word})," ",d.jsx("span",{className:"composer-verb-line",children:mu?mu.map(U=>typeof U=="string"?U:d.jsxs(Fe,{variant:"inline",className:"composer-verb-tail",...Ut(U.tip,void 0,{placement:"top"}),onClick:()=>{var Ze;window.open(U.url,"_blank"),re||(Ze=Nn.current)==null||Ze.focus()},...Pt.contextMenu(()=>[{id:"open-link",label:U.open,onClick:()=>window.open(U.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>nn(U.url)}]),children:[U.text," ",d.jsx(Tt,{name:"external",className:"icon-inline"})]},U.text)):Pn.line})]}):wu)}),_a&&d.jsxs(d.Fragment,{children:[`
|
|
242
|
-
`,d.jsx("span",{className:"composer-subline",children:_a})]})]}),Bl&&d.jsx(Mt,{icon:"stop",tone:"danger",className:We("composer-stop",(e==null?void 0:e.stopping)&&"pending"),label:e!=null&&e.stopping?"Stopping: the agent is winding down; press again to send the stop once more":`Stop the agent (context up to here is kept${D.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>w&&(p==null?void 0:p.send({t:"stop-agent",worktreeId:w}))})]}),j&&d.jsx("div",{className:"hint composer-notice",role:"status",children:j}),!C&&d.jsxs("div",{className:"hint composer-knobs",children:[d.jsxs("span",{className:"spawn-left",children:[Ft?Dt.length>1?d.jsx(F9,{agents:Dt,agent:Ht,model:lt,onChange:jn,onClose:$n}):d.jsx($x,{models:sn,value:lt,onChange:jt,onClose:$n}):e&&d.jsx($x,{models:sn,value:e.worktree.model??"",current:Ye,onChange:U=>p==null?void 0:p.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:U}),onClose:$n}),Ft?d.jsx(Ax,{efforts:ln,value:Kt,onChange:xn,onClose:$n}):e&&d.jsx(Ax,{efforts:ln,value:e.worktree.effort??"",current:nt,onChange:U=>p==null?void 0:p.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:U}),onClose:$n}),Et?!o&&d.jsx(Ix,{value:Ae,onChange:Yt,onClose:$n}):e&&d.jsx(Ix,{value:B,onChange:U=>p==null?void 0:p.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:U}),onClose:$n}),Dr&&d.jsxs("span",{className:"usage-knob",onMouseEnter:()=>{kt||(window.clearTimeout(vr.current),vr.current=window.setTimeout(()=>_r(!0),VB))},onMouseLeave:()=>{window.clearTimeout(vr.current),_r(!1)},onFocus:U=>{kt||!U.target.matches(":focus-visible")||(window.clearTimeout(vr.current),_r(!0))},onBlur:lo,children:[d.jsx(Mt,{icon:d.jsx(S9,{fraction:Zt?Zt.used/Zt.size:0,level:mt?Wz(mt,fr):void 0}),tone:"chrome",on:kt,silent:!0,label:Zt?`${Math.round(100*Zt.used/Zt.size)}% of context`:mt?Rb(mt,fr):"",detail:[...Zt&&mt?[Rb(mt,fr)]:[],...At?[At]:[]],...Pt.dropdown(ts,"left","usage",br),...Pt.contextMenu(ts,"usage")}),yo&&d.jsx(ZB,{usage:Zt,limits:mt,auth:Me==null?void 0:Me.auth,now:fr,onClose:lo})]})]}),d.jsxs("span",{className:"spawn-tools",children:[b&&(e||T||o)&&d.jsx(Mt,{icon:"attach",tone:"chrome",label:c?"Attach a picture":"Attach a picture or a file, or drop one here",onClick:()=>zS(m,b,{images:c})}),!i&&!_&&!c&&!o&&d.jsx(Mt,{icon:"terminal",tone:"chrome",on:De,className:"composer-term",disabled:!e,label:Xe?Xe.tip:"Terminal",hint:zt("terminal"),badge:Xe&&d.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(Xe&&!De&&w?{a:"term-stream",id:w,stream:Xe.stream}:{a:"toggle-terminal"})},...Pt.contextMenu(()=>e&&w?v8(e.procs,w,De,{sock:p,dispatch:m.dispatch}):[])}),!i&&!de&&!_&&!c&&!o&&d.jsx(Mt,{icon:"pick",label:"Pick an element on the page to attach",hint:zt("pick"),on:me==="chat",disabled:!Ee,onClick:()=>Ee&&Kc(Ee,me,u,"chat")}),re&&b&&(e||T||o)&&d.jsx(Mt,{icon:"send",tone:"primary",label:o?"Create the project":"Send",disabled:o?o.busy:kn,onMouseDown:U=>U.preventDefault(),onClick:Dl})]})]}),(V||Xn&&On)&&d.jsxs("div",{className:"composer-notes",children:[V&&Me&&d.jsxs("div",{className:"hint composer-note",role:"status",children:[d.jsx("span",{children:V.text}),(V.retry||pe)&&d.jsxs("span",{className:"composer-note-actions",children:[V.retry&&d.jsx(Fe,{variant:"outline",onClick:()=>p==null?void 0:p.send({t:"install-agent",agent:Me.id}),children:V.retry}),pe&&d.jsxs(Fe,{variant:"outline","data-tip":`${pe.name} is installed and takes this message instead`,onClick:()=>Qt(pe.id),children:["use ",pe.name]})]})]}),Xn&&On&&d.jsxs("div",{className:"hint composer-note",children:[d.jsx("span",{children:Xn}),az(On)&&d.jsx(Fe,{variant:"outline",busy:Cn==="pull-main",disabled:!!Cn,"data-tip":"Fast-forward main to origin",onClick:()=>pi(p,u,{t:"pull-main",worktreeId:On.id}),children:"pull"})]})]})]})}function LT({children:e,className:t,tip:n,...r}){return d.jsxs("label",{className:We("check",t),"data-tip":n,children:[d.jsx("input",{type:"checkbox",className:"check-box",...r}),d.jsx("span",{children:e})]})}const JB=[1,2,3];function eU({draft:e,lead:t}){const n=ut(),r=M(c=>Ei(c,t==null?void 0:t.repoId)),[o]=dT(r),i=M(c=>{var u;return((u=wl(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(Fe,{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:[JB.map(c=>d.jsx(Fe,{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(B9,{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(LT,{className:"hint draft-note",checked:DE(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 tU({row:e}){const t=it(),n=M(l=>l.clientId),r=M(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(no,{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(Fe,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function Pc({placement:e,className:t,width:n,archived:r,found:o}){const i=ut(),l=$s(),c=l4(),u=Rt(l==null?void 0:l.worktree.id,"sending"),p=Cl(),h=e==="centre"&&!r&&(p!=null&&p.assumed)?p:null,m=M(y=>{var b;return((b=y.dragFiles)==null?void 0:b.at)==="chat"}),g=Yn(),w=S.useMemo(()=>cD(g),[g]);return d.jsxs("div",{className:We(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,m&&"drop-over"),style:n===void 0?void 0:{width:n},...w,ref:y=>{var b;y?Rc.el=y:(b=Rc.el)!=null&&b.isConnected||(Rc.el=null)},children:[r?d.jsx(um,{active:null,archived:r,tail:d.jsx(Yz,{item:r})}):o?d.jsx(um,{active:null,found:o,tail:d.jsx(tU,{row:o})}):d.jsx(um,{active:l,lead:h&&d.jsxs("p",{className:"hint chat-centre-note",children:[h.name," has ",d.jsx("code",{children:h.assumed})," and no dev server, so it is chat only for now."," ",d.jsx(Fe,{variant:"inline",onClick:()=>i({a:"open",overlay:{kind:"setup",repoId:h.id}}),children:"add a dev server"})]})}),!r&&!o&&c&&!u&&d.jsx(eU,{draft:c,lead:l}),r?d.jsx(Mc,{active:null,archived:r,placement:e}):o?d.jsx(Mc,{active:null,found:o,placement:e}):d.jsx(Mc,{active:l,draft:c,placement:e})]})}const nU="modulepreload",rU=function(e){return"/"+e},Hx={},Sg=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let l=function(p){return Promise.all(p.map(h=>Promise.resolve(h).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(p=>{if(p=rU(p),p in Hx)return;Hx[p]=!0;const h=p.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${m}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":nU,h||(g.as="script"),g.crossOrigin="",g.href=p,u&&g.setAttribute("nonce",u),document.head.appendChild(g),h)return new Promise((w,y)=>{g.addEventListener("load",w),g.addEventListener("error",()=>y(Error(`Unable to preload CSS for ${p}`)))})}))}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)})},_w=800;function oU(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 Ho=e=>`${e.worktreeId}
|
|
243
|
-
${e.ref??""}
|
|
244
|
-
${e.since??""}
|
|
245
|
-
${e.path}`;class sU{constructor(t){$t(this,"files",new Map);$t(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(Ho(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(Ho(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=Vo();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=Ho(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(Ho(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(Ho(t)),r=n==null?void 0:n.conflict;!(n!=null&&n.buffer)||!r||(n.base={text:r.after,version:r.version},this.setConflict(n,null),n.pending=n.buffer.text(),this.next(n))}follow(t,n){var i,l,c,u;t.connected&&!n.connected&&this.dropped();const r=(i=n.editor)!=null&&i.loose?null:n.editor,o=(l=t.editor)!=null&&l.loose?null:t.editor;if(o&&(!r||Ho(o)!==Ho(r))&&this.closed(Ho(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const p of this.files.values())p.reread=!0,this.next(p);else r&&o&&o.seq===r.seq&&((c=Ro(t,r.worktreeId).git)==null?void 0:c.version)!==((u=Ro(n,r.worktreeId).git)==null?void 0:u.version)&&this.refresh(Ho(r))}opened(t){const n=Ho(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=Vo();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=Vo();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(Ho(t.file))}read(t,n){var g,w;const{file:r}=t;if(n.error){t.open&&this.d.store.dispatch({a:"editor-read",file:r,disk:null,error:n.error});return}const{before:o,after:i,version:l,writable:c,binary:u,tooLarge:p}=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:p}}),!u&&!p&&(l!==null||r.ref)&&this.askBlame(t,l));const h={after:t.buffer?t.buffer.normalize(i):i,version:l};if(!t.base){t.base={text:h.after,version:l};return}const m=((g=t.buffer)==null?void 0:g.text())??t.pending??t.base.text;switch(oU(t.base,m,t.pending,h)){case"same":break;case"adopt":t.base={text:h.after,version:l};break;case"apply":(w=t.buffer)==null||w.replace(h.after),t.base={text:h.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,h);return}this.setConflict(t,null)}askBlame(t,n){const r=Vo();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)},_w))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>sf||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const DT={attach:()=>{},edited:()=>{},saveNow:()=>{}},iU=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),_g=new Map;function aU(e){const t=_g.get(e.seq);return t?(_g.delete(e.seq),t(e),!0):!1}function lU(e,t,n,r){if(e.kind==="bytes")return DT;if(e.kind==="grant")return cU(e,t,n,r);const o=e.handle;let i=null,l,c=null,u=Promise.resolve(),p=!1;const h=()=>(c??(c=(async()=>await o.queryPermission({mode:"readwrite"})==="granted"?!0:await o.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),c),m=()=>{l!==void 0&&r.timers.clear(l),l=void 0},g=()=>{p||(p=!0,m(),n(`read-only: the browser would not save ${t}`))},w=async _=>{if(!await h())return g();const T=await o.createWritable();await T.write(_),await T.close()},y=()=>{if(!i||p)return;m();const _=i.text();u=u.then(()=>w(_)).catch(g)},b=()=>{l!==void 0&&y()};return{attach(_){var T,x;if(_){i=_,(T=r.win)==null||T.addEventListener("pagehide",b);return}l!==void 0&&y(),i=null,(x=r.win)==null||x.removeEventListener("pagehide",b)},edited(){!i||p||(h().then(_=>{_||g()}),m(),l=r.timers.set(y,_w))},saveNow:y}}function cU(e,t,n,r){let o=null,i,l=e.version,c=!1,u=null,p=!1;const h=()=>{i!==void 0&&r.timers.clear(i),i=void 0},m=b=>{p||(p=!0,h(),u=null,n(b))},g=b=>{if(!r.send)return;const _=Vo();c=!0,_g.set(_,T=>{if(c=!1,T.ok?l=T.version:T.reason==="changed"?m(`read-only: ${t} changed on disk; open it again to edit`):m(T.message??`not saved: ${t}`),u!==null&&!p){const x=u;u=null,g(x)}}),r.send({t:"write-loose",id:e.id,content:b,base:l,seq:_})},w=()=>{if(!o||p)return;h();const b=o.text();b.length>sf||(c?u=b:g(b))},y=()=>{i!==void 0&&w()};return{attach(b){var _,T;if(b){o=b,(_=r.win)==null||_.addEventListener("pagehide",y);return}i!==void 0&&w(),o=null,(T=r.win)==null||T.removeEventListener("pagehide",y)},edited(){!o||p||(h(),i=r.timers.set(w,_w))},saveNow:w}}function Nw({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:i,tabs:l,actions:c,menu:u,full:p,onToggleFull:h,onClose:m,closeHint:g="esc",children:w}){const y=yn("pane"),b=h&&d.jsxs(Fe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:h,"data-tip":p?"Split view: show the preview above":"Full height: hide the preview",children:[d.jsx(Tt,{name:p?"split":"full",className:"icon-inline"})," ",p?"split":"full"]}),_=d.jsxs("span",{className:"pane-shape",children:[b,d.jsx(Mt,{icon:"close",label:"Close",hint:g,onClick:m})]});return d.jsxs("div",{className:`pane ${t}`,"data-pane":e,tabIndex:-1,style:n===void 0?void 0:{height:n},children:[r&&d.jsx("div",{className:"pane-resize",onPointerDown:o}),d.jsx("div",{className:We("pane-head",l&&"pane-head-tabs"),...y.contextMenu(()=>(u==null?void 0:u())??[]),children:l?d.jsx(Jf,{...l,end:d.jsxs(d.Fragment,{children:[c,_]})}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"pane-title",children:i}),c,_]})}),w]})}function uU({src:e,path:t,full:n,onFull:r}){const o=yn("editor");return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>Gc(e,{open:()=>r(!0)})),children:d.jsx("img",{src:e,alt:t})}),n&&d.jsx(Zk,{owner:"editor",onClose:()=>r(!1),menu:()=>Gc(e),children:d.jsx("img",{src:e,alt:t})})]})}const dU={image:uU};function fU({kind:e,src:t,path:n,openSeq:r,focus:o,full:i,onFull:l}){const c=S.useRef(null);ft([r],()=>{var p;o&&((p=c.current)==null||p.focus())});const u=dU[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 hU="img[src], source[src], video[src], audio[src], video[poster], link[href], object[data]";function pU(e,t){if(!t)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=!1;for(const o of n.querySelectorAll(hU))for(const i of["src","href","poster","data"]){const l=o.getAttribute(i),c=l===null?null:qk(t.dir,l);c&&(o.setAttribute(i,t.urls.worktreeFile(t.worktreeId,c,t.version)),r=!0)}return r?`${n.doctype?`<!doctype html>
|
|
246
|
-
`:""}${n.documentElement.outerHTML}`:e}function mU({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i}){const l=S.useRef(null);ft([o],()=>{var h;i&&((h=l.current)==null||h.focus())});const c=Kr(),u=D_(t),p=S.useMemo(()=>pU(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:p})})}function gU(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 kU(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=gU(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}
|
|
247
|
-
${l}`,level:Number(o.tagName[1]),depth:r[i],text:l,el:o}})}const wU=48,yU=16;function zT({html:e,openSeq:t=0,focus:n=!0,onLink:r,onChat:o}){const i=S.useRef(null),l=S.useRef(null),[c,u]=S.useState([]),[p,h]=S.useState(-1),[m,g]=S.useState(null),w=T=>{var x;if(g(null),T){const N=window.getSelection();N==null||N.removeAllRanges(),N==null||N.addRange(T)}(x=i.current)==null||x.focus()};ft([t],()=>{var T;n&&((T=i.current)==null||T.focus())}),ft([e],()=>{i.current&&u(kU(i.current))}),S.useLayoutEffect(()=>{const T=i.current;if(!T)return;let x=0;const N=()=>{if(x=0,T.scrollTop+T.clientHeight>=T.scrollHeight-1){h(c.length-1);return}const $=T.scrollTop+wU;let P=-1;for(let R=0;R<c.length;R++)c[R].el.offsetTop<=$&&(P=R);h(P)},j=()=>{x||(x=requestAnimationFrame(N))};return N(),T.addEventListener("scroll",j),()=>{T.removeEventListener("scroll",j),x&&cancelAnimationFrame(x)}},[c]);const y=T=>{var N,j;const x=(N=c[T])==null?void 0:N.el;(j=i.current)==null||j.scrollTo({top:Math.max(0,x?x.offsetTop-yU:0),behavior:"smooth"})},b=T=>{const x=T.target.closest("a"),N=x==null?void 0:x.getAttribute("href");!N||(x==null?void 0:x.target)==="_blank"||(T.preventDefault(),r==null||r(N))},_=T=>{var x;if(Hk(T)){T.preventDefault(),T.stopPropagation();const N=(l.current&&Jm(l.current))??"";g(j=>({seed:N||(j==null?void 0:j.seed)||"",seq:((j==null?void 0:j.seq)??0)+1}));return}if(T.key==="Escape"&&m){T.stopPropagation(),w(null);return}if(A_(T)&&l.current){T.preventDefault(),$_(l.current);return}if(o&&((x=k1(T))==null?void 0:x.id)==="composer"&&l.current){const N=Jm(l.current);if(!N)return;T.preventDefault(),T.stopPropagation(),o(N)}};return d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:i,className:"document",tabIndex:-1,onClick:b,onKeyDown:_,children:d.jsx("div",{ref:l,className:"md md-preview",dangerouslySetInnerHTML:{__html:e}})}),m&&d.jsx(C_,{root:i,body:l,seed:m.seed,seq:m.seq,onClose:w}),d.jsx(vU,{heads:c,at:p,onJump:y})]})}function vU({heads:e,at:t,onJump:n}){const[r,o]=S.useState(!1),i=S.useRef(null);return e.length<2?null:d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:i,className:"document-outline","aria-hidden":!0,onPointerEnter:l=>{l.pointerType==="mouse"&&o(!0)},onClick:()=>o(l=>!l),children:e.map((l,c)=>d.jsx("span",{className:"document-outline-tick","data-level":l.level,"data-state":dr({current:c===t})},l.id))}),r&&d.jsx(Rs,{className:"document-outline-list",anchor:()=>{var l;return((l=i.current)==null?void 0:l.getBoundingClientRect())??null},placement:{side:"right",align:"center",cover:!0},trigger:i.current,onDismiss:()=>o(!1),onPointerLeave:l=>{l.pointerType==="mouse"&&o(!1)},children:e.map((l,c)=>d.jsx("button",{type:"button",className:"row document-outline-row","data-level":l.level,"data-state":dr({current:c===t}),onClick:()=>n(c),children:d.jsx("span",{className:"document-outline-label",style:{"--outline-depth":l.depth},children:l.text})},l.id))})]})}function bU({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:i,onChat:l}){it();const c=Kr(),u=ut(),p=D_(t),h=sh(e,{keepHtml:!0,base:r===void 0?void 0:{worktreeId:n,dir:p,version:r,urls:c}}),m=g=>{const w=qk(p,g);w&&er({dispatch:u},{worktreeId:n,path:w,view:wi(w)})};return d.jsx(zT,{html:h,openSeq:o,focus:i,onLink:m,onChat:l})}const xU=S.lazy(async()=>{const[e]=await Promise.all([Sg(()=>import("./Editor-CU91PIeX.js").then(t=>t.E),__vite__mapDeps([0,1,2])),Sg(()=>import("./grammar-xXcxTc3V.js"),[]).then(t=>t.grammarsReady)]);return e});function Wx({what:e}){return aS(!0,3e3)?d.jsx("div",{className:"empty",children:d.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const EU=()=>{},SU={diff:"diff",file:"text",preview:"book"};function _U({path:e,note:t}){const{name:n,dir:r}=RE(e);return d.jsxs("span",{className:"editor-title","data-tip":r?e:void 0,children:[d.jsxs("span",{className:"editor-name",children:[n,t]}),r&&d.jsx("span",{className:"editor-dir row-dim",children:r})]})}function NU(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 FT({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:i="stack"}){const l=i==="screen",c=ut(),u=Yn(),p=it(),h=Kr(),m=vk(),g=Kf(),{worktreeId:w,path:y,ref:b,since:_}=e,T=e.loose,x=M(q=>{var F;return((F=Oo(q))==null?void 0:F.id)===w}),N=M(q=>{var re,Ee;const F=(re=un(q,w))==null?void 0:re.worktree;return F?F.path:(Ee=Oo(q))==null?void 0:Ee.path}),j=b!==void 0,$=S.useMemo(()=>T?lU(T.source,y,q=>c({a:"editor-refused",file:{worktreeId:w,path:y},message:q}),iU(p?q=>p.send(q):null)):(m==null?void 0:m.bind({worktreeId:w,path:y,...b?{ref:b}:{},..._?{since:_}:{}}))??DT,[m,w,y,b,_,T,c,p]),P=M(q=>Ro(q,w).changedRanges[y]);S.useEffect(()=>{!P&&!j&&!x&&!T&&(p==null||p.send({t:"changed-ranges",worktreeId:w,path:y}))},[w,y,P,j,x,T,p]);const R=(P==null?void 0:P.offset)??0,A=e.disk,O=e.view??"diff",D=!!A&&(A.before===""||A.before===A.after),z=_S(y,D).filter(q=>q!==O&&!(T&&q==="diff")),X=(T==null?void 0:T.source.kind)==="grant"?T.source:null,ne=j||x||T&&!X?null:YM(y),[ee,ie]=S.useState(!1),[be,C]=go(Ge.editorWrap,!1,q=>q===null?void 0:q==="1"),Z=!!A&&!ne&&!A.binary&&!A.tooLarge&&O!=="preview",Y=e.line&&!e.line.fiber?e.line.n:void 0;return d.jsxs(Nw,{kind:"editor",className:We("editor-pane",n&&"full"),height:n||l?void 0:t,resizable:!n&&!l,onDragStart:o??EU,title:d.jsx(_U,{path:y,note:j?` at ${b==null?void 0:b.slice(0,7)}`:_?", last turn":void 0}),menu:()=>N&&!T?js({id:w,dir:N},y,{discard:!j&&!x,kept:x,ref:b,showing:e.view??void 0,noDiff:D},{sock:p,dispatch:c}):[],onClose:()=>c({a:"close-editor"}),full:n,onToggleFull:l?void 0:r,actions:d.jsxs(d.Fragment,{children:[!ne&&z.length>0&&d.jsx("span",{className:"editor-views",children:z.map(q=>d.jsxs(Fe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>c({a:"editor-view",v:q}),"data-tip":NU(q,O),children:[d.jsx(Tt,{name:SU[q],className:"icon-inline"})," ",q]},q))}),ne==="image"&&d.jsxs(Fe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>ie(!0),"data-tip":"Full size: see the picture over the window",children:[d.jsx(Tt,{name:"zen",className:"icon-inline"})," full size"]}),Z&&d.jsxs(Fe,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>C(!be),"data-tip":be?"Unwrap lines: one line per row, scroll sideways for the rest":"Wrap lines: fold a long line at the pane's edge",children:[d.jsx(Tt,{name:"wrap",className:"icon-inline"})," ",be?"unwrap":"wrap"]})]}),children:[A&&d.jsx(TU,{editor:e,disk:A,files:m}),d.jsx("div",{className:"editor-body",children:A?ne?d.jsx(fU,{kind:ne,src:X?h.loose(X.id,X.version):h.worktreeFile(w,y,A.version),path:y,openSeq:e.seq,focus:e.focus,full:ee,onFull:ie}):A.binary?d.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):A.tooLarge?d.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):O==="preview"&&Bf(y)==="html"?d.jsx(mU,{text:A.after,path:y,worktreeId:w,version:j||x||T?void 0:A.version,openSeq:e.seq,focus:e.focus}):O==="preview"?d.jsx(bU,{text:A.after,path:y,worktreeId:w,version:j||x||T?void 0:A.version,openSeq:e.seq,focus:e.focus,onChat:q=>ab(u,{worktreeId:w,text:q,name:y})}):d.jsx(Mk,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx(Wx,{what:O}),children:d.jsx(xU,{file:{worktreeId:w,path:y,...b?{ref:b}:{},..._?{since:_}:{}},disk:A,blame:e.blame,view:O,openSeq:e.seq,line:Y,focus:e.focus,readOnly:j||!A.writable||l,numbers:!l,wrap:be,theme:g,sync:$,onCopy:T?void 0:(q,F,re)=>v4(re,{worktreeId:w,path:q,...F,...b?{ref:b}:{}}),onChat:(q,F)=>ab(u,F&&(T?{worktreeId:w,text:F.text,name:q}:{worktreeId:w,text:F.text,source:{path:q,startLine:F.startLine,endLine:F.endLine,...b?{ref:b}:{}}})),onNew:()=>u.dispatch({a:"open-draft"}),onLineHover:j||T?void 0:q=>{q==null?an.post(w,{type:"highlight-clear"}):an.post(w,{type:"highlight-file",path:y,ranges:[[q+R,q+R]]})}},`${w}
|
|
248
|
-
${T?"loose":b??_??""}
|
|
249
|
-
${y}`)})}):d.jsx(Wx,{what:y},y)})]})}function TU({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 p=c.version===null;return d.jsxs("div",{className:"editor-note",children:[d.jsx("span",{className:"editor-note-text",children:p?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),d.jsx(Fe,{variant:"outline",onClick:()=>n==null?void 0:n.reload(u),"data-tip":p?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:p?"close":"reload"}),d.jsx(Fe,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":p?"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 BT(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 jU=(e,t)=>{const n=Rm(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"}},Sf="https://github.com/toyon-dev/toyon",CU=e=>`${Sf}/releases/tag/v${e}`,AU=`${Sf}/releases/latest`,IU=4e3;function $U(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${Rm(n)} for the newest version`,act:"check",busy:!0};const o=Rm(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(kE(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 RU(e,t,n,r,o,i=!1,l=null,c=null){if(n){if(n.restarting){const p=n.installed??n.running,h=n.restarting.length>0?QS(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${p} restarting`,text:h,act:"restart",busy:!0}}if(n.installing){const p=n.latest??n.installed??n.running;return{value:`${p} installing`,text:`Installing Toyon ${p}`,act:"update",busy:!0}}if(n.failed){const p=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${p}. 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=BT(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?$U(e,t,l,c):{value:e,text:`Toyon ${e}, ${jU(t,l)}`,act:"check",busy:!1}}function OU(e,t,n){const r=o=>()=>window.open(o,"_blank");return zn([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(CU(e))},{id:"latest-release",label:"latest release",onClick:r(AU)},{id:"repo",label:"Toyon on GitHub",onClick:r(Sf)},{id:"report",label:"report a problem",onClick:r(`${Sf}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>nn(e)}]])}const MU=HC.map(e=>({title:e,rows:ZC(e).map(t=>[zt(t),Cc[t].label])}));function PU(){const e=ut(),t=it(),n=yn("keys"),r=M(m=>m.themePrefs),o=M(m=>m.themes),i=M(m=>m.chatSide),l=M(m=>m.keepAwake),c=yk(),u=M(m=>m.agents),p=Cl(),h=m=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(m)};return d.jsxs(Jc,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[d.jsxs("div",{className:"keys-card",children:[d.jsxs("div",{children:[p&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:p.name}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"processes"}),d.jsx(Fe,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${p.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:p.id}}),...n.contextMenu(()=>ah(p,p.id,{sock:t,dispatch:e})),children:d.jsx("span",{className:"keys-v",children:Object.keys(p.config.run).join(" + ")||"not set up"})})]})]}),d.jsx("div",{className:"section-title keys-h",children:"Agents"}),u.map(m=>d.jsx(zU,{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(Fe,{variant:"field",mono:!0,onClick:()=>h({a:"open",overlay:{kind:"appearance"}}),children:kf[r.mode]})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"theme"}),d.jsx(Fe,{variant:"field",mono:!0,onClick:()=>h({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:Ff(r,o,c).name})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"chat side"}),d.jsx(Fe,{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(Fe,{variant:"field",mono:!0,onClick:()=>h({a:"open",overlay:{kind:"keep-awake"}}),children:wf[l]})]}),d.jsx(LU,{}),d.jsx(DU,{})]})]}),d.jsx("div",{className:"keys-card",children:MU.map(m=>d.jsxs("div",{children:[d.jsx("div",{className:"section-title keys-h",children:m.title}),m.rows.map(([g,w])=>d.jsxs("div",{className:"keys-row",children:[d.jsx(Yo,{k:g}),d.jsx("span",{className:"keys-d",children:w})]},g))]},m.title))})]})}function LU(){const e=it(),t=ut(),n=yn("keys"),r=M(N=>N.version),o=M(N=>N.install),i=M(N=>N.registry),l=M(N=>N.update),c=M(N=>N.self),u=M(N=>N.rebuilt),p=M(N=>N.repos),h=M(N=>N.managed.updates),m=M(N=>N.updateCheck),g=M(N=>N.frame),w=M(N=>N.newProject!==null),y=RU(r,o,l,c,p,u,i,m),b=!h&&(y.act==="update"||y.act==="check"),_=y.settles&&m&&m!=="asking"?m:null;S.useEffect(()=>{if(!_)return;const N=()=>t({a:"update-check-settle",check:_}),j=setTimeout(N,IU);return()=>{clearTimeout(j),N()}},[_,t]);const T=()=>{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"}))},x=()=>OU(r,y.act==="check"&&!y.busy?{run:T,...b?{off:"managed by your organization"}:{}}:null,g==="phone"||w?void 0:()=>t({a:"open-release-notes"}));return d.jsxs("div",{className:"keys-setting",...n.contextMenu(x),children:[d.jsx("span",{className:"keys-d",children:"version"}),d.jsx(Fe,{variant:"field",mono:!0,busy:y.busy,disabled:b,onClick:T,...Ut(b?"updates are managed by your organization":y.text,void 0,{detail:y.detail}),children:y.value})]})}function DU(){const e=M(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: ${z2(e).join(", ")||"nothing turned off"}`;return d.jsx("div",{className:"hint",children:t})}function UT(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:e.checkFailed?"not ready":"ready":e.installing?"installing":"not installed"}function HT(e){var n,r;return e.available?e.checkFailed?e.checkFailed:e.auth?[e.auth.detail,(n=e.auth.account)==null?void 0:n.email,(r=e.auth.account)==null?void 0:r.organization].filter(Boolean).join(" · ")||e.auth.label:"installed; it names the account it runs on the first time it runs":lh(e)}function zU({agent:e}){const t=ut(),n=it(),r=yn("keys");return d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:e.name}),d.jsx(Fe,{variant:"field",mono:!0,"data-tip":HT(e),...r.contextMenu(()=>yw(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:UT(e)})]})}function FU({agentId:e}){const t=ut(),n=it(),r=Cl(),o=M(g=>g.home),i=M(g=>g.agents.find(w=>w.id===e)??null),l=M(g=>g.agentConfigs[e]??null),c=yn("keys");if(S.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),PT(n,e,i??void 0),!i)return null;const u=yw(i,{sock:n}),p=()=>t({a:"close",back:!0}),h=g=>o&&g.startsWith(`${o}/`)?`~${g.slice(o.length)}`:g,m=g=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:g.id,...r?{repoId:r.id}:{}});return d.jsx(Jc,{bare:!0,boxClass:"keys-stack",onClose:p,children:d.jsxs("div",{className:"keys-card keys-settings",children:[d.jsx("div",{className:"agent-page-back",children:d.jsx(Mt,{icon:"back",label:"back to settings",hint:"esc",onClick:p})}),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(Fe,{variant:"field",mono:!0,"data-tip":HT(i),disabled:u.length===0,...c.dropdown(()=>u,"right"),children:UT(i)})]}),d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"commit messages"}),d.jsx("span",{className:"keys-d",children:i.quick?"its quick model writes one after each turn":"none: it has no quick model, so you write them in the changes panel; quickModel in agents.json names one"})]}),d.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),l===null?d.jsx("div",{className:"keys-setting",children:d.jsx("span",{className:"keys-d live-text",children:"reading"})}):l.servers.length===0?d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:"none configured"}),d.jsx("span",{className:"keys-d",children:"add one with the agent's own CLI, or a .mcp.json in the repo"})]}):l.servers.map(g=>d.jsx(BU,{s:g},`${g.scope}:${g.name}`)),l&&l.files.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),l.files.map(g=>d.jsxs("div",{className:"keys-setting",children:[d.jsx("span",{className:"keys-d",children:g.label}),g.exists?d.jsx(Fe,{variant:"field",mono:!0,"data-tip":`reveal ${h(g.path)} in Finder`,onClick:()=>m(g),children:h(g.path)}):d.jsxs("span",{className:"keys-d",children:["not present: ",h(g.path)]})]},g.id))]})]})})}function BU({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 UU(){const e=ut(),t=it(),n=M(o=>o.agents),r=M(o=>o.defaultAgent);return d.jsx(Mr,{items:n,filter:(o,i)=>o.filter(l=>cs(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=>yw(o,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:o=>d.jsx(An,{label:o.name,current:o.id===r,hint:o.available?o.checkFailed??(o.sandboxed?void 0:"unsandboxed"):lh(o)})})}const HU=["dark","light","system","daylight"],WU=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function KU(){const e=ut(),t=it(),n=M(u=>u.themePrefs),r=M(u=>u.themes),o=yk(),i=M(u=>u.daylight),l=u=>{var p;return((p=r.find(h=>h.id===n[Qg({...n,mode:u},o)]))==null?void 0:p.name)??""},c=u=>{if(u==="system")return`${o.system?"dark":"light"} now · ${l(u)}`;if(u!=="daylight")return l(u);const p=i&&i.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${WU.format(i.until)}`:"";return`${o.daylight?"dark":"light"} now${p} · ${l(u)}`};return d.jsx(Mr,{items:HU,filter:(u,p)=>u.filter(h=>cs(p,kf[h])),rowClass:()=>"picker-row",keyOf:u=>u,initialIndex:u=>u.indexOf(n.mode),onActive:u=>e({a:"preview-theme",theme:u?Ff({...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(An,{label:kf[u],current:u===n.mode,hint:c(u)})})}const ZU=2,Ng=e=>dE(e).join(" ").length<ZU,qU=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),GU=e=>({kind:"chat",id:e.id,name:e.title,hint:E_(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function VU(e,t,n){const r=dE(t),o=n==="all"&&!Ng(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 YU=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function XU({repoId:e,scope:t}){const n=ut(),r=it(),o=M(j=>j.clientId),i=M(j=>j.frame),l=M(j=>j.chats[e]),c=Sk(),u=M(j=>j.archived[e]),[p,h]=S.useState(t),m=S.useCallback(()=>h(j=>j==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const g=S.useMemo(()=>[...c.filter(j=>!kr(j.worktree)).map(qU),...(u??[]).map(GU)],[c,u]),w=S.useMemo(()=>new Map(g.map(j=>[j.id,j])),[g]),y=S.useMemo(()=>[...g,...((l==null?void 0:l.hits)??[]).map(j=>({kind:"hit",hit:j}))],[g,l]),b=S.useMemo(()=>{const j=new Map;for(const $ of(l==null?void 0:l.hits)??[])j.set($.worktreeId,Math.max(j.get($.worktreeId)??0,$.ts));return j},[l]),_=S.useCallback((j,$)=>VU(j,$,p),[p]),T=S.useCallback(j=>{p==="all"&&!Ng(j)&&(r==null||r.send({t:"search-chats",repoId:e,query:j.trim()}))},[r,e,p]),x=j=>!l||l.query!==j.trim(),N=j=>p==="all"&&!Ng(j);return d.jsx(Mr,{items:y,filter:_,onQuery:T,onTab:m,trailing:d.jsx(Fe,{tone:"chrome",on:p==="names","aria-pressed":p==="names",onClick:m,children:"names only"}),keyOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}:${j.hit.seq}`:`w:${j.id}`,rowClass:j=>j.kind==="hit"?"chats-hit":We("picker-row",j.archived&&!j.archived.restorable&&"dim"),rowTitle:j=>{var $;return j.kind==="hit"?j.hit.text:(($=j.archived)==null?void 0:$.prompt)??j.name},groupOf:j=>j.kind==="hit"?`h:${j.hit.worktreeId}`:j.archived?"archived":"open",groupHead:(j,$)=>{if(!j.startsWith("h:"))return`${j} · ${$}`;const P=j.slice(2),R=w.get(P),A=l==null?void 0:l.asks[P],O=b.get(P)??0;return d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"chats-name",children:[(R==null?void 0:R.name)??"a worktree",(R==null?void 0:R.archived)&&d.jsxs(d.Fragment,{children:[" ",d.jsx("span",{className:"row-dim",children:"archived"})]})]}),O>0&&d.jsx("span",{className:"picker-group-tail",children:wr(O)}),A&&d.jsx("span",{className:"picker-group-line",children:nh(A,c_*2)})]})},headAlone:!0,onPick:j=>{const $=j.kind==="hit"?j.hit.worktreeId:j.id,P=j.kind==="hit"?j.hit.archived:!!j.archived;n(P?{a:"open-archived",id:$}:{a:"activate",id:$}),j.kind==="hit"&&n({a:"reveal",id:$,seq:j.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:j=>j.kind==="chat"&&j.archived?Gd(j.archived,{clientId:o,frame:i},{sock:r,dispatch:n}):[],placeholder:p==="names"?"find a chat by name…":"search in chats…",keys:j=>({nav:"moves",tab:p==="names"?"searches messages too":"searches names only",pick:j?j.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:j=>j.trim()?N(j)?x(j)?d.jsx("span",{className:"live-text",children:"searching"}):"no chat says that":"no chat is named that":u?"no chats yet":d.jsx("span",{className:"live-text",children:"looking"}),footer:(j,$)=>{const P=$.filter(R=>R.kind==="hit").length;return l!=null&&l.truncated&&!x(j)&&P>0?d.jsxs("div",{className:"empty",children:["showing the first ",P,"; narrow the search"]}):null},row:j=>j.kind==="chat"?d.jsx(An,{label:j.name,hint:j.hint}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"chats-text",children:eu(j.hit.text,YU(j.hit.match),0)}),d.jsxs("span",{className:"chats-said row-dim",children:[j.hit.role==="user"?"you":"the agent",j.hit.ts>0&&wr(j.hit.ts)!==wr(b.get(j.hit.worktreeId)??0)?` · ${wr(j.hit.ts)}`:""]})]})})}const Il=function(e,t){let o=e;const i=Tc[t];let l=null,c=0,u=null;const p=[],h={},m=function(R,A){c=o*4+17,l=(function(O){const D=new Array(O);for(let z=0;z<O;z+=1){D[z]=new Array(O);for(let X=0;X<O;X+=1)D[z][X]=null}return D})(c),g(0,0),g(c-7,0),g(0,c-7),b(),y(),T(R,A),o>=7&&_(R),u==null&&(u=j(o,i,p)),x(u,A)},g=function(R,A){for(let O=-1;O<=7;O+=1)if(!(R+O<=-1||c<=R+O))for(let D=-1;D<=7;D+=1)A+D<=-1||c<=A+D||(0<=O&&O<=6&&(D==0||D==6)||0<=D&&D<=6&&(O==0||O==6)||2<=O&&O<=4&&2<=D&&D<=4?l[R+O][A+D]=!0:l[R+O][A+D]=!1)},w=function(){let R=0,A=0;for(let O=0;O<8;O+=1){m(!0,O);const D=li.getLostPoint(h);(O==0||R>D)&&(R=D,A=O)}return A},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=li.getPatternPosition(o);for(let A=0;A<R.length;A+=1)for(let O=0;O<R.length;O+=1){const D=R[A],z=R[O];if(l[D][z]==null)for(let X=-2;X<=2;X+=1)for(let ne=-2;ne<=2;ne+=1)X==-2||X==2||ne==-2||ne==2||X==0&&ne==0?l[D+X][z+ne]=!0:l[D+X][z+ne]=!1}},_=function(R){const A=li.getBCHTypeNumber(o);for(let O=0;O<18;O+=1){const D=!R&&(A>>O&1)==1;l[Math.floor(O/3)][O%3+c-8-3]=D}for(let O=0;O<18;O+=1){const D=!R&&(A>>O&1)==1;l[O%3+c-8-3][Math.floor(O/3)]=D}},T=function(R,A){const O=i<<3|A,D=li.getBCHTypeInfo(O);for(let z=0;z<15;z+=1){const X=!R&&(D>>z&1)==1;z<6?l[z][8]=X:z<8?l[z+1][8]=X:l[c-15+z][8]=X}for(let z=0;z<15;z+=1){const X=!R&&(D>>z&1)==1;z<8?l[8][c-z-1]=X:z<9?l[8][15-z-1+1]=X:l[8][15-z-1]=X}l[c-8][8]=!R},x=function(R,A){let O=-1,D=c-1,z=7,X=0;const ne=li.getMaskFunction(A);for(let ee=c-1;ee>0;ee-=2)for(ee==6&&(ee-=1);;){for(let ie=0;ie<2;ie+=1)if(l[D][ee-ie]==null){let be=!1;X<R.length&&(be=(R[X]>>>z&1)==1),ne(D,ee-ie)&&(be=!be),l[D][ee-ie]=be,z-=1,z==-1&&(X+=1,z=7)}if(D+=O,D<0||c<=D){D-=O,O=-O;break}}},N=function(R,A){let O=0,D=0,z=0;const X=new Array(A.length),ne=new Array(A.length);for(let C=0;C<A.length;C+=1){const Z=A[C].dataCount,Y=A[C].totalCount-Z;D=Math.max(D,Z),z=Math.max(z,Y),X[C]=new Array(Z);for(let Ee=0;Ee<X[C].length;Ee+=1)X[C][Ee]=255&R.getBuffer()[Ee+O];O+=Z;const q=li.getErrorCorrectPolynomial(Y),re=tu(X[C],q.getLength()-1).mod(q);ne[C]=new Array(q.getLength()-1);for(let Ee=0;Ee<ne[C].length;Ee+=1){const Te=Ee+re.getLength()-ne[C].length;ne[C][Ee]=Te>=0?re.getAt(Te):0}}let ee=0;for(let C=0;C<A.length;C+=1)ee+=A[C].totalCount;const ie=new Array(ee);let be=0;for(let C=0;C<D;C+=1)for(let Z=0;Z<A.length;Z+=1)C<X[Z].length&&(ie[be]=X[Z][C],be+=1);for(let C=0;C<z;C+=1)for(let Z=0;Z<A.length;Z+=1)C<ne[Z].length&&(ie[be]=ne[Z][C],be+=1);return ie},j=function(R,A,O){const D=Kx.getRSBlocks(R,A),z=Zx();for(let ne=0;ne<O.length;ne+=1){const ee=O[ne];z.put(ee.getMode(),4),z.put(ee.getLength(),li.getLengthInBits(ee.getMode(),R)),ee.write(z)}let X=0;for(let ne=0;ne<D.length;ne+=1)X+=D[ne].dataCount;if(z.getLengthInBits()>X*8)throw"code length overflow. ("+z.getLengthInBits()+">"+X*8+")";for(z.getLengthInBits()+4<=X*8&&z.put(0,4);z.getLengthInBits()%8!=0;)z.putBit(!1);for(;!(z.getLengthInBits()>=X*8||(z.put(236,8),z.getLengthInBits()>=X*8));)z.put(17,8);return N(z,D)};h.addData=function(R,A){A=A||"Byte";let O=null;switch(A){case"Numeric":O=QU(R);break;case"Alphanumeric":O=JU(R);break;case"Byte":O=e7(R);break;case"Kanji":O=t7(R);break;default:throw"mode:"+A}p.push(O),u=null},h.isDark=function(R,A){if(R<0||c<=R||A<0||c<=A)throw R+","+A;return l[R][A]},h.getModuleCount=function(){return c},h.make=function(){if(o<1){let R=1;for(;R<40;R++){const A=Kx.getRSBlocks(R,i),O=Zx();for(let z=0;z<p.length;z++){const X=p[z];O.put(X.getMode(),4),O.put(X.getLength(),li.getLengthInBits(X.getMode(),R)),X.write(O)}let D=0;for(let z=0;z<A.length;z++)D+=A[z].dataCount;if(O.getLengthInBits()<=D*8)break}o=R}m(!1,w())},h.createTableTag=function(R,A){R=R||2,A=typeof A>"u"?R*4:A;let O="";O+='<table style="',O+=" border-width: 0px; border-style: none;",O+=" border-collapse: collapse;",O+=" padding: 0px; margin: "+A+"px;",O+='">',O+="<tbody>";for(let D=0;D<h.getModuleCount();D+=1){O+="<tr>";for(let z=0;z<h.getModuleCount();z+=1)O+='<td style="',O+=" border-width: 0px; border-style: none;",O+=" border-collapse: collapse;",O+=" padding: 0px; margin: 0px;",O+=" width: "+R+"px;",O+=" height: "+R+"px;",O+=" background-color: ",O+=h.isDark(D,z)?"#000000":"#ffffff",O+=";",O+='"/>';O+="</tr>"}return O+="</tbody>",O+="</table>",O},h.createSvgTag=function(R,A,O,D){let z={};typeof arguments[0]=="object"&&(z=arguments[0],R=z.cellSize,A=z.margin,O=z.alt,D=z.title),R=R||2,A=typeof A>"u"?R*4:A,O=typeof O=="string"?{text:O}:O||{},O.text=O.text||null,O.id=O.text?O.id||"qrcode-description":null,D=typeof D=="string"?{text:D}:D||{},D.text=D.text||null,D.id=D.text?D.id||"qrcode-title":null;const X=h.getModuleCount()*R+A*2;let ne,ee,ie,be,C="",Z;for(Z="l"+R+",0 0,"+R+" -"+R+",0 0,-"+R+"z ",C+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',C+=z.scalable?"":' width="'+X+'px" height="'+X+'px"',C+=' viewBox="0 0 '+X+" "+X+'" ',C+=' preserveAspectRatio="xMinYMin meet"',C+=D.text||O.text?' role="img" aria-labelledby="'+$([D.id,O.id].join(" ").trim())+'"':"",C+=">",C+=D.text?'<title id="'+$(D.id)+'">'+$(D.text)+"</title>":"",C+=O.text?'<description id="'+$(O.id)+'">'+$(O.text)+"</description>":"",C+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',C+='<path d="',ie=0;ie<h.getModuleCount();ie+=1)for(be=ie*R+A,ne=0;ne<h.getModuleCount();ne+=1)h.isDark(ie,ne)&&(ee=ne*R+A,C+="M"+ee+","+be+Z);return C+='" stroke="transparent" fill="black"/>',C+="</svg>",C},h.createDataURL=function(R,A){R=R||2,A=typeof A>"u"?R*4:A;const O=h.getModuleCount()*R+A*2,D=A,z=O-A;return s7(O,O,function(X,ne){if(D<=X&&X<z&&D<=ne&&ne<z){const ee=Math.floor((X-D)/R),ie=Math.floor((ne-D)/R);return h.isDark(ie,ee)?0:1}else return 1})},h.createImgTag=function(R,A,O){R=R||2,A=typeof A>"u"?R*4:A;const D=h.getModuleCount()*R+A*2;let z="";return z+="<img",z+=' src="',z+=h.createDataURL(R,A),z+='"',z+=' width="',z+=D,z+='"',z+=' height="',z+=D,z+='"',O&&(z+=' alt="',z+=$(O),z+='"'),z+="/>",z};const $=function(R){let A="";for(let O=0;O<R.length;O+=1){const D=R.charAt(O);switch(D){case"<":A+="<";break;case">":A+=">";break;case"&":A+="&";break;case'"':A+=""";break;default:A+=D;break}}return A},P=function(R){R=typeof R>"u"?2:R;const O=h.getModuleCount()*1+R*2,D=R,z=O-R;let X,ne,ee,ie,be;const C={"██":"█","█ ":"▀"," █":"▄"," ":" "},Z={"██":"▀","█ ":"▀"," █":" "," ":" "};let Y="";for(X=0;X<O;X+=2){for(ee=Math.floor((X-D)/1),ie=Math.floor((X+1-D)/1),ne=0;ne<O;ne+=1)be="█",D<=ne&&ne<z&&D<=X&&X<z&&h.isDark(ee,Math.floor((ne-D)/1))&&(be=" "),D<=ne&&ne<z&&D<=X+1&&X+1<z&&h.isDark(ie,Math.floor((ne-D)/1))?be+=" ":be+="█",Y+=R<1&&X+1>=z?Z[be]:C[be];Y+=`
|
|
250
|
-
`}return O%2&&R>0?Y.substring(0,Y.length-O-1)+Array(O+1).join("▀"):Y.substring(0,Y.length-1)};return h.createASCII=function(R,A){if(R=R||1,R<2)return P(A);R-=1,A=typeof A>"u"?R*2:A;const O=h.getModuleCount()*R+A*2,D=A,z=O-A;let X,ne,ee,ie;const be=Array(R+1).join("██"),C=Array(R+1).join(" ");let Z="",Y="";for(X=0;X<O;X+=1){for(ee=Math.floor((X-D)/R),Y="",ne=0;ne<O;ne+=1)ie=1,D<=ne&&ne<z&&D<=X&&X<z&&h.isDark(ee,Math.floor((ne-D)/R))&&(ie=0),Y+=ie?be:C;for(ee=0;ee<R;ee+=1)Z+=Y+`
|
|
251
|
-
`}return Z.substring(0,Z.length-1)},h.renderTo2dContext=function(R,A){A=A||2;const O=h.getModuleCount();for(let D=0;D<O;D++)for(let z=0;z<O;z++)R.fillStyle=h.isDark(D,z)?"black":"white",R.fillRect(z*A,D*A,A,A)},h};Il.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};Il.createStringToBytes=function(e,t){const n=(function(){const o=r7(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 p=i(),h=i(),m=i(),g=String.fromCharCode(u<<8|p),w=h<<8|m;c[g]=w,l+=1}if(l!=t)throw l+" != "+t;return c})(),r=63;return function(o){const i=[];for(let l=0;l<o.length;l+=1){const c=o.charCodeAt(l);if(c<128)i.push(c);else{const u=n[o.charAt(l)];typeof u=="number"?(u&255)==u?i.push(u):(i.push(u>>>8),i.push(u&255)):i.push(r)}}return i}};const Rr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Tc={L:1,M:0,Q:3,H:2},ai={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},li=(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 ai.PATTERN000:return function(c,u){return(c+u)%2==0};case ai.PATTERN001:return function(c,u){return c%2==0};case ai.PATTERN010:return function(c,u){return u%3==0};case ai.PATTERN011:return function(c,u){return(c+u)%3==0};case ai.PATTERN100:return function(c,u){return(Math.floor(c/2)+Math.floor(u/3))%2==0};case ai.PATTERN101:return function(c,u){return c*u%2+c*u%3==0};case ai.PATTERN110:return function(c,u){return(c*u%2+c*u%3)%2==0};case ai.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=tu([1],0);for(let u=0;u<l;u+=1)c=c.multiply(tu([1,ui.gexp(u)],0));return c},o.getLengthInBits=function(l,c){if(1<=c&&c<10)switch(l){case Rr.MODE_NUMBER:return 10;case Rr.MODE_ALPHA_NUM:return 9;case Rr.MODE_8BIT_BYTE:return 8;case Rr.MODE_KANJI:return 8;default:throw"mode:"+l}else if(c<27)switch(l){case Rr.MODE_NUMBER:return 12;case Rr.MODE_ALPHA_NUM:return 11;case Rr.MODE_8BIT_BYTE:return 16;case Rr.MODE_KANJI:return 10;default:throw"mode:"+l}else if(c<41)switch(l){case Rr.MODE_NUMBER:return 14;case Rr.MODE_ALPHA_NUM:return 13;case Rr.MODE_8BIT_BYTE:return 16;case Rr.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+c},o.getLostPoint=function(l){const c=l.getModuleCount();let u=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1){let w=0;const y=l.isDark(m,g);for(let b=-1;b<=1;b+=1)if(!(m+b<0||c<=m+b))for(let _=-1;_<=1;_+=1)g+_<0||c<=g+_||b==0&&_==0||y==l.isDark(m+b,g+_)&&(w+=1);w>5&&(u+=3+w-5)}for(let m=0;m<c-1;m+=1)for(let g=0;g<c-1;g+=1){let w=0;l.isDark(m,g)&&(w+=1),l.isDark(m+1,g)&&(w+=1),l.isDark(m,g+1)&&(w+=1),l.isDark(m+1,g+1)&&(w+=1),(w==0||w==4)&&(u+=3)}for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)l.isDark(m,g)&&!l.isDark(m,g+1)&&l.isDark(m,g+2)&&l.isDark(m,g+3)&&l.isDark(m,g+4)&&!l.isDark(m,g+5)&&l.isDark(m,g+6)&&(u+=40);for(let m=0;m<c;m+=1)for(let g=0;g<c-6;g+=1)l.isDark(g,m)&&!l.isDark(g+1,m)&&l.isDark(g+2,m)&&l.isDark(g+3,m)&&l.isDark(g+4,m)&&!l.isDark(g+5,m)&&l.isDark(g+6,m)&&(u+=40);let p=0;for(let m=0;m<c;m+=1)for(let g=0;g<c;g+=1)l.isDark(g,m)&&(p+=1);const h=Math.abs(100*p/c/c-50)/5;return u+=h*10,u},o})(),ui=(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})(),tu=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]^=ui.gexp(ui.glog(r.getAt(l))+ui.glog(o.getAt(c)));return tu(i,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const i=ui.glog(r.getAt(0))-ui.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]^=ui.gexp(ui.glog(o.getAt(c))+i);return tu(l,0).mod(o)},r},Kx=(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 Tc.L:return e[(o-1)*4+0];case Tc.M:return e[(o-1)*4+1];case Tc.Q:return e[(o-1)*4+2];case Tc.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 p=0;p<c;p+=1){const h=l[p*3+0],m=l[p*3+1],g=l[p*3+2];for(let w=0;w<h;w+=1)u.push(t(m,g))}return u},n})(),Zx=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},QU=function(e){const t=Rr.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},JU=function(e){const t=Rr.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},e7=function(e){const t=Rr.MODE_8BIT_BYTE,n=Il.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},t7=function(e){const t=Rr.MODE_KANJI,n=Il.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},WT=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},n7=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},r7=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},o7=function(e,t){const n=e,r=t,o=new Array(e*t),i={};i.setPixel=function(p,h,m){o[h*n+p]=m},i.write=function(p){p.writeString("GIF87a"),p.writeShort(n),p.writeShort(r),p.writeByte(128),p.writeByte(0),p.writeByte(0),p.writeByte(0),p.writeByte(0),p.writeByte(0),p.writeByte(255),p.writeByte(255),p.writeByte(255),p.writeString(","),p.writeShort(0),p.writeShort(0),p.writeShort(n),p.writeShort(r),p.writeByte(0);const h=2,m=c(h);p.writeByte(h);let g=0;for(;m.length-g>255;)p.writeByte(255),p.writeBytes(m,g,255),g+=255;p.writeByte(m.length-g),p.writeBytes(m,g,m.length-g),p.writeByte(0),p.writeString(";")};const l=function(p){const h=p;let m=0,g=0;const w={};return w.write=function(y,b){if(y>>>b)throw"length over";for(;m+b>=8;)h.writeByte(255&(y<<m|g)),b-=8-m,y>>>=8-m,g=0,m=0;g=y<<m|g,m=m+b},w.flush=function(){m>0&&h.writeByte(g)},w},c=function(p){const h=1<<p,m=(1<<p)+1;let g=p+1;const w=u();for(let x=0;x<h;x+=1)w.add(String.fromCharCode(x));w.add(String.fromCharCode(h)),w.add(String.fromCharCode(m));const y=WT(),b=l(y);b.write(h,g);let _=0,T=String.fromCharCode(o[_]);for(_+=1;_<o.length;){const x=String.fromCharCode(o[_]);_+=1,w.contains(T+x)?T=T+x:(b.write(w.indexOf(T),g),w.size()<4095&&(w.size()==1<<g&&(g+=1),w.add(T+x)),T=x)}return b.write(w.indexOf(T),g),b.write(m,g),b.flush(),y.toByteArray()},u=function(){const p={};let h=0;const m={};return m.add=function(g){if(m.contains(g))throw"dup key:"+g;p[g]=h,h+=1},m.size=function(){return h},m.indexOf=function(g){return p[g]},m.contains=function(g){return typeof p[g]<"u"},m};return i},s7=function(e,t,n){const r=o7(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=WT();r.write(o);const i=n7(),l=o.toByteArray();for(let c=0;c<l.length;c+=1)i.writeByte(l[c]);return i.flush(),"data:image/gif;base64,"+i};Il.stringToBytes;function i7(e){const t=Il(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 rr={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 ${_f(e)}.`,waiting:(e,t)=>`Toyon on ${_f(e)} is asking whether to let ${t} in.`,added:e=>`Added ${e}.`,notKept:e=>`Let in, but not listed: ${e}`,add:"add"};function a7(e,t){return e.reached?e.toyon&&!e.toyon.answering?rr.notAnswering:t?rr.listed:e.toyon?null:rr.noToyon:rr.offline}function qx(e){var t;return(t=e.toyon)!=null&&t.answering?0:e.toyon?1:e.reached?2:3}function _f(e){try{return new URL(e).host}catch{return e}}function KT(e,t,n){const r=_f(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 l7(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",rr.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 c7=e=>e==="phone"?"phone":"laptop";function Gx({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:We("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(Tt,{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:We("tailnet-right",typeof t.right=="string"&&"hint"),children:t.right})]},t.key))})}const Vx=(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:c7(e.kind),right:t}},hm=4;function u7({text:e}){const{size:t,d:n}=S.useMemo(()=>{const r=i7(e);let o="";return r.forEach((i,l)=>{i.forEach((c,u)=>{c&&(o+=`M${u+hm} ${l+hm}h1v1h-1z`)})}),{size:r.length+hm*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 d7=5e3;function f7(e){return e.from===null?"A device that opened this address":`A Toyon page at ${_f(e.from)}`}function h7({knock:e,letIn:t,onAnswer:n}){return d.jsxs("div",{className:We("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?`${f7(e)} wants in.`:t?"is in.":"was turned away."})]}),t===null&&d.jsxs("div",{className:"devices-actions",children:[d.jsx(Fe,{tone:"primary",onClick:()=>n(!0),children:"let in"}),d.jsx(Fe,{variant:"outline",onClick:()=>n(!1),children:"not now"})]})]})}function p7({host:e,noPhone:t}){return d.jsxs("div",{className:"devices-address",children:[d.jsx("div",{className:"devices-frame",children:d.jsx(u7,{text:eA(e)})}),d.jsxs("div",{className:"devices-about",children:[d.jsx("p",{className:"devices-line",children:rr.scan}),t&&d.jsx("p",{className:"devices-note",children:rr.noPhone})]})]})}function m7(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)=>qx(r.d)-qx(o.d)||r.i-o.i).map(({d:r})=>r);return[...t,...n]}function g7(){const e=ut(),t=es(),n=Kr(),r=M(ge=>ge.frame==="desk"),o=M(ge=>{var oe;return((oe=ge.remote)==null?void 0:oe.host)??null}),i=M(ge=>ge.machine),l=M(ge=>ge.tailscale),c=M(ge=>ge.knocks),[u,p]=S.useState(""),[h,m]=S.useState({kind:"idle"}),[g,w]=S.useState([]),y=()=>e({a:"close"}),b=h.kind==="asking"||h.kind==="waiting",_=QL(()=>aP(n),d7,!b),T=S.useRef(new AbortController);S.useEffect(()=>()=>T.current.abort(),[]);const x=async ge=>{if(b)return;const oe=T.current.signal;m({kind:"asking",origin:ge});const we=await _E(ge,oe,_e=>m({kind:"waiting",origin:ge,word:_e}));if(oe.aborted)return;if(typeof we=="string"){m({kind:"failed",line:KT(we,ge,"this page")});return}const Ce=t.serving(),Se=await fP(ek(Ce.origin,Ce.token),ge,we.token);m(Se?{kind:"failed",line:rr.notKept(Se)}:{kind:"added",name:t.displayName(ge)})},N=()=>{const ge=tA(u);ge?x(ge):m({kind:"failed",line:rr.notAnAddress})},j=()=>{T.current.abort(),T.current=new AbortController,m({kind:"idle"})},$=(ge,oe)=>{w(we=>we.some(Ce=>Ce.knock.id===ge.id)?we:[...we,{knock:ge,letIn:oe}]),hP(n,ge.id,oe)},P=c.filter(ge=>!g.some(oe=>oe.knock.id===ge.id)),R=[...g,...P.map(ge=>({knock:ge,letIn:null}))],[A,O]=S.useState(!1),[D,z]=S.useState(null),X=async ge=>{O(!0),z(null);const oe=await(ge?lP(n):cP(n));O(!1),oe&&z(oe)},ne=(_==null?void 0:_.here)===!0,ee=l7(_,l,o),ie=o!==null,be=r&&(ne||_===void 0)?d.jsx(Fe,{variant:"outline",size:"sm",on:ie,"aria-pressed":ie,busy:A,disabled:!ie&&(l==null?void 0:l.state)!=="ready",onClick:()=>void X(!ie),...Ut(ie?"Take this machine's name off your tailnet":"Give this machine a name on your tailnet"),children:ie?"on":"off"}):null,[C,Z]=S.useState(!1),[Y,q]=S.useState(null),F=ge=>{window.open(ge,"_blank","noopener")===null?q(ge):q(null)},re=async ge=>{if(Z(!0),z(null),ge==="connect"){const oe=await uP(n);oe&&z(oe)}else{const oe=await dP(n);"url"in oe?F(oe.url):z(oe.why)}Z(!1)},Ee=r&&ee.offer!==null?Y!==null?d.jsx(Fe,{variant:"outline",size:"sm",onClick:()=>F(Y),children:"open the sign-in page"}):d.jsx(Fe,{variant:"outline",size:"sm",busy:C,onClick:()=>void re(ee.offer??"connect"),...ee.note?Ut(ee.note):{},children:ee.offer==="connect"?"connect":"sign in"}):null,Te=ee.word===null&&be===null&&Ee===null?"this machine":d.jsxs(d.Fragment,{children:[ee.word&&d.jsx("span",{className:"hint",children:ee.word}),be??Ee]}),de=[{key:"self",name:i??"This machine",host:o??void 0,reached:_===void 0?null:ne,icon:"laptop",right:Te}],ke=_?m7(_).map(ge=>{if(ge.kind==="phone"||ge.host==="")return Vx(ge,ge.reached?void 0:"not answering");const oe=`https://${ge.host}`,we=a7(ge,t.get(oe)!==null);return Vx(ge,we??d.jsx(Fe,{variant:"outline",size:"sm",disabled:b,onClick:()=>void x(oe),children:rr.request}))}):[],ae=r&&o!==null&&_!==null&&(_===void 0||_.here),G=_==null?void 0:_.devices.some(ge=>ge.kind==="machine"&&ge.host!==""&&ge.reached&&ge.toyon===null),ue=ae&&_!==void 0&&!_.devices.some(ge=>ge.kind==="phone"),Le=(()=>{switch(h.kind){case"asking":return rr.asking(h.origin);case"waiting":return rr.waiting(h.origin,h.word);case"added":return rr.added(h.name);case"failed":return h.line;case"idle":return null}})();return d.jsxs(Jc,{boxClass:"devices-card",onClose:y,children:[d.jsx("div",{className:"devices-title",children:rr.title}),d.jsx(Gx,{rows:de}),ee.note&&ee.offer===null&&d.jsx("p",{className:"devices-note",children:ee.note}),D&&d.jsx("p",{className:"devices-note",children:D}),r&&!ie&&(l==null?void 0:l.state)==="ready"&&d.jsx("p",{className:"devices-note",children:rr.turnOn}),ae&&o!==null&&d.jsx(p7,{host:o,noPhone:ue}),h.kind==="waiting"&&d.jsx("div",{className:"knock-word devices-word",children:h.word}),Le&&d.jsx("p",{className:We("devices-line",h.kind==="failed"&&"devices-failed"),children:Le}),_!==void 0&&d.jsxs(d.Fragment,{children:[ke.length>0&&d.jsx("div",{className:"devices-others",children:d.jsx(Gx,{rows:ke})}),(_==null?void 0:_.devices.length)===0&&d.jsx("p",{className:"devices-note",children:rr.noneOnTailnet}),G&&d.jsx("p",{className:"devices-note",children:rr.missing})]}),!b&&d.jsxs("form",{className:"devices-form",onSubmit:ge=>{ge.preventDefault(),N()},children:[d.jsx(Io,{size:"md",font:"ui",value:u,placeholder:rr.placeholder,"aria-label":"Address of the other machine",onChange:ge=>p(ge.target.value),className:"devices-field"}),d.jsx(Fe,{type:"submit",variant:"outline",disabled:!u.trim(),children:rr.add})]}),b&&d.jsx("div",{className:"devices-actions",children:d.jsx(Fe,{tone:"quiet",onClick:j,children:"cancel"})}),P.length>0&&d.jsx("p",{className:"devices-line devices-centred",children:rr.knocking}),R.map(ge=>d.jsx(h7,{knock:ge.knock,letIn:ge.letIn,onAnswer:oe=>$(ge.knock,oe)},ge.knock.id))]})}function k7({worktreeId:e,hits:t}){const n=ut(),r=it(),o=M(c=>c.layout.changes),i=M(c=>{var p;const u=(p=un(c,e))==null?void 0:p.worktree;return u?u.path:null}),l=S.useCallback((c,u)=>{const p=u.trim().toLowerCase();return p?c.filter(h=>`${h.path}:${h.line} ${h.text}`.toLowerCase().includes(p)):c},[]);return d.jsx(Mr,{items:t,filter:l,keyOf:c=>`${c.path}:${c.line}`,rowClass:()=>"search-hit",rowTitle:c=>`${c.path}:${c.line}`,onPick:c=>{er({dispatch:n},{worktreeId:e,path:c.path,view:"file",line:{n:c.line}}),o||n({a:"toggle-changes"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:c=>i?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 w7({project:e}){const t=ut(),n=it(),r=M(p=>p.paths),o=M(p=>p.home),i=S.useCallback(p=>{Xc(p)&&(n==null||n.send({t:"browse-path",path:p}))},[n]),l=S.useCallback((p,h)=>E8({query:h,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),c=Uc(e.name)?null:e.name.trim(),u=p=>`${p.replace(/\/+$/,"")}/`;return d.jsx(Mr,{initialQuery:u(e.parent),lead:d.jsx("span",{className:"picker-chip",children:c??"new project"}),items:[],filter:l,keyOf:p=>p.kind==="dir"?`d:${p.entry.path}`:`${p.kind}:${p.path}`,rowClass:()=>"picker-row folder-row",onQuery:i,completionOf:p=>p.kind==="dir"?u(p.entry.path):null,narrowTo:p=>p.kind==="dir"?u(p.entry.path):p.kind==="up"?u(p.path):null,onPick:p=>{p.kind==="here"&&(t({a:"new-project-set",v:{mode:e.mode==="init"?"create":e.mode,parent:p.path}}),t({a:"close"}))},onBack:()=>t({a:"close"}),placeholder:"type a folder path",keys:p=>({complete:"completes the path",pick:(p==null?void 0:p.kind)==="here"?"chooses it":(p==null?void 0:p.kind)==="up"?"goes up":"opens it",back:"goes back"}),empty:"no such folder",row:p=>p.kind==="here"?d.jsx(An,{label:`put ${c??"it"} in ${fg(p.path,o)}`,hint:d.jsx("bdi",{children:c?zN(p.path,c):p.path})}):p.kind==="up"?d.jsx(An,{label:`up to ${fg(p.path,o)}`,hint:d.jsx("bdi",{children:p.path})}):d.jsx(An,{label:p.entry.name})})}function y7({worktreeId:e}){const t=ut(),n=it(),r=M(m=>m.clientId),o=M(m=>un(m,e)),i=M(m=>m.repos),c=Rt(e,"draft").trim(),u=S.useMemo(()=>i.filter(m=>m.id!==(o==null?void 0:o.worktree.repoId)),[i,o]),p=()=>t({a:"close"}),h=m=>{if(!o)return p();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:""})),p()};return d.jsx(Mr,{lead:d.jsx("span",{className:"picker-chip",children:(o==null?void 0:o.worktree.title)??"worktree"}),items:u,filter:(m,g)=>m.filter(w=>cs(g,w.name,w.path)),keyOf:m=>m.id,row:m=>d.jsx(An,{label:m.name,hint:m.path}),onPick:h,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(`
|
|
252
|
-
`)[0]]}):void 0})}const v7={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 b7(){const e=ut(),t=it(),n=M(r=>r.keepAwake);return d.jsx(Mr,{items:[...NC],filter:(r,o)=>r.filter(i=>cs(o,wf[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(An,{label:wf[r],current:r===n,hint:v7[r]})})}function x7(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=ug(t.rows,null);return n?`${n.n} ${n.tier==="waiting"?"waiting":"unread"}`:"all quiet"}function Tg(e){try{return nA(new URL(e).hostname)}catch{return!1}}function E7(e){const t=new Set,n=e.build({...e.serving,serving:!0}),r=[];let o=n,i=[n];const l=()=>{i=[n,...r];for(const y of t)y()},c=new Map,u=y=>{var _;if(y.serving)return;(((_=y.store.getState().remote)==null?void 0:_.front)==="edge"||Tg(y.origin))&&y!==o?y.sock.suspend():y.sock.resume()},p=y=>{var _;let b=(_=y.store.getState().remote)==null?void 0:_.front;c.set(y.origin,y.store.subscribe(()=>{var x;const T=(x=y.store.getState().remote)==null?void 0:x.front;T!==b&&(b=T,u(y))}))},h=()=>i,m={list:h,active:()=>o,serving:()=>n,get:y=>h().find(b=>b.origin===y)??null,displayName(y){const b=h().find(T=>T.origin===y);return b?h().filter(T=>T.name===b.name).length>1?`${b.name} (${new URL(b.origin).host})`:b.name:y},activate(y){const b=h().find(T=>T.origin===y);if(!b||b===o)return;const _=o;o=b,u(_),u(b),l()},add(y){var T;const b=r.find(x=>x.origin===y.origin);if(y.origin===n.origin)return n;if(b){if(b.token===y.token)return b;(T=c.get(b.origin))==null||T(),b.dispose(),r.splice(r.indexOf(b),1),o===b&&(o=n)}const _=e.build({...y,serving:!1});return r.push(_),p(_),Tg(_.origin)&&_.sock.suspend(),l(),_},remove(y){var _;const b=r.find(T=>T.origin===y);b&&((_=c.get(y))==null||_(),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 h())b.store.dispatch(y)},subscribe(y){return t.add(y),()=>t.delete(y)}},g=y=>{for(const b of y)m.add(b);for(const b of[...r])y.some(_=>_.origin===b.origin)||m.remove(b.origin)};let w=n.store.getState().handed;return n.store.subscribe(()=>{const y=n.store.getState().handed;y!==w&&(w=y,g(w))}),g(w),m}function Tw({form:e,anchored:t}){var be;const n=ut(),r=it(),o=es(),i=ao(),l=o.displayName(i.origin),c=M(C=>C.repos),u=M(C=>C.newProject?null:C.activeRepoId),p=M(C=>C.rows),h=M(C=>C.paths),m=M(C=>C.home),g=M(C=>C.pending),w=M(C=>C.folderDialog),y=S.useRef(""),b=S.useMemo(()=>Pv(c,p),[c,p]),_=sS(),T=iS(),x=S.useMemo(()=>_.map(C=>{var Z;return{...C,repos:Pv(C.repos,((Z=T.find(Y=>Y.origin===C.origin))==null?void 0:Z.rows)??[])}}),[_,T]),N=S.useCallback(C=>{y.current=C,Xc(C)&&(r==null||r.send({t:"browse-path",path:C}))},[r]),j=S.useCallback((C,Z)=>x8({query:Z,repos:b,pending:g,entries:[...h.entries].sort((Y,q)=>Number(q.isRepo)-Number(Y.isRepo)),target:h.target,answered:h.query,home:m,others:x,current:u}),[b,h,g,m,x,u]),$=C=>ZT(p,C),P=()=>n({a:"close"}),R=()=>n({a:"close",back:!0}),A={sock:r,dispatch:n},O=C=>Qc(A,{t:"register-repo",path:C}),D=(C,Z)=>Qc(A,{t:"create-repo",mode:"create",parent:C,name:Z}),z=(C,Z,Y)=>n({a:"new-project",v:fk({mode:C,name:Z,parent:b8(c,u,m),...Y?{url:Y}:{}})}),X=()=>n({a:"open",overlay:{kind:"projects",form:"disk"}}),ne=()=>{const C=y.current.trim(),Z=C.lastIndexOf("/"),Y=Xc(C)&&Z>=0?C.slice(0,Z)||"/":"~";r==null||r.send({t:"choose-file",start:Y}),P()},ee=()=>n({a:"open",overlay:{kind:"devices"}}),ie=(C,Z)=>{const Y=o.get(C);Y&&(Y.store.dispatch({a:"activate-repo",id:Z}),o.activate(C))};return d.jsx(Mr,{anchored:e==="pill"&&(t??!0),initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:d.jsx("span",{className:"picker-chip",children:((be=c.find(C=>C.id===u))==null?void 0:be.name)??"no project"}),trailing:e==="disk"?w?d.jsx(Mt,{icon:"file",label:"Open a file from Finder",onClick:ne}):void 0:d.jsx(Mt,{icon:"folder",label:"Find a project or file on disk",onClick:X}),items:[],filter:j,initialIndex:C=>C.findIndex(Z=>Z.kind==="repo"&&!Z.machine&&Z.repo.id===u),groupOf:C=>C.kind==="machine"||C.kind==="repo"&&C.machine?C.machine.origin:i.origin,groupHead:C=>C===i.origin?l:d.jsx(S7,{origin:C}),keyOf:C=>C.kind==="repo"?C.machine?`${C.machine.origin}:${C.repo.id}`:C.repo.id:C.kind==="dir"?`d:${C.entry.path}`:C.kind==="file"?`f:${C.entry.path}`:C.kind==="open"?`open:${C.path}`:C.kind==="init"?`init:${C.path}`:C.kind==="pending"?`p:${C.pending.id}`:C.kind==="clone"?`clone:${C.url}`:C.kind==="new"?"new-project":C.kind==="disk"?"open-folder":C.kind==="add-machine"?"add-machine":C.kind==="machine"?`machine:${C.machine.origin}`:`new:${C.parent??""}/${C.name}`,rowClass:C=>We("picker-row",(C.kind==="new"||C.kind==="disk"||C.kind==="add-machine")&&"new-project-row"),onQuery:N,completionOf:C=>C.kind==="dir"?C.entry.isRepo?C.entry.path:`${C.entry.path}/`:C.kind==="file"?C.entry.path:null,narrowTo:C=>C.kind==="dir"&&!C.entry.isRepo?`${C.entry.path}/`:null,onPick:C=>{if(C.kind==="clone")return z("clone",C.name,C.url);if(C.kind==="create"&&!C.parent)return z("create",C.name);if(C.kind==="new")return z("create","");if(C.kind==="disk")return X();if(C.kind==="add-machine")return ee();C.kind==="machine"?o.activate(C.machine.origin):C.kind==="pending"?n({a:"watch-import",id:C.pending.id}):C.kind==="repo"&&C.machine?ie(C.machine.origin,C.repo.id):C.kind==="repo"?n({a:"activate-repo",id:C.repo.id}):C.kind==="open"?O(C.path):C.kind==="file"?g3(r,C.entry.path):C.kind==="init"?BN(A,C.path):C.kind==="dir"?O(C.entry.path):C.parent&&D(C.parent,C.name),P()},onBack:R,rowMenu:C=>C.kind==="machine"||C.kind==="repo"&&C.machine?dg(o,C.machine.origin):C.kind==="repo"?ah(C.repo,u,A):C.kind==="pending"?S8(C.pending,A):[],placeholder:c.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:C=>({complete:"completes the path",pick:(C==null?void 0:C.kind)==="dir"&&!C.entry.isRepo?"descends":(C==null?void 0:C.kind)==="pending"?"watches it":(C==null?void 0:C.kind)==="create"?C.parent?"creates it":"names it":(C==null?void 0:C.kind)==="clone"?"clones it":(C==null?void 0:C.kind)==="new"?"starts one":(C==null?void 0:C.kind)==="disk"?"browses":(C==null?void 0:C.kind)==="add-machine"?"adds one":(C==null?void 0:C.kind)==="machine"||(C==null?void 0:C.kind)==="repo"&&C.machine?"switches machine":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:C=>C.kind==="repo"&&C.machine?d.jsx(An,{label:C.repo.name,hint:d.jsx(_7,{origin:C.machine.origin,repo:C.repo})}):C.kind==="repo"?d.jsx(An,{label:C.repo.name,current:C.repo.id===u,hint:$(C.repo)}):C.kind==="pending"?d.jsx(An,{label:C.pending.name,hint:C.pending.error?"import failed":d.jsx("span",{className:"live-text",children:"importing"})}):C.kind==="dir"?d.jsx(An,{label:C.entry.name,hint:C.entry.isRepo?"git repo":void 0}):C.kind==="file"?d.jsx(An,{label:C.entry.name,hint:"file"}):C.kind==="open"?d.jsx(An,{label:`open ${C.path}`,hint:"register with this daemon"}):C.kind==="init"?d.jsx(An,{label:`open ${C.path}`,hint:"no git yet; starts it here with the files in it"}):C.kind==="clone"?d.jsx(An,{label:`clone ${C.name}`,hint:N7(C.url)}):C.kind==="new"?d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(Tt,{name:"plus",className:"icon-inline"}),"new project"]})}):C.kind==="disk"?d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(Tt,{name:"folder",className:"icon-inline"}),"open folder or file"]})}):C.kind==="add-machine"?d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(Tt,{name:"devices",className:"icon-inline"}),"add a machine"]})}):C.kind==="machine"?d.jsx(An,{label:`switch to ${o.displayName(C.machine.origin)}`}):d.jsx(An,{label:`create ${C.name}`,hint:C.parent?`in ${C.parent}`:"new project"})})}function ZT(e,t){const n=e.filter(u=>u.repoId===t.id),r=n.filter(Sn).filter(u=>u.worktree.kind!=="spare"),o=r.filter(u=>$o(u.agent)).length,i=r.length-1,l=n.length-n.filter(Sn).length;return[i>0?`${i} worktree${i===1?"":"s"}`:null,o>0?`${o} working`:null,l>0?`${l} discovered`:null].filter(Boolean).join(" · ")||void 0}function S7({origin:e}){const t=es(),n=t.get(e)??t.active(),r=Ja(n,m=>m.rows),o=Ja(n,m=>m.connected),i=Ja(n,m=>m.connectFailure),l=Ja(n,m=>m.incompatible),c=Ja(n,m=>{var g;return(g=m.remote)==null?void 0:g.front}),u=t.displayName(e),p=x7(u,{rows:r.filter(Sn),connected:o,connectFailure:i,incompatible:l,suspended:(c==="edge"||Tg(e))&&!o}),h=/^\d+ /.test(p);return d.jsxs(d.Fragment,{children:[u,d.jsx("span",{className:We("picker-group-tail",h&&"picker-group-owed"),children:p})]})}function _7({origin:e,repo:t}){const n=es(),r=n.get(e),o=Ja(r??n.active(),i=>i.rows);return d.jsx(d.Fragment,{children:r?ZT(o,t):null})}function N7(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function T7(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:()=>nn(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>nn(e.ref)}];return zn([t,n])}const j7=[],C7={branch:"branch",remote:"globe",pr:"pr"},Yx={pr:0,branch:1,remote:2},A7={pr:"pull requests",branch:"branches",remote:"remote branches"};function I7({repoId:e}){const t=ut(),n=it(),r=M(m=>m.clientId),o=M(m=>m.refs[e]),i=M(m=>m.rows),l=m=>{var g;return((g=i.find(w=>w.id===m))==null?void 0:g.name)??"a worktree"},c=S.useCallback(m=>[...m].sort((g,w)=>Yx[g.kind]-Yx[w.kind]),[]),u=S.useCallback(m=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:m.trim()}),[n,e]),p=m=>!o||o.query!==m.trim(),h=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(Mr,{items:(o==null?void 0:o.refs)??j7,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:T7,groupOf:m=>m.kind,groupHead:(m,g)=>`${A7[m]} · ${g}`,placeholder:"open a branch or PR…",keys:m=>({nav:"moves",pick:m!=null&&m.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:m=>p(m)?d.jsx("span",{className:"live-text",children:"looking"}):m.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:m=>d.jsx(An,{label:d.jsxs(d.Fragment,{children:[d.jsx(Tt,{name:C7[m.kind],className:"icon-inline"}),d.jsx("span",{className:"ref-name",children:m.name})]}),hint:h(m)})})}const Xx=[],pm=2;function $7({worktreeId:e}){const t=ut(),n=it(),r=mS(e).search,o=M(p=>p.layout.changes),i=M(p=>{var m;const h=(m=un(p,e))==null?void 0:m.worktree;return h?h.path:null}),l=S.useCallback((p,h)=>h.trim().length>=pm?p:Xx,[]),c=S.useCallback(p=>{const h=p.trim();h.length>=pm&&(n==null||n.send({t:"search",worktreeId:e,query:h}))},[n,e]),u=p=>!r||r.query.trim()!==p.trim();return S.useEffect(()=>()=>n==null?void 0:n.send({t:"search-stop"}),[n]),d.jsx(Mr,{items:(r==null?void 0:r.hits)??Xx,filter:l,onQuery:c,keyOf:p=>`${p.path}:${p.line}`,rowClass:()=>"search-hit",rowTitle:p=>`${p.path}:${p.line}`,onPick:p=>{er({dispatch:t},{worktreeId:e,path:p.path,view:"file",line:{n:p.line}}),o||t({a:"toggle-changes"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:p=>i?js({id:e,dir:i},p.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",keys:{pick:"opens the file",back:"closes"},empty:p=>p.trim().length<pm?"type at least two characters":u(p)?d.jsx("span",{className:"live-text",children:"searching"}):"no matches",footer:(p,h)=>r!=null&&r.truncated&&!u(p)&&h.length>0?d.jsx("div",{className:"empty",children:"not every match is shown; narrow the search"}):null,row:p=>d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"search-loc",children:[p.path,":",p.line]}),d.jsx("span",{className:"search-text",children:p.text})]})})}const Qx=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function R7({slot:e}){const t=ut(),n=it(),r=M(x=>x.themePrefs),o=M(x=>x.themes),i=yk(),l=Qg(r,i),c=r[e==="theme"?l:e],u=()=>t({a:"close"}),p=()=>t({a:"close",back:!0}),h=x=>t({a:"preview-theme",theme:x}),[m,g]=S.useState(null),[w,y]=S.useState(null),b=(x,N)=>x[N??l]??x.dark??x.light??null,_=S.useMemo(()=>WM(o),[o]),T=S.useMemo(()=>o.filter(x=>x.kind===e),[o,e]);return ft([m,w],()=>{e==="theme"&&h(m?b(m,w):null)}),e!=="theme"?d.jsx(Mr,{items:T,filter:(x,N)=>x.filter(j=>cs(N,j.name,j.id)),rowClass:()=>"picker-row",keyOf:x=>x.id,initialIndex:x=>x.findIndex(N=>N.id===c),onActive:h,onPick:x=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:x.id}}),u()},onBack:p,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:x=>d.jsx(An,{label:x.name,current:x.id===c,hint:Qx(x)})}):d.jsx(Mr,{items:_,filter:(x,N)=>x.filter(j=>{var $,P;return cs(N,j.name,($=j.dark)==null?void 0:$.name,(P=j.light)==null?void 0:P.name)}),rowClass:()=>"picker-row",keyOf:x=>{var N,j;return x.name+(((N=x.dark)==null?void 0:N.id)??((j=x.light)==null?void 0:j.id))},initialIndex:x=>x.findIndex(N=>{var j,$;return((j=N.dark)==null?void 0:j.id)===c||(($=N.light)==null?void 0:$.id)===c}),onActive:g,onSide:x=>{var N;x.dark&&x.light&&y((((N=b(x,w))==null?void 0:N.kind)??l)==="dark"?"light":"dark")},onPick:x=>{n==null||n.send({t:"set-theme",prefs:KM(r,x)}),u()},onBack:p,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(x,N)=>{var R,A;const j=b(x,N?w:null),$=Qx(x.dark??x.light),P=((R=x.dark)==null?void 0:R.id)===c||((A=x.light)==null?void 0:A.id)===c;return d.jsx(An,{label:x.name,current:P,hint:d.jsxs("span",{className:"theme-kinds",children:[$&&d.jsx("span",{children:$}),d.jsx("span",{className:"kind","data-state":dr({current:N&&(j==null?void 0:j.kind)==="dark"}),children:x.dark?"dark":""}),d.jsx("span",{className:"kind","data-state":dr({current:N&&(j==null?void 0:j.kind)==="light"}),children:x.light?"light":""})]})})}})}function qT(){const e=i4(),t=M(i=>i.frame==="phone"),n=jl(),r=M(i=>i.activeRepoId),o=M(i=>i.newProject);return d.jsxs(d.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&d.jsx(yB,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&d.jsx($7,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&d.jsx(k7,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&d.jsx(I7,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&d.jsx(XU,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&d.jsx(PU,{}),(e==null?void 0:e.kind)==="devices"&&d.jsx(g7,{}),(e==null?void 0:e.kind)==="theme"&&d.jsx(R7,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&d.jsx(KU,{}),(e==null?void 0:e.kind)==="keep-awake"&&d.jsx(b7,{}),(e==null?void 0:e.kind)==="agent"&&d.jsx(UU,{}),(e==null?void 0:e.kind)==="agent-page"&&d.jsx(FU,{agentId:e.agent}),(e==null?void 0:e.kind)==="handoff"&&d.jsx(y7,{worktreeId:e.worktreeId}),(e==null?void 0:e.kind)==="commands"&&!t&&d.jsx(ST,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&d.jsx(Tw,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&d.jsx(w7,{project:o})]})}const Lc="Lost the daemon; retrying",O7="Not run by Toyon",GT="new worktree",M7=(e,t)=>`in ${e}, started from ${t}`,P7=e=>`in ${e}, here while it needs you`,L7=new Set(["waiting","stopping","working","starting","failed","crashed"]);function jg(e,t){if(t.offline)return Lc;if(!Sn(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return sk(t.op);if(kr(e.worktree))return GT;const n=ok(e,t.needsSetup),r=e.worktree.lastTurn;return!L7.has(Is(e))&&r?Bk(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function D7(e,t){if(!Sn(e)||t)return!1;const n=Is(e);return(n==="idle"||n==="asleep")&&!e.unseen}function z7(e){const t=e.worktree.lastTurn,n=e.worktree.landed?Dk(e.worktree.lands):[],r=t?($o(e.agent)?wz:Bk)(t):void 0,o=Af(e.worktree),i=o&&!e.worktree.landed?Ts(o):void 0;return[...n,r,i].filter(l=>!!l)}function F7(e,t,n,r){let o;const i=(h,m)=>{const g=m==null?void 0:m[m.length-1];g&&(!o||g.at>o.mark.at)&&(o={title:h,mark:g})};for(const h of e)h.worktree&&i(h.worktree.title,h.worktree.lands);for(const h of t)i(h.title,h.lands);const l=o&&Lk(o.mark),c=o?`Landed ${o.title} ${Zo(wr(o.mark.at))}${l?`: ${Wr(l)}`:"."}`:void 0,u=n?l_(r,n):null,p=u?Wr(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${Zo(wr(n.fetchedAt))}.`:void 0;return[c,p].filter(h=>!!h)}function B7(e){const t=e.prompt?nh(e.prompt):"";return[...t?[t]:[],...Dk(e.lands)]}function U7(e){const n=[e.auto&&H7(e.auto,!!e.landed),e.cost!==void 0?uu(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function H7(e,t){const{what:n,idle:r}=IC(e);return r?`${t?"":`${n}, `}${r} idle`:n}const Jx=25;function W7(e,t){if(e.length<=Jx+1)return{shown:e,rest:0};const n=e.slice(0,Jx),r=t?e.find(o=>o.id===t):void 0;return r&&!n.includes(r)&&n.push(r),{shown:n,rest:e.length-n.length}}function K7(e,t,n){const r=e.indexOf(t);return r<0?null:e[r+(n?1:-1)]??null}const Z7=.5;function q7(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=Z7?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?uu(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}function G7(e){const t=o=>e.filter(fs).find(i=>i.id===o)??null,n=t("land"),r=t("archive");return[...n?[{id:"land",label:n.label,icon:"land",item:n}]:[],...r?[{id:"archive",label:r.label,icon:"archive",item:r}]:[],{id:"more",label:"more",icon:"more",item:null}]}function V7(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function Y7(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const X7=200,VT={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function Q7(e,t=VT){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 p=n!==null;n=V7(u),l(),n&&(p?i():o=t.set(()=>{o=null,i()},X7))},keyup(u){n&&u===n&&c()},mods(u){n&&!Y7(u,n)&&c()},end:c}}const J7=350,eH=80,tH=2e3;function nH(e,t=VT){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},p=()=>{c(),u(),o=null,n&&(n=!1,e(!1))};return{over(h){u(),l=t.set(p,tH),n||(n=!0,e(!0)),(r==null?void 0:r.id)!==(h==null?void 0:h.id)&&(c(),!(!h||h.id===o)&&(o=null,r={id:h.id,pending:t.set(()=>{r=null,o=h.id,h.land()},J7)}))},leave(){n&&(i!==null&&t.clear(i),i=t.set(p,eH))},end:p}}const Dd=e=>e>999?"1k+":String(e);function YT({width:e,placement:t="strip"}){const n=t==="screen",r=Si(),o=M(V=>V.chatSide)==="left"?"right":"left",i=ut(),l=it(),{host:c}=Kr(),u=Sk(),p=u[0]&&kr(u[0].worktree)?u[0]:null,h=p?u.slice(1):u,m=M(V=>wl(V,V.activeRepoId)),g=V=>p&&V.id===p.id&&m?{behind:m.behind,dirty:m.dirty}:V,[,w]=S.useState(0);S.useEffect(()=>{const V=setInterval(()=>w(pe=>pe+1),6e4);return()=>clearInterval(V)},[]);const y=JL(),b=e4(),_=t4(),T=n4(),x=(V,pe,Ye)=>{V.key!=="ArrowLeft"&&V.key!=="ArrowRight"||V.shiftKey||V.altKey||V.metaKey||V.ctrlKey||(V.preventDefault(),eh([{depth:0,open:pe}],0,V.key)&&i({a:Ye}))},N=ha(),j=M(V=>V.notesPage),$=M(V=>V.clientId),P=M(V=>V.frame),R=M(V=>V.activeRepoId),A=M(V=>V.connected);S.useEffect(()=>{l&&A&&R&&l.send({t:"list-archived",repoId:R})},[l,A,R]);const O=jl(),D=hS(),z=M(V=>V.layout),X=M(V=>V.railOpen),ne=M(V=>V.railPeek),ee=S.useRef(null),[ie,be]=S.useState(!1);ft([ne],()=>{var V;ne&&!n&&!r&&!((V=ee.current)!=null&&V.matches(":hover"))&&be(!0)}),S.useEffect(()=>{if(!ie)return;let V=null;const pe=Ye=>{if(!V){V={x:Ye.clientX,y:Ye.clientY};return}Math.abs(Ye.clientX-V.x)+Math.abs(Ye.clientY-V.y)<3||be(!1)};return window.addEventListener("pointermove",pe),()=>window.removeEventListener("pointermove",pe)},[ie]);const[C,Z]=S.useState(!1),Y=S.useMemo(()=>nH(Z),[]);S.useEffect(()=>()=>Y.end(),[Y]);const q=M(V=>{var pe;return((pe=V.dragFiles)==null?void 0:pe.at)==="rail"?V.dragFiles.worktreeId:null}),F=M(V=>V.focusRail),re=S.useRef(F),Ee=S.useRef(null);ft([F],()=>{if(F===re.current)return;re.current=F;const V=requestAnimationFrame(()=>{var pe,Ye;return(Ye=(pe=Ee.current)==null?void 0:pe.querySelector('[data-state~="current"]'))==null?void 0:Ye.focus()});return()=>cancelAnimationFrame(V)});const Te=(V,pe,Ye,nt,yt)=>{var ye,Ae;if(V.key!=="ArrowUp"&&V.key!=="ArrowDown"||V.altKey||V.ctrlKey||V.metaKey)return;V.preventDefault();const Jt=K7(pe,Ye,V.key==="ArrowDown");Jt!==null&&(yt(Jt),(Ae=(ye=Ee.current)==null?void 0:ye.querySelector(`[${nt}="${Jt}"]`))==null||Ae.focus())},de=M(V=>V.repos),ke=M(V=>V.shipping),ae=M(V=>V.rows),G=V=>de.find(pe=>pe.id===V.repoId)??null,ue=V=>R?gk(V,R,ae):null,Le=V=>R&&V.repoId!==R?G(V):null,ge=yn("rail"),oe=Tk(),we=M(V=>V.home),Ce=V=>{const pe=V.worktree?V.worktree.path:V.path;return we&&pe.startsWith(`${we}/`)?`~${pe.slice(we.length)}`:pe},[Se,_e]=S.useState(!1),[Be,wt]=S.useState([]),on=V=>{!Bd(V.worktree)||Le(V)||(_e(!0),wt(pe=>pe.includes(V.worktree.id)?pe.filter(Ye=>Ye!==V.worktree.id):[...pe,V.worktree.id]))},Et=()=>{_e(!1),wt([])};ft([Se],()=>{const V=pe=>pe.key==="Escape"&&Et();return Se&&window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)});const Vt=Pk(l,i),Ft={sock:l,dispatch:i},Ht=V=>{_e(!0),wt(pe=>V===O||pe.includes(V)?pe:[...pe,V])},Me=V=>Sn(V)?s_(V,G(V),{layout:z,shipping:ke,frame:P,repos:de},Ft,{...Le(V)?{}:{graft:Ht},hostname:c}):oz(V,{clientId:$,frame:P},Ft,c),[St,sn]=S.useState(null),ln=V=>Sn(V)?G7(Me(V)):[];IT(Ee,{rowOf:V=>{if(!n||Se)return null;const pe=V.closest(".slide"),Ye=pe==null?void 0:pe.dataset.row,nt=Ye?u.find(yt=>yt.id===Ye):void 0;return pe&&Ye&&nt?{el:pe,key:Ye,rungs:ln(nt).length}:null},onSlide:sn,onPick:(V,pe)=>{var yt;const Ye=u.find(Jt=>Jt.id===V),nt=Ye?ln(Ye)[pe-1]:void 0;if(!(!Ye||!nt)){if(nt.id==="more"){const Jt=(yt=Ee.current)==null?void 0:yt.querySelector(`.slide[data-row="${V}"]`);Jt&&ge.openUnder(Jt,()=>Me(Ye),V)}else if(nt.item&&!nt.item.disabled){const Jt=nt.item.onClick;window.setTimeout(Jt,AT)}}}});const lt=W7(_,(N==null?void 0:N.id)??null),jt=lt.shown.some(V=>(V.dirty??0)>0),Kt=V=>d.jsxs("button",{type:"button",className:We("row row-edge row-quiet rail-disc-item rail-arch-item",(oe==null?void 0:oe.owner)==="rail"&&oe.key===V.id&&"menu-open"),"data-state":dr({current:!n&&(N==null?void 0:N.id)===V.id}),"data-arch":V.id,...Ut(Gz(V),void 0,{placement:o,card:!0,detail:B7(V),aside:U7(V)}),onClick:()=>i({a:"open-archived",id:V.id}),onKeyDown:pe=>Te(pe,lt.shown.map(Ye=>Ye.id),V.id,"data-arch",Ye=>i({a:"open-archived",id:Ye})),...ge.contextMenu(()=>Gd(V,{clientId:$,frame:P},Ft),V.id),children:[d.jsxs("span",{className:"rail-gut",onClick:r?pe=>{pe.stopPropagation(),ge.openUnder(pe.currentTarget,()=>Gd(V,{clientId:$,frame:P},Ft),V.id)}:void 0,children:[d.jsx("span",{className:"rail-at row-dim",children:wr(V.archivedAt)}),d.jsx("span",{className:"rail-more",...Ut("Actions"),onClick:pe=>{pe.stopPropagation(),ge.openUnder(pe.currentTarget,()=>Gd(V,{clientId:$,frame:P},Ft),V.id)},children:d.jsx(Tt,{name:"more"})})]}),d.jsx("span",{className:"branch",children:V.title}),jt&&d.jsx("span",{className:"rail-counts",children:d.jsx("span",{className:"rail-count row-dim","data-tip":V.dirty?`${V.dirty} uncommitted, kept`:void 0,children:V.dirty?`~${Dd(V.dirty)}`:""})}),V.auto?d.jsx("span",{className:"rail-glyph rail-auto row-dim",children:d.jsx(Tt,{name:"clock",className:"icon-inline"})}):d.jsx("span",{className:"dot"}),n&&d.jsx("span",{className:"rail-at rail-at-end row-dim",children:wr(V.archivedAt)})]},V.id),xn=[...u,...y].map(g),Dt=["ahead","dirty","behind"].filter(V=>xn.some(pe=>(pe[V]??0)>0)),jn=V=>{const pe=Dt.findIndex(Ye=>(V[Ye]??0)>0);return new Set(pe<0?[]:Dt.slice(pe))},Qt=V=>{var Ct;const pe=Sn(V)?V:null,Ye=!!pe&&kr(pe.worktree),nt=g(V),yt=de.find(Bt=>Bt.id===V.repoId)??null,Jt=yt?Cf(yt):"main",ye=yt&&gA(yt)&&(m!=null&&m.fetchedAt)?` as of ${a_(m.fetchedAt)}`:"",Ae=jn(nt),Yt=!!nt.ahead&&!nt.dirty,B=V.id,me=(oe==null?void 0:oe.owner)==="rail"&&oe.key===B,De=pe?ue(pe):null,Xe=pe?Le(pe):null,Pt=pe&&!Xe&&Se&&Bd(pe.worktree)&&B!==O,_t=IE(V,(Ct=ke[B])==null?void 0:Ct.op),He=d.jsxs("button",{type:"button",className:We("row row-edge",pe?"rail-item":"row-quiet rail-disc-item",n&&D7(V,_t)&&"row-quiet",me&&"menu-open",q===B&&"drop-over"),"data-state":dr({current:!n&&B===O&&!N&&!j,checked:Be.includes(B)}),...pe?Ut(D?Lc:_t?sk(_t):ok(V,uf(G(pe))),void 0,{placement:o,card:!0,aside:q7(V),detail:kr(pe.worktree)?F7(u,_,m,Jt):[...Xe?[De?M7(Xe.name,De.worktree.title):P7(Xe.name)]:[],...z7(pe)],dot:D?void 0:_t?"spinner":Is(V)}):Ut(D?Lc:V.locked?`Held by ${V.lockReason??"another tool"}`:O7,void 0,{placement:o,card:!0,detail:Ce(V),dot:D||V.locked?void 0:"discovered"}),"data-wt":B,onKeyDown:Bt=>{if(Se)return;const qt=(pe?u:y).map(vn=>vn.id);Te(Bt,qt,B,"data-wt",vn=>i({a:"activate",id:vn}))},onClick:Bt=>{pe&&!Xe&&(Se||Bt.shiftKey)?B===O?_e(!0):on(pe):Ye&&!n?i({a:"open-draft"}):(i({a:"activate",id:B}),pe&&!r&&i({a:"walked"}))},...ge.contextMenu(()=>Me(V),B),children:[d.jsx("span",{className:"rail-gut",onClick:r&&!Se?Bt=>{Bt.stopPropagation(),ge.openUnder(Bt.currentTarget,()=>Me(V),B)}:void 0,children:Pt?d.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:Be.includes(B),readOnly:!0,tabIndex:-1}):!Se&&d.jsxs(d.Fragment,{children:[pe&&!Ye&&d.jsx("span",{className:"rail-at row-dim",children:wr(la(pe.worktree))}),d.jsx("span",{className:"rail-more",...Ut("Actions"),onClick:Bt=>{Bt.stopPropagation(),ge.openUnder(Bt.currentTarget,()=>Me(V),B)},children:d.jsx(Tt,{name:"more"})})]})}),Ye?d.jsxs("span",{className:"branch rail-main-label",children:[d.jsx(Tt,{name:"plus",className:"icon-inline"}),"new worktree"]}):d.jsx("span",{className:We("branch",(pe==null?void 0:pe.worktree.unnamed)&&"row-dim"),children:Mm(V,pe?G(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 Bt=G(pe),qt=n_(pe.worktree,Bt);return qt&&qt!==(Bt==null?void 0:Bt.config.defaultProfile)?d.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${qt} profile`,children:qt}):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:Bt=>{Bt.stopPropagation(),Vt.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"})]}),Xe&&d.jsx("span",{className:"rail-guest row-dim",children:Xe.name}),d.jsxs("span",{className:"rail-counts",children:[Ae.has("ahead")&&d.jsx("span",{className:"rail-count badge-ahead","data-tip":nt.ahead?`${nt.ahead} ahead of ${Jt}`:void 0,children:nt.ahead?`+${Dd(nt.ahead)}`:""}),Ae.has("dirty")&&!Yt&&d.jsx("span",{className:"rail-count badge-dirty","data-tip":nt.dirty?`${nt.dirty} uncommitted${Ye?" on main":""}`:void 0,children:nt.dirty?`~${Dd(nt.dirty)}`:""}),Ae.has("behind")&&d.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":nt.behind?`${nt.behind} behind ${Ye?"origin":Jt}${Ye?"":ye}`:void 0,children:nt.behind?Dd(nt.behind):""}),n&&pe&&d.jsx("span",{className:"rail-at row-dim",children:Ye?"":wr(la(pe.worktree))})]}),(()=>{if(_t)return d.jsx(vl,{size:"dot"});if(V.locked)return d.jsx("span",{className:"rail-glyph rail-lock row-dim",children:d.jsx(Tt,{name:"lock",className:"icon-inline"})});if(!pe)return d.jsx("span",{className:"dot discovered"});const Bt=Se||D?null:$E(V.procs),qt=V.unseen?" unseen":"",vn=Is(V);return Ye&&!Bt&&vn!=="crashed"&&!D?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:`dot ${vn} rail-main-dot`}),d.jsx("span",{className:"rail-glyph rail-main-strip",children:d.jsx(Tt,{name:"plus"})})]}):!Bt||vn!=="crashed"?d.jsx("span",{className:`dot ${vn}${qt}`}):d.jsx("span",{className:`dot crashed clickable${qt}`,...Ut(Bt.tip),onClick:On=>{On.stopPropagation(),i({a:"activate",id:B}),i({a:"term-stream",id:B,stream:Bt.stream})}})})(),n&&d.jsx("span",{className:"rail-say row-dim",children:jg(V,{offline:D,needsSetup:uf(pe?G(pe):null),path:Ce(V),op:_t})})]},B);if(!n||!pe)return He;const ze=(St==null?void 0:St.key)===B?St.step:null,qe=ze===null?null:ln(V)[Math.max(0,ze-1)],ht=!!qe&&ze!==null&&ze>0&&(qe.id==="more"||!!qe.item&&!qe.item.disabled);return d.jsxs("div",{className:"slide","data-row":B,children:[He,qe&&d.jsxs("span",{className:"slide-verb","data-rung":ht?qe.id:void 0,"aria-hidden":"true",children:[d.jsx("span",{className:"slide-word",children:qe.label}),d.jsx(Tt,{name:qe.icon})]})]},B)};return d.jsx("div",{ref:ee,className:We("rail",n&&"rail-screen",!n&&(Se||(oe==null?void 0:oe.owner)==="rail"||ne||C)&&"hold",ie&&"quiet",(n||X)&&"pinned",D&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!X?V=>{V.target instanceof Element&&V.target.closest("button, .rail-gut")||i({a:"toggle-rail"})}:void 0,onDragOver:V=>{var yt;if(!Zm(V.dataTransfer))return;const pe=V.target instanceof Element?(yt=V.target.closest("[data-wt]"))==null?void 0:yt.dataset.wt:void 0,Ye=pe?[...u,...y].find(Jt=>Jt.id===pe):void 0;if(!Ye||Se||Ye.id===O)return Y.over(null);const nt=!n&&Sn(Ye)&&kr(Ye.worktree);Y.over({id:Ye.id,land:()=>i(nt?{a:"open-draft"}:{a:"activate",id:Ye.id})})},onDragLeave:Y.leave,onDrop:Y.end,children:d.jsxs("div",{className:"rail-panel","data-tip":D?Lc:void 0,"data-tip-placement":"follow",children:[d.jsxs("div",{className:"rail-list",ref:Ee,children:[p&&!n&&Qt(p),h.map(Qt),Se&&d.jsxs("div",{className:"rail-graft",children:[(()=>{const V=u.find(nt=>nt.worktree.id===O&&Bd(nt.worktree)&&!Le(nt)),pe=Be.filter(nt=>nt!==(V==null?void 0:V.worktree.id)),Ye=pe.map(nt=>{var yt;return((yt=u.find(Jt=>Jt.worktree.id===nt))==null?void 0:yt.worktree.title)??nt}).join(", ");return d.jsxs(Fe,{size:"md",tone:"primary",disabled:!V||pe.length===0,"data-tip":V?`Merge the checked worktrees into ${V.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{V&&window.confirm(`Graft ${Ye} onto ${V.worktree.title}?
|
|
253
|
-
|
|
254
|
-
Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:V.worktree.id,sourceIds:pe}),Et())},children:["graft ",pe.length]})})(),d.jsxs(Fe,{size:"md",disabled:!Be.some(V=>{var pe;return(((pe=u.find(Ye=>Ye.worktree.id===V))==null?void 0:pe.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const V of Be){const pe=u.find(Ye=>Ye.worktree.id===V);((pe==null?void 0:pe.behind)??0)>0&&pi(l,i,{t:"sync-main",worktreeId:V})}Et()},children:[d.jsx(Tt,{name:"pull",className:"icon-inline"})," sync"]}),d.jsx(Fe,{size:"md",tone:"danger",disabled:Be.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${Be.length} worktree(s)?
|
|
255
|
-
|
|
256
|
-
Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(sa(l,i,Be),Et())},children:"archive…"}),d.jsx(Mt,{icon:"close",label:"Cancel",hint:"esc",onClick:Et})]}),!Se&&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:V=>x(V,b,"toggle-discovered"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(Tt,{name:"caret",className:We("icon-inline disc-caret",!b&&"shut")})}),d.jsx("span",{className:"rail-label",children:"discovered"})]}),b&&y.map(Qt)]}),!Se&&_.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":T,...Ut(`${_.length} archived worktree${_.length===1?"":"s"}, kept with ${_.length===1?"its chat":"their chats"}`,void 0,{placement:o}),onClick:()=>i({a:"toggle-archived"}),onKeyDown:V=>x(V,T,"toggle-archived"),children:[d.jsx("span",{className:"rail-gut",children:d.jsx(Tt,{name:"caret",className:We("icon-inline disc-caret",!T&&"shut")})}),d.jsx("span",{className:"rail-label",children:"archived"})]}),T&<.shown.map(Kt),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:[lt.rest," more"]}),d.jsx("span",{className:"dot"})]})]})]}),!n&&d.jsx("div",{className:"rail-foot",children:d.jsx(Mt,{icon:"worktrees",label:"Worktree panel",hint:zt("rail"),tone:"chrome",on:X,onClick:()=>i({a:"toggle-rail"})})})]})})}function rH({screen:e,tabs:t,fold:n}){const r=ut(),o=es(),i=ao(),l=M(C=>C.reading),c=s4(),u=Cl(),p=M(C=>C.repos),h=$s(),m=jl(),g=ha(),w=_k(),y=Sk(),b=hS(),_=iS(),T=w8(y,m,_),x=y.find(C=>kr(C.worktree)),N=e==="home",j=!N&&!g&&!!h&&kr(h.worktree),$=M(C=>{var Z;return j&&h?IE(h,(Z=C.shipping[h.id])==null?void 0:Z.op):null}),P=wk().length,R=o.displayName(i.origin),A=N?(c==null?void 0:c.name)??R:j?GT:(g==null?void 0:g.title)??(h==null?void 0:h.worktree.title)??(w==null?void 0:w.name)??null,O=y.filter(C=>!kr(C.worktree)).length,D=O===0?"no worktrees yet":`${O} ${O===1?"worktree":"worktrees"}`,z=N?c&&P>1?`${R} · ${D}`:D:g?E_(g):j?b?Lc:$?sk($):(c==null?void 0:c.name)??null:h?jg(h,{offline:b,needsSetup:uf(u),path:h.worktree.path,at:wr(la(h.worktree))}):w?jg(w,{offline:b,needsSetup:!1,path:w.path}):null,X=!N&&!g&&!!h&&Is(h)==="waiting",ne=M(C=>{var Z;return((Z=C.overlay)==null?void 0:Z.kind)==="projects"&&C.overlay.form==="pill"}),ee=M(C=>{var Z;return((Z=C.overlay)==null?void 0:Z.kind)==="commands"}),ie=d.jsxs("div",{className:"phone-title",children:[N&&(p.length>1||P>1)?d.jsxs("span",{className:"phone-drop phone-switch",children:[d.jsxs(Fe,{tone:"chrome",on:ne,onClick:()=>r({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[d.jsx("span",{className:"phone-name",children:A}),d.jsx(Tt,{name:"caret",className:"icon-inline"})]}),ne&&d.jsx(Tw,{form:"pill",anchored:{margin:6}})]}):d.jsx("span",{className:"phone-name",children:A}),z&&d.jsx("span",{className:We("phone-sub",X&&"phone-sub-asks"),children:z})]}),be=T&&d.jsxs(Fe,{size:"md",tone:"primary",onClick:()=>{const C=y8(y,m,_);if(!C)return;if(C.origin===null)return r({a:"activate",id:C.activate});const Z=o.get(C.origin);Z&&(Z.store.dispatch({a:"activate",id:C.activate}),o.activate(C.origin))},children:[T.n," ",T.tier]});return d.jsxs("div",{className:"phone-bar",children:[d.jsxs("div",{className:"phone-bar-row",children:[!N&&d.jsx(Mt,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>r({a:"screen",to:"home"})}),t?d.jsx("div",{className:"phone-tabs",children:t}):ie,!t&&be,N&&x&&d.jsx(Mt,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>r({a:"activate",id:x.id})}),d.jsxs("span",{className:"phone-drop",children:[d.jsx(Mt,{icon:"more",label:"Menu",tone:"chrome",on:ee,onClick:()=>r({a:"toggle",overlay:{kind:"commands"}})}),ee&&d.jsx(ST,{anchored:{flip:"align",margin:6},trailing:d.jsx(Mt,{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:[ie,be]})})]})}const Xd="toyonDepth",XT="toyonOver",mm=-1;function gm(e){if(e.frame!=="phone"||!e.heard)return null;if(!(e.screen!=="home"&&(wo(e,e.activeId)!==null||Oo(e)!==null)))return 0;const n=un(e,e.activeId)!==null&&!Ao(e)&&Oo(e)===null;return 1+(e.screen==="changes"||e.screen==="preview"&&n?1:0)+(e.editor?1:0)}const QT=(()=>{const e=new Set;return{watch(t){return e.add(t),()=>e.delete(t)},tell(t){for(const n of e)n(t)}}})(),km=e=>{const t=e&&typeof e=="object"?e[Xd]:void 0;return typeof t=="number"?t:null},oH=e=>!!e&&typeof e=="object"&&e[XT]===!0;function JT(e,t=window,n=bl,r=QT){const o=t.history;let i=km(o.state)??mm,l=km(o.state)!==null,c=null;const u=()=>{const N=n.open();c&&!N.includes(c)&&(c=null);for(let j=N.length-1;j>=0;j--){const $=N[j];if($!=null&&$.dismiss&&$!==c)return $}return null};let p=!1;const h=()=>{const N=gm(e.getState());if(N===null||p)return;l||(o.replaceState({[Xd]:mm},""),l=!0);const j=N+(u()?1:0);if(j!==i)if(j>i){for(let $=i+1;$<=j;$++)o.pushState({[Xd]:$,[XT]:$>N},"");i=j}else o.go(-1),p=!0};let m=!1;const g=()=>{m||(m=!0,queueMicrotask(()=>{m=!1,h()}))},w=(N,j,$)=>{const P=u();if(P){c=P,n.shut(P);return}const R=$===0?"home":N.editor&&$===j-1?N.screen:"chat";e.dispatch({a:"screen",to:R})},y=N=>{const j=p;p=!1,i=km(N.state)??mm;const $=e.getState(),P=gm($);if(P===null)return;if(i<0){o.pushState({[Xd]:0},""),i=0,h();return}if(j){h();return}const R=P+(u()?1:0);R!==i&&(R>i?w($,P,i):R===0&&$.activeId&&!oH(N.state)&&e.dispatch({a:"screen",to:"chat"}),h())},b=N=>{if(p){p=!1,h();return}const j=e.getState(),$=gm(j);$===null||$===0||j.screen==="preview"&&!j.editor&&$===2||N.dir==="forward"||w(j,$,$+(u()?1:0)-1)};t.addEventListener("popstate",y);const _=e.subscribe(h),T=n.watch(g),x=r.watch(b);return h(),()=>{t.removeEventListener("popstate",y),_(),T(),x()}}function sH({gated:e,active:t,url:n,hidden:r}){const o=mk(t),i=bD(ao(),o?n:null,e),l=S.useRef(null);return S.useEffect(()=>{if(!i)return;const c=new URL(i,location.href).origin,u=p=>{var m,g;if(p.source!==((m=l.current)==null?void 0:m.contentWindow)||p.origin!==c||!((g=p.data)!=null&&g.__toyon))return;const h=uE(p.data);(h==null?void 0:h.type)==="traversed"&&QT.tell({dir:h.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(ps,{wide:!0,children:d.jsx("p",{className:"status-line",children:ok(t)})})})}const iH=Jg();function aH(){const e=S.useRef(null);VL(e),YL(e);const t=ut(),n=M(R=>R.screen),r=$s(),o=ha(),i=_k(),l=M(R=>R.editor),c=M(R=>R.remote),u=au(),p=M(R=>R.connected),h=M(R=>R.heard),m=M(R=>R.connectFailure),g=Si(),w=ao(),y=es(),b=M(R=>R.incompatible),_=e_({connected:p,heard:h,connectFailure:m,hasToken:w.serving?iH:!0,projectChord:zt("project"),title:(r==null?void 0:r.worktree.title)??null,machine:w.serving?null:y.displayName(w.origin)}),T=n!=="home"&&(r!==null||o!==null||i!==null),x=T&&!u&&!o?r:null,{host:N}=Kr(),j=x?CE(x.worktree.id,x.worktree.proxyPort,c,N):null,$=n==="preview"&&!x?"chat":n,P=[{id:"chat",label:"chat"},...x&&j?[{id:"preview",label:"preview",trail:d.jsx(Mt,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>xD(w,j,qm(w,c))})}]:[],{id:"changes",label:"code"}];return d.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":g||void 0,"data-hover":!g||void 0,children:[d.jsx(qS,{}),d.jsx(XS,{}),d.jsx(rH,{screen:T?"chat":"home",fold:$!=="chat"||l!==null,tabs:T&&_===null&&d.jsx(Jf,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:P,current:$,onPick:R=>t({a:"screen",to:R})})}),d.jsx("div",{className:"phone-screen",children:d.jsxs("div",{className:"center-root",children:[b&&!w.serving?d.jsx(JS,{foreign:y.displayName(w.origin)}):_!==null?d.jsx(ps,{wide:!0,children:d.jsx("p",{className:We("status-line",_.live&&"live-text"),children:_.text})}):T?l?d.jsx(FT,{editor:l,placement:"screen"}):$==="chat"?d.jsx(Pc,{placement:"screen",archived:o,found:i}):$==="changes"?d.jsx(v_,{placement:"screen"}):null:d.jsx(YT,{placement:"screen"}),x&&j&&d.jsx(sH,{gated:qm(w,c),active:x,url:j,hidden:$!=="preview"||l!==null},x.worktree.id),d.jsx(qT,{})]})})]})}const lH=640,cH=1e3,ej=`(max-width: ${lH}px), ((hover: none) and (max-width: ${cH}px))`,tj="(hover: none)",jw=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,ej).matches?"phone":"desk"},uH=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,tj).matches)??!1};function dH(e){const t=(o,i)=>{var u;const l=(u=window.matchMedia)==null?void 0:u.call(window,o);if(!l)return()=>{};const c=p=>i(p.matches);return l.addEventListener("change",c),()=>l.removeEventListener("change",c)},n=t(ej,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(tj,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}function fH(){try{const e=localStorage.getItem(Ge.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return su}function hH(){if(jw()!=="phone")return"surface0";try{const e=sessionStorage.getItem(Ge.ground);if(e==="surface0"||e==="surface1")return e}catch{}return"surface1"}function nj(e,t={}){var i;const n=document.documentElement;for(const[l,c]of Object.entries(FM(e)))n.style.setProperty(l,c);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=t.ground??hH();n.dataset.ground=r;const o=jw()==="phone"?e.colors[r]:e.colors.surface1;if((i=document.querySelector('meta[name="theme-color"]'))==null||i.setAttribute("content",o),t.remember!==!1)try{localStorage.setItem(Ge.theme,JSON.stringify(e))}catch{}}function rj(e){const t=Xg(e);return{type:"theme",accent:t,accentFg:GM(t)}}function pH(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const mH=12*36e5;function gH(){try{const e=localStorage.getItem(Ge.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<mH?{dark:!t.dark,until:0}:null}catch{return null}}function kH(e){try{localStorage.setItem(Ge.daylight,JSON.stringify(e))}catch{}}function wH(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 yH(e,t){return{word:`what's new in ${t}`,text:`Toyon updated from ${e} to ${t} since you last opened it here. Press to read what changed`}}function e1(e,t){return t==="reading"?"Reading the release notes":`No release notes could be read from Toyon ${e}.`}function vH(){const e=Kr(),t=M(i=>i.version),[n,r]=S.useState(void 0);S.useEffect(()=>{let i=!0;return sP(e).then(l=>{i&&r(l)}),()=>{i=!1}},[e]);const o=sh(n??"",{keepHtml:!0});return n?d.jsx("div",{className:"notes-page",children:d.jsx(zT,{html:o})}):d.jsx(ps,{wide:!0,children:d.jsx("p",{className:"status-line",children:n===void 0?d.jsx("span",{className:"live-text",children:e1(t,"reading")}):e1(t,"missing")})})}function Cg(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>nn(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>nn(t)}]}function Ag(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>nn(e)}]}function bH(e,t,{sock:n},r){return t?zn([[{id:"source",label:"open source",onClick:r}],Jo(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t}),Qo(n)),[{id:"copy-path",label:"copy path",onClick:()=>nn(t)}]]):[]}function nu(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 xH(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function t1([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 oj(e,t){if(xH(e))return null;const n=nu(e);if(!n)return null;const r=nu(t);if(!r)return null;const[o,i]=[t1(n),t1(r)];return`${((Math.max(o,i)+.05)/(Math.min(o,i)+.05)).toFixed(2)}:1`}function EH({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const i=ut(),l=it(),c=M(p=>Ro(p,e).design);S.useEffect(()=>{c||l==null||l.send({t:"design-scan",worktreeId:e})},[c,e,l]),S.useEffect(()=>()=>an.post(e,{type:"highlight-clear"}),[e]);const u={outline:p=>an.post(e,p),clear:()=>an.post(e,{type:"highlight-clear"}),open:p=>er({dispatch:i},{worktreeId:e,path:p})};return d.jsx(Nw,{kind:"design",className:We("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:c?d.jsx("span",{children:TH(c)}):void 0,onClose:()=>i({a:"toggle-design"}),closeHint:zt("design"),full:n,onToggleFull:r,actions:d.jsxs(Fe,{variant:"outline",onClick:()=>l==null?void 0:l.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[d.jsx(Tt,{name:"reload",className:"icon-inline"})," rescan"]}),children:c?d.jsxs("div",{className:"design-body",style:NH,onMouseLeave:u.clear,children:[c.tokens.length===0&&c.literals.length>0?d.jsx(RH,{literals:c.literals,outline:u.outline,clear:u.clear}):d.jsx(IH,{tokens:c.tokens,coverage:c.coverage,outline:u.outline,clear:u.clear}),d.jsx(UH,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open}),d.jsx(HH,{index:c,outline:u.outline,clear:u.clear,onOpen:u.open})]}):d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"reading the design system"})})})}const SH=720,_H=132,NH={"--design-column":`${SH}px`,"--design-cell":`${_H}px`};function TH(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 sl=e=>`${e} use${e===1?"":"s"}`;function ch({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 Nf({children:e}){return d.jsx("p",{className:"design-gap",children:e})}const jH=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function CH(e){return e.find(t=>t.kind==="color"&&nu(t.resolved??t.value)!==null)}function AH(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 IH({tokens:e,coverage:t,outline:n,clear:r}){const o=CH(e),i=o&&(o.resolved??o.value),l=new Map;for(const u of e){const p=(u.resolved??u.value).trim().toLowerCase();l.set(p,[...l.get(p)??[],u.name])}const c=u=>(l.get((u.resolved??u.value).trim().toLowerCase())??[]).filter(p=>p!==u.name);return d.jsx(ch,{title:"Tokens",children:e.length===0?d.jsx(Nf,{children:AH(t)}):jH.map(({kind:u,label:p})=>{const h=e.filter(g=>g.kind===u);if(h.length===0)return null;const m=ij(h.map(g=>g.value));return d.jsxs("div",{className:"design-group",children:[u!=="font"&&d.jsx("span",{className:"design-group-name",children:p}),u==="font"?d.jsx(aj,{groups:DH(h),outline:n,clear:r}):d.jsx("div",{className:"design-breakout",style:sj(h.length),children:d.jsx("div",{className:"design-grid",children:h.map(g=>{const w=g.resolved??g.value,y=g.kind==="color"&&i?oj(w,i):null;return d.jsx(lj,{kind:g.kind,name:g.name,lines:g.resolved?[g.value,g.resolved]:[g.value],actual:w,ratio:y,largest:m,tipText:FH(g,y,o,c(g)),menu:()=>Cg(g.name,w),outline:n,clear:r},g.name)})})})]},u)})})}const $H=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function RH({literals:e,outline:t,clear:n}){const r=e.find(i=>i.ground&&nu(i.value)!==null),o=zH(e);return d.jsxs(ch,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&d.jsx("div",{className:"design-group",children:d.jsx(aj,{groups:o,outline:t,clear:n})}),$H.map(({role:i,kind:l,label:c})=>{const u=e.filter(h=>h.role===i);if(u.length===0)return null;const p=ij(u.map(h=>h.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:sj(u.length),children:d.jsx("div",{className:"design-grid",children:u.map(h=>{const m=l==="color"&&r?oj(h.value,r.value):null;return d.jsx(lj,{kind:l,name:h.value,lines:[sl(h.uses)],actual:h.value,ratio:m,largest:p,tipText:BH(h,m,r),menu:()=>Ag(h.value),outline:t,clear:n},h.value)})})})]},i)})]})}function sj(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 ij(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const OH=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function MH(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const Ig=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function PH(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:Ig(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:Ig(t[4]??""),size:n,lead:o}}function wm(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 LH(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 DH(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...PH(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}
|
|
257
|
-
${o.actual}`:void 0,menu:()=>o?Cg(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}
|
|
258
|
-
${i.actual}`,menu:()=>Cg(i.token.name,i.actual)}))}})}function zH(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":Ig(o);return{family:l,stack:o,name:i?sl(i.uses):void 0,label:l,tipText:i?`${i.value}
|
|
259
|
-
${sl(i.uses)}: ${i.selectors.join(", ")}`:void 0,menu:()=>i?Ag(i.value):[],rows:n.filter(c=>(c.family??"initial")===o).sort((c,u)=>wm(u.value)-wm(c.value)).map(c=>{const u=wm(c.value),p=LH(c.lead,u),h=c.value.endsWith("px")?`${u}`:c.value;return{key:`${c.value}/${c.lead??""}`,sample:`${l} ${h}${p===null?"":`/${p}`}`,style:{fontFamily:o,fontSize:c.value,lineHeight:c.lead},name:sl(c.uses),label:c.value,tipText:`${c.value}${c.lead?` / ${c.lead}`:""}
|
|
260
|
-
${sl(c.uses)}: ${c.selectors.join(", ")}`,menu:()=>Ag(c.value)}})}})}function aj({groups:e,outline:t,clear:n}){const r=(i,l,c)=>t({type:"highlight-computed",props:MH(i.currentTarget.querySelector(".design-face-sample"),l?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:c}),o=yn("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 lj({kind:e,name:t,lines:n,actual:r,ratio:o,largest:i,tipText:l,menu:c,outline:u,clear:p}){const h=e==="color"&&nu(r)!==null,m=e==="length"?Number.parseFloat(r):Number.NaN,g=yn("design");return d.jsxs("div",{className:"design-cell","data-kind":e,...g.contextMenu(c),onMouseEnter:h?w=>{const y=w.currentTarget.querySelector(".design-fill"),b=y?getComputedStyle(y).backgroundColor:"";u({type:"highlight-computed",props:OH.map(_=>[_,b]),match:"any",label:t})}:void 0,onMouseLeave:h?p:void 0,...Ut(l),children:[e==="color"&&d.jsx("div",{className:"design-sample",children:h&&d.jsx("span",{className:"design-fill",style:{background:r}})}),d.jsxs("div",{className:"design-plate",children:[d.jsx("span",{className:"design-cell-name",children:t}),n.map((w,y)=>d.jsxs("span",{className:"design-cell-line",children:[d.jsx("span",{className:"design-cell-value",children:w}),y===0&&o&&d.jsx("span",{className:"design-cell-note",children:o})]},w)),Number.isFinite(m)&&i>0&&d.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(m)/i*100)}%`}})]})]})}function FH(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(`
|
|
261
|
-
`)}function BH(e,t,n){const r=[e.value,`${sl(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(`
|
|
262
|
-
`)}function cj({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 UH({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:i}=e;if(o.length===0)return null;const l=o.filter(p=>p.imports>=2),c=o.filter(p=>p.imports<2),u=p=>d.jsx(uj,{count:p.imports,name:p.name,path:p.path,onEnter:()=>t({type:"highlight-file",path:p.path,ranges:null}),onLeave:n,onOpen:()=>r(p.path),children:p.variants.length>0&&d.jsx("span",{className:"design-variants",children:p.variants.map(h=>d.jsxs("span",{className:"design-variant",children:[h.prop,": ",h.values.join(" · ")]},h.prop))})},`${p.path}:${p.name}`);return d.jsxs(ch,{title:"Components",note:`${l.length} reused of ${o.length}`,children:[!i&&d.jsx(Nf,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),d.jsx(cj,{shared:l.map(u),rest:c.map(u)})]})}function HH({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:i}=e,l=o.filter(g=>g.uses>0),c=o.filter(g=>g.uses>=2),u=o.filter(g=>g.uses<2),p=c.filter(g=>g.unwrapped).length,h=o.length?`${c.length} reused of ${o.length}`+(p?`, ${p} with no component of their name`:""):void 0,m=g=>d.jsx(WH,{cls:g,outline:t,clear:n,onOpen:r},g.name);return d.jsx(ch,{title:"Classes",note:h,children:o.length===0?d.jsx(Nf,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):l.length===0?d.jsx(Nf,{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(cj,{shared:c.map(m),rest:u.map(m)})})}function WH({cls:e,outline:t,clear:n,onOpen:r}){return d.jsx(uj,{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 uj({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:i,children:l}){const c=$s(),u=it();ut();const p=yn("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,...p.contextMenu(()=>c?bH({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 KH({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:i}){const l=it();ut();const c={sock:l},u=(h,m)=>d.jsx(Mt,{icon:"reload",label:m,onClick:()=>i(h)}),p={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?[p]:[{id:Co,label:"shell",tip:Ut("A shell in this worktree",void 0,{placement:"top"}),menu:()=>LN(e,c),trail:u(Co,"Restart the shell")},...r?[p]:[],...t.map(h=>({id:h.name,label:h.name,lead:d.jsx("span",{className:`dot ${h.status}`}),tip:Ut(DP(h.status),void 0,{placement:"top",dot:h.status,name:h.name,detail:h.command,aside:[`:${h.port}`]}),menu:()=>hw(h,e,c),trail:u(h.name,`Restart ${h.name}`)})),...n.map(h=>({id:h,label:h,lead:d.jsx("span",{className:"dot borrowed"}),tip:Ut(`${h} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const ZH=S.lazy(()=>Sg(()=>import("./XTerm-y7vQoOEu.js"),__vite__mapDeps([3,4]))),qH=[];function GH({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=ut(),i=it(),l=Kf(),c=M(z=>z.connected),u=M(z=>z.focusTerm),p=$s(),h=(p==null?void 0:p.procs)??[],m=(p==null?void 0:p.borrowed)??qH,g=(p==null?void 0:p.login)??!1,w=Rt(e,"termStream"),y=M(z=>{var X;return((X=z.termRun)==null?void 0:X.id)===e&&w===Co?z.termRun.command:null}),[b,_]=S.useState(null),T=m.includes(w);S.useEffect(()=>{w===Co||(w===Cs?g:h.some(X=>X.name===w)||m.includes(w))||o({a:"term-stream",id:e,stream:Co})},[h,m,g,w,e,o]);const x=z=>{z!==w&&(_(null),o({a:"term-stream",id:e,stream:z}))},N=S.useRef(!1),[j,$]=S.useState(0),P=z=>{z===Co&&z===w&&(N.current=!0),i==null||i.send({t:"term-restart",worktreeId:e,stream:z}),z===Cs&&z===w&&(_(null),$(X=>X+1))},R=(z,X)=>{if(z)return _(null);if(N.current){N.current=!1,$(ne=>ne+1);return}_({code:X})},A=KH({worktreeId:e,procs:h,borrowed:m,login:g,current:w,onRestart:P}),O=S.useRef(!t),D=!O.current;return S.useEffect(()=>{O.current=!1},[]),d.jsxs(Nw,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:A,current:w,onPick:x,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:zt("terminal"),children:[d.jsxs("div",{className:"term-body",children:[T&&d.jsx(Wc,{pane:!0,title:`${w} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:d.jsx(Fe,{variant:"outline",onClick:()=>i==null?void 0:i.send({t:"own-procs",worktreeId:e,names:[w]}),children:"run it here"})}),d.jsx(Mk,{pane:!0,children:d.jsx(S.Suspense,{fallback:d.jsx("div",{className:"empty",children:d.jsx("span",{className:"live-text",children:"loading terminal"})}),children:d.jsx(ZH,{worktreeId:e,stream:w,theme:l,sock:i,connected:c,focusOnMount:D,focusReq:u,onAlive:R,run:y,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${w}:${j}`)})})]}),b!==null&&!T&&d.jsx(Wc,{pane:!0,title:w===Co?"the shell exited":w===Cs?"the login did not finish":`${w} exited`,body:b.code===void 0?void 0:`exit code ${b.code}`,action:d.jsx(Fe,{variant:"outline",onClick:()=>P(w),children:"restart"})})]})}function VH(e){return e==="reserved"?"checking out a fresh worktree":e==="warming"?"copying dependencies and running setup":"starting dev servers"}const YH="preview off; it starts when the agent writes a file";function XH({worktree:e,log:t}){const n=it(),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=M(b=>b.clientId),u=qc(e,"setup"),p=u&&u.status!=="terminated"?u:null,h=oa(Uk(p??void 0)?p==null?void 0:p.since:void 0),m=!!e.worktree.parked&&o.length===0,g=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),w=p&&(p.status==="running"||p.status==="detached"),y=()=>n==null?void 0:n.send({t:"fix-preview",worktreeId:e.id,clientId:c});return d.jsxs(ps,{wide:!0,children:[o.length===0?d.jsx("div",{className:"status-line",children:p?d.jsx("span",{className:"live-text","data-tip":Ym[p.status],children:ff("setup",p,h)}):m?YH:d.jsx("span",{className:"live-text",children:VH(e.worktree.phase)})}):d.jsx("ul",{className:"boot-procs",children:o.map(b=>d.jsxs("li",{className:We("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:QH(b)}),(b.status==="crashed"||b.status==="unreachable")&&d.jsx(Fe,{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(Fe,{variant:"outline",size:"lg",onClick:g,children:"start preview"})}),w&&d.jsx("div",{className:"status-actions",children:d.jsx(Fe,{variant:"outline","data-tip":k_("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(Fe,{variant:"outline",size:"lg",onClick:y,children:"ask the agent to fix it"}),d.jsx(Fe,{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(`
|
|
263
|
-
`)})]})}function QH(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 JH(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 n1(e){if(!e)return"/";try{const t=new URL(e);return`${t.pathname}${t.search}${t.hash}`}catch{return"/"}}function eW(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 tW({active:e}){const t=ut(),n=it(),r=Cl(),o=M(c=>c.home),i=e.worktree.title,l=()=>{r!=null&&r.made&&(t({a:"new-project",v:{...fk({mode:r.made==="git"?"init":"create",name:r.name,parent:FN(r.path,o)??r.path}),phase:"unmaking",repoId:r.id}}),t({a:"move-box",from:e.worktree.id,to:kl}),n==null||n.send({t:"unmake-repo",repoId:r.id}))};return d.jsx(ps,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Mc,{active:e,greenfield:!0})}),children:d.jsx("p",{className:"form-title",children:r!=null&&r.made?d.jsx(Fe,{variant:"inline",onClick:l,...Ut("Rename or move this project"),children:i}):i})})}function nW({pending:e}){const t=ut(),n=it(),r=!!e.error,o=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},i=S.useRef(null);return S.useEffect(()=>{var l;return(l=i.current)==null?void 0:l.scrollTo({top:i.current.scrollHeight})},[e.lines.length]),d.jsxs(ps,{wide:!0,children:[d.jsxs("p",{className:"status-line",children:[r?"could not import":"importing"," ",e.name]}),d.jsxs("p",{children:["from ",d.jsx("code",{children:e.url})," into ",d.jsx("code",{children:e.parent})]}),r?d.jsx("p",{className:"import-error",children:e.error}):d.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),d.jsx("div",{className:"status-tail",ref:i,children:e.lines.length===0&&!r?d.jsx("span",{className:"live-text",children:"starting git"}):e.lines.map((l,c)=>d.jsx("div",{children:l},c))}),d.jsx("div",{className:"status-actions",children:d.jsx(Fe,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const rW=150,oW=/^[^\s@]+@[^\s@]+$/,sW=14;function iW({project:e}){var Y;const t=ut(),n=it(),r=M(q=>q.repos),o=M(q=>q.home),i=M(q=>q.folderDialog),l=M(q=>q.gitIdentity),c=M(q=>q.choosingFolder),u=M(q=>q.chosenFolder),p=M(q=>q.paths),[h,m]=S.useState({name:"",email:""}),[g,w]=S.useState(null),y=S.useRef(null),{mode:b,name:_,parent:T}=e,x=b==="clone",N=b==="init",j=e.phase==="editing",$=_.trim(),P=N||!$?null:Uc(_),R=!N&&$&&!P?zN(T,$):null,A=fg(T,o),O=R!==null&&p.query===R&&((Y=p.target)==null?void 0:Y.exists)===!0,D=!l&&!x,z=!D||h.name.trim()!==""&&oW.test(h.email.trim()),X=j?g?"the folder you chose is already a project: open it, or choose another":!N&&!$?"name the project first":P??(O?`${A} already has a folder called ${$}`:z?null:"git needs your name and email first"):null;S.useEffect(()=>{if(!R)return;const q=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:R}),rW);return()=>clearTimeout(q)},[R,n]),ft([e.phase],()=>{var q;e.phase==="editing"&&((q=y.current)==null||q.focus())}),ft([e.error],()=>{e.error&&t({a:"notice",id:kl,text:e.error})});const ne={sock:n,dispatch:t},ee=()=>{X||!j||(t({a:"new-project-set",v:{phase:"creating"}}),Qc(ne,{t:"create-repo",mode:b,parent:T.trim(),name:$,...x&&e.url?{url:e.url}:{},...D?{identity:{name:h.name.trim(),email:h.email.trim()}}:{}}))},ie=q=>{const F=r.find(re=>re.path===El(q,o));F?t({a:"activate-repo",id:F.id}):Qc(ne,{t:"register-repo",path:q})},be=q=>{const F=pw(q);t({a:"new-project-set",v:{mode:"init",parent:F.parent,name:F.name}})},C=q=>{i?(t({a:"choosing-folder",v:q}),n==null||n.send({t:"choose-folder",start:T,purpose:q})):t(q==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};ft([u==null?void 0:u.seq],()=>{var F,re;if(!c||!u)return;t({a:"choosing-folder",v:!1});const q=u.folder;if(!q){(F=y.current)==null||F.focus();return}if(c==="open"){q.kind==="project"?ie(q.path):D?be(q.path):BN(ne,q.path);return}if(w(q.kind==="project"?q.path:null),q.kind!=="project"){if(q.kind==="empty"&&!x){be(q.path);return}t({a:"new-project-set",v:{mode:x?"clone":"create",parent:q.path}}),(re=y.current)==null||re.focus()}});const Z=N?"the folder you chose becomes the project":g?null:O?`${A} already has a folder called ${$}`:P;return d.jsxs(ps,{anchor:"line",foot:d.jsx("div",{className:"composer view-foot",children:d.jsx(Mc,{active:null,project:{name:$,why:X,busy:!j,create:ee}})}),children:[x&&d.jsx("p",{className:"new-project-url",children:e.url}),d.jsxs("div",{className:"form-head",children:[N?d.jsx("p",{className:"form-title",children:_}):d.jsx(Io,{ref:y,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:_,placeholder:"Project name",disabled:!j,style:{width:`${Math.max(_.length+1,sW)}ch`},onChange:q=>t({a:"new-project-set",v:{name:q.target.value}}),onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),t({a:"focus-chat"}))}}),d.jsxs("span",{className:"new-project-where",children:[d.jsx("span",{className:"hint",children:"in"}),d.jsx("span",{className:"new-project-parent",...Ut(T),children:A}),d.jsx(Mt,{icon:"folder",label:i?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:c==="location",disabled:!j,onClick:()=>C("location")})]})]}),Z&&d.jsx("p",{className:"hint",children:Z}),g&&d.jsxs("p",{className:"hint",children:["the folder you chose is already a project:"," ",d.jsx(Fe,{variant:"inline",autoFocus:!0,onClick:()=>ie(g),children:"open it"}),", or choose another"]}),D&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"new-project-identity",children:[d.jsx(Io,{size:"md",font:"ui",rule:!0,value:h.name,placeholder:"Your name",autoComplete:"name",disabled:!j,onChange:q=>m({...h,name:q.target.value})}),d.jsx(Io,{size:"md",font:"ui",rule:!0,type:"email",value:h.email,placeholder:"Email",autoComplete:"email",disabled:!j,onChange:q=>m({...h,email:q.target.value})})]}),d.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!x&&j&&d.jsx(Fe,{tone:"quiet",className:"new-project-open",onClick:()=>C("open"),children:"or open a folder you already have"})]})}function Qa({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 aW(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(`
|
|
264
|
-
`)}function lW(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(`
|
|
265
|
-
`)}let cW=1;const ym=(e,t,n=!1)=>({id:cW++,name:e,cmd:t,shared:n}),uW=[{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 dW({repo:e,onClose:t}){const n=it(),r=Yn(),o=M(ae=>ae.clientId),i=M(ae=>ae.rows.find(G=>{var ue;return Sn(G)&&G.id===((ue=wl(ae,e.id))==null?void 0:ue.id)})??null),l=M(ae=>{var G;return((G=wl(ae,e.id))==null?void 0:G.id)??null});S.useEffect(()=>{if(!t)return;const ae=G=>G.key==="Escape"&&t();return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[t]);const[c]=S.useState(()=>Object.keys(e.config.run).length>0),[u,p]=S.useState(()=>{const ae=Object.entries(e.config.run).map(([G,ue])=>ym(G,y1(ue),VC(ue)));return ae.length>0?ae:[ym("web","")]}),[h,m]=S.useState(()=>(e.config.setup??[]).join(`
|
|
266
|
-
`)),[g,w]=S.useState(()=>(e.config.teardown??[]).join(`
|
|
267
|
-
`)),[y,b]=S.useState(()=>e.config.check??""),[_,T]=S.useState(()=>fi(e.config).land),[x,N]=S.useState(()=>fi(e.config).automerge),[j,$]=S.useState(()=>fi(e.config).merge??"default"),[P,R]=S.useState(()=>QC(e.configFile)),A=JC(e.configFile,P),O=!!e.remote&&_==="pr",D=u.length>1,z=u.some(ae=>ae.name.trim()&&ae.cmd.trim()),ne=!!i&&!t&&!c&&!z,ee=(ae,G)=>p(u.map((ue,Le)=>Le===ae?{...ue,...G}:ue)),ie=ae=>ae.split(`
|
|
268
|
-
`).map(G=>G.trim()).filter(Boolean),be=()=>ie(h),C=()=>ie(g),Z=()=>{const{check:ae,land:G,teardown:ue,...Le}=e.config,ge=e.remote?_:Sm,oe=j==="default"||ge!=="pr"&&j===_m?void 0:j,we={...ge!==Sm?{route:ge}:{},...ge==="pr"&&x?{automerge:!0}:{},...oe?{method:oe}:{}};return{...Le,setup:be(),...C().length>0?{teardown:C()}:{},...y.trim()?{check:y.trim()}:{},...Object.keys(we).length>0?{land:we}:{}}},Y=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...Z(),run:Object.fromEntries(u.filter(ae=>ae.name.trim()&&ae.cmd.trim()).map((ae,G)=>[ae.name.trim(),ae.shared&&G>0?{cmd:ae.cmd.trim(),from:"trunk"}:ae.cmd.trim()]))},kind:P}),t==null||t()},q=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...Z(),run:{}},kind:P}),t==null||t()},F=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:lW(e,A)}),re=e.services,Ee=[h,g,...u.map(ae=>ae.cmd)].some(ae=>ae.includes("TOYON_WORKTREE"))||YC(e.config),Te=re?[re.envUrl?`the database at ${re.envUrl.name} in ${re.envUrl.file}`:null,re.compose?`the stack in ${re.compose}`:null].filter(Boolean).join(" and "):"",de=()=>re&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:aW(e,A,re)})),ke=(ae,G)=>d.jsxs("div",{className:"setup-proc",children:[D&&d.jsx(Io,{size:"md",rule:!0,className:"setup-name",value:ae.name,placeholder:"name",...Ut("Process name, shown in the status bar"),onChange:ue=>ee(G,{name:ue.target.value})}),d.jsx(Io,{size:"md",rule:!0,className:"setup-cmd",value:ae.cmd,placeholder:"npm run dev",onChange:ue=>ee(G,{cmd:ue.target.value})}),D&&d.jsx(Mt,{icon:"close",label:"Remove",onClick:()=>p(u.filter((ue,Le)=>Le!==G))}),D&&G>0&&d.jsx(LT,{className:"setup-shared",checked:ae.shared,onChange:ue=>ee(G,{shared:ue.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},ae.id);return d.jsxs(ps,{children:[d.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),re&&!Ee&&d.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",Te,", migrations included."," ",d.jsx(Fe,{tone:"quiet",disabled:!i,onClick:de,children:"ask the agent to keep them apart"})]}),d.jsx(Qa,{label:"install",hint:"once per new worktree; one command per line",children:d.jsx(Zc,{size:"md",rule:!0,rows:Math.max(1,h.split(`
|
|
269
|
-
`).length),value:h,placeholder:"bun install",onChange:ae=>m(ae.target.value)})}),d.jsx(Qa,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:d.jsx(Zc,{size:"md",rule:!0,rows:Math.max(1,g.split(`
|
|
270
|
-
`).length),value:g,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:ae=>w(ae.target.value)})}),d.jsx(Qa,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:d.jsx(Io,{size:"md",rule:!0,value:y,placeholder:"bun run check",onChange:ae=>b(ae.target.value)})}),e.remote&&d.jsx(Qa,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:d.jsxs("div",{className:"setup-land",children:[d.jsx(di,{value:_,options:hA.map(ae=>({id:ae.id,label:ae.name,description:ae.description})),onChange:T,hint:"where the work goes",placeholder:"where work lands"}),O&&d.jsx(di,{value:x?"github":"you",options:mA.map(ae=>({id:ae.id,label:ae.name,description:ae.description})),onChange:ae=>N(ae==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),d.jsx(Qa,{label:"merge",hint:O?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:d.jsx(di,{value:j==="default"&&!O?_m:j,options:[...O?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...pA.map(ae=>({id:ae.id,label:ae.name,description:ae.description}))],onChange:$,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),d.jsx(Qa,{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(Fe,{mono:!0,tone:"quiet",...Ut(`open ${e.guess} in the editor pane`),onClick:()=>ia(r,n,l,e.guess??"",1),children:e.guess})]})]}),children:u[0]&&ke(u[0],0)}),u.slice(1).map((ae,G)=>d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsx("div",{className:"form-control",children:ke(ae,G+1)})]},ae.id)),d.jsxs("div",{className:"form-row",children:[d.jsx("span",{className:"form-label"}),d.jsxs(Fe,{tone:"quiet",onClick:()=>p([...u,ym("","")]),children:[d.jsx(Tt,{name:"plus",className:"icon-inline"})," another process"]})]}),d.jsxs("div",{className:"form-knobs",children:[d.jsx(di,{value:P,options:uW,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:A}),t&&d.jsx(Fe,{onClick:t,children:"cancel"}),(!c||t)&&d.jsx(Fe,{...Ut("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:q,children:"no dev server"}),ne&&i?d.jsx(Fe,{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:F,children:"let the agent work it out"}):d.jsxs(Fe,{variant:"outline",size:"lg",disabled:!z,...t?Ut("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:Y,children:[t?"save + restart":"start"," ",d.jsx(Tt,{name:"forward",className:"icon-inline"})]})]})]})}function fW(e){return`${Math.round(e.w)} × ${Math.round(e.h)}`}function hW(e){return e.w>0&&e.h>0}function pW(e,t,n){S.useEffect(()=>{if(!e||!t){n(null);return}const r=new ResizeObserver(o=>{var c;const i=(c=o[o.length-1])==null?void 0:c.contentRect;if(!i)return;const l={w:i.width,h:i.height};n(hW(l)?fW(l):null)});return r.observe(e),()=>{r.disconnect(),n(null)}},[e,t,n])}const mW=1500,gW={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class kW{constructor(t,n,r=gW){$t(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=N0(r));const i=Df(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)},mW)}title(t,n){const r=this.frame(t);r.title=N0(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 wW=Jg(),yW=2*6e4;function r1(e){e==null||e.setAttribute("src",e.src)}const vW=8e3;function bW(e,t){try{const n=new URL(e,t);return n.origin===new URL(t).origin?n.href:null}catch{return null}}function xW({onRoot:e}){const t=S.useRef(null),n=S.useCallback(se=>{t.current=se,e(se)},[e]),r=ut(),o=Yn(),i=it(),l=S.useRef(i);l.current=i;const[c]=S.useState(()=>new kW((se,Ne,at)=>{var gt,Wt;(gt=l.current)==null||gt.send({t:"visit",worktreeId:se,path:Ne,title:at}),PE((Wt=o.getState().local[se])==null?void 0:Wt.pages)&&an.post(se,{type:"links"})},(se,Ne,at)=>{var gt;return(gt=l.current)==null?void 0:gt.send({t:"page-title",worktreeId:se,path:Ne,title:at})}));S.useEffect(()=>()=>c.dispose(),[c]);const u=pS(),p=jl(),h=$s(),m=M(se=>se.connected),g=M(se=>se.heard),w=M(se=>se.connectFailure),y=M(se=>se.remote),{host:b}=Kr(),_=ao(),T=es(),x=M(se=>se.editor),N=gS(),j=a4(),$=M(se=>se.notesPage),P=iu(),R=M(se=>se.layout.term)&&!P,A=M(se=>se.focusTerm),O=S.useRef(!1),D=S.useRef(A),z=!O.current||A!==D.current;S.useEffect(()=>{O.current=R&&!!p,D.current=A});const X=au(),ne=M(se=>se.layout.design)&&!P&&!X,ee=M(se=>se.reloadReq),ie=Kf(),be=S.useRef(ie);be.current=ie;const C=M(se=>se.zen),Z=M(se=>{var Ne;return((Ne=se.dragFiles)==null?void 0:Ne.at)==="centre"}),Y=S.useRef(C);Y.current=C;const q=Rt(p,"log"),F=M(se=>se.incompatible),re=c4(),Ee=M(se=>{var Ne;return((Ne=se.overlay)==null?void 0:Ne.kind)==="setup"?se.repos.find(at=>at.id===se.overlay.repoId)??null:null}),Te=(h==null?void 0:h.worktree.empty)===!0,de=$o(h==null?void 0:h.agent),ke=re&&!Te&&!de?re:null,ae=ke??Ee,G=M(se=>se.pending.find(Ne=>Ne.id===se.activeImportId)??null),[ue,Le]=S.useState([]),ge=S.useMemo(()=>ue.map(se=>se.id),[ue]),oe=S.useRef(new Map),we=S.useRef(new Map),[Ce,Se]=S.useState([]),_e=S.useRef(new Set),Be=S.useRef(new Set),wt=S.useRef(se=>r1(oe.current.get(se)));S.useEffect(()=>{an.post=(se,Ne)=>{var at,gt;if(Ne.type==="reload"&&_e.current.has(se))return wt.current(se);(gt=(at=oe.current.get(se))==null?void 0:at.contentWindow)==null||gt.postMessage({__toyon:!0,...Ne},we.current.get(se)??"*")},an.broadcast=se=>{var Ne;for(const[at,gt]of oe.current)(Ne=gt.contentWindow)==null||Ne.postMessage({__toyon:!0,...se},we.current.get(at)??"*")}},[]),S.useEffect(()=>{let se=null;const Ne=Wt=>{Wt.target instanceof HTMLElement&&Wt.target.tagName!=="IFRAME"&&(se=Wt.target)},at=Wt=>{Wt.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(se=null)},0)},gt=Wt=>{var gn,kn,tr,dn,fn;if((gn=Wt.data)!=null&&gn.__toyon)for(const[Nt,Pr]of oe.current){if(Pr.contentWindow!==Wt.source)continue;if(Wt.origin!==we.current.get(Nt))return;const pt=uE(Wt.data);if(!pt)return;switch(pt.type){case"key":window.dispatchEvent(new KeyboardEvent(pt.up?"keyup":"keydown",{key:pt.key,code:pt.code,metaKey:pt.meta,ctrlKey:!!pt.ctrl,shiftKey:!!pt.shift,altKey:!!pt.alt}));break;case"hmr":r({a:"hmr",id:Nt}),(kn=l.current)==null||kn.send({t:"page-loaded",worktreeId:Nt});break;case"loaded":_e.current.delete(Nt),Be.current.add(Nt),Se(In=>In.includes(Nt)?In:[...In,Nt]),an.post(Nt,rj(be.current)),an.post(Nt,{type:"zen",on:Y.current}),r({a:"hmr",id:Nt}),r({a:"page",id:Nt,url:pt.url,title:pt.title}),(tr=l.current)==null||tr.send({t:"page-loaded",worktreeId:Nt}),c.note(Nt,pt.url,pt.title);break;case"navigated":r({a:"page",id:Nt,url:pt.url,...pt.title!==void 0?{title:pt.title}:{}}),c.note(Nt,pt.url,pt.title);break;case"title":r({a:"page",id:Nt,title:pt.title}),c.title(Nt,pt.title);break;case"links":r({a:"links",id:Nt,links:pt.links});break;case"page-error":{const In=MP(pt);In&&((dn=l.current)==null||dn.send({t:"page-error",worktreeId:Nt,message:In}));break}case"picked":{const{type:In,verb:je,site:Ve,...rt}=pt,et=Ve==="call"?{file:rt.callFile,line:rt.callLine}:{file:rt.file,line:rt.line};if(je==="code"){r({a:"set-picking",v:!1});const cn=(fn=un(o.getState(),Nt))==null?void 0:fn.worktree;et.file?ia(o,i,Nt,AE(et.file,cn==null?void 0:cn.path),et.line??1):i==null||i.send({t:"find-element",worktreeId:Nt,seq:Vo(),element:rt.element})}else H4(o,Nt,rt);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":pt.over?Rk(o,o.getState().activeId?{at:"centre"}:null):MS(o);break;case"drop-files":US(o,i,o.getState().activeId?{at:"centre"}:null,pD(pt.files));break;case"focus":pt.gesture?se=null:document.activeElement===Pr&&(se!=null&&se.isConnected)&&se!==document.body&&se.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${pt.path}: ${pt.fileMatched} elements from this file, ${pt.withSource} elements with source info on page, ranges=${JSON.stringify(pt.ranges)}`);break}return}};return window.addEventListener("message",gt),document.addEventListener("focusin",Ne),document.addEventListener("focusout",at),()=>{window.removeEventListener("message",gt),document.removeEventListener("focusin",Ne),document.removeEventListener("focusout",at)}},[r,o,i,c]),S.useEffect(()=>{an.broadcast({type:"zen",on:C})},[C]);const on=S.useRef(new Map);ft([ee==null?void 0:ee.id,ee==null?void 0:ee.n],()=>{if(!ee)return;const{id:se}=ee;clearTimeout(on.current.get(se)),on.current.set(se,setTimeout(()=>{on.current.delete(se),an.post(se,{type:"reload"})},1200))});const Et=Ek(),Vt=Et&&!Sn(Et)?Et:null,Ft=ha(),Ht=!!h&&h.procs.some(se=>se.status==="running"),Me=Nk(),St=Me!==null&&Me===p&&Ht;S.useEffect(()=>{var se;if(Me&&St&&!ge.includes(Me)){const Ne=n1((se=o.getState().local[Me])==null?void 0:se.page.url);Le(at=>[...at,{id:Me,path:Ne}])}},[Me,St,ge,o]);const sn=u.filter(se=>Sn(se)&&se.procs.some(Ne=>Ne.status==="asleep")).map(se=>se.id).join(" ");S.useEffect(()=>{const se=new Set(sn.split(" ").filter(Boolean));ge.some(Ne=>se.has(Ne))&&Le(Ne=>Ne.filter(at=>!se.has(at.id)))},[sn,ge]);const ln=ge.join(" ");S.useEffect(()=>{const se=ln.split(" ").filter(Ne=>Ne&&Ne!==Me).map(Ne=>setTimeout(()=>Le(at=>at.filter(gt=>gt.id!==Ne)),yW));return()=>{for(const Ne of se)clearTimeout(Ne)}},[ln,Me]),S.useEffect(()=>{Se(se=>se.every(Ne=>ge.includes(Ne))?se:se.filter(Ne=>ge.includes(Ne)))},[ge]);const lt=S.useMemo(()=>u.filter(Sn).flatMap(se=>{const Ne=ue.find(gt=>gt.id===se.id);if(!Ne)return[];const at=CE(se.worktree.id,se.worktree.proxyPort,y,b);return[{id:se.worktree.id,port:se.worktree.proxyPort,title:se.worktree.title,url:bW(Ne.path,at)??at}]}),[u,ue,y,b]),jt=qm(_,y),Kt=KS(_,lt,jt);wt.current=se=>{var at;const Ne=n1((at=o.getState().local[se])==null?void 0:at.page.url);if(ue.some(gt=>gt.id===se&>.path!==Ne)){Le(gt=>gt.map(Wt=>Wt.id===se?{...Wt,path:Ne}:Wt));return}jt?Kt.renew(se):r1(oe.current.get(se))};const xn=lt.filter(se=>{var Ne;return(Ne=u.find(at=>at.id===se.id))==null?void 0:Ne.procs.some(at=>at.status==="running")}).map(se=>se.id).join(" ");ft([xn],()=>{for(const se of xn.split(" "))_e.current.has(se)&&wt.current(se)});const Dt=M(se=>se.carryTo),[jn,Qt]=S.useState(null),[V,pe]=S.useState(Me),Ye=S.useRef(null);V!==Me&&(pe(Me),Qt(JH({leaving:Ye.current,arriving:Me,carryTo:Dt,repoOf:se=>{var Ne;return((Ne=u.find(at=>at.id===se))==null?void 0:Ne.repoId)??null}}))),S.useEffect(()=>{if(!jn)return;const se=setTimeout(()=>Qt(null),vW);return()=>clearTimeout(se)},[jn]);const nt=Me!==null&&Ce.includes(Me),yt=eW({previewId:Me,painted:nt,ready:St,carry:jn,mounted:ge}),Jt=yt!==null&&yt!==Me;S.useEffect(()=>{Ye.current=yt});const ye=yt!==null&&!ae&&!G&&!$&&!P&&!X,[Ae,Yt]=S.useState(null),B=S.useCallback(se=>r({a:"preview-size",text:se}),[r]);pW(Ae,ye,B);const[me,De]=go(Ge.editorHeight,0,se=>{const Ne=Number(se);return Number.isFinite(Ne)&&Ne>=120?Ne:0}),[Xe,Pt]=go(Ge.designHeight,0,se=>{const Ne=Number(se);return Number.isFinite(Ne)&&Ne>0?Ne:0}),[_t,He]=go(Ge.designFull,!1,se=>se===null?void 0:se==="1"),[ze,qe]=go(Ge.editorFull,!1,se=>se===null?void 0:se==="1"),[ht,Ct]=go(Ge.termHeight,240,se=>{const Ne=Number(se);return Number.isFinite(Ne)&&Ne>=140?Ne:void 0}),Bt=M(se=>se.termTall);ft([Bt],()=>{const se=t.current;Bt&&se&&Ct(Math.max(ht,Math.round(se.clientHeight/2)))});const qt=se=>(Ne,at)=>{const gt=at.parentElement,Wt=t.current;if(!gt||!Wt)return null;let gn=0;for(const tr of Array.from(Wt.querySelectorAll(":scope > .pane")))tr!==gt&&!tr.classList.contains("full")&&(gn+=tr.offsetHeight);const kn=Math.max(Wt.clientHeight-gn-80,se);return Math.min(Math.max(gt.getBoundingClientRect().bottom-Ne.clientY,se),kn)},vn=dl(qt(120),se=>De(Math.round(se))),On=dl(qt(160),se=>Pt(Math.round(se))),Cn=dl(qt(140),se=>Ct(Math.round(se))),Xn=M(se=>{var Ne,at;return h&&kr(h.worktree)?((at=(Ne=se.rows.find(gt=>{var Wt;return gt.repoId===h.worktree.repoId&&((Wt=gt.worktree)==null?void 0:Wt.kind)==="worktree"}))==null?void 0:Ne.worktree)==null?void 0:at.title)??null:null}),Kn=nz({connected:m,heard:g,connectFailure:w,hasToken:_.serving?wW:!0,projectChord:zt("project"),title:(h==null?void 0:h.worktree.title)??null,machine:_.serving?null:T.displayName(_.origin),needsSetup:!!re,busy:de,treeEmpty:Te,landsFrom:Xn});return d.jsxs("div",{className:"center-root",ref:n,children:[d.jsx("div",{className:We("center-area",Z&&"drop-over"),style:{display:!(C&&!X)&&!Ft&&!$&&(x&&ze||ne&&_t)?"none":void 0},children:d.jsxs("div",{className:"frames-wrap",ref:Yt,children:[lt.map(se=>d.jsx("iframe",{ref:Ne=>{Ne?(oe.current.set(se.id,Ne),we.current.set(se.id,new URL(se.url).origin)):(oe.current.delete(se.id),we.current.delete(se.id),_e.current.delete(se.id),Be.current.delete(se.id))},onLoad:()=>{Be.current.delete(se.id)?_e.current.delete(se.id):_e.current.add(se.id)},src:Kt.urlOf(se.id)??void 0,title:se.title,style:{display:ye&&se.id===yt?"block":"none"}},se.id)),j?d.jsx(iW,{project:j}):$?d.jsx(vH,{}):d.jsxs(d.Fragment,{children:[G&&d.jsx(nW,{pending:G},G.id),N&&h&&!G&&d.jsx(tW,{active:h},h.worktree.id),ae&&!G&&!N&&d.jsx(dW,{repo:ae,onClose:ke?void 0:()=>r({a:"close"})},`${ae.id}:${JSON.stringify(ae.config)}`),Vt&&!ae&&!G&&!Ft&&d.jsx(Pc,{placement:"centre",found:Vt},Vt.id),Ft&&!ae&&!G&&d.jsx(Pc,{placement:"centre",archived:Ft},Ft.id),!Ht&&!Vt&&!Ft&&!ae&&!G&&!N&&F&&d.jsx(JS,{foreign:_.serving?void 0:T.displayName(_.origin)}),!Ht&&!Vt&&!Ft&&!ae&&!G&&!N&&!F&&(Kn!==null?d.jsx(ps,{wide:!0,children:d.jsx("p",{className:We("status-line",Kn.live&&"live-text"),children:Kn.text})}):X?d.jsx(Pc,{placement:"centre"}):Jt?null:h&&d.jsx(XH,{worktree:h,log:q}))]})]})}),x&&d.jsx(FT,{editor:x,height:ze?"100%":me>0?me:"45%",full:ze,onToggleFull:()=>qe(!ze),onDragStart:vn}),ne&&p&&!Ft&&!$&&d.jsx(EH,{worktreeId:p,height:_t?"100%":Xe>0?Xe:"55%",full:_t,onToggleFull:()=>He(!_t),onDragStart:On},`design:${p}`),R&&p&&!Ft&&!$&&d.jsx(GH,{worktreeId:p,opened:z,height:ht,onDragStart:Cn},`term:${p}`),d.jsx(qT,{})]})}function EW({width:e}){const t=M(r=>r.layout.chat),n=iu();return d.jsx(Pc,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function SW(e,t){const n=[];return e&&(n.push(xS(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>nn(e)})),zn([n,[{id:"reload",label:"reload preview",key:zt("reload"),onClick:t.reload}]])}const _W=520,vm=8;function NW({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,i=Math.max(0,Math.min(_W,Math.floor(e*.4),o-2*vm)),l=t.left+(o-i)/2,c=n+vm,u=r-vm-i,p=Math.max(Math.min(l,u),c);return{left:Math.round(p),width:i}}function TW({center:e}){const t=FL(),n=uS(e),r=S.useRef(null);XL(r);const o=ID(),[i,l]=Q0(),[c,u]=Q0(),p=NW({winW:t,centre:n,leadRight:l.right,toolsLeft:u.left}),h=ut(),m=it(),g=Yn(),w=yn("bar"),y=$s(),b=au(),_=M(ne=>ne.zen)&&!b,T=M(ne=>ne.layout.changes),x=M(ne=>ne.layout.chat),N=iu(),j=M(ne=>ne.layout.design),$=M(ne=>{var ee;return((ee=ne.overlay)==null?void 0:ee.kind)==="keys"}),P=sT(),R=(y==null?void 0:y.worktree.id)??null,A=M(ne=>ne.archivedPage!==null||ne.notesPage),O=!!y&&mk(y)&&!A,D=M(ne=>ne.chatSide)==="left",z=!N&&d.jsx(Mt,{icon:"branch",label:"Changes panel",hint:zt("changes"),tone:"chrome",on:T,onClick:()=>h({a:"toggle-changes"})}),X=!N&&!b&&d.jsx(Mt,{icon:"chat",label:"Chat panel",hint:zt("composer"),tone:"chrome",on:x,onClick:()=>h({a:"toggle-chat"})});return d.jsxs("div",{className:"top-bar",ref:r,"data-float-up":o||void 0,children:[_&&d.jsx("span",{className:"bar-zen-title",children:(y==null?void 0:y.worktree.title)??"Toyon"}),d.jsxs("span",{className:"bar-lead",ref:i,children:[D?X:z,d.jsx(jW,{}),P&&d.jsx(hu,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void P.prompt(),children:"install app"}),d.jsx(AW,{}),d.jsx(IW,{}),d.jsx($W,{})]}),!b&&d.jsx(CW,{worktreeId:R,repoId:(y==null?void 0:y.repoId)??null,ready:O,left:p.left,width:p.width}),d.jsx("span",{className:"bar-grow"}),d.jsxs("span",{className:"bar-tools",ref:c,children:[d.jsx(RW,{}),d.jsx(Mt,{icon:"settings",label:"Settings & shortcuts",hint:zt("keys"),tone:"chrome",on:$,"aria-controls":"keys-help","aria-expanded":$,onClick:()=>h({a:"toggle",overlay:{kind:"keys"}}),...w.contextMenu(()=>UN(g.getState(),{sock:m,dispatch:h}))}),!N&&!b&&d.jsx(Mt,{icon:"palette",label:"Design system",hint:zt("design"),tone:"chrome",on:j,onClick:()=>h({a:"toggle-design"})}),D?z:X,!b&&d.jsx(Mt,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:zt("zen"),tone:"chrome",on:_,onClick:()=>h({a:"toggle-zen"})})]})]})}function jW(){const e=ut(),t=it(),n=Cl(),r=M(h=>h.activeRepoId),o=M(h=>h.repos),i=yn("bar"),l=()=>zn([[{id:"project",label:o.length>1?"switch project…":"open project…",key:zt("project"),onClick:()=>e({a:"open",overlay:{kind:"projects",form:"pill"}})},{id:"project-disk",label:"find a project on disk…",onClick:()=>e({a:"open",overlay:{kind:"projects",form:"disk"}})}],n?ah(n,r,{sock:t,dispatch:e}):[]]),c=M(h=>{var m;return((m=h.overlay)==null?void 0:m.kind)==="projects"&&h.overlay.form==="pill"}),u=M(h=>h.heard),p=M(h=>h.newProject!==null);return d.jsxs("span",{className:"bar-project",children:[d.jsx(Fe,{tone:"chrome",className:"bar-pill",on:c,...Ut(o.length>1?"Switch project":"Open a project",zt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...i.contextMenu(l),children:d.jsx("span",{className:"bar-project-name",children:p?"new project":(n==null?void 0:n.name)??(u?"open project":"")})}),c&&d.jsx(Tw,{form:"pill"})]})}function CW({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const i=Rt(e,"page").url,l=ut(),c=M(w=>{var y;return((y=w.overlay)==null?void 0:y.kind)==="routes"}),u=M(w=>w.previewSize);ft([e,n],()=>{c&&l({a:"close"})});const h=yn("bar").contextMenu(()=>n?SW(i,{reload:()=>e&&an.post(e,{type:"reload"})}):[]),m=M(w=>w.picking),g=Nk();return d.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[d.jsx(Mt,{icon:"back",label:"Back",hint:zt("back"),disabled:!n,onClick:()=>e&&an.post(e,{type:"back"}),...h}),d.jsx(Mt,{icon:"forward",label:"Forward",hint:zt("forward"),disabled:!n,onClick:()=>e&&an.post(e,{type:"forward"}),...h}),d.jsx(Mt,{icon:"reload",label:"Reload preview",hint:zt("reload"),disabled:!n,onClick:()=>e&&an.post(e,{type:"reload"}),...h}),d.jsxs("span",{className:"bar-route",children:[n&&e&&t?d.jsx(hB,{worktreeId:e,repoId:t,url:i,open:c},e):d.jsx(Io,{className:"bar-path",value:"",readOnly:!0,disabled:!0}),u&&d.jsx("span",{className:"bar-size",children:u})]}),d.jsx(Mt,{icon:"inspect",label:"Pick an element to open its code",hint:zt("inspect"),also:{text:"Add an element to chat",key:zt("pick")},on:m==="code",disabled:!n||!g,onClick:()=>g&&Kc(g,m,l,"code")})]})}function hu({icon:e,busy:t,children:n,...r}){return d.jsxs(Fe,{disabled:t,...r,children:[!t&&d.jsx(Tt,{name:e,className:"icon-inline"}),d.jsx("span",{className:We(t&&"live-text"),children:n})]})}function AW(){const e=M(u=>u.self),t=M(u=>u.rebuilt),n=M(u=>u.repos),r=it(),o=M(u=>{var p;return((p=u.update)==null?void 0:p.restarting)!=null}),i=BT(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(hu,{icon:"reload",busy:i.busy,onClick:c,...Ut(i.text,void 0,{detail:i.detail}),children:l})}function IW(){const e=M(o=>o.update),t=M(o=>o.managed.updates),n=it(),r=GD(e);return!r||!t?null:d.jsx(hu,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...Ut(r.text),children:r.word})}function $W(){const e=ut(),t=M(aL),n=M(l=>l.ranBefore),r=M(l=>l.newProject!==null);if(!t||!n||r)return null;const{word:o,text:i}=yH(n,t);return d.jsx(hu,{icon:"book",onClick:()=>e({a:"open-release-notes"}),...Ut(i),children:o})}function RW(){const e=ut(),t=M(yL),n=M(i=>i.letIn),r=M(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(Mt,{icon:"devices",label:"Your devices",tone:"chrome",on:r,"aria-expanded":r,onClick:o}):d.jsx(hu,{icon:"devices","aria-expanded":r,onClick:o,...Ut("Open this machine on your phone, and let it in"),children:"open on phone"})}function OW(e,t,n){return t==="left"?n-e.left:e.right-n}const MW="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function PW(){const e=Yn(),t=ut(),n=it(),r=iu(),o=Si(),i=au(),l=M(Y=>Y.zen)&&!i,c=ha(),u=M(Y=>Y.notesPage),p=!!_k()||!!c||u,h=M(Y=>Y.layout.changes)&&!r,m=M(Y=>Y.layout.chat)&&!r&&!i&&!p,g=M(Y=>Y.chatSide),w=M(Y=>Y.railOpen),[y,b]=go(Ge.changesWidth,220,Y=>Y?jd(Number(Y),220):void 0),[_,T]=go(Ge.chatWidth,380,Y=>Y?jd(Number(Y),380):void 0),[x,N]=go(Ge.railWidth,280,Y=>Y?jd(Number(Y),280):void 0),j=(Y,q,F)=>{const re=q.classList.contains("left")?"left":"right",Ee=re==="left"?q.previousElementSibling:q.nextElementSibling;return Ee?jd(OW(Ee.getBoundingClientRect(),re,Y.clientX),F):null},$=dl((Y,q)=>j(Y,q,220),b),P=dl((Y,q)=>j(Y,q,380),T),R=dl((Y,q)=>j(Y,q,280),N),[A,O]=S.useState(null),z=yn("app").contextMenu(()=>PN(e.getState(),{sock:n,dispatch:t})),X=d.jsx(v_,{width:y}),ne=!i&&!p&&d.jsx(EW,{width:_}),ee=!r&&d.jsx(YT,{width:x}),ie=Y=>!r&&w&&d.jsx("div",{className:`dock-resize ${Y}`,onPointerDown:R}),be=g==="left",C=be?{dock:ne,open:m,drag:P}:{dock:X,open:h,drag:$},Z=be?{dock:X,open:h,drag:$}:{dock:ne,open:m,drag:P};return d.jsxs("div",{className:We("app",l&&"zen"),"data-chat-side":g,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:Y=>{Y.defaultPrevented||Y.target instanceof Element&&Y.target.closest(MW)||z.onContextMenu(Y)},children:[d.jsx(qS,{}),d.jsx(XS,{}),d.jsx(TW,{center:A}),d.jsxs("div",{className:"docks",children:[be&&ee,be&&ie("left"),C.dock,C.open&&d.jsx("div",{className:"dock-resize left",onPointerDown:C.drag}),d.jsx(xW,{onRoot:O}),Z.open&&d.jsx("div",{className:"dock-resize right",onPointerDown:Z.drag}),Z.dock,!be&&ie("right"),!be&&ee]})]})}function LW(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 DW=new Set(["design","chats"]),zW=new Set(["reload","back","forward"]),FW=new Set(["project","commands","keys","zen"]);function BW(){const e=Yn(),t=it();S.useEffect(()=>{const n=Q7(h=>e.dispatch({a:"rail-peek",on:h})),r=n.end,o=h=>{e.getState().railOpen||n.press(h)},i=h=>n.keyup(h.key),l=h=>n.mods(h),c=()=>{var w,y;const h=e.getState(),g=((y=(w=document.activeElement)==null?void 0:w.closest("[data-pane]"))==null?void 0:y.dataset.pane)??(h.layout.term?"terminal":h.editor?"editor":h.layout.design?"design":null);g==="terminal"?e.dispatch({a:"toggle-terminal"}):g==="editor"?e.dispatch({a:"close-editor"}):g==="design"&&e.dispatch({a:"toggle-design"})},u=h=>{h.key!=="Escape"||!e.getState().choosingFolder||(h.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},p=h=>{var _,T,x,N;l(h),LC(h)&&!h.defaultPrevented&&h.preventDefault();const m=e.getState(),{dispatch:g}=e,w=j=>{const $=document.activeElement,P=!$||$===document.body||!!$.closest(".rail, .chat-input");g({a:"activate",id:j}),P&&g({a:"walked"})},y=k1(h,{guest:!!((_=document.activeElement)!=null&&_.closest(".xterm"))});if(!(m.zen&&!Ao(m)&&!m.overlay&&!m.picking&&!(y&&PC.has(y.id))||(y==null?void 0:y.id)==="close"&&!lk()||(T=document.activeElement)!=null&&T.closest(".monaco-editor")&&y&&DW.has(y.id))&&!(y&&UC(y.id,document.activeElement))&&!(y&&zW.has(y.id)&&!(xc(m)&&df(m)))){if(y){const j=h.defaultPrevented;if(h.preventDefault(),m.newProject&&!FW.has(y.id))return;switch(y.id){case"worktree":{const $=zC(y.digit,m.visible.length),P=$===null?void 0:m.visible[$];P&&w(P.id);break}case"wt-prev":case"wt-next":{const $=LW(m.visible,m.visibleDiscovered,m.activeId,y.id==="wt-next"?1:-1);$&&w($.activate),o(h);break}case"wt-unseen-prev":case"wt-unseen-next":{const $=fw(m.visible,m.activeId,y.id==="wt-unseen-next"?1:-1);$&&w($.activate),o(h);break}case"mark-unread":m.activeId&&!m.draft&&m.visible.some($=>$.id===m.activeId)&&o_(t,g,m.activeId);break;case"wt-archive":{if(h.repeat||j)break;const $=m.draft||m.archivedPage?void 0:m.visible.find(P=>P.id===m.activeId);$&&Pk(t,g).archive($);break}case"new":g({a:"open-draft"});break;case"project":g({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((x=m.overlay)==null?void 0:x.kind)==="quick-open"?g({a:"close"}):m.activeId&&g({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((N=m.overlay)==null?void 0:N.kind)==="routes"?g({a:"close"}):df(m)&&g({a:"open",overlay:{kind:"routes"}});break;case"reload":case"back":case"forward":{const $=xc(m);$&&an.post($,{type:y.id});break}case"pick":case"inspect":{const $=xc(m);$&&Kc($,m.picking,g,y.id==="pick"?"chat":"code");break}case"search":m.activeId&&g({a:"toggle",overlay:{kind:"search"}});break;case"refs":m.activeRepoId&&g({a:"toggle",overlay:{kind:"refs"}});break;case"chats":m.activeRepoId&&g({a:"toggle",overlay:{kind:"chats"}});break;case"commands":g({a:"toggle",overlay:{kind:"commands"}});break;case"zen":g({a:"toggle-zen"});break;case"close":!(m.zen&&!Ao(m))&&!m.overlay&&c();break;case"changes":g(m.layout.changes&&(yl(m)==="changes"||Oo(m)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":g(m.layout.changes&&yl(m)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(Hf(m))break;g(m.layout.changes?{a:"focus-changes",tab:iL(m,y.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":g(HE(m));break;case"rail":g(m.railOpen?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":g({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":g(m.layout.term?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":g({a:"toggle-design"});break;case"term-tab":{const $=m.rows.find(O=>O.id===m.activeId);if(!$)break;const P=Ro(m,m.activeId).termStream;if($.login&&P===Cs)break;const R=[Co,...$.login?[Cs]:[],...$.procs.map(O=>O.name)],A=R.indexOf(P);g({a:"term-stream",id:$.id,stream:R[(A+1)%R.length]??Co});break}}}else if(h.key==="Escape")if(m.newProject)m.newProject.phase==="editing"&&g({a:"close-new-project"});else if(m.picking){const j=xc(m);j&&an.post(j,{type:"pick-cancel"}),g({a:"set-picking",v:!1})}else m.notesPage?g({a:"close-release-notes"}):m.archivedPage?g({a:"close-archived"}):m.activeImportId?g({a:"watch-import",id:null}):c()}};return window.addEventListener("keydown",u,!0),window.addEventListener("keydown",p),window.addEventListener("keyup",i),window.addEventListener("pointermove",l),window.addEventListener("pointerdown",l),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",u,!0),window.removeEventListener("keydown",p),window.removeEventListener("keyup",i),window.removeEventListener("pointermove",l),window.removeEventListener("pointerdown",l),window.removeEventListener("blur",r),r()}},[e,t]),S.useEffect(()=>{const n=r=>{if(r.key!=="Alt"&&r.key!=="Shift")return;const o=e.getState();o.picking&&o.activeId&&an.post(o.activeId,{type:"pick-mods",alt:r.altKey,shift:r.shiftKey})};return window.addEventListener("keydown",n),window.addEventListener("keyup",n),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",n)}},[e])}const UW=3,HW=2e3,WW=200,KW=5e3;function ZW(){const e=Yn(),t=ut(),n=it(),{storage:r}=ao(),o=jl(),i=M(de=>de.activeRepoId),l=$s(),c=Ek(),u=M(de=>de.connected),p=M(de=>de.daylight),h=M(de=>{var ke;return((ke=de.daylight)==null?void 0:ke.until)??0}),m=ha(),g=M(de=>de.notesPage),w=M(de=>de.version),y=M(de=>de.railOpen),b=M(de=>de.chatSide),_=M(de=>de.layouts),T=M(de=>de.lastActive),x=M(de=>de.discoveredOpen),N=M(de=>de.archivedOpen),j=M(de=>de.committedShut),$=M(de=>de.turnOpen),P=M(de=>de.treeOpen),R=Kf(),A=M(de=>de.previewTheme!==null),O=M(de=>de.openUrl),D=pS();S.useEffect(()=>bl.install(window),[]);const z=S.useRef([]);S.useEffect(()=>{if(!n||!u||!o)return;const de=[o,...z.current.filter(ke=>ke!==o)];for(const ke of de.splice(UW))n.send({t:"unsubscribe",worktreeId:ke});z.current.includes(o)||n.send({t:"subscribe",worktreeId:o}),z.current=de},[o,u,n]),S.useEffect(()=>{if(!(!n||!u))for(const de of z.current)n.send({t:"subscribe",worktreeId:de})},[u,n]);const X=S.useRef(void 0);S.useEffect(()=>{if(!n||!u)return;let de;const ke=()=>{const ue=document.visibilityState==="visible"?o:null;n.send({t:"view",worktreeId:ue}),X.current=ue},ae=()=>{clearTimeout(de),de=setTimeout(ke,WW)};X.current===void 0||X.current===o||document.visibilityState!=="visible"?ke():ae();const G=()=>document.visibilityState==="visible"?ae():ke();return document.addEventListener("visibilitychange",G),()=>{clearTimeout(de),document.removeEventListener("visibilitychange",G)}},[o,u,n]);const ne=(m==null?void 0:m.id)??null;S.useEffect(()=>{if(!(!n||!u||!ne))return n.send({t:"subscribe",worktreeId:ne}),()=>n.send({t:"unsubscribe",worktreeId:ne})},[ne,u,n]),S.useEffect(()=>{const de=new Set(D.map(ae=>ae.id)),ke=z.current.filter(ae=>!de.has(ae));if(ke.length!==0&&(z.current=z.current.filter(ae=>de.has(ae)),!(!n||!u)))for(const ae of ke)n.send({t:"unsubscribe",worktreeId:ae})},[D,u,n]);const ee=g?"Release notes":(m==null?void 0:m.title)??(c==null?void 0:c.name)??null;S.useEffect(()=>{document.title=ee?`${ee} · Toyon`:"Toyon"},[ee]);const ie=!!(l!=null&&l.unseen),be=M(de=>de.unreadHold!==null&&de.unreadHold===de.activeId);S.useEffect(()=>{if(!n||!o||!ie||be)return;let de;const ke=()=>document.visibilityState==="visible"&&document.hasFocus(),ae=()=>{clearTimeout(de),ke()&&(de=setTimeout(()=>{ke()&&n.send({t:"seen",worktreeId:o})},HW))},G=()=>clearTimeout(de);return ae(),window.addEventListener("focus",ae),window.addEventListener("blur",G),()=>{G(),window.removeEventListener("focus",ae),window.removeEventListener("blur",G)}},[n,o,ie,be]);const C=S.useRef(0),Z=M(de=>pk(de));S.useEffect(()=>{if(!n||!u||!i)return;const de=()=>{Date.now()-C.current<KW||(C.current=Date.now(),n.send({t:"refresh-git",repoId:i}),Z&&Z!==i&&n.send({t:"refresh-git",repoId:Z}))};return window.addEventListener("focus",de),()=>window.removeEventListener("focus",de)},[n,u,i,Z]);const Y=M(de=>de.frame==="phone"&&de.screen==="home"?"surface1":"surface0");S.useEffect(()=>{try{sessionStorage.setItem(Ge.ground,Y)}catch{}},[Y]),S.useEffect(()=>{nj(R,{remember:!A,ground:Y}),an.broadcast(rj(R))},[R,A,Y]);const q=S.useCallback(()=>{n==null||n.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[n]);S.useEffect(()=>{if(!u)return;q();const de=()=>{document.visibilityState==="visible"&&q()};return document.addEventListener("visibilitychange",de),()=>document.removeEventListener("visibilitychange",de)},[u,q]),S.useEffect(()=>{if(!u||h<=Date.now())return;const de=setTimeout(q,h-Date.now()+1e3);return()=>clearTimeout(de)},[u,h,q]),S.useEffect(()=>{p&&p.until>0&&kH(p)},[p]),S.useEffect(()=>{o&&r.set(Ge.active,o)},[o,r]),S.useEffect(()=>{w&&r.set(Ge.version,w)},[w,r]);const F=M(de=>de.frame==="phone"?de.screen!=="home":null);S.useEffect(()=>{F!==null&&r.session.set(Ge.phoneRow,F?"1":"0")},[F,r]),S.useEffect(()=>{i&&r.set(Ge.repo,i)},[i,r]),S.useEffect(()=>{try{localStorage.setItem(Ge.rail,y?"1":"0")}catch{}},[y]),S.useEffect(()=>{try{localStorage.setItem(Ge.chatSide,b)}catch{}},[b]),S.useEffect(()=>{try{localStorage.setItem(Ge.layouts,JSON.stringify(_))}catch{}},[_]),S.useEffect(()=>{r.set(Ge.lastActive,JSON.stringify(T))},[T,r]),S.useEffect(()=>{r.set(Ge.discoveredOpen,JSON.stringify(x))},[x,r]),S.useEffect(()=>{r.set(Ge.archivedOpen,JSON.stringify(N))},[N,r]),S.useEffect(()=>{r.set(Ge.committedShut,JSON.stringify(j))},[j,r]),S.useEffect(()=>{r.set(Ge.turnOpen,JSON.stringify($))},[$,r]),S.useEffect(()=>{r.set(Ge.treeOpen,JSON.stringify(P))},[P,r]),BW(),yD();const re=S.useRef(null);S.useEffect(()=>{!O||re.current===O||(re.current=O,window.open(O,"_blank"),t({a:"opened-url"}))},[O,t]);const Ee=S.useRef(null);return ft([o],()=>{var oe,we,Ce,Se;const de=Ee.current;if(Ee.current=o,!de||!o||de===o)return;const ke=e.getState(),ae=D.find(_e=>_e.id===de),G=D.find(_e=>_e.id===o),ue=(we=(oe=ae==null?void 0:ae.worktree)==null?void 0:oe.variant)==null?void 0:we.group;if(!ue||((Se=(Ce=G==null?void 0:G.worktree)==null?void 0:Ce.variant)==null?void 0:Se.group)!==ue)return;const Le=_e=>{var Be;try{const wt=(Be=ke.local[_e])==null?void 0:Be.page.url;return wt?new URL(wt).pathname+new URL(wt).search:"/"}catch{return"/"}},ge=Le(de);ge!==Le(o)&&an.post(o,{type:"navigate",path:ge})}),M(de=>de.frame)==="phone"?d.jsx(aH,{}):d.jsx(PW,{})}function qW({origin:e,machine:t,onToken:n}){const[r,o]=S.useState({kind:"asking"}),[i,l]=S.useState(0);return ft([i],()=>{const c=new AbortController;return o({kind:"asking"}),_E(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(ps,{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.":KT(r.failure,e,"this device")}),r.kind==="failed"&&d.jsx("div",{className:"status-actions",children:d.jsx(Fe,{variant:"outline",onClick:()=>l(c=>c+1),children:"ask again"})})]})}function GW(){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(SC(t.worktreeId,t.stream))??[])n(t)}}}function VW(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 YW(e){const t={};try{const n=JSON.parse(e??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))XP(o)&&(t[r]=o)}catch{}return t}function XW(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 zd(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 QW(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 JW=400,eK=2e3;function dj(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function fj(e,t,n){const r=e.getState(),o=[];for(const[i,l]of t){if(l===n||r.local[i])continue;const c=ds(i);c&&c.clientId!==r.clientId||o.push(i)}return o}function tK(e,t){const n=new Map,r=new Map,o=dj(),i=u=>{var h,m;clearTimeout((h=r.get(u))==null?void 0:h.timer),r.delete(u);const p=e.getState().local[u];!p||((m=p.mark)==null?void 0:m.by)==="walk"||(n.get(u)??"")!==p.draft&&(n.set(u,p.draft),t.send({t:"set-draft",boxId:u,text:p.draft,clientId:e.getState().clientId}))},l=()=>{for(const u of[...r.keys()])i(u)},c=e.subscribe(()=>{var u,p,h;for(const[m,g]of Object.entries(e.getState().local)){if(o.another(m,g.sent)&&(clearTimeout((u=r.get(m))==null?void 0:u.timer),r.delete(m),n.set(m,"")),((p=g.mark)==null?void 0:p.by)==="walk"||(n.get(m)??"")===g.draft)continue;if(!g.draft){i(m);continue}const w=r.get(m);if((w==null?void 0:w.text)===g.draft)continue;clearTimeout(w==null?void 0:w.timer);const y=(w==null?void 0:w.since)??Date.now(),b=Math.max(0,Math.min(JW,y+eK-Date.now()));r.set(m,{text:g.draft,timer:setTimeout(i,b,m),since:y})}for(const m of fj(e,n,""))clearTimeout((h=r.get(m))==null?void 0:h.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[p,h]of Object.entries(u))n.set(p,h)},heard(u,p){return r.has(u)?!1:(n.set(u,p),!0)},dispose(){c();for(const u of r.values())clearTimeout(u.timer);r.clear(),window.removeEventListener("focusout",l),window.removeEventListener("pagehide",l)}}}function nK(e,t){const n=new Map,r=new Map,o=dj(),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 p=dk(u.attachments),h=JSON.stringify(p),m=r.get(c)??"[]";m!==h&&(r.set(c,h),l.push({id:c,items:p,before:LE(JSON.parse(m))}))}for(const c of fj(e,r,"[]"))r.set(c,"[]"),l.push({id:c,items:[],before:[]});for(const c of GP(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 rK(e,t){return e.subscribe(()=>{for(const n of qP(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(bc(o.outgoing.frame,n,o.draft,o.attachments)),e.dispatch({a:"sent-out",id:n}))}})}const o1="not sent: the page reloaded while an upload was on its way; attach it again and send";function s1(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=ds(c);if((u==null?void 0:u.clientId)!==r.clientId||(l=r.local[c])!=null&&l.outgoing)continue;const p=n.drafts[c]??"",h=n.attachments[c]??[],m=n.drafts[u.source]??"",g=[...h,...n.attachments[u.source]??[]],w=m||p,y=r.clientId;g.length&&t.send({t:"set-attachments",boxId:u.source,items:g,clientId:y}),w!==m&&t.send({t:"set-draft",boxId:u.source,text:w,clientId:y}),t.send({t:"set-attachments",boxId:c,items:[],clientId:y}),t.send({t:"set-draft",boxId:c,text:"",clientId:y}),delete n.drafts[c],delete n.attachments[c],w&&(n.drafts[u.source]=w),g.length&&(n.attachments[u.source]=g),i.push(u.source)}return i}function oK(e,t){const n=(t.storage??eP)(e.origin),r=ML(JP({cached:t.cached,systemDark:t.systemDark,daylight:t.daylight,storedActive:n.get(Ge.active),storedPhoneRow:n.session.get(Ge.phoneRow)==="1",storedRepo:n.get(Ge.repo),storedVersion:n.get(Ge.version),storedRailOpen:bm(Ge.rail)==="1",storedChatSide:bm(Ge.chatSide)==="right"?"right":"left",storedLayouts:YW(bm(Ge.layouts)),storedLastActive:XW(n.get(Ge.lastActive)),storedDiscoveredOpen:zd(n.get(Ge.discoveredOpen)),storedArchivedOpen:zd(n.get(Ge.archivedOpen)),storedCommittedShut:zd(n.get(Ge.committedShut)),storedTurnOpen:zd(n.get(Ge.turnOpen)),storedTreeOpen:QW(n.get(Ge.treeOpen)),clientId:t.clientId,frame:t.frame,touch:t.touch})),o=GW(),i={version:null,protocol:null},l=y6(y=>r.dispatch({a:"server",msg:y}));let c,u,p,h=[];const m=new vP(e,y=>{if(y.t==="hello"){if(i.protocol=y.protocol,e.serving){const{rebuilt:_,update:T}=r.getState(),x=_&&(T==null?void 0:T.restarting)!=null;if(i.version!==null&&(x||y.version!==i.version||y.protocol!==Nd)){m.dispose(),t.reload();return}if(y.protocol!==Nd){r.dispatch({a:"incompatible"}),m.dispose();return}}else if(y.protocol!==Nd){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 _=T=>Object.fromEntries(Object.entries(T).filter(([x])=>!b.has(x)));y.drafts=_(y.drafts),y.attachments=_(y.attachments)}h=s1(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(q2(y)){o.deliver(y);return}if(G2(y)){if(y.t==="file-written"&&M4(y))return;p.receive(y);return}if(y.t==="loose-written"){aU(y);return}if(p3(y)){w3(r,m,y);return}if(y.t==="open-refused"){k3(r,y);return}l(y);for(const b of h.splice(0))r.dispatch({a:"notice",id:b,text:o1})}},(y,b)=>r.dispatch({a:"connected",v:y,failure:b}));z4(r,m.urls),p=new sU({store:r,send:y=>m.send(y),timers:{set:(y,b)=>setTimeout(y,b),clear:y=>clearTimeout(y)},win:window});const g=p.start();c=tK(r,m),u=nK(r,m);const w=rK(r,m);return{origin:e.origin,serving:e.serving,token:e.token,get name(){return r.getState().machine??VW(e.origin)},store:r,sock:m,files:p,terminals:o,storage:n,heard:i,boot(y){if(y.t!=="hello"||y.protocol!==Nd)return;i.version??(i.version=y.version);const b=s1(r,m,y);u.hello(y.attachments),r.dispatch({a:"server",msg:y});for(const _ of b)r.dispatch({a:"notice",id:_,text:o1})},dispose(){m.dispose(),g(),c.dispose(),u.dispose(),w()}}}function bm(e){try{return localStorage.getItem(e)}catch{return null}}window.__toyonShell=!0;window.top!==window&&(document.documentElement.dataset.framed="");nP(location.origin);const hj=fH();nj(hj);function sK(e,t){try{return e.getItem(t)}catch{return null}}function iK(){const e=sK(sessionStorage,Ge.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(Ge.client,t)}catch{}return t}const aK={cached:hj,systemDark:pH(),daylight:gH(),clientId:iK(),frame:jw(),touch:uH(),reload:()=>window.location.reload()},yi=E7({serving:{origin:location.origin,token:yE()},build:e=>oK(e,aK)});dH({dispatch:e=>yi.broadcast(e)});wH(e=>yi.broadcast({a:"system-dark",v:e}));let i1=JT(yi.active().store),a1=yi.active();yi.subscribe(()=>{const e=yi.active();e!==a1&&(a1=e,i1(),e.store.getState().frame==="phone"&&e.store.dispatch({a:"screen",to:"home"}),i1=JT(e.store))});window.addEventListener("vite:preloadError",VD);const lK=(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;t&&typeof t=="object"&&t.t==="hello"&&yi.active().boot(t)});function cK(e){vE(e),window.location.reload()}const uK=yC.createRoot(document.getElementById("root"));lK.then(()=>{var e;kC.flushSync(()=>uK.render(d.jsx(hC.StrictMode,{children:d.jsx(Mk,{children:Jg()?d.jsx(LL,{machines:yi,children:d.jsx(ZW,{})}):d.jsx(qW,{origin:location.origin,machine:location.host,onToken:cK})})}))),document.documentElement.style.removeProperty("background"),document.documentElement.style.removeProperty("--boot-ink"),(e=document.getElementById("boot"))==null||e.remove()});"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Rs as F,Sg as _,wr as a,Xg as b,mK as c,ft as d,kK as e,hK as f,w1 as g,ZM as h,SC as i,d as j,t3 as k,Hk as l,k1 as m,fK as n,pK as p,S as r,zM as s,su as t,gK as u,C0 as w};
|