toyon 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +62 -39
  2. package/dist/bridge.js +1 -1
  3. package/dist/cli.js +255 -68
  4. package/dist/daemon.js +2404 -516
  5. package/dist/shell/assets/{Editor-Cn-KsoFr.js → Editor-Lle8R8mY.js} +148 -148
  6. package/dist/shell/assets/{XTerm-DSSGYyFZ.js → XTerm-DcWpV1FL.js} +13 -13
  7. package/dist/shell/assets/{cssMode-BU_otbjh.js → cssMode-Ck0mAapo.js} +1 -1
  8. package/dist/shell/assets/{freemarker2-C-NGmKSC.js → freemarker2-B5OkSZOW.js} +1 -1
  9. package/dist/shell/assets/{handlebars-BWvVdY_e.js → handlebars-C6vrFwYj.js} +1 -1
  10. package/dist/shell/assets/{html-CBO-8nU2.js → html-CE92cnIr.js} +1 -1
  11. package/dist/shell/assets/{htmlMode-Dwz6npQ-.js → htmlMode-CfM52A9Q.js} +1 -1
  12. package/dist/shell/assets/index-DOf1M9v5.js +233 -0
  13. package/dist/shell/assets/index-b4LMTPcs.css +1 -0
  14. package/dist/shell/assets/{javascript-__evPE7m.js → javascript-C7Q1bCJn.js} +1 -1
  15. package/dist/shell/assets/{jsonMode-DpbQTbP6.js → jsonMode-Cq43R9DW.js} +1 -1
  16. package/dist/shell/assets/{liquid-CgOzfjEh.js → liquid-CnxQAGJm.js} +1 -1
  17. package/dist/shell/assets/{lspLanguageFeatures-DM57zeAM.js → lspLanguageFeatures-BtjVqb14.js} +1 -1
  18. package/dist/shell/assets/{mdx-DxN7Bq5u.js → mdx-ycMLgnto.js} +1 -1
  19. package/dist/shell/assets/{python-C3rGYQJF.js → python-se_0lOPN.js} +1 -1
  20. package/dist/shell/assets/{razor-C5rkTP_6.js → razor-DjByizBq.js} +1 -1
  21. package/dist/shell/assets/{tsMode-DDCDv-RH.js → tsMode-D1mOZbLC.js} +1 -1
  22. package/dist/shell/assets/{typescript-CyHgeKIZ.js → typescript-B-dZdvXG.js} +1 -1
  23. package/dist/shell/assets/{workers-C7XbwGBM.js → workers-DXwGNRtC.js} +1 -1
  24. package/dist/shell/assets/{xml-Dmw92JAf.js → xml-CoqNFco9.js} +1 -1
  25. package/dist/shell/assets/{yaml-Bj_aHuSs.js → yaml-D5Qru8sI.js} +1 -1
  26. package/dist/shell/index.html +2 -2
  27. package/dist/shell/manifest.json +1 -1
  28. package/package.json +2 -2
  29. package/dist/shell/assets/index-B61fMQI2.css +0 -1
  30. package/dist/shell/assets/index-Mb4zTZaD.js +0 -230
@@ -1,230 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-Cn-KsoFr.js","assets/Editor-CB2SckMT.css","assets/XTerm-DSSGYyFZ.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
- var Ax=Object.defineProperty;var $x=(e,t,n)=>t in e?Ax(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var dt=(e,t,n)=>$x(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&o(c)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function ky(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _d={exports:{}},Xs={},Ed={exports:{}},at={};/**
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 Ym;function Mx(){if(Ym)return at;Ym=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.iterator;function k(j){return j===null||typeof j!="object"?null:(j=g&&j[g]||j["@@iterator"],typeof j=="function"?j:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,_={};function I(j,Q,Ie){this.props=j,this.context=Q,this.refs=_,this.updater=Ie||w}I.prototype.isReactComponent={},I.prototype.setState=function(j,Q){if(typeof j!="object"&&typeof j!="function"&&j!=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,j,Q,"setState")},I.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function C(){}C.prototype=I.prototype;function E(j,Q,Ie){this.props=j,this.context=Q,this.refs=_,this.updater=Ie||w}var Z=E.prototype=new C;Z.constructor=E,b(Z,I.prototype),Z.isPureReactComponent=!0;var M=Array.isArray,$=Object.prototype.hasOwnProperty,D={current:null},q={key:!0,ref:!0,__self:!0,__source:!0};function J(j,Q,Ie){var xe,V={},be=null,Ae=null;if(Q!=null)for(xe in Q.ref!==void 0&&(Ae=Q.ref),Q.key!==void 0&&(be=""+Q.key),Q)$.call(Q,xe)&&!q.hasOwnProperty(xe)&&(V[xe]=Q[xe]);var Pe=arguments.length-2;if(Pe===1)V.children=Ie;else if(1<Pe){for(var B=Array(Pe),F=0;F<Pe;F++)B[F]=arguments[F+2];V.children=B}if(j&&j.defaultProps)for(xe in Pe=j.defaultProps,Pe)V[xe]===void 0&&(V[xe]=Pe[xe]);return{$$typeof:e,type:j,key:be,ref:Ae,props:V,_owner:D.current}}function se(j,Q){return{$$typeof:e,type:j.type,key:Q,ref:j.ref,props:j.props,_owner:j._owner}}function me(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function Oe(j){var Q={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(Ie){return Q[Ie]})}var ae=/\/+/g;function ie(j,Q){return typeof j=="object"&&j!==null&&j.key!=null?Oe(""+j.key):Q.toString(36)}function Y(j,Q,Ie,xe,V){var be=typeof j;(be==="undefined"||be==="boolean")&&(j=null);var Ae=!1;if(j===null)Ae=!0;else switch(be){case"string":case"number":Ae=!0;break;case"object":switch(j.$$typeof){case e:case t:Ae=!0}}if(Ae)return Ae=j,V=V(Ae),j=xe===""?"."+ie(Ae,0):xe,M(V)?(Ie="",j!=null&&(Ie=j.replace(ae,"$&/")+"/"),Y(V,Q,Ie,"",function(F){return F})):V!=null&&(me(V)&&(V=se(V,Ie+(!V.key||Ae&&Ae.key===V.key?"":(""+V.key).replace(ae,"$&/")+"/")+j)),Q.push(V)),1;if(Ae=0,xe=xe===""?".":xe+":",M(j))for(var Pe=0;Pe<j.length;Pe++){be=j[Pe];var B=xe+ie(be,Pe);Ae+=Y(be,Q,Ie,B,V)}else if(B=k(j),typeof B=="function")for(j=B.call(j),Pe=0;!(be=j.next()).done;)be=be.value,B=xe+ie(be,Pe++),Ae+=Y(be,Q,Ie,B,V);else if(be==="object")throw Q=String(j),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.");return Ae}function de(j,Q,Ie){if(j==null)return j;var xe=[],V=0;return Y(j,xe,"","",function(be){return Q.call(Ie,be,V++)}),xe}function ge(j){if(j._status===-1){var Q=j._result;Q=Q(),Q.then(function(Ie){(j._status===0||j._status===-1)&&(j._status=1,j._result=Ie)},function(Ie){(j._status===0||j._status===-1)&&(j._status=2,j._result=Ie)}),j._status===-1&&(j._status=0,j._result=Q)}if(j._status===1)return j._result.default;throw j._result}var Ee={current:null},X={transition:null},ce={ReactCurrentDispatcher:Ee,ReactCurrentBatchConfig:X,ReactCurrentOwner:D};function ee(){throw Error("act(...) is not supported in production builds of React.")}return at.Children={map:de,forEach:function(j,Q,Ie){de(j,function(){Q.apply(this,arguments)},Ie)},count:function(j){var Q=0;return de(j,function(){Q++}),Q},toArray:function(j){return de(j,function(Q){return Q})||[]},only:function(j){if(!me(j))throw Error("React.Children.only expected to receive a single React element child.");return j}},at.Component=I,at.Fragment=n,at.Profiler=s,at.PureComponent=E,at.StrictMode=o,at.Suspense=d,at.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ce,at.act=ee,at.cloneElement=function(j,Q,Ie){if(j==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+j+".");var xe=b({},j.props),V=j.key,be=j.ref,Ae=j._owner;if(Q!=null){if(Q.ref!==void 0&&(be=Q.ref,Ae=D.current),Q.key!==void 0&&(V=""+Q.key),j.type&&j.type.defaultProps)var Pe=j.type.defaultProps;for(B in Q)$.call(Q,B)&&!q.hasOwnProperty(B)&&(xe[B]=Q[B]===void 0&&Pe!==void 0?Pe[B]:Q[B])}var B=arguments.length-2;if(B===1)xe.children=Ie;else if(1<B){Pe=Array(B);for(var F=0;F<B;F++)Pe[F]=arguments[F+2];xe.children=Pe}return{$$typeof:e,type:j.type,key:V,ref:be,props:xe,_owner:Ae}},at.createContext=function(j){return j={$$typeof:c,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},j.Provider={$$typeof:a,_context:j},j.Consumer=j},at.createElement=J,at.createFactory=function(j){var Q=J.bind(null,j);return Q.type=j,Q},at.createRef=function(){return{current:null}},at.forwardRef=function(j){return{$$typeof:u,render:j}},at.isValidElement=me,at.lazy=function(j){return{$$typeof:m,_payload:{_status:-1,_result:j},_init:ge}},at.memo=function(j,Q){return{$$typeof:p,type:j,compare:Q===void 0?null:Q}},at.startTransition=function(j){var Q=X.transition;X.transition={};try{j()}finally{X.transition=Q}},at.unstable_act=ee,at.useCallback=function(j,Q){return Ee.current.useCallback(j,Q)},at.useContext=function(j){return Ee.current.useContext(j)},at.useDebugValue=function(){},at.useDeferredValue=function(j){return Ee.current.useDeferredValue(j)},at.useEffect=function(j,Q){return Ee.current.useEffect(j,Q)},at.useId=function(){return Ee.current.useId()},at.useImperativeHandle=function(j,Q,Ie){return Ee.current.useImperativeHandle(j,Q,Ie)},at.useInsertionEffect=function(j,Q){return Ee.current.useInsertionEffect(j,Q)},at.useLayoutEffect=function(j,Q){return Ee.current.useLayoutEffect(j,Q)},at.useMemo=function(j,Q){return Ee.current.useMemo(j,Q)},at.useReducer=function(j,Q,Ie){return Ee.current.useReducer(j,Q,Ie)},at.useRef=function(j){return Ee.current.useRef(j)},at.useState=function(j){return Ee.current.useState(j)},at.useSyncExternalStore=function(j,Q,Ie){return Ee.current.useSyncExternalStore(j,Q,Ie)},at.useTransition=function(){return Ee.current.useTransition()},at.version="18.3.1",at}var Qm;function Lf(){return Qm||(Qm=1,Ed.exports=Mx()),Ed.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 Xm;function Px(){if(Xm)return Xs;Xm=1;var e=Lf(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(u,d,p){var m,g={},k=null,w=null;p!==void 0&&(k=""+p),d.key!==void 0&&(k=""+d.key),d.ref!==void 0&&(w=d.ref);for(m in d)o.call(d,m)&&!a.hasOwnProperty(m)&&(g[m]=d[m]);if(u&&u.defaultProps)for(m in d=u.defaultProps,d)g[m]===void 0&&(g[m]=d[m]);return{$$typeof:t,type:u,key:k,ref:w,props:g,_owner:s.current}}return Xs.Fragment=n,Xs.jsx=c,Xs.jsxs=c,Xs}var Jm;function Lx(){return Jm||(Jm=1,_d.exports=Px()),_d.exports}var h=Lx();const zx=new Set(["edit","delete","move","execute"]),Dx=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function Fx(e){return e.kind?zx.has(e.kind):Dx.has(e.name)}const yy={image:6,paste:4,pick:8},Ux={image:"image",paste:"paste",pick:"element"},Bx={image:"Image",paste:"Pasted text"},vy=(e,t)=>`${Bx[e]} ${t}`,zf=e=>`at most ${yy[e]} ${Ux[e]}s per message`,Zx=(e,t)=>e.filter(n=>n.kind===t).length,Hx=(e,t)=>Math.max(0,yy[t]-Zx(e,t));function Wx(e){const t={image:1,paste:1,pick:1};for(const n of e)for(const o of n??[])t[o.kind]=Math.max(t[o.kind],o.n+1);return t}function Kx(e,t){const n={...t};return e.map(o=>[o,n[o.kind]++])}const sf=[{id:"quick-open",key:"p"},{id:"commands",key:"p",shift:!0,aliases:["e"]},{id:"search",key:"f",shift:!0},{id:"left",key:"b"},{id:"composer",key:"l"},{id:"rail",key:"k",shift:!0,aliases:["l"]},{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:"mark-unread",key:"u",shift:!0},{id:"project",key:"o",ctrlAlias:{key:"r",hostOnly:!0},cmdShiftAlias:["o"]},{id:"refs",key:"g",shift:!0},{id:"routes",key:"g"}];function Vx(e,{guest:t=!1}={}){var o,s;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const a=sf.find(c=>c.alt&&c.key===e.key&&!!c.shift===e.shiftKey);return a&&a.id!=="worktree"?{id:a.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 a of sf){if(a.id==="worktree")continue;const c=a.ctrlAlias;if(c&&e.ctrlKey&&c.key===n&&!!c.shift===e.shiftKey&&!(t&&c.hostOnly))return{id:a.id};if(e.metaKey&&e.shiftKey&&((o=a.cmdShiftAlias)!=null&&o.includes(n)))return{id:a.id};if(!a.alt&&!(e.ctrlKey&&!a.ctrl||!!a.shift!==e.shiftKey)&&(a.key===n||(s=a.aliases)!=null&&s.includes(n)))return{id:a.id}}return null}function Gx(e){const t=sf.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function qx(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function Yx(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}const Qx=["Find","Preview","Panels","Worktrees"],fa={"quick-open":{label:"jump to file",section:"Find"},commands:{label:"command palette",section:"Find",advertise:{key:"e",when:"firefox"}},search:{label:"search in files",section:"Find"},left:{label:"changes panel",section:"Panels"},composer:{label:"chat panel, with the editor's selection",section:"Panels"},rail:{label:"worktree panel",section:"Panels"},keys:{label:"settings & shortcuts",section:"Panels"},terminal:{label:"terminal",section:"Panels"},design:{label:"design system",section:"Panels"},"term-tab":{label:"next terminal tab",section:"Panels"},routes:{label:"go to page",section:"Preview"},pick:{label:"element to chat",section:"Preview"},inspect:{label:"element to code",section:"Preview"},zen:{label:"full-bleed preview",section:"Preview"},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 that needs you",section:"Worktrees",hidden:!0},"wt-unseen-next":{label:"next worktree that needs you",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"}},Xx={ArrowUp:"↑",ArrowDown:"↓",Tab:"Tab"};function Jx(e,t={}){var u;const n=Gx(e),o=fa[e],s=o.advertise&&t[o.advertise.when]?o.advertise.key:n.key,a=s==="1-9"?"1-9":Xx[s]??s.toUpperCase(),c=s!==n.key&&s===((u=n.ctrlAlias)==null?void 0:u.key)?n.ctrlAlias:void 0;return c?`⌃${c.shift?"⇧":""}${a}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${a}`}function e1(e){return Object.keys(fa).filter(t=>fa[t].section===e&&!fa[t].hidden)}const t1={folder:{shared:".toyon/settings.json"}};function n1(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const r1=4401,o1=25e4;function i1(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let o=0;for(;o<e.length-n&&o<t.length-n&&e[e.length-1-o]===t[t.length-1-o];)o++;const s=e.slice(0,n).map(a=>({mark:" ",value:a}));return s.push(...s1(e.slice(n,e.length-o),t.slice(n,t.length-o))),s.push(...e.slice(e.length-o).map(a=>({mark:" ",value:a}))),s}function s1(e,t){if(e.length===0)return t.map(u=>({mark:"+",value:u}));if(t.length===0)return e.map(u=>({mark:"-",value:u}));if((e.length+1)*(t.length+1)>o1)return[...e.map(u=>({mark:"-",value:u})),...t.map(u=>({mark:"+",value:u}))];const n=t.length+1,o=new Uint32Array((e.length+1)*n);for(let u=e.length-1;u>=0;u--)for(let d=t.length-1;d>=0;d--)o[u*n+d]=e[u]===t[d]?(o[(u+1)*n+d+1]??0)+1:Math.max(o[(u+1)*n+d]??0,o[u*n+d+1]??0);const s=[];let a=0,c=0;for(;a<e.length&&c<t.length;)e[a]===t[c]?(s.push({mark:" ",value:e[a]}),a++,c++):(o[(a+1)*n+c]??0)>=(o[a*n+c+1]??0)?(s.push({mark:"-",value:e[a]}),a++):(s.push({mark:"+",value:t[c]}),c++);for(;a<e.length;)s.push({mark:"-",value:e[a++]});for(;c<t.length;)s.push({mark:"+",value:t[c++]});return s}const a1=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function eg(e){return e.match(a1)??[]}const l1=.4;function c1(e,t){if(e===t)return null;const n=i1(eg(e),eg(t));let o=0;for(const s of n)s.mark===" "&&(o+=s.value.length);return o<l1*Math.max(e.length,t.length)?null:{before:tg(n,"-"),after:tg(n,"+")}}function tg(e,t){const n=[];for(const o of e){if(o.mark!==" "&&o.mark!==t)continue;const s=o.mark===t,a=n[n.length-1];a&&a.changed===s?a.text+=o.value:n.push({text:o.value,changed:s})}for(let o=1;o<n.length-1;o++){const s=n[o];s&&(s.changed?s.changed=s.text.trim()!=="":s.changed=s.text.length<=2)}return wy(n)}function ng(e){const t=[[]];for(const n of e){const o=n.text.split(`
19
- `);for(const[s,a]of o.entries())s>0&&t.push([]),a&&t[t.length-1].push({text:a,changed:n.changed})}return t.map(wy)}function wy(e){const t=[];for(const n of e){const o=t[t.length-1];o&&o.changed===n.changed?o.text+=n.text:t.push({...n})}return t}const u1=[{id:"merge",name:"merge here",description:"merge into main in this checkout; nothing is pushed"},{id:"push",name:"merge and push",description:"merge into main here, then push main to origin"},{id:"pr",name:"open a PR",description:"push the branch and open a pull request on GitHub"}],d1=[{id:"merge",name:"merge commit",description:"one merge commit records the landing"},{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"}],af="merge";function fs(e){var n,o,s;const t=((n=e.land)==null?void 0:n.route)??af;return{land:t,automerge:t==="pr"&&((o=e.land)==null?void 0:o.automerge)===!0,...(s=e.land)!=null&&s.method?{merge:e.land.method}:{}}}function Df(e,t="main"){switch(e.land){case"merge":return`Commit and merge into ${t} here`;case"push":return`Commit, merge into ${t} and push it`;case"pr":return e.automerge?"Commit, push the branch and open a PR that GitHub merges when its rules allow":"Commit, push the branch and open a PR"}}const f1="https://toyon.cloud",p1=e=>`${f1}/#add=${encodeURIComponent(e)}`,Ff=[{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"}],lf="auto";function h1(e){return e.branch.startsWith("toyon/")}const vo="shell",Ao="login";function m1(e,t){return`${e}/${t}`}function by(e){return e.find(t=>t.id==="default")}function g1(e){const t=by(e);if(t!=null&&t.description)return e.find(n=>n!==t&&n.name===t.description)}const xy=43,k1=5e6,y1=["image/png","image/jpeg","image/gif","image/webp"],rg=2576,Sd=5*1024*1024,v1=1200,w1=10,b1=1e5;function x1(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function _1(e){return e.t==="file-read"||e.t==="file-written"}const E1=80;function S1(e){var o;const t=e.split(`
20
- `),n=((o=t.find(s=>s.trim().length>0))==null?void 0:o.trim())??"";return{chars:e.length,lines:t.length,preview:n.slice(0,E1)}}function N1(e){return e.length>=v1||e.split(`
21
- `).length>=w1}function T1({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function I1(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${T1(e)})`}const O1=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function R1(e){return e.replace(O1,"")}const _y="Projects";function C1(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function ka(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":C1(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 j1=/^(?:https?|ssh|git|file):\/\/\S+$/i,Ey=/^[\w.-]+@[\w.-]+:\S+$/;function A1(e){const t=e.trim();if(!j1.test(t)&&!Ey.test(t))return null;const n=$1(t);return n&&!ka(n)?{url:t,name:n}:null}function $1(e){var s;const t=((s=e.split(/[?#]/)[0])==null?void 0:s.replace(/\/+$/,""))??"";return((Ey.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}function Sy(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,s])=>t.indexOf(+o)===-1).map(([o,s])=>s)}function og(e,t="|"){return e.map(n=>Iy(n)).join(t)}function cf(e,t){return typeof t=="bigint"?t.toString():t}function _c(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function M1(e){return e==null}function Uf(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function P1(e,t){const n=e/t,o=Math.round(n),s=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-o)<s?0:n-o}function vr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function si(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function L1(e){return JSON.stringify(e)}function z1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ny="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ya(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const D1=_c(()=>{var e;if(ao.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 va(e){if(ya(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ya(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ty(e){return va(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const F1=new Set(["string","number","symbol"]);function gs(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ai(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(o._zod.parent=e),o}function Fe(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 Iy(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function U1(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const B1={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 Z1(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const a=si(e._zod.def,{get shape(){const c={};for(const u of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,u))throw new Error(`Unrecognized key: "${String(u)}"`);t[u]&&vr(c,u,n.shape[u])}return vr(this,"shape",c),c},checks:[]});return ai(e,a)}function H1(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const a=si(e._zod.def,{get shape(){const c={...e._zod.def.shape};for(const u of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,u))throw new Error(`Unrecognized key: "${String(u)}"`);t[u]&&delete c[u]}return vr(this,"shape",c),c},checks:[]});return ai(e,a)}function W1(e,t){if(!va(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const a=e._zod.def.shape;for(const c of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(a,c)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=si(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return vr(this,"shape",a),a}});return ai(e,s)}function K1(e,t){if(!va(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=si(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return vr(this,"shape",o),o}});return ai(e,n)}function V1(e,t){var o,s;if(!((o=t==null?void 0:t._zod)!=null&&o.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((s=e._zod.def.checks)!=null&&s.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=si(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return vr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ai(e,n)}function ig(e,t,n,o="partial"){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(`.${o}() cannot be used on object schemas containing refinements`);const u=si(t._zod.def,{get shape(){const d=t._zod.def.shape,p={...d};if(n)for(const m of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(d,m))throw new Error(`Unrecognized key: "${String(m)}"`);n[m]&&(p[m]=e?new e({type:"optional",innerType:d[m]}):d[m])}else for(const m of Reflect.ownKeys(d))p[m]=e?new e({type:"optional",innerType:d[m]}):d[m];return vr(this,"shape",p),p},checks:[]});return ai(t,u)}function G1(e,t,n){const o=si(t._zod.def,{get shape(){const s=t._zod.def.shape,a={...s};if(n)for(const c of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(a,c))throw new Error(`Unrecognized key: "${String(c)}"`);n[c]&&(a[c]=new e({type:"nonoptional",innerType:s[c]}))}else for(const c of Reflect.ownKeys(s))a[c]=new e({type:"nonoptional",innerType:s[c]});return vr(this,"shape",a),a}});return ai(t,o)}function cs(e,t=0){var n;if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(((n=e.issues[o])==null?void 0:n.continue)!==!0)return!0;return!1}function q1(e,t=0){var n;if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(((n=e.issues[o])==null?void 0:n.continue)===!1)return!0;return!1}function Ec(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function Js(e){return typeof e=="string"?e:e==null?void 0:e.message}function sg(e,t,n){var o;for(let s=t;s<e.length;s++)(o=e[s]).schema??(o.schema=n)}function vs(e,t,n){var k,w,b,_,I,C,E,Z,M,$;var o;const s=(w=(k=e.inst)==null?void 0:k._zod)==null?void 0:w.traits;s!=null&&s.has("$ZodType")&&(s.has("$ZodCheck")?(o=e).schema??(o.schema=e.inst):e.schema=e.inst);const a=e.schema!==e.inst?(_=(b=e.schema)==null?void 0:b._zod.def)==null?void 0:_.error:void 0,c=e.message?e.message:Js((E=(C=(I=e.inst)==null?void 0:I._zod.def)==null?void 0:C.error)==null?void 0:E.call(C,e))??Js(a==null?void 0:a(e))??Js((Z=t==null?void 0:t.error)==null?void 0:Z.call(t,e))??Js((M=n.customError)==null?void 0:M.call(n,e))??Js(($=n.localeError)==null?void 0:$.call(n,e))??"Invalid input",{inst:u,schema:d,continue:p,input:m,...g}=e;return g.path??(g.path=[]),g.message=c,t!=null&&t.reportInput&&(g.input=m),g}const Y1=/[\uD800-\uDBFF]/;function Bf(e){const t=e.length;if(!Y1.test(e))return t;let n=t;for(let o=0;o<t-1;o++)(e.charCodeAt(o)&64512)===55296&&(e.charCodeAt(o+1)&64512)===56320&&(n--,o++);return n}function Zf(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Q1(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 wa(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}function X1(e,t){for(const n in t){const o=Object.getOwnPropertyDescriptor(t,n);o.get?Object.defineProperty(e,n,{...o,enumerable:!1}):J1(e,n,o.value)}}function ks(e,t,n,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:n}),n}function Oy(e,t,n){return ks(e,t,n,!1)}function J1(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:ks(this,t,n.bind(this))},set(o){ks(this,t,o)}})}function e_(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Nd,ri=!1;const t_={configurable:!0,get(){ri=!0}};function Mt(e,t,n){const o=Object.getPrototypeOf(e._zod);if(t in o&&Nd!==e._zod){Nd=void 0;return}Nd=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,t_);const s=ri;ri=!1;try{const a=n(this);return ri?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:a}),ri=ri||s,a}catch(a){throw delete this[t],ri=ri||s,a}},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s})}})}function n_(e,t,n,o){const s=e_(e,t);s&&Object.defineProperty(s,t,{configurable:!0,get(){const a={configurable:!0,writable:!0,enumerable:o,value:void 0};return Object.defineProperty(this,t,a),a.value=n(this),Object.defineProperty(this,t,a),a.value},set(a){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:o,value:a})}})}const r_="~constantCatch";function o_(e){const t=()=>e;return t[r_]=!0,t}var ag;const Td={value:void 0,enumerable:!1};let lg="captureStackTrace"in Error?Error:null;function i_(e){const t=lg;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return lg=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function re(e,t,n,o){const s={};function a(k){this.def=k,this.constr=g,this.traits=new Set}a.prototype=s;const c=n,u=c&&new WeakSet;function d(k,w){if(!k._zod){Td.value=new a(w);try{Object.defineProperty(k,"_zod",Td)}finally{Td.value=void 0}}if(k._zod.traits.has(e))return;if(k._zod.traits.add(e),t(k,w),u){const _=Object.getPrototypeOf(k),I=k._zod.constr.prototype;let C=_;for(;C&&C!==I;)C=Object.getPrototypeOf(C);const E=C??_;u.has(E)||(u.add(E),X1(E,c))}const b=g.prototype;for(const _ in b)Object.prototype.hasOwnProperty.call(b,_)&&(_ in k||(k[_]=b[_].bind(k)))}const p=(o==null?void 0:o.Parent)??Object;class m extends p{}Object.defineProperty(m,"name",{value:e});function g(k){var I;const w=o!=null&&o.Parent?i_(m):this;d(w,k);const b=w._zod.deferred;if(b){for(const C of b)C();w._zod.deferred=void 0}const _=(I=globalThis.__zod_globalConfig)==null?void 0:I.postProcessor;return _&&_(w),w}return Object.defineProperty(g,"init",{value:d}),Object.defineProperty(g,Symbol.hasInstance,{value:k=>{var w,b;return o!=null&&o.Parent&&k instanceof o.Parent?!0:(b=(w=k==null?void 0:k._zod)==null?void 0:w.traits)==null?void 0:b.has(e)}}),Object.defineProperty(g,"name",{value:e}),g}class ps extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ry extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(ag=globalThis).__zod_globalConfig??(ag.__zod_globalConfig={});const ao=globalThis.__zod_globalConfig;function li(e){return e&&Object.assign(ao,e),ao}function s_(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,cf,2)),e.message}function a_(e){this._zod.message=e}const l_={get:s_,set:a_,enumerable:!0,configurable:!0},Id={value:void 0,enumerable:!1},Od={value:void 0,enumerable:!1},cg=new WeakSet([Object.prototype,Error.prototype]),Cy=(e,t)=>{e.name="$ZodError",Id.value=e._zod,Object.defineProperty(e,"_zod",Id),Od.value=t,Object.defineProperty(e,"issues",Od),Id.value=void 0,Od.value=void 0,Object.defineProperty(e,"message",l_);const n=Object.getPrototypeOf(e);cg.has(n)||(cg.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const o=()=>this.message;return Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0})}}))},jy=re("$ZodError",Cy),Ay=re("$ZodError",Cy,void 0,{Parent:Error});function c_(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 u_(e,t=n=>n.message){const n={},o=[];for(const s of e.issues)s.path.length>0?c_(n,s.path[0],()=>[]).push(t(s)):o.push(t(s));return{formErrors:o,fieldErrors:n}}function d_(e,t=n=>n.message){const n={_errors:[]},o=(s,a=[])=>{for(const c of s.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>o({issues:u},[...a,...c.path]));else if(c.code==="invalid_key")o({issues:c.issues},[...a,...c.path]);else if(c.code==="invalid_element")o({issues:c.issues},[...a,...c.path]);else{const u=[...a,...c.path];if(u.length===0)n._errors.push(t(c));else{let d=n,p=0;for(;p<u.length;){const m=u[p],g=p===u.length-1;if(m==="_errors"){g&&d._errors.push(t(c)),p++;continue}Object.prototype.hasOwnProperty.call(d,m)||Object.defineProperty(d,m,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const k=d[m];g&&k._errors.push(t(c)),d=k,p++}}}};return o(e),n}function Sc(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const Hf=e=>{const t=(n,o,s,a)=>{const c=s?{...s,async:!1}:{async:!1},u=n._zod.run({value:o,issues:[]},c);if(u instanceof Promise)throw new ps;if(u.issues.length){const d=new((a==null?void 0:a.Err)??e)(u.issues.map(p=>vs(p,c,li())));throw Ny(d,(a==null?void 0:a.callee)??t),d}return u.value};return t},Wf=e=>{const t=async(n,o,s,a)=>{const c=s?{...s,async:!0}:{async:!0};let u=n._zod.run({value:o,issues:[]},c);if(u instanceof Promise&&(u=await u),u.issues.length){const d=new((a==null?void 0:a.Err)??e)(u.issues.map(p=>vs(p,c,li())));throw Ny(d,(a==null?void 0:a.callee)??t),d}return u.value};return t},Nc=e=>(t,n,o)=>{const s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new ps;return a.issues.length?{success:!1,error:new(e??jy)(a.issues.map(c=>vs(c,s,li())))}:{success:!0,data:a.value}},f_=Nc(Ay),Tc=e=>async(t,n,o)=>{const s=o?{...o,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},s);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(c=>vs(c,s,li())))}:{success:!0,data:a.value}},p_=Tc(Ay),h_=e=>{const t=Hf(e),n=(o,s,a,c)=>{const u=a?{...a,direction:"backward"}:{direction:"backward"};return t(o,s,u,Sc(n,c))};return n},m_=e=>{const t=Hf(e),n=(o,s,a,c)=>t(o,s,a,Sc(n,c));return n},g_=e=>{const t=Wf(e),n=async(o,s,a,c)=>{const u=a?{...a,direction:"backward"}:{direction:"backward"};return await t(o,s,u,Sc(n,c))};return n},k_=e=>{const t=Wf(e),n=async(o,s,a,c)=>await t(o,s,a,Sc(n,c));return n},y_=e=>(t,n,o)=>{const s=o?{...o,direction:"backward"}:{direction:"backward"};return Nc(e)(t,n,s)},v_=e=>(t,n,o)=>Nc(e)(t,n,o),w_=e=>async(t,n,o)=>{const s=o?{...o,direction:"backward"}:{direction:"backward"};return Tc(e)(t,n,s)},b_=e=>async(t,n,o)=>Tc(e)(t,n,o),x_=/^[cC][0-9a-z]{6,}$/,__=/^[0-9a-z]+$/,E_=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,S_=/^[0-9a-vA-V]{20}$/,N_=/^[A-Za-z0-9]{27}$/,T_=/^[a-zA-Z0-9_-]{21}$/;function I_(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const O_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,R_=/^([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})$/,ug=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)$/,C_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,j_="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function A_(){return new RegExp(j_,"u")}const $_=/^(?:(?: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])$/,M_=/^(([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}|:))$/,P_=/^((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])$/,L_=/^(([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])$/,z_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$y=/^[A-Za-z0-9_-]*$/,D_=/^https?$/,F_=/^\+[1-9]\d{6,14}$/,My="(?:(?:\\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 U_(e){return new RegExp(`^${e}$`)}const B_=U_(My);function uf(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 Z_(e){return new RegExp(`^${uf(e)}$`)}function H_(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${uf({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,o=e.local?`${n}|${uf({precision:e.precision})}`:n;return new RegExp(`^${My}T(?:${o})$`)}const W_=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}$`)},K_=/^-?\d+$/,V_=/^-?\d+(?:\.\d+)?$/,G_=/^(?:true|false)$/i,q_=/^[^A-Z]*$/,Y_=/^[^a-z]*$/,br=re("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Kf=e=>{const t=e.value;return!M1(t)&&t.length!==void 0},oc={number:"number",bigint:"bigint",object:"date"},Py=re("$ZodCheckLessThan",(e,t)=>{br.init(e,t);const n=oc[typeof t.value];e._zod.onattach.push(o=>{const s=o._zod.bag,a=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?s.maximum=t.value:s.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:oc[typeof o.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ly=re("$ZodCheckGreaterThan",(e,t)=>{br.init(e,t);const n=oc[typeof t.value];e._zod.onattach.push(o=>{const s=o._zod.bag,a=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:oc[typeof o.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Q_=re("$ZodCheckMultipleOf",(e,t)=>{br.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.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):P1(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})}}),X_=re("$ZodCheckNumberFormat",(e,t)=>{var c;br.init(e,t),t.format=t.format||"float64";const n=(c=t.format)==null?void 0:c.includes("int"),o=n?"int":"number",[s,a]=B1[t.format];e._zod.onattach.push(u=>{const d=u._zod.bag;d.format=t.format,d.minimum=s,d.maximum=a,n&&(d.pattern=K_)}),e._zod.check=u=>{const d=u.value;if(n){if(!Number.isInteger(d)){u.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?u.issues.push({input:d,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):u.issues.push({input:d,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}d<s&&u.issues.push({origin:"number",input:d,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),d>a&&u.issues.push({origin:"number",input:d,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),J_=re("$ZodCheckMaxLength",(e,t)=>{var n;br.init(e,t),(n=e._zod.def).when??(n.when=Kf),e._zod.onattach.push(o=>{const s=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const s=o.value,a=s.length;if((typeof s=="string"&&a>t.maximum?Bf(s):a)<=t.maximum)return;const u=Zf(s);o.issues.push({origin:u,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),eE=re("$ZodCheckMinLength",(e,t)=>{var n;br.init(e,t),(n=e._zod.def).when??(n.when=Kf),e._zod.onattach.push(o=>{const s=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const s=o.value,a=s.length;if((typeof s=="string"&&a>=t.minimum&&a<t.minimum*2?Bf(s):a)>=t.minimum)return;const u=Zf(s);o.issues.push({origin:u,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),tE=re("$ZodCheckLengthEquals",(e,t)=>{var n;br.init(e,t),(n=e._zod.def).when??(n.when=Kf),e._zod.onattach.push(o=>{const s=o._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=o=>{const s=o.value,a=s.length,c=typeof s=="string"&&a>=t.length&&a<=t.length*2?Bf(s):a;if(c===t.length)return;const u=Zf(s),d=c>t.length;o.issues.push({origin:u,...d?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Ic=re("$ZodCheckStringFormat",(e,t)=>{var n,o;br.init(e,t),e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),nE=re("$ZodCheckRegex",(e,t)=>{Ic.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})}}),rE=re("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=q_),Ic.init(e,t)}),oE=re("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Y_),Ic.init(e,t)}),iE=re("$ZodCheckIncludes",(e,t)=>{br.init(e,t);const n=gs(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=o,e._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(o)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),sE=re("$ZodCheckStartsWith",(e,t)=>{br.init(e,t);const n=new RegExp(`^${gs(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),aE=re("$ZodCheckEndsWith",(e,t)=>{br.init(e,t);const n=new RegExp(`.*${gs(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),lE=re("$ZodCheckOverwrite",(e,t)=>{br.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class cE{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 o=t.split(`
22
- `).filter(c=>c),s=Math.min(...o.map(c=>c.length-c.trimStart().length)),a=o.map(c=>c.slice(s)).map(c=>" ".repeat(this.indent*2)+c);for(const c of a)this.content.push(c)}compile(){const t=Function,n=(this==null?void 0:this.content)??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
23
- ${n.join(`
24
- `)}
25
- };`)(...Object.values(this.closed))}}const uE={major:4,minor:5,patch:4},en=re("$ZodType",(e,t)=>{var a;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=uE;const o=e._zod.def.checks,s=e._zod.traits.has("$ZodCheck")?[e,...o??[]]:o!=null&&o.length?[...o]:[];for(const c of s)for(const u of c._zod.onattach)u(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const c=(d,p,m)=>{if(d.memo)return d;let g=cs(d),k;for(const w of p){if(w._zod.def.when){if(q1(d)||!w._zod.def.when(d))continue}else if(g)continue;const b=d.issues.length,_=w._zod.check(d);if(_ instanceof Promise&&(m==null?void 0:m.async)===!1)throw new ps;if(k||_ instanceof Promise)k=(k??Promise.resolve()).then(async()=>{await _,d.issues.length!==b&&(sg(d.issues,b,e),g||(g=cs(d,b)))});else{if(d.issues.length===b)continue;sg(d.issues,b,e),g||(g=cs(d,b))}}return k?k.then(()=>d):d},u=(d,p,m)=>{if(cs(d))return d.aborted=!0,d;const g=c(p,s,m);if(g instanceof Promise){if(m.async===!1)throw new ps;return g.then(k=>e._zod.parse(k,m))}return e._zod.parse(g,m)};e._zod.run=(d,p)=>{if(p.skipChecks)return e._zod.parse(d,p);if(p.direction==="backward"){const g=e._zod.parse({value:d.value,issues:[]},{...p,skipChecks:!0});return g instanceof Promise?g.then(k=>u(k,d,p)):u(g,d,p)}const m=e._zod.parse(d,p);if(m instanceof Promise){if(p.async===!1)throw new ps;return m.then(g=>c(g,s,p))}return c(m,s,p)}}},{get"~standard"(){return Oy(this,"~standard",zy(this))},set"~standard"(e){ks(this,"~standard",e)}}),dg=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function zy(e){return{validate:t=>{try{return dg(f_(e,t))}catch{return p_(e,t).then(dg)}},vendor:"zod",version:1}}const Vf=re("$ZodString",(e,t)=>{var n;en.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??W_(e._zod.bag),e._zod.parse=(o,s)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),tn=re("$ZodStringFormat",(e,t)=>{Ic.init(e,t),Vf.init(e,t)}),dE=re("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=R_),tn.init(e,t)}),fE=re("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ug(o))}else t.pattern??(t.pattern=ug());tn.init(e,t)}),pE=re("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=C_),tn.init(e,t)}),Dy=1,Fy=2;function hE(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===D_.source&&!/^https?:\/\//i.test(e))return Dy;try{return new URL(e)}catch{return Fy}}const mE=/[\t\n\r]/g;function gE(e){return e.replace(mE,"")}function kE(e,t){return t.lastIndex=0,t.test(e.hostname)}function yE(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const vE=re("$ZodURL",(e,t)=>{tn.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),s=hE(o,t);if(s===Dy){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(s===Fy){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!kE(s,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&&!yE(s,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?s.href:gE(o);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),wE=re("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=A_()),tn.init(e,t)}),bE=re("$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?T_:I_(t.length)),tn.init(e,t)}),xE=re("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=x_),tn.init(e,t)}),_E=re("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=__),tn.init(e,t)}),EE=re("$ZodULID",(e,t)=>{t.pattern??(t.pattern=E_),tn.init(e,t)}),SE=re("$ZodXID",(e,t)=>{t.pattern??(t.pattern=S_),tn.init(e,t)}),NE=re("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=N_),tn.init(e,t)}),TE=re("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=H_(t)),tn.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),IE=re("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=B_),tn.init(e,t)}),OE=re("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Z_(t)),tn.init(e,t)}),RE=re("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=O_),tn.init(e,t)}),CE=re("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=$_),tn.init(e,t),e._zod.bag.format="ipv4"}),jE=/^[0-9a-fA-F:.]+$/;function Uy(e){if(!jE.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const AE=re("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=M_),tn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{Uy(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),$E=re("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=P_),tn.init(e,t)});function ME(e){const t=e.split("/");if(t.length!==2)return!1;const[n,o]=t;if(!o)return!1;const s=Number(o);return`${s}`!==o||s<0||s>128?!1:Uy(n)}const PE=re("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=L_),tn.init(e,t),e._zod.check=n=>{ME(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function By(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const LE=re("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=z_),tn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{By(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function zE(e){if(!$y.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return By(n)}const DE=re("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$y),tn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{zE(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),FE=re("$ZodE164",(e,t)=>{t.pattern??(t.pattern=F_),tn.init(e,t)});function UE(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const s=JSON.parse(atob(o));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const BE=re("$ZodJWT",(e,t)=>{tn.init(e,t),e._zod.check=n=>{UE(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Zy=re("$ZodNumber",(e,t)=>{en.init(e,t),e._zod.pattern=e._zod.bag.pattern??V_,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const a=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:String(s):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...a?{received:a}:{}}),n}}),ZE=re("$ZodNumberFormat",(e,t)=>{X_.init(e,t),Zy.init(e,t)}),HE=re("$ZodBoolean",(e,t)=>{en.init(e,t),e._zod.pattern=G_,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const s=n.value;return typeof s=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),n}}),WE=re("$ZodUnknown",(e,t)=>{en.init(e,t),e._zod.parse=n=>n}),KE=re("$ZodNever",(e,t)=>{en.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function fg(e,t,n){e.issues.length&&t.issues.push(...Ec(n,e.issues)),t.value[n]=e.value}const VE=re("$ZodArray",(e,t)=>{en.init(e,t);const n=ao.memoizer;n==null||n.attach(e),e._zod.parse=(o,s)=>{const a=o.value;if(!Array.isArray(a))return o.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),o;o.value=n?n.alloc(e,o,Array(a.length),s):Array(a.length);const c=[];for(let u=0;u<a.length;u++){const d=a[u],p=t.element._zod.run({value:d,issues:[]},s);p instanceof Promise?c.push(p.then(m=>fg(m,o,u))):fg(p,o,u)}return c.length?Promise.all(c).then(()=>o):o}});function ic(e,t,n,o,s,a){const c=n in o,u=a==="optional";if(!(!c&&u&&s==="optional")){if(e.issues.length){if(s!==void 0&&u&&!c)return;t.issues.push(...Ec(n,e.issues))}if(!c&&s===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?c&&(t.value[n]=void 0):t.value[n]=e.value}}const GE=[];function Hy(e){var c,u,d,p;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),o=n.length?n:GE,s=o.length?[...t,...o]:t;for(const m of s)if(!((p=(d=(u=(c=e.shape)==null?void 0:c[m])==null?void 0:u._zod)==null?void 0:d.traits)!=null&&p.has("$ZodType")))throw new Error(`Invalid element at key "${String(m)}": expected a Zod schema`);const a=U1(e.shape);return{...e,allKeys:s,symbolKeys:o,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Wy(e,t,n,o,s,a){const c=[],u=s.keySet,d=s.catchall._zod,p=d.def.type,m=d.optin,g=d.optout;for(const k in t){if(u.has(k))continue;if(k==="__proto__"){p==="never"&&c.push(k);continue}if(p==="never"){c.push(k);continue}const w=d.run({value:t[k],issues:[]},o);w instanceof Promise?e.push(w.then(b=>ic(b,n,k,t,m,g))):ic(w,n,k,t,m,g)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const df=new WeakMap,qE=re("$ZodObject",(e,t)=>{en.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const d=t.shape;df.set(t,d),Object.defineProperty(t,"shape",{get:()=>{const p={...d};return Object.defineProperty(t,"shape",{value:p}),df.set(t,p),p}})}const o=_c(()=>Hy(t));Mt(e,"propValues",d=>{const p=d.def.shape,m={};for(const g in p){const k=p[g]._zod;if(k.values){Object.prototype.hasOwnProperty.call(m,g)||vr(m,g,new Set);for(const w of k.values)m[g].add(w);k.optin!==void 0&&m[g].add(void 0)}}return m});const s=ya,a=t.catchall;let c;const u=ao.memoizer;u==null||u.attach(e),e._zod.parse=(d,p)=>{c??(c=o.value);const m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),d;d.value=u?u.alloc(e,d,{},p):{};const g=[],k=c.shape;for(const w of c.allKeys){if(w==="__proto__")continue;const b=k[w],_=b._zod.optin,I=b._zod.optout,C=b._zod.run({value:m[w],issues:[]},p);C instanceof Promise?g.push(C.then(E=>ic(E,d,w,m,_,I))):ic(C,d,w,m,_,I)}return a?Wy(g,m,d,p,o.value,e):g.length?Promise.all(g).then(()=>d):d}}),YE=re("$ZodObjectJIT",(e,t)=>{qE.init(e,t);const n=e._zod.parse,o=_c(()=>Hy(t)),s=ao.memoizer,a=w=>{var $,D;const b=o.value,_=b.symbolKeys,I=new cE(["payload","ctx"],{shape:w,inst:e,memo:s,syms:_}),C=q=>`shape[${q}]._zod.run({ value: input[${q}], issues: [] }, ctx)`,E=(q,J)=>`
26
- for (let i = 0; i < ${q}.issues.length; i++) {
27
- const iss = ${q}.issues[i];
28
- iss.path = iss.path ? [${J}, ...iss.path] : [${J}];
29
- payload.issues.push(iss);
30
- }`;I.write("const input = payload.value;");const Z=Object.create(null);let M=0;for(const q of b.allKeys)Z[q]=`key_${M++}`;I.write(s?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const q of b.allKeys){if(q==="__proto__")continue;const J=Z[q],se=typeof q=="symbol"?`syms[${_.indexOf(q)}]`:L1(q),me=`${se} in input`,Oe=w[q],ae=($=Oe==null?void 0:Oe._zod)==null?void 0:$.optin,ie=ae!==void 0,Y=((D=Oe==null?void 0:Oe._zod)==null?void 0:D.optout)==="optional";if(I.write(`const ${J} = ${C(se)};`),ie&&Y){const de=ae==="optional"?`${J}_present`:`${J}.value !== undefined || ${J}_present`;I.write(`
31
- const ${J}_present = ${me};
32
- if (!${J}.issues.length || ${J}_present) {
33
- if (${J}.issues.length) {${E(J,se)}
34
- }
35
-
36
- if (${de}) {
37
- newResult[${se}] = ${J}.value;
38
- }
39
- }
40
-
41
- `)}else ie?I.write(`
42
- if (${J}.issues.length) {${E(J,se)}
43
- }
44
-
45
- if (${J}.value === undefined) {
46
- if (${me}) {
47
- newResult[${se}] = undefined;
48
- }
49
- } else {
50
- newResult[${se}] = ${J}.value;
51
- }
52
-
53
- `):I.write(`
54
- const ${J}_present = ${me};
55
- if (${J}.issues.length) {${E(J,se)}
56
- }
57
- if (!${J}_present && !${J}.issues.length) {
58
- payload.issues.push({
59
- code: "invalid_type",
60
- expected: "nonoptional",
61
- input: undefined,
62
- path: [${se}]
63
- });
64
- }
65
-
66
- if (${J}_present) {
67
- newResult[${se}] = ${J}.value;
68
- }
69
-
70
- `)}return I.write("payload.value = newResult;"),I.write("return payload;"),I.compile()};let c;const u=ya,d=!ao.jitless,m=d&&D1.value,g=t.catchall;let k;e._zod.parse=(w,b)=>{k??(k=o.value);const _=w.value;return u(_)?d&&m&&(b==null?void 0:b.async)===!1&&b.jitless!==!0?(c||(c=a(t.shape)),w=c(w,b),g?Wy([],_,w,b,k,e):w):n(w,b):(w.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),w)}});function pg(e,t,n,o){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const s=e.filter(a=>!cs(a));return s.length===1?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(a=>a.issues.map(c=>vs(c,o,li())))}),t)}const Ky=re("$ZodUnion",(e,t)=>{en.init(e,t),Mt(e,"optin",o=>o.def.options.some(s=>s._zod.optin==="defaulted")?"defaulted":o.def.options.some(s=>s._zod.optin!==void 0)?"optional":void 0),Mt(e,"optout",o=>o.def.options.some(s=>s._zod.optout==="optional")?"optional":void 0),Mt(e,"values",o=>{if(o.def.options.every(s=>s._zod.values))return new Set(o.def.options.flatMap(s=>Array.from(s._zod.values)))}),Mt(e,"pattern",o=>{if(o.def.options.every(s=>s._zod.pattern)){const s=o.def.options.map(a=>a._zod.pattern);return new RegExp(`^(${s.map(a=>Uf(a.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,s)=>{if(n)return n(o,s);let a=!1;const c=[];for(const u of t.options){const d=u._zod.run({value:o.value,issues:[]},s);if(d instanceof Promise)c.push(d),a=!0;else{if(d.issues.length===0)return d;c.push(d)}}return a?Promise.all(c).then(u=>pg(u,o,e,s)):pg(c,o,e,s)}}),QE=re("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ky.init(e,t);const n=e._zod.parse;Mt(e,"propValues",s=>{const a={};for(const c of s.def.options){const u=c._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${s.def.options.indexOf(c)}"`);for(const[d,p]of Object.entries(u)){Object.prototype.hasOwnProperty.call(a,d)||vr(a,d,new Set);for(const m of p)a[d].add(m)}}return a}),t.options.forEach((s,a)=>{const c=df.get(s._zod.def);if(c&&!Object.prototype.hasOwnProperty.call(c,t.discriminator))throw new Error(`Invalid discriminated union option at index "${a}"`)});const o=_c(()=>{var c;const s=t.options,a=new Map;for(const u of s){const d=(c=u._zod.propValues)==null?void 0:c[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const p of d){if(a.has(p))throw new Error(`Duplicate discriminator value "${String(p)}"`);a.set(p,u)}}return a});e._zod.parse=(s,a)=>{const c=s.value;if(!ya(c))return s.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),s;const u=o.value.get(c==null?void 0:c[t.discriminator]);return u?u._zod.run(s,a):t.unionFallback||a.direction==="backward"?n(s,a):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:c,path:[t.discriminator],inst:e}),s)}}),XE=re("$ZodIntersection",(e,t)=>{en.init(e,t),e._zod.parse=(n,o)=>{const s=n.value,a=t.left._zod.run({value:s,issues:[]},o),c=t.right._zod.run({value:s,issues:[]},o);return a instanceof Promise||c instanceof Promise?Promise.all([a,c]).then(([d,p])=>hg(n,d,p)):hg(n,a,c)}});function ff(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(va(e)&&va(t)){const n=Object.keys(t),o=Object.keys(e).filter(a=>n.indexOf(a)!==-1),s={...e,...t};Object.prototype.hasOwnProperty.call(s,"__proto__")&&delete s.__proto__;for(const a of o){if(a==="__proto__")continue;const c=ff(e[a],t[a]);if(!c.valid)return{valid:!1,mergeErrorPath:[a,...c.mergeErrorPath]};s[a]=c.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const s=e[o],a=t[o],c=ff(s,a);if(!c.valid)return{valid:!1,mergeErrorPath:[o,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function hg(e,t,n){const o=new Map;let s;const a=new Map,c=(p,m)=>{var k,w;let g;if(p.code==="unrecognized_keys"&&!((k=p.path)!=null&&k.length))s??(s=p),g=p.keys;else if(p.code==="invalid_key"&&p.origin==="record"&&((w=p.path)==null?void 0:w.length)===1){const b=String(p.path[0]);a.has(b)||a.set(b,p),g=[b]}else return!1;for(const b of g)o.has(b)||o.set(b,{}),o.get(b)[m]=!0;return!0};for(const p of t.issues)c(p,"l")||e.issues.push(p);for(const p of n.issues)c(p,"r")||e.issues.push(p);const u=[...o].filter(([,p])=>p.l&&p.r).map(([p])=>p);if(u.length){const p=s?u.filter(m=>s.keys.includes(m)):[];p.length&&e.issues.push({...s,keys:p});for(const m of u)!p.includes(m)&&a.has(m)&&e.issues.push(a.get(m))}const d=ff(t.value,n.value);if(!d.valid){if(cs(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(d.mergeErrorPath)}`)}return e.value=d.data,e}const JE=re("$ZodTuple",(e,t)=>{en.init(e,t);const n=t.items,o=ao.memoizer;o==null||o.attach(e),e._zod.parse=(s,a)=>{const c=s.value;if(!Array.isArray(c))return s.issues.push({input:c,inst:e,expected:"tuple",code:"invalid_type"}),s;s.value=o?o.alloc(e,s,[],a):[];const u=[],d=mg(n,"optin"),p=mg(n,"optout");if(!t.rest){if(c.length<d)return s.issues.push({code:"too_small",minimum:d,inclusive:!0,input:c,inst:e,origin:"array"}),s;c.length>n.length&&s.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:c,inst:e,origin:"array"})}const m=new Array(n.length);for(let g=0;g<n.length;g++){const k=n[g]._zod.run({value:c[g],issues:[]},a);k instanceof Promise?u.push(k.then(w=>{m[g]=w})):m[g]=k}if(t.rest){let g=n.length-1;const k=c.slice(n.length);for(const w of k){g++;const b=t.rest._zod.run({value:w,issues:[]},a);b instanceof Promise?u.push(b.then(_=>gg(_,s,g))):gg(b,s,g)}}return u.length?Promise.all(u).then(()=>kg(m,s,n,c,p)):kg(m,s,n,c,p)}});function mg(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 gg(e,t,n){e.issues.length&&t.issues.push(...Ec(n,e.issues)),t.value[n]=e.value}function kg(e,t,n,o,s){for(let a=0;a<n.length;a++){const c=e[a],u=a<o.length;if(!u&&a>=s&&n[a]._zod.optin==="optional"){t.value.length=a;break}if(c.issues.length){if(!u&&a>=s){t.value.length=a;break}t.issues.push(...Ec(a,c.issues))}t.value[a]=c.value}for(let a=t.value.length-1;a>=o.length&&(n[a]._zod.optout==="optional"&&t.value[a]===void 0);a--)t.value.length=a;return t}const eS=re("$ZodEnum",(e,t)=>{en.init(e,t);const n=Sy(t.entries),o=new Set(n);e._zod.values=o;const s=n.filter(a=>F1.has(typeof a));e._zod.pattern=new RegExp(s.length?`^(${s.map(a=>gs(a.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(a,c)=>{const u=a.value;return o.has(u)||a.issues.push({code:"invalid_value",values:n,input:u,inst:e}),a}}),tS=re("$ZodLiteral",(e,t)=>{en.init(e,t);const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(t.values.length?`^(${t.values.map(o=>typeof o=="string"?gs(o):o?gs(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(o,s)=>{const a=o.value;return n.has(a)||o.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),o}}),nS=re("$ZodTransform",(e,t)=>{var n;en.init(e,t),e._zod.optin="optional",(n=ao.memoizer)==null||n.guard(e),e._zod.parse=(o,s)=>{if(s.direction==="backward")throw new Ry(e.constructor.name);const a=t.transform(o.value,o);if(s.async)return(a instanceof Promise?a:Promise.resolve(a)).then(u=>(o.value=u,o));if(a instanceof Promise)throw new ps;return o.value=a,o}});function yg(e,t){return e.value=t.issues.length?void 0:t.value,e}const Vy=re("$ZodOptional",(e,t)=>{en.init(e,t),Mt(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Mt(e,"values",n=>{const o=n.def.innerType._zod.values;return o?new Set([...o,void 0]):void 0}),Mt(e,"pattern",n=>{const o=n.def.innerType._zod.pattern;return o?new RegExp(`^(${Uf(o.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const s=t.innerType._zod.run({value:n.value,issues:[]},o);return s instanceof Promise?s.then(a=>yg(n,a)):yg(n,s)}return t.innerType._zod.run(n,o)}}),rS=re("$ZodExactOptional",(e,t)=>{Vy.init(e,t),Mt(e,"values",n=>n.def.innerType._zod.values),Mt(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),oS=re("$ZodNullable",(e,t)=>{en.init(e,t),Mt(e,"optin",n=>n.def.innerType._zod.optin),Mt(e,"optout",n=>n.def.innerType._zod.optout),Mt(e,"pattern",n=>{const o=n.def.innerType._zod.pattern;return o?new RegExp(`^(${Uf(o.source)}|null)$`):void 0}),Mt(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),iS=re("$ZodDefault",(e,t)=>{en.init(e,t),e._zod.optin="defaulted",Mt(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(a=>vg(a,t)):vg(s,t)}});function vg(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const sS=re("$ZodPrefault",(e,t)=>{en.init(e,t),e._zod.optin="defaulted",Mt(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),aS=re("$ZodNonOptional",(e,t)=>{en.init(e,t),Mt(e,"values",n=>{const o=n.def.innerType._zod.values;return o?new Set([...o].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,o)=>{const s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(a=>wg(a,e)):wg(s,e)}});function wg(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 bg(e,t,n,o){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(s=>vs(s,o,li()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const lS=re("$ZodCatch",(e,t)=>{en.init(e,t),Mt(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Mt(e,"optout",n=>n.def.innerType._zod.optout),Mt(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const s=t.innerType._zod.run({value:n.value,issues:[]},o);return s instanceof Promise?s.then(a=>bg(n,a,t,o)):bg(n,s,t,o)}}),cS=re("$ZodPipe",(e,t)=>{en.init(e,t),Mt(e,"values",n=>n.def.in._zod.values),Mt(e,"optin",n=>n.def.in._zod.optin),Mt(e,"optout",n=>n.def.out._zod.optout),Mt(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const a=t.out._zod.run(n,o);return a instanceof Promise?a.then(c=>Pl(c,t.in,o)):Pl(a,t.in,o)}const s=t.in._zod.run(n,o);return s instanceof Promise?s.then(a=>Pl(a,t.out,o)):Pl(s,t.out,o)}});function Pl(e,t,n){return e.issues.some(o=>o.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const uS=re("$ZodReadonly",(e,t)=>{en.init(e,t),Mt(e,"propValues",n=>n.def.innerType._zod.propValues),Mt(e,"values",n=>n.def.innerType._zod.values),Mt(e,"optin",n=>{var o,s;return(s=(o=n.def.innerType)==null?void 0:o._zod)==null?void 0:s.optin}),Mt(e,"optout",n=>{var o,s;return(s=(o=n.def.innerType)==null?void 0:o._zod)==null?void 0:s.optout}),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const s=t.innerType._zod.run(n,o);return s instanceof Promise?s.then(xg):xg(s)}});function xg(e){return e.memo||(e.value=Object.freeze(e.value)),e}const dS=re("$ZodCustom",(e,t)=>{br.init(e,t),en.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,s=t.fn(o);if(s instanceof Promise)return s.then(a=>_g(a,n,o,e));_g(s,n,o,e)}});function _g(e,t,n,o){if(!e){const s={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(s.params=o._zod.def.params),t.issues.push(wa(s))}}class fS extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const pf="~memo",Eg=[];function Rd(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Sg=new WeakMap;function Gy(e,t){const n=Sg.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let o=!1;const s=u=>{!o&&(u!=null&&u._zod)&&Gy(u,t)&&(o=!0)},a=e._zod.def;switch(a.type){case"object":{for(const u of Reflect.ownKeys(a.shape))s(a.shape[u]);s(a.catchall);break}case"array":s(a.element);break;case"tuple":for(const u of a.items)s(u);s(a.rest);break;case"record":case"map":s(a.keyType),s(a.valueType);break;case"set":s(a.valueType);break;case"union":for(const u of a.options)s(u);break;case"intersection":s(a.left),s(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(a.innerType);break;case"pipe":s(a.in),s(a.out);break;case"function":s(a.input),s(a.output);break;case"lazy":s(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 u in a){const d=Object.getOwnPropertyDescriptor(a,u);if(!d||d.get)continue;const p=d.value;if(!(!p||typeof p!="object")){if(p._zod)s(p);else if(Array.isArray(p))for(const m of p)s(m)}}}return t.delete(e),Sg.set(e,o),o}function pS(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let Ll;const zl=[],hS={alloc(e,t,n){const o=Ll;if(!o)return n;Ll=void 0;const s={value:n,issues:null};return o.set(t.value,s),zl.push(s),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,o=(s,a)=>{if(a.direction!=="backward"&&gS(a,s.value))throw new fS;return n(s,a)};e._zod.parse=o,e._zod.run===n&&(e._zod.run=o)})},attach(e){var t;let n,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const a=e._zod.parse,c=(u,d)=>{if(n===void 0&&(n=Gy(e,new Set),!n))return e._zod.parse=a,e._zod.run===c&&(e._zod.run=a),a(u,d);const p=u.value;if(p===null||typeof p!="object")return a(u,d);let m=d[pf];m||(m={buckets:new Map,backEdges:void 0},d[pf]=m);let g;o===d?g=s:(g=pS(m,e),o=d,s=g);const k=g.get(p);if(k)return u.value=k.value,k.issues?k.issues.length&&u.issues.push(...Rd(k.issues)):(u.memo=!0,m.backEdges??(m.backEdges=new Set),m.backEdges.add(k.value)),u;Ll=g;const w=zl.length,b=a(u,d);Ll=void 0;const _=zl.length>w?zl.pop():void 0;return b instanceof Promise?b.then(I=>(_&&(_.issues=I.issues.length?Rd(I.issues):Eg),I)):(_&&(_.issues=b.issues.length?Rd(b.issues):Eg),b)};e._zod.parse=c,e._zod.run===a&&(e._zod.run=c)})}};function mS(){return hS}function gS(e,t){var o;const n=(o=e[pf])==null?void 0:o.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const kS=()=>{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(a){return e[a]??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"},o={nan:"NaN"};function s(a,c){return a==="number"&&typeof c=="number"&&!Number.isFinite(c)?String(c):o[a]??a}return a=>{switch(a.code){case"invalid_type":{const c=s(a.expected),u=Q1(a.input),d=s(u,a.input);return`Invalid input: expected ${c}, received ${d}`}case"invalid_value":return a.values.length===1?`Invalid input: expected ${Iy(a.values[0])}`:`Invalid option: expected one of ${og(a.values,"|")}`;case"too_big":{const c=a.exact?"exactly ":a.inclusive?"<=":"<",u=t(a.origin);return u?`Too big: expected ${a.origin??"value"} to have ${c}${a.maximum.toString()} ${u.unit??"elements"}`:`Too big: expected ${a.origin??"value"} to be ${c}${a.maximum.toString()}`}case"too_small":{const c=a.exact?"exactly ":a.inclusive?">=":">",u=t(a.origin);return u?`Too small: expected ${a.origin} to have ${c}${a.minimum.toString()} ${u.unit}`:`Too small: expected ${a.origin} to be ${c}${a.minimum.toString()}`}case"invalid_format":{const c=a;return c.format==="starts_with"?`Invalid string: must start with "${c.prefix}"`:c.format==="ends_with"?`Invalid string: must end with "${c.suffix}"`:c.format==="includes"?`Invalid string: must include "${c.includes}"`:c.format==="regex"?`Invalid string: must match pattern ${c.pattern}`:`Invalid ${n[c.format]??a.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${a.divisor}`;case"unrecognized_keys":return`Unrecognized key${a.keys.length>1?"s":""}: ${og(a.keys,", ")}`;case"invalid_key":return`Invalid key in ${a.origin}`;case"invalid_union":return a.options&&Array.isArray(a.options)&&a.options.length>0?`Invalid discriminator value. Expected ${a.options.map(u=>`'${u}'`).join(" | ")}`:a.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${a.origin}`;default:return"Invalid input"}}};function yS(){return{localeError:kS()}}var Ng;class vS{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.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 o={...this.get(n)??{}};delete o.id;const s={...o,...this._map.get(t)};return Object.keys(s).length?s:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function wS(){return new vS}(Ng=globalThis).__zod_globalRegistry??(Ng.__zod_globalRegistry=wS());const aa=globalThis.__zod_globalRegistry;function bS(e,t){return new e({type:"string",...Fe(t)})}function xS(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Fe(t)})}function _S(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Fe(t)})}function ES(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Fe(t)})}function SS(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Fe(t)})}function NS(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Fe(t)})}function TS(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Fe(t)})}function IS(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Fe(t)})}function OS(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Fe(t)})}function RS(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Fe(t)})}function CS(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Fe(t)})}function jS(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Fe(t)})}function AS(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Fe(t)})}function $S(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Fe(t)})}function MS(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Fe(t)})}function PS(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Fe(t)})}function LS(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Fe(t)})}function zS(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Fe(t)})}function DS(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Fe(t)})}function FS(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Fe(t)})}function US(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Fe(t)})}function BS(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Fe(t)})}function ZS(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Fe(t)})}function HS(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Fe(t)})}function WS(e,t){return new e({type:"string",format:"date",check:"string_format",...Fe(t)})}function KS(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Fe(t)})}function VS(e,t){return new e({type:"string",format:"duration",check:"string_format",...Fe(t)})}function GS(e,t){return new e({type:"number",checks:[],...Fe(t)})}function qS(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Fe(t)})}function YS(e,t){return new e({type:"boolean",...Fe(t)})}function QS(e){return new e({type:"unknown"})}function XS(e,t){return new e({type:"never",...Fe(t)})}function Tg(e,t){return new Py({check:"less_than",...Fe(t),value:e,inclusive:!1})}function Cd(e,t){return new Py({check:"less_than",...Fe(t),value:e,inclusive:!0})}function Ig(e,t){return new Ly({check:"greater_than",...Fe(t),value:e,inclusive:!1})}function jd(e,t){return new Ly({check:"greater_than",...Fe(t),value:e,inclusive:!0})}function Og(e,t){return new Q_({check:"multiple_of",...Fe(t),value:e})}function qy(e,t){return new J_({check:"max_length",...Fe(t),maximum:e})}function sc(e,t){return new eE({check:"min_length",...Fe(t),minimum:e})}function Yy(e,t){return new tE({check:"length_equals",...Fe(t),length:e})}function JS(e,t){return new nE({check:"string_format",format:"regex",...Fe(t),pattern:e})}function eN(e){return new rE({check:"string_format",format:"lowercase",...Fe(e)})}function tN(e){return new oE({check:"string_format",format:"uppercase",...Fe(e)})}function nN(e,t){return new iE({check:"string_format",format:"includes",...Fe(t),includes:e})}function rN(e,t){return new sE({check:"string_format",format:"starts_with",...Fe(t),prefix:e})}function oN(e,t){return new aE({check:"string_format",format:"ends_with",...Fe(t),suffix:e})}function ws(e){return new lE({check:"overwrite",tx:e})}function iN(e){return ws(t=>t.normalize(e))}function sN(){return ws(e=>e.trim())}function aN(){return ws(e=>e.toLowerCase())}function lN(){return ws(e=>e.toUpperCase())}function cN(){return ws(e=>z1(e))}function uN(e,t,n){return new e({type:"array",element:t,...Fe(n)})}function dN(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Fe(n)})}function fN(e,t){const n=pN(o=>(o.addIssue=s=>{if(typeof s=="string")o.issues.push(wa(s,o.value,n._zod.def));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=o.value),a.inst??(a.inst=n),a.continue??(a.continue=!n._zod.def.abort),o.issues.push(wa(a))}},e(o.value,o)),t);return n}function pN(e,t){const n=new br({check:"custom",...Fe(t)});return n._zod.check=e,n}function pa(e,...t){for(const n of t)for(const o of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,o)&&vr(e,o,n[o]);return e}function Qy(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)??aa,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",intersections:[],deferred:[],external:(e==null?void 0:e.external)??void 0}}function ii(e,t,n,o,s){const a=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:o.path,message:s}):t.unrepresentable;if(a==="any")return!1;if(a===void 0||a==="throw")throw new Error(s);return Object.assign(n,a),!0}function On(e,t,n={path:[],schemaPath:[]}){var m,g;var o;const s=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;const c={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,c),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const u=(g=(m=e._zod).toJSONSchema)==null?void 0:g.call(m);if(u)c.schema=u;else{const k={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,k);else{const b=c.schema,_=t.processors[s.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);_(e,t,b,k)}const w=e._zod.parent;w&&(c.ref||(c.ref=w),On(w,t,k),t.seen.get(w).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&pa(c.schema,d),t.io==="input"&&sr(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&"_prefault"in c.schema&&((o=c.schema).default??(o.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function Rg(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Xy(e,t){var c,u,d,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 o=new Map;for(const m of e.seen.entries()){const g=(c=e.metadataRegistry.get(m[0]))==null?void 0:c.id;if(g){const k=o.get(g);if(k&&k!==m[0])throw new Error(`Duplicate schema id "${g}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(g,m[0])}}const s=m=>{var _;const g=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const I=(_=e.external.registry.get(m[0]))==null?void 0:_.id,C=e.external.uri??(Z=>Z);if(I)return{ref:C(I)};const E=m[1].defId??m[1].schema.id??`schema${e.counter++}`;return m[1].defId=E,{defId:E,ref:`${C("__shared")}#/${g}/${Rg(E)}`}}const k="#",w=`${k}/${g}/`;if(m[1]===n&&!m[1].schema.id)return{ref:k};const b=m[1].schema.id??`__schema${e.counter++}`;return{defId:b,ref:w+Rg(b)}},a=m=>{if(m[1].schema.$ref)return;const g=m[1],{ref:k,defId:w}=s(m);g.def={...g.schema},w&&(g.defId=w);const b=g.schema;for(const _ in b)delete b[_];b.$ref=k};if(e.cycles==="throw")for(const m of e.seen.entries()){const g=m[1];if(g.cycle)throw new Error(`Cycle detected: #/${(u=g.cycle)==null?void 0:u.join("/")}/<root>
71
-
72
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const m of e.seen.entries()){const g=m[1];if(t===m[0]){a(m);continue}if(e.external){const w=(d=e.external.registry.get(m[0]))==null?void 0:d.id;if(t!==m[0]&&w){a(m);continue}}if((p=e.metadataRegistry.get(m[0]))==null?void 0:p.id){a(m);continue}if(g.cycle){a(m);continue}if(g.count>1&&e.reused==="ref"){a(m);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Jy(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const o of t){if(!o||typeof o!="object")return;Jy(o);const s=Object.keys(o);if(s.length!==1||s[0]!=="type")return;const a=o.type;for(const c of Array.isArray(a)?a:[a]){if(typeof c!="string")return;n.includes(c)||n.push(c)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const ev=new Set(["type","properties","required","additionalProperties"]),Cg=["oneOf","anyOf"];function jg(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function hf(e){var a;const t=[];for(const c of e){if(typeof c!="object"||c.type!=="object")return null;for(const u in c)if(!ev.has(u))return null;t.push(c)}const n={},o=new Set;for(const c of t){for(const u in c.properties){if(Object.prototype.hasOwnProperty.call(n,u))continue;const d=[];for(const m of t){const g=((a=m.properties)==null?void 0:a[u])??jg(m);g!=null&&(d.some(k=>JSON.stringify(k)===JSON.stringify(g))||d.push(g))}const p=d.length===1?d[0]:hf(d)??{allOf:d};vr(n,u,p)}for(const u of c.required??[])o.add(u)}const s={type:"object",properties:n};if(o.size&&(s.required=[...o]),t.every(c=>c.additionalProperties===!1))s.additionalProperties=!1;else{const c=[];for(const u of t){const d=jg(u);d&&!c.some(p=>JSON.stringify(p)===JSON.stringify(d))&&c.push(d)}c.length===1?s.additionalProperties=c[0]:c.length>1&&(s.additionalProperties={allOf:c})}return s}function hN(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const s of ev)if(s in e)return;const n=t.filter(s=>Cg.some(a=>Array.isArray(s[a])));let o=null;if(!n.length)o=hf(t);else{const s=n[0],a=Cg.find(d=>Array.isArray(s[d]));if(Object.keys(s).length!==1)return;const c=t.filter(d=>d!==s),u=s[a].map(d=>hf([...c,d]));if(u.some(d=>!d))return;o={[a]:u}}o&&(delete e.allOf,pa(e,o))}function tv(e,t){var u,d,p,m;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=g=>{const k=e.seen.get(g);if(k.ref===null)return;const w=k.def??k.schema,b={...w},_=k.ref;if(k.ref=null,_){o(_);const C=e.seen.get(_),E=C.schema;if(E.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(w.allOf=w.allOf??[],w.allOf.push(E)):pa(w,E),pa(w,b),g._zod.parent===_)for(const M in w)M==="$ref"||M==="allOf"||M in b||delete w[M];if(E.$ref&&C.def)for(const M in w)M==="$ref"||M==="allOf"||M in C.def&&JSON.stringify(w[M])===JSON.stringify(C.def[M])&&delete w[M]}const I=g._zod.parent;if(I&&I!==_){o(I);const C=e.seen.get(I);if(C!=null&&C.schema.$ref&&(w.$ref=C.schema.$ref,C.def))for(const E in w)E==="$ref"||E==="allOf"||E in C.def&&JSON.stringify(w[E])===JSON.stringify(C.def[E])&&delete w[E]}e.override({zodSchema:g,jsonSchema:w,path:k.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const g of[...e.seen.entries()].reverse())o(g[0]);if(e.target!=="openapi-3.0")for(const g of e.seen.entries())Jy(g[1].def??g[1].schema);for(const g of e.deferred)g();if(e.intersections.length){const g=new Map;for(const k of e.seen.values())for(const w of[k.schema,k.def]){const b=w==null?void 0:w.allOf;if(!Array.isArray(b))continue;const _=g.get(b);_?_.push(w):g.set(b,[w])}for(const k of e.intersections)for(const w of g.get(k)??[])hN(w)}}const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,(u=e.external)!=null&&u.uri){const g=(d=e.external.registry.get(t))==null?void 0:d.id;if(!g)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(g)}pa(s,n.defId?n.schema:n.def??n.schema);const a=(p=e.metadataRegistry.get(t))==null?void 0:p.id;a!==void 0&&s.id===a&&delete s.id;const c=((m=e.external)==null?void 0:m.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const g of e.seen.entries()){const k=g[1];k.def&&k.defId&&(k.def.id===k.defId&&delete k.def.id,vr(c,k.defId,k.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?s.$defs=c:s.definitions=c);try{const g=JSON.parse(JSON.stringify(s));return Object.defineProperty(g,"~standard",{value:{...t["~standard"],jsonSchema:{input:ac(t,"input",e.processors),output:ac(t,"output",e.processors)}},enumerable:!1,writable:!1}),g}catch{throw new Error("Error converting schema to JSON.")}}function sr(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return sr(o.element,n);if(o.type==="set")return sr(o.valueType,n);if(o.type==="lazy")return sr(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return sr(o.innerType,n);if(o.type==="intersection")return sr(o.left,n)||sr(o.right,n);if(o.type==="record"||o.type==="map")return sr(o.keyType,n)||sr(o.valueType,n);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:sr(o.in,n)||sr(o.out,n);if(o.type==="object"){for(const s in o.shape)if(sr(o.shape[s],n))return!0;return!1}if(o.type==="union"){for(const s of o.options)if(sr(s,n))return!0;return!1}if(o.type==="tuple"){for(const s of o.items)if(sr(s,n))return!0;return!!(o.rest&&sr(o.rest,n))}return!1}const mN=(e,t={})=>n=>{const o=Qy({...n,processors:t});return On(e,o),Xy(o,e),tv(o,e)},ac=(e,t,n={})=>o=>{const{libraryOptions:s,target:a}=o??{},c=Qy({...s??{},target:a,io:t,processors:n});return On(e,c),Xy(c,e),tv(c,e)},gN={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},kN=(e,t,n,o)=>{const s=n;s.type="string";const{minimum:a,maximum:c,format:u,patterns:d,contentEncoding:p,laxFormat:m}=e._zod.bag;if(typeof a=="number"&&(s.minLength=a),typeof c=="number"&&(s.maxLength=c),u&&(s.format=gN[u]??u,s.format===""&&delete s.format,(u==="time"||m)&&delete s.format),p&&(s.contentEncoding=p),d&&d.size>0){const g=[...d];g.length===1?s.pattern=g[0].source:g.length>1&&(s.allOf=[...g.map(k=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:k.source}))])}},yN=(e,t,n,o)=>{const s=n,{minimum:a,maximum:c,format:u,multipleOf:d,exclusiveMaximum:p,exclusiveMinimum:m}=e._zod.bag;typeof u=="string"&&u.includes("int")?s.type="integer":s.type="number";const g=typeof m=="number"&&m>=(a??Number.NEGATIVE_INFINITY),k=typeof p=="number"&&p<=(c??Number.POSITIVE_INFINITY),w=t.target==="draft-04"||t.target==="openapi-3.0";g?w?(s.minimum=m,s.exclusiveMinimum=!0):s.exclusiveMinimum=m:typeof a=="number"&&(s.minimum=a),k?w?(s.maximum=p,s.exclusiveMaximum=!0):s.exclusiveMaximum=p:typeof c=="number"&&(s.maximum=c),typeof d=="number"&&(Number.isFinite(d)&&d!==0?s.multipleOf=Math.abs(d):ii(e,t,s,o,`A multipleOf divisor of ${d} cannot be represented in JSON Schema`))},vN=(e,t,n,o)=>{n.type="boolean"},wN=(e,t,n,o)=>{n.not={}},bN=(e,t,n,o)=>{},xN=(e,t,n,o)=>{const s=e._zod.def,a=Sy(s.entries);if(a.length===0){n.not={};return}a.every(c=>typeof c=="number")&&(n.type="number"),a.every(c=>typeof c=="string")&&(n.type="string"),n.enum=a},_N=(e,t,n,o)=>{const s=e._zod.def;if(s.values.length===0){n.not={};return}const a=[];for(const c of s.values)if(c===void 0){if(ii(e,t,n,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof c=="bigint"){if(ii(e,t,n,o,"BigInt literals cannot be represented in JSON Schema"))return;a.push(Number(c))}else a.push(c);if(a.length!==0)if(a.length===1){const c=a[0];n.type=c===null?"null":typeof c,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[c]:n.const=c}else a.every(c=>typeof c=="number")&&(n.type="number"),a.every(c=>typeof c=="string")&&(n.type="string"),a.every(c=>typeof c=="boolean")&&(n.type="boolean"),a.every(c=>c===null)&&(n.type="null"),n.enum=a},EN=(e,t,n,o)=>{ii(e,t,n,o,"Custom types cannot be represented in JSON Schema")},SN=(e,t,n,o)=>{ii(e,t,n,o,"Transforms cannot be represented in JSON Schema")},NN=(e,t,n,o)=>{const s=n,a=e._zod.def,{minimum:c,maximum:u}=e._zod.bag;typeof c=="number"&&(s.minItems=c),typeof u=="number"&&(s.maxItems=u),s.type="array",s.items=On(a.element,t,{...o,path:[...o.path,"items"]})};function lc(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?lc(t.out):t.type==="catch"?lc(t.innerType):e._zod.optin}const TN=(e,t,n,o)=>{var m;const s=n,a=e._zod.def,c=a.shape;if(Object.getOwnPropertySymbols(c).length&&ii(e,t,s,o,"Symbol keys cannot be represented in JSON Schema"))return;s.type="object",s.properties={};for(const g in c)vr(s.properties,g,On(c[g],t,{...o,path:[...o.path,"properties",g]}));const d=new Set(Object.keys(c)),p=new Set([...d].filter(g=>{const k=a.shape[g];return t.io==="input"?lc(k)===void 0:k._zod.optout===void 0}));p.size>0&&(s.required=Array.from(p)),((m=a.catchall)==null?void 0:m._zod.def.type)==="never"?s.additionalProperties=!1:a.catchall?a.catchall&&(s.additionalProperties=On(a.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},IN=(e,t,n,o)=>{const s=e._zod.def,a=s.inclusive===!1,c=s.options.map((u,d)=>On(u,t,{...o,path:[...o.path,a?"oneOf":"anyOf",d]}));a?n.oneOf=c:n.anyOf=c},ON=(e,t,n,o)=>{const s=e._zod.def,a=On(s.left,t,{...o,path:[...o.path,"allOf",0]}),c=On(s.right,t,{...o,path:[...o.path,"allOf",1]}),u=p=>"allOf"in p&&Object.keys(p).length===1,d=[...u(a)?a.allOf:[a],...u(c)?c.allOf:[c]];n.allOf=d,t.intersections.push(d)},RN=(e,t,n,o)=>{const s=n,a=e._zod.def;s.type="array";const c=t.target==="draft-2020-12"?"prefixItems":"items",u=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",d=a.items.map((_,I)=>On(_,t,{...o,path:[...o.path,c,I]})),p=a.rest?On(a.rest,t,{...o,path:[...o.path,u,...t.target==="openapi-3.0"?[a.items.length]:[]]}):null;let m=a.items.length;for(;m>0;){const _=a.items[m-1];if(!(t.io==="input"?lc(_)!==void 0:_._zod.optout==="optional"))break;m--}const g=a.items.length,k=!a.rest;t.target==="draft-2020-12"?(s.prefixItems=d,k?s.items=!1:p&&(s.items=p),m>0&&(s.minItems=m),k&&(s.maxItems=g)):t.target==="openapi-3.0"?(s.items={anyOf:d},p&&s.items.anyOf.push(p),m>0&&(s.minItems=m),k&&(s.maxItems=g)):(s.items=d,k?s.additionalItems=!1:p&&(s.additionalItems=p),m>0&&(s.minItems=m),k&&(s.maxItems=g));const{minimum:w,maximum:b}=e._zod.bag;typeof w=="number"&&(s.minItems=w),typeof b=="number"&&(s.maxItems=b)},CN=(e,t,n,o)=>{const s=e._zod.def,a=On(s.innerType,t,o),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=s.innerType,n.nullable=!0):n.anyOf=[a,{type:"null"}]},jN=(e,t,n,o)=>{const s=e._zod.def;On(s.innerType,t,o);const a=t.seen.get(e);a.ref=s.innerType},Gf=Symbol();function nv(e,t,n,o,s){let a=!1;const c=JSON.stringify(e,(u,d)=>typeof d!="bigint"?d:(a=!0,null));return a?(ii(t,n,o,s,"BigInt defaults cannot be represented in JSON Schema"),Gf):JSON.parse(c)}const AN=(e,t,n,o)=>{const s=e._zod.def;On(s.innerType,t,o);const a=t.seen.get(e);a.ref=s.innerType;const c=nv(s.defaultValue,e,t,n,o);c!==Gf&&(n.default=c)},$N=(e,t,n,o)=>{const s=e._zod.def;On(s.innerType,t,o);const a=t.seen.get(e);if(a.ref=s.innerType,t.io!=="input")return;const c=nv(s.defaultValue,e,t,n,o);c!==Gf&&(n._prefault=c)},MN=(e,t,n,o)=>{const s=e._zod.def;On(s.innerType,t,o);const a=t.seen.get(e);a.ref=s.innerType;let c;try{c=s.catchValue(void 0)}catch{ii(e,t,n,o,"Dynamic catch values are not supported in JSON Schema");return}n.default=c},PN=(e,t,n,o)=>{const s=e._zod.def,a=s.in._zod.traits.has("$ZodTransform"),c=t.io==="input"?a?s.out:s.in:s.out;On(c,t,o);const u=t.seen.get(e);u.ref=c},LN=(e,t,n,o)=>{const s=e._zod.def;On(s.innerType,t,o);const a=t.seen.get(e);a.ref=s.innerType,n.readOnly=!0},rv=(e,t,n,o)=>{const s=e._zod.def;On(s.innerType,t,o);const a=t.seen.get(e);a.ref=s.innerType},Ag=new WeakSet([Object.prototype,Error.prototype]);function Dl(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const o=n(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}const zN=(e,t)=>{jy.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Ag.has(n)||(Ag.add(n),Dl(n,"format",o=>s=>d_(o,s)),Dl(n,"flatten",o=>s=>u_(o,s)),Dl(n,"addIssue",o=>s=>{o.issues.push(s),o.message=JSON.stringify(o.issues,cf,2)}),Dl(n,"addIssues",o=>s=>{o.issues.push(...s),o.message=JSON.stringify(o.issues,cf,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Wr=re("ZodError",zN,void 0,{Parent:Error}),DN=Hf(Wr),FN=Wf(Wr),UN=Nc(Wr),BN=Tc(Wr),ZN=h_(Wr),HN=m_(Wr),WN=g_(Wr),KN=k_(Wr),VN=y_(Wr),GN=v_(Wr),qN=w_(Wr),YN=b_(Wr);function QN(){ao.localeError||li(yS())}function Oc(){ao.memoizer||li({memoizer:mS()})}const un=re("ZodType",(e,t)=>(QN(),en.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(si(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 ai(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(YT(e,t))},superRefine(e,t){return this.check(QT(e,t))},overwrite(e){return this.check(ws(e))},optional(){return Pg(this)},exactOptional(){return LT(this)},nullable(){return Lg(this)},nullish(){return Pg(Lg(this))},nonoptional(e){return ZT(this,e)},array(){return ba(this)},or(e){return IT([this,e])},and(e){return jT(this,e)},transform(e){return zg(this,PT(e))},default(e){return FT(this,e)},prefault(e){return BT(this,e)},catch(e){return WT(this,e)},pipe(e){return zg(this,e)},readonly(){return GT(this)},describe(e){const t=this.clone();return aa.add(t,{description:e}),t},meta(...e){if(e.length===0)return aa.get(this);const t=this.clone();return aa.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 Oy(this,"~standard",{...zy(this),jsonSchema:{input:ac(this,"input"),output:ac(this,"output")}})},set"~standard"(e){ks(this,"~standard",e)},parse:function e(t,n){return DN(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await FN(this,t,n,{callee:e})},safeParse(e,t){return UN(this,e,t)},async safeParseAsync(e,t){return BN(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){ks(this,"spa",e)},encode:function e(t,n){return ZN(this,t,n,{callee:e})},decode:function e(t,n){return HN(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await WN(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await KN(this,t,n,{callee:e})},safeEncode(e,t){return VN(this,e,t)},safeDecode(e,t){return GN(this,e,t)},async safeEncodeAsync(e,t){return qN(this,e,t)},async safeDecodeAsync(e,t){return YN(this,e,t)},toJSONSchema(e){return mN(this,{})(e)},get description(){var e;return(e=aa.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),ov=re("_ZodString",(e,t)=>{Vf.init(e,t),un.init(e,t),e._zod.processJSONSchema=(o,s,a)=>kN(e,o,s);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(JS(...e))},includes(...e){return this.check(nN(...e))},startsWith(...e){return this.check(rN(...e))},endsWith(...e){return this.check(oN(...e))},min(...e){return this.check(sc(...e))},max(...e){return this.check(qy(...e))},length(...e){return this.check(Yy(...e))},nonempty(...e){return this.check(sc(1,...e))},lowercase(e){return this.check(eN(e))},uppercase(e){return this.check(tN(e))},trim(){return this.check(sN())},normalize(...e){return this.check(iN(...e))},toLowerCase(){return this.check(aN())},toUpperCase(){return this.check(lN())},slugify(){return this.check(cN())}}),XN=re("ZodString",(e,t)=>{Vf.init(e,t),ov.init(e,t)},{email(e){return this.check(xS(rT,e))},url(e){return this.check(IS(iT,e))},jwt(e){return this.check(ZS(wT,e))},emoji(e){return this.check(OS(sT,e))},guid(e){return this.check(_S(oT,e))},uuid(e){return this.check(ES(Fl,e))},uuidv4(e){return this.check(SS(Fl,e))},uuidv6(e){return this.check(NS(Fl,e))},uuidv7(e){return this.check(TS(Fl,e))},nanoid(e){return this.check(RS(aT,e))},cuid(e){return this.check(CS(lT,e))},cuid2(e){return this.check(jS(cT,e))},ulid(e){return this.check(AS(uT,e))},base64(e){return this.check(FS(kT,e))},base64url(e){return this.check(US(yT,e))},xid(e){return this.check($S(dT,e))},ksuid(e){return this.check(MS(fT,e))},ipv4(e){return this.check(PS(pT,e))},ipv6(e){return this.check(LS(hT,e))},cidrv4(e){return this.check(zS(mT,e))},cidrv6(e){return this.check(DS(gT,e))},e164(e){return this.check(BS(vT,e))},datetime(e){return this.check(HS(JN,e))},date(e){return this.check(WS(eT,e))},time(e){return this.check(KS(tT,e))},duration(e){return this.check(VS(nT,e))}});function Wt(e){return bS(XN,e)}const dn=re("ZodStringFormat",(e,t)=>{tn.init(e,t),ov.init(e,t)}),JN=re("ZodISODateTime",(e,t)=>{TE.init(e,t),dn.init(e,t)}),eT=re("ZodISODate",(e,t)=>{IE.init(e,t),dn.init(e,t)}),tT=re("ZodISOTime",(e,t)=>{OE.init(e,t),dn.init(e,t)}),nT=re("ZodISODuration",(e,t)=>{RE.init(e,t),dn.init(e,t)}),rT=re("ZodEmail",(e,t)=>{pE.init(e,t),dn.init(e,t)}),oT=re("ZodGUID",(e,t)=>{dE.init(e,t),dn.init(e,t)}),Fl=re("ZodUUID",(e,t)=>{fE.init(e,t),dn.init(e,t)}),iT=re("ZodURL",(e,t)=>{vE.init(e,t),dn.init(e,t)}),sT=re("ZodEmoji",(e,t)=>{wE.init(e,t),dn.init(e,t)}),aT=re("ZodNanoID",(e,t)=>{bE.init(e,t),dn.init(e,t)}),lT=re("ZodCUID",(e,t)=>{xE.init(e,t),dn.init(e,t)}),cT=re("ZodCUID2",(e,t)=>{_E.init(e,t),dn.init(e,t)}),uT=re("ZodULID",(e,t)=>{EE.init(e,t),dn.init(e,t)}),dT=re("ZodXID",(e,t)=>{SE.init(e,t),dn.init(e,t)}),fT=re("ZodKSUID",(e,t)=>{NE.init(e,t),dn.init(e,t)}),pT=re("ZodIPv4",(e,t)=>{CE.init(e,t),dn.init(e,t)}),hT=re("ZodIPv6",(e,t)=>{AE.init(e,t),dn.init(e,t)}),mT=re("ZodCIDRv4",(e,t)=>{$E.init(e,t),dn.init(e,t)}),gT=re("ZodCIDRv6",(e,t)=>{PE.init(e,t),dn.init(e,t)}),kT=re("ZodBase64",(e,t)=>{LE.init(e,t),dn.init(e,t)}),yT=re("ZodBase64URL",(e,t)=>{DE.init(e,t),dn.init(e,t)}),vT=re("ZodE164",(e,t)=>{FE.init(e,t),dn.init(e,t)}),wT=re("ZodJWT",(e,t)=>{BE.init(e,t),dn.init(e,t)}),iv=re("ZodNumber",(e,t)=>{Zy.init(e,t),un.init(e,t),e._zod.processJSONSchema=(o,s,a)=>yN(e,o,s,a);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(Ig(e,t))},gte(e,t){return this.check(jd(e,t))},min(e,t){return this.check(jd(e,t))},lt(e,t){return this.check(Tg(e,t))},lte(e,t){return this.check(Cd(e,t))},max(e,t){return this.check(Cd(e,t))},int(e){return this.check($g(e))},safe(e){return this.check($g(e))},positive(e){return this.check(Ig(0,e))},nonnegative(e){return this.check(jd(0,e))},negative(e){return this.check(Tg(0,e))},nonpositive(e){return this.check(Cd(0,e))},multipleOf(e,t){return this.check(Og(e,t))},step(e,t){return this.check(Og(e,t))},finite(){return this}});function Si(e){return GS(iv,e)}const bT=re("ZodNumberFormat",(e,t)=>{ZE.init(e,t),iv.init(e,t)});function $g(e){return qS(bT,e)}const xT=re("ZodBoolean",(e,t)=>{HE.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>vN(e,n,o)});function Ul(e){return YS(xT,e)}const _T=re("ZodUnknown",(e,t)=>{WE.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>bN()});function Mg(){return QS(_T)}const ET=re("ZodNever",(e,t)=>{KE.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>wN(e,n,o)});function ST(e){return XS(ET,e)}const NT=re("ZodArray",(e,t)=>{Oc(),VE.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>NN(e,n,o,s),e.element=t.element},{min(e,t){return this.check(sc(e,t))},nonempty(e){return this.check(sc(1,e))},max(e,t){return this.check(qy(e,t))},length(e,t){return this.check(Yy(e,t))},unwrap(){return this.element}});function ba(e,t){return uN(NT,e,t)}const TT=re("ZodObject",(e,t)=>{Oc(),YE.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>TN(e,n,o,s),n_(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return gf(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Mg()})},loose(){return this.clone({...this._zod.def,catchall:Mg()})},strict(){return this.clone({...this._zod.def,catchall:ST()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return W1(this,e)},safeExtend(e){return K1(this,e)},merge(e){return V1(this,e)},pick(e){return Z1(this,e)},omit(e){return H1(this,e)},partial(...e){return ig(qf,this,e[0])},exactPartial(...e){return ig(lv,this,e[0],"exactPartial")},required(...e){return G1(cv,this,e[0])}});function gr(e,t){const n={type:"object",shape:e??{},...Fe(t)};return new TT(n)}const sv=re("ZodUnion",(e,t)=>{Ky.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>IN(e,n,o,s),e.options=t.options});function IT(e,t){return new sv({type:"union",options:e,...Fe(t)})}const OT=re("ZodDiscriminatedUnion",(e,t)=>{sv.init(e,t),QE.init(e,t)});function RT(e,t,n){return new OT({type:"union",options:t,discriminator:e,...Fe(n)})}const CT=re("ZodIntersection",(e,t)=>{XE.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ON(e,n,o,s)});function jT(e,t){return new CT({type:"intersection",left:e,right:t})}const AT=re("ZodTuple",(e,t)=>{Oc(),JE.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>RN(e,n,o,s)},{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 qf({type:"optional",innerType:n}))})}});function av(e,t,n){const o=t instanceof en,s=o?n:t,a=o?t:null;return new AT({type:"tuple",items:e,rest:a,...Fe(s)})}const mf=re("ZodEnum",(e,t)=>{eS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(o,s,a)=>xN(e,o,s),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,s)=>{const a={};for(const c of o)if(n.has(c))a[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new mf({...t,checks:[],...Fe(s),entries:a})},e.exclude=(o,s)=>{const a={...t.entries};for(const c of o)if(n.has(c))delete a[c];else throw new Error(`Key ${c} not found in enum`);return new mf({...t,checks:[],...Fe(s),entries:a})}});function gf(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new mf({type:"enum",entries:n,...Fe(t)})}const $T=re("ZodLiteral",(e,t)=>{tS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>_N(e,n,o,s),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 Zr(e,t){return new $T({type:"literal",values:Array.isArray(e)?e:[e],...Fe(t)})}const MT=re("ZodTransform",(e,t)=>{Oc(),nS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>SN(e,n,o,s),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Ry(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(wa(a,n.value,t));else{const c=a;c.fatal&&(c.continue=!1),c.code??(c.code="custom"),"input"in c||(c.input=n.value),c.inst??(c.inst=e),n.issues.push(wa(c))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(a=>(n.value=a,n)):(n.value=s,n)}});function PT(e){return new MT({type:"transform",transform:e})}const qf=re("ZodOptional",(e,t)=>{Vy.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>rv(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function Pg(e){return new qf({type:"optional",innerType:e})}const lv=re("ZodExactOptional",(e,t)=>{rS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>rv(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function LT(e){return new lv({type:"optional",innerType:e})}const zT=re("ZodNullable",(e,t)=>{oS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>CN(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function Lg(e){return new zT({type:"nullable",innerType:e})}const DT=re("ZodDefault",(e,t)=>{iS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>AN(e,n,o,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function FT(e,t){return new DT({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ty(t)}})}const UT=re("ZodPrefault",(e,t)=>{sS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>$N(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function BT(e,t){return new UT({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ty(t)}})}const cv=re("ZodNonOptional",(e,t)=>{aS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>jN(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function ZT(e,t){return new cv({type:"nonoptional",innerType:e,...Fe(t)})}const HT=re("ZodCatch",(e,t)=>{lS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>MN(e,n,o,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function WT(e,t){return new HT({type:"catch",innerType:e,catchValue:typeof t=="function"?t:o_(t)})}const KT=re("ZodPipe",(e,t)=>{cS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>PN(e,n,o,s),e.in=t.in,e.out=t.out});function zg(e,t){return new KT({type:"pipe",in:e,out:t})}const VT=re("ZodReadonly",(e,t)=>{uS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>LN(e,n,o,s),e.unwrap=()=>e._zod.def.innerType});function GT(e){return new VT({type:"readonly",innerType:e})}const qT=re("ZodCustom",(e,t)=>{dS.init(e,t),un.init(e,t),e._zod.processJSONSchema=(n,o,s)=>EN(e,n,o,s)});function YT(e,t={}){return dN(qT,e,t)}function QT(e,t){return fN(e,t)}const XT=gr({component:Wt().nullable(),file:Wt().nullable(),line:Si().nullable(),callFile:Wt().nullable().default(null),callLine:Si().nullable().default(null),tag:Wt(),selector:Wt()}),JT=gr({tag:Wt().max(40),id:Wt().max(200),classes:ba(Wt().max(120)).max(16),text:Wt().max(200),attrs:ba(av([Wt().max(40),Wt().max(200)])).max(12)}),eI=av([Si(),Si()]),tI=XT.extend({classes:Wt(),text:Wt(),html:Wt(),route:Wt(),element:JT}),nI=RT("type",[gr({type:Zr("loaded"),url:Wt(),title:Wt()}),gr({type:Zr("navigated"),url:Wt(),title:Wt().optional()}),gr({type:Zr("title"),title:Wt()}),gr({type:Zr("links"),links:ba(gr({path:Wt().max(2048),text:Wt().max(120)})).max(200)}),gr({type:Zr("hmr")}),gr({type:Zr("page-error"),message:Wt(),source:Wt().optional(),line:Si().optional()}),tI.extend({type:Zr("picked"),verb:gf(["chat","code"]).default("chat"),site:gf(["call","source"]).default("source")}),gr({type:Zr("pick-cancel")}),gr({type:Zr("highlight-miss"),path:Wt(),fileMatched:Si(),withSource:Si(),ranges:ba(eI).nullable()}),gr({type:Zr("drag-files")}),gr({type:Zr("drop-files")}),gr({type:Zr("key"),key:Wt(),meta:Ul(),ctrl:Ul().optional(),shift:Ul().optional(),alt:Ul().optional()})]);function rI(e){const t=nI.safeParse(e);return t.success?t.data:null}const kf="shell",oI="check",iI="http://preview.invalid",sI=200;function Dg(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,sI).trim();return t||void 0}function Rc(e){let t;try{t=new URL(e,iI)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=Fg(t.pathname)||"/",o=t.hash.startsWith("#/")?Fg(t.hash.split("?")[0]??""):"";return o.length>1?`${n}${o}`:n}const Fg=e=>e.replace(/\/+$/,""),aI={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},cc=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function uv(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 o=/^\[\[([^\]]+)\]\]$/.exec(e)??/^:([\w-]+)\?$/.exec(e)??/^\{-\$([\w-]+)\}$/.exec(e);if(o)return{kind:"optional",name:o[1]};const s=/^\[([^\]=]+)(?:=[^\]]*)?\]$/.exec(e)??/^:([\w-]+)$/.exec(e)??/^\$([\w-]+)$/.exec(e);if(s)return{kind:"param",name:s[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 a=[];let c="",u=0;for(const p of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const m=e.slice(u,p.index);m&&(a.push({text:m}),c+=cc(m)),a.push({name:p[1]??p[2]??"param"}),c+="[^/]+?",u=(p.index??0)+p[0].length}const d=e.slice(u);if(d&&(a.push({text:d}),c+=cc(d)),a.some(p=>"name"in p))return{kind:"mixed",pattern:c,parts:a}}return{kind:"static",text:e}}function lI(e){const t=e.split("/").filter(Boolean).map(uv);if(t.every(o=>o.kind==="static"))return null;let n="";for(const o of t)o.kind==="static"?n+=`/${cc(o.text)}`:o.kind==="optional-static"?n+=`(?:/${cc(o.text)})?`:o.kind==="param"?n+="/[^/]+":o.kind==="optional"?n+="(?:/[^/]+)?":o.kind==="splat"?n+=o.min?"/.+":"(?:/.*)?":n+=`/${o.pattern}`;return{path:e,re:new RegExp(`^${n}$`),specificity:t.reduce((o,s)=>o+aI[s.kind],0),statics:t.filter(o=>o.kind==="static").length}}function cI(e,t){let n=null;for(const o of e)o.statics===0||!o.re.test(t)||(!n||o.specificity>n.specificity)&&(n=o);return n}function Cc(e){let t="";const n=[],o=s=>{n.push([t.length,t.length+s.length]),t+=s};for(const s of e.split("/").filter(Boolean).map(uv))if(t+="/",s.kind==="static"||s.kind==="optional-static")t+=s.text;else if(s.kind==="mixed")for(const a of s.parts)"name"in a?o(a.name):t+=a.text;else o(s.name);return t||(t="/"),{text:t,params:n,literal:n.length>0?t.slice(0,n[0][0]):t}}const Oa={id:"toyon-dark",family:"Toyon",name:"Toyon Dark",kind:"dark",source:"builtin",pair:"toyon-light",accent:"red",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:"#fa891e",string:"#78c945",number:"#ca94ca",type:"#fcbe03",function:"#4dc7a7",variable:"#69a9e8"}},dv={id:"toyon-light",family:"Toyon",name:"Toyon Light",kind:"light",source:"builtin",pair:"toyon-dark",accent:"red",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:"#b15b02",string:"#3c8c03",number:"#865889",type:"#ac7e02",function:"#01775c",variable:"#12689e"}},uI={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"}},dI={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"}},fI={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"}},pI={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"}},hI={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"}},mI={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"}},gI={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"}},kI={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"}},yI={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"}},vI={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"}},wI={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"}},bI={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"}},xI={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"}},_I={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"}},EI={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"}},SI={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"}},NI={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"}},TI=[gI,kI,yI,vI,wI,bI,xI,_I,EI,SI,NI],Jl=[Oa,dv,uI,dI,fI,pI,hI,mI,...TI],II={mode:"dark",light:dv.id,dark:Oa.id},OI=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function RI(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function Ug(e){const t=pv(e);return t>.008856?116*t**(1/3)-16:903.3*t}function fv(e,t){const n=Ug(e)+t,o=Ac(e);if(!o)return e;let s=0,a=2;for(let c=0;c<24;c++){const u=(s+a)/2,d=uc(Math.min(255,o[0]*u),Math.min(255,o[1]*u),Math.min(255,o[2]*u));Ug(d)<n?s=u:a=u}return uc(Math.min(255,o[0]*s),Math.min(255,o[1]*s),Math.min(255,o[2]*s))}function CI(e){return fv(e.colors.surface1,-4)}function jI(e){return fv(e.colors.surface0,-4)}function Bg(e){return UI(e,.55)}function AI(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 $I(e){const t={};for(const n of OI)t[RI(n)]=e.colors[n];for(const[n,o]of Object.entries(AI(e)))t[`--syntax-${n}`]=o;return t["--accent"]=e.colors[Yf(e)],t["--fault"]=e.colors[MI(e)],t["--sunken"]=CI(e),t["--sunken-floor"]=jI(e),t["--scrim"]=FI(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=Bg(e.colors.diffAdd),t["--diff-del-word"]=Bg(e.colors.diffDel),t}function Yf(e){return e.accent??"orange"}function MI(e){return Yf(e)==="orange"?"red":"orange"}function PI(e){return e==="system"||e==="daylight"}function Qf(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function jc(e,t,n){const o=Qf(e,n);return t.find(s=>s.id===e[o])??Jl.find(s=>s.kind===o)??Oa}function LI(e,t){if(e.pair){const c=t.find(u=>u.id===e.pair);if(c&&c.kind!==e.kind)return c}const n=e.kind==="dark"?"light":"dark",o=c=>c.toLowerCase().replace(/\b(dark|light)\b/g,"*").replace(/\s+/g," ").trim(),s=o(e.name);if(!s.includes("*"))return null;const a=e.id.startsWith("vscode:")?e.id.slice(0,e.id.lastIndexOf(":")+1):null;return t.find(c=>c.kind===n&&c.source===e.source&&(!a||c.id.startsWith(a))&&o(c.name)===s)??null}function zI(e){const t=[],n=new Set,o=s=>s.family??(s.name.replace(/\b(dark|light)\b/gi,"").replace(/\s+/g," ").trim()||s.name);for(const s of e){if(n.has(s.id))continue;const a=LI(s,e),c={name:o(s)};c[s.kind]=s,n.add(s.id),a&&(c[a.kind]=a,n.add(a.id)),t.push(c)}return t}function DI(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!PI(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function Ac(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(s=>s+s).join("")),n.length!==6&&n.length!==8)return null;const o=s=>parseInt(n.slice(s,s+2),16);return[o(0),o(2),o(4),n.length===8?o(6)/255:1]}function uc(e,t,n,o=1){const s=a=>Math.round(Math.max(0,Math.min(255,a))).toString(16).padStart(2,"0");return`#${s(e)}${s(t)}${s(n)}${o>=1?"":s(o*255)}`}function FI(e,t){const n=Ac(e);return n?uc(n[0],n[1],n[2],t):e}function UI(e,t){const n=Ac(e);return n?uc(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function pv(e){const t=Ac(e);if(!t)return 0;const n=o=>{const s=o/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}function BI(e){return pv(e)>.179?"#1d2021":"#fbf1c7"}function ar(e){return e.worktree!==void 0}function Zn(e){return e.kind==="main"}function hv(e){return e.kind==="worktree"}function mv(e){return e.kind==="worktree"&&h1(e)}function Xf(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function ec(e){return e.kind==="worktree"}function $c(e){return!!e.branch&&!e.locked&&!(e.worktree&&Zn(e.worktree))}var O=Lf();const ZI=ky(O);var Bl={},Ad={exports:{}},mr={},$d={exports:{}},Md={};/**
73
- * @license React
74
- * scheduler.production.min.js
75
- *
76
- * Copyright (c) Facebook, Inc. and its affiliates.
77
- *
78
- * This source code is licensed under the MIT license found in the
79
- * LICENSE file in the root directory of this source tree.
80
- */var Zg;function HI(){return Zg||(Zg=1,(function(e){function t(X,ce){var ee=X.length;X.push(ce);e:for(;0<ee;){var j=ee-1>>>1,Q=X[j];if(0<s(Q,ce))X[j]=ce,X[ee]=Q,ee=j;else break e}}function n(X){return X.length===0?null:X[0]}function o(X){if(X.length===0)return null;var ce=X[0],ee=X.pop();if(ee!==ce){X[0]=ee;e:for(var j=0,Q=X.length,Ie=Q>>>1;j<Ie;){var xe=2*(j+1)-1,V=X[xe],be=xe+1,Ae=X[be];if(0>s(V,ee))be<Q&&0>s(Ae,V)?(X[j]=Ae,X[be]=ee,j=be):(X[j]=V,X[xe]=ee,j=xe);else if(be<Q&&0>s(Ae,ee))X[j]=Ae,X[be]=ee,j=be;else break e}}return ce}function s(X,ce){var ee=X.sortIndex-ce.sortIndex;return ee!==0?ee:X.id-ce.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var d=[],p=[],m=1,g=null,k=3,w=!1,b=!1,_=!1,I=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function Z(X){for(var ce=n(p);ce!==null;){if(ce.callback===null)o(p);else if(ce.startTime<=X)o(p),ce.sortIndex=ce.expirationTime,t(d,ce);else break;ce=n(p)}}function M(X){if(_=!1,Z(X),!b)if(n(d)!==null)b=!0,ge($);else{var ce=n(p);ce!==null&&Ee(M,ce.startTime-X)}}function $(X,ce){b=!1,_&&(_=!1,C(J),J=-1),w=!0;var ee=k;try{for(Z(ce),g=n(d);g!==null&&(!(g.expirationTime>ce)||X&&!Oe());){var j=g.callback;if(typeof j=="function"){g.callback=null,k=g.priorityLevel;var Q=j(g.expirationTime<=ce);ce=e.unstable_now(),typeof Q=="function"?g.callback=Q:g===n(d)&&o(d),Z(ce)}else o(d);g=n(d)}if(g!==null)var Ie=!0;else{var xe=n(p);xe!==null&&Ee(M,xe.startTime-ce),Ie=!1}return Ie}finally{g=null,k=ee,w=!1}}var D=!1,q=null,J=-1,se=5,me=-1;function Oe(){return!(e.unstable_now()-me<se)}function ae(){if(q!==null){var X=e.unstable_now();me=X;var ce=!0;try{ce=q(!0,X)}finally{ce?ie():(D=!1,q=null)}}else D=!1}var ie;if(typeof E=="function")ie=function(){E(ae)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,de=Y.port2;Y.port1.onmessage=ae,ie=function(){de.postMessage(null)}}else ie=function(){I(ae,0)};function ge(X){q=X,D||(D=!0,ie())}function Ee(X,ce){J=I(function(){X(e.unstable_now())},ce)}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(X){X.callback=null},e.unstable_continueExecution=function(){b||w||(b=!0,ge($))},e.unstable_forceFrameRate=function(X){0>X||125<X?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):se=0<X?Math.floor(1e3/X):5},e.unstable_getCurrentPriorityLevel=function(){return k},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(X){switch(k){case 1:case 2:case 3:var ce=3;break;default:ce=k}var ee=k;k=ce;try{return X()}finally{k=ee}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(X,ce){switch(X){case 1:case 2:case 3:case 4:case 5:break;default:X=3}var ee=k;k=X;try{return ce()}finally{k=ee}},e.unstable_scheduleCallback=function(X,ce,ee){var j=e.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?j+ee:j):ee=j,X){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=ee+Q,X={id:m++,callback:ce,priorityLevel:X,startTime:ee,expirationTime:Q,sortIndex:-1},ee>j?(X.sortIndex=ee,t(p,X),n(d)===null&&X===n(p)&&(_?(C(J),J=-1):_=!0,Ee(M,ee-j))):(X.sortIndex=Q,t(d,X),b||w||(b=!0,ge($))),X},e.unstable_shouldYield=Oe,e.unstable_wrapCallback=function(X){var ce=k;return function(){var ee=k;k=ce;try{return X.apply(this,arguments)}finally{k=ee}}}})(Md)),Md}var Hg;function WI(){return Hg||(Hg=1,$d.exports=HI()),$d.exports}/**
81
- * @license React
82
- * react-dom.production.min.js
83
- *
84
- * Copyright (c) Facebook, Inc. and its affiliates.
85
- *
86
- * This source code is licensed under the MIT license found in the
87
- * LICENSE file in the root directory of this source tree.
88
- */var Wg;function KI(){if(Wg)return mr;Wg=1;var e=Lf(),t=WI();function n(r){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+r,l=1;l<arguments.length;l++)i+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+r+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,s={};function a(r,i){c(r,i),c(r+"Capture",i)}function c(r,i){for(s[r]=i,r=0;r<i.length;r++)o.add(i[r])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=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]*$/,m={},g={};function k(r){return d.call(g,r)?!0:d.call(m,r)?!1:p.test(r)?g[r]=!0:(m[r]=!0,!1)}function w(r,i,l,f){if(l!==null&&l.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return f?!1:l!==null?!l.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function b(r,i,l,f){if(i===null||typeof i>"u"||w(r,i,l,f))return!0;if(f)return!1;if(l!==null)switch(l.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function _(r,i,l,f,y,v,x){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=f,this.attributeNamespace=y,this.mustUseProperty=l,this.propertyName=r,this.type=i,this.sanitizeURL=v,this.removeEmptyString=x}var I={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){I[r]=new _(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var i=r[0];I[i]=new _(i,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){I[r]=new _(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){I[r]=new _(r,2,!1,r,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(r){I[r]=new _(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){I[r]=new _(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){I[r]=new _(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){I[r]=new _(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){I[r]=new _(r,5,!1,r.toLowerCase(),null,!1,!1)});var C=/[\-:]([a-z])/g;function E(r){return r[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(r){var i=r.replace(C,E);I[i]=new _(i,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var i=r.replace(C,E);I[i]=new _(i,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var i=r.replace(C,E);I[i]=new _(i,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){I[r]=new _(r,1,!1,r.toLowerCase(),null,!1,!1)}),I.xlinkHref=new _("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){I[r]=new _(r,1,!1,r.toLowerCase(),null,!0,!0)});function Z(r,i,l,f){var y=I.hasOwnProperty(i)?I[i]:null;(y!==null?y.type!==0:f||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(b(i,l,y,f)&&(l=null),f||y===null?k(i)&&(l===null?r.removeAttribute(i):r.setAttribute(i,""+l)):y.mustUseProperty?r[y.propertyName]=l===null?y.type===3?!1:"":l:(i=y.attributeName,f=y.attributeNamespace,l===null?r.removeAttribute(i):(y=y.type,l=y===3||y===4&&l===!0?"":""+l,f?r.setAttributeNS(f,i,l):r.setAttribute(i,l))))}var M=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,$=Symbol.for("react.element"),D=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),J=Symbol.for("react.strict_mode"),se=Symbol.for("react.profiler"),me=Symbol.for("react.provider"),Oe=Symbol.for("react.context"),ae=Symbol.for("react.forward_ref"),ie=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),de=Symbol.for("react.memo"),ge=Symbol.for("react.lazy"),Ee=Symbol.for("react.offscreen"),X=Symbol.iterator;function ce(r){return r===null||typeof r!="object"?null:(r=X&&r[X]||r["@@iterator"],typeof r=="function"?r:null)}var ee=Object.assign,j;function Q(r){if(j===void 0)try{throw Error()}catch(l){var i=l.stack.trim().match(/\n( *(at )?)/);j=i&&i[1]||""}return`
89
- `+j+r}var Ie=!1;function xe(r,i){if(!r||Ie)return"";Ie=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(G){var f=G}Reflect.construct(r,[],i)}else{try{i.call()}catch(G){f=G}r.call(i.prototype)}else{try{throw Error()}catch(G){f=G}r()}}catch(G){if(G&&f&&typeof G.stack=="string"){for(var y=G.stack.split(`
90
- `),v=f.stack.split(`
91
- `),x=y.length-1,T=v.length-1;1<=x&&0<=T&&y[x]!==v[T];)T--;for(;1<=x&&0<=T;x--,T--)if(y[x]!==v[T]){if(x!==1||T!==1)do if(x--,T--,0>T||y[x]!==v[T]){var A=`
92
- `+y[x].replace(" at new "," at ");return r.displayName&&A.includes("<anonymous>")&&(A=A.replace("<anonymous>",r.displayName)),A}while(1<=x&&0<=T);break}}}finally{Ie=!1,Error.prepareStackTrace=l}return(r=r?r.displayName||r.name:"")?Q(r):""}function V(r){switch(r.tag){case 5:return Q(r.type);case 16:return Q("Lazy");case 13:return Q("Suspense");case 19:return Q("SuspenseList");case 0:case 2:case 15:return r=xe(r.type,!1),r;case 11:return r=xe(r.type.render,!1),r;case 1:return r=xe(r.type,!0),r;default:return""}}function be(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case q:return"Fragment";case D:return"Portal";case se:return"Profiler";case J:return"StrictMode";case ie:return"Suspense";case Y:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case Oe:return(r.displayName||"Context")+".Consumer";case me:return(r._context.displayName||"Context")+".Provider";case ae:var i=r.render;return r=r.displayName,r||(r=i.displayName||i.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case de:return i=r.displayName||null,i!==null?i:be(r.type)||"Memo";case ge:i=r._payload,r=r._init;try{return be(r(i))}catch{}}return null}function Ae(r){var i=r.type;switch(r.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=i.render,r=r.displayName||r.name||"",i.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return be(i);case 8:return i===J?"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 i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function Pe(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function B(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function F(r){var i=B(r)?"checked":"value",l=Object.getOwnPropertyDescriptor(r.constructor.prototype,i),f=""+r[i];if(!r.hasOwnProperty(i)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var y=l.get,v=l.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return y.call(this)},set:function(x){f=""+x,v.call(this,x)}}),Object.defineProperty(r,i,{enumerable:l.enumerable}),{getValue:function(){return f},setValue:function(x){f=""+x},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function Te(r){r._valueTracker||(r._valueTracker=F(r))}function lt(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var l=i.getValue(),f="";return r&&(f=B(r)?r.checked?"true":"false":r.value),r=f,r!==l?(i.setValue(r),!0):!1}function Pt(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function Ye(r,i){var l=i.checked;return ee({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??r._wrapperState.initialChecked})}function Ge(r,i){var l=i.defaultValue==null?"":i.defaultValue,f=i.checked!=null?i.checked:i.defaultChecked;l=Pe(i.value!=null?i.value:l),r._wrapperState={initialChecked:f,initialValue:l,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function Ue(r,i){i=i.checked,i!=null&&Z(r,"checked",i,!1)}function At(r,i){Ue(r,i);var l=Pe(i.value),f=i.type;if(l!=null)f==="number"?(l===0&&r.value===""||r.value!=l)&&(r.value=""+l):r.value!==""+l&&(r.value=""+l);else if(f==="submit"||f==="reset"){r.removeAttribute("value");return}i.hasOwnProperty("value")?ut(r,i.type,l):i.hasOwnProperty("defaultValue")&&ut(r,i.type,Pe(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(r.defaultChecked=!!i.defaultChecked)}function Tt(r,i,l){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var f=i.type;if(!(f!=="submit"&&f!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+r._wrapperState.initialValue,l||i===r.value||(r.value=i),r.defaultValue=i}l=r.name,l!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,l!==""&&(r.name=l)}function ut(r,i,l){(i!=="number"||Pt(r.ownerDocument)!==r)&&(l==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+l&&(r.defaultValue=""+l))}var Vt=Array.isArray;function K(r,i,l,f){if(r=r.options,i){i={};for(var y=0;y<l.length;y++)i["$"+l[y]]=!0;for(l=0;l<r.length;l++)y=i.hasOwnProperty("$"+r[l].value),r[l].selected!==y&&(r[l].selected=y),y&&f&&(r[l].defaultSelected=!0)}else{for(l=""+Pe(l),i=null,y=0;y<r.length;y++){if(r[y].value===l){r[y].selected=!0,f&&(r[y].defaultSelected=!0);return}i!==null||r[y].disabled||(i=r[y])}i!==null&&(i.selected=!0)}}function _e(r,i){if(i.dangerouslySetInnerHTML!=null)throw Error(n(91));return ee({},i,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function pt(r,i){var l=i.value;if(l==null){if(l=i.children,i=i.defaultValue,l!=null){if(i!=null)throw Error(n(92));if(Vt(l)){if(1<l.length)throw Error(n(93));l=l[0]}i=l}i==null&&(i=""),l=i}r._wrapperState={initialValue:Pe(l)}}function It(r,i){var l=Pe(i.value),f=Pe(i.defaultValue);l!=null&&(l=""+l,l!==r.value&&(r.value=l),i.defaultValue==null&&r.defaultValue!==l&&(r.defaultValue=l)),f!=null&&(r.defaultValue=""+f)}function vn(r){var i=r.textContent;i===r._wrapperState.initialValue&&i!==""&&i!==null&&(r.value=i)}function vt(r){switch(r){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 Gt(r,i){return r==null||r==="http://www.w3.org/1999/xhtml"?vt(i):r==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var te,Be=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,l,f,y){MSApp.execUnsafeLocalFunction(function(){return r(i,l,f,y)})}:r})(function(r,i){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=i;else{for(te=te||document.createElement("div"),te.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=te.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;i.firstChild;)r.appendChild(i.firstChild)}});function mt(r,i){if(i){var l=r.firstChild;if(l&&l===r.lastChild&&l.nodeType===3){l.nodeValue=i;return}}r.textContent=i}var it={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},rt=["Webkit","ms","Moz","O"];Object.keys(it).forEach(function(r){rt.forEach(function(i){i=i+r.charAt(0).toUpperCase()+r.substring(1),it[i]=it[r]})});function Rn(r,i,l){return i==null||typeof i=="boolean"||i===""?"":l||typeof i!="number"||i===0||it.hasOwnProperty(r)&&it[r]?(""+i).trim():i+"px"}function Xe(r,i){r=r.style;for(var l in i)if(i.hasOwnProperty(l)){var f=l.indexOf("--")===0,y=Rn(l,i[l],f);l==="float"&&(l="cssFloat"),f?r.setProperty(l,y):r[l]=y}}var wn=ee({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 Lt(r,i){if(i){if(wn[r]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(n(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(n(61))}if(i.style!=null&&typeof i.style!="object")throw Error(n(62))}}function xr(r,i){if(r.indexOf("-")===-1)return typeof i.is=="string";switch(r){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 hn=null;function Dn(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Zt=null,Fn=null,bn=null;function Jn(r){if(r=Ls(r)){if(typeof Zt!="function")throw Error(n(280));var i=r.stateNode;i&&(i=Qa(i),Zt(r.stateNode,r.type,i))}}function R(r){Fn?bn?bn.push(r):bn=[r]:Fn=r}function ne(){if(Fn){var r=Fn,i=bn;if(bn=Fn=null,Jn(r),i)for(r=0;r<i.length;r++)Jn(i[r])}}function ve(r,i){return r(i)}function He(){}var gt=!1;function wt(r,i,l){if(gt)return r(i,l);gt=!0;try{return ve(r,i,l)}finally{gt=!1,(Fn!==null||bn!==null)&&(He(),ne())}}function Se(r,i){var l=r.stateNode;if(l===null)return null;var f=Qa(l);if(f===null)return null;l=f[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(f=!f.disabled)||(r=r.type,f=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!f;break e;default:r=!1}if(r)return null;if(l&&typeof l!="function")throw Error(n(231,i,typeof l));return l}var Ne=!1;if(u)try{var we={};Object.defineProperty(we,"passive",{get:function(){Ne=!0}}),window.addEventListener("test",we,we),window.removeEventListener("test",we,we)}catch{Ne=!1}function Rt(r,i,l,f,y,v,x,T,A){var G=Array.prototype.slice.call(arguments,3);try{i.apply(l,G)}catch(ue){this.onError(ue)}}var Ot=!1,xn=null,er=!1,Cn=null,Wn={onError:function(r){Ot=!0,xn=r}};function Cr(r,i,l,f,y,v,x,T,A){Ot=!1,xn=null,Rt.apply(Wn,arguments)}function jr(r,i,l,f,y,v,x,T,A){if(Cr.apply(this,arguments),Ot){if(Ot){var G=xn;Ot=!1,xn=null}else throw Error(n(198));er||(er=!0,Cn=G)}}function lr(r){var i=r,l=r;if(r.alternate)for(;i.return;)i=i.return;else{r=i;do i=r,(i.flags&4098)!==0&&(l=i.return),r=i.return;while(r)}return i.tag===3?l:null}function uo(r){if(r.tag===13){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function kt(r){if(lr(r)!==r)throw Error(n(188))}function tr(r){var i=r.alternate;if(!i){if(i=lr(r),i===null)throw Error(n(188));return i!==r?null:r}for(var l=r,f=i;;){var y=l.return;if(y===null)break;var v=y.alternate;if(v===null){if(f=y.return,f!==null){l=f;continue}break}if(y.child===v.child){for(v=y.child;v;){if(v===l)return kt(y),r;if(v===f)return kt(y),i;v=v.sibling}throw Error(n(188))}if(l.return!==f.return)l=y,f=v;else{for(var x=!1,T=y.child;T;){if(T===l){x=!0,l=y,f=v;break}if(T===f){x=!0,f=y,l=v;break}T=T.sibling}if(!x){for(T=v.child;T;){if(T===l){x=!0,l=v,f=y;break}if(T===f){x=!0,f=v,l=y;break}T=T.sibling}if(!x)throw Error(n(189))}}if(l.alternate!==f)throw Error(n(190))}if(l.tag!==3)throw Error(n(188));return l.stateNode.current===l?r:i}function Lo(r){return r=tr(r),r!==null?Kr(r):null}function Kr(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var i=Kr(r);if(i!==null)return i;r=r.sibling}return null}var Ar=t.unstable_scheduleCallback,_n=t.unstable_cancelCallback,fo=t.unstable_shouldYield,mn=t.unstable_requestPaint,$t=t.unstable_now,zo=t.unstable_getCurrentPriorityLevel,$r=t.unstable_ImmediatePriority,En=t.unstable_UserBlockingPriority,Vr=t.unstable_NormalPriority,pe=t.unstable_LowPriority,Re=t.unstable_IdlePriority,et=null,Qe=null;function zt(r){if(Qe&&typeof Qe.onCommitFiberRoot=="function")try{Qe.onCommitFiberRoot(et,r,void 0,(r.current.flags&128)===128)}catch{}}var Dt=Math.clz32?Math.clz32:rn,nr=Math.log,Mr=Math.LN2;function rn(r){return r>>>=0,r===0?32:31-(nr(r)/Mr|0)|0}var L=64,Ze=4194304;function tt(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Ft(r,i){var l=r.pendingLanes;if(l===0)return 0;var f=0,y=r.suspendedLanes,v=r.pingedLanes,x=l&268435455;if(x!==0){var T=x&~y;T!==0?f=tt(T):(v&=x,v!==0&&(f=tt(v)))}else x=l&~y,x!==0?f=tt(x):v!==0&&(f=tt(v));if(f===0)return 0;if(i!==0&&i!==f&&(i&y)===0&&(y=f&-f,v=i&-i,y>=v||y===16&&(v&4194240)!==0))return i;if((f&4)!==0&&(f|=l&16),i=r.entangledLanes,i!==0)for(r=r.entanglements,i&=f;0<i;)l=31-Dt(i),y=1<<l,f|=r[l],i&=~y;return f}function on(r,i){switch(r){case 1:case 2:case 4:return i+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 i+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 xo(r,i){for(var l=r.suspendedLanes,f=r.pingedLanes,y=r.expirationTimes,v=r.pendingLanes;0<v;){var x=31-Dt(v),T=1<<x,A=y[x];A===-1?((T&l)===0||(T&f)!==0)&&(y[x]=on(T,i)):A<=i&&(r.expiredLanes|=T),v&=~T}}function po(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function Li(){var r=L;return L<<=1,(L&4194240)===0&&(L=64),r}function Gr(r){for(var i=[],l=0;31>l;l++)i.push(r);return i}function qr(r,i,l){r.pendingLanes|=i,i!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,i=31-Dt(i),r[i]=l}function rr(r,i){var l=r.pendingLanes&~i;r.pendingLanes=i,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=i,r.mutableReadLanes&=i,r.entangledLanes&=i,i=r.entanglements;var f=r.eventTimes;for(r=r.expirationTimes;0<l;){var y=31-Dt(l),v=1<<y;i[y]=0,f[y]=-1,r[y]=-1,l&=~v}}function Do(r,i){var l=r.entangledLanes|=i;for(r=r.entanglements;l;){var f=31-Dt(l),y=1<<f;y&i|r[f]&i&&(r[f]|=i),l&=~y}}var ht=0;function Ve(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var ci,sn,_t,Pr,cr,fe=!1,S=[],N=null,U=null,oe=null,ke=new Map,Ce=new Map,Je=[],Ut="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 Sn(r,i){switch(r){case"focusin":case"focusout":N=null;break;case"dragenter":case"dragleave":U=null;break;case"mouseover":case"mouseout":oe=null;break;case"pointerover":case"pointerout":ke.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ce.delete(i.pointerId)}}function gn(r,i,l,f,y,v){return r===null||r.nativeEvent!==v?(r={blockedOn:i,domEventName:l,eventSystemFlags:f,nativeEvent:v,targetContainers:[y]},i!==null&&(i=Ls(i),i!==null&&sn(i)),r):(r.eventSystemFlags|=f,i=r.targetContainers,y!==null&&i.indexOf(y)===-1&&i.push(y),r)}function _s(r,i,l,f,y){switch(i){case"focusin":return N=gn(N,r,i,l,f,y),!0;case"dragenter":return U=gn(U,r,i,l,f,y),!0;case"mouseover":return oe=gn(oe,r,i,l,f,y),!0;case"pointerover":var v=y.pointerId;return ke.set(v,gn(ke.get(v)||null,r,i,l,f,y)),!0;case"gotpointercapture":return v=y.pointerId,Ce.set(v,gn(Ce.get(v)||null,r,i,l,f,y)),!0}return!1}function jn(r){var i=ui(r.target);if(i!==null){var l=lr(i);if(l!==null){if(i=l.tag,i===13){if(i=uo(l),i!==null){r.blockedOn=i,cr(r.priority,function(){_t(l)});return}}else if(i===3&&l.stateNode.current.memoizedState.isDehydrated){r.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}r.blockedOn=null}function La(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var l=Yc(r.domEventName,r.eventSystemFlags,i[0],r.nativeEvent);if(l===null){l=r.nativeEvent;var f=new l.constructor(l.type,l);hn=f,l.target.dispatchEvent(f),hn=null}else return i=Ls(l),i!==null&&sn(i),r.blockedOn=l,!1;i.shift()}return!0}function Mp(r,i,l){La(r)&&l.delete(i)}function rb(){fe=!1,N!==null&&La(N)&&(N=null),U!==null&&La(U)&&(U=null),oe!==null&&La(oe)&&(oe=null),ke.forEach(Mp),Ce.forEach(Mp)}function Es(r,i){r.blockedOn===i&&(r.blockedOn=null,fe||(fe=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,rb)))}function Ss(r){function i(y){return Es(y,r)}if(0<S.length){Es(S[0],r);for(var l=1;l<S.length;l++){var f=S[l];f.blockedOn===r&&(f.blockedOn=null)}}for(N!==null&&Es(N,r),U!==null&&Es(U,r),oe!==null&&Es(oe,r),ke.forEach(i),Ce.forEach(i),l=0;l<Je.length;l++)f=Je[l],f.blockedOn===r&&(f.blockedOn=null);for(;0<Je.length&&(l=Je[0],l.blockedOn===null);)jn(l),l.blockedOn===null&&Je.shift()}var zi=M.ReactCurrentBatchConfig,za=!0;function ob(r,i,l,f){var y=ht,v=zi.transition;zi.transition=null;try{ht=1,qc(r,i,l,f)}finally{ht=y,zi.transition=v}}function ib(r,i,l,f){var y=ht,v=zi.transition;zi.transition=null;try{ht=4,qc(r,i,l,f)}finally{ht=y,zi.transition=v}}function qc(r,i,l,f){if(za){var y=Yc(r,i,l,f);if(y===null)pu(r,i,f,Da,l),Sn(r,f);else if(_s(y,r,i,l,f))f.stopPropagation();else if(Sn(r,f),i&4&&-1<Ut.indexOf(r)){for(;y!==null;){var v=Ls(y);if(v!==null&&ci(v),v=Yc(r,i,l,f),v===null&&pu(r,i,f,Da,l),v===y)break;y=v}y!==null&&f.stopPropagation()}else pu(r,i,f,null,l)}}var Da=null;function Yc(r,i,l,f){if(Da=null,r=Dn(f),r=ui(r),r!==null)if(i=lr(r),i===null)r=null;else if(l=i.tag,l===13){if(r=uo(i),r!==null)return r;r=null}else if(l===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;r=null}else i!==r&&(r=null);return Da=r,null}function Pp(r){switch(r){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(zo()){case $r:return 1;case En:return 4;case Vr:case pe:return 16;case Re:return 536870912;default:return 16}default:return 16}}var Fo=null,Qc=null,Fa=null;function Lp(){if(Fa)return Fa;var r,i=Qc,l=i.length,f,y="value"in Fo?Fo.value:Fo.textContent,v=y.length;for(r=0;r<l&&i[r]===y[r];r++);var x=l-r;for(f=1;f<=x&&i[l-f]===y[v-f];f++);return Fa=y.slice(r,1<f?1-f:void 0)}function Ua(r){var i=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&i===13&&(r=13)):r=i,r===10&&(r=13),32<=r||r===13?r:0}function Ba(){return!0}function zp(){return!1}function _r(r){function i(l,f,y,v,x){this._reactName=l,this._targetInst=y,this.type=f,this.nativeEvent=v,this.target=x,this.currentTarget=null;for(var T in r)r.hasOwnProperty(T)&&(l=r[T],this[T]=l?l(v):v[T]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?Ba:zp,this.isPropagationStopped=zp,this}return ee(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Ba)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Ba)},persist:function(){},isPersistent:Ba}),i}var Di={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Xc=_r(Di),Ns=ee({},Di,{view:0,detail:0}),sb=_r(Ns),Jc,eu,Ts,Za=ee({},Ns,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:nu,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==Ts&&(Ts&&r.type==="mousemove"?(Jc=r.screenX-Ts.screenX,eu=r.screenY-Ts.screenY):eu=Jc=0,Ts=r),Jc)},movementY:function(r){return"movementY"in r?r.movementY:eu}}),Dp=_r(Za),ab=ee({},Za,{dataTransfer:0}),lb=_r(ab),cb=ee({},Ns,{relatedTarget:0}),tu=_r(cb),ub=ee({},Di,{animationName:0,elapsedTime:0,pseudoElement:0}),db=_r(ub),fb=ee({},Di,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),pb=_r(fb),hb=ee({},Di,{data:0}),Fp=_r(hb),mb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},gb={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"},kb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function yb(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=kb[r])?!!i[r]:!1}function nu(){return yb}var vb=ee({},Ns,{key:function(r){if(r.key){var i=mb[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=Ua(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?gb[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:nu,charCode:function(r){return r.type==="keypress"?Ua(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Ua(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),wb=_r(vb),bb=ee({},Za,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Up=_r(bb),xb=ee({},Ns,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:nu}),_b=_r(xb),Eb=ee({},Di,{propertyName:0,elapsedTime:0,pseudoElement:0}),Sb=_r(Eb),Nb=ee({},Za,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),Tb=_r(Nb),Ib=[9,13,27,32],ru=u&&"CompositionEvent"in window,Is=null;u&&"documentMode"in document&&(Is=document.documentMode);var Ob=u&&"TextEvent"in window&&!Is,Bp=u&&(!ru||Is&&8<Is&&11>=Is),Zp=" ",Hp=!1;function Wp(r,i){switch(r){case"keyup":return Ib.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kp(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Fi=!1;function Rb(r,i){switch(r){case"compositionend":return Kp(i);case"keypress":return i.which!==32?null:(Hp=!0,Zp);case"textInput":return r=i.data,r===Zp&&Hp?null:r;default:return null}}function Cb(r,i){if(Fi)return r==="compositionend"||!ru&&Wp(r,i)?(r=Lp(),Fa=Qc=Fo=null,Fi=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return Bp&&i.locale!=="ko"?null:i.data;default:return null}}var jb={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 Vp(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!jb[r.type]:i==="textarea"}function Gp(r,i,l,f){R(f),i=Ga(i,"onChange"),0<i.length&&(l=new Xc("onChange","change",null,l,f),r.push({event:l,listeners:i}))}var Os=null,Rs=null;function Ab(r){fh(r,0)}function Ha(r){var i=Wi(r);if(lt(i))return r}function $b(r,i){if(r==="change")return i}var qp=!1;if(u){var ou;if(u){var iu="oninput"in document;if(!iu){var Yp=document.createElement("div");Yp.setAttribute("oninput","return;"),iu=typeof Yp.oninput=="function"}ou=iu}else ou=!1;qp=ou&&(!document.documentMode||9<document.documentMode)}function Qp(){Os&&(Os.detachEvent("onpropertychange",Xp),Rs=Os=null)}function Xp(r){if(r.propertyName==="value"&&Ha(Rs)){var i=[];Gp(i,Rs,r,Dn(r)),wt(Ab,i)}}function Mb(r,i,l){r==="focusin"?(Qp(),Os=i,Rs=l,Os.attachEvent("onpropertychange",Xp)):r==="focusout"&&Qp()}function Pb(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Ha(Rs)}function Lb(r,i){if(r==="click")return Ha(i)}function zb(r,i){if(r==="input"||r==="change")return Ha(i)}function Db(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var Yr=typeof Object.is=="function"?Object.is:Db;function Cs(r,i){if(Yr(r,i))return!0;if(typeof r!="object"||r===null||typeof i!="object"||i===null)return!1;var l=Object.keys(r),f=Object.keys(i);if(l.length!==f.length)return!1;for(f=0;f<l.length;f++){var y=l[f];if(!d.call(i,y)||!Yr(r[y],i[y]))return!1}return!0}function Jp(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function eh(r,i){var l=Jp(r);r=0;for(var f;l;){if(l.nodeType===3){if(f=r+l.textContent.length,r<=i&&f>=i)return{node:l,offset:i-r};r=f}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Jp(l)}}function th(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?th(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function nh(){for(var r=window,i=Pt();i instanceof r.HTMLIFrameElement;){try{var l=typeof i.contentWindow.location.href=="string"}catch{l=!1}if(l)r=i.contentWindow;else break;i=Pt(r.document)}return i}function su(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i&&(i==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||i==="textarea"||r.contentEditable==="true")}function Fb(r){var i=nh(),l=r.focusedElem,f=r.selectionRange;if(i!==l&&l&&l.ownerDocument&&th(l.ownerDocument.documentElement,l)){if(f!==null&&su(l)){if(i=f.start,r=f.end,r===void 0&&(r=i),"selectionStart"in l)l.selectionStart=i,l.selectionEnd=Math.min(r,l.value.length);else if(r=(i=l.ownerDocument||document)&&i.defaultView||window,r.getSelection){r=r.getSelection();var y=l.textContent.length,v=Math.min(f.start,y);f=f.end===void 0?v:Math.min(f.end,y),!r.extend&&v>f&&(y=f,f=v,v=y),y=eh(l,v);var x=eh(l,f);y&&x&&(r.rangeCount!==1||r.anchorNode!==y.node||r.anchorOffset!==y.offset||r.focusNode!==x.node||r.focusOffset!==x.offset)&&(i=i.createRange(),i.setStart(y.node,y.offset),r.removeAllRanges(),v>f?(r.addRange(i),r.extend(x.node,x.offset)):(i.setEnd(x.node,x.offset),r.addRange(i)))}}for(i=[],r=l;r=r.parentNode;)r.nodeType===1&&i.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<i.length;l++)r=i[l],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var Ub=u&&"documentMode"in document&&11>=document.documentMode,Ui=null,au=null,js=null,lu=!1;function rh(r,i,l){var f=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;lu||Ui==null||Ui!==Pt(f)||(f=Ui,"selectionStart"in f&&su(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),js&&Cs(js,f)||(js=f,f=Ga(au,"onSelect"),0<f.length&&(i=new Xc("onSelect","select",null,i,l),r.push({event:i,listeners:f}),i.target=Ui)))}function Wa(r,i){var l={};return l[r.toLowerCase()]=i.toLowerCase(),l["Webkit"+r]="webkit"+i,l["Moz"+r]="moz"+i,l}var Bi={animationend:Wa("Animation","AnimationEnd"),animationiteration:Wa("Animation","AnimationIteration"),animationstart:Wa("Animation","AnimationStart"),transitionend:Wa("Transition","TransitionEnd")},cu={},oh={};u&&(oh=document.createElement("div").style,"AnimationEvent"in window||(delete Bi.animationend.animation,delete Bi.animationiteration.animation,delete Bi.animationstart.animation),"TransitionEvent"in window||delete Bi.transitionend.transition);function Ka(r){if(cu[r])return cu[r];if(!Bi[r])return r;var i=Bi[r],l;for(l in i)if(i.hasOwnProperty(l)&&l in oh)return cu[r]=i[l];return r}var ih=Ka("animationend"),sh=Ka("animationiteration"),ah=Ka("animationstart"),lh=Ka("transitionend"),ch=new Map,uh="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 Uo(r,i){ch.set(r,i),a(i,[r])}for(var uu=0;uu<uh.length;uu++){var du=uh[uu],Bb=du.toLowerCase(),Zb=du[0].toUpperCase()+du.slice(1);Uo(Bb,"on"+Zb)}Uo(ih,"onAnimationEnd"),Uo(sh,"onAnimationIteration"),Uo(ah,"onAnimationStart"),Uo("dblclick","onDoubleClick"),Uo("focusin","onFocus"),Uo("focusout","onBlur"),Uo(lh,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var As="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(" "),Hb=new Set("cancel close invalid load scroll toggle".split(" ").concat(As));function dh(r,i,l){var f=r.type||"unknown-event";r.currentTarget=l,jr(f,i,void 0,r),r.currentTarget=null}function fh(r,i){i=(i&4)!==0;for(var l=0;l<r.length;l++){var f=r[l],y=f.event;f=f.listeners;e:{var v=void 0;if(i)for(var x=f.length-1;0<=x;x--){var T=f[x],A=T.instance,G=T.currentTarget;if(T=T.listener,A!==v&&y.isPropagationStopped())break e;dh(y,T,G),v=A}else for(x=0;x<f.length;x++){if(T=f[x],A=T.instance,G=T.currentTarget,T=T.listener,A!==v&&y.isPropagationStopped())break e;dh(y,T,G),v=A}}}if(er)throw r=Cn,er=!1,Cn=null,r}function qt(r,i){var l=i[vu];l===void 0&&(l=i[vu]=new Set);var f=r+"__bubble";l.has(f)||(ph(i,r,2,!1),l.add(f))}function fu(r,i,l){var f=0;i&&(f|=4),ph(l,r,f,i)}var Va="_reactListening"+Math.random().toString(36).slice(2);function $s(r){if(!r[Va]){r[Va]=!0,o.forEach(function(l){l!=="selectionchange"&&(Hb.has(l)||fu(l,!1,r),fu(l,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[Va]||(i[Va]=!0,fu("selectionchange",!1,i))}}function ph(r,i,l,f){switch(Pp(i)){case 1:var y=ob;break;case 4:y=ib;break;default:y=qc}l=y.bind(null,i,l,r),y=void 0,!Ne||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(y=!0),f?y!==void 0?r.addEventListener(i,l,{capture:!0,passive:y}):r.addEventListener(i,l,!0):y!==void 0?r.addEventListener(i,l,{passive:y}):r.addEventListener(i,l,!1)}function pu(r,i,l,f,y){var v=f;if((i&1)===0&&(i&2)===0&&f!==null)e:for(;;){if(f===null)return;var x=f.tag;if(x===3||x===4){var T=f.stateNode.containerInfo;if(T===y||T.nodeType===8&&T.parentNode===y)break;if(x===4)for(x=f.return;x!==null;){var A=x.tag;if((A===3||A===4)&&(A=x.stateNode.containerInfo,A===y||A.nodeType===8&&A.parentNode===y))return;x=x.return}for(;T!==null;){if(x=ui(T),x===null)return;if(A=x.tag,A===5||A===6){f=v=x;continue e}T=T.parentNode}}f=f.return}wt(function(){var G=v,ue=Dn(l),he=[];e:{var le=ch.get(r);if(le!==void 0){var je=Xc,Me=r;switch(r){case"keypress":if(Ua(l)===0)break e;case"keydown":case"keyup":je=wb;break;case"focusin":Me="focus",je=tu;break;case"focusout":Me="blur",je=tu;break;case"beforeblur":case"afterblur":je=tu;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":je=Dp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":je=lb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":je=_b;break;case ih:case sh:case ah:je=db;break;case lh:je=Sb;break;case"scroll":je=sb;break;case"wheel":je=Tb;break;case"copy":case"cut":case"paste":je=pb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":je=Up}var Le=(i&4)!==0,pn=!Le&&r==="scroll",H=Le?le!==null?le+"Capture":null:le;Le=[];for(var P=G,W;P!==null;){W=P;var ye=W.stateNode;if(W.tag===5&&ye!==null&&(W=ye,H!==null&&(ye=Se(P,H),ye!=null&&Le.push(Ms(P,ye,W)))),pn)break;P=P.return}0<Le.length&&(le=new je(le,Me,null,l,ue),he.push({event:le,listeners:Le}))}}if((i&7)===0){e:{if(le=r==="mouseover"||r==="pointerover",je=r==="mouseout"||r==="pointerout",le&&l!==hn&&(Me=l.relatedTarget||l.fromElement)&&(ui(Me)||Me[_o]))break e;if((je||le)&&(le=ue.window===ue?ue:(le=ue.ownerDocument)?le.defaultView||le.parentWindow:window,je?(Me=l.relatedTarget||l.toElement,je=G,Me=Me?ui(Me):null,Me!==null&&(pn=lr(Me),Me!==pn||Me.tag!==5&&Me.tag!==6)&&(Me=null)):(je=null,Me=G),je!==Me)){if(Le=Dp,ye="onMouseLeave",H="onMouseEnter",P="mouse",(r==="pointerout"||r==="pointerover")&&(Le=Up,ye="onPointerLeave",H="onPointerEnter",P="pointer"),pn=je==null?le:Wi(je),W=Me==null?le:Wi(Me),le=new Le(ye,P+"leave",je,l,ue),le.target=pn,le.relatedTarget=W,ye=null,ui(ue)===G&&(Le=new Le(H,P+"enter",Me,l,ue),Le.target=W,Le.relatedTarget=pn,ye=Le),pn=ye,je&&Me)t:{for(Le=je,H=Me,P=0,W=Le;W;W=Zi(W))P++;for(W=0,ye=H;ye;ye=Zi(ye))W++;for(;0<P-W;)Le=Zi(Le),P--;for(;0<W-P;)H=Zi(H),W--;for(;P--;){if(Le===H||H!==null&&Le===H.alternate)break t;Le=Zi(Le),H=Zi(H)}Le=null}else Le=null;je!==null&&hh(he,le,je,Le,!1),Me!==null&&pn!==null&&hh(he,pn,Me,Le,!0)}}e:{if(le=G?Wi(G):window,je=le.nodeName&&le.nodeName.toLowerCase(),je==="select"||je==="input"&&le.type==="file")var ze=$b;else if(Vp(le))if(qp)ze=zb;else{ze=Pb;var We=Mb}else(je=le.nodeName)&&je.toLowerCase()==="input"&&(le.type==="checkbox"||le.type==="radio")&&(ze=Lb);if(ze&&(ze=ze(r,G))){Gp(he,ze,l,ue);break e}We&&We(r,le,G),r==="focusout"&&(We=le._wrapperState)&&We.controlled&&le.type==="number"&&ut(le,"number",le.value)}switch(We=G?Wi(G):window,r){case"focusin":(Vp(We)||We.contentEditable==="true")&&(Ui=We,au=G,js=null);break;case"focusout":js=au=Ui=null;break;case"mousedown":lu=!0;break;case"contextmenu":case"mouseup":case"dragend":lu=!1,rh(he,l,ue);break;case"selectionchange":if(Ub)break;case"keydown":case"keyup":rh(he,l,ue)}var Ke;if(ru)e:{switch(r){case"compositionstart":var qe="onCompositionStart";break e;case"compositionend":qe="onCompositionEnd";break e;case"compositionupdate":qe="onCompositionUpdate";break e}qe=void 0}else Fi?Wp(r,l)&&(qe="onCompositionEnd"):r==="keydown"&&l.keyCode===229&&(qe="onCompositionStart");qe&&(Bp&&l.locale!=="ko"&&(Fi||qe!=="onCompositionStart"?qe==="onCompositionEnd"&&Fi&&(Ke=Lp()):(Fo=ue,Qc="value"in Fo?Fo.value:Fo.textContent,Fi=!0)),We=Ga(G,qe),0<We.length&&(qe=new Fp(qe,r,null,l,ue),he.push({event:qe,listeners:We}),Ke?qe.data=Ke:(Ke=Kp(l),Ke!==null&&(qe.data=Ke)))),(Ke=Ob?Rb(r,l):Cb(r,l))&&(G=Ga(G,"onBeforeInput"),0<G.length&&(ue=new Fp("onBeforeInput","beforeinput",null,l,ue),he.push({event:ue,listeners:G}),ue.data=Ke))}fh(he,i)})}function Ms(r,i,l){return{instance:r,listener:i,currentTarget:l}}function Ga(r,i){for(var l=i+"Capture",f=[];r!==null;){var y=r,v=y.stateNode;y.tag===5&&v!==null&&(y=v,v=Se(r,l),v!=null&&f.unshift(Ms(r,v,y)),v=Se(r,i),v!=null&&f.push(Ms(r,v,y))),r=r.return}return f}function Zi(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function hh(r,i,l,f,y){for(var v=i._reactName,x=[];l!==null&&l!==f;){var T=l,A=T.alternate,G=T.stateNode;if(A!==null&&A===f)break;T.tag===5&&G!==null&&(T=G,y?(A=Se(l,v),A!=null&&x.unshift(Ms(l,A,T))):y||(A=Se(l,v),A!=null&&x.push(Ms(l,A,T)))),l=l.return}x.length!==0&&r.push({event:i,listeners:x})}var Wb=/\r\n?/g,Kb=/\u0000|\uFFFD/g;function mh(r){return(typeof r=="string"?r:""+r).replace(Wb,`
93
- `).replace(Kb,"")}function qa(r,i,l){if(i=mh(i),mh(r)!==i&&l)throw Error(n(425))}function Ya(){}var hu=null,mu=null;function gu(r,i){return r==="textarea"||r==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var ku=typeof setTimeout=="function"?setTimeout:void 0,Vb=typeof clearTimeout=="function"?clearTimeout:void 0,gh=typeof Promise=="function"?Promise:void 0,Gb=typeof queueMicrotask=="function"?queueMicrotask:typeof gh<"u"?function(r){return gh.resolve(null).then(r).catch(qb)}:ku;function qb(r){setTimeout(function(){throw r})}function yu(r,i){var l=i,f=0;do{var y=l.nextSibling;if(r.removeChild(l),y&&y.nodeType===8)if(l=y.data,l==="/$"){if(f===0){r.removeChild(y),Ss(i);return}f--}else l!=="$"&&l!=="$?"&&l!=="$!"||f++;l=y}while(l);Ss(i)}function Bo(r){for(;r!=null;r=r.nextSibling){var i=r.nodeType;if(i===1||i===3)break;if(i===8){if(i=r.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return r}function kh(r){r=r.previousSibling;for(var i=0;r;){if(r.nodeType===8){var l=r.data;if(l==="$"||l==="$!"||l==="$?"){if(i===0)return r;i--}else l==="/$"&&i++}r=r.previousSibling}return null}var Hi=Math.random().toString(36).slice(2),ho="__reactFiber$"+Hi,Ps="__reactProps$"+Hi,_o="__reactContainer$"+Hi,vu="__reactEvents$"+Hi,Yb="__reactListeners$"+Hi,Qb="__reactHandles$"+Hi;function ui(r){var i=r[ho];if(i)return i;for(var l=r.parentNode;l;){if(i=l[_o]||l[ho]){if(l=i.alternate,i.child!==null||l!==null&&l.child!==null)for(r=kh(r);r!==null;){if(l=r[ho])return l;r=kh(r)}return i}r=l,l=r.parentNode}return null}function Ls(r){return r=r[ho]||r[_o],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function Wi(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function Qa(r){return r[Ps]||null}var wu=[],Ki=-1;function Zo(r){return{current:r}}function Yt(r){0>Ki||(r.current=wu[Ki],wu[Ki]=null,Ki--)}function Ht(r,i){Ki++,wu[Ki]=r.current,r.current=i}var Ho={},Kn=Zo(Ho),ur=Zo(!1),di=Ho;function Vi(r,i){var l=r.type.contextTypes;if(!l)return Ho;var f=r.stateNode;if(f&&f.__reactInternalMemoizedUnmaskedChildContext===i)return f.__reactInternalMemoizedMaskedChildContext;var y={},v;for(v in l)y[v]=i[v];return f&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=i,r.__reactInternalMemoizedMaskedChildContext=y),y}function dr(r){return r=r.childContextTypes,r!=null}function Xa(){Yt(ur),Yt(Kn)}function yh(r,i,l){if(Kn.current!==Ho)throw Error(n(168));Ht(Kn,i),Ht(ur,l)}function vh(r,i,l){var f=r.stateNode;if(i=i.childContextTypes,typeof f.getChildContext!="function")return l;f=f.getChildContext();for(var y in f)if(!(y in i))throw Error(n(108,Ae(r)||"Unknown",y));return ee({},l,f)}function Ja(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Ho,di=Kn.current,Ht(Kn,r),Ht(ur,ur.current),!0}function wh(r,i,l){var f=r.stateNode;if(!f)throw Error(n(169));l?(r=vh(r,i,di),f.__reactInternalMemoizedMergedChildContext=r,Yt(ur),Yt(Kn),Ht(Kn,r)):Yt(ur),Ht(ur,l)}var Eo=null,el=!1,bu=!1;function bh(r){Eo===null?Eo=[r]:Eo.push(r)}function Xb(r){el=!0,bh(r)}function Wo(){if(!bu&&Eo!==null){bu=!0;var r=0,i=ht;try{var l=Eo;for(ht=1;r<l.length;r++){var f=l[r];do f=f(!0);while(f!==null)}Eo=null,el=!1}catch(y){throw Eo!==null&&(Eo=Eo.slice(r+1)),Ar($r,Wo),y}finally{ht=i,bu=!1}}return null}var Gi=[],qi=0,tl=null,nl=0,Lr=[],zr=0,fi=null,So=1,No="";function pi(r,i){Gi[qi++]=nl,Gi[qi++]=tl,tl=r,nl=i}function xh(r,i,l){Lr[zr++]=So,Lr[zr++]=No,Lr[zr++]=fi,fi=r;var f=So;r=No;var y=32-Dt(f)-1;f&=~(1<<y),l+=1;var v=32-Dt(i)+y;if(30<v){var x=y-y%5;v=(f&(1<<x)-1).toString(32),f>>=x,y-=x,So=1<<32-Dt(i)+y|l<<y|f,No=v+r}else So=1<<v|l<<y|f,No=r}function xu(r){r.return!==null&&(pi(r,1),xh(r,1,0))}function _u(r){for(;r===tl;)tl=Gi[--qi],Gi[qi]=null,nl=Gi[--qi],Gi[qi]=null;for(;r===fi;)fi=Lr[--zr],Lr[zr]=null,No=Lr[--zr],Lr[zr]=null,So=Lr[--zr],Lr[zr]=null}var Er=null,Sr=null,Jt=!1,Qr=null;function _h(r,i){var l=Br(5,null,null,0);l.elementType="DELETED",l.stateNode=i,l.return=r,i=r.deletions,i===null?(r.deletions=[l],r.flags|=16):i.push(l)}function Eh(r,i){switch(r.tag){case 5:var l=r.type;return i=i.nodeType!==1||l.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(r.stateNode=i,Er=r,Sr=Bo(i.firstChild),!0):!1;case 6:return i=r.pendingProps===""||i.nodeType!==3?null:i,i!==null?(r.stateNode=i,Er=r,Sr=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(l=fi!==null?{id:So,overflow:No}:null,r.memoizedState={dehydrated:i,treeContext:l,retryLane:1073741824},l=Br(18,null,null,0),l.stateNode=i,l.return=r,r.child=l,Er=r,Sr=null,!0):!1;default:return!1}}function Eu(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Su(r){if(Jt){var i=Sr;if(i){var l=i;if(!Eh(r,i)){if(Eu(r))throw Error(n(418));i=Bo(l.nextSibling);var f=Er;i&&Eh(r,i)?_h(f,l):(r.flags=r.flags&-4097|2,Jt=!1,Er=r)}}else{if(Eu(r))throw Error(n(418));r.flags=r.flags&-4097|2,Jt=!1,Er=r}}}function Sh(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Er=r}function rl(r){if(r!==Er)return!1;if(!Jt)return Sh(r),Jt=!0,!1;var i;if((i=r.tag!==3)&&!(i=r.tag!==5)&&(i=r.type,i=i!=="head"&&i!=="body"&&!gu(r.type,r.memoizedProps)),i&&(i=Sr)){if(Eu(r))throw Nh(),Error(n(418));for(;i;)_h(r,i),i=Bo(i.nextSibling)}if(Sh(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,i=0;r;){if(r.nodeType===8){var l=r.data;if(l==="/$"){if(i===0){Sr=Bo(r.nextSibling);break e}i--}else l!=="$"&&l!=="$!"&&l!=="$?"||i++}r=r.nextSibling}Sr=null}}else Sr=Er?Bo(r.stateNode.nextSibling):null;return!0}function Nh(){for(var r=Sr;r;)r=Bo(r.nextSibling)}function Yi(){Sr=Er=null,Jt=!1}function Nu(r){Qr===null?Qr=[r]:Qr.push(r)}var Jb=M.ReactCurrentBatchConfig;function zs(r,i,l){if(r=l.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(n(309));var f=l.stateNode}if(!f)throw Error(n(147,r));var y=f,v=""+r;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===v?i.ref:(i=function(x){var T=y.refs;x===null?delete T[v]:T[v]=x},i._stringRef=v,i)}if(typeof r!="string")throw Error(n(284));if(!l._owner)throw Error(n(290,r))}return r}function ol(r,i){throw r=Object.prototype.toString.call(i),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":r))}function Th(r){var i=r._init;return i(r._payload)}function Ih(r){function i(H,P){if(r){var W=H.deletions;W===null?(H.deletions=[P],H.flags|=16):W.push(P)}}function l(H,P){if(!r)return null;for(;P!==null;)i(H,P),P=P.sibling;return null}function f(H,P){for(H=new Map;P!==null;)P.key!==null?H.set(P.key,P):H.set(P.index,P),P=P.sibling;return H}function y(H,P){return H=Jo(H,P),H.index=0,H.sibling=null,H}function v(H,P,W){return H.index=W,r?(W=H.alternate,W!==null?(W=W.index,W<P?(H.flags|=2,P):W):(H.flags|=2,P)):(H.flags|=1048576,P)}function x(H){return r&&H.alternate===null&&(H.flags|=2),H}function T(H,P,W,ye){return P===null||P.tag!==6?(P=kd(W,H.mode,ye),P.return=H,P):(P=y(P,W),P.return=H,P)}function A(H,P,W,ye){var ze=W.type;return ze===q?ue(H,P,W.props.children,ye,W.key):P!==null&&(P.elementType===ze||typeof ze=="object"&&ze!==null&&ze.$$typeof===ge&&Th(ze)===P.type)?(ye=y(P,W.props),ye.ref=zs(H,P,W),ye.return=H,ye):(ye=Il(W.type,W.key,W.props,null,H.mode,ye),ye.ref=zs(H,P,W),ye.return=H,ye)}function G(H,P,W,ye){return P===null||P.tag!==4||P.stateNode.containerInfo!==W.containerInfo||P.stateNode.implementation!==W.implementation?(P=yd(W,H.mode,ye),P.return=H,P):(P=y(P,W.children||[]),P.return=H,P)}function ue(H,P,W,ye,ze){return P===null||P.tag!==7?(P=bi(W,H.mode,ye,ze),P.return=H,P):(P=y(P,W),P.return=H,P)}function he(H,P,W){if(typeof P=="string"&&P!==""||typeof P=="number")return P=kd(""+P,H.mode,W),P.return=H,P;if(typeof P=="object"&&P!==null){switch(P.$$typeof){case $:return W=Il(P.type,P.key,P.props,null,H.mode,W),W.ref=zs(H,null,P),W.return=H,W;case D:return P=yd(P,H.mode,W),P.return=H,P;case ge:var ye=P._init;return he(H,ye(P._payload),W)}if(Vt(P)||ce(P))return P=bi(P,H.mode,W,null),P.return=H,P;ol(H,P)}return null}function le(H,P,W,ye){var ze=P!==null?P.key:null;if(typeof W=="string"&&W!==""||typeof W=="number")return ze!==null?null:T(H,P,""+W,ye);if(typeof W=="object"&&W!==null){switch(W.$$typeof){case $:return W.key===ze?A(H,P,W,ye):null;case D:return W.key===ze?G(H,P,W,ye):null;case ge:return ze=W._init,le(H,P,ze(W._payload),ye)}if(Vt(W)||ce(W))return ze!==null?null:ue(H,P,W,ye,null);ol(H,W)}return null}function je(H,P,W,ye,ze){if(typeof ye=="string"&&ye!==""||typeof ye=="number")return H=H.get(W)||null,T(P,H,""+ye,ze);if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case $:return H=H.get(ye.key===null?W:ye.key)||null,A(P,H,ye,ze);case D:return H=H.get(ye.key===null?W:ye.key)||null,G(P,H,ye,ze);case ge:var We=ye._init;return je(H,P,W,We(ye._payload),ze)}if(Vt(ye)||ce(ye))return H=H.get(W)||null,ue(P,H,ye,ze,null);ol(P,ye)}return null}function Me(H,P,W,ye){for(var ze=null,We=null,Ke=P,qe=P=0,Mn=null;Ke!==null&&qe<W.length;qe++){Ke.index>qe?(Mn=Ke,Ke=null):Mn=Ke.sibling;var Et=le(H,Ke,W[qe],ye);if(Et===null){Ke===null&&(Ke=Mn);break}r&&Ke&&Et.alternate===null&&i(H,Ke),P=v(Et,P,qe),We===null?ze=Et:We.sibling=Et,We=Et,Ke=Mn}if(qe===W.length)return l(H,Ke),Jt&&pi(H,qe),ze;if(Ke===null){for(;qe<W.length;qe++)Ke=he(H,W[qe],ye),Ke!==null&&(P=v(Ke,P,qe),We===null?ze=Ke:We.sibling=Ke,We=Ke);return Jt&&pi(H,qe),ze}for(Ke=f(H,Ke);qe<W.length;qe++)Mn=je(Ke,H,qe,W[qe],ye),Mn!==null&&(r&&Mn.alternate!==null&&Ke.delete(Mn.key===null?qe:Mn.key),P=v(Mn,P,qe),We===null?ze=Mn:We.sibling=Mn,We=Mn);return r&&Ke.forEach(function(ei){return i(H,ei)}),Jt&&pi(H,qe),ze}function Le(H,P,W,ye){var ze=ce(W);if(typeof ze!="function")throw Error(n(150));if(W=ze.call(W),W==null)throw Error(n(151));for(var We=ze=null,Ke=P,qe=P=0,Mn=null,Et=W.next();Ke!==null&&!Et.done;qe++,Et=W.next()){Ke.index>qe?(Mn=Ke,Ke=null):Mn=Ke.sibling;var ei=le(H,Ke,Et.value,ye);if(ei===null){Ke===null&&(Ke=Mn);break}r&&Ke&&ei.alternate===null&&i(H,Ke),P=v(ei,P,qe),We===null?ze=ei:We.sibling=ei,We=ei,Ke=Mn}if(Et.done)return l(H,Ke),Jt&&pi(H,qe),ze;if(Ke===null){for(;!Et.done;qe++,Et=W.next())Et=he(H,Et.value,ye),Et!==null&&(P=v(Et,P,qe),We===null?ze=Et:We.sibling=Et,We=Et);return Jt&&pi(H,qe),ze}for(Ke=f(H,Ke);!Et.done;qe++,Et=W.next())Et=je(Ke,H,qe,Et.value,ye),Et!==null&&(r&&Et.alternate!==null&&Ke.delete(Et.key===null?qe:Et.key),P=v(Et,P,qe),We===null?ze=Et:We.sibling=Et,We=Et);return r&&Ke.forEach(function(jx){return i(H,jx)}),Jt&&pi(H,qe),ze}function pn(H,P,W,ye){if(typeof W=="object"&&W!==null&&W.type===q&&W.key===null&&(W=W.props.children),typeof W=="object"&&W!==null){switch(W.$$typeof){case $:e:{for(var ze=W.key,We=P;We!==null;){if(We.key===ze){if(ze=W.type,ze===q){if(We.tag===7){l(H,We.sibling),P=y(We,W.props.children),P.return=H,H=P;break e}}else if(We.elementType===ze||typeof ze=="object"&&ze!==null&&ze.$$typeof===ge&&Th(ze)===We.type){l(H,We.sibling),P=y(We,W.props),P.ref=zs(H,We,W),P.return=H,H=P;break e}l(H,We);break}else i(H,We);We=We.sibling}W.type===q?(P=bi(W.props.children,H.mode,ye,W.key),P.return=H,H=P):(ye=Il(W.type,W.key,W.props,null,H.mode,ye),ye.ref=zs(H,P,W),ye.return=H,H=ye)}return x(H);case D:e:{for(We=W.key;P!==null;){if(P.key===We)if(P.tag===4&&P.stateNode.containerInfo===W.containerInfo&&P.stateNode.implementation===W.implementation){l(H,P.sibling),P=y(P,W.children||[]),P.return=H,H=P;break e}else{l(H,P);break}else i(H,P);P=P.sibling}P=yd(W,H.mode,ye),P.return=H,H=P}return x(H);case ge:return We=W._init,pn(H,P,We(W._payload),ye)}if(Vt(W))return Me(H,P,W,ye);if(ce(W))return Le(H,P,W,ye);ol(H,W)}return typeof W=="string"&&W!==""||typeof W=="number"?(W=""+W,P!==null&&P.tag===6?(l(H,P.sibling),P=y(P,W),P.return=H,H=P):(l(H,P),P=kd(W,H.mode,ye),P.return=H,H=P),x(H)):l(H,P)}return pn}var Qi=Ih(!0),Oh=Ih(!1),il=Zo(null),sl=null,Xi=null,Tu=null;function Iu(){Tu=Xi=sl=null}function Ou(r){var i=il.current;Yt(il),r._currentValue=i}function Ru(r,i,l){for(;r!==null;){var f=r.alternate;if((r.childLanes&i)!==i?(r.childLanes|=i,f!==null&&(f.childLanes|=i)):f!==null&&(f.childLanes&i)!==i&&(f.childLanes|=i),r===l)break;r=r.return}}function Ji(r,i){sl=r,Tu=Xi=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&i)!==0&&(fr=!0),r.firstContext=null)}function Dr(r){var i=r._currentValue;if(Tu!==r)if(r={context:r,memoizedValue:i,next:null},Xi===null){if(sl===null)throw Error(n(308));Xi=r,sl.dependencies={lanes:0,firstContext:r}}else Xi=Xi.next=r;return i}var hi=null;function Cu(r){hi===null?hi=[r]:hi.push(r)}function Rh(r,i,l,f){var y=i.interleaved;return y===null?(l.next=l,Cu(i)):(l.next=y.next,y.next=l),i.interleaved=l,To(r,f)}function To(r,i){r.lanes|=i;var l=r.alternate;for(l!==null&&(l.lanes|=i),l=r,r=r.return;r!==null;)r.childLanes|=i,l=r.alternate,l!==null&&(l.childLanes|=i),l=r,r=r.return;return l.tag===3?l.stateNode:null}var Ko=!1;function ju(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ch(r,i){r=r.updateQueue,i.updateQueue===r&&(i.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function Io(r,i){return{eventTime:r,lane:i,tag:0,payload:null,callback:null,next:null}}function Vo(r,i,l){var f=r.updateQueue;if(f===null)return null;if(f=f.shared,(bt&2)!==0){var y=f.pending;return y===null?i.next=i:(i.next=y.next,y.next=i),f.pending=i,To(r,l)}return y=f.interleaved,y===null?(i.next=i,Cu(f)):(i.next=y.next,y.next=i),f.interleaved=i,To(r,l)}function al(r,i,l){if(i=i.updateQueue,i!==null&&(i=i.shared,(l&4194240)!==0)){var f=i.lanes;f&=r.pendingLanes,l|=f,i.lanes=l,Do(r,l)}}function jh(r,i){var l=r.updateQueue,f=r.alternate;if(f!==null&&(f=f.updateQueue,l===f)){var y=null,v=null;if(l=l.firstBaseUpdate,l!==null){do{var x={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};v===null?y=v=x:v=v.next=x,l=l.next}while(l!==null);v===null?y=v=i:v=v.next=i}else y=v=i;l={baseState:f.baseState,firstBaseUpdate:y,lastBaseUpdate:v,shared:f.shared,effects:f.effects},r.updateQueue=l;return}r=l.lastBaseUpdate,r===null?l.firstBaseUpdate=i:r.next=i,l.lastBaseUpdate=i}function ll(r,i,l,f){var y=r.updateQueue;Ko=!1;var v=y.firstBaseUpdate,x=y.lastBaseUpdate,T=y.shared.pending;if(T!==null){y.shared.pending=null;var A=T,G=A.next;A.next=null,x===null?v=G:x.next=G,x=A;var ue=r.alternate;ue!==null&&(ue=ue.updateQueue,T=ue.lastBaseUpdate,T!==x&&(T===null?ue.firstBaseUpdate=G:T.next=G,ue.lastBaseUpdate=A))}if(v!==null){var he=y.baseState;x=0,ue=G=A=null,T=v;do{var le=T.lane,je=T.eventTime;if((f&le)===le){ue!==null&&(ue=ue.next={eventTime:je,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var Me=r,Le=T;switch(le=i,je=l,Le.tag){case 1:if(Me=Le.payload,typeof Me=="function"){he=Me.call(je,he,le);break e}he=Me;break e;case 3:Me.flags=Me.flags&-65537|128;case 0:if(Me=Le.payload,le=typeof Me=="function"?Me.call(je,he,le):Me,le==null)break e;he=ee({},he,le);break e;case 2:Ko=!0}}T.callback!==null&&T.lane!==0&&(r.flags|=64,le=y.effects,le===null?y.effects=[T]:le.push(T))}else je={eventTime:je,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ue===null?(G=ue=je,A=he):ue=ue.next=je,x|=le;if(T=T.next,T===null){if(T=y.shared.pending,T===null)break;le=T,T=le.next,le.next=null,y.lastBaseUpdate=le,y.shared.pending=null}}while(!0);if(ue===null&&(A=he),y.baseState=A,y.firstBaseUpdate=G,y.lastBaseUpdate=ue,i=y.shared.interleaved,i!==null){y=i;do x|=y.lane,y=y.next;while(y!==i)}else v===null&&(y.shared.lanes=0);ki|=x,r.lanes=x,r.memoizedState=he}}function Ah(r,i,l){if(r=i.effects,i.effects=null,r!==null)for(i=0;i<r.length;i++){var f=r[i],y=f.callback;if(y!==null){if(f.callback=null,f=l,typeof y!="function")throw Error(n(191,y));y.call(f)}}}var Ds={},mo=Zo(Ds),Fs=Zo(Ds),Us=Zo(Ds);function mi(r){if(r===Ds)throw Error(n(174));return r}function Au(r,i){switch(Ht(Us,i),Ht(Fs,r),Ht(mo,Ds),r=i.nodeType,r){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:Gt(null,"");break;default:r=r===8?i.parentNode:i,i=r.namespaceURI||null,r=r.tagName,i=Gt(i,r)}Yt(mo),Ht(mo,i)}function es(){Yt(mo),Yt(Fs),Yt(Us)}function $h(r){mi(Us.current);var i=mi(mo.current),l=Gt(i,r.type);i!==l&&(Ht(Fs,r),Ht(mo,l))}function $u(r){Fs.current===r&&(Yt(mo),Yt(Fs))}var an=Zo(0);function cl(r){for(var i=r;i!==null;){if(i.tag===13){var l=i.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var Mu=[];function Pu(){for(var r=0;r<Mu.length;r++)Mu[r]._workInProgressVersionPrimary=null;Mu.length=0}var ul=M.ReactCurrentDispatcher,Lu=M.ReactCurrentBatchConfig,gi=0,ln=null,Nn=null,An=null,dl=!1,Bs=!1,Zs=0,ex=0;function Vn(){throw Error(n(321))}function zu(r,i){if(i===null)return!1;for(var l=0;l<i.length&&l<r.length;l++)if(!Yr(r[l],i[l]))return!1;return!0}function Du(r,i,l,f,y,v){if(gi=v,ln=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,ul.current=r===null||r.memoizedState===null?ox:ix,r=l(f,y),Bs){v=0;do{if(Bs=!1,Zs=0,25<=v)throw Error(n(301));v+=1,An=Nn=null,i.updateQueue=null,ul.current=sx,r=l(f,y)}while(Bs)}if(ul.current=hl,i=Nn!==null&&Nn.next!==null,gi=0,An=Nn=ln=null,dl=!1,i)throw Error(n(300));return r}function Fu(){var r=Zs!==0;return Zs=0,r}function go(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return An===null?ln.memoizedState=An=r:An=An.next=r,An}function Fr(){if(Nn===null){var r=ln.alternate;r=r!==null?r.memoizedState:null}else r=Nn.next;var i=An===null?ln.memoizedState:An.next;if(i!==null)An=i,Nn=r;else{if(r===null)throw Error(n(310));Nn=r,r={memoizedState:Nn.memoizedState,baseState:Nn.baseState,baseQueue:Nn.baseQueue,queue:Nn.queue,next:null},An===null?ln.memoizedState=An=r:An=An.next=r}return An}function Hs(r,i){return typeof i=="function"?i(r):i}function Uu(r){var i=Fr(),l=i.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=r;var f=Nn,y=f.baseQueue,v=l.pending;if(v!==null){if(y!==null){var x=y.next;y.next=v.next,v.next=x}f.baseQueue=y=v,l.pending=null}if(y!==null){v=y.next,f=f.baseState;var T=x=null,A=null,G=v;do{var ue=G.lane;if((gi&ue)===ue)A!==null&&(A=A.next={lane:0,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),f=G.hasEagerState?G.eagerState:r(f,G.action);else{var he={lane:ue,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null};A===null?(T=A=he,x=f):A=A.next=he,ln.lanes|=ue,ki|=ue}G=G.next}while(G!==null&&G!==v);A===null?x=f:A.next=T,Yr(f,i.memoizedState)||(fr=!0),i.memoizedState=f,i.baseState=x,i.baseQueue=A,l.lastRenderedState=f}if(r=l.interleaved,r!==null){y=r;do v=y.lane,ln.lanes|=v,ki|=v,y=y.next;while(y!==r)}else y===null&&(l.lanes=0);return[i.memoizedState,l.dispatch]}function Bu(r){var i=Fr(),l=i.queue;if(l===null)throw Error(n(311));l.lastRenderedReducer=r;var f=l.dispatch,y=l.pending,v=i.memoizedState;if(y!==null){l.pending=null;var x=y=y.next;do v=r(v,x.action),x=x.next;while(x!==y);Yr(v,i.memoizedState)||(fr=!0),i.memoizedState=v,i.baseQueue===null&&(i.baseState=v),l.lastRenderedState=v}return[v,f]}function Mh(){}function Ph(r,i){var l=ln,f=Fr(),y=i(),v=!Yr(f.memoizedState,y);if(v&&(f.memoizedState=y,fr=!0),f=f.queue,Zu(Dh.bind(null,l,f,r),[r]),f.getSnapshot!==i||v||An!==null&&An.memoizedState.tag&1){if(l.flags|=2048,Ws(9,zh.bind(null,l,f,y,i),void 0,null),$n===null)throw Error(n(349));(gi&30)!==0||Lh(l,i,y)}return y}function Lh(r,i,l){r.flags|=16384,r={getSnapshot:i,value:l},i=ln.updateQueue,i===null?(i={lastEffect:null,stores:null},ln.updateQueue=i,i.stores=[r]):(l=i.stores,l===null?i.stores=[r]:l.push(r))}function zh(r,i,l,f){i.value=l,i.getSnapshot=f,Fh(i)&&Uh(r)}function Dh(r,i,l){return l(function(){Fh(i)&&Uh(r)})}function Fh(r){var i=r.getSnapshot;r=r.value;try{var l=i();return!Yr(r,l)}catch{return!0}}function Uh(r){var i=To(r,1);i!==null&&to(i,r,1,-1)}function Bh(r){var i=go();return typeof r=="function"&&(r=r()),i.memoizedState=i.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:r},i.queue=r,r=r.dispatch=rx.bind(null,ln,r),[i.memoizedState,r]}function Ws(r,i,l,f){return r={tag:r,create:i,destroy:l,deps:f,next:null},i=ln.updateQueue,i===null?(i={lastEffect:null,stores:null},ln.updateQueue=i,i.lastEffect=r.next=r):(l=i.lastEffect,l===null?i.lastEffect=r.next=r:(f=l.next,l.next=r,r.next=f,i.lastEffect=r)),r}function Zh(){return Fr().memoizedState}function fl(r,i,l,f){var y=go();ln.flags|=r,y.memoizedState=Ws(1|i,l,void 0,f===void 0?null:f)}function pl(r,i,l,f){var y=Fr();f=f===void 0?null:f;var v=void 0;if(Nn!==null){var x=Nn.memoizedState;if(v=x.destroy,f!==null&&zu(f,x.deps)){y.memoizedState=Ws(i,l,v,f);return}}ln.flags|=r,y.memoizedState=Ws(1|i,l,v,f)}function Hh(r,i){return fl(8390656,8,r,i)}function Zu(r,i){return pl(2048,8,r,i)}function Wh(r,i){return pl(4,2,r,i)}function Kh(r,i){return pl(4,4,r,i)}function Vh(r,i){if(typeof i=="function")return r=r(),i(r),function(){i(null)};if(i!=null)return r=r(),i.current=r,function(){i.current=null}}function Gh(r,i,l){return l=l!=null?l.concat([r]):null,pl(4,4,Vh.bind(null,i,r),l)}function Hu(){}function qh(r,i){var l=Fr();i=i===void 0?null:i;var f=l.memoizedState;return f!==null&&i!==null&&zu(i,f[1])?f[0]:(l.memoizedState=[r,i],r)}function Yh(r,i){var l=Fr();i=i===void 0?null:i;var f=l.memoizedState;return f!==null&&i!==null&&zu(i,f[1])?f[0]:(r=r(),l.memoizedState=[r,i],r)}function Qh(r,i,l){return(gi&21)===0?(r.baseState&&(r.baseState=!1,fr=!0),r.memoizedState=l):(Yr(l,i)||(l=Li(),ln.lanes|=l,ki|=l,r.baseState=!0),i)}function tx(r,i){var l=ht;ht=l!==0&&4>l?l:4,r(!0);var f=Lu.transition;Lu.transition={};try{r(!1),i()}finally{ht=l,Lu.transition=f}}function Xh(){return Fr().memoizedState}function nx(r,i,l){var f=Qo(r);if(l={lane:f,action:l,hasEagerState:!1,eagerState:null,next:null},Jh(r))em(i,l);else if(l=Rh(r,i,l,f),l!==null){var y=ir();to(l,r,f,y),tm(l,i,f)}}function rx(r,i,l){var f=Qo(r),y={lane:f,action:l,hasEagerState:!1,eagerState:null,next:null};if(Jh(r))em(i,y);else{var v=r.alternate;if(r.lanes===0&&(v===null||v.lanes===0)&&(v=i.lastRenderedReducer,v!==null))try{var x=i.lastRenderedState,T=v(x,l);if(y.hasEagerState=!0,y.eagerState=T,Yr(T,x)){var A=i.interleaved;A===null?(y.next=y,Cu(i)):(y.next=A.next,A.next=y),i.interleaved=y;return}}catch{}finally{}l=Rh(r,i,y,f),l!==null&&(y=ir(),to(l,r,f,y),tm(l,i,f))}}function Jh(r){var i=r.alternate;return r===ln||i!==null&&i===ln}function em(r,i){Bs=dl=!0;var l=r.pending;l===null?i.next=i:(i.next=l.next,l.next=i),r.pending=i}function tm(r,i,l){if((l&4194240)!==0){var f=i.lanes;f&=r.pendingLanes,l|=f,i.lanes=l,Do(r,l)}}var hl={readContext:Dr,useCallback:Vn,useContext:Vn,useEffect:Vn,useImperativeHandle:Vn,useInsertionEffect:Vn,useLayoutEffect:Vn,useMemo:Vn,useReducer:Vn,useRef:Vn,useState:Vn,useDebugValue:Vn,useDeferredValue:Vn,useTransition:Vn,useMutableSource:Vn,useSyncExternalStore:Vn,useId:Vn,unstable_isNewReconciler:!1},ox={readContext:Dr,useCallback:function(r,i){return go().memoizedState=[r,i===void 0?null:i],r},useContext:Dr,useEffect:Hh,useImperativeHandle:function(r,i,l){return l=l!=null?l.concat([r]):null,fl(4194308,4,Vh.bind(null,i,r),l)},useLayoutEffect:function(r,i){return fl(4194308,4,r,i)},useInsertionEffect:function(r,i){return fl(4,2,r,i)},useMemo:function(r,i){var l=go();return i=i===void 0?null:i,r=r(),l.memoizedState=[r,i],r},useReducer:function(r,i,l){var f=go();return i=l!==void 0?l(i):i,f.memoizedState=f.baseState=i,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:i},f.queue=r,r=r.dispatch=nx.bind(null,ln,r),[f.memoizedState,r]},useRef:function(r){var i=go();return r={current:r},i.memoizedState=r},useState:Bh,useDebugValue:Hu,useDeferredValue:function(r){return go().memoizedState=r},useTransition:function(){var r=Bh(!1),i=r[0];return r=tx.bind(null,r[1]),go().memoizedState=r,[i,r]},useMutableSource:function(){},useSyncExternalStore:function(r,i,l){var f=ln,y=go();if(Jt){if(l===void 0)throw Error(n(407));l=l()}else{if(l=i(),$n===null)throw Error(n(349));(gi&30)!==0||Lh(f,i,l)}y.memoizedState=l;var v={value:l,getSnapshot:i};return y.queue=v,Hh(Dh.bind(null,f,v,r),[r]),f.flags|=2048,Ws(9,zh.bind(null,f,v,l,i),void 0,null),l},useId:function(){var r=go(),i=$n.identifierPrefix;if(Jt){var l=No,f=So;l=(f&~(1<<32-Dt(f)-1)).toString(32)+l,i=":"+i+"R"+l,l=Zs++,0<l&&(i+="H"+l.toString(32)),i+=":"}else l=ex++,i=":"+i+"r"+l.toString(32)+":";return r.memoizedState=i},unstable_isNewReconciler:!1},ix={readContext:Dr,useCallback:qh,useContext:Dr,useEffect:Zu,useImperativeHandle:Gh,useInsertionEffect:Wh,useLayoutEffect:Kh,useMemo:Yh,useReducer:Uu,useRef:Zh,useState:function(){return Uu(Hs)},useDebugValue:Hu,useDeferredValue:function(r){var i=Fr();return Qh(i,Nn.memoizedState,r)},useTransition:function(){var r=Uu(Hs)[0],i=Fr().memoizedState;return[r,i]},useMutableSource:Mh,useSyncExternalStore:Ph,useId:Xh,unstable_isNewReconciler:!1},sx={readContext:Dr,useCallback:qh,useContext:Dr,useEffect:Zu,useImperativeHandle:Gh,useInsertionEffect:Wh,useLayoutEffect:Kh,useMemo:Yh,useReducer:Bu,useRef:Zh,useState:function(){return Bu(Hs)},useDebugValue:Hu,useDeferredValue:function(r){var i=Fr();return Nn===null?i.memoizedState=r:Qh(i,Nn.memoizedState,r)},useTransition:function(){var r=Bu(Hs)[0],i=Fr().memoizedState;return[r,i]},useMutableSource:Mh,useSyncExternalStore:Ph,useId:Xh,unstable_isNewReconciler:!1};function Xr(r,i){if(r&&r.defaultProps){i=ee({},i),r=r.defaultProps;for(var l in r)i[l]===void 0&&(i[l]=r[l]);return i}return i}function Wu(r,i,l,f){i=r.memoizedState,l=l(f,i),l=l==null?i:ee({},i,l),r.memoizedState=l,r.lanes===0&&(r.updateQueue.baseState=l)}var ml={isMounted:function(r){return(r=r._reactInternals)?lr(r)===r:!1},enqueueSetState:function(r,i,l){r=r._reactInternals;var f=ir(),y=Qo(r),v=Io(f,y);v.payload=i,l!=null&&(v.callback=l),i=Vo(r,v,y),i!==null&&(to(i,r,y,f),al(i,r,y))},enqueueReplaceState:function(r,i,l){r=r._reactInternals;var f=ir(),y=Qo(r),v=Io(f,y);v.tag=1,v.payload=i,l!=null&&(v.callback=l),i=Vo(r,v,y),i!==null&&(to(i,r,y,f),al(i,r,y))},enqueueForceUpdate:function(r,i){r=r._reactInternals;var l=ir(),f=Qo(r),y=Io(l,f);y.tag=2,i!=null&&(y.callback=i),i=Vo(r,y,f),i!==null&&(to(i,r,f,l),al(i,r,f))}};function nm(r,i,l,f,y,v,x){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(f,v,x):i.prototype&&i.prototype.isPureReactComponent?!Cs(l,f)||!Cs(y,v):!0}function rm(r,i,l){var f=!1,y=Ho,v=i.contextType;return typeof v=="object"&&v!==null?v=Dr(v):(y=dr(i)?di:Kn.current,f=i.contextTypes,v=(f=f!=null)?Vi(r,y):Ho),i=new i(l,v),r.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=ml,r.stateNode=i,i._reactInternals=r,f&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=y,r.__reactInternalMemoizedMaskedChildContext=v),i}function om(r,i,l,f){r=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(l,f),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(l,f),i.state!==r&&ml.enqueueReplaceState(i,i.state,null)}function Ku(r,i,l,f){var y=r.stateNode;y.props=l,y.state=r.memoizedState,y.refs={},ju(r);var v=i.contextType;typeof v=="object"&&v!==null?y.context=Dr(v):(v=dr(i)?di:Kn.current,y.context=Vi(r,v)),y.state=r.memoizedState,v=i.getDerivedStateFromProps,typeof v=="function"&&(Wu(r,i,v,l),y.state=r.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(i=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),i!==y.state&&ml.enqueueReplaceState(y,y.state,null),ll(r,l,y,f),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308)}function ts(r,i){try{var l="",f=i;do l+=V(f),f=f.return;while(f);var y=l}catch(v){y=`
94
- Error generating stack: `+v.message+`
95
- `+v.stack}return{value:r,source:i,stack:y,digest:null}}function Vu(r,i,l){return{value:r,source:null,stack:l??null,digest:i??null}}function Gu(r,i){try{console.error(i.value)}catch(l){setTimeout(function(){throw l})}}var ax=typeof WeakMap=="function"?WeakMap:Map;function im(r,i,l){l=Io(-1,l),l.tag=3,l.payload={element:null};var f=i.value;return l.callback=function(){xl||(xl=!0,cd=f),Gu(r,i)},l}function sm(r,i,l){l=Io(-1,l),l.tag=3;var f=r.type.getDerivedStateFromError;if(typeof f=="function"){var y=i.value;l.payload=function(){return f(y)},l.callback=function(){Gu(r,i)}}var v=r.stateNode;return v!==null&&typeof v.componentDidCatch=="function"&&(l.callback=function(){Gu(r,i),typeof f!="function"&&(qo===null?qo=new Set([this]):qo.add(this));var x=i.stack;this.componentDidCatch(i.value,{componentStack:x!==null?x:""})}),l}function am(r,i,l){var f=r.pingCache;if(f===null){f=r.pingCache=new ax;var y=new Set;f.set(i,y)}else y=f.get(i),y===void 0&&(y=new Set,f.set(i,y));y.has(l)||(y.add(l),r=bx.bind(null,r,i,l),i.then(r,r))}function lm(r){do{var i;if((i=r.tag===13)&&(i=r.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return r;r=r.return}while(r!==null);return null}function cm(r,i,l,f,y){return(r.mode&1)===0?(r===i?r.flags|=65536:(r.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(i=Io(-1,1),i.tag=2,Vo(l,i,1))),l.lanes|=1),r):(r.flags|=65536,r.lanes=y,r)}var lx=M.ReactCurrentOwner,fr=!1;function or(r,i,l,f){i.child=r===null?Oh(i,null,l,f):Qi(i,r.child,l,f)}function um(r,i,l,f,y){l=l.render;var v=i.ref;return Ji(i,y),f=Du(r,i,l,f,v,y),l=Fu(),r!==null&&!fr?(i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~y,Oo(r,i,y)):(Jt&&l&&xu(i),i.flags|=1,or(r,i,f,y),i.child)}function dm(r,i,l,f,y){if(r===null){var v=l.type;return typeof v=="function"&&!gd(v)&&v.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(i.tag=15,i.type=v,fm(r,i,v,f,y)):(r=Il(l.type,null,f,i,i.mode,y),r.ref=i.ref,r.return=i,i.child=r)}if(v=r.child,(r.lanes&y)===0){var x=v.memoizedProps;if(l=l.compare,l=l!==null?l:Cs,l(x,f)&&r.ref===i.ref)return Oo(r,i,y)}return i.flags|=1,r=Jo(v,f),r.ref=i.ref,r.return=i,i.child=r}function fm(r,i,l,f,y){if(r!==null){var v=r.memoizedProps;if(Cs(v,f)&&r.ref===i.ref)if(fr=!1,i.pendingProps=f=v,(r.lanes&y)!==0)(r.flags&131072)!==0&&(fr=!0);else return i.lanes=r.lanes,Oo(r,i,y)}return qu(r,i,l,f,y)}function pm(r,i,l){var f=i.pendingProps,y=f.children,v=r!==null?r.memoizedState:null;if(f.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ht(rs,Nr),Nr|=l;else{if((l&1073741824)===0)return r=v!==null?v.baseLanes|l:l,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:r,cachePool:null,transitions:null},i.updateQueue=null,Ht(rs,Nr),Nr|=r,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},f=v!==null?v.baseLanes:l,Ht(rs,Nr),Nr|=f}else v!==null?(f=v.baseLanes|l,i.memoizedState=null):f=l,Ht(rs,Nr),Nr|=f;return or(r,i,y,l),i.child}function hm(r,i){var l=i.ref;(r===null&&l!==null||r!==null&&r.ref!==l)&&(i.flags|=512,i.flags|=2097152)}function qu(r,i,l,f,y){var v=dr(l)?di:Kn.current;return v=Vi(i,v),Ji(i,y),l=Du(r,i,l,f,v,y),f=Fu(),r!==null&&!fr?(i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~y,Oo(r,i,y)):(Jt&&f&&xu(i),i.flags|=1,or(r,i,l,y),i.child)}function mm(r,i,l,f,y){if(dr(l)){var v=!0;Ja(i)}else v=!1;if(Ji(i,y),i.stateNode===null)kl(r,i),rm(i,l,f),Ku(i,l,f,y),f=!0;else if(r===null){var x=i.stateNode,T=i.memoizedProps;x.props=T;var A=x.context,G=l.contextType;typeof G=="object"&&G!==null?G=Dr(G):(G=dr(l)?di:Kn.current,G=Vi(i,G));var ue=l.getDerivedStateFromProps,he=typeof ue=="function"||typeof x.getSnapshotBeforeUpdate=="function";he||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(T!==f||A!==G)&&om(i,x,f,G),Ko=!1;var le=i.memoizedState;x.state=le,ll(i,f,x,y),A=i.memoizedState,T!==f||le!==A||ur.current||Ko?(typeof ue=="function"&&(Wu(i,l,ue,f),A=i.memoizedState),(T=Ko||nm(i,l,T,f,le,A,G))?(he||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(i.flags|=4194308)):(typeof x.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=f,i.memoizedState=A),x.props=f,x.state=A,x.context=G,f=T):(typeof x.componentDidMount=="function"&&(i.flags|=4194308),f=!1)}else{x=i.stateNode,Ch(r,i),T=i.memoizedProps,G=i.type===i.elementType?T:Xr(i.type,T),x.props=G,he=i.pendingProps,le=x.context,A=l.contextType,typeof A=="object"&&A!==null?A=Dr(A):(A=dr(l)?di:Kn.current,A=Vi(i,A));var je=l.getDerivedStateFromProps;(ue=typeof je=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(T!==he||le!==A)&&om(i,x,f,A),Ko=!1,le=i.memoizedState,x.state=le,ll(i,f,x,y);var Me=i.memoizedState;T!==he||le!==Me||ur.current||Ko?(typeof je=="function"&&(Wu(i,l,je,f),Me=i.memoizedState),(G=Ko||nm(i,l,G,f,le,Me,A)||!1)?(ue||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(f,Me,A),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(f,Me,A)),typeof x.componentDidUpdate=="function"&&(i.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof x.componentDidUpdate!="function"||T===r.memoizedProps&&le===r.memoizedState||(i.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||T===r.memoizedProps&&le===r.memoizedState||(i.flags|=1024),i.memoizedProps=f,i.memoizedState=Me),x.props=f,x.state=Me,x.context=A,f=G):(typeof x.componentDidUpdate!="function"||T===r.memoizedProps&&le===r.memoizedState||(i.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||T===r.memoizedProps&&le===r.memoizedState||(i.flags|=1024),f=!1)}return Yu(r,i,l,f,v,y)}function Yu(r,i,l,f,y,v){hm(r,i);var x=(i.flags&128)!==0;if(!f&&!x)return y&&wh(i,l,!1),Oo(r,i,v);f=i.stateNode,lx.current=i;var T=x&&typeof l.getDerivedStateFromError!="function"?null:f.render();return i.flags|=1,r!==null&&x?(i.child=Qi(i,r.child,null,v),i.child=Qi(i,null,T,v)):or(r,i,T,v),i.memoizedState=f.state,y&&wh(i,l,!0),i.child}function gm(r){var i=r.stateNode;i.pendingContext?yh(r,i.pendingContext,i.pendingContext!==i.context):i.context&&yh(r,i.context,!1),Au(r,i.containerInfo)}function km(r,i,l,f,y){return Yi(),Nu(y),i.flags|=256,or(r,i,l,f),i.child}var Qu={dehydrated:null,treeContext:null,retryLane:0};function Xu(r){return{baseLanes:r,cachePool:null,transitions:null}}function ym(r,i,l){var f=i.pendingProps,y=an.current,v=!1,x=(i.flags&128)!==0,T;if((T=x)||(T=r!==null&&r.memoizedState===null?!1:(y&2)!==0),T?(v=!0,i.flags&=-129):(r===null||r.memoizedState!==null)&&(y|=1),Ht(an,y&1),r===null)return Su(i),r=i.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((i.mode&1)===0?i.lanes=1:r.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(x=f.children,r=f.fallback,v?(f=i.mode,v=i.child,x={mode:"hidden",children:x},(f&1)===0&&v!==null?(v.childLanes=0,v.pendingProps=x):v=Ol(x,f,0,null),r=bi(r,f,l,null),v.return=i,r.return=i,v.sibling=r,i.child=v,i.child.memoizedState=Xu(l),i.memoizedState=Qu,r):Ju(i,x));if(y=r.memoizedState,y!==null&&(T=y.dehydrated,T!==null))return cx(r,i,x,f,T,y,l);if(v){v=f.fallback,x=i.mode,y=r.child,T=y.sibling;var A={mode:"hidden",children:f.children};return(x&1)===0&&i.child!==y?(f=i.child,f.childLanes=0,f.pendingProps=A,i.deletions=null):(f=Jo(y,A),f.subtreeFlags=y.subtreeFlags&14680064),T!==null?v=Jo(T,v):(v=bi(v,x,l,null),v.flags|=2),v.return=i,f.return=i,f.sibling=v,i.child=f,f=v,v=i.child,x=r.child.memoizedState,x=x===null?Xu(l):{baseLanes:x.baseLanes|l,cachePool:null,transitions:x.transitions},v.memoizedState=x,v.childLanes=r.childLanes&~l,i.memoizedState=Qu,f}return v=r.child,r=v.sibling,f=Jo(v,{mode:"visible",children:f.children}),(i.mode&1)===0&&(f.lanes=l),f.return=i,f.sibling=null,r!==null&&(l=i.deletions,l===null?(i.deletions=[r],i.flags|=16):l.push(r)),i.child=f,i.memoizedState=null,f}function Ju(r,i){return i=Ol({mode:"visible",children:i},r.mode,0,null),i.return=r,r.child=i}function gl(r,i,l,f){return f!==null&&Nu(f),Qi(i,r.child,null,l),r=Ju(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function cx(r,i,l,f,y,v,x){if(l)return i.flags&256?(i.flags&=-257,f=Vu(Error(n(422))),gl(r,i,x,f)):i.memoizedState!==null?(i.child=r.child,i.flags|=128,null):(v=f.fallback,y=i.mode,f=Ol({mode:"visible",children:f.children},y,0,null),v=bi(v,y,x,null),v.flags|=2,f.return=i,v.return=i,f.sibling=v,i.child=f,(i.mode&1)!==0&&Qi(i,r.child,null,x),i.child.memoizedState=Xu(x),i.memoizedState=Qu,v);if((i.mode&1)===0)return gl(r,i,x,null);if(y.data==="$!"){if(f=y.nextSibling&&y.nextSibling.dataset,f)var T=f.dgst;return f=T,v=Error(n(419)),f=Vu(v,f,void 0),gl(r,i,x,f)}if(T=(x&r.childLanes)!==0,fr||T){if(f=$n,f!==null){switch(x&-x){case 4:y=2;break;case 16:y=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:y=32;break;case 536870912:y=268435456;break;default:y=0}y=(y&(f.suspendedLanes|x))!==0?0:y,y!==0&&y!==v.retryLane&&(v.retryLane=y,To(r,y),to(f,r,y,-1))}return md(),f=Vu(Error(n(421))),gl(r,i,x,f)}return y.data==="$?"?(i.flags|=128,i.child=r.child,i=xx.bind(null,r),y._reactRetry=i,null):(r=v.treeContext,Sr=Bo(y.nextSibling),Er=i,Jt=!0,Qr=null,r!==null&&(Lr[zr++]=So,Lr[zr++]=No,Lr[zr++]=fi,So=r.id,No=r.overflow,fi=i),i=Ju(i,f.children),i.flags|=4096,i)}function vm(r,i,l){r.lanes|=i;var f=r.alternate;f!==null&&(f.lanes|=i),Ru(r.return,i,l)}function ed(r,i,l,f,y){var v=r.memoizedState;v===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:f,tail:l,tailMode:y}:(v.isBackwards=i,v.rendering=null,v.renderingStartTime=0,v.last=f,v.tail=l,v.tailMode=y)}function wm(r,i,l){var f=i.pendingProps,y=f.revealOrder,v=f.tail;if(or(r,i,f.children,l),f=an.current,(f&2)!==0)f=f&1|2,i.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=i.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&vm(r,l,i);else if(r.tag===19)vm(r,l,i);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}f&=1}if(Ht(an,f),(i.mode&1)===0)i.memoizedState=null;else switch(y){case"forwards":for(l=i.child,y=null;l!==null;)r=l.alternate,r!==null&&cl(r)===null&&(y=l),l=l.sibling;l=y,l===null?(y=i.child,i.child=null):(y=l.sibling,l.sibling=null),ed(i,!1,y,l,v);break;case"backwards":for(l=null,y=i.child,i.child=null;y!==null;){if(r=y.alternate,r!==null&&cl(r)===null){i.child=y;break}r=y.sibling,y.sibling=l,l=y,y=r}ed(i,!0,l,null,v);break;case"together":ed(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function kl(r,i){(i.mode&1)===0&&r!==null&&(r.alternate=null,i.alternate=null,i.flags|=2)}function Oo(r,i,l){if(r!==null&&(i.dependencies=r.dependencies),ki|=i.lanes,(l&i.childLanes)===0)return null;if(r!==null&&i.child!==r.child)throw Error(n(153));if(i.child!==null){for(r=i.child,l=Jo(r,r.pendingProps),i.child=l,l.return=i;r.sibling!==null;)r=r.sibling,l=l.sibling=Jo(r,r.pendingProps),l.return=i;l.sibling=null}return i.child}function ux(r,i,l){switch(i.tag){case 3:gm(i),Yi();break;case 5:$h(i);break;case 1:dr(i.type)&&Ja(i);break;case 4:Au(i,i.stateNode.containerInfo);break;case 10:var f=i.type._context,y=i.memoizedProps.value;Ht(il,f._currentValue),f._currentValue=y;break;case 13:if(f=i.memoizedState,f!==null)return f.dehydrated!==null?(Ht(an,an.current&1),i.flags|=128,null):(l&i.child.childLanes)!==0?ym(r,i,l):(Ht(an,an.current&1),r=Oo(r,i,l),r!==null?r.sibling:null);Ht(an,an.current&1);break;case 19:if(f=(l&i.childLanes)!==0,(r.flags&128)!==0){if(f)return wm(r,i,l);i.flags|=128}if(y=i.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),Ht(an,an.current),f)break;return null;case 22:case 23:return i.lanes=0,pm(r,i,l)}return Oo(r,i,l)}var bm,td,xm,_m;bm=function(r,i){for(var l=i.child;l!==null;){if(l.tag===5||l.tag===6)r.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===i)break;for(;l.sibling===null;){if(l.return===null||l.return===i)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},td=function(){},xm=function(r,i,l,f){var y=r.memoizedProps;if(y!==f){r=i.stateNode,mi(mo.current);var v=null;switch(l){case"input":y=Ye(r,y),f=Ye(r,f),v=[];break;case"select":y=ee({},y,{value:void 0}),f=ee({},f,{value:void 0}),v=[];break;case"textarea":y=_e(r,y),f=_e(r,f),v=[];break;default:typeof y.onClick!="function"&&typeof f.onClick=="function"&&(r.onclick=Ya)}Lt(l,f);var x;l=null;for(G in y)if(!f.hasOwnProperty(G)&&y.hasOwnProperty(G)&&y[G]!=null)if(G==="style"){var T=y[G];for(x in T)T.hasOwnProperty(x)&&(l||(l={}),l[x]="")}else G!=="dangerouslySetInnerHTML"&&G!=="children"&&G!=="suppressContentEditableWarning"&&G!=="suppressHydrationWarning"&&G!=="autoFocus"&&(s.hasOwnProperty(G)?v||(v=[]):(v=v||[]).push(G,null));for(G in f){var A=f[G];if(T=y!=null?y[G]:void 0,f.hasOwnProperty(G)&&A!==T&&(A!=null||T!=null))if(G==="style")if(T){for(x in T)!T.hasOwnProperty(x)||A&&A.hasOwnProperty(x)||(l||(l={}),l[x]="");for(x in A)A.hasOwnProperty(x)&&T[x]!==A[x]&&(l||(l={}),l[x]=A[x])}else l||(v||(v=[]),v.push(G,l)),l=A;else G==="dangerouslySetInnerHTML"?(A=A?A.__html:void 0,T=T?T.__html:void 0,A!=null&&T!==A&&(v=v||[]).push(G,A)):G==="children"?typeof A!="string"&&typeof A!="number"||(v=v||[]).push(G,""+A):G!=="suppressContentEditableWarning"&&G!=="suppressHydrationWarning"&&(s.hasOwnProperty(G)?(A!=null&&G==="onScroll"&&qt("scroll",r),v||T===A||(v=[])):(v=v||[]).push(G,A))}l&&(v=v||[]).push("style",l);var G=v;(i.updateQueue=G)&&(i.flags|=4)}},_m=function(r,i,l,f){l!==f&&(i.flags|=4)};function Ks(r,i){if(!Jt)switch(r.tailMode){case"hidden":i=r.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?r.tail=null:l.sibling=null;break;case"collapsed":l=r.tail;for(var f=null;l!==null;)l.alternate!==null&&(f=l),l=l.sibling;f===null?i||r.tail===null?r.tail=null:r.tail.sibling=null:f.sibling=null}}function Gn(r){var i=r.alternate!==null&&r.alternate.child===r.child,l=0,f=0;if(i)for(var y=r.child;y!==null;)l|=y.lanes|y.childLanes,f|=y.subtreeFlags&14680064,f|=y.flags&14680064,y.return=r,y=y.sibling;else for(y=r.child;y!==null;)l|=y.lanes|y.childLanes,f|=y.subtreeFlags,f|=y.flags,y.return=r,y=y.sibling;return r.subtreeFlags|=f,r.childLanes=l,i}function dx(r,i,l){var f=i.pendingProps;switch(_u(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gn(i),null;case 1:return dr(i.type)&&Xa(),Gn(i),null;case 3:return f=i.stateNode,es(),Yt(ur),Yt(Kn),Pu(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(r===null||r.child===null)&&(rl(i)?i.flags|=4:r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Qr!==null&&(fd(Qr),Qr=null))),td(r,i),Gn(i),null;case 5:$u(i);var y=mi(Us.current);if(l=i.type,r!==null&&i.stateNode!=null)xm(r,i,l,f,y),r.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!f){if(i.stateNode===null)throw Error(n(166));return Gn(i),null}if(r=mi(mo.current),rl(i)){f=i.stateNode,l=i.type;var v=i.memoizedProps;switch(f[ho]=i,f[Ps]=v,r=(i.mode&1)!==0,l){case"dialog":qt("cancel",f),qt("close",f);break;case"iframe":case"object":case"embed":qt("load",f);break;case"video":case"audio":for(y=0;y<As.length;y++)qt(As[y],f);break;case"source":qt("error",f);break;case"img":case"image":case"link":qt("error",f),qt("load",f);break;case"details":qt("toggle",f);break;case"input":Ge(f,v),qt("invalid",f);break;case"select":f._wrapperState={wasMultiple:!!v.multiple},qt("invalid",f);break;case"textarea":pt(f,v),qt("invalid",f)}Lt(l,v),y=null;for(var x in v)if(v.hasOwnProperty(x)){var T=v[x];x==="children"?typeof T=="string"?f.textContent!==T&&(v.suppressHydrationWarning!==!0&&qa(f.textContent,T,r),y=["children",T]):typeof T=="number"&&f.textContent!==""+T&&(v.suppressHydrationWarning!==!0&&qa(f.textContent,T,r),y=["children",""+T]):s.hasOwnProperty(x)&&T!=null&&x==="onScroll"&&qt("scroll",f)}switch(l){case"input":Te(f),Tt(f,v,!0);break;case"textarea":Te(f),vn(f);break;case"select":case"option":break;default:typeof v.onClick=="function"&&(f.onclick=Ya)}f=y,i.updateQueue=f,f!==null&&(i.flags|=4)}else{x=y.nodeType===9?y:y.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=vt(l)),r==="http://www.w3.org/1999/xhtml"?l==="script"?(r=x.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof f.is=="string"?r=x.createElement(l,{is:f.is}):(r=x.createElement(l),l==="select"&&(x=r,f.multiple?x.multiple=!0:f.size&&(x.size=f.size))):r=x.createElementNS(r,l),r[ho]=i,r[Ps]=f,bm(r,i,!1,!1),i.stateNode=r;e:{switch(x=xr(l,f),l){case"dialog":qt("cancel",r),qt("close",r),y=f;break;case"iframe":case"object":case"embed":qt("load",r),y=f;break;case"video":case"audio":for(y=0;y<As.length;y++)qt(As[y],r);y=f;break;case"source":qt("error",r),y=f;break;case"img":case"image":case"link":qt("error",r),qt("load",r),y=f;break;case"details":qt("toggle",r),y=f;break;case"input":Ge(r,f),y=Ye(r,f),qt("invalid",r);break;case"option":y=f;break;case"select":r._wrapperState={wasMultiple:!!f.multiple},y=ee({},f,{value:void 0}),qt("invalid",r);break;case"textarea":pt(r,f),y=_e(r,f),qt("invalid",r);break;default:y=f}Lt(l,y),T=y;for(v in T)if(T.hasOwnProperty(v)){var A=T[v];v==="style"?Xe(r,A):v==="dangerouslySetInnerHTML"?(A=A?A.__html:void 0,A!=null&&Be(r,A)):v==="children"?typeof A=="string"?(l!=="textarea"||A!=="")&&mt(r,A):typeof A=="number"&&mt(r,""+A):v!=="suppressContentEditableWarning"&&v!=="suppressHydrationWarning"&&v!=="autoFocus"&&(s.hasOwnProperty(v)?A!=null&&v==="onScroll"&&qt("scroll",r):A!=null&&Z(r,v,A,x))}switch(l){case"input":Te(r),Tt(r,f,!1);break;case"textarea":Te(r),vn(r);break;case"option":f.value!=null&&r.setAttribute("value",""+Pe(f.value));break;case"select":r.multiple=!!f.multiple,v=f.value,v!=null?K(r,!!f.multiple,v,!1):f.defaultValue!=null&&K(r,!!f.multiple,f.defaultValue,!0);break;default:typeof y.onClick=="function"&&(r.onclick=Ya)}switch(l){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}}f&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return Gn(i),null;case 6:if(r&&i.stateNode!=null)_m(r,i,r.memoizedProps,f);else{if(typeof f!="string"&&i.stateNode===null)throw Error(n(166));if(l=mi(Us.current),mi(mo.current),rl(i)){if(f=i.stateNode,l=i.memoizedProps,f[ho]=i,(v=f.nodeValue!==l)&&(r=Er,r!==null))switch(r.tag){case 3:qa(f.nodeValue,l,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&qa(f.nodeValue,l,(r.mode&1)!==0)}v&&(i.flags|=4)}else f=(l.nodeType===9?l:l.ownerDocument).createTextNode(f),f[ho]=i,i.stateNode=f}return Gn(i),null;case 13:if(Yt(an),f=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(Jt&&Sr!==null&&(i.mode&1)!==0&&(i.flags&128)===0)Nh(),Yi(),i.flags|=98560,v=!1;else if(v=rl(i),f!==null&&f.dehydrated!==null){if(r===null){if(!v)throw Error(n(318));if(v=i.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(n(317));v[ho]=i}else Yi(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Gn(i),v=!1}else Qr!==null&&(fd(Qr),Qr=null),v=!0;if(!v)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=l,i):(f=f!==null,f!==(r!==null&&r.memoizedState!==null)&&f&&(i.child.flags|=8192,(i.mode&1)!==0&&(r===null||(an.current&1)!==0?Tn===0&&(Tn=3):md())),i.updateQueue!==null&&(i.flags|=4),Gn(i),null);case 4:return es(),td(r,i),r===null&&$s(i.stateNode.containerInfo),Gn(i),null;case 10:return Ou(i.type._context),Gn(i),null;case 17:return dr(i.type)&&Xa(),Gn(i),null;case 19:if(Yt(an),v=i.memoizedState,v===null)return Gn(i),null;if(f=(i.flags&128)!==0,x=v.rendering,x===null)if(f)Ks(v,!1);else{if(Tn!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(x=cl(r),x!==null){for(i.flags|=128,Ks(v,!1),f=x.updateQueue,f!==null&&(i.updateQueue=f,i.flags|=4),i.subtreeFlags=0,f=l,l=i.child;l!==null;)v=l,r=f,v.flags&=14680066,x=v.alternate,x===null?(v.childLanes=0,v.lanes=r,v.child=null,v.subtreeFlags=0,v.memoizedProps=null,v.memoizedState=null,v.updateQueue=null,v.dependencies=null,v.stateNode=null):(v.childLanes=x.childLanes,v.lanes=x.lanes,v.child=x.child,v.subtreeFlags=0,v.deletions=null,v.memoizedProps=x.memoizedProps,v.memoizedState=x.memoizedState,v.updateQueue=x.updateQueue,v.type=x.type,r=x.dependencies,v.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),l=l.sibling;return Ht(an,an.current&1|2),i.child}r=r.sibling}v.tail!==null&&$t()>os&&(i.flags|=128,f=!0,Ks(v,!1),i.lanes=4194304)}else{if(!f)if(r=cl(x),r!==null){if(i.flags|=128,f=!0,l=r.updateQueue,l!==null&&(i.updateQueue=l,i.flags|=4),Ks(v,!0),v.tail===null&&v.tailMode==="hidden"&&!x.alternate&&!Jt)return Gn(i),null}else 2*$t()-v.renderingStartTime>os&&l!==1073741824&&(i.flags|=128,f=!0,Ks(v,!1),i.lanes=4194304);v.isBackwards?(x.sibling=i.child,i.child=x):(l=v.last,l!==null?l.sibling=x:i.child=x,v.last=x)}return v.tail!==null?(i=v.tail,v.rendering=i,v.tail=i.sibling,v.renderingStartTime=$t(),i.sibling=null,l=an.current,Ht(an,f?l&1|2:l&1),i):(Gn(i),null);case 22:case 23:return hd(),f=i.memoizedState!==null,r!==null&&r.memoizedState!==null!==f&&(i.flags|=8192),f&&(i.mode&1)!==0?(Nr&1073741824)!==0&&(Gn(i),i.subtreeFlags&6&&(i.flags|=8192)):Gn(i),null;case 24:return null;case 25:return null}throw Error(n(156,i.tag))}function fx(r,i){switch(_u(i),i.tag){case 1:return dr(i.type)&&Xa(),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return es(),Yt(ur),Yt(Kn),Pu(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 5:return $u(i),null;case 13:if(Yt(an),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(n(340));Yi()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return Yt(an),null;case 4:return es(),null;case 10:return Ou(i.type._context),null;case 22:case 23:return hd(),null;case 24:return null;default:return null}}var yl=!1,qn=!1,px=typeof WeakSet=="function"?WeakSet:Set,$e=null;function ns(r,i){var l=r.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(f){fn(r,i,f)}else l.current=null}function nd(r,i,l){try{l()}catch(f){fn(r,i,f)}}var Em=!1;function hx(r,i){if(hu=za,r=nh(),su(r)){if("selectionStart"in r)var l={start:r.selectionStart,end:r.selectionEnd};else e:{l=(l=r.ownerDocument)&&l.defaultView||window;var f=l.getSelection&&l.getSelection();if(f&&f.rangeCount!==0){l=f.anchorNode;var y=f.anchorOffset,v=f.focusNode;f=f.focusOffset;try{l.nodeType,v.nodeType}catch{l=null;break e}var x=0,T=-1,A=-1,G=0,ue=0,he=r,le=null;t:for(;;){for(var je;he!==l||y!==0&&he.nodeType!==3||(T=x+y),he!==v||f!==0&&he.nodeType!==3||(A=x+f),he.nodeType===3&&(x+=he.nodeValue.length),(je=he.firstChild)!==null;)le=he,he=je;for(;;){if(he===r)break t;if(le===l&&++G===y&&(T=x),le===v&&++ue===f&&(A=x),(je=he.nextSibling)!==null)break;he=le,le=he.parentNode}he=je}l=T===-1||A===-1?null:{start:T,end:A}}else l=null}l=l||{start:0,end:0}}else l=null;for(mu={focusedElem:r,selectionRange:l},za=!1,$e=i;$e!==null;)if(i=$e,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,$e=r;else for(;$e!==null;){i=$e;try{var Me=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(Me!==null){var Le=Me.memoizedProps,pn=Me.memoizedState,H=i.stateNode,P=H.getSnapshotBeforeUpdate(i.elementType===i.type?Le:Xr(i.type,Le),pn);H.__reactInternalSnapshotBeforeUpdate=P}break;case 3:var W=i.stateNode.containerInfo;W.nodeType===1?W.textContent="":W.nodeType===9&&W.documentElement&&W.removeChild(W.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(ye){fn(i,i.return,ye)}if(r=i.sibling,r!==null){r.return=i.return,$e=r;break}$e=i.return}return Me=Em,Em=!1,Me}function Vs(r,i,l){var f=i.updateQueue;if(f=f!==null?f.lastEffect:null,f!==null){var y=f=f.next;do{if((y.tag&r)===r){var v=y.destroy;y.destroy=void 0,v!==void 0&&nd(i,l,v)}y=y.next}while(y!==f)}}function vl(r,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var l=i=i.next;do{if((l.tag&r)===r){var f=l.create;l.destroy=f()}l=l.next}while(l!==i)}}function rd(r){var i=r.ref;if(i!==null){var l=r.stateNode;switch(r.tag){case 5:r=l;break;default:r=l}typeof i=="function"?i(r):i.current=r}}function Sm(r){var i=r.alternate;i!==null&&(r.alternate=null,Sm(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&(delete i[ho],delete i[Ps],delete i[vu],delete i[Yb],delete i[Qb])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Nm(r){return r.tag===5||r.tag===3||r.tag===4}function Tm(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Nm(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function od(r,i,l){var f=r.tag;if(f===5||f===6)r=r.stateNode,i?l.nodeType===8?l.parentNode.insertBefore(r,i):l.insertBefore(r,i):(l.nodeType===8?(i=l.parentNode,i.insertBefore(r,l)):(i=l,i.appendChild(r)),l=l._reactRootContainer,l!=null||i.onclick!==null||(i.onclick=Ya));else if(f!==4&&(r=r.child,r!==null))for(od(r,i,l),r=r.sibling;r!==null;)od(r,i,l),r=r.sibling}function id(r,i,l){var f=r.tag;if(f===5||f===6)r=r.stateNode,i?l.insertBefore(r,i):l.appendChild(r);else if(f!==4&&(r=r.child,r!==null))for(id(r,i,l),r=r.sibling;r!==null;)id(r,i,l),r=r.sibling}var Un=null,Jr=!1;function Go(r,i,l){for(l=l.child;l!==null;)Im(r,i,l),l=l.sibling}function Im(r,i,l){if(Qe&&typeof Qe.onCommitFiberUnmount=="function")try{Qe.onCommitFiberUnmount(et,l)}catch{}switch(l.tag){case 5:qn||ns(l,i);case 6:var f=Un,y=Jr;Un=null,Go(r,i,l),Un=f,Jr=y,Un!==null&&(Jr?(r=Un,l=l.stateNode,r.nodeType===8?r.parentNode.removeChild(l):r.removeChild(l)):Un.removeChild(l.stateNode));break;case 18:Un!==null&&(Jr?(r=Un,l=l.stateNode,r.nodeType===8?yu(r.parentNode,l):r.nodeType===1&&yu(r,l),Ss(r)):yu(Un,l.stateNode));break;case 4:f=Un,y=Jr,Un=l.stateNode.containerInfo,Jr=!0,Go(r,i,l),Un=f,Jr=y;break;case 0:case 11:case 14:case 15:if(!qn&&(f=l.updateQueue,f!==null&&(f=f.lastEffect,f!==null))){y=f=f.next;do{var v=y,x=v.destroy;v=v.tag,x!==void 0&&((v&2)!==0||(v&4)!==0)&&nd(l,i,x),y=y.next}while(y!==f)}Go(r,i,l);break;case 1:if(!qn&&(ns(l,i),f=l.stateNode,typeof f.componentWillUnmount=="function"))try{f.props=l.memoizedProps,f.state=l.memoizedState,f.componentWillUnmount()}catch(T){fn(l,i,T)}Go(r,i,l);break;case 21:Go(r,i,l);break;case 22:l.mode&1?(qn=(f=qn)||l.memoizedState!==null,Go(r,i,l),qn=f):Go(r,i,l);break;default:Go(r,i,l)}}function Om(r){var i=r.updateQueue;if(i!==null){r.updateQueue=null;var l=r.stateNode;l===null&&(l=r.stateNode=new px),i.forEach(function(f){var y=_x.bind(null,r,f);l.has(f)||(l.add(f),f.then(y,y))})}}function eo(r,i){var l=i.deletions;if(l!==null)for(var f=0;f<l.length;f++){var y=l[f];try{var v=r,x=i,T=x;e:for(;T!==null;){switch(T.tag){case 5:Un=T.stateNode,Jr=!1;break e;case 3:Un=T.stateNode.containerInfo,Jr=!0;break e;case 4:Un=T.stateNode.containerInfo,Jr=!0;break e}T=T.return}if(Un===null)throw Error(n(160));Im(v,x,y),Un=null,Jr=!1;var A=y.alternate;A!==null&&(A.return=null),y.return=null}catch(G){fn(y,i,G)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)Rm(i,r),i=i.sibling}function Rm(r,i){var l=r.alternate,f=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(eo(i,r),ko(r),f&4){try{Vs(3,r,r.return),vl(3,r)}catch(Le){fn(r,r.return,Le)}try{Vs(5,r,r.return)}catch(Le){fn(r,r.return,Le)}}break;case 1:eo(i,r),ko(r),f&512&&l!==null&&ns(l,l.return);break;case 5:if(eo(i,r),ko(r),f&512&&l!==null&&ns(l,l.return),r.flags&32){var y=r.stateNode;try{mt(y,"")}catch(Le){fn(r,r.return,Le)}}if(f&4&&(y=r.stateNode,y!=null)){var v=r.memoizedProps,x=l!==null?l.memoizedProps:v,T=r.type,A=r.updateQueue;if(r.updateQueue=null,A!==null)try{T==="input"&&v.type==="radio"&&v.name!=null&&Ue(y,v),xr(T,x);var G=xr(T,v);for(x=0;x<A.length;x+=2){var ue=A[x],he=A[x+1];ue==="style"?Xe(y,he):ue==="dangerouslySetInnerHTML"?Be(y,he):ue==="children"?mt(y,he):Z(y,ue,he,G)}switch(T){case"input":At(y,v);break;case"textarea":It(y,v);break;case"select":var le=y._wrapperState.wasMultiple;y._wrapperState.wasMultiple=!!v.multiple;var je=v.value;je!=null?K(y,!!v.multiple,je,!1):le!==!!v.multiple&&(v.defaultValue!=null?K(y,!!v.multiple,v.defaultValue,!0):K(y,!!v.multiple,v.multiple?[]:"",!1))}y[Ps]=v}catch(Le){fn(r,r.return,Le)}}break;case 6:if(eo(i,r),ko(r),f&4){if(r.stateNode===null)throw Error(n(162));y=r.stateNode,v=r.memoizedProps;try{y.nodeValue=v}catch(Le){fn(r,r.return,Le)}}break;case 3:if(eo(i,r),ko(r),f&4&&l!==null&&l.memoizedState.isDehydrated)try{Ss(i.containerInfo)}catch(Le){fn(r,r.return,Le)}break;case 4:eo(i,r),ko(r);break;case 13:eo(i,r),ko(r),y=r.child,y.flags&8192&&(v=y.memoizedState!==null,y.stateNode.isHidden=v,!v||y.alternate!==null&&y.alternate.memoizedState!==null||(ld=$t())),f&4&&Om(r);break;case 22:if(ue=l!==null&&l.memoizedState!==null,r.mode&1?(qn=(G=qn)||ue,eo(i,r),qn=G):eo(i,r),ko(r),f&8192){if(G=r.memoizedState!==null,(r.stateNode.isHidden=G)&&!ue&&(r.mode&1)!==0)for($e=r,ue=r.child;ue!==null;){for(he=$e=ue;$e!==null;){switch(le=$e,je=le.child,le.tag){case 0:case 11:case 14:case 15:Vs(4,le,le.return);break;case 1:ns(le,le.return);var Me=le.stateNode;if(typeof Me.componentWillUnmount=="function"){f=le,l=le.return;try{i=f,Me.props=i.memoizedProps,Me.state=i.memoizedState,Me.componentWillUnmount()}catch(Le){fn(f,l,Le)}}break;case 5:ns(le,le.return);break;case 22:if(le.memoizedState!==null){Am(he);continue}}je!==null?(je.return=le,$e=je):Am(he)}ue=ue.sibling}e:for(ue=null,he=r;;){if(he.tag===5){if(ue===null){ue=he;try{y=he.stateNode,G?(v=y.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none"):(T=he.stateNode,A=he.memoizedProps.style,x=A!=null&&A.hasOwnProperty("display")?A.display:null,T.style.display=Rn("display",x))}catch(Le){fn(r,r.return,Le)}}}else if(he.tag===6){if(ue===null)try{he.stateNode.nodeValue=G?"":he.memoizedProps}catch(Le){fn(r,r.return,Le)}}else if((he.tag!==22&&he.tag!==23||he.memoizedState===null||he===r)&&he.child!==null){he.child.return=he,he=he.child;continue}if(he===r)break e;for(;he.sibling===null;){if(he.return===null||he.return===r)break e;ue===he&&(ue=null),he=he.return}ue===he&&(ue=null),he.sibling.return=he.return,he=he.sibling}}break;case 19:eo(i,r),ko(r),f&4&&Om(r);break;case 21:break;default:eo(i,r),ko(r)}}function ko(r){var i=r.flags;if(i&2){try{e:{for(var l=r.return;l!==null;){if(Nm(l)){var f=l;break e}l=l.return}throw Error(n(160))}switch(f.tag){case 5:var y=f.stateNode;f.flags&32&&(mt(y,""),f.flags&=-33);var v=Tm(r);id(r,v,y);break;case 3:case 4:var x=f.stateNode.containerInfo,T=Tm(r);od(r,T,x);break;default:throw Error(n(161))}}catch(A){fn(r,r.return,A)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function mx(r,i,l){$e=r,Cm(r)}function Cm(r,i,l){for(var f=(r.mode&1)!==0;$e!==null;){var y=$e,v=y.child;if(y.tag===22&&f){var x=y.memoizedState!==null||yl;if(!x){var T=y.alternate,A=T!==null&&T.memoizedState!==null||qn;T=yl;var G=qn;if(yl=x,(qn=A)&&!G)for($e=y;$e!==null;)x=$e,A=x.child,x.tag===22&&x.memoizedState!==null?$m(y):A!==null?(A.return=x,$e=A):$m(y);for(;v!==null;)$e=v,Cm(v),v=v.sibling;$e=y,yl=T,qn=G}jm(r)}else(y.subtreeFlags&8772)!==0&&v!==null?(v.return=y,$e=v):jm(r)}}function jm(r){for(;$e!==null;){var i=$e;if((i.flags&8772)!==0){var l=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:qn||vl(5,i);break;case 1:var f=i.stateNode;if(i.flags&4&&!qn)if(l===null)f.componentDidMount();else{var y=i.elementType===i.type?l.memoizedProps:Xr(i.type,l.memoizedProps);f.componentDidUpdate(y,l.memoizedState,f.__reactInternalSnapshotBeforeUpdate)}var v=i.updateQueue;v!==null&&Ah(i,v,f);break;case 3:var x=i.updateQueue;if(x!==null){if(l=null,i.child!==null)switch(i.child.tag){case 5:l=i.child.stateNode;break;case 1:l=i.child.stateNode}Ah(i,x,l)}break;case 5:var T=i.stateNode;if(l===null&&i.flags&4){l=T;var A=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":A.autoFocus&&l.focus();break;case"img":A.src&&(l.src=A.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var G=i.alternate;if(G!==null){var ue=G.memoizedState;if(ue!==null){var he=ue.dehydrated;he!==null&&Ss(he)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}qn||i.flags&512&&rd(i)}catch(le){fn(i,i.return,le)}}if(i===r){$e=null;break}if(l=i.sibling,l!==null){l.return=i.return,$e=l;break}$e=i.return}}function Am(r){for(;$e!==null;){var i=$e;if(i===r){$e=null;break}var l=i.sibling;if(l!==null){l.return=i.return,$e=l;break}$e=i.return}}function $m(r){for(;$e!==null;){var i=$e;try{switch(i.tag){case 0:case 11:case 15:var l=i.return;try{vl(4,i)}catch(A){fn(i,l,A)}break;case 1:var f=i.stateNode;if(typeof f.componentDidMount=="function"){var y=i.return;try{f.componentDidMount()}catch(A){fn(i,y,A)}}var v=i.return;try{rd(i)}catch(A){fn(i,v,A)}break;case 5:var x=i.return;try{rd(i)}catch(A){fn(i,x,A)}}}catch(A){fn(i,i.return,A)}if(i===r){$e=null;break}var T=i.sibling;if(T!==null){T.return=i.return,$e=T;break}$e=i.return}}var gx=Math.ceil,wl=M.ReactCurrentDispatcher,sd=M.ReactCurrentOwner,Ur=M.ReactCurrentBatchConfig,bt=0,$n=null,kn=null,Bn=0,Nr=0,rs=Zo(0),Tn=0,Gs=null,ki=0,bl=0,ad=0,qs=null,pr=null,ld=0,os=1/0,Ro=null,xl=!1,cd=null,qo=null,_l=!1,Yo=null,El=0,Ys=0,ud=null,Sl=-1,Nl=0;function ir(){return(bt&6)!==0?$t():Sl!==-1?Sl:Sl=$t()}function Qo(r){return(r.mode&1)===0?1:(bt&2)!==0&&Bn!==0?Bn&-Bn:Jb.transition!==null?(Nl===0&&(Nl=Li()),Nl):(r=ht,r!==0||(r=window.event,r=r===void 0?16:Pp(r.type)),r)}function to(r,i,l,f){if(50<Ys)throw Ys=0,ud=null,Error(n(185));qr(r,l,f),((bt&2)===0||r!==$n)&&(r===$n&&((bt&2)===0&&(bl|=l),Tn===4&&Xo(r,Bn)),hr(r,f),l===1&&bt===0&&(i.mode&1)===0&&(os=$t()+500,el&&Wo()))}function hr(r,i){var l=r.callbackNode;xo(r,i);var f=Ft(r,r===$n?Bn:0);if(f===0)l!==null&&_n(l),r.callbackNode=null,r.callbackPriority=0;else if(i=f&-f,r.callbackPriority!==i){if(l!=null&&_n(l),i===1)r.tag===0?Xb(Pm.bind(null,r)):bh(Pm.bind(null,r)),Gb(function(){(bt&6)===0&&Wo()}),l=null;else{switch(Ve(f)){case 1:l=$r;break;case 4:l=En;break;case 16:l=Vr;break;case 536870912:l=Re;break;default:l=Vr}l=Hm(l,Mm.bind(null,r))}r.callbackPriority=i,r.callbackNode=l}}function Mm(r,i){if(Sl=-1,Nl=0,(bt&6)!==0)throw Error(n(327));var l=r.callbackNode;if(is()&&r.callbackNode!==l)return null;var f=Ft(r,r===$n?Bn:0);if(f===0)return null;if((f&30)!==0||(f&r.expiredLanes)!==0||i)i=Tl(r,f);else{i=f;var y=bt;bt|=2;var v=zm();($n!==r||Bn!==i)&&(Ro=null,os=$t()+500,vi(r,i));do try{vx();break}catch(T){Lm(r,T)}while(!0);Iu(),wl.current=v,bt=y,kn!==null?i=0:($n=null,Bn=0,i=Tn)}if(i!==0){if(i===2&&(y=po(r),y!==0&&(f=y,i=dd(r,y))),i===1)throw l=Gs,vi(r,0),Xo(r,f),hr(r,$t()),l;if(i===6)Xo(r,f);else{if(y=r.current.alternate,(f&30)===0&&!kx(y)&&(i=Tl(r,f),i===2&&(v=po(r),v!==0&&(f=v,i=dd(r,v))),i===1))throw l=Gs,vi(r,0),Xo(r,f),hr(r,$t()),l;switch(r.finishedWork=y,r.finishedLanes=f,i){case 0:case 1:throw Error(n(345));case 2:wi(r,pr,Ro);break;case 3:if(Xo(r,f),(f&130023424)===f&&(i=ld+500-$t(),10<i)){if(Ft(r,0)!==0)break;if(y=r.suspendedLanes,(y&f)!==f){ir(),r.pingedLanes|=r.suspendedLanes&y;break}r.timeoutHandle=ku(wi.bind(null,r,pr,Ro),i);break}wi(r,pr,Ro);break;case 4:if(Xo(r,f),(f&4194240)===f)break;for(i=r.eventTimes,y=-1;0<f;){var x=31-Dt(f);v=1<<x,x=i[x],x>y&&(y=x),f&=~v}if(f=y,f=$t()-f,f=(120>f?120:480>f?480:1080>f?1080:1920>f?1920:3e3>f?3e3:4320>f?4320:1960*gx(f/1960))-f,10<f){r.timeoutHandle=ku(wi.bind(null,r,pr,Ro),f);break}wi(r,pr,Ro);break;case 5:wi(r,pr,Ro);break;default:throw Error(n(329))}}}return hr(r,$t()),r.callbackNode===l?Mm.bind(null,r):null}function dd(r,i){var l=qs;return r.current.memoizedState.isDehydrated&&(vi(r,i).flags|=256),r=Tl(r,i),r!==2&&(i=pr,pr=l,i!==null&&fd(i)),r}function fd(r){pr===null?pr=r:pr.push.apply(pr,r)}function kx(r){for(var i=r;;){if(i.flags&16384){var l=i.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var f=0;f<l.length;f++){var y=l[f],v=y.getSnapshot;y=y.value;try{if(!Yr(v(),y))return!1}catch{return!1}}}if(l=i.child,i.subtreeFlags&16384&&l!==null)l.return=i,i=l;else{if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function Xo(r,i){for(i&=~ad,i&=~bl,r.suspendedLanes|=i,r.pingedLanes&=~i,r=r.expirationTimes;0<i;){var l=31-Dt(i),f=1<<l;r[l]=-1,i&=~f}}function Pm(r){if((bt&6)!==0)throw Error(n(327));is();var i=Ft(r,0);if((i&1)===0)return hr(r,$t()),null;var l=Tl(r,i);if(r.tag!==0&&l===2){var f=po(r);f!==0&&(i=f,l=dd(r,f))}if(l===1)throw l=Gs,vi(r,0),Xo(r,i),hr(r,$t()),l;if(l===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=i,wi(r,pr,Ro),hr(r,$t()),null}function pd(r,i){var l=bt;bt|=1;try{return r(i)}finally{bt=l,bt===0&&(os=$t()+500,el&&Wo())}}function yi(r){Yo!==null&&Yo.tag===0&&(bt&6)===0&&is();var i=bt;bt|=1;var l=Ur.transition,f=ht;try{if(Ur.transition=null,ht=1,r)return r()}finally{ht=f,Ur.transition=l,bt=i,(bt&6)===0&&Wo()}}function hd(){Nr=rs.current,Yt(rs)}function vi(r,i){r.finishedWork=null,r.finishedLanes=0;var l=r.timeoutHandle;if(l!==-1&&(r.timeoutHandle=-1,Vb(l)),kn!==null)for(l=kn.return;l!==null;){var f=l;switch(_u(f),f.tag){case 1:f=f.type.childContextTypes,f!=null&&Xa();break;case 3:es(),Yt(ur),Yt(Kn),Pu();break;case 5:$u(f);break;case 4:es();break;case 13:Yt(an);break;case 19:Yt(an);break;case 10:Ou(f.type._context);break;case 22:case 23:hd()}l=l.return}if($n=r,kn=r=Jo(r.current,null),Bn=Nr=i,Tn=0,Gs=null,ad=bl=ki=0,pr=qs=null,hi!==null){for(i=0;i<hi.length;i++)if(l=hi[i],f=l.interleaved,f!==null){l.interleaved=null;var y=f.next,v=l.pending;if(v!==null){var x=v.next;v.next=y,f.next=x}l.pending=f}hi=null}return r}function Lm(r,i){do{var l=kn;try{if(Iu(),ul.current=hl,dl){for(var f=ln.memoizedState;f!==null;){var y=f.queue;y!==null&&(y.pending=null),f=f.next}dl=!1}if(gi=0,An=Nn=ln=null,Bs=!1,Zs=0,sd.current=null,l===null||l.return===null){Tn=1,Gs=i,kn=null;break}e:{var v=r,x=l.return,T=l,A=i;if(i=Bn,T.flags|=32768,A!==null&&typeof A=="object"&&typeof A.then=="function"){var G=A,ue=T,he=ue.tag;if((ue.mode&1)===0&&(he===0||he===11||he===15)){var le=ue.alternate;le?(ue.updateQueue=le.updateQueue,ue.memoizedState=le.memoizedState,ue.lanes=le.lanes):(ue.updateQueue=null,ue.memoizedState=null)}var je=lm(x);if(je!==null){je.flags&=-257,cm(je,x,T,v,i),je.mode&1&&am(v,G,i),i=je,A=G;var Me=i.updateQueue;if(Me===null){var Le=new Set;Le.add(A),i.updateQueue=Le}else Me.add(A);break e}else{if((i&1)===0){am(v,G,i),md();break e}A=Error(n(426))}}else if(Jt&&T.mode&1){var pn=lm(x);if(pn!==null){(pn.flags&65536)===0&&(pn.flags|=256),cm(pn,x,T,v,i),Nu(ts(A,T));break e}}v=A=ts(A,T),Tn!==4&&(Tn=2),qs===null?qs=[v]:qs.push(v),v=x;do{switch(v.tag){case 3:v.flags|=65536,i&=-i,v.lanes|=i;var H=im(v,A,i);jh(v,H);break e;case 1:T=A;var P=v.type,W=v.stateNode;if((v.flags&128)===0&&(typeof P.getDerivedStateFromError=="function"||W!==null&&typeof W.componentDidCatch=="function"&&(qo===null||!qo.has(W)))){v.flags|=65536,i&=-i,v.lanes|=i;var ye=sm(v,T,i);jh(v,ye);break e}}v=v.return}while(v!==null)}Fm(l)}catch(ze){i=ze,kn===l&&l!==null&&(kn=l=l.return);continue}break}while(!0)}function zm(){var r=wl.current;return wl.current=hl,r===null?hl:r}function md(){(Tn===0||Tn===3||Tn===2)&&(Tn=4),$n===null||(ki&268435455)===0&&(bl&268435455)===0||Xo($n,Bn)}function Tl(r,i){var l=bt;bt|=2;var f=zm();($n!==r||Bn!==i)&&(Ro=null,vi(r,i));do try{yx();break}catch(y){Lm(r,y)}while(!0);if(Iu(),bt=l,wl.current=f,kn!==null)throw Error(n(261));return $n=null,Bn=0,Tn}function yx(){for(;kn!==null;)Dm(kn)}function vx(){for(;kn!==null&&!fo();)Dm(kn)}function Dm(r){var i=Zm(r.alternate,r,Nr);r.memoizedProps=r.pendingProps,i===null?Fm(r):kn=i,sd.current=null}function Fm(r){var i=r;do{var l=i.alternate;if(r=i.return,(i.flags&32768)===0){if(l=dx(l,i,Nr),l!==null){kn=l;return}}else{if(l=fx(l,i),l!==null){l.flags&=32767,kn=l;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{Tn=6,kn=null;return}}if(i=i.sibling,i!==null){kn=i;return}kn=i=r}while(i!==null);Tn===0&&(Tn=5)}function wi(r,i,l){var f=ht,y=Ur.transition;try{Ur.transition=null,ht=1,wx(r,i,l,f)}finally{Ur.transition=y,ht=f}return null}function wx(r,i,l,f){do is();while(Yo!==null);if((bt&6)!==0)throw Error(n(327));l=r.finishedWork;var y=r.finishedLanes;if(l===null)return null;if(r.finishedWork=null,r.finishedLanes=0,l===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var v=l.lanes|l.childLanes;if(rr(r,v),r===$n&&(kn=$n=null,Bn=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||_l||(_l=!0,Hm(Vr,function(){return is(),null})),v=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||v){v=Ur.transition,Ur.transition=null;var x=ht;ht=1;var T=bt;bt|=4,sd.current=null,hx(r,l),Rm(l,r),Fb(mu),za=!!hu,mu=hu=null,r.current=l,mx(l),mn(),bt=T,ht=x,Ur.transition=v}else r.current=l;if(_l&&(_l=!1,Yo=r,El=y),v=r.pendingLanes,v===0&&(qo=null),zt(l.stateNode),hr(r,$t()),i!==null)for(f=r.onRecoverableError,l=0;l<i.length;l++)y=i[l],f(y.value,{componentStack:y.stack,digest:y.digest});if(xl)throw xl=!1,r=cd,cd=null,r;return(El&1)!==0&&r.tag!==0&&is(),v=r.pendingLanes,(v&1)!==0?r===ud?Ys++:(Ys=0,ud=r):Ys=0,Wo(),null}function is(){if(Yo!==null){var r=Ve(El),i=Ur.transition,l=ht;try{if(Ur.transition=null,ht=16>r?16:r,Yo===null)var f=!1;else{if(r=Yo,Yo=null,El=0,(bt&6)!==0)throw Error(n(331));var y=bt;for(bt|=4,$e=r.current;$e!==null;){var v=$e,x=v.child;if(($e.flags&16)!==0){var T=v.deletions;if(T!==null){for(var A=0;A<T.length;A++){var G=T[A];for($e=G;$e!==null;){var ue=$e;switch(ue.tag){case 0:case 11:case 15:Vs(8,ue,v)}var he=ue.child;if(he!==null)he.return=ue,$e=he;else for(;$e!==null;){ue=$e;var le=ue.sibling,je=ue.return;if(Sm(ue),ue===G){$e=null;break}if(le!==null){le.return=je,$e=le;break}$e=je}}}var Me=v.alternate;if(Me!==null){var Le=Me.child;if(Le!==null){Me.child=null;do{var pn=Le.sibling;Le.sibling=null,Le=pn}while(Le!==null)}}$e=v}}if((v.subtreeFlags&2064)!==0&&x!==null)x.return=v,$e=x;else e:for(;$e!==null;){if(v=$e,(v.flags&2048)!==0)switch(v.tag){case 0:case 11:case 15:Vs(9,v,v.return)}var H=v.sibling;if(H!==null){H.return=v.return,$e=H;break e}$e=v.return}}var P=r.current;for($e=P;$e!==null;){x=$e;var W=x.child;if((x.subtreeFlags&2064)!==0&&W!==null)W.return=x,$e=W;else e:for(x=P;$e!==null;){if(T=$e,(T.flags&2048)!==0)try{switch(T.tag){case 0:case 11:case 15:vl(9,T)}}catch(ze){fn(T,T.return,ze)}if(T===x){$e=null;break e}var ye=T.sibling;if(ye!==null){ye.return=T.return,$e=ye;break e}$e=T.return}}if(bt=y,Wo(),Qe&&typeof Qe.onPostCommitFiberRoot=="function")try{Qe.onPostCommitFiberRoot(et,r)}catch{}f=!0}return f}finally{ht=l,Ur.transition=i}}return!1}function Um(r,i,l){i=ts(l,i),i=im(r,i,1),r=Vo(r,i,1),i=ir(),r!==null&&(qr(r,1,i),hr(r,i))}function fn(r,i,l){if(r.tag===3)Um(r,r,l);else for(;i!==null;){if(i.tag===3){Um(i,r,l);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(qo===null||!qo.has(f))){r=ts(l,r),r=sm(i,r,1),i=Vo(i,r,1),r=ir(),i!==null&&(qr(i,1,r),hr(i,r));break}}i=i.return}}function bx(r,i,l){var f=r.pingCache;f!==null&&f.delete(i),i=ir(),r.pingedLanes|=r.suspendedLanes&l,$n===r&&(Bn&l)===l&&(Tn===4||Tn===3&&(Bn&130023424)===Bn&&500>$t()-ld?vi(r,0):ad|=l),hr(r,i)}function Bm(r,i){i===0&&((r.mode&1)===0?i=1:(i=Ze,Ze<<=1,(Ze&130023424)===0&&(Ze=4194304)));var l=ir();r=To(r,i),r!==null&&(qr(r,i,l),hr(r,l))}function xx(r){var i=r.memoizedState,l=0;i!==null&&(l=i.retryLane),Bm(r,l)}function _x(r,i){var l=0;switch(r.tag){case 13:var f=r.stateNode,y=r.memoizedState;y!==null&&(l=y.retryLane);break;case 19:f=r.stateNode;break;default:throw Error(n(314))}f!==null&&f.delete(i),Bm(r,l)}var Zm;Zm=function(r,i,l){if(r!==null)if(r.memoizedProps!==i.pendingProps||ur.current)fr=!0;else{if((r.lanes&l)===0&&(i.flags&128)===0)return fr=!1,ux(r,i,l);fr=(r.flags&131072)!==0}else fr=!1,Jt&&(i.flags&1048576)!==0&&xh(i,nl,i.index);switch(i.lanes=0,i.tag){case 2:var f=i.type;kl(r,i),r=i.pendingProps;var y=Vi(i,Kn.current);Ji(i,l),y=Du(null,i,f,r,y,l);var v=Fu();return i.flags|=1,typeof y=="object"&&y!==null&&typeof y.render=="function"&&y.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,dr(f)?(v=!0,Ja(i)):v=!1,i.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,ju(i),y.updater=ml,i.stateNode=y,y._reactInternals=i,Ku(i,f,r,l),i=Yu(null,i,f,!0,v,l)):(i.tag=0,Jt&&v&&xu(i),or(null,i,y,l),i=i.child),i;case 16:f=i.elementType;e:{switch(kl(r,i),r=i.pendingProps,y=f._init,f=y(f._payload),i.type=f,y=i.tag=Sx(f),r=Xr(f,r),y){case 0:i=qu(null,i,f,r,l);break e;case 1:i=mm(null,i,f,r,l);break e;case 11:i=um(null,i,f,r,l);break e;case 14:i=dm(null,i,f,Xr(f.type,r),l);break e}throw Error(n(306,f,""))}return i;case 0:return f=i.type,y=i.pendingProps,y=i.elementType===f?y:Xr(f,y),qu(r,i,f,y,l);case 1:return f=i.type,y=i.pendingProps,y=i.elementType===f?y:Xr(f,y),mm(r,i,f,y,l);case 3:e:{if(gm(i),r===null)throw Error(n(387));f=i.pendingProps,v=i.memoizedState,y=v.element,Ch(r,i),ll(i,f,null,l);var x=i.memoizedState;if(f=x.element,v.isDehydrated)if(v={element:f,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},i.updateQueue.baseState=v,i.memoizedState=v,i.flags&256){y=ts(Error(n(423)),i),i=km(r,i,f,l,y);break e}else if(f!==y){y=ts(Error(n(424)),i),i=km(r,i,f,l,y);break e}else for(Sr=Bo(i.stateNode.containerInfo.firstChild),Er=i,Jt=!0,Qr=null,l=Oh(i,null,f,l),i.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Yi(),f===y){i=Oo(r,i,l);break e}or(r,i,f,l)}i=i.child}return i;case 5:return $h(i),r===null&&Su(i),f=i.type,y=i.pendingProps,v=r!==null?r.memoizedProps:null,x=y.children,gu(f,y)?x=null:v!==null&&gu(f,v)&&(i.flags|=32),hm(r,i),or(r,i,x,l),i.child;case 6:return r===null&&Su(i),null;case 13:return ym(r,i,l);case 4:return Au(i,i.stateNode.containerInfo),f=i.pendingProps,r===null?i.child=Qi(i,null,f,l):or(r,i,f,l),i.child;case 11:return f=i.type,y=i.pendingProps,y=i.elementType===f?y:Xr(f,y),um(r,i,f,y,l);case 7:return or(r,i,i.pendingProps,l),i.child;case 8:return or(r,i,i.pendingProps.children,l),i.child;case 12:return or(r,i,i.pendingProps.children,l),i.child;case 10:e:{if(f=i.type._context,y=i.pendingProps,v=i.memoizedProps,x=y.value,Ht(il,f._currentValue),f._currentValue=x,v!==null)if(Yr(v.value,x)){if(v.children===y.children&&!ur.current){i=Oo(r,i,l);break e}}else for(v=i.child,v!==null&&(v.return=i);v!==null;){var T=v.dependencies;if(T!==null){x=v.child;for(var A=T.firstContext;A!==null;){if(A.context===f){if(v.tag===1){A=Io(-1,l&-l),A.tag=2;var G=v.updateQueue;if(G!==null){G=G.shared;var ue=G.pending;ue===null?A.next=A:(A.next=ue.next,ue.next=A),G.pending=A}}v.lanes|=l,A=v.alternate,A!==null&&(A.lanes|=l),Ru(v.return,l,i),T.lanes|=l;break}A=A.next}}else if(v.tag===10)x=v.type===i.type?null:v.child;else if(v.tag===18){if(x=v.return,x===null)throw Error(n(341));x.lanes|=l,T=x.alternate,T!==null&&(T.lanes|=l),Ru(x,l,i),x=v.sibling}else x=v.child;if(x!==null)x.return=v;else for(x=v;x!==null;){if(x===i){x=null;break}if(v=x.sibling,v!==null){v.return=x.return,x=v;break}x=x.return}v=x}or(r,i,y.children,l),i=i.child}return i;case 9:return y=i.type,f=i.pendingProps.children,Ji(i,l),y=Dr(y),f=f(y),i.flags|=1,or(r,i,f,l),i.child;case 14:return f=i.type,y=Xr(f,i.pendingProps),y=Xr(f.type,y),dm(r,i,f,y,l);case 15:return fm(r,i,i.type,i.pendingProps,l);case 17:return f=i.type,y=i.pendingProps,y=i.elementType===f?y:Xr(f,y),kl(r,i),i.tag=1,dr(f)?(r=!0,Ja(i)):r=!1,Ji(i,l),rm(i,f,y),Ku(i,f,y,l),Yu(null,i,f,!0,r,l);case 19:return wm(r,i,l);case 22:return pm(r,i,l)}throw Error(n(156,i.tag))};function Hm(r,i){return Ar(r,i)}function Ex(r,i,l,f){this.tag=r,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=f,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Br(r,i,l,f){return new Ex(r,i,l,f)}function gd(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Sx(r){if(typeof r=="function")return gd(r)?1:0;if(r!=null){if(r=r.$$typeof,r===ae)return 11;if(r===de)return 14}return 2}function Jo(r,i){var l=r.alternate;return l===null?(l=Br(r.tag,i,r.key,r.mode),l.elementType=r.elementType,l.type=r.type,l.stateNode=r.stateNode,l.alternate=r,r.alternate=l):(l.pendingProps=i,l.type=r.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=r.flags&14680064,l.childLanes=r.childLanes,l.lanes=r.lanes,l.child=r.child,l.memoizedProps=r.memoizedProps,l.memoizedState=r.memoizedState,l.updateQueue=r.updateQueue,i=r.dependencies,l.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},l.sibling=r.sibling,l.index=r.index,l.ref=r.ref,l}function Il(r,i,l,f,y,v){var x=2;if(f=r,typeof r=="function")gd(r)&&(x=1);else if(typeof r=="string")x=5;else e:switch(r){case q:return bi(l.children,y,v,i);case J:x=8,y|=8;break;case se:return r=Br(12,l,i,y|2),r.elementType=se,r.lanes=v,r;case ie:return r=Br(13,l,i,y),r.elementType=ie,r.lanes=v,r;case Y:return r=Br(19,l,i,y),r.elementType=Y,r.lanes=v,r;case Ee:return Ol(l,y,v,i);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case me:x=10;break e;case Oe:x=9;break e;case ae:x=11;break e;case de:x=14;break e;case ge:x=16,f=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return i=Br(x,l,i,y),i.elementType=r,i.type=f,i.lanes=v,i}function bi(r,i,l,f){return r=Br(7,r,f,i),r.lanes=l,r}function Ol(r,i,l,f){return r=Br(22,r,f,i),r.elementType=Ee,r.lanes=l,r.stateNode={isHidden:!1},r}function kd(r,i,l){return r=Br(6,r,null,i),r.lanes=l,r}function yd(r,i,l){return i=Br(4,r.children!==null?r.children:[],r.key,i),i.lanes=l,i.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},i}function Nx(r,i,l,f,y){this.tag=i,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Gr(0),this.expirationTimes=Gr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Gr(0),this.identifierPrefix=f,this.onRecoverableError=y,this.mutableSourceEagerHydrationData=null}function vd(r,i,l,f,y,v,x,T,A){return r=new Nx(r,i,l,T,A),i===1?(i=1,v===!0&&(i|=8)):i=0,v=Br(3,null,null,i),r.current=v,v.stateNode=r,v.memoizedState={element:f,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},ju(v),r}function Tx(r,i,l){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:D,key:f==null?null:""+f,children:r,containerInfo:i,implementation:l}}function Wm(r){if(!r)return Ho;r=r._reactInternals;e:{if(lr(r)!==r||r.tag!==1)throw Error(n(170));var i=r;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(dr(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(n(171))}if(r.tag===1){var l=r.type;if(dr(l))return vh(r,l,i)}return i}function Km(r,i,l,f,y,v,x,T,A){return r=vd(l,f,!0,r,y,v,x,T,A),r.context=Wm(null),l=r.current,f=ir(),y=Qo(l),v=Io(f,y),v.callback=i??null,Vo(l,v,y),r.current.lanes=y,qr(r,y,f),hr(r,f),r}function Rl(r,i,l,f){var y=i.current,v=ir(),x=Qo(y);return l=Wm(l),i.context===null?i.context=l:i.pendingContext=l,i=Io(v,x),i.payload={element:r},f=f===void 0?null:f,f!==null&&(i.callback=f),r=Vo(y,i,x),r!==null&&(to(r,y,x,v),al(r,y,x)),x}function Cl(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function Vm(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var l=r.retryLane;r.retryLane=l!==0&&l<i?l:i}}function wd(r,i){Vm(r,i),(r=r.alternate)&&Vm(r,i)}function Ix(){return null}var Gm=typeof reportError=="function"?reportError:function(r){console.error(r)};function bd(r){this._internalRoot=r}jl.prototype.render=bd.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(n(409));Rl(r,i,null,null)},jl.prototype.unmount=bd.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;yi(function(){Rl(null,r,null,null)}),i[_o]=null}};function jl(r){this._internalRoot=r}jl.prototype.unstable_scheduleHydration=function(r){if(r){var i=Pr();r={blockedOn:null,target:r,priority:i};for(var l=0;l<Je.length&&i!==0&&i<Je[l].priority;l++);Je.splice(l,0,r),l===0&&jn(r)}};function xd(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function Al(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function qm(){}function Ox(r,i,l,f,y){if(y){if(typeof f=="function"){var v=f;f=function(){var G=Cl(x);v.call(G)}}var x=Km(i,f,r,0,null,!1,!1,"",qm);return r._reactRootContainer=x,r[_o]=x.current,$s(r.nodeType===8?r.parentNode:r),yi(),x}for(;y=r.lastChild;)r.removeChild(y);if(typeof f=="function"){var T=f;f=function(){var G=Cl(A);T.call(G)}}var A=vd(r,0,!1,null,null,!1,!1,"",qm);return r._reactRootContainer=A,r[_o]=A.current,$s(r.nodeType===8?r.parentNode:r),yi(function(){Rl(i,A,l,f)}),A}function $l(r,i,l,f,y){var v=l._reactRootContainer;if(v){var x=v;if(typeof y=="function"){var T=y;y=function(){var A=Cl(x);T.call(A)}}Rl(i,x,r,y)}else x=Ox(l,i,r,y,f);return Cl(x)}ci=function(r){switch(r.tag){case 3:var i=r.stateNode;if(i.current.memoizedState.isDehydrated){var l=tt(i.pendingLanes);l!==0&&(Do(i,l|1),hr(i,$t()),(bt&6)===0&&(os=$t()+500,Wo()))}break;case 13:yi(function(){var f=To(r,1);if(f!==null){var y=ir();to(f,r,1,y)}}),wd(r,1)}},sn=function(r){if(r.tag===13){var i=To(r,134217728);if(i!==null){var l=ir();to(i,r,134217728,l)}wd(r,134217728)}},_t=function(r){if(r.tag===13){var i=Qo(r),l=To(r,i);if(l!==null){var f=ir();to(l,r,i,f)}wd(r,i)}},Pr=function(){return ht},cr=function(r,i){var l=ht;try{return ht=r,i()}finally{ht=l}},Zt=function(r,i,l){switch(i){case"input":if(At(r,l),i=l.name,l.type==="radio"&&i!=null){for(l=r;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<l.length;i++){var f=l[i];if(f!==r&&f.form===r.form){var y=Qa(f);if(!y)throw Error(n(90));lt(f),At(f,y)}}}break;case"textarea":It(r,l);break;case"select":i=l.value,i!=null&&K(r,!!l.multiple,i,!1)}},ve=pd,He=yi;var Rx={usingClientEntryPoint:!1,Events:[Ls,Wi,Qa,R,ne,pd]},Qs={findFiberByHostInstance:ui,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Cx={bundleType:Qs.bundleType,version:Qs.version,rendererPackageName:Qs.rendererPackageName,rendererConfig:Qs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=Lo(r),r===null?null:r.stateNode},findFiberByHostInstance:Qs.findFiberByHostInstance||Ix,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 Ml=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ml.isDisabled&&Ml.supportsFiber)try{et=Ml.inject(Cx),Qe=Ml}catch{}}return mr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Rx,mr.createPortal=function(r,i){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!xd(i))throw Error(n(200));return Tx(r,i,null,l)},mr.createRoot=function(r,i){if(!xd(r))throw Error(n(299));var l=!1,f="",y=Gm;return i!=null&&(i.unstable_strictMode===!0&&(l=!0),i.identifierPrefix!==void 0&&(f=i.identifierPrefix),i.onRecoverableError!==void 0&&(y=i.onRecoverableError)),i=vd(r,1,!1,null,null,l,!1,f,y),r[_o]=i.current,$s(r.nodeType===8?r.parentNode:r),new bd(i)},mr.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var i=r._reactInternals;if(i===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=Lo(i),r=r===null?null:r.stateNode,r},mr.flushSync=function(r){return yi(r)},mr.hydrate=function(r,i,l){if(!Al(i))throw Error(n(200));return $l(null,r,i,!0,l)},mr.hydrateRoot=function(r,i,l){if(!xd(r))throw Error(n(405));var f=l!=null&&l.hydratedSources||null,y=!1,v="",x=Gm;if(l!=null&&(l.unstable_strictMode===!0&&(y=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(x=l.onRecoverableError)),i=Km(i,null,r,1,l??null,y,!1,v,x),r[_o]=i.current,$s(r),f)for(r=0;r<f.length;r++)l=f[r],y=l._getVersion,y=y(l._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[l,y]:i.mutableSourceEagerHydrationData.push(l,y);return new jl(i)},mr.render=function(r,i,l){if(!Al(i))throw Error(n(200));return $l(null,r,i,!1,l)},mr.unmountComponentAtNode=function(r){if(!Al(r))throw Error(n(40));return r._reactRootContainer?(yi(function(){$l(null,null,r,!1,function(){r._reactRootContainer=null,r[_o]=null})}),!0):!1},mr.unstable_batchedUpdates=pd,mr.unstable_renderSubtreeIntoContainer=function(r,i,l,f){if(!Al(l))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return $l(r,i,l,!1,f)},mr.version="18.3.1-next-f1338f8080-20240426",mr}var Kg;function VI(){if(Kg)return Ad.exports;Kg=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(),Ad.exports=KI(),Ad.exports}var Vg;function GI(){if(Vg)return Bl;Vg=1;var e=VI();return Bl.createRoot=e.createRoot,Bl.hydrateRoot=e.hydrateRoot,Bl}var qI=GI();function Gg(e,t,n){const o=location.hostname;return n!==null&&o===n.host?`${n1(n.previews,e,t)}/`:o.endsWith(".localhost")?`http://w${e}.${o}:${t}/`:o==="127.0.0.1"||o==="localhost"?`http://127.0.0.1:${t}/`:`${location.protocol}//${o}:${t}/`}function qg(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function Yg(e,t){if(t&&e.startsWith(`${t}/`))return e.slice(t.length+1);const n=e.lastIndexOf("/src/");return n>=0?e.slice(n+1):e}function Zl(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function Mc(e){return e.agent==="working"||e.agent==="waiting"}function la(e){var t;return e.agent==="waiting"?"waiting":e.agent==="working"?"working":(t=e.worktree)!=null&&t.landed?"landed":e.procs.some(n=>n.status==="crashed"||n.status==="unreachable")?"crashed":e.procs.some(n=>n.status==="running")?"running":e.procs.some(n=>n.status==="starting")?"starting":"idle"}const YI={waiting:"Waiting for you",working:"Agent working",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",idle:"Idle"};function QI(e,t=!1){const n=la(e);return n==="idle"&&t?"Not set up":YI[n]}function gv(e){const t=e.filter(s=>s.status==="crashed"||s.status==="unreachable"),n=t[0];if(!n)return null;const o=t.map(s=>s.status==="unreachable"?`${s.name} never answered on :${s.port}`:`${s.name} crashed on :${s.port}`).join(", ");return{dead:t,tip:`${o} · click to open its tab`,stream:n.name}}function XI(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}function kv(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function yv(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 JI=/Firefox\//.test(navigator.userAgent);function vv(){const e=t=>{var n;return((n=window.matchMedia)==null?void 0:n.call(window,`(display-mode: ${t})`).matches)??!1};return e("standalone")||e("window-controls-overlay")}const eO=/Chrome\//.test(navigator.userAgent)&&vv(),yt=e=>Jx(e,{firefox:JI,pwa:eO});function Jf(e){return e.component?`<${e.component} />`:`<${e.tag}>`}const co=e=>e.linkPath??e.path;function yf(e,t){return e.worktree&&Zn(e.worktree)&&t?t.defaultBranch:e.name}function xa(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 o=n/60;if(o<24)return`${Math.floor(o)}h`;const s=o/24;return s<7?`${Math.floor(s)}d`:s<365?`${Math.floor(s/7)}w`:`${Math.floor(s/365)}y`}function tO(e,t,n,o){var c;if(!t)return null;const s=e.filter(ar).filter(u=>u.repoId===t&&(u.worktree.agent??o)===n);return((c=s.find(u=>Zn(u.worktree))??s[0])==null?void 0:c.id)??null}const wv=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function nO(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const rO=new Set(["top","bottom"]),Pd={top:"bottom",bottom:"top",left:"right",right:"left"};function Ld(e,t,n,o,s){const a=n==="top"||n==="left";return s?a?e.end+o-t:e.start-o:a?e.start-o-t:e.end+o}function Qg(e,t,n,o,s){return n==="top"||n==="left"?e>=s:e+t<=o-s}function zd(e,t,n,o){return n==="center"?e.start+(e.end-e.start)/2-t/2:n==="start"?e.start-o:e.end+o-t}function Xg(e,t,n,o,s){return n==="start"?e+t<=o-s:e>=s}const Jg=(e,t,n,o)=>n||!o?e:t,ek=(e,t,n,o)=>Math.max(o,Math.min(e,n-o-t));function oO(e,t,n,o){const{offset:s=0,alignOffset:a=0,cover:c=!1,flip:u="none",margin:d=8}=o,p=rO.has(o.side),m=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},g=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 k=o.side;if(u==="side"||u==="both"){const I=Ld(m.a,m.size,k,s,c),C=Ld(m.a,m.size,Pd[k],s,c);k=Jg(k,Pd[k],Qg(I,m.size,k,m.limit,d),Qg(C,m.size,Pd[k],m.limit,d))}let w=o.align??"center";if((u==="align"||u==="both")&&w!=="center"){const I=w==="start"?"end":"start",C=zd(g.a,g.size,w,a),E=zd(g.a,g.size,I,a);w=Jg(w,I,Xg(C,g.size,w,g.limit,d),Xg(E,g.size,I,g.limit,d))}const b=ek(Ld(m.a,m.size,k,s,c),m.size,m.limit,d),_=ek(zd(g.a,g.size,w,a),g.size,g.limit,d);return p?{x:_,y:b,side:k,align:w}:{x:b,y:_,side:k,align:w}}function iO(e,t,n){var a,c;const o=e.length;if(o===0)return-1;let s=t<0?n===1?0:o-1:(t+n+o)%o;for(let u=0;u<o&&((a=e[s])!=null&&a.disabled);u++)s=(s+n+o)%o;return(c=e[s])!=null&&c.disabled?-1:s}const bv={sep:!0},Ni=e=>!("sep"in e);function Pc(e){const t=[];for(const n of e)(Ni(n)||t.length>0&&Ni(t[t.length-1]))&&t.push(n);for(;t.length>0&&!Ni(t[t.length-1]);)t.pop();return t}const Hn=e=>Pc(e.flatMap((t,n)=>n?[bv,...t]:t));let ss=null,sO=0;const vf=new Set,tk=()=>{for(const e of vf)e()},yr={get:()=>ss,subscribe(e){return vf.add(e),()=>{vf.delete(e)}},open(e){const t=Pc(e.items);if(t.length===0)return yr.close();ss={...e,items:t,id:++sO},tk()},close(){ss&&(ss=null,tk())},toggle(e){ss&&ss.target===e.target?yr.close():yr.open(e)}};function xv(){return O.useSyncExternalStore(yr.subscribe,yr.get)}function _v(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function aO(e,t){return _v(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function lO(e){const t=e.anchor;return t?{rect:t,placement:{side:"bottom",align:e.align==="right"?"end":"start",offset:4,margin:4}}:{rect:wv(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function nn(e){return O.useMemo(()=>({contextMenu(t,n){return{onContextMenu:o=>{const s=Pc(t(_v(o)?"keyboard":"pointer"));if(s.length===0)return;o.preventDefault(),o.stopPropagation();const a=o.currentTarget;yr.open({items:s,owner:e,key:n,target:a,...aO(o,a)})}}},dropdown(t,n="left"){return{"aria-haspopup":"menu",onClick:o=>{o.stopPropagation();const s=o.currentTarget;yr.toggle({items:t(),owner:e,target:s,anchor:s.getBoundingClientRect(),align:n})}}},openUnder(t,n,o){yr.open({items:n(),owner:e,key:o,target:t,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const cO=200;function uO(e,t){const n=new Map(e.map(o=>[o.path,o]));for(const o of t){if(n.size>=cO)break;const s=Rc(o.path);s&&!n.has(s)&&n.set(s,{path:s,text:o.text})}return n.size===e.length?e:[...n.values()]}function Ev(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const wf=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt};function dO(e){const t=[],n=new Map;for(const o of e){const s=o.worktree,a=Zn(s)?0:s.landed?2:1,c=s.variant?`${a}:${s.variant.group}`:null,u=c?n.get(c):void 0;if(u){u.rows.push(o),u.at=Math.max(u.at,wf(s));continue}const d={tier:a,at:wf(s),rows:[o]};t.push(d),c&&n.set(c,d)}return t.sort((o,s)=>o.tier-s.tier||s.at-o.at),t.flatMap(o=>o.rows.length>1?o.rows.sort((s,a)=>{var c,u;return(((c=s.worktree.variant)==null?void 0:c.index)??0)-(((u=a.worktree.variant)==null?void 0:u.index)??0)}):o.rows)}const Sv="draft:",Nv=e=>Sv+e,ep=(e,t)=>e?t?Nv(e.worktree.repoId):e.worktree.id:null,Tv=Object.freeze({chat:[],log:[],queue:[],page:{errors:[]},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:vo}),tp=e=>({...e,phase:"editing",repoId:null,prompt:""}),nk=()=>tp({mode:"create",name:"",parent:`~/${_y}`}),Hl=Object.freeze({left:!0,right:!0,term:!1,design:!1});function tc(e){return{left:e.leftOpen,right:e.rightOpen,term:e.termOpen,design:e.designOpen}}function fO(e,t){return e.left===t.left&&e.right===t.right&&e.term===t.term&&e.design===t.design}function Iv(e,t){return{...e,leftOpen:t.left,rightOpen:t.right,termOpen:t.term,designOpen:t.design,leftAuto:!1}}const rk=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref;function Ov(e,t,n,o){var a;if(!o.fiber)return o;const s=(a=lo(e,t).changedRanges[n])==null?void 0:a.offset;return s===void 0?o:{n:o.n-s}}function pO(e){const t=e.cached??Oa,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],removing:[],shipping:{},visibleDiscovered:[],discoveredOpen:e.storedDiscoveredOpen??{},archivedOpen:e.storedArchivedOpen??{},refs:{},archived:{},lastActive:e.storedLastActive??{},pendingOpen:!1,activeId:null,clientId:e.clientId,storedActive:e.storedActive??null,storedRepo:e.storedRepo??null,heard:!1,local:{},editor:null,toast:null,reloadReq:null,dragFiles:!1,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,leftOpen:!0,focusLeft:0,editCommit:0,rightOpen:!0,focusRight:0,railOpen:e.storedRailOpen??!1,focusRail:0,unreadHold:null,panels:e.storedPanels??{},leftAuto:!0,zen:!1,termOpen:!1,focusTerm:0,termTall:0,designOpen:!1,themes:Jl.some(s=>s.id===t.id)?Jl:[...Jl,t],themePrefs:{...II,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,remote:null,gitIdentity:!0,choosingFolder:!1,newProject:null,autoSend:null,chosenFolder:null,pending:[],activeImportId:null,agents:[],defaultAgent:"claude",agentConfigs:{},draft:null,spares:[],visits:{}},o=e.storedRepo?n.panels[e.storedRepo]:void 0;return o?Iv(n,o):n}function Rv(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function hO(e){return e.previewTheme??jc(e.themePrefs,e.themes,Rv(e))}function lo(e,t){return t&&e.local[t]||Tv}function Ti(e,t){return t&&e.rows.find(n=>n.id===t)||null}function cn(e,t){const n=Ti(e,t);return n&&ar(n)?n:null}function Cv(e){const t=cn(e,e.activeId);if(!t||!Zn(t.worktree)||t.agent!=="idle"||t.worktree.empty!==!0)return!1;const n=Ai(e,t.repoId),o=e.rows.some(s=>{var a;return s.repoId===t.repoId&&((a=s.worktree)==null?void 0:a.kind)==="worktree"});return!!(n!=null&&n.needsSetup)&&!o&&lo(e,t.id).chat.length===0}function jv(e){return e.newProject!==null||Cv(e)}function Av(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function $v(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function wo(e){const t=e.activeRepoId?e.repos.find(n=>n.id===e.activeRepoId):void 0;return!!t&&Av(t)}function Wl(e){return e.rightOpen||wo(e)?e:{...e,rightOpen:!0}}function Ai(e,t){return t&&e.repos.find(n=>n.id===t)||null}function Mv(e,t){return t&&e.rows.filter(ar).find(n=>n.repoId===t&&Zn(n.worktree))||null}function Pv(e){const t=e.draft?cn(e,e.draft.base):null;if(!t||!Zn(t.worktree))return null;const n=Ai(e,t.repoId);return n&&Av(n)?null:e.spares.find(o=>o.repoId===t.repoId&&o.ready)??null}function bf(e){var t;return wo(e)?null:e.draft?((t=Pv(e))==null?void 0:t.id)??e.draft.base:e.activeId}function Lv(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function np(e){const t=cn(e,e.activeId);return t&&Lv(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function mO(e,t,n){const o=e.filter(ar),s=n.length?o.filter(a=>!n.includes(a.id)):o;return dO(t?s.filter(a=>a.repoId===t):s)}function gO(e,t){const n=e.filter(o=>!ar(o));return t?n.filter(o=>o.repoId===t):n}function ha(e,t,n=e.rows){var u;const o=n.filter(ar),s=e.removing.length?o.filter(d=>!e.removing.includes(d.id)):o,a=t?e.lastActive[t]:void 0;if(a&&s.some(d=>d.id===a))return a;const c=t?s.filter(d=>d.repoId===t):s;return((u=c.find(d=>Zn(d.worktree))??c[0])==null?void 0:u.id)??null}function Kl(e,t){const n=Object.entries(e),o=n.filter(([s])=>!t(s));return o.length===n.length?e:Object.fromEntries(o)}function us(e,t){const n=Ti(e,t),o=(n==null?void 0:n.repoId)??e.activeRepoId,s=n&&ar(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,a=e.activeId!==t?e.activeId:null,c=a?e.local[a]:void 0,u=a&&(c==null?void 0:c.recapFor)!==void 0?{...e.local,[a]:rp(c)}:e.local;return{...e,activeId:t,activeRepoId:o,lastActive:s,editor:null,draft:null,local:u}}function rp({recapFor:e,...t}){return t}function ok(e,t,n){return!e.draft||n?null:t.some(o=>{var s;return o.id===((s=e.draft)==null?void 0:s.base)})?e.draft:null}const zv=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder";function Qt(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??Tv)}}}function kO(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function yO(e){const t=e.activeRepoId;if(!t)return e;const n=e.panels[t];return n?Iv(e,n):{...e,panels:{...e.panels,[t]:tc(e)}}}function vO(e){return e.a==="server"&&e.msg.t==="git-status"}function hs(e,t){let n=wO(e,t);return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.activeRepoId!==e.activeRepoId?n=yO(n):n.activeRepoId&&!vO(t)&&!fO(tc(e),tc(n))&&(n={...n,panels:{...n.panels,[n.activeRepoId]:tc(n)}}),n.rows===e.rows&&n.activeRepoId===e.activeRepoId&&n.removing===e.removing?n:{...n,visible:mO(n.rows,n.activeRepoId,n.removing),visibleDiscovered:gO(n.rows,n.activeRepoId)}}function wO(e,t){var n,o,s,a,c,u;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure??e.connectFailure};case"activate":return us(e,t.id);case"open-draft":{if(jv(e))return e;const d=t.base??((n=Mv(e,e.activeRepoId))==null?void 0:n.id)??null;return!d||!cn(e,d)?e:((o=e.draft)==null?void 0:o.base)===d?{...e,draft:null}:Wl({...us(e,d),draft:{base:d,variants:1,batch:!1,agent:e.defaultAgent},overlay:null,paletteReturn:null})}case"close-draft":return e.draft?{...e,draft:null}: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"remove-worktrees":{const d=t.ids.filter(m=>!e.removing.includes(m)&&cn(e,m));if(d.length===0)return e;const p={...e,removing:[...e.removing,...d]};return e.activeId&&d.includes(e.activeId)?us(p,ha(p,e.activeRepoId)):p}case"shipping":return e.shipping[t.id]||!Ti(e,t.id)?e:{...e,shipping:{...e.shipping,[t.id]:t.op}};case"activate-repo":{if(!Ai(e,t.id))return e;const d=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return d;const p=ha(d,t.id);return{...us(d,p),activeRepoId:t.id,pendingOpen:!1}}case"open-repo":return{...e,pendingOpen:!0};case"new-project":return{...e,newProject:t.v,overlay:null,paletteReturn:null,previewTheme:null,draft:null,editor:null};case"new-project-set":return e.newProject?{...e,newProject:{...e.newProject,...t.v}}:e;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 d=t.v,p=e.editor,m=p&&p.worktreeId===d.worktreeId&&p.path===d.path&&p.ref===d.ref?p:null,g=d.line&&Ov(e,d.worktreeId,d.path,d.line);return{...e,editor:{worktreeId:d.worktreeId,path:d.path,...d.ref?{ref:d.ref}:{},view:d.view??(m==null?void 0:m.view)??null,seq:d.seq,disk:(m==null?void 0:m.disk)??null,...g?{line:g}:{},focus:d.focus,conflict:(m==null?void 0:m.conflict)??null}}}case"editor-read":{const d=e.editor;if(!d||!rk(d,t.file))return e;const p=t.disk;if(!p){const m={ok:!1,message:t.error??`could not read ${d.path}`};return d.disk?{...e,toast:m}:{...e,editor:null,toast:m}}return{...e,editor:{...d,view:d.view??(p.before===p.after?"file":"diff"),disk:p}}}case"editor-conflict":{const d=e.editor;return d&&rk(d,t.file)?{...e,editor:{...d,conflict:t.theirs}}:e}case"editor-view":return e.editor?{...e,editor:{...e.editor,view:t.v,line:void 0}}:e;case"dismiss-toast":return{...e,toast:null};case"set-draft":return Qt(e,t.id,({walk:d,recapFor:p,...m})=>({...m,draft:t.text,...p!==void 0&&!t.text.trim()?{recapFor:p}:{}}));case"arrive":{const d=(a=(s=Ti(e,t.id))==null?void 0:s.worktree)==null?void 0:a.lastTurn;return!((c=Ti(e,t.id))==null?void 0:c.unseen)||!(d!=null&&d.recap)?e:Qt(e,t.id,m=>m.recapFor===d.at?m:{...m,recapFor:d.at})}case"walk":return Qt(e,t.id,({walk:d,...p})=>({...p,draft:t.text,...t.walk?{walk:t.walk}:{}}));case"attach":return Qt(Wl(e),t.id,d=>({...rp(d),attachments:[...d.attachments,...t.items]}));case"detach":return Qt(e,t.id,d=>({...d,attachments:d.attachments.filter(p=>p.key!==t.key)}));case"clear-attachments":return Qt(e,t.id,d=>d.attachments.length?{...d,attachments:[]}:d);case"hmr":return Qt(e,t.id,d=>({...d,turn:{...d.turn,hmr:!0}}));case"page":return Qt(e,t.id,d=>({...d,page:{url:t.url??d.page.url,title:t.title??d.page.title,errors:t.fresh?[]:t.error?[...d.page.errors.slice(-2),t.error]:d.page.errors}}));case"links":return Qt(e,t.id,d=>{const p=uO(d.links??[],t.links);return p===d.links?d:{...d,links:p}});case"drag-files":return e.dragFiles===t.v?e:{...e,dragFiles:t.v};case"set-picking":return{...e,picking:t.v};case"open":return{...e,overlay:t.overlay,previewTheme:null,paletteReturn:zv(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...kO(e,t.back)};case"toggle":return((u=e.overlay)==null?void 0:u.kind)===t.overlay.kind?hs(e,{a:"close"}):hs(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-left":return{...e,leftOpen:!e.leftOpen,leftAuto:!1};case"focus-left":return{...e,leftOpen:!0,leftAuto:!1,focusLeft:e.focusLeft+1};case"edit-commit":return{...e,leftOpen:!0,leftAuto:!1,editCommit:e.editCommit+1};case"toggle-right":return wo(e)?e:{...e,rightOpen:!e.rightOpen};case"focus-right":return{...Wl(e),focusRight:e.focusRight+1};case"show-right":return Wl(e);case"hold-unread":return{...e,unreadHold:t.id};case"toggle-rail":return{...e,railOpen:!e.railOpen};case"focus-rail":return{...e,railOpen:!0,focusRail:e.focusRail+1};case"toggle-discovered":{const d=e.activeRepoId;return d?{...e,discoveredOpen:{...e.discoveredOpen,[d]:!e.discoveredOpen[d]}}:e}case"toggle-archived":{const d=e.activeRepoId;return d?{...e,archivedOpen:{...e.archivedOpen,[d]:!e.archivedOpen[d]}}:e}case"toggle-zen":return wo(e)?e:{...e,zen:!e.zen,toast:e.zen?e.toast:{ok:!0,message:"⌘. to exit"}};case"toggle-terminal":return{...e,termOpen:!e.termOpen};case"focus-terminal":return{...e,termOpen:!0,focusTerm:e.focusTerm+1};case"toggle-design":return wo(e)?e:{...e,designOpen:!e.designOpen};case"term-stream":return Qt({...e,termOpen:!0,termTall:t.tall?e.termTall+1:e.termTall},t.id,d=>({...d,termStream:t.stream}));case"preview-theme":return{...e,previewTheme:t.theme};case"system-dark":return{...e,systemDark:t.v};case"toast":return{...e,toast:t.toast};case"incompatible":return{...e,incompatible:!0,connected:!1};case"server":return xO(e,t.msg)}}function ik(e,t,n){const o=new Set([...t.map(a=>a.id),...n.map(a=>a.id)]),s=a=>o.has(a)||a.startsWith(Sv);return Object.keys(e).every(s)?e:Object.fromEntries(Object.entries(e).filter(([a])=>s(a)))}function bO(e,t){const n=new Set(t.map(o=>o.id));return Object.values(e).every(o=>n.has(o))?e:Object.fromEntries(Object.entries(e).filter(([,o])=>n.has(o)))}function Vl(e,t){const n=new Set(t.map(o=>o.id));return Object.keys(e).every(o=>n.has(o))?e:Object.fromEntries(Object.entries(e).filter(([o])=>n.has(o)))}function sk(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=Mv(e,t.repoId);return n?t.prompt.trim()?{...Qt(e,n.id,s=>({...s,draft:t.prompt})),newProject:null,autoSend:n.id}:{...e,newProject:null}:e}function xO(e,t){var n,o,s,a,c,u,d;switch(t.t){case"hello":{const p=b=>!!b&&t.rows.some(_=>_.id===b),m=b=>!!b&&t.repos.some(_=>_.id===b),g=m(e.activeRepoId)?e.activeRepoId:m(e.storedRepo)?e.storedRepo:null,k=p(e.activeId)?e.activeId:p(e.storedActive)?e.storedActive:ha(e,g,t.rows),w=t.rows.find(b=>b.id===k);return{...e,heard:!0,repos:t.repos,rows:t.rows,activeId:k,activeRepoId:(w==null?void 0:w.repoId)??g??((n=t.repos[0])==null?void 0:n.id)??null,spares:t.spares,draft:ok(e,t.rows,!1),removing:e.removing.length?[]:e.removing,shipping:Kl(e.shipping,()=>!0),local:ik(e.local,t.rows,t.spares),lastActive:bO(e.lastActive,t.rows),discoveredOpen:Vl(e.discoveredOpen,t.repos),archivedOpen:Vl(e.archivedOpen,t.repos),refs:Vl(e.refs,t.repos),archived:Vl(e.archived,t.repos),themes:t.themes??e.themes,themePrefs:t.themePrefs??e.themePrefs,agents:t.agents,defaultAgent:t.defaultAgent,home:t.home,folderDialog:t.folderDialog,remote:t.remote,gitIdentity:t.gitIdentity,newProject:e.newProject??(t.repos.length===0&&t.rows.length===0&&t.pending.length===0?nk():null),pending:t.pending,visits:t.visits,activeImportId:t.pending.some(b=>b.id===e.activeImportId)?e.activeImportId:null}}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"agents":return{...e,agents:t.agents,defaultAgent:t.defaultAgent};case"agent-config":{const{t:p,...m}=t;return{...e,agentConfigs:{...e.agentConfigs,[m.agent]:m}}}case"pending-repos":{const p=new Set(e.pending.map(b=>b.id)),m=t.pending.find(b=>!p.has(b.id)),g=m&&e.pendingOpen?m.id:e.activeImportId,k=t.pending.some(b=>b.id===g),w=t.pending.some(b=>b.id===g&&b.error);return{...e,pending:t.pending,activeImportId:k?g:null,pendingOpen:w?!1:e.pendingOpen,newProject:m&&e.pendingOpen&&((o=e.newProject)==null?void 0:o.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:(((s=e.chosenFolder)==null?void 0:s.seq)??0)+1,folder:t.folder}};case"refs":return{...e,refs:{...e.refs,[t.repoId]:{query:t.query,refs:t.refs}}};case"archived":return{...e,archived:{...e.archived,[t.repoId]:t.items}};case"repos":{const p=new Set(e.repos.map(_=>_.id)),m=t.repos.find(_=>!p.has(_.id));let g=e.activeRepoId,k=e.pendingOpen,w=e.newProject;m&&(k||!g)?(g=m.id,k=!1,w&&w.phase!=="unmaking"&&(w={...w,phase:"creating",repoId:m.id})):t.repos.some(_=>_.id===g)||(g=((a=t.repos[0])==null?void 0:a.id)??null),(w==null?void 0:w.phase)==="unmaking"&&!t.repos.some(_=>_.id===(w==null?void 0:w.repoId))&&(w={...w,phase:"editing",repoId:null}),t.repos.length===0&&!w&&(w=nk());const b=e.gitIdentity||t.repos.some(_=>_.made&&!p.has(_.id));return g===e.activeRepoId?{...e,repos:t.repos,pendingOpen:k,newProject:w,gitIdentity:b}:sk({...e,repos:t.repos,pendingOpen:k,newProject:w,gitIdentity:b,activeRepoId:g,activeId:ha(e,g),editor:null,draft:null})}case"worktrees":{let p=e.activeId;(!p||!t.rows.some(w=>w.id===p))&&(p=ha(e,e.activeRepoId,t.rows));const m=new Set(e.rows.map(w=>w.id)),g=t.rows.find(w=>{var b;return!m.has(w.id)&&((b=w.worktree)==null?void 0:b.kind)==="worktree"&&w.worktree.createdBy===e.clientId});g&&e.rows.length>0&&(p=g.id);const k=e.removing.filter(w=>t.rows.some(b=>b.id===w));return sk({...us({...e,rows:t.rows,spares:t.spares,removing:k.length===e.removing.length?e.removing:k,shipping:Kl(e.shipping,w=>!t.rows.some(b=>b.id===w)),local:ik(e.local,t.rows,t.spares)},p),draft:ok(e,t.rows,!!g),editor:p===e.activeId?e.editor:null})}case"proc":{const p=e.rows.map(m=>m.id===t.worktreeId?{...m,procs:_O(m.procs,t.proc)}:m);return{...e,rows:p}}case"log":return Qt(e,t.worktreeId,p=>({...p,log:[...p.log.slice(-400),{proc:t.proc,line:t.line}]}));case"agent":{const p=t.event,m=t.worktreeId;let g=Qt(e,m,k=>{const w=lk(k.chat,p);let b=k.turn;p.type==="turn-start"?b={edits:!1,hmr:!1}:p.type==="tool-start"&&Fx(p)&&(b={...b,edits:!0});const _=p.type==="session-info"&&p.model?p.model:k.model,I=p.type==="session-info"&&p.effort?p.effort:k.effort,C=p.type==="usage"?ak(p):k.usage;return{...p.type==="turn-start"||p.type==="user-message"?rp(k):k,chat:w,turn:b,..._!==k.model?{model:_}:{},...I!==k.effort?{effort:I}:{},...C!==k.usage?{usage:C}:{}}});if(p.type==="turn-end"){const k=g.local[m].turn;k.edits&&!k.hmr&&(g={...g,reloadReq:{id:m,n:(((c=g.reloadReq)==null?void 0:c.n)??0)+1}})}return g}case"backfill":{let p=[],m;for(const{event:g}of t.events)p=lk(p,g),g.type==="usage"&&(m=ak(g));return Qt(e,t.worktreeId,g=>({...g,chat:p,log:t.log??g.log,...m?{usage:m}:{}}))}case"git-status":{let p=e.leftOpen,m=e.leftAuto;if(e.leftAuto&&t.worktreeId===e.activeId){const k=cn(e,t.worktreeId);k&&Zn(k.worktree)&&t.files.length===0&&(((u=t.committed)==null?void 0:u.length)??0)===0&&(p=!1),m=!1}return{...Qt(e,t.worktreeId,k=>({...k,git:{files:t.files,committed:t.committed,ahead:t.ahead,behind:t.behind,head:t.head},changedRanges:{}})),leftOpen:p,leftAuto:m}}case"changed-ranges":{const p=Qt(e,t.worktreeId,g=>({...g,changedRanges:{...g.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),m=p.editor;return!((d=m==null?void 0:m.line)!=null&&d.fiber)||m.worktreeId!==t.worktreeId||m.path!==t.path?p:{...p,editor:{...m,line:Ov(p,m.worktreeId,m.path,m.line)}}}case"shipped":{const p=t.suggestion?Qt(us(e,t.worktreeId),t.worktreeId,m=>({...m,draft:t.suggestion})):e;return{...p,shipping:Kl(p.shipping,m=>m===t.worktreeId),toast:{ok:t.ok,message:t.message,url:t.url,removeIds:t.merged&&t.ok?t.removeIds??[t.worktreeId]:void 0,restoreId:t.restoreId}}}case"files":return Qt(e,t.worktreeId,p=>({...p,files:t.paths}));case"search-results":return Qt(e,t.worktreeId,p=>({...p,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[p]=t.hits;if(!p)return{...e,toast:{ok:!1,message:"nothing in the source matches this element"}};if(!t.sure)return hs(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const m=hs(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:p.path,view:"file",line:{n:p.line},focus:!0,seq:t.seq}});return m.leftOpen?m:hs(m,{a:"toggle-left"})}case"design-index":return Qt(e,t.worktreeId,p=>({...p,design:t.index}));case"routes":return Qt(e,t.worktreeId,p=>({...p,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return Qt(e,t.worktreeId,p=>({...p,queue:t.items}));case"agent-commands":return Qt(e,t.worktreeId,p=>({...p,commands:t.commands}));case"git-log":return Qt(e,t.worktreeId,p=>({...p,commits:t.commits}));case"git-commit":return Qt(e,t.worktreeId,p=>({...p,commitFiles:{...p.commitFiles,[t.sha]:t.files}}));case"error":{const p=e.newProject,m=(p==null?void 0:p.phase)==="creating"&&!p.repoId;return{...e,toast:{ok:!1,message:t.message},removing:e.removing.length?[]:e.removing,shipping:Kl(e.shipping,()=>!0),newProject:m?{...p,phase:"editing"}:(p==null?void 0:p.phase)==="unmaking"?null:p,pendingOpen:m?!1:e.pendingOpen}}default:return e}}function _O(e,t){const n=e.findIndex(s=>s.name===t.name);if(n===-1)return[...e,t];const o=e.slice();return o[n]=t,o}function ak(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function lk(e,t){var o;const n=e[e.length-1];switch(t.type){case"user-message":return[...e,{kind:"user",text:t.text,...(o=t.attachments)!=null&&o.length?{attachments:t.attachments}:{}}];case"text-delta":return(n==null?void 0:n.kind)==="assistant"?[...e.slice(0,-1),{...n,text:n.text+t.text}]:[...e,{kind:"assistant",text:t.text}];case"thinking-delta":return(n==null?void 0:n.kind)==="thinking"?[...e.slice(0,-1),{...n,text:n.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 s=e.findLastIndex(u=>u.kind==="tool"&&u.id===t.toolId);if(s===-1)return e;const a=e.slice(),c=a[s];return a[s]={...c,...t.name?{name:t.name}:{},...t.title?{title:t.title}:{},...t.input!==void 0?{input:t.input}:{},...t.kind?{toolKind:t.kind}:{}},a}case"tool-delta":{const s=e.findLastIndex(u=>u.kind==="tool"&&u.id===t.toolId);if(s===-1)return e;const a=e.slice(),c=a[s];return a[s]={...c,output:(c.output??"")+t.text},a}case"tool-end":{const s=e.findLastIndex(u=>u.kind==="tool"&&u.id===t.toolId);if(s===-1)return e;const a=e.slice(),c=a[s];return a[s]={...c,output:t.output,isError:t.isError,done:!0},a}case"agent-error":return[...e,{kind:"error",text:t.message}];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"agent-auth-required":return[...e,{kind:"auth",agent:t.agent,agentName:t.agentName,methods:t.methods,...t.rejected?{rejected:!0}:{},done:!1}];case"agent-auth-ok":return e.some(s=>s.kind==="auth"&&!s.done)?e.map(s=>s.kind==="auth"&&!s.done?{...s,done:!0}:s):e;case"agent-question":return ck(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":return ck(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"permission",title:t.title,...t.detail?{detail:t.detail}:{},choices:t.choices}});case"agent-ask-end":{const s=e.findLastIndex(c=>c.kind==="ask"&&c.id===t.id&&!c.outcome);if(s===-1)return e;const a=e.slice();return a[s]={...a[s],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},a}default:return e}}function ck(e,t,n){const o=t?e.findLastIndex(s=>s.kind==="tool"&&s.id===t):-1;return o===-1?[...e,n]:[...e.slice(0,o),...e.slice(o+1),n]}function Dv(e,{sock:t,dispatch:n}){var m;const o=g=>g?"hide":"show",s=e.repos.some(g=>g.id===e.activeRepoId),a=(m=cn(e,e.activeId))==null?void 0:m.worktree.id,c=[];s&&(c.push({id:"new",label:"new worktree…",key:yt("new"),onClick:()=>n({a:"open-draft"})}),c.push({id:"refs",label:"open a branch or PR…",key:yt("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),a&&(c.push({id:"jump",label:"jump to file…",key:yt("quick-open"),onClick:()=>{t==null||t.send({t:"list-files",worktreeId:a}),n({a:"open",overlay:{kind:"quick-open"}})}}),c.push({id:"search",label:"search in files…",key:yt("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),np(e)&&c.push({id:"routes",label:"go to page…",key:yt("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),c.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:yt("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const u=[{id:"left",label:`${o(e.leftOpen)} changes panel`,key:yt("left"),onClick:()=>n({a:"toggle-left"})},{id:"right",label:`${o(e.rightOpen)} chat panel`,key:yt("composer"),onClick:()=>n({a:"toggle-right"})},{id:"terminal",label:`${o(e.termOpen)} terminal`,key:yt("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${o(e.railOpen)} worktree panel`,key:yt("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${o(e.designOpen)} design system`,key:yt("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:yt("zen"),onClick:()=>n({a:"toggle-zen"})}],d=[{id:"commands",label:"command palette",key:yt("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:yt("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];if(e.remote){const g=p1(`https://${e.remote.host}`);d.push({id:"toyon-cloud",label:"add to toyon.cloud",onClick:()=>window.open(g,"_blank")})}const p=wo(e)?new Set(["right","design","zen"]):null;return Hn([c,p?u.filter(g=>!p.has(g.id)):u,d])}const Ln=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function Fv(e){const t=[e.landed?"merged":e.uncommitted?"uncommitted changes":null];return e.restorable||t.push("commits not kept"),t.push(xa(e.archivedAt)),t.filter(Boolean).join(" · ")}function Lc(e,t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function xf(e,t,{sock:n,dispatch:o}){const s=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{Lc(n,e.id,t),o({a:"close"})}}];return Hn([s,[{id:"copy-branch",label:"copy branch name",onClick:()=>Ln(e.branch)}],[{id:"delete",label:"delete for good…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}" for good?
96
-
97
- Its chat, attachments and kept commits are deleted, and it can no longer be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}function zc(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function Uv(e,t){const n=zc(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const EO=e=>Df(fs((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function $o(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const Bv=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function _a(e,t,n){if(n.length!==0){t({a:"remove-worktrees",ids:n});for(const o of n)e==null||e.send({t:"remove-worktree",worktreeId:o})}}function Zv(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function Hv(e,t){return{rename(n){if(!mv(n.worktree))return;const o=window.prompt("Rename worktree (also renames its branch):",n.worktree.title);o!=null&&o.trim()&&(e==null||e.send({t:"rename-worktree",worktreeId:n.worktree.id,title:o.trim()}))},pickVariant(n){const o=n.worktree.variant;if(!o)return;const s=o.of-1;window.confirm(`Keep "${n.worktree.title}" and remove ${s} sibling variant(s)? Their directories and branches go; their chats and changes are archived.`)&&(e==null||e.send({t:"pick-variant",worktreeId:n.worktree.id}))},setProfile(n,o){e==null||e.send({t:"set-worktree-profile",worktreeId:n.worktree.id,profile:o})},remove(n){if(!hv(n.worktree))return;if(!Bv(n))return _a(e,t,[n.worktree.id]);window.confirm(`Remove worktree "${n.worktree.title}"?
98
-
99
- Its directory and branch (${n.worktree.branch}) go. The chat, the commits and any uncommitted changes are archived, and the project menu can restore it.`)&&_a(e,t,[n.worktree.id])}}}function Wv(e,t,n,{sock:o,dispatch:s},a={}){const c=e.worktree.id,u=Hv(o,s),d=[],p=[],m=[],g=[],k=[],w=[];Mc(e)&&d.push({id:"stop",label:"stop agent",onClick:()=>o==null?void 0:o.send({t:"stop-agent",worktreeId:c})});const b=!n.shipping[c];((e.dirty??0)>0||(e.ahead??0)>0||!n.leftOpen)&&p.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{s({a:"activate",id:c}),n.leftOpen||s({a:"toggle-left"})}}),e.worktree.kind!=="spare"&&p.push({id:"terminal",label:"open terminal",onClick:()=>{s({a:"activate",id:c}),n.termOpen||s({a:"toggle-terminal"})}}),p.push({id:"reveal",label:"reveal in Finder",onClick:()=>o==null?void 0:o.send({t:"reveal",worktreeId:c})}),p.push({id:"unread",label:"mark as unread",disabled:e.unseen?"already unread":void 0,onClick:()=>Zv(o,s,c)});const _=[{id:"draft",label:"new worktree from here",onClick:()=>s({a:"open-draft",base:c})}],I=Uv(e.worktree,t);for(const E of zc(t))m.push({id:`profile:${E}`,label:`run with ${E}`,checked:E===I,onClick:()=>u.setProfile(e,E)});if(mv(e.worktree)&&g.push({id:"rename",label:"rename…",onClick:()=>u.rename(e)}),e.worktree.variant&&g.push({id:"keep",label:"keep this variant…",onClick:()=>u.pickVariant(e)}),a.graft&&ec(e.worktree)){const E=a.graft;g.push({id:"graft",label:"graft with…",onClick:()=>E(c)})}const C=b?void 0:"waiting on the one in progress";return $c(e)&&(e.behind??0)>0&&k.push({id:"sync",label:`sync from main (${e.behind} behind)`,disabled:C,onClick:()=>$o(o,s,{t:"sync-main",worktreeId:c})}),Xf(e.worktree)&&k.push({id:"land",label:"land",detail:EO(t),disabled:C,onClick:()=>$o(o,s,{t:"land",worktreeId:c})}),hv(e.worktree)&&w.push({id:"remove",label:Bv(e)?"remove…":"remove",danger:!0,onClick:()=>u.remove(e)}),Hn([d,p,_,m,g,k,w])}function SO(e,t,{sock:n,dispatch:o}){const s=[],a=[{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 $c(e)&&(e.behind??0)>0&&s.push({id:"sync",label:`sync from main (${e.behind} behind)`,onClick:()=>n==null?void 0:n.send({t:"sync-main",worktreeId:e.id})}),s.push({id:"shell",label:"open a shell here",onClick:()=>{o({a:"activate",id:e.id}),t.termOpen||o({a:"toggle-terminal"})}}),s.push({id:"reveal",label:"reveal in Finder",onClick:()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id})}),Hn([a,s,[{id:"copy-path",label:"copy path",onClick:()=>Ln(e.path)}]])}function NO(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(o){const s=hs(t,o);if(s!==t){t=s;for(const a of n)a()}},subscribe(o){return n.add(o),()=>n.delete(o)}}}const Kv=O.createContext(null),Vv=O.createContext(null),Gv=O.createContext(null);function TO({store:e,sock:t,files:n,children:o}){return h.jsx(Kv.Provider,{value:e,children:h.jsx(Vv.Provider,{value:t,children:h.jsx(Gv.Provider,{value:n,children:o})})})}function Xn(){const e=O.useContext(Kv);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function z(e){const t=Xn();return O.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function op(){const e=z(n=>n.systemDark),t=z(n=>{var o;return(o=n.daylight)==null?void 0:o.dark});return{system:e,daylight:t??e}}function st(){return Xn().dispatch}function nt(){return O.useContext(Vv)}function IO(){return O.useContext(Gv)}const ft={active:"toyon-active",repo:"toyon-repo",lastActive:"toyon-last",discoveredOpen:"toyon-disc",archivedOpen:"toyon-arch",token:"toyon-token",theme:"toyon-theme",daylight:"toyon-sun",leftWidth:"toyon-lw",rightWidth:"toyon-rw",editorHeight:"toyon-dh",editorFull:"toyon-dfull",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",panels:"toyon-panels",client:"toyon-client",profilePrefix:"toyon-profile-",modePrefix:"toyon-mode-",modelPrefix:"toyon-model-",effortPrefix:"toyon-effort-"},OO="orch-";function RO(){for(const[e,t]of[[localStorage,["active","token","theme","leftWidth","rightWidth","editorHeight","editorFull"]],[sessionStorage,["client"]]])for(const n of t){const o=ft[n],s=OO+o.slice(6);try{const a=e.getItem(s);a!==null&&(e.getItem(o)===null&&e.setItem(o,a),e.removeItem(s))}catch{}}}function CO(e=!1){const t=O.useRef(null);return O.useEffect(()=>{const n=()=>{const s=t.current;!s||document.activeElement===s||(s.focus(),e&&s instanceof HTMLInputElement&&s.select())};n();const o=requestAnimationFrame(n);return()=>cancelAnimationFrame(o)},[e]),t}function so(e,t,n){const o=()=>{try{return n(localStorage.getItem(e))??t}catch{return t}},[s,a]=O.useState(()=>({key:e,value:o()}));return s.key!==e&&a({key:e,value:o()}),[s.key===e?s.value:o(),d=>{a({key:e,value:d});try{localStorage.setItem(e,typeof d=="boolean"?d?"1":"0":String(d))}catch{}}]}function ma(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const o=n.currentTarget;o.classList.add("active");const s=c=>{const u=e(c,o);u!==null&&t(u)},a=()=>{document.body.classList.remove("resizing"),o.classList.remove("active"),window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",a)};window.addEventListener("pointermove",s),window.addEventListener("pointerup",a)}}function jO(e,t){const[n,o]=O.useState(!1);return O.useEffect(()=>{if(!e){o(!1);return}const s=setTimeout(()=>o(!0),t);return()=>clearTimeout(s)},[e,t]),n}function AO(){const[e,t]=O.useState(window.innerWidth);return O.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}function $O(e){const t=O.useRef(null);return O.useLayoutEffect(()=>{const n=t.current;if(!n)return;t.current=null;const o=n.closest(e);if(!o)return;const s=o.getBoundingClientRect(),a=n.getBoundingClientRect(),c=a.bottom-s.bottom;if(c<=0)return;const u=parseFloat(getComputedStyle(o).paddingTop)||0;o.scrollTop+=Math.min(c,Math.max(0,a.top-s.top-u))}),n=>{t.current=n}}function Bt(e,t){const n=O.useRef(t);n.current=t,O.useEffect(()=>n.current(),e)}const Ra=()=>z(e=>e.activeId),MO=()=>jO(!z(e=>e.connected),900),$i=()=>z(e=>cn(e,e.activeId)),ip=()=>z(e=>Ti(e,e.activeId)),qv=()=>z(e=>e.rows),PO=()=>z(e=>e.visible),LO=()=>z(e=>e.visibleDiscovered),zO=()=>z(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),uk=[],DO=()=>z(e=>e.activeRepoId?e.archived[e.activeRepoId]??uk:uk),FO=()=>z(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),Ca=()=>z(e=>Ai(e,e.activeRepoId)),Yv=e=>z(t=>lo(t,e)),Xt=(e,t)=>z(n=>lo(n,e)[t]),UO=()=>z(e=>e.overlay),Dc=()=>z(hO),Qv=()=>z(Cv),ja=()=>z(jv),Fc=()=>z(wo),BO=()=>z(e=>e.newProject),ZO=()=>z(e=>e.draft),HO=()=>z(Pv),sp=()=>z(bf),WO=()=>z(e=>{const t=Ti(e,e.activeId),n=t?e.repos.find(o=>o.id===t.repoId):null;return $v(n)?n:null}),Nt={post:(e,t)=>{},broadcast:e=>{}};function Ea(e,t,n,o){const s=t===o;Nt.post(e,s?{type:"pick-cancel"}:{type:"pick-start",verb:o}),n({a:"set-picking",v:s?!1:o})}const KO=[{label:"Zed",scheme:"zed"},{label:"VS Code",scheme:"vscode"},{label:"Cursor",scheme:"cursor"}];function Xv(e){return e==="127.0.0.1"||e==="localhost"||e==="[::1]"||e.endsWith(".localhost")}function bs(e,t,n=location.hostname){if(!Xv(n))return[];const o=KO.map(s=>({id:`open:${s.scheme}`,label:`open in ${s.label}`,onClick:()=>{window.location.href=`${s.scheme}://file${e}`}}));return t&&o.push({id:"reveal",label:"reveal in Finder",onClick:t}),o}const VO=["diff","file"];let GO=0;const dc=()=>++GO;function bo({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:dc()}})}function oi(e,t,{discard:n=!1,ref:o,showing:s},a){const{sock:c,dispatch:u}=a,d=VO.filter(g=>g!==s).map(g=>({id:`view:${g}`,label:`view ${g}`,onClick:()=>s?u({a:"editor-view",v:g}):bo(a,{worktreeId:e.id,path:t,view:g,ref:o})})),p=bs(`${e.dir}/${t}`,()=>c==null?void 0:c.send({t:"reveal",worktreeId:e.id,path:t}));return Hn([d,p,n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(`Discard uncommitted changes to ${t}?`)&&(c==null||c.send({t:"discard-file",worktreeId:e.id,path:t}))}}]:[]])}const Jv=(e,t)=>e.dispatch({a:"toast",toast:{ok:!1,message:t}});function Uc(e,t,n){var s;const o=Hx(((s=e.getState().local[t])==null?void 0:s.attachments)??[],n);return o===0&&Jv(e,zf(n)),o}function qO(e){switch(e.kind){case"image":{const{key:t,bytes:n,...o}=e;return o}case"paste":{const{key:t,chars:n,lines:o,preview:s,...a}=e;return a}case"pick":{const{key:t,...n}=e;return n}}}function ap(e,t,n,o={}){if(!t)return;const s=R1(o.source?n.replace(/\r?\n$/,""):n);if(Uc(e,t,"paste")!==0){if(s.length>b1)return Jv(e,"that paste is too large; save it in the worktree and reference it with @path");e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:s,...o,...S1(s)}]})}}function YO(e,t){var a;const n=e.getState(),o=cn(n,n.activeId),s=ep(o,!!n.draft);if(t&&s&&t.worktreeId===(o==null?void 0:o.worktree.id)&&t.text.trim()){const{path:c,startLine:u,endLine:d,ref:p}=t.source;(((a=n.local[s])==null?void 0:a.attachments)??[]).some(g=>{var k;return g.kind==="paste"&&((k=g.source)==null?void 0:k.path)===c&&g.source.startLine===u&&g.source.endLine===d&&g.source.ref===p})||ap(e,s,t.text,{source:t.source})}e.dispatch({a:"focus-right"})}function QO(e,t){const n=e.draft?cn(e,e.draft.base):null,o=cn(e,t);return n&&(t===n.id||!o)?Nv(n.repoId):o?t:null}function XO(e,t){var s;const n=(s=cn(e,t))==null?void 0:s.worktree;if(n)return[n.path,n.linkPath].filter(a=>!!a);const o=e.spares.find(a=>a.id===t);return o?[o.path]:[]}function dk(e,t){if(!e)return e;const n=t.find(o=>e.startsWith(`${o}/`));return n?e.slice(n.length+1):e}function JO(e,t,n){var k;e.dispatch({a:"set-picking",v:!1});const o=e.getState(),s=QO(o,t);if(!s)return;const{classes:a,route:c,element:u,...d}=n,p=XO(o,t),m={...d,file:dk(d.file,p),callFile:dk(d.callFile,p)};!(((k=o.local[s])==null?void 0:k.attachments)??[]).some(w=>w.kind==="pick"&&w.selector===m.selector)&&Uc(e,s,"pick")>0&&e.dispatch({a:"attach",id:s,items:[{kind:"pick",key:crypto.randomUUID(),...m}]}),e.dispatch({a:"focus-right"})}function Bc(e,t,n,o,s){const{leftOpen:a}=e.getState();bo({dispatch:e.dispatch},{worktreeId:n,path:o,view:"file",line:{n:s,fiber:!0}}),a||e.dispatch({a:"toggle-left"})}function eR(){try{const e=localStorage.getItem(ft.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return Oa}function ew(e,t={}){var o;const n=document.documentElement;for(const[s,a]of Object.entries($I(e)))n.style.setProperty(s,a);if(n.style.colorScheme=e.kind,n.dataset.theme=e.kind,(o=document.querySelector('meta[name="theme-color"]'))==null||o.setAttribute("content",e.colors.surface1),t.remember!==!1)try{localStorage.setItem(ft.theme,JSON.stringify(e))}catch{}}function tw(e){const t=e.colors[Yf(e)];return{type:"theme",accent:t,accentFg:BI(t)}}function tR(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const nR=12*36e5;function rR(){try{const e=localStorage.getItem(ft.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<nR?{dark:!t.dark,until:0}:null}catch{return null}}function oR(e){try{localStorage.setItem(ft.daylight,JSON.stringify(e))}catch{}}function iR(e){var o;const t=(o=window.matchMedia)==null?void 0:o.call(window,"(prefers-color-scheme: dark)");if(!t)return()=>{};const n=s=>e(s.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}function ot(...e){return e.filter(Boolean).join(" ")}const sR={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",stop:"M4.5 4.5h7v7h-7z",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",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",diff:"M8 2.8v5 M5.5 5.3h5 M5.5 11.2h5",folder:"M2.2 3.9a1 1 0 0 1 1-1h2.9l1.5 1.7h5.2a1 1 0 0 1 1 1v5.9a1 1 0 0 1-1 1H3.2a1 1 0 0 1-1-1z",book:"M8 4.6c-1.2-1-2.7-1.4-4.4-1.3v7.6c1.7-.1 3.2.3 4.4 1.3 1.2-1 2.7-1.4 4.4-1.3V3.3c-1.7-.1-3.2.3-4.4 1.3z M8 4.6v8.6",trash:"M3.6 4.6h8.8 M6.4 4.6V3.2a.7.7 0 0 1 .7-.7h1.8a.7.7 0 0 1 .7.7v1.4 M5 4.6l.55 8.1a.9.9 0 0 0 .9.84h3.1a.9.9 0 0 0 .9-.84L11 4.6",move:"M2.8 8h9.2 M8.9 4.9 12 8l-3.1 3.1",search:"M7.2 2.6a4.6 4.6 0 1 0 0 9.2 4.6 4.6 0 1 0 0-9.2z M10.5 10.5 13.5 13.5",run:"M3.4 4.2 7.6 8l-4.2 3.8 M9 11.8h4",bulb:"M4.8 8.8a4 4 0 1 1 6.4 0L9.5 10.6v1.4H6.5v-1.4z M6.7 13.8h2.6",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",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",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function Ct({name:e,className:t}){return h.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:h.jsx("path",{d:sR[e]})})}function nw({size:e="inline",className:t}){return h.jsx("span",{className:ot("spinner",e==="dot"&&"spinner-dot",t),"aria-hidden":"true"})}const aR='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function fk(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,aR))??t??null}function lR(e,t){var o,s,a;if(e.box.contains(t)||(o=e.trigger)!=null&&o.contains(t))return!0;const n=(a=(s=t.closest)==null?void 0:s.call(t,"[aria-controls]"))==null?void 0:a.getAttribute("aria-controls");return!!n&&n===e.box.id}function cR(e,t){if(!t)return null;for(let n=e.length-1;n>=0;n--){const o=e[n];if(o!=null&&o.box.contains(t))return o}return null}function uR(e,t){const n=new Set;for(const o of e)if(lR(o,t))for(let s=o;s;s=s.parent)n.add(s);return e.filter(o=>!n.has(o)&&o.dismiss).reverse()}const dR=e=>{setTimeout(e,0)};function fR({schedule:e=dR}={}){let t=[],n=null;const o=s=>{var a;for(const c of[...t].reverse())(a=c.dismiss)==null||a.call(c,s)};return{register(s){const a=s.trigger??n??null,c={box:s.box,trigger:a,parent:cR(t,a),dismiss:s.dismiss,onKey:s.onKey};return t=[...t,c],c},unregister(s){t=t.filter(a=>a!==s)},top:()=>t[t.length-1]??null,open:()=>t,install(s){const a=s.document,c=g=>{var w;const k=g.target;if(k)for(const b of uR(t,k))(w=b.dismiss)==null||w.call(b,"outside");n=fk(g.target)},u=()=>e(()=>n=null),d=g=>{n||(n=fk(g.target),u())},p=g=>{var w;const k=t[t.length-1];(w=k==null?void 0:k.onKey)==null||w.call(k,g)},m=()=>e(()=>{var g;((g=a.activeElement)==null?void 0:g.tagName)==="IFRAME"&&o("frame")});return a.addEventListener("pointerdown",c,!0),a.addEventListener("pointerup",u,!0),a.addEventListener("pointercancel",u,!0),a.addEventListener("click",d,!0),s.addEventListener("keydown",p,!0),s.addEventListener("blur",m),()=>{a.removeEventListener("pointerdown",c,!0),a.removeEventListener("pointerup",u,!0),a.removeEventListener("pointercancel",u,!0),a.removeEventListener("click",d,!0),s.removeEventListener("keydown",p,!0),s.removeEventListener("blur",m)}}}}const Sa=fR(),Dd=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,pk=e=>(e==null?void 0:e.getBoundingClientRect())??null;function pR(e,t,n,o){const s=e.querySelector(t);if(!s)return null;const a=e.getBoundingClientRect(),c=s.getBoundingClientRect();return{offset:n==="top"?a.bottom-c.bottom:c.top-a.top,alignOffset:o==="end"?a.right-c.right:c.left-a.left}}function Aa({className:e,anchor:t,placement:n,coverBy:o,track:s=t==="parent",raiseKey:a,onDismiss:c,onKey:u,trigger:d,boxRef:p,handle:m,children:g,...k}){const w=O.useRef(null),b=O.useRef({anchor:t,placement:n,coverBy:o,onDismiss:c,onKey:u,trigger:d});b.current={anchor:t,placement:n,coverBy:o,onDismiss:c,onKey:u,trigger:d};const _=O.useCallback(()=>{const C=w.current,{anchor:E,placement:Z,coverBy:M}=b.current;if(!C||!E||!Z)return;const $=E==="parent"?pk(C.parentElement):E();if(!$)return;const D=nO($,Z);D!==void 0&&(C.style.width=`${D}px`);for(let q=0;q<2;q++){const J=M?pR(C,M,C.dataset.side??"",C.dataset.align??""):null,se=oO($,{w:C.offsetWidth,h:C.offsetHeight},{w:window.innerWidth,h:window.innerHeight},J?{...Z,...J}:Z);C.style.left=`${se.x}px`,C.style.top=`${se.y}px`;const me=C.dataset.side!==se.side||C.dataset.align!==se.align;if(C.dataset.side=se.side,C.dataset.align=se.align,!me)break}},[]);O.useImperativeHandle(m,()=>({update:_}),[_]),O.useLayoutEffect(()=>{const C=w.current;if(!C)return;p&&(p.current=C),Dd&&(C.popover="manual",C.matches(":popover-open")||C.showPopover());const{onDismiss:E,onKey:Z,trigger:M}=b.current,$=E||Z?Sa.register({box:C,trigger:M,dismiss:E?D=>{var q,J;return(J=(q=b.current).onDismiss)==null?void 0:J.call(q,D)}:void 0,onKey:Z?D=>{var q,J;return(J=(q=b.current).onKey)==null?void 0:J.call(q,D)}:void 0}):null;return()=>{$&&Sa.unregister($),p&&(p.current=null),Dd&&C.isConnected&&C.matches(":popover-open")&&C.hidePopover()}},[p]),O.useLayoutEffect(_),O.useLayoutEffect(()=>{if(!s)return;let C=0,E="";const Z=()=>{const M=w.current,{anchor:$}=b.current,D=M&&$?$==="parent"?pk(M.parentElement):$():null;if(M&&D){const q=`${D.left},${D.top},${D.right},${D.bottom},${M.offsetWidth},${M.offsetHeight},${window.innerWidth},${window.innerHeight}`;q!==E&&(E=q,_())}C=requestAnimationFrame(Z)};return C=requestAnimationFrame(Z),()=>cancelAnimationFrame(C)},[s,_]);const I=O.useRef(!0);return Bt([a],()=>{if(I.current){I.current=!1;return}const C=w.current;!Dd||!(C!=null&&C.matches(":popover-open"))||(C.hidePopover(),C.showPopover(),_())}),h.jsx("div",{ref:w,className:ot("float",e),...k,children:g})}function hR(e,{onDismiss:t,onKey:n,trigger:o}={}){const s=O.useRef({onDismiss:t,onKey:n,trigger:o});s.current={onDismiss:t,onKey:n,trigger:o},O.useLayoutEffect(()=>{const a=e.current;if(!a)return;const{onDismiss:c,onKey:u,trigger:d}=s.current,p=Sa.register({box:a,trigger:d,dismiss:c?m=>{var g,k;return(k=(g=s.current).onDismiss)==null?void 0:k.call(g,m)}:void 0,onKey:u?m=>{var g,k;return(k=(g=s.current).onKey)==null?void 0:k.call(g,m)}:void 0});return()=>Sa.unregister(p)},[e])}const mR=/^[⌘⇧⌥⌃]+/;function Or({k:e,chip:t=!1,className:n}){var c;const o=(c=e.match(mR))==null?void 0:c[0],s=o?e.slice(o.length):e,a=["kbd",t?"kbd-chip":"",n??""].filter(Boolean).join(" ");return h.jsxs("kbd",{className:a,children:[o&&h.jsx("span",{className:"kbd-mod",children:o}),s]})}function St(e,t,{placement:n,detail:o,dot:s,lead:a,also:c}={}){const u=a?`${a} ${e}`:e,d=o?`${u}, ${o}`:u;return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":o,"data-tip-dot":s,"data-tip-lead":a,"data-tip-also":c==null?void 0:c.text,"data-tip-also-key":c==null?void 0:c.key,"aria-label":t?`${d} (${t})`:d}}const gR=120,kR=600,yR=150,vR=6,wR=18,hk=8;function mk(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function bR(e){return e==="follow"?{side:"bottom",align:"start",offset:wR,alignOffset:-12,flip:"both",margin:hk}:{side:e,align:"center",offset:vR,flip:"side",margin:hk}}function xR(e,t){return e.placement==="follow"?wv(t):e.el.getBoundingClientRect()}function _R(){const[e,t]=O.useState(null),n=O.useRef(null),o=O.useRef(null),s=O.useRef({x:0,y:0});if(O.useEffect(()=>{let u=0,d=0,p=null,m=!1,g=0;const k=()=>{window.clearTimeout(u),window.clearTimeout(d)},w=()=>{k(),m&&(g=Date.now()),m=!1,p=null,t(null)},b=($,D)=>{const q=$.dataset.tip;if(!q)return w();k(),m=!0,t({el:$,text:q,key:$.dataset.tipKey,detail:$.dataset.tipDetail,dot:$.dataset.tipDot,lead:$.dataset.tipLead,also:$.dataset.tipAlso&&$.dataset.tipAlsoKey?{text:$.dataset.tipAlso,key:$.dataset.tipAlsoKey}:void 0,placement:D})},_=$=>{const D=$.target;return D instanceof Element?D.closest("[data-tip]"):null},I=$=>{s.current={x:$.clientX,y:$.clientY};const D=_($);if(D===p)return;if(k(),p=D,!D){m&&(d=window.setTimeout(w,yR));return}const q=mk(D);if(m||Date.now()-g<kR)return b(D,q);u=window.setTimeout(()=>b(D,q),gR)},C=$=>{$.relatedTarget||w()},E=$=>{const D=_($);if(D!=null&&D.matches(":focus-visible")){k(),p=D;const q=mk(D);b(D,q==="follow"?"bottom":q)}},Z=()=>w(),M=$=>{$.key!=="Shift"&&$.key!=="Control"&&$.key!=="Alt"&&$.key!=="Meta"&&w()};return document.addEventListener("mouseover",I),document.addEventListener("mouseout",C),document.addEventListener("mousedown",w),document.addEventListener("keydown",M),document.addEventListener("scroll",w,!0),document.addEventListener("focusin",E),document.addEventListener("focusout",Z),window.addEventListener("blur",w),()=>{k(),document.removeEventListener("mouseover",I),document.removeEventListener("mouseout",C),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",M),document.removeEventListener("scroll",w,!0),document.removeEventListener("focusin",E),document.removeEventListener("focusout",Z),window.removeEventListener("blur",w)}},[]),O.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),O.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const u=d=>{var p;s.current={x:d.clientX,y:d.clientY},(p=o.current)==null||p.update()};return document.addEventListener("mousemove",u),()=>document.removeEventListener("mousemove",u)},[e]),!e)return null;const a=h.jsxs(h.Fragment,{children:[e.dot&&h.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}),c=h.jsxs(h.Fragment,{children:[a,e.key&&h.jsx(Or,{k:e.key,className:"tooltip-key"})]});return h.jsxs(Aa,{className:"tooltip",role:"tooltip",boxRef:n,handle:o,anchor:()=>xR(e,s.current),placement:bR(e.placement),track:!1,raiseKey:e,children:[e.also?h.jsxs("div",{className:"tooltip-pair",children:[h.jsx("span",{children:a}),e.key?h.jsx(Or,{k:e.key,className:"tooltip-key"}):h.jsx("span",{}),h.jsx("span",{className:"tooltip-also",children:e.also.text}),h.jsx(Or,{k:e.also.key,className:"tooltip-key"})]}):e.lead?h.jsxs("div",{className:"tooltip-line",children:[h.jsx("span",{className:"tooltip-lead",children:e.lead}),h.jsx("span",{children:c})]}):c,e.detail&&h.jsx("div",{className:"tooltip-detail",children:e.detail})]})}const ER={sm:"",md:"btn-md",lg:"btn-lg"},SR={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},rw={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function De({variant:e="ghost",size:t="sm",tone:n,on:o,mono:s,busy:a,className:c,type:u="button",disabled:d,children:p,...m}){const g=ot("btn",SR[e],ER[t],n&&rw[n],o&&"on",s&&"btn-mono",a&&"btn-busy",c);return h.jsxs("button",{className:g,type:u,disabled:a||d,"aria-busy":a||void 0,...m,children:[a&&h.jsx(nw,{}),p]})}function Kt({icon:e,label:t,hint:n,detail:o,also:s,badge:a,tone:c,on:u,className:d,type:p="button",...m}){const g=ot("btn-icon",c&&rw[c],u&&"on",d);return h.jsxs("button",{className:g,type:p,...St(t,n,{detail:o,also:s}),...m,children:[typeof e=="string"?h.jsx(Ct,{name:e}):e,a]})}let _f=!1;function NR(){_f=!0}function lp({title:e,body:t,action:n,pane:o}){return h.jsxs("div",{className:ot("crash",o&&"in-pane"),children:[h.jsx("div",{className:"crash-title",children:e}),t&&h.jsx("div",{className:"crash-body",children:t}),n]})}const fc={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class cp extends O.Component{constructor(){super(...arguments);dt(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,o){console.error("[toyon] render error",n,o.componentStack)}render(){const{error:n}=this.state;return n?h.jsx(lp,{pane:this.props.pane,title:_f?fc.title:"Toyon hit an error",body:_f?fc.body:n.message||String(n),action:h.jsx(De,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}function up(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1]){try{localStorage.setItem(ft.token,e[1])}catch{}return e[1]}try{return localStorage.getItem(ft.token)??sessionStorage.getItem(ft.token)??""}catch{return""}}function TR(){return up()!==""}function gk(e,t){return`/attachments/${e}/${t}?token=${up()}`}const IR=1e3,OR=3e4,kk=50;class RR{constructor(t,n){dt(this,"ws",null);dt(this,"queue",[]);dt(this,"closed",!1);dt(this,"attempt",0);dt(this,"timer",null);this.onMsg=t,this.onStatus=n,this.connect()}async diagnose(t){if(t===r1)return"unauthorized";try{return(await fetch("/health",{signal:AbortSignal.timeout(2e3)})).ok?"blocked":"down"}catch{return"down"}}connect(){if(this.closed)return;const n=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws?token=${up()}`,o=new WebSocket(n);this.ws=o;let s=!1;o.onmessage=a=>{if(!s){s=!0,this.attempt=0,this.onStatus(!0);for(const c of this.queue)o.send(c.raw);this.queue=[]}try{this.onMsg(JSON.parse(a.data))}catch{}},o.onclose=a=>{if(this.onStatus(!1),this.closed)return;this.diagnose(a.code).then(u=>{this.ws===o&&!this.closed&&this.onStatus(!1,u)});const c=Math.min(OR,IR*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),c/2+Math.random()*(c/2))},o.onerror=()=>o.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 o=t.t==="subscribe"||t.t==="unsubscribe"?`sub:${t.worktreeId}`:null;o&&(this.queue=this.queue.filter(s=>s.key!==o)),this.queue.push({key:o,raw:n}),this.queue.length>kk&&this.queue.splice(0,this.queue.length-kk)}dispose(){var t;this.closed=!0,this.timer&&clearTimeout(this.timer),(t=this.ws)==null||t.close()}}function Mi({anchor:e="top",wide:t,children:n}){return h.jsx("div",{className:ot("view",e==="line"&&"view-line",t&&"view-wide"),children:n})}/*! @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 yk(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function CR(e){if(Array.isArray(e))return e}function jR(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var o,s,a,c,u=[],d=!0,p=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(d=(o=a.call(n)).done)&&(u.push(o.value),u.length!==t);d=!0);}catch(m){p=!0,s=m}finally{try{if(!d&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(p)throw s}}return u}}function AR(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
100
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $R(e,t){return CR(e)||jR(e,t)||MR(e,t)||AR()}function MR(e,t){if(e){if(typeof e=="string")return yk(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)?yk(e,t):void 0}}const ow=Object.entries,vk=Object.setPrototypeOf,PR=Object.isFrozen,LR=Object.getPrototypeOf,zR=Object.getOwnPropertyDescriptor;let In=Object.freeze,zn=Object.seal,ls=Object.create,iw=typeof Reflect<"u"&&Reflect,Ef=iw.apply,Sf=iw.construct;In||(In=function(t){return t});zn||(zn=function(t){return t});Ef||(Ef=function(t,n){for(var o=arguments.length,s=new Array(o>2?o-2:0),a=2;a<o;a++)s[a-2]=arguments[a];return t.apply(n,s)});Sf||(Sf=function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return new t(...o)});const _i=yn(Array.prototype.forEach),DR=yn(Array.prototype.lastIndexOf),wk=yn(Array.prototype.pop),ea=yn(Array.prototype.push),FR=yn(Array.prototype.splice),ms=Array.isArray,ca=yn(String.prototype.toLowerCase),Fd=yn(String.prototype.toString),bk=yn(String.prototype.match),ta=yn(String.prototype.replace),xk=yn(String.prototype.indexOf),UR=yn(String.prototype.trim),BR=yn(Number.prototype.toString),ZR=yn(Boolean.prototype.toString),_k=typeof BigInt>"u"?null:yn(BigInt.prototype.toString),Ek=typeof Symbol>"u"?null:yn(Symbol.prototype.toString),kr=yn(Object.prototype.hasOwnProperty),na=yn(Object.prototype.toString),Yn=yn(RegExp.prototype.test),xi=HR(TypeError);function yn(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return Ef(e,t,o)}}function HR(e){return function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return Sf(e,n)}}function xt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ca;if(vk&&vk(e,null),!ms(t))return e;let o=t.length;for(;o--;){let s=t[o];if(typeof s=="string"){const a=n(s);a!==s&&(PR(t)||(t[o]=a),s=a)}e[s]=!0}return e}function WR(e){for(let t=0;t<e.length;t++)kr(e,t)||(e[t]=null);return e}function Ir(e){const t=ls(null);for(const o of ow(e)){var n=$R(o,2);const s=n[0],a=n[1];kr(e,s)&&(ms(a)?t[s]=WR(a):a&&typeof a=="object"&&a.constructor===Object?t[s]=Ir(a):t[s]=a)}return t}function KR(e){switch(typeof e){case"string":return e;case"number":return BR(e);case"boolean":return ZR(e);case"bigint":return _k?_k(e):"0";case"symbol":return Ek?Ek(e):"Symbol()";case"undefined":return na(e);case"function":case"object":{if(e===null)return na(e);const t=e,n=ro(t,"toString");if(typeof n=="function"){const o=n(t);return typeof o=="string"?o:na(o)}return na(e)}default:return na(e)}}function ro(e,t){for(;e!==null;){const o=zR(e,t);if(o){if(o.get)return yn(o.get);if(typeof o.value=="function")return yn(o.value)}e=LR(e)}function n(){return null}return n}function VR(e){try{return Yn(e,""),!0}catch{return!1}}const Sk=In(["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"]),Ud=In(["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"]),Bd=In(["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"]),GR=In(["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"]),Zd=In(["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"]),qR=In(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Nk=In(["#text"]),Tk=In(["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"]),Hd=In(["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"]),Ik=In(["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"]),Gl=In(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),YR=zn(/{{[\w\W]*|^[\w\W]*}}/g),QR=zn(/<%[\w\W]*|^[\w\W]*%>/g),XR=zn(/\${[\w\W]*/g),JR=zn(/^data-[\-\w.\u00B7-\uFFFF]+$/),eC=zn(/^aria-[\-\w]+$/),Ok=zn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),tC=zn(/^(?:\w+script|data):/i),nC=zn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),rC=zn(/^html$/i),oC=zn(/^[a-z][.\w]*(-[.\w]+)+$/i),Rk=zn(/<[/\w!]/g),Ck=zn(/<[/\w]/g),iC=zn(/<\/no(script|embed|frames)/i),sC=zn(/\/>/i),Tr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},sw=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],aC=In(xt({},sw)),lC=(function(){const e={};return _i(sw,t=>{e[t]=zn(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),In(e)})(),cC=function(){return typeof window>"u"?null:window},uC=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(o=n.getAttribute(s));const a="dompurify"+(o?"#"+o:"");try{return t.createPolicy(a,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},jk=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},ti=function(t,n,o,s){return kr(t,n)&&ms(t[n])?xt(s.base?Ir(s.base):{},t[n],s.transform):o},Wd=function(t,n,o){const s=kr(t,n)?t[n]:void 0;return s&&typeof s=="object"?Ir(s):o()};function aw(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:cC();const t=fe=>aw(fe);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==Tr.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const o=n,s=o.currentScript;e.DocumentFragment;const a=e.HTMLTemplateElement,c=e.Node,u=e.Element,d=e.NodeFilter,p=e.NamedNodeMap;p===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const m=e.DOMParser,g=e.trustedTypes,k=u.prototype,w=ro(k,"cloneNode"),b=ro(k,"remove"),_=ro(k,"nextSibling"),I=ro(k,"childNodes"),C=ro(k,"parentNode"),E=ro(k,"shadowRoot"),Z=ro(k,"attributes"),M=c&&c.prototype?ro(c.prototype,"nodeType"):null,$=c&&c.prototype?ro(c.prototype,"nodeName"):null,D=c&&c.prototype?ro(c.prototype,"ownerDocument"):null,q=function(S){return M?M(S):S.nodeType},J=function(S){return $?$(S):S.nodeName};if(typeof a=="function"){const fe=n.createElement("template");fe.content&&fe.content.ownerDocument&&(n=fe.content.ownerDocument)}let se,me="",Oe,ae=!1,ie=0;const Y=function(){if(ie>0)throw xi('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},de=function(S){Y(),ie++;try{return se.createHTML(S)}finally{ie--}},ge=function(S){Y(),ie++;try{return se.createScriptURL(S)}finally{ie--}},Ee=function(){return ae||(Oe=uC(g,s),ae=!0),Oe},X=n,ce=X.implementation,ee=X.createNodeIterator,j=X.createDocumentFragment,Q=X.getElementsByTagName,Ie=o.importNode;let xe=jk();t.isSupported=typeof ow=="function"&&typeof C=="function"&&ce&&ce.createHTMLDocument!==void 0;const V=YR,be=QR,Ae=XR,Pe=JR,B=eC,F=tC,Te=nC,lt=oC;let Pt=Ok,Ye=null;const Ge=xt({},[...Sk,...Ud,...Bd,...Zd,...Nk]);let Ue=null;const At=xt({},[...Tk,...Hd,...Ik,...Gl]);let Tt=Object.seal(ls(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}})),ut=null,Vt=null;const K=Object.seal(ls(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let _e=!0,pt=!0,It=!1,vn=!0,vt=!1,Gt=!0,te=!1,Be=!1,mt=null,it=null,rt=!1,Rn=!1,Xe=!1,wn=!1,Lt=!0,xr=!1;const hn="user-content-";let Dn=!0,Zt=!1,Fn={},bn=null;const Jn=xt({},["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 R=null;const ne=xt({},["audio","video","img","source","image","track"]);let ve=null;const He=xt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),gt="http://www.w3.org/1998/Math/MathML",wt="http://www.w3.org/2000/svg",Se="http://www.w3.org/1999/xhtml";let Ne=Se,we=!1,Rt=null;const Ot=xt({},[gt,wt,Se],Fd),xn=In(["mi","mo","mn","ms","mtext"]);let er=xt({},xn);const Cn=In(["annotation-xml"]);let Wn=xt({},Cn);const Cr=xt({},["title","style","font","a","script"]);let jr=null;const lr=["application/xhtml+xml","text/html"],uo="text/html";let kt=null,tr=null;const Lo=n.createElement("form"),Kr=function(S){return S instanceof RegExp||S instanceof Function},Ar=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(tr&&tr===S)return;(!S||typeof S!="object")&&(S={}),S=Ir(S),jr=lr.indexOf(S.PARSER_MEDIA_TYPE)===-1?uo:S.PARSER_MEDIA_TYPE,kt=jr==="application/xhtml+xml"?Fd:ca,Ye=ti(S,"ALLOWED_TAGS",Ge,{transform:kt}),Ue=ti(S,"ALLOWED_ATTR",At,{transform:kt}),Rt=ti(S,"ALLOWED_NAMESPACES",Ot,{transform:Fd}),ve=ti(S,"ADD_URI_SAFE_ATTR",He,{transform:kt,base:He}),R=ti(S,"ADD_DATA_URI_TAGS",ne,{transform:kt,base:ne}),bn=ti(S,"FORBID_CONTENTS",Jn,{transform:kt}),ut=ti(S,"FORBID_TAGS",Ir({}),{transform:kt}),Vt=ti(S,"FORBID_ATTR",Ir({}),{transform:kt}),Fn=kr(S,"USE_PROFILES")?S.USE_PROFILES&&typeof S.USE_PROFILES=="object"?Ir(S.USE_PROFILES):S.USE_PROFILES:!1,_e=S.ALLOW_ARIA_ATTR!==!1,pt=S.ALLOW_DATA_ATTR!==!1,It=S.ALLOW_UNKNOWN_PROTOCOLS||!1,vn=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,vt=S.SAFE_FOR_TEMPLATES||!1,Gt=S.SAFE_FOR_XML!==!1,te=S.WHOLE_DOCUMENT||!1,Rn=S.RETURN_DOM||!1,Xe=S.RETURN_DOM_FRAGMENT||!1,wn=S.RETURN_TRUSTED_TYPE||!1,rt=S.FORCE_BODY||!1,Lt=S.SANITIZE_DOM!==!1,xr=S.SANITIZE_NAMED_PROPS||!1,Dn=S.KEEP_CONTENT!==!1,Zt=S.IN_PLACE||!1,Pt=VR(S.ALLOWED_URI_REGEXP)?S.ALLOWED_URI_REGEXP:Ok,Ne=typeof S.NAMESPACE=="string"?S.NAMESPACE:Se,er=Wd(S,"MATHML_TEXT_INTEGRATION_POINTS",()=>xt({},xn)),Wn=Wd(S,"HTML_INTEGRATION_POINTS",()=>xt({},Cn));const N=Wd(S,"CUSTOM_ELEMENT_HANDLING",()=>ls(null));if(Tt=ls(null),kr(N,"tagNameCheck")&&Kr(N.tagNameCheck)&&(Tt.tagNameCheck=N.tagNameCheck),kr(N,"attributeNameCheck")&&Kr(N.attributeNameCheck)&&(Tt.attributeNameCheck=N.attributeNameCheck),kr(N,"allowCustomizedBuiltInElements")&&typeof N.allowCustomizedBuiltInElements=="boolean"&&(Tt.allowCustomizedBuiltInElements=N.allowCustomizedBuiltInElements),zn(Tt),vt&&(pt=!1),Xe&&(Rn=!0),Fn&&(Ye=xt({},Nk),Ue=ls(null),Fn.html===!0&&(xt(Ye,Sk),xt(Ue,Tk)),Fn.svg===!0&&(xt(Ye,Ud),xt(Ue,Hd),xt(Ue,Gl)),Fn.svgFilters===!0&&(xt(Ye,Bd),xt(Ue,Hd),xt(Ue,Gl)),Fn.mathMl===!0&&(xt(Ye,Zd),xt(Ue,Ik),xt(Ue,Gl))),K.tagCheck=null,K.attributeCheck=null,kr(S,"ADD_TAGS")&&(typeof S.ADD_TAGS=="function"?K.tagCheck=S.ADD_TAGS:ms(S.ADD_TAGS)&&(Ye===Ge&&(Ye=Ir(Ye)),xt(Ye,S.ADD_TAGS,kt))),kr(S,"ADD_ATTR")&&(typeof S.ADD_ATTR=="function"?K.attributeCheck=S.ADD_ATTR:ms(S.ADD_ATTR)&&(Ue===At&&(Ue=Ir(Ue)),xt(Ue,S.ADD_ATTR,kt))),kr(S,"ADD_FORBID_CONTENTS")&&ms(S.ADD_FORBID_CONTENTS)&&(bn===Jn&&(bn=Ir(bn)),xt(bn,S.ADD_FORBID_CONTENTS,kt)),Dn&&(Ye["#text"]=!0),te&&xt(Ye,["html","head","body"]),Ye.table&&(xt(Ye,["tbody"]),delete ut.tbody),S.TRUSTED_TYPES_POLICY){if(typeof S.TRUSTED_TYPES_POLICY.createHTML!="function")throw xi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof S.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw xi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const U=se;se=S.TRUSTED_TYPES_POLICY;try{me=de("")}catch(oe){throw se=U,oe}}else S.TRUSTED_TYPES_POLICY===null?(se=void 0,me=""):(se===void 0&&(se=Ee()),se&&typeof me=="string"&&(me=de("")));In&&In(S),tr=S},_n=xt({},[...Ud,...Bd,...GR]),fo=xt({},[...Zd,...qR]),mn=function(S,N,U){return N.namespaceURI===Se?S==="svg":N.namespaceURI===gt?S==="svg"&&(U==="annotation-xml"||er[U]):!!_n[S]},$t=function(S,N,U){return N.namespaceURI===Se?S==="math":N.namespaceURI===wt?S==="math"&&Wn[U]:!!fo[S]},zo=function(S,N,U){return N.namespaceURI===wt&&!Wn[U]||N.namespaceURI===gt&&!er[U]?!1:!fo[S]&&(Cr[S]||!_n[S])},$r=function(S){let N=C(S);(!N||!N.tagName)&&(N={namespaceURI:Ne,tagName:"template"});const U=ca(S.tagName),oe=ca(N.tagName);return Rt[S.namespaceURI]?S.namespaceURI===wt?mn(U,N,oe):S.namespaceURI===gt?$t(U,N,oe):S.namespaceURI===Se?zo(U,N,oe):!!(jr==="application/xhtml+xml"&&Rt[S.namespaceURI]):!1},En=function(S){ea(t.removed,{element:S});try{C(S).removeChild(S)}catch{if(b(S),!C(S))throw xi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Vr=function(S,N,U){try{S.removeAttributeNode(N)}catch{try{S.removeAttribute(U)}catch{}}},pe=function(S){Qe(S);const N=I(S);if(N){const oe=[];_i(N,ke=>{ea(oe,ke)}),_i(oe,ke=>{try{b(ke)}catch{}})}const U=Z(S);if(U)for(let oe=U.length-1;oe>=0;--oe){const ke=U[oe],Ce=ke&&ke.name;typeof Ce=="string"&&Vr(S,ke,Ce)}},Re=function(S,N,U){if(!U)try{U=N.getAttributeNode(S)}catch{U=null}ea(t.removed,{attribute:U||null,from:N});try{U?N.removeAttributeNode(U):N.removeAttribute(S)}catch{try{N.removeAttribute(S)}catch{}}if(S==="is")if(Rn||Xe)try{En(N)}catch{}else try{N.setAttribute(S,"")}catch{}},et=function(S){const N=Z(S);if(N)for(let U=N.length-1;U>=0;--U){const oe=N[U],ke=oe&&oe.name;typeof ke!="string"||Ue[kt(ke)]||Vr(S,oe,ke)}},Qe=function(S){const N=[S];for(;N.length>0;){const U=N.pop();q(U)===Tr.element&&et(U);const ke=I(U);if(ke)for(let Ce=ke.length-1;Ce>=0;--Ce)N.push(ke[Ce])}},zt=function(S,N){return Gt?S==="patchsrc"?!0:S==="for"&&N!=="label"&&N!=="output":!1},Dt=function(S){if(!Gt)return;const N=[S];for(;N.length>0;){const U=N.pop(),oe=q(U);if(oe===Tr.processingInstruction||oe===Tr.comment&&Yn(Ck,U.data)){try{b(U)}catch{}continue}if(oe===Tr.element){const Ce=U,Je=kt(J(U));try{Ce.hasAttribute&&Ce.hasAttribute("patchsrc")&&Ce.removeAttribute("patchsrc"),Ce.hasAttribute&&Ce.hasAttribute("for")&&zt("for",Je)&&Ce.removeAttribute("for")}catch{}}const ke=I(U);if(ke)for(let Ce=ke.length-1;Ce>=0;--Ce)N.push(ke[Ce])}},nr=function(S){let N=null,U=null;if(rt)S="<remove></remove>"+S;else{const Ce=bk(S,/^[\r\n\t ]+/);U=Ce&&Ce[0]}jr==="application/xhtml+xml"&&Ne===Se&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const oe=se?de(S):S;if(Ne===Se)try{N=new m().parseFromString(oe,jr)}catch{}if(!N||!N.documentElement){N=ce.createDocument(Ne,"template",null);try{N.documentElement.innerHTML=we?me:oe}catch{}}const ke=N.body||N.documentElement;return S&&U&&ke.insertBefore(n.createTextNode(U),ke.childNodes[0]||null),Ne===Se?Q.call(N,te?"html":"body")[0]:te?N.documentElement:ke},Mr=function(S){const N=D?D(S):S.ownerDocument;return ee.call(N||S,S,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},rn=function(S){return S=ta(S,V," "),S=ta(S,be," "),S=ta(S,Ae," "),S},L=function(S){var N;S.normalize();const U=D?D(S):S.ownerDocument,oe=ee.call(U||S,S,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let ke=oe.nextNode();for(;ke;)ke.data=rn(ke.data),ke=oe.nextNode();const Ce=(N=S.querySelectorAll)===null||N===void 0?void 0:N.call(S,"template");Ce&&_i(Ce,Je=>{tt(Je.content)&&L(Je.content)})},Ze=function(S){const N=$?$(S):null;return typeof N!="string"||kt(N)!=="form"?!1:typeof S.nodeName!="string"||typeof S.textContent!="string"||typeof S.removeChild!="function"||S.attributes!==Z(S)||typeof S.removeAttribute!="function"||typeof S.setAttribute!="function"||typeof S.namespaceURI!="string"||typeof S.insertBefore!="function"||typeof S.hasChildNodes!="function"||S.nodeType!==M(S)||S.childNodes!==I(S)},tt=function(S){if(!M||typeof S!="object"||S===null)return!1;try{return M(S)===Tr.documentFragment}catch{return!1}},Ft=function(S){if(!M||typeof S!="object"||S===null)return!1;try{return typeof M(S)=="number"}catch{return!1}};function on(fe,S,N){fe.length!==0&&_i(fe,U=>{U.call(t,S,N,tr)})}const xo=function(S,N){return!!(Gt&&S.hasChildNodes()&&!Ft(S.firstElementChild)&&Yn(Rk,S.textContent)&&Yn(Rk,S.innerHTML)||Gt&&S.namespaceURI===Se&&aC[N]&&(Ft(S.firstElementChild)||typeof S.textContent=="string"&&Yn(lC[N],S.textContent))||S.nodeType===Tr.processingInstruction||Gt&&S.nodeType===Tr.comment&&Yn(Ck,S.data))},po=function(S,N){if(S instanceof RegExp)return Yn(S,N);if(S instanceof Function){for(var U=arguments.length,oe=new Array(U>2?U-2:0),ke=2;ke<U;ke++)oe[ke-2]=arguments[ke];return!!S(N,...oe)}return!1},Li=function(S,N,U){if(!ut[N]&&Ve(N)&&po(Tt.tagNameCheck,N))return!1;if(Dn&&!bn[N]){const oe=C(S),ke=I(S);if(ke&&oe){const Ce=ke.length;for(let Je=Ce-1;Je>=0;--Je){const Ut=S===U?w(ke[Je],!0):ke[Je];oe.insertBefore(Ut,_(S))}}}return En(S),!0},Gr=function(S,N,U,oe){return S.length===0?N:N===U||N===oe?Ir(N):N},qr=function(S,N){return S===N||C(S)!==null?!1:(Zt&&Qe(S),!0)},rr=function(S,N){if(on(xe.beforeSanitizeElements,S,null),qr(S,N))return!0;if(Ze(S))return En(S),!0;const U=kt(J(S));if(Ye=Gr(xe.uponSanitizeElement,Ye,Ge,mt),on(xe.uponSanitizeElement,S,{tagName:U,allowedTags:Ye}),qr(S,N))return!0;if(xo(S,U))return En(S),!0;if(ut[U]||!(K.tagCheck instanceof Function&&K.tagCheck(U))&&!Ye[U]){const ke=Li(S,U,N);return ke===!1&&on(xe.afterSanitizeElements,S,null),ke}if(q(S)===Tr.element&&!$r(S)||(U==="noscript"||U==="noembed"||U==="noframes")&&Yn(iC,S.innerHTML))return En(S),!0;if(vt&&S.nodeType===Tr.text){const ke=rn(S.textContent);S.textContent!==ke&&(ea(t.removed,{element:S.cloneNode()}),S.textContent=ke)}return on(xe.afterSanitizeElements,S,null),!1},Do=function(S,N,U){if(Vt[N]||zt(N,S)||Lt&&(N==="id"||N==="name")&&(U in n||U in Lo))return!1;const oe=Ue[N]||K.attributeCheck instanceof Function&&K.attributeCheck(N,S);return pt&&Yn(Pe,N)||_e&&Yn(B,N)?!0:oe?ve[N]||Yn(Pt,ta(U,Te,""))||(N==="src"||N==="xlink:href"||N==="href")&&S!=="script"&&xk(U,"data:")===0&&R[S]||It&&!Yn(F,ta(U,Te,""))?!0:!U:Ve(S)&&po(Tt.tagNameCheck,S)&&po(Tt.attributeNameCheck,N,S)||N==="is"&&Tt.allowCustomizedBuiltInElements&&po(Tt.tagNameCheck,U)},ht=xt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ve=function(S){return!ht[ca(S)]&&Yn(lt,S)},ci=function(S,N,U,oe){if(se&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!U)switch(g.getAttributeType(S,N)){case"TrustedHTML":return de(oe);case"TrustedScriptURL":return ge(oe)}return oe},sn=function(S,N,U,oe){try{U?S.setAttributeNS(U,N,oe):S.setAttribute(N,oe),Ze(S)?En(S):wk(t.removed)}catch{Re(N,S)}},_t=function(S){on(xe.beforeSanitizeAttributes,S,null);const N=S.attributes;if(!N||Ze(S))return;Ue=Gr(xe.uponSanitizeAttribute,Ue,At,it);const U={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ue,forceKeepAttr:void 0};let oe=N.length;const ke=kt(S.nodeName);for(;oe--;){const Ce=N[oe],Je=Ce.name,Ut=Ce.namespaceURI,Sn=Ce.value,gn=kt(Je),_s=Sn;let jn=Je==="value"?_s:UR(_s);if(U.attrName=gn,U.attrValue=jn,U.keepAttr=!0,U.forceKeepAttr=void 0,on(xe.uponSanitizeAttribute,S,U),jn=U.attrValue,xr&&(gn==="id"||gn==="name")&&xk(jn,hn)!==0&&(Re(Je,S,Ce),jn=hn+jn),Gt&&Yn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,jn)){Re(Je,S,Ce);continue}if(gn==="attributename"&&bk(jn,"href")){Re(Je,S,Ce);continue}if(!U.forceKeepAttr){if(!U.keepAttr){Re(Je,S,Ce);continue}if(!vn&&Yn(sC,jn)){Re(Je,S,Ce);continue}if(vt&&(jn=rn(jn)),!Do(ke,gn,jn)){Re(Je,S,Ce);continue}jn=ci(ke,gn,Ut,jn),jn!==_s&&sn(S,Je,Ut,jn)}}on(xe.afterSanitizeAttributes,S,null)},Pr=function(S){let N=null;const U=Mr(S);for(on(xe.beforeSanitizeShadowDOM,S,null);N=U.nextNode();)if(on(xe.uponSanitizeShadowNode,N,null),rr(N,S),_t(N),tt(N.content)&&Pr(N.content),q(N)===Tr.element){const oe=E(N);tt(oe)&&(cr(oe),Pr(oe))}on(xe.afterSanitizeShadowDOM,S,null)},cr=function(S){const N=[{node:S,shadow:null}];for(;N.length>0;){const U=N.pop();if(U.shadow){Pr(U.shadow);continue}const oe=U.node,Ce=q(oe)===Tr.element,Je=I(oe);if(Je)for(let Ut=Je.length-1;Ut>=0;--Ut)N.push({node:Je[Ut],shadow:null});if(Ce){const Ut=$?$(oe):null;if(typeof Ut=="string"&&kt(Ut)==="template"){const Sn=oe.content;tt(Sn)&&N.push({node:Sn,shadow:null})}}if(Ce){const Ut=E(oe);tt(Ut)&&N.push({node:null,shadow:Ut},{node:Ut,shadow:null})}}};return t.sanitize=function(fe){let S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=null,U=null,oe=null,ke=null;if(we=!fe,we&&(fe="<!-->"),typeof fe!="string"&&!Ft(fe)&&(fe=KR(fe),typeof fe!="string"))throw xi("dirty is not a string, aborting");if(!t.isSupported)return fe;Be?(Ye=mt,Ue=it):Ar(S),(xe.uponSanitizeElement.length>0||xe.uponSanitizeAttribute.length>0)&&(Ye=Ir(Ye)),xe.uponSanitizeAttribute.length>0&&(Ue=Ir(Ue)),t.removed=[];const Ce=Zt&&typeof fe!="string"&&Ft(fe);if(Ce){Dt(fe);const Sn=J(fe);if(typeof Sn=="string"){const gn=kt(Sn);if(!Ye[gn]||ut[gn])throw pe(fe),xi("root node is forbidden and cannot be sanitized in-place")}if(Ze(fe))throw pe(fe),xi("root node is clobbered and cannot be sanitized in-place");try{cr(fe)}catch(gn){throw pe(fe),gn}}else if(Ft(fe))N=nr("<!---->"),U=N.ownerDocument.importNode(fe,!0),U.nodeType===Tr.element&&U.nodeName==="BODY"||U.nodeName==="HTML"?N=U:N.appendChild(U),cr(U);else{if(!Rn&&!vt&&!te&&fe.indexOf("<")===-1)return se&&wn?de(fe):fe;if(N=nr(fe),!N)return Rn?null:wn?me:""}N&&rt&&En(N.firstChild);const Je=Ce?fe:N;try{const Sn=Mr(Je);for(;oe=Sn.nextNode();)rr(oe,Je),_t(oe),tt(oe.content)&&Pr(oe.content)}catch(Sn){throw Ce&&(pe(fe),_i(t.removed,gn=>{gn.element&&Qe(gn.element)})),Sn}if(Ce)return _i(t.removed,Sn=>{Sn.element&&Qe(Sn.element)}),vt&&L(fe),fe;if(Rn){if(vt&&L(N),Xe)for(ke=j.call(N.ownerDocument);N.firstChild;)ke.appendChild(N.firstChild);else ke=N;return(Ue.shadowroot||Ue.shadowrootmode)&&(ke=Ie.call(o,ke,!0)),ke}let Ut=te?N.outerHTML:N.innerHTML;return te&&Ye["!doctype"]&&N.ownerDocument&&N.ownerDocument.doctype&&N.ownerDocument.doctype.name&&Yn(rC,N.ownerDocument.doctype.name)&&(Ut="<!DOCTYPE "+N.ownerDocument.doctype.name+`>
101
- `+Ut),vt&&(Ut=rn(Ut)),se&&wn?de(Ut):Ut},t.setConfig=function(){let fe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ar(fe),Be=!0,mt=Ye,it=Ue},t.clearConfig=function(){tr=null,Be=!1,mt=null,it=null,se=Oe,me=""},t.isValidAttribute=function(fe,S,N){tr||Ar({});const U=kt(fe),oe=kt(S);return Do(U,oe,N)},t.addHook=function(fe,S){typeof S=="function"&&kr(xe,fe)&&ea(xe[fe],S)},t.removeHook=function(fe,S){if(kr(xe,fe)){if(S!==void 0){const N=DR(xe[fe],S);return N===-1?void 0:FR(xe[fe],N,1)[0]}return wk(xe[fe])}},t.removeHooks=function(fe){kr(xe,fe)&&(xe[fe]=[])},t.removeAllHooks=function(){xe=jk()},t}var lw=aw();function dp(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Pi=dp();function cw(e){Pi=e}var Ei={exec:()=>null};function as(e){let t=[];return n=>{let o=Math.max(0,Math.min(3,n-1)),s=t[o];return s||(s=e(o),t[o]=s),s}}function ct(e,t=""){let n=typeof e=="string"?e:e.source,o={replace:(s,a)=>{let c=typeof a=="string"?a:a.source;return c=c.replace(Qn.caret,"$1"),n=n.replace(s,c),o},getRegex:()=>new RegExp(n,t)};return o}var dC=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Qn={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:as(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:as(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:as(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:as(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:as(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:as(e=>new RegExp(`^ {0,${e}}>`))},fC=/^(?:[ \t]*(?:\n|$))+/,pC=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,hC=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,$a=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,mC=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,fp=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,uw=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,dw=ct(uw).replace(/bull/g,fp).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(),gC=ct(uw).replace(/bull/g,fp).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(),pp=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,kC=/^[^\n]+/,hp=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,yC=ct(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",hp).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),vC=ct(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,fp).getRegex(),Zc="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",mp=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,wC=ct("^ {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",mp).replace("tag",Zc).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),fw=e=>ct(pp).replace("hr",$a).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",Zc).getRegex(),bC=fw(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),xC=fw(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),_C=ct(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xC).getRegex(),gp={blockquote:_C,code:pC,def:yC,fences:hC,heading:mC,hr:$a,html:wC,lheading:dw,list:vC,newline:fC,paragraph:bC,table:Ei,text:kC},Ak=ct("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",$a).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",Zc).getRegex(),EC={...gp,lheading:gC,table:Ak,paragraph:ct(pp).replace("hr",$a).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ak).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",Zc).getRegex()},SC={...gp,html:ct(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",mp).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:Ei,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ct(pp).replace("hr",$a).replace("heading",` *#{1,6} *[^
102
- ]`).replace("lheading",dw).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},NC=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,TC=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,pw=/^( {2,}|\\)\n(?!\s*$)/,IC=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Po=/[\p{P}\p{S}]/u,xs=/[\s\p{P}\p{S}]/u,Ma=/[^\s\p{P}\p{S}]/u,OC=ct(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,xs).getRegex(),RC=/[\p{Pi}\p{Ps}"']/u,hw=/(?!~)[\p{P}\p{S}]/u,CC=/(?!~)[\s\p{P}\p{S}]/u,jC=/(?:[^\s\p{P}\p{S}]|~)/u,AC=ct(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",dC?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),mw=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,$C=ct(mw,"u").replace(/punct/g,Po).getRegex(),MC=ct(mw,"u").replace(/punct/g,hw).getRegex(),PC=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,LC=ct(PC,"u").replace(/openQuote/g,RC).replace(/punct/g,Po).getRegex(),gw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",zC=ct(gw,"gu").replace(/notPunctSpace/g,Ma).replace(/punctSpace/g,xs).replace(/punct/g,Po).getRegex(),DC=ct(gw,"gu").replace(/notPunctSpace/g,jC).replace(/punctSpace/g,CC).replace(/punct/g,hw).getRegex(),FC="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",UC=ct(FC,"gu").replace(/notPunctSpace/g,Ma).replace(/punctSpace/g,xs).replace(/punct/g,Po).getRegex(),BC=ct("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ma).replace(/punctSpace/g,xs).replace(/punct/g,Po).getRegex(),ZC="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",HC=ct(ZC,"gu").replace(/notPunctSpace/g,Ma).replace(/punctSpace/g,xs).replace(/punct/g,Po).getRegex(),WC=ct(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Po).getRegex(),KC="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",VC=ct(KC,"gu").replace(/notPunctSpace/g,Ma).replace(/punctSpace/g,xs).replace(/punct/g,Po).getRegex(),GC=ct(/\\(punct)/,"gu").replace(/punct/g,Po).getRegex(),qC=ct(/^<(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(),YC=ct(mp).replace("(?:-->|$)","-->").getRegex(),QC=ct("^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",YC).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),pc=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,XC=ct(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",pc).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),kw=ct(/^!?\[(label)\]\[(ref)\]/).replace("label",pc).replace("ref",hp).getRegex(),yw=ct(/^!?\[(ref)\](?:\[\])?/).replace("ref",hp).getRegex(),JC=ct("reflink|nolink(?!\\()","g").replace("reflink",kw).replace("nolink",yw).getRegex(),$k=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,kp={_backpedal:Ei,anyPunctuation:GC,autolink:qC,blockSkip:AC,br:pw,code:TC,del:Ei,delLDelim:Ei,delRDelim:Ei,emStrongLDelim:$C,emStrongRDelimAst:zC,emStrongRDelimUnd:BC,escape:NC,link:XC,nolink:yw,punctuation:OC,reflink:kw,reflinkSearch:JC,tag:QC,text:IC,url:Ei},ej={...kp,emStrongLDelim:LC,emStrongRDelimAst:UC,emStrongRDelimUnd:HC,link:ct(/^!?\[(label)\]\((.*?)\)/).replace("label",pc).getRegex(),reflink:ct(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pc).getRegex()},Nf={...kp,emStrongRDelimAst:DC,emStrongLDelim:MC,delLDelim:WC,delRDelim:VC,url:ct(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",$k).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:ct(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",$k).getRegex()},tj={...Nf,br:ct(pw).replace("{2,}","*").getRegex(),text:ct(Nf.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ql={normal:gp,gfm:EC,pedantic:SC},ra={normal:kp,gfm:Nf,breaks:tj,pedantic:ej},nj={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Mk=e=>nj[e];function yo(e,t){if(t){if(Qn.escapeTest.test(e))return e.replace(Qn.escapeReplace,Mk)}else if(Qn.escapeTestNoEncode.test(e))return e.replace(Qn.escapeReplaceNoEncode,Mk);return e}function Pk(e){try{e=encodeURI(e).replace(Qn.percentDecode,"%")}catch{return null}return e}function Lk(e,t){var a;let n=e.replace(Qn.findPipe,(c,u,d)=>{let p=!1,m=u;for(;--m>=0&&d[m]==="\\";)p=!p;return p?"|":" |"}),o=n.split(Qn.splitPipe),s=0;if(o[0].trim()||o.shift(),o.length>0&&!((a=o.at(-1))!=null&&a.trim())&&o.pop(),t)if(o.length>t)o.splice(t);else for(;o.length<t;)o.push("");for(;s<o.length;s++)o[s]=o[s].trim().replace(Qn.slashPipe,"|");return o}function ni(e,t,n){let o=e.length;if(o===0)return"";let s=0;for(;s<o&&e.charAt(o-s-1)===t;)s++;return e.slice(0,o-s)}function zk(e){let t=e.split(`
103
- `),n=t.length-1;for(;n>=0&&Qn.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
104
- `)}function rj(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let o=0;o<e.length;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])n++;else if(e[o]===t[1]&&(n--,n<0))return o;return n>0?-2:-1}function oj(e,t=0){let n=t,o="";for(let s of e)if(s===" "){let a=4-n%4;o+=" ".repeat(a),n+=a}else o+=s,n++;return o}function Dk(e,t,n,o,s){let a=t.href,c=t.title||null,u=e[1].replace(s.other.outputLinkReplace,"$1"),d=e[0].charAt(0)==="!";o.state.inLink=!0;let p=o.state.linkEmitted,m=o.state.inRawBlock;o.state.linkEmitted=!1;let g=o.inlineTokens(u),k=o.state.linkEmitted;if(o.state.linkEmitted=p,o.state.inLink=!1,!d){if(k){o.state.inRawBlock=m;return}o.state.linkEmitted=!0}return{type:d?"image":"link",raw:n,href:a,title:c,text:u,tokens:g}}function ij(e,t,n){let o=e.match(n.other.indentCodeCompensation);if(o===null)return t;let s=o[1];return t.split(`
105
- `).map(a=>{let c=a.match(n.other.beginningSpace);if(c===null)return a;let[u]=c;return u.length>=s.length?a.slice(s.length):a}).join(`
106
- `)}var hc=class{constructor(e){dt(this,"options");dt(this,"rules");dt(this,"lexer");this.options=e||Pi}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]:zk(t[0]),o=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:o}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],o=ij(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:o}}}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 o=ni(n,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceChar.test(o))&&(n=o.trim())}return{type:"heading",raw:ni(t[0],`
107
- `),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:ni(t[0],`
108
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=ni(t[0],`
109
- `).split(`
110
- `),o="",s="",a=[];for(;n.length>0;){let c=!1,u=[],d;for(d=0;d<n.length;d++)if(this.rules.other.blockquoteStart.test(n[d]))u.push(n[d]),c=!0;else if(!c)u.push(n[d]);else break;n=n.slice(d);let p=u.join(`
111
- `),m=p.replace(this.rules.other.blockquoteSetextReplace,`
112
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
113
- ${p}`:p,s=s?`${s}
114
- ${m}`:m;let g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(m,a,!0),this.lexer.state.top=g,n.length===0)break;let k=a.at(-1);if((k==null?void 0:k.type)==="code")break;if((k==null?void 0:k.type)==="blockquote"){let w=k,b=n.join(`
115
- `),_=w.raw+`
116
- `+b.replace(this.rules.other.blockquoteSetextReplace2,""),I=this.blockquote(_);a[a.length-1]=I,o=`${o}
117
- ${b}`,s=s.substring(0,s.length-w.text.length)+I.text;break}else if((k==null?void 0:k.type)==="list"){let w=k,b=w.raw+`
118
- `+n.join(`
119
- `),_=this.list(b);a[a.length-1]=_,o=o.substring(0,o.length-k.raw.length)+_.raw,s=s.substring(0,s.length-w.raw.length)+_.raw,n=b.substring(a.at(-1).raw.length).split(`
120
- `);continue}}return{type:"blockquote",raw:o,tokens:a,text:s}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),o=n.length>1,s={type:"list",raw:"",ordered:o,start:o?+n.slice(0,-1):"",loose:!1,items:[]};n=o?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=o?n:"[*+-]");let a=this.rules.other.listItemRegex(n),c=!1;for(;e;){let d=!1,p="",m="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let g=oj(t[2].split(`
121
- `,1)[0],t[1].length),k=e.split(`
122
- `,1)[0],w=!g.trim(),b=0;if(this.options.pedantic?(b=2,m=g.trimStart()):w?b=t[1].length+1:(b=g.search(this.rules.other.nonSpaceChar),b=b>4?1:b,m=g.slice(b),b+=t[1].length),w&&this.rules.other.blankLine.test(k)&&(p+=k+`
123
- `,e=e.substring(k.length+1),d=!0),!d){let _=this.rules.other.nextBulletRegex(b),I=this.rules.other.hrRegex(b),C=this.rules.other.fencesBeginRegex(b),E=this.rules.other.headingBeginRegex(b),Z=this.rules.other.htmlBeginRegex(b),M=this.rules.other.blockquoteBeginRegex(b);for(;e;){let $=e.split(`
124
- `,1)[0],D;if(k=$,this.options.pedantic?(k=k.replace(this.rules.other.listReplaceNesting," "),D=k):D=k.replace(this.rules.other.tabCharGlobal," "),C.test(k)||E.test(k)||Z.test(k)||M.test(k)||_.test(k)||I.test(k))break;if(D.search(this.rules.other.nonSpaceChar)>=b||!k.trim())m+=`
125
- `+D.slice(b);else{if(w||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||C.test(g)||E.test(g)||I.test(g))break;m+=`
126
- `+k}w=!k.trim(),p+=$+`
127
- `,e=e.substring($.length+1),g=D.slice(b)}}s.loose||(c?s.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(c=!0)),s.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(m),loose:!1,text:m,tokens:[]}),s.raw+=p}let u=s.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let d of s.items)if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),!s.loose){let p=d.tokens.filter(g=>g.type==="space"),m=p.length>0&&p.some(g=>this.rules.other.anyLine.test(g.raw));s.loose=m}for(let d of s.items){let p=d.tokens[0];if(d.task&&((p==null?void 0:p.type)==="text"||(p==null?void 0:p.type)==="paragraph")){d.text=d.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 g=this.lexer.inlineQueue.length-1;g>=0;g--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[g].src)){this.lexer.inlineQueue[g].src=this.lexer.inlineQueue[g].src.replace(this.rules.other.listReplaceTask,"");break}let m=this.rules.other.listTaskCheckbox.exec(d.raw);if(m){let g={type:"checkbox",raw:m[0]+" ",checked:m[0]!=="[ ]"};d.checked=g.checked,s.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=g.raw+d.tokens[0].raw,d.tokens[0].text=g.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(g)):d.tokens.unshift({type:"paragraph",raw:g.raw,text:g.raw,tokens:[g]}):d.tokens.unshift(g)}}else d.task&&(d.task=!1)}if(s.loose)for(let d of s.items){d.loose=!0;for(let p of d.tokens)p.type==="text"&&(p.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=zk(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," "),o=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:ni(t[0],`
128
- `),href:o,title:s}}}table(e){var c;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Lk(t[1]),o=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(c=t[3])!=null&&c.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
129
- `):[],a={type:"table",raw:ni(t[0],`
130
- `),header:[],align:[],rows:[]};if(n.length===o.length){for(let u of o)this.rules.other.tableAlignRight.test(u)?a.align.push("right"):this.rules.other.tableAlignCenter.test(u)?a.align.push("center"):this.rules.other.tableAlignLeft.test(u)?a.align.push("left"):a.align.push(null);for(let u=0;u<n.length;u++)a.header.push({text:n[u],tokens:this.lexer.inline(n[u]),header:!0,align:a.align[u]});for(let u of s)a.rows.push(Lk(u,a.header.length).map((d,p)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:a.align[p]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:ni(t[0],`
131
- `),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)===`
132
- `?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 a=ni(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=rj(t[2],"()");if(a===-2)return;if(a>-1){let c=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let o=t[2],s="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(o);a&&(o=a[1],s=a[3])}else s=t[3]?t[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?o=o.slice(1):o=o.slice(1,-1)),Dk(t,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.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 o=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[o.toLowerCase()];if(!s){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return Dk(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let o=this.rules.inline.emStrongLDelim.exec(e);if(!(!o||!o[1]&&!o[2]&&!o[3]&&!o[4]||o[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(o[1]||o[3])||!n||this.rules.inline.punctuation.exec(n))){let s=[...o[0]].length-1,a,c,u=s,d=0,p=o[0][0],m=n===p,g=p==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(g.lastIndex=0,t=t.slice(-1*e.length+s);(o=g.exec(t))!==null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(c=[...a].length,o[3]||o[4]){u+=c;continue}else if(o[5]||o[6]){if(s%3&&!((s+c)%3)){d+=c;continue}if(m)break}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);let k=[...o[0]][0].length,w=e.slice(0,s+o.index+k+c);if(Math.min(s,c)%2){let _=w.slice(1,-1);return{type:"em",raw:w,text:_,tokens:this.lexer.inlineTokens(_)}}let b=w.slice(2,-2);return{type:"strong",raw:w,text:b,tokens:this.lexer.inlineTokens(b)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),o=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return o&&s&&(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 o=this.rules.inline.delLDelim.exec(e);if(o&&(!o[1]||!n||this.rules.inline.punctuation.exec(n))){let s=[...o[0]].length-1,a,c,u=s,d=this.rules.inline.delRDelim;for(d.lastIndex=0,t=t.slice(-1*e.length+s);(o=d.exec(t))!==null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a||(c=[...a].length,c!==s))continue;if(o[3]||o[4]){u+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u);let p=[...o[0]][0].length,m=e.slice(0,s+o.index+p+c),g=m.slice(s,-s);return{type:"del",raw:m,text:g,tokens:this.lexer.inlineTokens(g)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,o;return t[2]==="@"?(n=t[1],o="mailto:"+n):(n=t[1],o=n),{type:"link",raw:t[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let o,s;if(t[2]==="@")o=t[0],s="mailto:"+o;else{let a;do a=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(a!==t[0]);o=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}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}}}},oo=class Tf{constructor(t){dt(this,"tokens");dt(this,"options");dt(this,"state");dt(this,"inlineQueue");dt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Pi,this.options.tokenizer=this.options.tokenizer||new hc,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:Qn,block:ql.normal,inline:ra.normal};this.options.pedantic?(n.block=ql.pedantic,n.inline=ra.pedantic):this.options.gfm&&(n.block=ql.gfm,this.options.breaks?n.inline=ra.breaks:n.inline=ra.gfm),this.tokenizer.rules=n}static get rules(){return{block:ql,inline:ra}}static lex(t,n){return new Tf(n).lex(t)}static lexInline(t,n){return new Tf(n).inlineTokens(t)}lex(t){t=t.replace(Qn.carriageReturn,`
133
- `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let o=this.inlineQueue[n];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],o=!1){var a,c,u;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Qn.tabCharGlobal," ").replace(Qn.spaceLine,""));let s=1/0;for(;t;){if(t.length<s)s=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let d;if((c=(a=this.options.extensions)==null?void 0:a.block)!=null&&c.some(m=>(d=m.call({lexer:this},t,n))?(t=t.substring(d.raw.length),n.push(d),!0):!1))continue;if(d=this.tokenizer.space(t)){t=t.substring(d.raw.length);let m=n.at(-1);d.raw.length===1&&m!==void 0?m.raw+=`
134
- `:n.push(d);continue}if(d=this.tokenizer.code(t)){t=t.substring(d.raw.length);let m=n.at(-1);(m==null?void 0:m.type)==="paragraph"||(m==null?void 0:m.type)==="text"?(m.raw+=(m.raw.endsWith(`
135
- `)?"":`
136
- `)+d.raw,m.text+=`
137
- `+d.text,this.inlineQueue.at(-1).src=m.text):n.push(d);continue}if(d=this.tokenizer.fences(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.heading(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.hr(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.blockquote(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.list(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.html(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.def(t)){t=t.substring(d.raw.length);let m=n.at(-1);(m==null?void 0:m.type)==="paragraph"||(m==null?void 0:m.type)==="text"?(m.raw+=(m.raw.endsWith(`
138
- `)?"":`
139
- `)+d.raw,m.text+=`
140
- `+d.raw,this.inlineQueue.at(-1).src=m.text):this.tokens.links[d.tag]||(this.tokens.links[d.tag]={href:d.href,title:d.title},n.push(d));continue}if(d=this.tokenizer.table(t)){t=t.substring(d.raw.length),n.push(d);continue}if(d=this.tokenizer.lheading(t)){t=t.substring(d.raw.length),n.push(d);continue}let p=t;if((u=this.options.extensions)!=null&&u.startBlock){let m=1/0,g=t.slice(1),k;this.options.extensions.startBlock.forEach(w=>{k=w.call({lexer:this},g),typeof k=="number"&&k>=0&&(m=Math.min(m,k))}),m<1/0&&m>=0&&(p=t.substring(0,m+1))}if(this.state.top&&(d=this.tokenizer.paragraph(p))){let m=n.at(-1);o&&(m==null?void 0:m.type)==="paragraph"?(m.raw+=(m.raw.endsWith(`
141
- `)?"":`
142
- `)+d.raw,m.text+=`
143
- `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=m.text):n.push(d),o=p.length!==t.length,t=t.substring(d.raw.length);continue}if(d=this.tokenizer.text(t)){t=t.substring(d.raw.length);let m=n.at(-1);(m==null?void 0:m.type)==="text"?(m.raw+=(m.raw.endsWith(`
144
- `)?"":`
145
- `)+d.raw,m.text+=`
146
- `+d.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=m.text):n.push(d);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 o of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(o[0])&&t.charAt(o.index-1)!=="!")return!0;for(let o of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let s=o[0],a=s.lastIndexOf("[");if(!(s.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,s.slice(a+1,-1)))&&!(a>1&&this.linkInText(s.slice(1,a-1))))return!0}return!1}inlineTokens(t,n=[]){var u,d,p,m,g;this.tokenizer.lexer=this;let o=t;if(this.tokens.links&&t.includes("[")){let k=this.tokenizer.rules.inline.reflinkSearch,w=b=>{let _=b.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,b.slice(_+1,-1)))return b;if(_>1&&b.charAt(0)!=="!"){let I=b.slice(1,_-1);if(this.linkInText(I))return"["+I.replace(k,w)+"]["+"a".repeat(b.length-_-2)+"]"}return"["+"a".repeat(b.length-2)+"]"};o=o.replace(k,w)}o=o.replace(this.tokenizer.rules.inline.anyPunctuation,k=>"+".repeat(k.length)),o=o.replace(this.tokenizer.rules.inline.blockSkip,(k,w,b)=>{let _=b?b.length:0;return k.slice(0,_)+"["+"a".repeat(k.length-_-2)+"]"}),o=((d=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:d.call({lexer:this},o))??o;let s=!1,a="",c=1/0;for(;t;){if(t.length<c)c=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}s||(a=""),s=!1;let k;if((m=(p=this.options.extensions)==null?void 0:p.inline)!=null&&m.some(b=>(k=b.call({lexer:this},t,n))?(t=t.substring(k.raw.length),n.push(k),!0):!1))continue;if(k=this.tokenizer.escape(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.tag(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.link(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(k.raw.length);let b=n.at(-1);k.type==="text"&&(b==null?void 0:b.type)==="text"?(b.raw+=k.raw,b.text+=k.text):n.push(k);continue}if(k=this.tokenizer.emStrong(t,o,a)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.codespan(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.br(t)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.del(t,o,a)){t=t.substring(k.raw.length),n.push(k);continue}if(k=this.tokenizer.autolink(t)){t=t.substring(k.raw.length),n.push(k);continue}if(!this.state.inLink&&(k=this.tokenizer.url(t))){t=t.substring(k.raw.length),n.push(k);continue}let w=t;if((g=this.options.extensions)!=null&&g.startInline){let b=1/0,_=t.slice(1),I;this.options.extensions.startInline.forEach(C=>{I=C.call({lexer:this},_),typeof I=="number"&&I>=0&&(b=Math.min(b,I))}),b<1/0&&b>=0&&(w=t.substring(0,b+1))}if(k=this.tokenizer.inlineText(w)){t=t.substring(k.raw.length),k.raw.slice(-1)!=="_"&&(a=k.raw.slice(-1)),s=!0;let b=n.at(-1);(b==null?void 0:b.type)==="text"?(b.raw+=k.raw,b.text+=k.text):n.push(k);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},mc=class{constructor(e){dt(this,"options");dt(this,"parser");this.options=e||Pi}space(e){return""}code({text:e,lang:t,escaped:n}){var a;let o=(a=(t||"").match(Qn.notSpaceStart))==null?void 0:a[0],s=e.replace(Qn.endingNewline,"")+`
147
- `;return o?'<pre><code class="language-'+yo(o)+'">'+(n?s:yo(s,!0))+`</code></pre>
148
- `:"<pre><code>"+(n?s:yo(s,!0))+`</code></pre>
149
- `}blockquote({tokens:e}){return`<blockquote>
150
- ${this.parser.parse(e)}</blockquote>
151
- `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
152
- `}hr(e){return`<hr>
153
- `}list(e){let t=e.ordered,n=e.start,o="";for(let c=0;c<e.items.length;c++){let u=e.items[c];o+=this.listitem(u)}let s=t?"ol":"ul",a=t&&n!==1?' start="'+n+'"':"";return"<"+s+a+`>
154
- `+o+"</"+s+`>
155
- `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
156
- `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
157
- `}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let o="";for(let s=0;s<e.rows.length;s++){let a=e.rows[s];n="";for(let c=0;c<a.length;c++)n+=this.tablecell(a[c]);o+=this.tablerow({text:n})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
158
- <thead>
159
- `+t+`</thead>
160
- `+o+`</table>
161
- `}tablerow({text:e}){return`<tr>
162
- ${e}</tr>
163
- `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
164
- `}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>${yo(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 o=this.parser.parseInline(n),s=Pk(e);if(s===null)return o;e=s;let a='<a href="'+e+'"';return t&&(a+=' title="'+yo(t)+'"'),a+=">"+o+"</a>",a}image({href:e,title:t,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));let s=Pk(e);if(s===null)return yo(n);e=s;let a=`<img src="${e}" alt="${yo(n)}"`;return t&&(a+=` title="${yo(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:yo(e.text)}},yp=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}},io=class If{constructor(t){dt(this,"options");dt(this,"renderer");dt(this,"textRenderer");this.options=t||Pi,this.options.renderer=this.options.renderer||new mc,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new yp}static parse(t,n){return new If(n).parse(t)}static parseInline(t,n){return new If(n).parseInline(t)}parse(t){var o,s;this.renderer.parser=this;let n="";for(let a=0;a<t.length;a++){let c=t[a];if((s=(o=this.options.extensions)==null?void 0:o.renderers)!=null&&s[c.type]){let d=c,p=this.options.extensions.renderers[d.type].call({parser:this},d);if(p!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(d.type)){n+=p||"";continue}}let u=c;switch(u.type){case"space":{n+=this.renderer.space(u);break}case"hr":{n+=this.renderer.hr(u);break}case"heading":{n+=this.renderer.heading(u);break}case"code":{n+=this.renderer.code(u);break}case"table":{n+=this.renderer.table(u);break}case"blockquote":{n+=this.renderer.blockquote(u);break}case"list":{n+=this.renderer.list(u);break}case"checkbox":{n+=this.renderer.checkbox(u);break}case"html":{n+=this.renderer.html(u);break}case"def":{n+=this.renderer.def(u);break}case"paragraph":{n+=this.renderer.paragraph(u);break}case"text":{n+=this.renderer.text(u);break}default:{let d='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return n}parseInline(t,n=this.renderer){var s,a;this.renderer.parser=this;let o="";for(let c=0;c<t.length;c++){let u=t[c];if((a=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&a[u.type]){let p=this.options.extensions.renderers[u.type].call({parser:this},u);if(p!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(u.type)){o+=p||"";continue}}let d=u;switch(d.type){case"escape":{o+=n.text(d);break}case"html":{o+=n.html(d);break}case"link":{o+=n.link(d);break}case"image":{o+=n.image(d);break}case"checkbox":{o+=n.checkbox(d);break}case"strong":{o+=n.strong(d);break}case"em":{o+=n.em(d);break}case"codespan":{o+=n.codespan(d);break}case"br":{o+=n.br(d);break}case"del":{o+=n.del(d);break}case"text":{o+=n.text(d);break}default:{let p='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return o}},Xl,ua=(Xl=class{constructor(e){dt(this,"options");dt(this,"block");this.options=e||Pi}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?oo.lex:oo.lexInline}provideParser(e=this.block){return e?io.parse:io.parseInline}},dt(Xl,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),dt(Xl,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Xl),sj=class{constructor(...e){dt(this,"defaults",dp());dt(this,"options",this.setOptions);dt(this,"parse",this.parseMarkdown(!0));dt(this,"parseInline",this.parseMarkdown(!1));dt(this,"Parser",io);dt(this,"Renderer",mc);dt(this,"TextRenderer",yp);dt(this,"Lexer",oo);dt(this,"Tokenizer",hc);dt(this,"Hooks",ua);this.use(...e)}walkTokens(e,t){var o,s;let n=[];for(let a of e)switch(n=n.concat(t.call(this,a)),a.type){case"table":{let c=a;for(let u of c.header)n=n.concat(this.walkTokens(u.tokens,t));for(let u of c.rows)for(let d of u)n=n.concat(this.walkTokens(d.tokens,t));break}case"list":{let c=a;n=n.concat(this.walkTokens(c.items,t));break}default:{let c=a;(s=(o=this.defaults.extensions)==null?void 0:o.childTokens)!=null&&s[c.type]?this.defaults.extensions.childTokens[c.type].forEach(u=>{let d=c[u].flat(1/0);n=n.concat(this.walkTokens(d,t))}):c.tokens&&(n=n.concat(this.walkTokens(c.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let a=t.renderers[s.name];a?t.renderers[s.name]=function(...c){let u=s.renderer.apply(this,c);return u===!1&&(u=a.apply(this,c)),u}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[s.level];a?a.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),o.extensions=t),n.renderer){let s=this.defaults.renderer||new mc(this.defaults);for(let a in n.renderer){if(!(a in s))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let c=a,u=n.renderer[c],d=s[c];s[c]=(...p)=>{let m=u.apply(s,p);return m===!1&&(m=d.apply(s,p)),m||""}}o.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new hc(this.defaults);for(let a in n.tokenizer){if(!(a in s))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let c=a,u=n.tokenizer[c],d=s[c];s[c]=(...p)=>{let m=u.apply(s,p);return m===!1&&(m=d.apply(s,p)),m}}o.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new ua;for(let a in n.hooks){if(!(a in s))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let c=a,u=n.hooks[c],d=s[c];ua.passThroughHooks.has(a)?s[c]=p=>{if(this.defaults.async&&ua.passThroughHooksRespectAsync.has(a))return(async()=>{let g=await u.call(s,p);return d.call(s,g)})();let m=u.call(s,p);return d.call(s,m)}:s[c]=(...p)=>{if(this.defaults.async)return(async()=>{let g=await u.apply(s,p);return g===!1&&(g=await d.apply(s,p)),g})();let m=u.apply(s,p);return m===!1&&(m=d.apply(s,p)),m}}o.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,a=n.walkTokens;o.walkTokens=function(c){let u=[];return u.push(a.call(this,c)),s&&(u=u.concat(s.call(this,c))),u}}this.defaults={...this.defaults,...o}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return oo.lex(e,t??this.defaults)}parser(e,t){return io.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let o={...n},s={...this.defaults,...o},a=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&o.async===!1)return a(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 a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let c=s.hooks?await s.hooks.preprocess(t):t,u=await(s.hooks?await s.hooks.provideLexer(e):e?oo.lex:oo.lexInline)(c,s),d=s.hooks?await s.hooks.processAllTokens(u):u;s.walkTokens&&await Promise.all(this.walkTokens(d,s.walkTokens));let p=await(s.hooks?await s.hooks.provideParser(e):e?io.parse:io.parseInline)(d,s);return s.hooks?await s.hooks.postprocess(p):p})().catch(a);try{s.hooks&&(t=s.hooks.preprocess(t));let c=(s.hooks?s.hooks.provideLexer(e):e?oo.lex:oo.lexInline)(t,s);s.hooks&&(c=s.hooks.processAllTokens(c)),s.walkTokens&&this.walkTokens(c,s.walkTokens);let u=(s.hooks?s.hooks.provideParser(e):e?io.parse:io.parseInline)(c,s);return s.hooks&&(u=s.hooks.postprocess(u)),u}catch(c){return a(c)}}}onError(e,t){return n=>{if(n.message+=`
165
- Please report this to https://github.com/markedjs/marked.`,e){let o="<p>An error occurred:</p><pre>"+yo(n.message+"",!0)+"</pre>";return t?Promise.resolve(o):o}if(t)return Promise.reject(n);throw n}}},Ri=new sj;function jt(e,t){return Ri.parse(e,t)}jt.options=jt.setOptions=function(e){return Ri.setOptions(e),jt.defaults=Ri.defaults,cw(jt.defaults),jt};jt.getDefaults=dp;jt.defaults=Pi;function aj(...e){return Ri.use(...e),jt.defaults=Ri.defaults,cw(jt.defaults),jt}jt.use=aj;jt.walkTokens=function(e,t){return Ri.walkTokens(e,t)};jt.parseInline=Ri.parseInline;jt.Parser=io;jt.parser=io.parse;jt.Renderer=mc;jt.TextRenderer=yp;jt.Lexer=oo;jt.lexer=oo.lex;jt.Tokenizer=hc;jt.Hooks=ua;jt.parse=jt;jt.options;jt.setOptions;jt.walkTokens;jt.parseInline;io.parse;oo.lex;function Kd(e,t,{dispatch:n}){const o=[{id:"copy",label:"copy message",onClick:()=>Ln(e.text)}],s=[];return e.kind==="user"&&t&&s.push({id:"draft",label:"edit in composer",onClick:()=>n({a:"set-draft",id:t,text:e.text})}),Hn([o,s])}function lj(e,t={}){const n=e.callFile??e.file,o=n&&(n.startsWith("/")?n:t.dir?`${t.dir}/${n}`:null),s=o?bs(o):[],a=n?[{id:"copy-path",label:"copy path",onClick:()=>Ln(n)}]:[],c=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Hn([s,a,c])}function cj(e,t){const n=e.startsWith("/")?e:t?`${t}/${e}`:null;return n?Hn([bs(n),[{id:"copy-path",label:"copy path",onClick:()=>Ln(e)}]]):[]}const uj={sm:"",md:"field-md",lg:"field-lg"};function vw({size:e="sm",font:t,bare:n,rule:o,className:s}){const a=t??(e==="lg"?"ui":"mono");return ot("field",uj[e],a==="ui"&&"field-ui",a==="lead"&&"field-lead",n&&"field-bare",o&&"field-rule",s)}const Mo=O.forwardRef(function({size:t,font:n,bare:o,rule:s,className:a,...c},u){return h.jsx("input",{ref:u,className:vw({size:t,font:n,bare:o,rule:s,className:a}),...c})}),Pa=O.forwardRef(function({size:t,font:n,bare:o,rule:s,className:a,...c},u){return h.jsx("textarea",{ref:u,className:vw({size:t,font:n,bare:o,rule:s,className:a}),...c})});function Rr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}function vp({hints:e,className:t=""}){return h.jsx("div",{className:`key-hints ${t}`.trim(),children:e.map(([n,o])=>h.jsxs("span",{className:"key-hint",children:[h.jsx(Or,{k:n}),o]},n))})}function wp(e,t,n){return n===0?0:(e+t+n)%n}function Fk(e,t,n){return e>=0?wp(e,t,n):n===0?-1:t>0?0:n-1}function dj(e,t,n){var a;const o=e.length,s=n.toLowerCase();for(let c=1;c<=o;c++){const u=(Math.max(t,-1)+c)%o;if((a=e[u])!=null&&a.trim().toLowerCase().startsWith(s))return u}return-1}function Vd(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function fj(e,t){if(e==null)return null;if(typeof e=="string"){const s=Vd(e,t);return s?{text:s,accept:s,params:[]}:null}const n=Vd(e.show,t);if(!n)return null;const o=(e.params??[]).map(([s,a])=>[Math.max(s,t.length)-t.length,a-t.length]).filter(([s,a])=>a>s);return{text:n,accept:Vd(e.accept,t),params:o}}function bp(e){const{results:t,keyOf:n,q:o,onPick:s,listRef:a,onActive:c,onSide:u,completionOf:d,narrowTo:p,setQ:m,tabPicks:g,onIdlePick:k}=e,[w,b]=O.useState(()=>{var D;return e.idle?-1:Math.max(0,((D=e.initialIndex)==null?void 0:D.call(e,t))??0)}),_=w>=0&&t[w]?n(t[w]):null,I=O.useRef(c);I.current=c,Bt([_],()=>{var D,q,J;(q=(D=a.current)==null?void 0:D.querySelector('.picker-item[data-state~="cursor"]'))==null||q.scrollIntoView({block:"nearest"}),(J=I.current)==null||J.call(I,w>=0?t[w]??null:null)});const C=w<0?-1:Math.min(w,Math.max(0,t.length-1)),E=C>=0?t[C]??null:null,Z=E?fj(d==null?void 0:d(E,o),o):null,M=D=>{const q=p==null?void 0:p(D,o);if(q==null)return s(D,o);m==null||m(q),b(0)};return{index:C,active:E,ghost:Z,setIndex:b,pick:M,onKeyDown:D=>{if(D.key==="ArrowDown")D.preventDefault(),b(Fk(C,1,t.length));else if(D.key==="ArrowUp")D.preventDefault(),b(Fk(C,-1,t.length));else if((D.key==="ArrowLeft"||D.key==="ArrowRight")&&u&&E)D.preventDefault(),u(E,D.key==="ArrowLeft"?-1:1);else if(D.key==="Tab"&&(Z!=null&&Z.accept))D.preventDefault(),m==null||m(o+Z.accept),b(0);else if(D.key==="Tab"&&g&&E)D.preventDefault(),M(E);else if(D.key==="Enter"&&E)D.preventDefault(),M(E);else if(D.key==="Enter"&&C<0&&k)D.preventDefault(),k(o);else return!1;return!0}}}function pj(e){return e.flatMap((t,n)=>t.options.map(o=>({q:n,option:o})))}function hj(e){return`${e.q}:${e.option.value}`}function mj(e){return e.map(()=>({selected:[]}))}function Uk(e,t,n){return e.map((o,s)=>{if(s!==t.q)return o;const a=o.selected.includes(t.option.value);return n?{...o,selected:a?o.selected.filter(c=>c!==t.option.value):[...o.selected,t.option.value]}:{...o,selected:[t.option.value]}})}function gj(e,t,n){return e.map((o,s)=>s===t?{...o,note:n}:o)}function kj(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function Bk(e,t){return e.every((n,o)=>!n.required||kj(t[o]))}function yj(e,t){var s;const n=((t==null?void 0:t.selected)??[]).map(a=>{var c;return((c=e.options.find(u=>u.value===a))==null?void 0:c.label)??a}),o=(s=t==null?void 0:t.note)==null?void 0:s.trim();return n.length===0?o||"skipped":o?`${n.join(", ")}: ${o}`:n.join(", ")}function xp(e,t){var n;return((n=e[t])==null?void 0:n.q)??0}function vj(e,t,n){var a;const o=xp(e,t);return((a=e.map((c,u)=>({r:c,i:u})).filter(({r:c})=>c.q===o)[n-1])==null?void 0:a.i)??-1}function wj(e,t){const n=xp(e,t),o=e.findIndex(s=>s.q>n);return o===-1?t:o}const bj=[["↑↓","move"],["⏎","choose"],["⌘⏎","send"],["esc","back to the message box"]],ww={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function xj({item:e}){return e.ask.kind==="question"?h.jsx(_j,{item:e,ask:e.ask}):h.jsx(Ej,{item:e,ask:e.ask})}function bw(e){const t=O.useRef(null);return O.useEffect(()=>{if(!e)return;const n=requestAnimationFrame(()=>{var o,s;(o=t.current)==null||o.focus(),(s=t.current)==null||s.scrollIntoView({block:"nearest"})});return()=>cancelAnimationFrame(n)},[e]),t}function xw(e){var t,n;(t=e.current)==null||t.blur(),(n=document.querySelector(".composer textarea"))==null||n.focus()}function _j({item:e,ask:t}){const n=!e.outcome,o=bw(n),s=nt(),a=z(M=>M.activeId),{message:c,questions:u}=t,d=O.useMemo(()=>pj(u),[u]),[p,m]=O.useState(()=>mj(u)),[g,k]=O.useState(null),w=bp({results:d,keyOf:hj,q:"",listRef:o,onPick:M=>b(M)}),b=M=>{const $=u[M.q];$&&(m(D=>Uk(D,M,!!$.multi)),$.multi||w.setIndex(wj(d,d.indexOf(M))))},_=M=>{!a||!n||s==null||s.send({t:"agent-answer",worktreeId:a,askId:e.id,...M?{answers:M}:{}})},I=()=>{Bk(u,p)&&_(p)};if(!n)return h.jsx(Sj,{item:e,lead:c,questions:u});const C=xp(d,w.index),E=u[C],Z=M=>{var $;if(!(M.target instanceof HTMLTextAreaElement)){if(M.key==="Escape")return M.preventDefault(),M.stopPropagation(),xw(o);if((M.key==="Enter"||M.key==="NumpadEnter")&&(M.metaKey||M.ctrlKey))return M.preventDefault(),I();if(M.key==="Enter"&&w.active){M.preventDefault(),b(w.active),u.length===1&&!(($=u[0])!=null&&$.multi)&&g===null&&_(Uk(p,w.active,!1));return}if(M.key===" "&&(E!=null&&E.multi)&&w.active)return M.preventDefault(),b(w.active);if(M.key==="n"&&(E!=null&&E.note))return M.preventDefault(),k(C);if(M.key==="s")return M.preventDefault(),_();if(M.key>="1"&&M.key<="9"){const D=vj(d,w.index,Number(M.key));return D===-1?void 0:(M.preventDefault(),w.setIndex(D),b(d[D]))}w.onKeyDown(M)}};return h.jsxs("fieldset",{ref:o,className:"ask-card",tabIndex:-1,onKeyDown:Z,children:[h.jsx("div",{className:"ask-lead",children:c}),u.map((M,$)=>{var D,q,J,se;return h.jsxs("div",{className:"ask-block",children:[M.header&&h.jsx("div",{className:"ask-header",children:M.header}),M.text&&M.text!==c&&h.jsx("div",{className:"ask-text",children:M.text}),h.jsx("div",{className:"ask-options",children:M.options.map((me,Oe)=>{var Y;const ae=d.findIndex(de=>de.q===$&&de.option.value===me.value),ie=(Y=p[$])==null?void 0:Y.selected.includes(me.value);return h.jsxs("button",{type:"button",className:"picker-item picker-row ask-opt row-edge","data-state":Rr({cursor:ae===w.index,checked:ie}),onMouseMove:()=>ae!==w.index&&w.setIndex(ae),onClick:()=>{var de;w.setIndex(ae),b(d[ae]),(de=o.current)==null||de.focus()},children:[h.jsx(Or,{k:String(Oe+1),className:"ask-num row-dim"}),h.jsx("span",{className:"picker-name",children:me.label}),me.description&&h.jsx("span",{className:"picker-desc row-dim",children:me.description})]},me.value)})}),((D=w.active)==null?void 0:D.q)===$&&w.active.option.preview&&h.jsx("pre",{className:"ask-preview",children:w.active.option.preview}),M.note&&g!==$&&h.jsxs(De,{tone:"quiet",onClick:()=>k($),children:[h.jsx(Or,{k:"n",chip:!0}),(J=(q=p[$])==null?void 0:q.note)!=null&&J.trim()?"edit your note":"add a note"]}),M.note&&g===$&&h.jsx(Pa,{font:"ui",className:"ask-note",autoFocus:!0,rows:2,placeholder:`${M.note.label}: goes to the agent with your pick`,value:((se=p[$])==null?void 0:se.note)??"",onChange:me=>m(Oe=>gj(Oe,$,me.target.value)),onKeyDown:me=>{var Oe;me.key==="Escape"?(me.preventDefault(),me.stopPropagation(),k(null),(Oe=o.current)==null||Oe.focus()):me.key==="Enter"&&!me.shiftKey&&(me.preventDefault(),I())}})]},M.id)}),h.jsxs("div",{className:"ask-foot",children:[h.jsx(De,{variant:"outline",size:"md",disabled:!Bk(u,p),onClick:I,children:"send"}),h.jsxs(De,{tone:"quiet",size:"md",onClick:()=>_(),children:[h.jsx(Or,{k:"s",chip:!0}),"skip"]})]}),h.jsx(vp,{hints:bj,className:"ask-keys"})]})}function Ej({item:e,ask:t}){const n=!e.outcome,o=bw(n),s=nt(),a=z(m=>m.activeId),c=O.useMemo(()=>t.detail?lw.sanitize(jt.parse(t.detail,{async:!1})):"",[t.detail]),u=m=>{a&&n&&(s==null||s.send({t:"agent-decide",worktreeId:a,askId:e.id,choiceId:m}))},d=t.choices.find(m=>m.id===e.choiceId),p=m=>{if(m.key==="Escape")return m.preventDefault(),m.stopPropagation(),xw(o);if(m.key>="1"&&m.key<="9"){const g=t.choices[Number(m.key)-1];if(!g)return;m.preventDefault(),u(g.id)}};return h.jsxs("fieldset",{ref:o,className:`ask-card ${n?"":"done"}`,tabIndex:-1,onKeyDown:p,children:[h.jsx("div",{className:"ask-lead",children:t.title}),c&&h.jsx("div",{className:"ask-detail md",dangerouslySetInnerHTML:{__html:c}}),n?h.jsx("div",{className:"ask-options",children:t.choices.map((m,g)=>h.jsxs("button",{type:"button",className:`picker-item picker-row ask-opt row-edge ${m.kind.startsWith("reject")?"deny":""}`,onClick:()=>u(m.id),children:[h.jsx(Or,{k:String(g+1),className:"ask-num row-dim"}),h.jsx("span",{className:"picker-name",children:m.name})]},m.id))}):h.jsx("div",{className:"ask-answered",children:d?d.name:ww[e.outcome??""]??"closed"})]})}function Sj({item:e,lead:t,questions:n}){const o=ww[e.outcome??""];return h.jsxs("div",{children:[h.jsx("div",{className:"ask-lead",children:t}),o?h.jsx("div",{className:"ask-answered",children:o}):n.map((s,a)=>{var c;return h.jsxs("div",{className:"ask-answered",children:[s.header&&h.jsx("span",{className:"ask-header",children:s.header}),yj(s,(c=e.answers)==null?void 0:c[a])]},s.id)})]})}const Nj={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},Zk={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},Tj={grep:"search",rg:"search",ag:"search",ack:"search",find:"search",fd:"search",cat:"book",head:"book",tail:"book",less:"book",bat:"book",ls:"folder",tree:"folder",mkdir:"folder",rm:"trash",rmdir:"trash",mv:"move",curl:"globe",wget:"globe",git:"branch"};function Ij(e){const t=e.trim().split(/\s+/)[0]??"";return Tj[t.slice(t.lastIndexOf("/")+1)]}function Co(e,t){const n=e.input,o=n?n[t]:void 0;return typeof o=="string"?o:""}function Hc(e,t=[]){const n=Co(e,"command"),s=Ew(e)||n||Co(e,"path")||Co(e,"pattern")||(e.title&&e.title!==e.name?e.title:""),a=_p(Co(e,"description")||s,t),c=e.toolKind&&e.toolKind in Zk?e.toolKind:"other",u=Nj[c],d=a&&e.name===e.title?"":e.name,p=d&&d.toLowerCase()!==u?d:a?"":u,m=(c==="execute"||c==="other")&&n?Ij(n):void 0;return{label:u,name:p,icon:m??Zk[c],hint:a===p?"":a,command:n&&n!==a?n:""}}function _w(e,t){const n=Sw(t),o=n[0],s=Co(e,"description");return s&&o&&!o.code&&o.text===s?n.slice(1):n}function Wc(e){return Ew(e)||Co(e,"path")}function Ew(e){return Co(e,"file_path")||Co(e,"filepath")||Co(e,"filePath")}function _p(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 Oj=/^```([\w+#.-]*)\s*$/;function Sw(e){const t=[];let n=[],o="",s=!1;const a=()=>{const c=n.join(`
166
- `).replace(/^\n+|\n+$/g,"");c.trim()&&t.push({code:s,diff:Rj(c,o),lang:s?o:"",text:c}),n=[]};for(const c of e.split(`
167
- `)){const u=Oj.exec(c);if(!u){n.push(c);continue}a(),s=!s,o=s?(u[1]??"").toLowerCase():""}return a(),t}function Rj(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const Cj=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function jj(e){const t=[];for(const n of e.split(`
168
- `)){const o=$j(n);if(o==="meta"&&!n.startsWith("diff --git "))continue;const s=o==="add"||o==="del"||n.startsWith(" ");t.push({kind:o,text:s?n.slice(1):n})}return Aj(t),t}function Aj(e){var t,n,o,s;for(let a=0;a<e.length;){if(((t=e[a])==null?void 0:t.kind)!=="del"&&((n=e[a])==null?void 0:n.kind)!=="add"){a++;continue}let c=a;for(;((o=e[c])==null?void 0:o.kind)==="del";)c++;let u=c;for(;((s=e[u])==null?void 0:s.kind)==="add";)u++;const d=e.slice(a,c),p=e.slice(c,u),m=d.length>0&&p.length>0?c1(d.map(g=>g.text).join(`
169
- `),p.map(g=>g.text).join(`
170
- `)):null;m&&(Hk(d,ng(m.before)),Hk(p,ng(m.after)));for(const g of[...d,...p])g.spans??(g.spans=[]);a=u}}function Hk(e,t){if(t.length===e.length)for(const[n,o]of e.entries())o.spans=t[n]}function $j(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||Cj.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}const Mj=new Set(["read","edit"]);function Pj(e,t){if(e.isError||!e.toolKind||!Mj.has(e.toolKind))return"";const{hint:n}=Hc(e,t);return n?`${e.parentToolId??""}
171
- ${e.toolKind}
172
- ${e.name}
173
- ${n}`:""}const Lj=5,zj=new Map;function Dj(e){const t=new Map;for(const n of e)n.kind!=="tool"||!n.parentToolId||t.has(n.parentToolId)||t.set(n.parentToolId,t.size%Lj);return t.size>1?t:zj}function Fj(e,t){const n=[];let o="";for(const[s,a]of e.entries()){if(a.kind!=="tool"){o="",n.push({at:s,item:a});continue}const c=Pj(a,t),u=n.at(-1);if(c&&c===o&&u&&"tools"in u){u.tools.push(a);continue}o=c,n.push({at:s,tools:[a]})}return n}function Uj(e,t){return e.length===t.length&&e.every((n,o)=>n===t[o])}function Bj(e){var t;for(let n=e.length-1;n>=0;n--){const o=e[n];if("tools"in o){if(((t=o.tools[0])==null?void 0:t.toolKind)==="think")return n;continue}if(o.item.kind==="thinking"){if(o.item.text.trim())return n;continue}if(Zj(o.item))return-1}return-1}function Zj(e){return e.kind==="assistant"?!!e.text.trim():!0}const Hj=new Set(y1),Wj=2*1024*1024;function Kj(e){if(!e)return[];const t=[];for(const n of Array.from(e.items??[])){if(n.kind!=="file"||!n.type.startsWith("image/"))continue;const o=n.getAsFile();o&&t.push(o)}if(t.length===0)for(const n of Array.from(e.files??[]))n.type.startsWith("image/")&&t.push(n);return t}function Vj(e){if(!e)return[];const t=[];for(const n of Array.from(e.items??[])){if(n.kind!=="file"||n.type.startsWith("image/"))continue;const o=n.getAsFile();o&&t.push(o)}if(t.length===0)for(const n of Array.from(e.files??[]))n.type.startsWith("image/")||t.push(n);return t}async function Gj(e){if(e.size>Wj)return null;try{return new TextDecoder("utf-8",{fatal:!0}).decode(await e.arrayBuffer())}catch{return null}}async function qj(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function Yj(e){let t="";const n=new Uint8Array(e);for(let o=0;o<n.length;o+=32768)t+=String.fromCharCode(...n.subarray(o,o+32768));return btoa(t)}function Wk(e,t,n){const o=document.createElement("canvas");return o.width=Math.max(1,Math.round(e.width*t)),o.height=Math.max(1,Math.round(e.height*t)),o.getContext("2d").drawImage(e,0,0,o.width,o.height),new Promise((s,a)=>o.toBlob(c=>c?s(c):a(new Error("could not encode image")),n,.9))}let Qj=0;async function Xj(e){const t=await qj(e);try{const n=Math.max(t.width,t.height);let o=e,s=e.type,a=t.width,c=t.height;if(!Hj.has(s)||n>rg||e.size>Sd){const u=s==="image/jpeg"?"image/jpeg":"image/png";let d=Math.min(1,rg/n);for(o=await Wk(t,d,u);o.size>Sd&&d>.1;)d*=.7,o=await Wk(t,d,u);if(o.size>Sd)throw new Error(`${e.name||"image"}: too large even after downscaling`);s=u,a=Math.max(1,Math.round(t.width*d)),c=Math.max(1,Math.round(t.height*d))}return{kind:"image",key:`img${++Qj}`,name:e.name||`pasted.${s==="image/jpeg"?"jpg":"png"}`,mimeType:s,data:Yj(await o.arrayBuffer()),width:a,height:c,bytes:o.size}}finally{t.close()}}function Jj(e){return`data:${e.mimeType};base64,${e.data}`}function eA(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function Nw({src:e,n:t,name:n,width:o,height:s,bytes:a,onRemove:c,className:u=""}){const d=h.jsxs(h.Fragment,{children:[h.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),h.jsxs("span",{className:"pick-target",children:[h.jsx("b",{children:vy("image",t)}),h.jsxs("span",{className:"pick-file",children:[" ","· ",n," · ",o,"×",s," · ",eA(a)]})]})]});return h.jsxs("div",{className:ot("pick-chip image-chip",u),"data-tip":c?void 0:"Open full size",children:[c?d:h.jsx("a",{className:"image-link",href:e,target:"_blank",rel:"noreferrer",children:d}),c&&h.jsx(Kt,{icon:"close",label:"Remove image",tone:"quiet",onClick:c})]})}function tA({img:e,src:t}){return h.jsx(Nw,{className:"in-chat",src:t,...e})}function nA(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:oA(e.map(t=>t[0].text))}const rA=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function oA(e,t=3){let n=[];for(const o of e){const s=iA(o);if(!s)return null;const a=sA(n,s);if(!a)return null;n=a}return n.some(o=>o.kind!=="same")?aA(n,t):null}function iA(e){const t=[];let n=null;for(const o of e.split(`
174
- `)){const s=rA.exec(o);if(s){n={oldStart:Number(s[1]),newStart:Number(s[2]),ops:[]},t.push(n);continue}if(!n)return null;const a=o[0];if(a===" "||a==="-"||a==="+")n.ops.push({mark:a,text:o.slice(1)});else if(o==="")n.ops.push({mark:" ",text:""});else return null}return t.length>0?t:null}function sA(e,t){const n=[];let o=0,s=0,a=0,c=0;const u=m=>{m.kind==="same"?s=m.a-m.c:m.kind==="add"?s-=1:s+=1},d=()=>{for(;o<e.length&&e[o].kind==="del";)n.push(e[o]),u(e[o]),o++},p=m=>{for(let g=m;g<e.length;g++){const k=e[g];if(k.kind!=="del")return k.c}return Number.POSITIVE_INFINITY};for(const m of t){if(m.oldStart<=c)return null;for(;o<e.length;){const w=e[o];if((w.kind==="del"?p(o):w.c)>=m.oldStart)break;n.push(w.kind==="del"?w:{...w,c:w.c+a}),u(w),o++}let g=m.oldStart,k=m.newStart;for(const w of m.ops){if(d(),w.mark==="+"){n.push({kind:"add",c:k,text:w.text}),k++;continue}const b=e[o],_=b&&b.kind!=="del"&&b.c===g?b:void 0;if(_){if(_.text!==w.text)return null;o++,u(_),w.mark===" "?n.push({..._,c:k}):_.kind==="same"&&n.push({kind:"del",a:_.a,text:_.text})}else w.mark===" "?n.push({kind:"same",a:g+s,c:k,text:w.text}):n.push({kind:"del",a:g+s,text:w.text});w.mark===" "&&k++,g++}a=k-g,c=g-1}for(;o<e.length;o++){const m=e[o];n.push(m.kind==="del"?m:{...m,c:m.c+a})}return n}function aA(e,t){const n=[];for(const o of cA(e))for(const[s,a]of uA(o.rows,t)){const c=lA(o.rows.slice(s,a)),u=c.filter(g=>g.kind!=="add").length,d=c.filter(g=>g.kind!=="del").length,p=c.find(g=>g.kind!=="add"),m=c.find(g=>g.kind!=="del");n.push(`@@ -${p?p.a:o.oldAt[s]},${u} +${m?m.c:o.newAt[s]},${d} @@`,...c.map(g=>`${g.kind==="add"?"+":g.kind==="del"?"-":" "}${g.text}`))}return n.join(`
175
- `)}function lA(e){const t=[];for(let n=0;n<e.length;){if(e[n].kind==="same"){t.push(e[n]),n++;continue}let o=n;for(;o<e.length&&e[o].kind!=="same";)o++;const s=e.slice(n,o);t.push(...s.filter(a=>a.kind==="del"),...s.filter(a=>a.kind==="add")),n=o}return t}function cA(e){const t=[];let n=null,o=1,s=1;for(const a of e){const c=a.kind==="add"?o:a.a,u=a.kind==="del"?s:a.c;(!n||c!==o||u!==s)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(a),n.oldAt.push(c),n.newAt.push(u),o=c+(a.kind==="add"?0:1),s=u+(a.kind==="del"?0:1)}return t}function uA(e,t){const n=[];let o=0;for(;o<e.length;){if(e[o].kind==="same"){o++;continue}let s=o,a=o;for(;a<e.length;){if(e[a].kind!=="same"){s=a,a++;continue}let c=0;for(;a+c<e.length&&e[a+c].kind==="same";)c++;if(c>t*2||a+c>=e.length)break;a+=c}n.push([Math.max(0,o-t),Math.min(e.length,s+t+1)]),o=s+t+1}return n}function Tw({n:e,name:t,source:n,lines:o,chars:s,preview:a,href:c,onRemove:u,className:d=""}){const p=n!=null&&n.path.includes("/")?n.path.slice(0,n.path.lastIndexOf("/")):"",m=n?[p,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[`${o} ${o===1?"line":"lines"}`,`${s.toLocaleString()} chars`,a].filter(Boolean).join(" · "),g=h.jsxs(h.Fragment,{children:[h.jsx(Ct,{name:"text",className:"icon-inline"}),h.jsxs("span",{className:"pick-target",children:[h.jsx("b",{children:t??(n?I1(n):vy("paste",e))}),m&&h.jsxs("span",{className:"pick-file",children:[" · ",m]})]})]});return h.jsxs("div",{className:ot("pick-chip paste-chip",d),"data-tip":a||void 0,children:[c?h.jsx("a",{className:"image-link",href:c,target:"_blank",rel:"noreferrer",children:g}):g,u&&h.jsx(Kt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:u})]})}function Iw({pick:e,dir:t,tipText:n,onHover:o,onOpen:s,onRemove:a,className:c=""}){const u=e.callFile,d=e.file,p=u?{path:u,line:e.callLine}:d?{path:d,line:e.line}:null,m=u&&d?{path:d,line:e.line}:null,g=(_,I)=>`${_}${I?`:${I}`:""}`,k=_=>_.split("/").pop()??_,w=(_,I,C,E)=>s?h.jsx("button",{className:"pick-open","data-tip":E,onClick:()=>s(_,I??1),children:C}):C,b=nn("chat");return h.jsxs("div",{className:ot("pick-chip",c),"data-tip":n,onMouseEnter:()=>o==null?void 0:o(!0),onMouseLeave:()=>o==null?void 0:o(!1),...b.contextMenu(()=>lj(e,{dir:t,remove:a})),children:[h.jsxs("span",{className:"pick-target",children:[h.jsx(Ct,{name:"pick",className:"icon-inline"})," ",Jf(e),p&&h.jsxs("span",{className:"pick-file",children:[" ","· ",w(p.path,p.line,g(k(p.path),p.line),`Open ${g(p.path,p.line)}`)]}),m&&h.jsxs("span",{className:"pick-file",children:[" ","·"," ",w(m.path,m.line,g(m.path.split("/").pop()??m.path,m.line),`Open the component: ${g(m.path,m.line)}`)]})]}),a&&h.jsx(Kt,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:a})]})}function dA(e){const t=e.regex,n={},o={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},o]});const s={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),c={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},u={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,s]};s.contains.push(u);const d={match:/\\"/},p={className:"string",begin:/'/,end:/'/},m={match:/\\'/},g={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},k=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],w=e.SHEBANG({binary:`(${k.join("|")})`,relevance:10}),b={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},_=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],I=["true","false"],C={match:/(\/[a-z._-]+)+/},E=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],Z=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],M=["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:_,literal:I,built_in:[...E,...Z,"set","shopt",...M,...$]},contains:[w,e.SHEBANG(),b,g,a,c,C,u,d,p,m,n]}}const fA=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_-]*/}}),pA=["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"],hA=["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"],mA=[...pA,...hA],gA=["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(),kA=["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(),yA=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),vA=["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 wA(e){const t=e.regex,n=fA(e),o={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",a=/@-?\w[\w]*(-\w+)*/,c="[a-zA-Z-][a-zA-Z0-9_-]*",u=[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,o,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+c,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+kA.join("|")+")"},{begin:":(:)?("+yA.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+vA.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...u,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...u,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:a},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:gA.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+mA.join("|")+")\\b"}]}}function bA(e){const a={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:a,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:a,illegal:/["']/}]}]}}function xA(e){const t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},o=e.COMMENT();o.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const s={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},a={className:"literal",begin:/\bon|off|true|false|yes|no\b/},c={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},u={begin:/\[/,end:/\]/,contains:[o,a,s,c,n,"self"],relevance:0},d=/[A-Za-z0-9_-]+/,p=/"(\\"|[^"])*"/,m=/'[^']*'/,g=t.either(d,p,m),k=t.concat(g,"(\\s*\\.\\s*",g,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[o,{className:"section",begin:/\[+/,end:/\]+/},{begin:k,className:"attr",starts:{end:/$/,contains:[o,u,a,s,c,n]}}]}}const Kk="[A-Za-z$_][0-9A-Za-z$_]*",_A=["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"],EA=["true","false","null","undefined","NaN","Infinity"],Ow=["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"],Rw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Cw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],SA=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],NA=[].concat(Cw,Ow,Rw);function TA(e){const t=e.regex,n=(X,{after:ce})=>{const ee="</"+X[0].slice(1);return X.input.indexOf(ee,ce)!==-1},o=Kk,s={begin:"<>",end:"</>"},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(X,ce)=>{const ee=X[0].length+X.index,j=X.input[ee];if(j==="<"||j===","){ce.ignoreMatch();return}j===">"&&(n(X,{after:ee})||ce.ignoreMatch());let Q;const Ie=X.input.substring(ee);if(Q=Ie.match(/^\s*=/)){ce.ignoreMatch();return}if((Q=Ie.match(/^\s+extends\s+/))&&Q.index===0){ce.ignoreMatch();return}}},u={$pattern:Kk,keyword:_A,literal:EA,built_in:NA,"variable.language":SA},d="[0-9](_?[0-9])*",p=`\\.(${d})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${m})((${p})|\\.)?|(${p}))[eE][+-]?(${d})\\b`},{begin:`\\b(${m})\\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},k={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"css"}},_={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"graphql"}},I={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,k]},E={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:o+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},Z=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,b,_,I,{match:/\$\d+/},g];k.contains=Z.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(Z)});const M=[].concat(E,k.contains),$=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(M)}]),D={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:$},q={variants:[{match:[/class/,/\s+/,o,/\s+/,/extends/,/\s+/,t.concat(o,"(",t.concat(/\./,o),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,o],scope:{1:"keyword",3:"title.class"}}]},J={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:{_:[...Ow,...Rw]}},se={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},me={variants:[{match:[/function/,/\s+/,o,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[D],illegal:/%/},Oe={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function ae(X){return t.concat("(?!",X.join("|"),")")}const ie={match:t.concat(/\b/,ae([...Cw,"super","import","await"].map(X=>`${X}\\s*\\(`)),o,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},Y={begin:t.concat(/\./,t.lookahead(t.concat(o,/(?![0-9A-Za-z$_(])/))),end:o,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},de={match:[/get|set/,/\s+/,o,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},D]},ge="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Ee={match:[/const|var|let/,/\s+/,o,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ge)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[D]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:J},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),se,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,b,_,I,E,{match:/\$\d+/},g,J,{scope:"attr",match:o+t.lookahead(":"),relevance:0},Ee,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,e.REGEXP_MODE,{className:"function",begin:ge,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:u,contains:$}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:a},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},me,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[D,e.inherit(e.TITLE_MODE,{begin:o,className:"title.function"})]},{match:/\.\.\./,relevance:0},Y,{match:"\\$"+o,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[D]},ie,Oe,q,de,{match:/\$[(.]/}]}}const IA="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",OA={scope:"number",match:IA,relevance:0};function RA(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},o=["true","false","null"],s={scope:"literal",beginKeywords:o.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:o},contains:[t,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,s,OA,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function CA(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},o={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},s={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}]},a={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},c={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,d={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,u,/:\/\/.*?\)/),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}/}]},m={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(p,{contains:[]}),k=e.inherit(m,{contains:[]});p.contains.push(k),m.contains.push(g);let w=[n,d];return[p,m,g,k].forEach(C=>{C.contains=C.contains.concat(w)}),w=w.concat(p,m),{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,a,o,p,m,{className:"quote",begin:"^>\\s+",contains:w,end:"$"},s,d,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function jA(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),o=["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"],u={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:o,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"]},d={className:"meta",begin:/^(>>>|\.\.\.) /},p={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},m={begin:/\{\{/,relevance:0},g={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,d,m,p]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d,m,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,m,p]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,m,p]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},k="[0-9](_?[0-9])*",w=`(\\b(${k}))?\\.(${k})|\\b(${k})\\.`,b=`\\b|${o.join("|")}`,_={className:"number",relevance:0,variants:[{begin:`(\\b(${k})|(${w}))[eE][+-]?(${k})[jJ]?(?=${b})`},{begin:`(${w})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${b})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${b})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${b})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${b})`},{begin:`\\b(${k})[jJ](?=${b})`}]},I={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},C={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",d,_,g,e.HASH_COMMENT_MODE]}]};return p.contains=[g,_,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[d,_,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,I,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[C]},{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:[_,C,g]}]}}function AA(e){const t=e.regex,n=/(r#)?/,o=t.concat(n,e.UNDERSCORE_IDENT_RE),s=t.concat(n,e.IDENT_RE),a={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,s,t.lookahead(/\s*\(/))},c="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",u=["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"],d=["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!"],m=["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:m,keyword:u,literal:d,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_]+)"+c},{begin:"\\b0o([0-7_]+)"+c},{begin:"\\b0x([A-Fa-f0-9_]+)"+c},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+c}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,o],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,o],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,o,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,o],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,o],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:p,type:m}},{scope:"punctuation",begin:"->"},a]}}const gc="[A-Za-z$_][0-9A-Za-z$_]*",jw=["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"],Aw=["true","false","null","undefined","NaN","Infinity"],$w=["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"],Mw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Pw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Lw=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],zw=[].concat(Pw,$w,Mw);function $A(e){const t=e.regex,n=(X,{after:ce})=>{const ee="</"+X[0].slice(1);return X.input.indexOf(ee,ce)!==-1},o=gc,s={begin:"<>",end:"</>"},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(X,ce)=>{const ee=X[0].length+X.index,j=X.input[ee];if(j==="<"||j===","){ce.ignoreMatch();return}j===">"&&(n(X,{after:ee})||ce.ignoreMatch());let Q;const Ie=X.input.substring(ee);if(Q=Ie.match(/^\s*=/)){ce.ignoreMatch();return}if((Q=Ie.match(/^\s+extends\s+/))&&Q.index===0){ce.ignoreMatch();return}}},u={$pattern:gc,keyword:jw,literal:Aw,built_in:zw,"variable.language":Lw},d="[0-9](_?[0-9])*",p=`\\.(${d})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${m})((${p})|\\.)?|(${p}))[eE][+-]?(${d})\\b`},{begin:`\\b(${m})\\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},k={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"css"}},_={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"graphql"}},I={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,k]},E={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:o+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},Z=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,b,_,I,{match:/\$\d+/},g];k.contains=Z.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(Z)});const M=[].concat(E,k.contains),$=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(M)}]),D={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:$},q={variants:[{match:[/class/,/\s+/,o,/\s+/,/extends/,/\s+/,t.concat(o,"(",t.concat(/\./,o),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,o],scope:{1:"keyword",3:"title.class"}}]},J={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:{_:[...$w,...Mw]}},se={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},me={variants:[{match:[/function/,/\s+/,o,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[D],illegal:/%/},Oe={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function ae(X){return t.concat("(?!",X.join("|"),")")}const ie={match:t.concat(/\b/,ae([...Pw,"super","import","await"].map(X=>`${X}\\s*\\(`)),o,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},Y={begin:t.concat(/\./,t.lookahead(t.concat(o,/(?![0-9A-Za-z$_(])/))),end:o,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},de={match:[/get|set/,/\s+/,o,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},D]},ge="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Ee={match:[/const|var|let/,/\s+/,o,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(ge)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[D]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:J},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),se,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,w,b,_,I,E,{match:/\$\d+/},g,J,{scope:"attr",match:o+t.lookahead(":"),relevance:0},Ee,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,e.REGEXP_MODE,{className:"function",begin:ge,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:u,contains:$}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:a},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},me,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[D,e.inherit(e.TITLE_MODE,{begin:o,className:"title.function"})]},{match:/\.\.\./,relevance:0},Y,{match:"\\$"+o,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[D]},ie,Oe,q,de,{match:/\$[(.]/}]}}function MA(e){const t=e.regex,n=$A(e),o=gc,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},c={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},d=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],p={$pattern:gc,keyword:jw.concat(d),literal:Aw,built_in:zw.concat(s),"variable.language":Lw},m={className:"meta",begin:"@"+o},g=(_,I,C)=>{const E=_.contains.findIndex(Z=>Z.label===I);if(E===-1)throw new Error("can not find mode to replace");_.contains.splice(E,1,C)};Object.assign(n.keywords,p),n.exports.PARAMS_CONTAINS.push(m);const k=n.contains.find(_=>_.scope==="attr"),w=Object.assign({},k,{match:t.concat(o,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,k,w]),n.contains=n.contains.concat([m,a,c,w]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",u);const b=n.contains.find(_=>_.label==="func.def");return b.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function PA(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),o=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},c=e.inherit(a,{begin:/\(/,end:/\)/}),u=e.inherit(e.APOS_STRING_MODE,{className:"string"}),d=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),p={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:o,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{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:[a,d,u,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[a,c,d,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[d]},{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 LA(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",o={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},s={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},a={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},c={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,s]},u=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),k={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},w={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},b={begin:/\{/,end:/\}/,contains:[w],illegal:"\\n",relevance:0},_={begin:"\\[",end:"\\]",contains:[w],illegal:"\\n",relevance:0},I=[o,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},k,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},b,_,a,c],C=[...I];return C.pop(),C.push(u),w.contains=C,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:I}}var Gd,Vk;function zA(){if(Vk)return Gd;Vk=1;function e(R){return R instanceof Map?R.clear=R.delete=R.set=function(){throw new Error("map is read-only")}:R instanceof Set&&(R.add=R.clear=R.delete=function(){throw new Error("set is read-only")}),Object.freeze(R),Object.getOwnPropertyNames(R).forEach(ne=>{const ve=R[ne],He=typeof ve;(He==="object"||He==="function")&&!Object.isFrozen(ve)&&e(ve)}),R}class t{constructor(ne){ne.data===void 0&&(ne.data={}),this.data=ne.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(R){return R.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function o(R,...ne){const ve=Object.create(null);for(const He in R)ve[He]=R[He];return ne.forEach(function(He){for(const gt in He)ve[gt]=He[gt]}),ve}const s="</span>",a=R=>!!R.scope,c=(R,{prefix:ne})=>{if(R.startsWith("language:"))return R.replace("language:","language-");if(R.includes(".")){const ve=R.split(".");return[`${ne}${ve.shift()}`,...ve.map((He,gt)=>`${He}${"_".repeat(gt+1)}`)].join(" ")}return`${ne}${R}`};class u{constructor(ne,ve){this.buffer="",this.classPrefix=ve.classPrefix,ne.walk(this)}addText(ne){this.buffer+=n(ne)}openNode(ne){if(!a(ne))return;const ve=c(ne.scope,{prefix:this.classPrefix});this.span(ve)}closeNode(ne){a(ne)&&(this.buffer+=s)}value(){return this.buffer}span(ne){this.buffer+=`<span class="${ne}">`}}const d=(R={})=>{const ne={children:[]};return Object.assign(ne,R),ne};class p{constructor(){this.rootNode=d(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ne){this.top.children.push(ne)}openNode(ne){const ve=d({scope:ne});this.add(ve),this.stack.push(ve)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ne){return this.constructor._walk(ne,this.rootNode)}static _walk(ne,ve){return typeof ve=="string"?ne.addText(ve):ve.children&&(ne.openNode(ve),ve.children.forEach(He=>this._walk(ne,He)),ne.closeNode(ve)),ne}static _collapse(ne){typeof ne!="string"&&ne.children&&(ne.children.every(ve=>typeof ve=="string")?ne.children=[ne.children.join("")]:ne.children.forEach(ve=>{p._collapse(ve)}))}}class m extends p{constructor(ne){super(),this.options=ne}addText(ne){ne!==""&&this.add(ne)}startScope(ne){this.openNode(ne)}endScope(){this.closeNode()}__addSublanguage(ne,ve){const He=ne.root;ve&&(He.scope=`language:${ve}`),this.add(He)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(R){return R?typeof R=="string"?R:R.source:null}function k(R){return _("(?=",R,")")}function w(R){return _("(?:",R,")*")}function b(R){return _("(?:",R,")?")}function _(...R){return R.map(ve=>g(ve)).join("")}function I(R){const ne=R[R.length-1];return typeof ne=="object"&&ne.constructor===Object?(R.splice(R.length-1,1),ne):{}}function C(...R){return"("+(I(R).capture?"":"?:")+R.map(He=>g(He)).join("|")+")"}function E(R){return new RegExp(R.toString()+"|").exec("").length-1}function Z(R,ne){const ve=R&&R.exec(ne);return ve&&ve.index===0}const M=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function $(R,{joinWith:ne}){let ve=0;return R.map(He=>{ve+=1;const gt=ve;let wt=g(He),Se="";for(;wt.length>0;){const Ne=M.exec(wt);if(!Ne){Se+=wt;break}Se+=wt.substring(0,Ne.index),wt=wt.substring(Ne.index+Ne[0].length),Ne[0][0]==="\\"&&Ne[1]?Se+="\\"+String(Number(Ne[1])+gt):(Se+=Ne[0],Ne[0]==="("&&ve++)}return Se}).map(He=>`(${He})`).join(ne)}const D=/\b\B/,q="[a-zA-Z]\\w*",J="[a-zA-Z_]\\w*",se="\\b\\d+(\\.\\d+)?",me="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Oe="\\b(0b[01]+)",ae="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ie=(R={})=>{const ne=/^#![ ]*\//;return R.binary&&(R.begin=_(ne,/.*\b/,R.binary,/\b.*/)),o({scope:"meta",begin:ne,end:/$/,relevance:0,"on:begin":(ve,He)=>{ve.index!==0&&He.ignoreMatch()}},R)},Y={begin:"\\\\[\\s\\S]",relevance:0},de={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Y]},ge={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Y]},Ee={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/},X=function(R,ne,ve={}){const He=o({scope:"comment",begin:R,end:ne,contains:[]},ve);He.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 gt=C("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 He.contains.push({begin:_(/[ ]+/,"(",gt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),He},ce=X("//","$"),ee=X("/\\*","\\*/"),j=X("#","$"),Q={scope:"number",begin:se,relevance:0},Ie={scope:"number",begin:me,relevance:0},xe={scope:"number",begin:Oe,relevance:0},V={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Y,{begin:/\[/,end:/\]/,relevance:0,contains:[Y]}]},be={scope:"title",begin:q,relevance:0},Ae={scope:"title",begin:J,relevance:0},Pe={begin:"\\.\\s*"+J,relevance:0};var F=Object.freeze({__proto__:null,APOS_STRING_MODE:de,BACKSLASH_ESCAPE:Y,BINARY_NUMBER_MODE:xe,BINARY_NUMBER_RE:Oe,COMMENT:X,C_BLOCK_COMMENT_MODE:ee,C_LINE_COMMENT_MODE:ce,C_NUMBER_MODE:Ie,C_NUMBER_RE:me,END_SAME_AS_BEGIN:function(R){return Object.assign(R,{"on:begin":(ne,ve)=>{ve.data._beginMatch=ne[1]},"on:end":(ne,ve)=>{ve.data._beginMatch!==ne[1]&&ve.ignoreMatch()}})},HASH_COMMENT_MODE:j,IDENT_RE:q,MATCH_NOTHING_RE:D,METHOD_GUARD:Pe,NUMBER_MODE:Q,NUMBER_RE:se,PHRASAL_WORDS_MODE:Ee,QUOTE_STRING_MODE:ge,REGEXP_MODE:V,RE_STARTERS_RE:ae,SHEBANG:ie,TITLE_MODE:be,UNDERSCORE_IDENT_RE:J,UNDERSCORE_TITLE_MODE:Ae});function Te(R,ne){R.input[R.index-1]==="."&&ne.ignoreMatch()}function lt(R,ne){R.className!==void 0&&(R.scope=R.className,delete R.className)}function Pt(R,ne){ne&&R.beginKeywords&&(R.begin="\\b("+R.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",R.__beforeBegin=Te,R.keywords=R.keywords||R.beginKeywords,delete R.beginKeywords,R.relevance===void 0&&(R.relevance=0))}function Ye(R,ne){Array.isArray(R.illegal)&&(R.illegal=C(...R.illegal))}function Ge(R,ne){if(R.match){if(R.begin||R.end)throw new Error("begin & end are not supported with match");R.begin=R.match,delete R.match}}function Ue(R,ne){R.relevance===void 0&&(R.relevance=1)}const At=(R,ne)=>{if(!R.beforeMatch)return;if(R.starts)throw new Error("beforeMatch cannot be used with starts");const ve=Object.assign({},R);Object.keys(R).forEach(He=>{delete R[He]}),R.keywords=ve.keywords,R.begin=_(ve.beforeMatch,k(ve.begin)),R.starts={relevance:0,contains:[Object.assign(ve,{endsParent:!0})]},R.relevance=0,delete ve.beforeMatch},Tt=["of","and","for","in","not","or","if","then","parent","list","value"],ut="keyword";function Vt(R,ne,ve=ut){const He=Object.create(null);return typeof R=="string"?gt(ve,R.split(" ")):Array.isArray(R)?gt(ve,R):Object.keys(R).forEach(function(wt){Object.assign(He,Vt(R[wt],ne,wt))}),He;function gt(wt,Se){ne&&(Se=Se.map(Ne=>Ne.toLowerCase())),Se.forEach(function(Ne){const we=Ne.split("|");He[we[0]]=[wt,K(we[0],we[1])]})}}function K(R,ne){return ne?Number(ne):_e(R)?0:1}function _e(R){return Tt.includes(R.toLowerCase())}const pt={},It=R=>{console.error(R)},vn=(R,...ne)=>{console.log(`WARN: ${R}`,...ne)},vt=(R,ne)=>{pt[`${R}/${ne}`]||(console.log(`Deprecated as of ${R}. ${ne}`),pt[`${R}/${ne}`]=!0)},Gt=new Error;function te(R,ne,{key:ve}){let He=0;const gt=R[ve],wt={},Se={};for(let Ne=1;Ne<=ne.length;Ne++)Se[Ne+He]=gt[Ne],wt[Ne+He]=!0,He+=E(ne[Ne-1]);R[ve]=Se,R[ve]._emit=wt,R[ve]._multi=!0}function Be(R){if(Array.isArray(R.begin)){if(R.skip||R.excludeBegin||R.returnBegin)throw It("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Gt;if(typeof R.beginScope!="object"||R.beginScope===null)throw It("beginScope must be object"),Gt;te(R,R.begin,{key:"beginScope"}),R.begin=$(R.begin,{joinWith:""})}}function mt(R){if(Array.isArray(R.end)){if(R.skip||R.excludeEnd||R.returnEnd)throw It("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Gt;if(typeof R.endScope!="object"||R.endScope===null)throw It("endScope must be object"),Gt;te(R,R.end,{key:"endScope"}),R.end=$(R.end,{joinWith:""})}}function it(R){R.scope&&typeof R.scope=="object"&&R.scope!==null&&(R.beginScope=R.scope,delete R.scope)}function rt(R){it(R),typeof R.beginScope=="string"&&(R.beginScope={_wrap:R.beginScope}),typeof R.endScope=="string"&&(R.endScope={_wrap:R.endScope}),Be(R),mt(R)}function Rn(R){function ne(Se,Ne){return new RegExp(g(Se),"m"+(R.case_insensitive?"i":"")+(R.unicodeRegex?"u":"")+(Ne?"g":""))}class ve{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Ne,we){we.position=this.position++,this.matchIndexes[this.matchAt]=we,this.regexes.push([we,Ne]),this.matchAt+=E(Ne)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Ne=this.regexes.map(we=>we[1]);this.matcherRe=ne($(Ne,{joinWith:"|"}),!0),this.lastIndex=0}exec(Ne){this.matcherRe.lastIndex=this.lastIndex;const we=this.matcherRe.exec(Ne);if(!we)return null;const Rt=we.findIndex((xn,er)=>er>0&&xn!==void 0),Ot=this.matchIndexes[Rt];return we.splice(0,Rt),Object.assign(we,Ot)}}class He{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Ne){if(this.multiRegexes[Ne])return this.multiRegexes[Ne];const we=new ve;return this.rules.slice(Ne).forEach(([Rt,Ot])=>we.addRule(Rt,Ot)),we.compile(),this.multiRegexes[Ne]=we,we}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Ne,we){this.rules.push([Ne,we]),we.type==="begin"&&this.count++}exec(Ne){const we=this.getMatcher(this.regexIndex);we.lastIndex=this.lastIndex;let Rt=we.exec(Ne);if(this.resumingScanAtSamePosition()&&!(Rt&&Rt.index===this.lastIndex)){const Ot=this.getMatcher(0);Ot.lastIndex=this.lastIndex+1,Rt=Ot.exec(Ne)}return Rt&&(this.regexIndex+=Rt.position+1,this.regexIndex===this.count&&this.considerAll()),Rt}}function gt(Se){const Ne=new He;return Se.contains.forEach(we=>Ne.addRule(we.begin,{rule:we,type:"begin"})),Se.terminatorEnd&&Ne.addRule(Se.terminatorEnd,{type:"end"}),Se.illegal&&Ne.addRule(Se.illegal,{type:"illegal"}),Ne}function wt(Se,Ne){const we=Se;if(Se.isCompiled)return we;[lt,Ge,rt,At].forEach(Ot=>Ot(Se,Ne)),R.compilerExtensions.forEach(Ot=>Ot(Se,Ne)),Se.__beforeBegin=null,[Pt,Ye,Ue].forEach(Ot=>Ot(Se,Ne)),Se.isCompiled=!0;let Rt=null;return typeof Se.keywords=="object"&&Se.keywords.$pattern&&(Se.keywords=Object.assign({},Se.keywords),Rt=Se.keywords.$pattern,delete Se.keywords.$pattern),Rt=Rt||/\w+/,Se.keywords&&(Se.keywords=Vt(Se.keywords,R.case_insensitive)),we.keywordPatternRe=ne(Rt,!0),Ne&&(Se.begin||(Se.begin=/\B|\b/),we.beginRe=ne(we.begin),!Se.end&&!Se.endsWithParent&&(Se.end=/\B|\b/),Se.end&&(we.endRe=ne(we.end)),we.terminatorEnd=g(we.end)||"",Se.endsWithParent&&Ne.terminatorEnd&&(we.terminatorEnd+=(Se.end?"|":"")+Ne.terminatorEnd)),Se.illegal&&(we.illegalRe=ne(Se.illegal)),Se.contains||(Se.contains=[]),Se.contains=[].concat(...Se.contains.map(function(Ot){return wn(Ot==="self"?Se:Ot)})),Se.contains.forEach(function(Ot){wt(Ot,we)}),Se.starts&&wt(Se.starts,Ne),we.matcher=gt(we),we}if(R.compilerExtensions||(R.compilerExtensions=[]),R.contains&&R.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return R.classNameAliases=o(R.classNameAliases||{}),wt(R)}function Xe(R){return R?R.endsWithParent||Xe(R.starts):!1}function wn(R){return R.variants&&!R.cachedVariants&&(R.cachedVariants=R.variants.map(function(ne){return o(R,{variants:null},ne)})),R.cachedVariants?R.cachedVariants:Xe(R)?o(R,{starts:R.starts?o(R.starts):null}):Object.isFrozen(R)?o(R):R}var Lt="11.11.2";class xr extends Error{constructor(ne,ve){super(ne),this.name="HTMLInjectionError",this.html=ve}}const hn=n,Dn=o,Zt=Symbol("nomatch"),Fn=7,bn=function(R){const ne=Object.create(null),ve=Object.create(null),He=[];let gt=!0;const wt="Could not find the language '{}', did you forget to load/include a language module?",Se={disableAutodetect:!0,name:"Plain text",contains:[]};let Ne={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:m};function we(pe){return Ne.noHighlightRe.test(pe)}function Rt(pe){let Re=pe.className+" ";Re+=pe.parentNode?pe.parentNode.className:"";const et=Ne.languageDetectRe.exec(Re);if(et){const Qe=_n(et[1]);return Qe||(vn(wt.replace("{}",et[1])),vn("Falling back to no-highlight mode for this block.",pe)),Qe?et[1]:"no-highlight"}return Re.split(/\s+/).find(Qe=>we(Qe)||_n(Qe))}function Ot(pe,Re,et){let Qe="",zt="";typeof Re=="object"?(Qe=pe,et=Re.ignoreIllegals,zt=Re.language):(vt("10.7.0","highlight(lang, code, ...args) has been deprecated."),vt("10.7.0",`Please use highlight(code, options) instead.
176
- https://github.com/highlightjs/highlight.js/issues/2277`),zt=pe,Qe=Re),et===void 0&&(et=!0);const Dt={code:Qe,language:zt};En("before:highlight",Dt);const nr=Dt.result?Dt.result:xn(Dt.language,Dt.code,et);return nr.code=Dt.code,En("after:highlight",nr),nr}function xn(pe,Re,et,Qe){const zt=Object.create(null);function Dt(N,U){return N.keywords[U]}function nr(){if(!Ve.keywords){sn.addText(_t);return}let N=0;Ve.keywordPatternRe.lastIndex=0;let U=Ve.keywordPatternRe.exec(_t),oe="";for(;U;){oe+=_t.substring(N,U.index);const ke=rr.case_insensitive?U[0].toLowerCase():U[0],Ce=Dt(Ve,ke);if(Ce){const[Je,Ut]=Ce;if(sn.addText(oe),oe="",zt[ke]=(zt[ke]||0)+1,zt[ke]<=Fn&&(Pr+=Ut),Je.startsWith("_"))oe+=U[0];else{const Sn=rr.classNameAliases[Je]||Je;L(U[0],Sn)}}else oe+=U[0];N=Ve.keywordPatternRe.lastIndex,U=Ve.keywordPatternRe.exec(_t)}oe+=_t.substring(N),sn.addText(oe)}function Mr(){if(_t==="")return;let N=null;if(typeof Ve.subLanguage=="string"){if(!ne[Ve.subLanguage]){sn.addText(_t);return}N=xn(Ve.subLanguage,_t,!0,ci[Ve.subLanguage]),ci[Ve.subLanguage]=N._top}else N=Cn(_t,Ve.subLanguage.length?Ve.subLanguage:null);Ve.relevance>0&&(Pr+=N.relevance),sn.__addSublanguage(N._emitter,N.language)}function rn(){Ve.subLanguage!=null?Mr():nr(),_t=""}function L(N,U){N!==""&&(sn.startScope(U),sn.addText(N),sn.endScope())}function Ze(N,U){let oe=1;const ke=U.length-1;for(;oe<=ke;){if(!N._emit[oe]){oe++;continue}const Ce=rr.classNameAliases[N[oe]]||N[oe],Je=U[oe];Ce?L(Je,Ce):(_t=Je,nr(),_t=""),oe++}}function tt(N,U){return N.scope&&typeof N.scope=="string"&&sn.openNode(rr.classNameAliases[N.scope]||N.scope),N.beginScope&&(N.beginScope._wrap?(L(_t,rr.classNameAliases[N.beginScope._wrap]||N.beginScope._wrap),_t=""):N.beginScope._multi&&(Ze(N.beginScope,U),_t="")),Ve=Object.create(N,{parent:{value:Ve}}),Ve}function Ft(N,U,oe){let ke=Z(N.endRe,oe);if(ke){if(N["on:end"]){const Ce=new t(N);N["on:end"](U,Ce),Ce.isMatchIgnored&&(ke=!1)}if(ke){for(;N.endsParent&&N.parent;)N=N.parent;return N}}if(N.endsWithParent)return Ft(N.parent,U,oe)}function on(N){return Ve.matcher.regexIndex===0?(_t+=N[0],1):(S=!0,0)}function xo(N){const U=N[0],oe=N.rule,ke=new t(oe),Ce=[oe.__beforeBegin,oe["on:begin"]];for(const Je of Ce)if(Je&&(Je(N,ke),ke.isMatchIgnored))return on(U);return oe.skip?_t+=U:(oe.excludeBegin&&(_t+=U),rn(),!oe.returnBegin&&!oe.excludeBegin&&(_t=U)),tt(oe,N),oe.returnBegin?0:U.length}function po(N){const U=N[0],oe=Re.substring(N.index),ke=Ft(Ve,N,oe);if(!ke)return Zt;const Ce=Ve;Ve.endScope&&Ve.endScope._wrap?(rn(),L(U,Ve.endScope._wrap)):Ve.endScope&&Ve.endScope._multi?(rn(),Ze(Ve.endScope,N)):Ce.skip?_t+=U:(Ce.returnEnd||Ce.excludeEnd||(_t+=U),rn(),Ce.excludeEnd&&(_t=U));do Ve.scope&&sn.closeNode(),!Ve.skip&&!Ve.subLanguage&&(Pr+=Ve.relevance),Ve=Ve.parent;while(Ve!==ke.parent);return ke.starts&&tt(ke.starts,N),Ce.returnEnd?0:U.length}function Li(){const N=[];for(let U=Ve;U!==rr;U=U.parent)U.scope&&N.unshift(U.scope);N.forEach(U=>sn.openNode(U))}let Gr={};function qr(N,U){const oe=U&&U[0];if(_t+=N,oe==null)return rn(),0;if(Gr.type==="begin"&&U.type==="end"&&Gr.index===U.index&&oe===""){if(_t+=Re.slice(U.index,U.index+1),!gt){const ke=new Error(`0 width match regex (${pe})`);throw ke.languageName=pe,ke.badRule=Gr.rule,ke}return 1}if(Gr=U,U.type==="begin")return xo(U);if(U.type==="illegal"&&!et){const ke=new Error('Illegal lexeme "'+oe+'" for mode "'+(Ve.scope||"<unnamed>")+'"');throw ke.mode=Ve,ke}else if(U.type==="end"){const ke=po(U);if(ke!==Zt)return ke}if(U.type==="illegal"&&oe==="")return U.index===Re.length||(_t+=`
177
- `),1;if(fe>1e5&&fe>U.index*3)throw new Error("potential infinite loop, way more iterations than matches");return _t+=oe,oe.length}const rr=_n(pe);if(!rr)throw It(wt.replace("{}",pe)),new Error('Unknown language: "'+pe+'"');const Do=Rn(rr);let ht="",Ve=Qe||Do;const ci={},sn=new Ne.__emitter(Ne);Li();let _t="",Pr=0,cr=0,fe=0,S=!1;try{if(rr.__emitTokens)rr.__emitTokens(Re,sn);else{for(Ve.matcher.considerAll();;){fe++,S?S=!1:Ve.matcher.considerAll(),Ve.matcher.lastIndex=cr;const N=Ve.matcher.exec(Re);if(!N)break;const U=Re.substring(cr,N.index),oe=qr(U,N);cr=N.index+oe}qr(Re.substring(cr))}return sn.finalize(),ht=sn.toHTML(),{language:pe,value:ht,relevance:Pr,illegal:!1,_emitter:sn,_top:Ve}}catch(N){if(N.message&&N.message.includes("Illegal"))return{language:pe,value:hn(Re),illegal:!0,relevance:0,_illegalBy:{message:N.message,index:cr,context:Re.slice(cr-100,cr+100),mode:N.mode,resultSoFar:ht},_emitter:sn};if(gt)return{language:pe,value:hn(Re),illegal:!1,relevance:0,errorRaised:N,_emitter:sn,_top:Ve};throw N}}function er(pe){const Re={value:hn(pe),illegal:!1,relevance:0,_top:Se,_emitter:new Ne.__emitter(Ne)};return Re._emitter.addText(pe),Re}function Cn(pe,Re){Re=Re||Ne.languages||Object.keys(ne);const et=er(pe),Qe=Re.filter(_n).filter(mn).map(rn=>xn(rn,pe,!1));Qe.unshift(et);const zt=Qe.sort((rn,L)=>{if(rn.relevance!==L.relevance)return L.relevance-rn.relevance;if(rn.language&&L.language){if(_n(rn.language).supersetOf===L.language)return 1;if(_n(L.language).supersetOf===rn.language)return-1}return 0}),[Dt,nr]=zt,Mr=Dt;return Mr.secondBest=nr,Mr}function Wn(pe,Re,et){const Qe=Re&&ve[Re]||et;pe.classList.add("hljs"),pe.classList.add(`language-${Qe}`)}function Cr(pe){let Re=null;const et=Rt(pe);if(we(et))return;if(En("before:highlightElement",{el:pe,language:et}),pe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",pe);return}if(pe.children.length>0&&(Ne.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(pe)),Ne.throwUnescapedHTML))throw new xr("One of your code blocks includes unescaped HTML.",pe.innerHTML);Re=pe;const Qe=Re.textContent,zt=et?Ot(Qe,{language:et,ignoreIllegals:!0}):Cn(Qe);pe.innerHTML=zt.value,pe.dataset.highlighted="yes",Wn(pe,et,zt.language),pe.result={language:zt.language,re:zt.relevance,relevance:zt.relevance},zt.secondBest&&(pe.secondBest={language:zt.secondBest.language,relevance:zt.secondBest.relevance}),En("after:highlightElement",{el:pe,result:zt,text:Qe})}function jr(pe){Ne=Dn(Ne,pe)}const lr=()=>{tr(),vt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function uo(){tr(),vt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let kt=!1;function tr(){function pe(){tr()}if(document.readyState==="loading"){kt||window.addEventListener("DOMContentLoaded",pe,!1),kt=!0;return}document.querySelectorAll(Ne.cssSelector).forEach(Cr)}function Lo(pe,Re){let et=null;try{et=Re(R)}catch(Qe){if(It("Language definition for '{}' could not be registered.".replace("{}",pe)),gt)It(Qe);else throw Qe;et=Se}et.name||(et.name=pe),ne[pe]=et,et.rawDefinition=Re.bind(null,R),et.aliases&&fo(et.aliases,{languageName:pe})}function Kr(pe){delete ne[pe];for(const Re of Object.keys(ve))ve[Re]===pe&&delete ve[Re]}function Ar(){return Object.keys(ne)}function _n(pe){return pe=(pe||"").toLowerCase(),ne[pe]||ne[ve[pe]]}function fo(pe,{languageName:Re}){typeof pe=="string"&&(pe=[pe]),pe.forEach(et=>{ve[et.toLowerCase()]=Re})}function mn(pe){const Re=_n(pe);return Re&&!Re.disableAutodetect}function $t(pe){pe["before:highlightBlock"]&&!pe["before:highlightElement"]&&(pe["before:highlightElement"]=Re=>{pe["before:highlightBlock"](Object.assign({block:Re.el},Re))}),pe["after:highlightBlock"]&&!pe["after:highlightElement"]&&(pe["after:highlightElement"]=Re=>{pe["after:highlightBlock"](Object.assign({block:Re.el},Re))})}function zo(pe){$t(pe),He.push(pe)}function $r(pe){const Re=He.indexOf(pe);Re!==-1&&He.splice(Re,1)}function En(pe,Re){const et=pe;He.forEach(function(Qe){Qe[et]&&Qe[et](Re)})}function Vr(pe){return vt("10.7.0","highlightBlock will be removed entirely in v12.0"),vt("10.7.0","Please use highlightElement now."),Cr(pe)}Object.assign(R,{highlight:Ot,highlightAuto:Cn,highlightAll:tr,highlightElement:Cr,highlightBlock:Vr,configure:jr,initHighlighting:lr,initHighlightingOnLoad:uo,registerLanguage:Lo,unregisterLanguage:Kr,listLanguages:Ar,getLanguage:_n,registerAliases:fo,autoDetection:mn,inherit:Dn,addPlugin:zo,removePlugin:$r}),R.debugMode=function(){gt=!1},R.safeMode=function(){gt=!0},R.versionString=Lt,R.regex={concat:_,lookahead:k,either:C,optional:b,anyNumberOfTimes:w};for(const pe in F)typeof F[pe]=="object"&&e(F[pe]);return Object.assign(R,F),R},Jn=bn({});return Jn.newInstance=()=>bn({}),Gd=Jn,Jn.HighlightJS=Jn,Jn.default=Jn,Gd}var DA=zA();const FA=ky(DA),Gk={},UA="hljs-";function BA(e){const t=FA.newInstance();return e&&a(e),{highlight:n,highlightAuto:o,listLanguages:s,register:a,registerAlias:c,registered:u};function n(d,p,m){const g=m||Gk,k=typeof g.prefix=="string"?g.prefix:UA;if(!t.getLanguage(d))throw new Error("Unknown language: `"+d+"` is not registered");t.configure({__emitter:ZA,classPrefix:k});const w=t.highlight(p,{ignoreIllegals:!0,language:d});if(w.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:w.errorRaised});const b=w._emitter.root,_=b.data;return _.language=w.language,_.relevance=w.relevance,b}function o(d,p){const g=(p||Gk).subset||s();let k=-1,w=0,b;for(;++k<g.length;){const _=g[k];if(!t.getLanguage(_))continue;const I=n(_,d,p);I.data&&I.data.relevance!==void 0&&I.data.relevance>w&&(w=I.data.relevance,b=I)}return b||{type:"root",children:[],data:{language:void 0,relevance:w}}}function s(){return t.listLanguages()}function a(d,p){if(typeof d=="string")t.registerLanguage(d,p);else{let m;for(m in d)Object.hasOwn(d,m)&&t.registerLanguage(m,d[m])}}function c(d,p){if(typeof d=="string")t.registerAliases(typeof p=="string"?p:[...p],{languageName:d});else{let m;for(m in d)if(Object.hasOwn(d,m)){const g=d[m];t.registerAliases(typeof g=="string"?g:[...g],{languageName:m})}}}function u(d){return!!t.getLanguage(d)}}class ZA{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],o=n.children[n.children.length-1];o&&o.type==="text"?o.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const o=this.stack[this.stack.length-1],s=t.root.children;n?o.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):o.children.push(...s)}openNode(t){const n=this,o=t.split(".").map(function(c,u){return u?c+"_".repeat(u):n.options.classPrefix+c}),s=this.stack[this.stack.length-1],a={type:"element",tagName:"span",properties:{className:o},children:[]};s.children.push(a),this.stack.push(a)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Dw=BA({bash:dA,css:wA,go:bA,ini:xA,javascript:TA,json:RA,markdown:CA,python:jA,rust:AA,typescript:MA,xml:PA,yaml:LA}),qk={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 Fw(e,t){const n=e&&(qk[e]??(Dw.registered(e)?e:null));if(n)return n;const o=t.lastIndexOf("."),s=o<0?"":t.slice(o+1).toLowerCase();return(s?qk[s]:null)??null}const HA=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function WA(e){const t=new Set;for(const n of e.matchAll(HA)){const o=n[1]??n[2]??"";o&&o!=="/dev/null"&&t.add(o)}return t.size===1?[...t][0]:""}const KA={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 Uw(e,t){const n=[[]],o=(a,c)=>{const u=a.split(`
178
- `);for(const[d,p]of u.entries()){if(d>0&&n.push([]),!p)continue;const m=n[n.length-1],g=m[m.length-1];g&&g.scope===c?g.text+=p:m.push({text:p,scope:c})}},s=(a,c)=>{for(const u of a)u.type==="text"?o(u.value,c):u.type==="element"&&s(u.children,VA(u)??c)};try{s(Dw.highlight(t,e).children,"")}catch{return e.split(`
179
- `).map(a=>a?[{text:a,scope:""}]:[])}return n}function VA(e){var o;const t=((o=e.properties)==null?void 0:o.className)??[];let n=null;for(const s of t){const a=KA[s.startsWith("hljs-")?s.slice(5):s];a&&(n=a)}return n}function Bw(e,t){return t?Uw(e,t).map(n=>n.map(o=>({text:o.text,changed:!1,scope:o.scope}))):[]}function GA(e,t){var o;const n=new Array(e.length);if(t){let s=0;for(let a=0;a<=e.length;a++){const c=(o=e[a])==null?void 0:o.kind;a<e.length&&c!=="hunk"&&c!=="meta"||(qA(e,s,a,t,n),s=a+1)}}return e.map((s,a)=>YA(s.spans,n[a],s.text))}function qA(e,t,n,o,s){var a,c;for(const u of["del","add"]){const d=[];for(let g=t;g<n;g++){const k=(a=e[g])==null?void 0:a.kind;(k===""||k===u)&&d.push(g)}if(d.length===0)continue;const p=d.map(g=>{var k;return((k=e[g])==null?void 0:k.text)??""}).join(`
180
- `),m=Uw(p,o);for(const[g,k]of d.entries())(u==="add"||((c=e[k])==null?void 0:c.kind)==="del")&&(s[k]=m[g])}}function YA(e,t,n){if(!(e!=null&&e.length)&&!(t!=null&&t.length))return n?[{text:n,changed:!1,scope:""}]:[];const o=[],s=e!=null&&e.length?e:[{text:n,changed:!1}],a=t!=null&&t.length?t:[{text:n,scope:""}];let c=0,u=0,d=0,p=0;for(;c<s.length&&u<a.length;){const m=s[c],g=a[u],k=Math.min(m.text.length-d,g.text.length-p);if(k>0){const w={text:m.text.slice(d,d+k),changed:m.changed,scope:g.scope},b=o[o.length-1];b&&b.changed===w.changed&&b.scope===w.scope?b.text+=w.text:o.push(w)}d+=k,p+=k,d>=m.text.length&&(c++,d=0),p>=g.text.length&&(u++,p=0)}return o}function QA(e,t,n,o,s){const{sock:a}=o,c=e[0];if(!c)return[];const u=[],d=_p(Wc(c),t);if(d&&!d.startsWith("/")&&n){const w=c.toolKind==="edit"?"diff":"file";u.push({id:"open-diff",label:`open ${w}`,onClick:()=>bo(o,{worktreeId:n.id,path:d,view:w})}),u.push(...bs(`${n.dir}/${d}`,()=>a==null?void 0:a.send({t:"reveal",worktreeId:n.id,path:d})))}const p=[],m=Hc(c,t).command;m&&p.push({id:"copy-command",label:"copy command",onClick:()=>Ln(m)});const g=e.map(w=>w.output??"").filter(Boolean).join(`
181
- `);g&&p.push({id:"copy-output",label:"copy output",onClick:()=>Ln(g)});const k=[{id:"fold",label:s.open?"collapse":"expand",onClick:s.toggle}];return Hn([u,p,k])}jt.use({renderer:{code({text:e,lang:t}){const n=Fw((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${Bw(e,n).map(s=>s.map(a=>a.scope?`<span class="sy-${a.scope}">${Yk(a.text)}</span>`:Yk(a.text)).join("")).join(`
182
- `)}</code></pre>
183
- `:!1}}});const Yk=e=>e.replace(/[&<>]/g,t=>t==="&"?"&amp;":t==="<"?"&lt;":"&gt;"),qd=e=>lw.sanitize(jt.parse(e,{async:!1}));function Zw(e){const[t,n]=O.useState(()=>qd(e)),o=O.useRef(0);return O.useEffect(()=>{const s=performance.now()-o.current;if(s>=100){o.current=performance.now(),n(qd(e));return}const a=setTimeout(()=>{o.current=performance.now(),n(qd(e))},100-s);return()=>clearTimeout(a)},[e]),t}function XA({text:e,menu:t}){const n=Zw(e),o=nn("chat");return h.jsx("div",{className:"msg-assistant md",...o.contextMenu(t),dangerouslySetInnerHTML:{__html:n}})}const Yd=40;function Hw(e,t){return e.map(n=>{const o=Fw(n.lang,n.diff?t||WA(n.text):"");if(n.diff){const s=jj(n.text);return{...n,lines:s,painted:GA(s,o)}}return{...n,lines:[],painted:Bw(n.text,o)}})}function Ww({blocks:e,path:t,worktreeId:n}){nt();const o=st();return h.jsx("div",{className:"tool-out",children:e.map((s,a)=>s.diff?h.jsxs("pre",{className:"tool-block diff",children:[s.lines.slice(0,Yd).map((c,u)=>{var d;return c.kind==="hunk"?h.jsx("span",{className:"dl hunk",title:c.text},u):h.jsx("span",{className:`dl ${c.kind}`,children:(d=s.painted[u])!=null&&d.length?h.jsx(Qk,{pieces:s.painted[u]}):c.text||" "},u)}),s.lines.length>Yd&&h.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&bo({dispatch:o},{worktreeId:n,path:t,view:"diff"}),children:[s.lines.length-Yd," more lines"]})]},a):s.code?h.jsx("pre",{className:"tool-block",children:s.painted.length?s.painted.map((c,u)=>h.jsxs(O.Fragment,{children:[u>0?`
184
- `:null,h.jsx(Qk,{pieces:c})]},u)):s.text},a):h.jsx("p",{className:"tool-note",children:s.text},a))})}const JA=O.memo(function({item:t,roots:n,worktreeId:o}){const s=O.useMemo(()=>Hw(_w(t,t.output??""),Wc(t)),[t]),a=Hc(t,n).command;return!a&&s.length===0?null:h.jsxs("div",{className:"tool-part",children:[a&&h.jsx("pre",{className:"tool-block cmd",children:a}),s.length>0&&h.jsx(Ww,{blocks:s,path:Kw(t,n),worktreeId:o})]})});function Kw(e,t){const n=_p(Wc(e),t??[]);return n.startsWith("/")?"":n}const e$=O.memo(function({text:t,item:n,roots:o,worktreeId:s}){const a=Wc(n),c=O.useMemo(()=>Hw([{code:!0,diff:!0,lang:"diff",text:t}],a),[t,a]);return h.jsx("div",{className:"tool-part",children:h.jsx(Ww,{blocks:c,path:Kw(n,o),worktreeId:s})})});function Qk({pieces:e}){return h.jsx(h.Fragment,{children:e.map((t,n)=>{const o=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return o?h.jsx("span",{className:o,children:t.text},n):h.jsx(O.Fragment,{children:t.text},n)})})}function Vw({className:e,state:t,auto:n,label:o,summary:s,menu:a,children:c}){const[u,d]=O.useState(null),p=O.useRef(null),m=$O(".chat-log"),g=u??n,k=()=>{g||m(p.current),d(!g)},w=nn("chat");return h.jsxs("details",{ref:p,className:e,"data-state":t,open:g,...w.contextMenu(()=>a({open:g,toggle:k})),tabIndex:-1,onPointerDown:()=>{var b;return(b=p.current)==null?void 0:b.focus({preventScroll:!0})},onKeyDown:b=>{b.key!=="Escape"||!g||(b.stopPropagation(),d(!1))},children:[h.jsx("summary",{"aria-label":o,onClick:b=>{b.preventDefault(),k()},children:s}),c]})}const t$=O.memo(function({item:t,open:n,streaming:o}){const s=Zw(t.text),a=o?"Thinking":"Thought";return h.jsx(Vw,{className:"tool-row",auto:!!n,label:a,menu:c=>Hn([[{id:"copy",label:"copy thought",onClick:()=>Ln(t.text)}],[{id:"fold",label:c.open?"collapse":"expand",onClick:c.toggle}]]),summary:h.jsxs(h.Fragment,{children:[h.jsx(Ct,{name:"bulb",className:"tool-icon"}),h.jsx("span",{className:ot("tool-name",o&&"live-text"),children:a}),o&&h.jsx("span",{className:"live-dot"})]}),children:h.jsx("div",{className:"tool-part",children:h.jsx("div",{className:"tool-out thought-out md",dangerouslySetInnerHTML:{__html:s}})})})}),n$=O.memo(function({tools:t,live:n,roots:o,worktreeId:s,rail:a,marked:c}){var E;const u=t[0],d=O.useMemo(()=>nA(t.map(Z=>_w(Z,Z.output??""))),[t]),p=!!n,{label:m,name:g,icon:k,hint:w}=Hc(u,o),b=!((E=t.at(-1))!=null&&E.done),_=[m,w].filter(Boolean).join(" "),I=Xn(),C=nt();return h.jsx(Vw,{className:ot("tool-row",b&&"live-row",t.some(Z=>Z.isError)&&"error",u.parentToolId&&"nested",u.subagent&&"spawn",a!==void 0&&`rail-${a}`),state:Rr({cursor:c}),auto:p,label:t.length>1?`${_}, ${t.length} calls`:_,menu:Z=>{const M=cn(I.getState(),s),$=M?{id:M.worktree.id,dir:co(M.worktree)}:null;return QA(t,o??[],$,{sock:C,dispatch:I.dispatch},Z)},summary:h.jsxs(h.Fragment,{children:[h.jsx(Ct,{name:k,className:"tool-icon"}),g&&h.jsx("span",{className:ot("tool-name",b&&"live-text"),children:g}),w&&h.jsx("span",{className:ot("tool-hint",b&&"live-text"),children:w}),t.length>1&&h.jsxs("span",{className:"tool-count",children:["×",t.length]}),b&&h.jsx("span",{className:"live-dot"})]}),children:d?h.jsx(e$,{text:d,item:u,roots:o,worktreeId:s}):t.map(Z=>h.jsx(JA,{item:Z,roots:o,worktreeId:s},Z.id))})},(e,t)=>e.live===t.live&&e.roots===t.roots&&e.worktreeId===t.worktreeId&&e.rail===t.rail&&e.marked===t.marked&&Uj(e.tools,t.tools));function r$({item:e}){const t=nt(),n=st(),o=z(w=>w.activeId),s=z(w=>w.termOpen),a=z(w=>{var b;return((b=w.rows.find(_=>_.id===w.activeId))==null?void 0:b.login)??!1}),[c,u]=O.useState(""),[d,p]=O.useState(null),m=O.useRef(!1);if(Bt([a],()=>{a&&m.current&&o&&n({a:"term-stream",id:o,stream:Ao,tall:!0})}),Bt([e.done],()=>{e.done&&m.current&&s&&n({a:"toggle-terminal"}),m.current=!1}),!o)return null;const g=(w,b)=>{t==null||t.send({t:"agent-auth",worktreeId:o,methodId:w,...b?{apiKey:b}:{}})},k=e.methods.find(w=>w.id===d);return h.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[h.jsx("div",{className:"auth-title",children:e.done?`${e.agentName} is logged in`:e.rejected?`${e.agentName}'s credentials were refused`:`${e.agentName} is not logged in`}),!e.done&&h.jsxs("div",{className:"auth-methods",children:[e.methods.map(w=>w.needsKey?h.jsx(De,{variant:"outline",on:d===w.id,"data-tip":w.description,onClick:()=>p(d===w.id?null:w.id),children:w.name},w.id):h.jsx(De,{variant:"outline","data-tip":w.kind==="terminal"?"opens in the terminal pane":w.description,onClick:()=>{g(w.id),w.kind==="terminal"&&(m.current=!0)},children:w.name},w.id)),h.jsx(De,{variant:"outline","data-tip":"after logging in elsewhere (the terminal, another window)",onClick:()=>t==null?void 0:t.send({t:"agent-retry",worktreeId:o}),children:"send again"})]}),!e.done&&a&&h.jsx("div",{className:"hint auth-hint",children:"paste the code into the login tab below and press Enter; it stays hidden as you paste. Your message sends once you are in."}),!e.done&&k&&h.jsxs("form",{className:"auth-key",onSubmit:w=>{w.preventDefault(),c.trim()&&(g(k.id,c.trim()),u(""),p(null))},children:[h.jsx(Mo,{type:"password",autoFocus:!0,placeholder:`${k.name} for ${e.agentName}`,value:c,onChange:w=>u(w.target.value)}),h.jsx(De,{type:"submit",children:"use key"})]})]})}const o$=O.memo(function({item:t,worktreeId:n,onPickHover:o,marked:s}){const a=Xn(),c=nt(),u=nn("chat"),d={dispatch:a.dispatch},p=()=>{const m=cn(a.getState(),n);return m?co(m.worktree):null};switch(t.kind){case"user":return h.jsxs("div",{className:"msg-user row-edge","data-state":Rr({cursor:s}),...u.contextMenu(()=>Kd(t,n??null,d)),children:[t.attachments&&n&&h.jsx("div",{className:"msg-attachments",children:t.attachments.map(m=>m.kind==="image"?h.jsx(tA,{img:m,src:gk(n,m.file)},`${m.kind}-${m.n}`):m.kind==="paste"?h.jsx(Tw,{className:"in-chat",n:m.n,name:m.name,source:m.source,lines:m.lines,chars:m.chars,preview:m.preview,href:gk(n,m.file)},`${m.kind}-${m.n}`):h.jsx(Iw,{pick:m,dir:p(),className:"in-chat",tipText:"Hover to highlight on the page",onHover:g=>o==null?void 0:o(m,g),onOpen:(g,k)=>Bc(a,c,n,g,k)},`${m.kind}-${m.n}`))}),t.text]});case"assistant":return h.jsx(XA,{text:t.text,menu:()=>Kd(t,n??null,d)});case"error":return h.jsx("div",{className:"msg-assistant msg-error",...u.contextMenu(()=>Kd(t,n??null,d)),children:t.text});case"auth":return h.jsx(r$,{item:t});case"ask":return h.jsx(xj,{item:t});case"blocked":return h.jsxs("div",{className:"blocked-row",...u.contextMenu(()=>cj(t.path,p())),children:[h.jsxs("div",{className:"blocked-head",children:[h.jsx("span",{className:"blocked-tag",children:"blocked"}),h.jsx("span",{className:"tool-name",children:t.tool}),t.path&&h.jsx("span",{className:"tool-hint",children:t.path})]}),h.jsx("div",{className:"blocked-why row-dim",children:t.reason})]});case"grafted":return h.jsxs("div",{className:"graft-row","data-tip":`what follows was said in ${t.title} before it was merged in here`,"data-tip-placement":"follow",children:[h.jsx("span",{className:"graft-tag",children:"grafted"}),h.jsx("span",{className:"tool-name",children:t.title}),h.jsx("span",{className:"tool-hint",children:t.branch})]})}});function i$(e){return e.startsWith("!")?e.slice(1).trim():null}function Gw(e){if(e.kind!=="tool"||e.name!==kf&&e.name!==oI)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}const Xk=6e3;function s$(e){const t=[];for(let n=e.length-1;n>=0;n--){const o=e[n];if(o.kind==="user")break;if(o.kind!=="tool"||!o.done)continue;const s=Gw(o);if(s===null)continue;const a=Sw(o.output??"").map(u=>u.text).join(`
185
- `),c=a.length>Xk?`${a.slice(0,Xk)}
186
- [output cut here]`:a;t.unshift(`$ ${s}${c?`
187
- ${c}`:""}`)}if(t.length!==0)return`[Shell commands the user ran in this worktree since their last message, with what each printed, attached automatically:
188
- ${t.join(`
189
- `)}]`}const qw=e=>e===""||e==="!";function Jk(e,t){const n=new Set,o=[];for(let s=e.length-1;s>=0;s--){const a=e[s],c=Gw(a),u=c!==null?`!${c}`:a.kind==="user"&&!t?a.text:null;u===null||!u.trim()||n.has(u)||(n.add(u),o.push({text:u,at:s}))}return o}function a$(e,t,n,o){if(!t){if(o!=="up"||!qw(n))return null;const u=Jk(e,n==="!")[0];return u?{walk:{at:u.at,from:n},text:u.text}:null}const s=Jk(e,t.from==="!"),a=s.findIndex(u=>u.at===t.at)+(o==="up"?1:-1);if(a<0)return{walk:null,text:t.from};const c=s[a];return c?{walk:{at:c.at,from:t.from},text:c.text}:{walk:t,text:n}}const Yw=3;function l$(e,t){const n=O.useRef(Date.now()),[o,s]=O.useState(()=>Date.now());return Bt([e],()=>{const a=(o-n.current)/1e3>=Yw;n.current=Date.now(),a&&s(n.current)}),O.useEffect(()=>{if(!t)return;const a=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(a)},[t]),t?Math.floor((o-n.current)/1e3):0}function c$({active:e,lead:t}){var ie;const n=st(),o=nt(),s=Xn(),a=(e==null?void 0:e.worktree.id)??null,c=Xt(a,"chat"),u=Xt(a,"queue"),d=O.useRef(null),p=O.useRef(!0),[m,g]=O.useState(!1);O.useEffect(()=>{const Y=d.current;Y&&(p.current?(Y.scrollTop=Y.scrollHeight,g(!1)):c.length>0&&g(!0))},[c]),Bt([a],()=>{p.current=!0,g(!1)}),O.useEffect(()=>{const Y=d.current;if(!Y)return;const de=new ResizeObserver(()=>{p.current&&(Y.scrollTop=Y.scrollHeight)});return de.observe(Y),()=>de.disconnect()},[]);const k=()=>{const Y=d.current;if(!Y)return;const de=Y.scrollHeight-Y.scrollTop-Y.clientHeight<40;p.current=de,de&&g(!1)},w=()=>{const Y=d.current;Y&&Y.scrollTo({top:Y.scrollHeight,behavior:"smooth"}),p.current=!0,g(!1)},b=(ie=Xt(a,"walk"))==null?void 0:ie.at,_=O.useRef(null);Bt([b],()=>{const Y=d.current;if(!Y)return;if(b===void 0){const Ee=_.current;if(_.current=null,!Ee||!qw(lo(s.getState(),a).draft))return;Y.scrollTop=Ee.bottom?Y.scrollHeight:Ee.top,p.current=Ee.bottom,Ee.bottom&&g(!1);return}_.current??(_.current={bottom:p.current,top:Y.scrollTop});const de=Y.querySelector(':scope > [data-state~="cursor"]');if(!de)return;const ge=parseFloat(getComputedStyle(Y).paddingTop)||0;Y.scrollTop+=de.getBoundingClientRect().top-Y.getBoundingClientRect().top-ge,k()});const I=O.useCallback((Y,de)=>{a&&(de?Nt.post(a,{type:"highlight-selector",selector:Y.selector,label:Jf(Y)}):Nt.post(a,{type:"highlight-clear"}))},[a]),C=!!e&&Mc(e),E=e==null?void 0:e.worktree,Z=O.useMemo(()=>[E==null?void 0:E.path,E==null?void 0:E.linkPath].filter(Y=>!!Y),[E==null?void 0:E.path,E==null?void 0:E.linkPath]),M=O.useMemo(()=>Fj(c,Z),[c,Z]),$=O.useMemo(()=>Dj(c),[c]),D=(e==null?void 0:e.agent)==="working",q=O.useMemo(()=>D?Bj(M):-1,[D,M]),J=M.at(-1),se=D&&J&&"item"in J&&J.item.kind==="thinking"?M.length-1:-1,me=M.findLastIndex(Y=>{var de;return"tools"in Y&&((de=Y.tools[0])==null?void 0:de.name)===kf}),Oe=c.some(Y=>Y.kind==="tool"&&Y.name===kf&&!Y.done),ae=l$(c,C);return Bt([C,e==null?void 0:e.agent,Oe,u.length],()=>{const Y=d.current;Y&&p.current&&(Y.scrollTop=Y.scrollHeight)}),h.jsxs("div",{className:"chat-wrap",children:[h.jsxs("div",{className:"chat-log",ref:d,onScroll:k,children:[t,M.map((Y,de)=>{var ge;return"tools"in Y?h.jsx(n$,{tools:Y.tools,live:de===q||de===me,roots:Z,worktreeId:a,rail:$.get(((ge=Y.tools[0])==null?void 0:ge.parentToolId)??""),marked:Y.at===b},Y.at):Y.item.kind==="thinking"?h.jsx(t$,{item:Y.item,open:de===q,streaming:de===se},Y.at):h.jsx(o$,{item:Y.item,worktreeId:a,onPickHover:I,marked:Y.at===b},Y.at)}),C&&e&&h.jsxs("div",{className:"working-row",children:[e.agent==="waiting"?"waiting for your answer…":h.jsxs("span",{children:["working…",ae>=Yw&&h.jsxs("span",{className:"working-quiet",children:[ae,"s"]})]}),h.jsxs(De,{variant:"outline",tone:"danger","data-tip":`Stop the agent (context up to here is kept${u.length?"; queued messages go next":""})`,"data-tip-key":"esc",onClick:()=>o==null?void 0:o.send({t:"stop-agent",worktreeId:e.worktree.id}),children:[h.jsx(Ct,{name:"stop",className:"icon-inline"})," stop"]})]}),Oe&&e&&h.jsxs("div",{className:"working-row",children:["running…",h.jsxs(De,{variant:"outline",tone:"danger","data-tip":"Kill the command; what it printed so far stays",onClick:()=>o==null?void 0:o.send({t:"exec-stop",worktreeId:e.worktree.id}),children:[h.jsx(Ct,{name:"stop",className:"icon-inline"})," stop"]})]}),a&&u.map((Y,de)=>h.jsxs("div",{className:"msg-user queued-msg",children:[h.jsx("span",{className:"queued-tag",children:"queued"}),h.jsx("span",{className:"queued-text",children:Y}),h.jsxs("span",{className:"queued-actions",children:[h.jsx(Kt,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>{o==null||o.send({t:"unqueue",worktreeId:a,index:de}),n({a:"set-draft",id:a,text:Y})}}),h.jsx(Kt,{icon:"close",label:"Remove from queue",onClick:()=>o==null?void 0:o.send({t:"unqueue",worktreeId:a,index:de})})]})]},`q-${de}`))]}),m&&h.jsxs("button",{className:"jump-down",onClick:w,"data-tip":"Jump to latest",children:[h.jsx(Ct,{name:"caret",className:"icon-inline"})," new messages"]})]})}function Ep(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 Qw(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:vo})}]}function u$(e,t,n,o){return Hn([[...e.flatMap(s=>Ep(s,t,o)),...Qw(t,o)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>o.dispatch({a:"toggle-terminal"})}]])}const d$={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function f$({results:e,keyOf:t,row:n,rowClass:o,nav:s,listRef:a,empty:c}){return h.jsxs(Aa,{className:"inline-picker",anchor:"parent",placement:d$,children:[h.jsxs("div",{className:"picker-list",ref:a,children:[e.map((u,d)=>h.jsx("button",{className:ot("picker-item",o==null?void 0:o(u)),"data-state":Rr({cursor:d===s.index}),onMouseMove:()=>d!==s.index&&s.setIndex(d),onMouseDown:p=>p.preventDefault(),onClick:()=>s.pick(u),children:n(u,d===s.index)},t(u))),e.length===0&&h.jsx("div",{className:"empty",children:c})]}),h.jsx(vp,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]]})]})}function p$({fraction:e,className:t}){const o=2*Math.PI*5.5,s=Math.max(0,Math.min(1,Number.isFinite(e)?e:0));return h.jsxs("svg",{className:ot("ring",t),viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[h.jsx("circle",{className:"ring-track",cx:"7",cy:"7",r:5.5}),h.jsx("circle",{className:"ring-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${o*s} ${o}`})]})}function h$(e,t=t1.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 m$(e,t){const n=t??0;return n===0?null:`${n} uncommitted on ${e} stay behind`}function g$(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function k$(e){const t=e??0;return t===0?null:`${t} behind origin`}const jo="";function y$(e){var d;const t=e.name.match(/^([A-Za-z]+)-(\d+(?:\.\d+)*)(?:-([A-Z][a-z]+))?$/);if(t!=null&&t[1]&&t[2])return{label:t[3]??t[1],version:t[2],...e.description?{description:e.description}:{}};const[n="",...o]=(e.description??"").split(" · "),s=e.name.replace(/\s*\([^)]*\)$/,""),a=n.match(/^(.+?) (\d+(?:\.\d+)*)(?: with (.+))?$/);if(!(a!=null&&a[2])||a[1]!==s)return{label:e.name,...e.description?{description:e.description}:{}};const u=[a[3]??((d=e.name.match(/\(([^)]*)\)$/))==null?void 0:d[1]),...o].filter(Boolean).join(" · ");return{label:s,version:a[2],...u?{description:u}:{}}}function Xw(e,t,n,o){const s=by(e),a=g1(e),c=t||n||(s==null?void 0:s.id)||jo,u=a&&c===(s==null?void 0:s.id)?a.id:c,d=a?e.filter(w=>w!==s):e,p=d.some(w=>w.id===u),m=d.map(w=>({c:w,words:y$(w)})),g=w=>[w.label,w.version].filter(Boolean).join(" ");return{rows:[...s?[]:[{id:jo,label:o.label,description:o.description}],...m.map(({c:w,words:b})=>{const _=m.filter(C=>g(C.words)===g(b)).length===1?b:void 0,I=_?_.description:w.description;return{id:w.id,label:_?_.label:w.name,..._!=null&&_.version?{suffix:_.version}:{},..._!=null&&_.version&&m.some(C=>C.c!==w&&C.words.label===_.label)?{chip:g(_)}:{},description:w===a?["recommended",I].filter(Boolean).join(" · "):I}}),...u&&!p?[{id:u,label:u}]:[]],shown:u}}const oa=(e,t)=>`${e} ${t}`;function v$(e){const t=e.indexOf(" ");return t<0?{agent:e,model:jo}:{agent:e.slice(0,t),model:e.slice(t+1)}}function w$(e,t,n){const o=e.length>1;let s=oa(t,n);return{rows:e.flatMap(c=>{var m;const u=c.short??c.name,d=c.id===t;if(!c.available||!((m=c.models)!=null&&m.length))return d&&(s=oa(c.id,jo)),[{id:oa(c.id,jo),label:u,description:c.available?"its own default model; the rest are listed once it has run":c.reason??"not installed",disabled:!c.available}];const p=Xw(c.models,d?n:jo,void 0,{label:`${u} default`,description:`whatever ${c.name} runs when nothing is asked for`});return d&&(s=oa(c.id,p.shown)),p.rows.map(g=>({...g,id:oa(c.id,g.id),...o&&g.id!==jo?{prefix:u}:{}}))}),shown:s}}function Sp({anchored:e=!1,...t}){return e?h.jsx(b$,{...t,anchored:e===!0?{}:e}):h.jsx(x$,{...t})}function b$({onClose:e,onEscape:t,boxClass:n="",bare:o=!1,anchored:s,coverBy:a,id:c,children:u}){return h.jsx(Aa,{className:ot(o?"":"overlay-box","anchored",n),id:c,anchor:"parent",placement:{side:"bottom",align:"start",cover:!0,margin:0,...s},coverBy:a,onDismiss:e?()=>e():void 0,onKey:t?Jw(t):void 0,children:u})}function x$({onClose:e,onEscape:t,boxClass:n="",bare:o=!1,id:s,children:a}){const c=O.useRef(null);return hR(c,{onDismiss:e?()=>e():void 0,onKey:t?Jw(t):void 0}),h.jsx("div",{className:"overlay",children:h.jsx("div",{className:ot(o?"":"overlay-box",n),id:s,ref:c,children:a})})}const Jw=e=>t=>{t.key==="Escape"&&(t.stopPropagation(),e())};function _$({text:e,params:t}){if(t.length===0)return e;const n=[];let o=0;for(const[s,a]of t)s>o&&n.push(e.slice(o,s)),n.push(h.jsx("span",{className:"picker-ghost-param",children:e.slice(s,a)},s)),o=a;return o<e.length&&n.push(e.slice(o)),n}function wr({items:e,filter:t,keyOf:n,row:o,rowClass:s,rowTitle:a,onPick:c,onBack:u,onActive:d,onSide:p,onQuery:m,completionOf:g,narrowTo:k,placeholder:w,initialQuery:b="",initialIndex:_,selectOnMount:I=!1,idleWhen:C,onIdlePick:E,anchored:Z=!1,onEscape:M,lead:$,trailing:D,empty:q="no matches",footer:J,keys:se,rowMenu:me}){const Oe=nn("picker"),[ae,ie]=O.useState(b),Y=O.useMemo(()=>t(e,ae),[e,ae,t]),de=O.useRef(null),ge=CO(I);O.useEffect(()=>{if(!m)return;const V=setTimeout(()=>m(ae),150);return()=>clearTimeout(V)},[ae,m]);const Ee=bp({results:Y,keyOf:n,q:ae,onPick:c,listRef:de,onActive:d,onSide:p,completionOf:g,narrowTo:k,setQ:ie,initialIndex:_,idle:(C==null?void 0:C(b))??!1,onIdlePick:E}),{index:X,ghost:ce}=Ee,ee=typeof se=="function"?se(Ee.active,ae):se,j=[];ee!=null&&ee.nav&&j.push(["↑↓",ee.nav]),ee!=null&&ee.side&&p&&j.push(["←→",ee.side]),ee!=null&&ee.complete&&(ce!=null&&ce.accept)&&j.push(["tab",ee.complete]),ee!=null&&ee.pick&&j.push(["enter",ee.pick]),ee!=null&&ee.back&&j.push(["esc",ee.back]);const Q=h.jsxs("div",{className:"picker-input",onMouseDown:V=>{var be;V.target.closest("input, button")||(V.preventDefault(),(be=ge.current)==null||be.focus())},children:[$,h.jsxs("div",{className:"picker-caret",children:[h.jsx(Mo,{font:"mono",bare:!0,ref:ge,value:ae,onChange:V=>{ie(V.target.value),Ee.setIndex(C!=null&&C(V.target.value)?-1:0)},onKeyDown:V=>{var be;if(me&&Ee.active&&(V.key==="ContextMenu"||V.key==="F10"&&V.shiftKey)){const Ae=(be=de.current)==null?void 0:be.querySelector('[data-state~="cursor"]');if(Ae){V.preventDefault(),V.stopPropagation(),yr.open({items:me(Ee.active),owner:"picker",target:Ae,anchor:Ae.getBoundingClientRect()});return}}Ee.onKeyDown(V)},placeholder:w}),ce&&h.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[h.jsx("span",{className:"picker-typed",children:ae}),_$(ce)]})]}),D]}),Ie=h.jsxs("div",{className:"picker-list",ref:de,children:[Y.map((V,be)=>h.jsx("button",{className:ot("picker-item",s==null?void 0:s(V)),"data-state":Rr({cursor:be===X}),title:a==null?void 0:a(V),onMouseMove:()=>be!==X&&Ee.setIndex(be),onClick:()=>{var Ae;Ee.pick(V),(Ae=ge.current)==null||Ae.focus()},...Oe.contextMenu(()=>(me==null?void 0:me(V))??[]),children:o(V,be===X,ae)},n(V))),Y.length===0&&h.jsx("div",{className:"empty",children:typeof q=="function"?q(ae):q}),J==null?void 0:J(ae,Y)]}),xe=j.length>0&&h.jsx(vp,{hints:j});return h.jsxs(Sp,{onClose:u,onEscape:M,boxClass:"picker",anchored:Z,coverBy:$?".picker-input > *:first-child":void 0,children:[Q,Ie,xe]})}function Ci({value:e,options:t,onChange:n,placeholder:o,hint:s,className:a,onClose:c}){const[u,d]=O.useState(!1),p=()=>{d(!1),c==null||c()},m=t.find(k=>k.id===e),g=(m==null?void 0:m.chip)??(m==null?void 0:m.label)??e;return h.jsxs("span",{className:"chip-picker",children:[h.jsx(De,{variant:"ghost",tone:"chrome",mono:!0,on:u,className:ot("chip-picker-btn",a),...St(s),onClick:()=>u?p():d(!0),children:g}),u&&h.jsx(wr,{anchored:{flip:"both",margin:8},onEscape:p,items:t,filter:(k,w)=>{const b=w.trim().toLowerCase().split(/\s+/).filter(Boolean);return k.filter(_=>{const I=`${_.prefix??""} ${_.label??_.id} ${_.suffix??""} ${_.id}`.toLowerCase();return b.every(C=>I.includes(C))})},keyOf:k=>k.id,initialIndex:k=>Math.max(0,k.findIndex(w=>w.id===e)),lead:h.jsx(De,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:p,children:g}),placeholder:o,rowClass:()=>"picker-row",row:k=>h.jsxs(h.Fragment,{children:[k.id===e&&h.jsx("span",{className:"row-current","aria-hidden":"true"}),h.jsxs("span",{className:ot("chip-option",k.disabled&&"chip-option-off"),"aria-disabled":k.disabled,children:[h.jsxs("span",{className:"chip-option-name",children:[k.prefix?`${k.prefix} `:null,k.label??k.id,k.suffix?h.jsx("span",{className:"chip-option-suffix",children:` ${k.suffix}`}):null]}),k.description&&h.jsx("span",{className:"chip-option-desc row-dim",children:k.description})]})]}),onPick:k=>{k.disabled||(n(k.id),p())},onBack:p})]})}function e0({choices:e,value:t,current:n,what:o,defaultLabel:s,defaultDescription:a,placeholder:c,className:u,onChange:d,onClose:p}){if(e.length===0)return null;const{rows:m,shown:g}=Xw(e,t,n,{label:s,description:a}),k=m.find(b=>b.id===g),w=(k==null?void 0:k.chip)??(k==null?void 0:k.label)??g;return h.jsx(Ci,{value:g,options:m,onChange:d,onClose:p,className:u,hint:t?`asked for ${w}; click to change`:`${w}, the agent's choice; click to pick ${o}`,placeholder:c})}function t0(e){const[t,n]=so(ft.effortPrefix+(e??""),jo,o=>o??"");return[t,n]}function Of({efforts:e,value:t,current:n,onChange:o,onClose:s}){return h.jsx(e0,{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:o,onClose:s})}function E$(e){const[t,n]=so(ft.modePrefix+((e==null?void 0:e.id)??""),lf,o=>Ff.some(s=>s.id===o)?o:lf);return[t,n]}const S$=e=>{var t;return((t=Ff.find(n=>n.id===e))==null?void 0:t.description)??""};function ey({value:e,onChange:t,onClose:n}){return h.jsx(Ci,{value:e,options:Ff.map(o=>({id:o.id,label:o.name,description:o.description})),onChange:t,onClose:n,className:ot("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${S$(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function n0(e){const[t,n]=so(ft.modelPrefix+(e??""),jo,o=>o??"");return[t,n]}function r0(e,t){try{localStorage.setItem(ft.modelPrefix+e,t)}catch{}}function Rf({models:e,value:t,current:n,onChange:o,onClose:s}){return h.jsx(e0,{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:o,onClose:s})}function o0({agents:e,agent:t,model:n,onChange:o,onClose:s}){const{rows:a,shown:c}=w$(e,t,n);if(a.length===0)return null;const u=a.find(p=>p.id===c),d=u?[u.prefix,u.label,u.suffix].filter(Boolean).join(" "):n;return h.jsx(Ci,{value:c,options:a,onChange:p=>{const m=v$(p);o(m.agent,m.model)},onClose:s,className:"model-chip",hint:`${d} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function i0(e){const t=zc(e),[n,o]=so(ft.profilePrefix+((e==null?void 0:e.id)??""),(e==null?void 0:e.config.defaultProfile)??"",a=>a??void 0);return[t.length===0?void 0:t.includes(n)?n:e==null?void 0:e.config.defaultProfile,o]}function N$({repo:e,value:t,onChange:n,onClose:o}){const s=zc(e);if(s.length===0||!t)return null;const a=(e==null?void 0:e.config.profiles)??{},c=(e==null?void 0:e.configFile)??"the settings",u=d=>{var g;const p=((g=a[d])==null?void 0:g.run)??[],m=p.length>0?`runs ${p.join(", ")}`:"runs nothing";return d===(e==null?void 0:e.config.defaultProfile)?`${m}; the default in ${c}`:m};return h.jsx(Ci,{value:t,options:s.map(d=>({id:d,description:u(d)})),onChange:n,onClose:o,hint:s.length>1?`${t}: ${u(t)}. Click to change`:`the only profile in ${c}`,placeholder:"the profile the worktree runs"})}function T$({title:e,value:t,onChange:n,onClose:o}){return h.jsx(Ci,{value:t,options:[{id:"new",label:"new worktree",description:`starts an agent in a new worktree from ${e}`},{id:"here",label:e,description:`the agent edits ${e} directly`}],onChange:n,onClose:o,className:"target-chip",hint:t==="new"?`The agent works in a new worktree from ${e}`:`The agent edits ${e} directly`,placeholder:"where the message goes"})}function kc(e,t,n){if(!t)return e;const o=new Set(t.map(c=>c-n)),s=[];let a="";for(let c=0;c<e.length;c++)o.has(c)?(a&&s.push(a),a="",s.push(h.jsx("b",{className:"hit",children:e[c]},c))):a+=e[c];return a&&s.push(a),s}function I$(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 Kc(e,t,{sock:n,dispatch:o}){const s=[];e.id!==t&&s.push({id:`repo:${e.id}`,label:`switch to ${e.name}`,onClick:()=>o({a:"activate-repo",id:e.id})});const a=[{id:`setup:${e.id}`,label:"project settings…",detail:e.configFile,onClick:()=>o({a:"open",overlay:{kind:"setup",repoId:e.id}})},{id:`archived:${e.id}`,label:"archived worktrees…",onClick:()=>o({a:"open",overlay:{kind:"archived",repoId:e.id}})},{id:`forget:${e.id}`,label:"forget project…",danger:!0,onClick:()=>{window.confirm(`Forget ${e.name}?
190
-
191
- 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 Hn([s,a])}const yc={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"};function O$(e){const t=document.createElement("input");t.type="file",t.accept=".json,.jsonc,application/json",t.onchange=()=>{var o;const n=(o=t.files)==null?void 0:o[0];n&&n.text().then(s=>e(n.name,s))},t.click()}function s0(e,{sock:t,dispatch:n}){var a;const o=e.themePrefs,s=c=>{var u;return((u=e.themes.find(d=>d.id===c))==null?void 0:u.name)??c};return Hn([[{id:"theme",label:"theme…",detail:jc(o,e.themes,Rv(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:yc[o.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((a=e.agents.find(c=>c.id===e.defaultAgent))==null?void 0:a.name)??e.defaultAgent,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"agent"}})}],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>O$((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:s(o.dark),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"dark"}})},{id:"theme-light",topic:"theme",label:"light slot override…",detail:s(o.light),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"light"}})}]])}function R$(e,t,n,o,s){const a=[],c=(g,k,w,b,_)=>a.push({id:g,label:k,hint:b,run:w,sub:_}),u=(g,k)=>{for(const w of g){if(!Ni(w)||w.disabled!==void 0||w.checked)continue;const b=w.key??(typeof w.detail=="string"?w.detail:void 0),_=k?`${k.scope}:${w.id}`:w.id,I=w.topic?`${w.topic}: ${w.label}`:w.label;c(_,k?`${I} · ${k.name}`:I,w.onClick,b,w.sub)}},d={sock:n,dispatch:t},p=o,m=p==null?void 0:p.worktree.id;if(u(Dv(e,d).filter(g=>!Ni(g)||g.id!=="commands")),s&&u(Kc(s,s.id,d),{scope:"project",name:s.name}),m&&!wo(e)&&(c("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>Ea(m,e.picking,t,"chat"),yt("pick")),c("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>Ea(m,e.picking,t,"code"),yt("inspect")),c("reload","reload preview",()=>Nt.post(m,{type:"reload"}))),u(s0(e,d)),p&&m){const g=e.repos.find(k=>k.id===p.worktree.repoId)??null;u(Wv(p,g,e,d),{scope:"wt",name:yf(p,g)});for(const k of p.procs)u(Ep(k,m,d))}e.visible.forEach((g,k)=>{if(g.worktree.id===m)return;const w=g.worktree.variant;c(`go:${g.worktree.id}`,`switch to ${yf(g,s)}${w?` (v${w.index}/${w.of})`:""}`,()=>t({a:"activate",id:g.worktree.id}),qx(k,e.visible.length))});for(const g of e.repos)g.id!==(s==null?void 0:s.id)&&c(`repo:${g.id}`,`switch to project ${g.name}`,()=>t({a:"activate-repo",id:g.id}));return a}function a0(){const e=st(),t=nt(),n=z($=>$.picking),o=z($=>$.leftOpen),s=z($=>$.rightOpen),a=z($=>$.railOpen),c=z($=>$.termOpen),u=z($=>$.designOpen),d=z($=>$.themePrefs),p=z($=>$.themes),m=z($=>$.systemDark),g=z($=>$.daylight),k=z($=>$.rows),w=z($=>$.visible),b=z($=>$.activeId),_=z($=>$.activeRepoId),I=z($=>$.repos),C=z($=>$.agents),E=z($=>$.defaultAgent),Z=z($=>$.shipping),M=z($=>$.remote);return O.useMemo(()=>{const $={picking:n,leftOpen:o,rightOpen:s,railOpen:a,termOpen:c,designOpen:u,themePrefs:d,themes:p,systemDark:m,daylight:g,rows:k,visible:w,activeId:b,activeRepoId:_,repos:I,agents:C,defaultAgent:E,shipping:Z,remote:M};return R$($,e,t,cn($,b),Ai($,_))},[n,o,s,a,c,u,d,p,m,g,k,w,b,_,I,C,E,Z,M,e,t])}function l0(e,t){const n=t.trim().toLowerCase();if(!n)return e;const o=[];for(const s of e){const a=Cf(s.label.toLowerCase(),n);a>0&&o.push({c:s,score:a})}return o.sort((s,a)=>a.score-s.score),o.map(s=>s.c)}function Cf(e,t){const n=Np(e,t);if(!n)return 0;let o=0,s=0,a=-1;for(const c of n)s=c===a+1?s+1:1,o+=s+(c0(e,c)?3:0),a=c;return o+Math.max(0,40-e.length/4)}const c0=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function Np(e,t){const n=e.toLowerCase(),o=[];let s=0;for(const a of t.toLowerCase()){let c=-1;if(n[s]===a)c=s;else if(a===" ")c=n.indexOf(" ",s);else for(let u=n.indexOf(a,s);u!==-1;u=n.indexOf(a,u+1))if(c0(n,u)){c=u;break}if(c===-1)return null;o.push(c),s=c+1}return o}const ys=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(o=>o==null?void 0:o.toLowerCase().includes(n))};function C$({c:e,query:t}){const n=t.trim();return h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"picker-name",children:["/",kc(e.name,n?Np(e.name,n):null,0)]}),h.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function Pn({label:e,hint:t,current:n=!1}){return h.jsxs(h.Fragment,{children:[n&&h.jsx("span",{className:"row-current","aria-hidden":"true"}),h.jsx("span",{className:"picker-label",children:e}),t?h.jsx("span",{className:"picker-hint row-dim",children:t}):null]})}function u0({f:e}){return e.add===void 0&&e.del===void 0?null:h.jsxs("span",{className:"counts",children:[e.add?h.jsxs("span",{className:"add",children:["+",e.add]}):null,e.del?h.jsxs("span",{className:"del",children:["−",e.del]}):null]})}const Qd=O.memo(function({f:t,active:n,selected:o,onOpen:s,menu:a,onHover:c}){const u=nn("changes"),{name:d,dir:p}=XI(t.path);return h.jsxs("button",{className:"row row-sm git-file row-edge","data-state":Rr({current:n,cursor:o}),role:"option","aria-selected":o,tabIndex:-1,onClick:()=>s(t.path),...u.contextMenu(()=>a(t.path)),onMouseEnter:()=>c(t.path,!0),onMouseLeave:()=>c(t.path,!1),children:[h.jsx("span",{className:`xy ${kv(t.xy)}`,children:yv(t.xy)}),h.jsxs("span",{className:"path","data-tip":p?t.path:void 0,children:[h.jsx("span",{className:"name",children:d}),p&&h.jsx("span",{className:"dir row-dim",children:p})]}),h.jsx(u0,{f:t})]})});function j$(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 A$=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,$$=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,M$=/^[[:$*{]|\[/;function P$(e){const t=new Map,n=e.filter(a=>!!a.title);if(new Set(n.map(a=>a.path)).size<2)return t;const o=n.map(a=>({path:a.path,parts:a.title.split(A$).map(c=>c.trim()).filter(Boolean)})),s=new Map;for(const{path:a,parts:c}of o)for(const u of c)s.set(u,(s.get(u)??new Set).add(a));for(const{path:a,parts:c}of o){const u=c.filter(d=>{var p;return(((p=s.get(d))==null?void 0:p.size)??0)<2});u.length>0&&t.set(a,u.join(" "))}return t}function Tp(e){const t=e.split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let o=t[n];try{o=decodeURIComponent(o)}catch{}if($$.test(o)||M$.test(o))continue;const s=o.replace(/[-_.]+/g," ").trim();if(s)return s[0].toUpperCase()+s.slice(1)}return"Home"}const Xd=8,L$=3,z$=50,D$=3;function F$(e,t,n=[]){const o=new Map,s=[],a=new Map;for(const c of(t==null?void 0:t.routes)??[]){if(c.endpoint)continue;const u=c.dynamic?lI(c.path):null;u?(s.push(u),a.set(c.path,c)):o.set(c.path,c)}return{history:e,statics:o,templates:s,templateRoutes:a,unseen:(t==null?void 0:t.unseen)??{},titles:P$(e),links:new Map(n.map(c=>[c.path,c.text]))}}function d0(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function U$(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function B$(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const f0=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),da=e=>f0(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),Z$=e=>Cc(`/${e}`).text.slice(1),Ip=e=>e.split("/").filter(Boolean);function Op(e,t){const n=t.startsWith("/"),o=t.replace(/^\//,"").split("/"),s=Ip(e);let a="";const c=[],u=g=>{const k=Z$(g);c.push([a.length,a.length+k.length]),a+=k};for(let g=0;g<o.length;g++){const k=o[g],w=s[g];if(w===void 0)return null;if(g<o.length-1){if(f0(w))return{show:t,accept:t};if(da(w)){if(!k)return null}else if(k.toLowerCase()!==w.toLowerCase())return null;a+=`${da(w)?k:w}/`;continue}if(da(w))k?a+=k:u(w);else{if(!w.toLowerCase().startsWith(k.toLowerCase()))return null;a+=w}}for(const g of s.slice(o.length))a+="/",da(g)?u(g):a+=g;const d=n?1:0,p=(n?"/":"")+a,m=c[0];return{show:p,accept:m?p.slice(0,m[0]+d):p,params:c.map(([g,k])=>[g+d,k+d])}}function H$(e,t){const n=Op(e,t);return n?n.accept.length>t.length?n.accept:t:Cc(e).literal}function p0(e,t){if(e.kind==="go")return null;if(e.template){const n=Op(e.path,t);return n&&n.show.length>t.length?n:null}return B$(e.path,t)}const W$=e=>e.trim().replace(/^\//,"").toLowerCase();function h0(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function K$(e,t,n){const o=e.replace(/^\//,"").toLowerCase(),s=t.toLowerCase();return o===n?100:o.startsWith(n)?80:h0(o,n)?60:s.startsWith(n)?50:s.split(/\s+/).some(a=>a.startsWith(n))?45:o.includes(n)||s.includes(n)?20:0}function V$(e,t){const{text:n,literal:o}=Cc(e);return o.replace(/^\//,"").toLowerCase().startsWith(t)?80:Op(e,t)?70:h0(n.replace(/^\//,"").toLowerCase(),t)?60:0}function G$(e,t){const n=Ip(e).findIndex(da);return n>=0&&t.split("/").length>n}function ga(e,t,n){var u;const o=e.statics.get(t),s=o?null:cI(e.templates,t),a=(o==null?void 0:o.file)??(s?(u=e.templateRoutes.get(s.path))==null?void 0:u.file:void 0),c=a?e.unseen[a]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||Tp(t),template:!1,visited:n<Number.POSITIVE_INFINITY,...a?{file:a}:{},...c?{badge:c}:{},rank:n,group:(s==null?void 0:s.path)??t,score:0}}function m0(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:Tp(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function nc({rank:e,group:t,score:n,...o}){return o}const vc=e=>Ip(e).length,wc=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function q$(e,t){const n=new Set,o=[];e.history.forEach((m,g)=>{if(m.path===t)return;const k=ga(e,m.path,g);n.has(k.group)||(n.add(k.group),o.push(k))});const s=new Set(o.map(m=>m.path)),a=o.filter(m=>m.badge);for(const[m,g]of e.statics)e.unseen[g.file]&&m!==t&&!s.has(m)&&a.push(ga(e,m,Number.POSITIVE_INFINITY));for(const m of e.templateRoutes.values())e.unseen[m.file]&&!n.has(m.path)&&a.push(m0(e,m));a.sort((m,g)=>wc(m)-wc(g)||m.rank-g.rank);const c=o.filter(m=>!m.badge),u=a.slice(0,Xd-Math.min(L$,c.length));for(const m of c)u.length<Xd&&u.push(m);const d=new Set(u.map(m=>m.path)),p=[...e.statics.keys(),...[...e.links.keys()].filter(m=>!e.statics.has(m))].filter(m=>m!==t&&!d.has(m)&&!s.has(m)).sort((m,g)=>vc(m)-vc(g)||(m<g?-1:m>g?1:0));for(const m of p){if(u.length>=Xd)break;u.push(ga(e,m,Number.POSITIVE_INFINITY))}return u.map(nc)}function Y$(e,t,n){var g;const o=W$(t),s=U$(t),a=new Map;e.history.forEach((k,w)=>{k.path!==n&&a.set(k.path,ga(e,k.path,w))});for(const k of[...e.statics.keys(),...e.links.keys()])k!==n&&!a.has(k)&&a.set(k,ga(e,k,Number.POSITIVE_INFINITY));const c=[];for(const k of a.values()){const w=K$(k.path,k.title,o);w>0&&c.push({...k,score:w})}let u=null;for(const k of e.templates){const w=e.templateRoutes.get(k.path);if(!u&&!e.statics.has(s)&&k.re.test(s)){u=w;continue}const b=V$(k.path,o);b>=60&&c.push({...m0(e,w),score:b})}c.sort((k,w)=>w.score-k.score||k.rank-w.rank||wc(k)-wc(w)||vc(k.path)-vc(w.path)||(k.path<w.path?-1:k.path>w.path?1:0));const d=new Map,p=[];for(const k of c){if(!k.template&&k.group!==k.path){const w=d.get(k.group)??0;if(w>=D$&&!G$(k.group,o))continue;d.set(k.group,w+1)}if(p.push(k),p.length>=z$)break}if(p.some(k=>k.score===100))return p.map(nc);const m={kind:"go",path:s,title:Tp((u==null?void 0:u.path)??s)};return u||(((g=p[0])==null?void 0:g.score)??0)<80?[m,...p.map(nc)]:[...p.map(nc),m]}function g0(e,{query:t,current:n,here:o}){return t===n||t.trim()===""?q$(e,o):Y$(e,t,o)}const Q$=[],X$=[];function k0(e,t){const n=z(a=>(t?a.visits[t]:void 0)??Q$),o=Xt(e,"pages"),s=Xt(e,"links");return Bt([e],()=>{Ev(o)&&Nt.post(e,{type:"links"})}),O.useMemo(()=>F$(n,o,s),[n,o,s])}function J$({row:e}){if(e.kind!=="page"||!e.template)return h.jsx("span",{className:"bar-route-path row-dim",children:e.path});const{text:t,params:n}=Cc(e.path),o=[];let s=0;for(const[a,c]of n)a>s&&o.push(t.slice(s,a)),o.push(h.jsx("span",{className:"bar-route-param",children:t.slice(a,c)},a)),s=c;return s<t.length&&o.push(t.slice(s)),h.jsx("span",{className:"bar-route-path row-dim",children:o})}function y0({row:e}){return h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"picker-label",children:e.title}),h.jsx(J$,{row:e}),e.kind==="go"?h.jsx("span",{className:"picker-hint row-dim",children:"go"}):e.badge?h.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const v0=e=>e.kind==="page"&&e.file?e.file:e.path,w0=(e,t)=>e.kind==="page"&&e.template?H$(e.path,t):null,b0=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function x0(e,t,n){return e.kind!=="page"?[]:Pc([...e.file&&t.dir?oi({id:t.worktreeId,dir:t.dir},e.file,{},n):[],bv,...e.visited?j$(t.repoId,e.path,n):[]])}function e2({worktreeId:e,repoId:t,url:n}){const o=st(),s=nt(),a=z(k=>{const w=cn(k,e);return w?co(w.worktree):null}),c=k0(e,t),u=d0(n),d=n?Rc(n):null,p=O.useCallback((k,w)=>g0(c,{query:w,current:u,here:d}),[c,u,d]),m=O.useCallback(k=>k===u||k.trim()==="",[u]),g=()=>o({a:"close"});return h.jsx(wr,{anchored:{matchWidth:0},items:X$,filter:p,initialQuery:u,selectOnMount:!0,idleWhen:m,onIdlePick:()=>{Nt.post(e,{type:"reload"}),g()},keyOf:k=>`${k.kind}:${k.path}`,rowClass:()=>"picker-row",rowTitle:v0,completionOf:(k,w)=>m(w)?null:p0(k,w),narrowTo:w0,onPick:k=>{Nt.post(e,{type:"navigate",path:k.path}),g()},onBack:g,rowMenu:k=>x0(k,{worktreeId:e,repoId:t,dir:a},{sock:s,dispatch:o}),placeholder:"type a path",keys:k=>({complete:"completes the path",pick:k?b0(k):"reloads",back:"closes"}),empty:"no pages yet; type a path",row:k=>h.jsx(y0,{row:k})})}function _0(e,t){const n=t.trim();return h.jsx(Pn,{label:kc(e.label,n?Np(e.label,n):null,0),hint:e.hint&&h.jsx(Or,{k:e.hint})})}function t2(){const e=st(),t=a0(),n=z(o=>{var s;return((s=o.paletteReturn)==null?void 0:s.mode)==="commands"?o.paletteReturn.q:""});return h.jsx(wr,{items:t,filter:l0,rowClass:()=>"picker-row",keyOf:o=>o.id,onPick:(o,s)=>{o.sub?e({a:"palette-return",v:{mode:"commands",q:s}}):e({a:"close"}),o.run()},onBack:()=>e({a:"close"}),placeholder:"run a command…",keys:{pick:"runs",back:"closes"},initialQuery:n,empty:"no matching command",row:(o,s,a)=>_0(o,a)})}function n2(e,t){const n=new Map(t.map(c=>[c.path,c])),o=t.filter(c=>c.xy==="??"&&c.path.endsWith("/")).map(c=>c.path),s=e.map(c=>{const u=n.get(c)??(o.some(d=>c.startsWith(d))?{path:c,xy:"??"}:void 0);return u?{path:c,status:u}:{path:c}}),a=new Set(e);for(const c of t)!a.has(c.path)&&!c.path.endsWith("/")&&s.push({path:c.path,status:c});return s}function E0(e,t,n,o=50){const s=n2(e,t),a=n.trim().toLowerCase();if(!a){const u=new Map(t.map((g,k)=>[g.path,k])),d=g=>{var k;return u.get(((k=g.status)==null?void 0:k.path)??"")??u.get(g.path)??Number.MAX_SAFE_INTEGER},p=s.filter(g=>g.status).sort((g,k)=>d(g)-d(k)||g.path.localeCompare(k.path)),m=s.filter(g=>!g.status).sort((g,k)=>g.path.localeCompare(k.path));return{rows:[...p,...m].slice(0,o),changed:Math.min(p.length,o)}}const c=[];for(const u of s){const d=u.path.toLowerCase();let p=ty(d,a);p<=0||(ty(d.slice(d.lastIndexOf("/")+1),a)>0&&(p+=10),u.status&&(p+=4),c.push({row:u,score:p}))}return c.sort((u,d)=>d.score-u.score||u.row.path.localeCompare(d.row.path)),{rows:c.slice(0,o).map(u=>u.row),changed:0}}function r2(e,t){const n=e.toLowerCase(),o=[];let s=0;for(const a of t.toLowerCase()){const c=n.indexOf(a,s);if(c===-1)return null;o.push(c),s=c+1}return o}function ty(e,t){let n=0,o=0,s=0;for(const a of t){const c=e.indexOf(a,o);if(c===-1)return 0;s=c===o?s+1:1,n+=s+(c===0||e[c-1]==="/"||e[c-1]==="."?3:0),o=c+1}return n+Math.max(0,40-e.length/4)}function o2(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const ny=[],i2=[],s2=[];function a2({worktreeId:e}){var b;const t=st(),n=nt(),o=Yv(e),s=o.files??i2,a=((b=o.git)==null?void 0:b.files)??s2,c=a0(),u=z(_=>{var I;return((I=_.paletteReturn)==null?void 0:I.mode)==="quick-open"?_.paletteReturn.q:""}),d=z(_=>{var C;const I=(C=cn(_,e))==null?void 0:C.worktree;return I?co(I):null}),p=z(_=>{var I;return((I=cn(_,e))==null?void 0:I.repoId)??null}),m=z(_=>{var I;return((I=np(_))==null?void 0:I.worktreeId)===e}),g=k0(e,p),k=o.page.url?Rc(o.page.url):null,w=O.useCallback((_,I)=>I.startsWith(">")?l0(c,I.slice(1)).map(C=>({kind:"cmd",c:C})):I.startsWith("/")?m?g0(g,{query:I,current:"/",here:k}).map(C=>({kind:"page",page:C})):ny:E0(s,a,I).rows.map(C=>({kind:"file",path:C.path,status:C.status})),[c,s,a,m,g,k]);return h.jsx(wr,{items:ny,filter:w,keyOf:_=>_.kind==="cmd"?`c:${_.c.id}`:_.kind==="page"?`p:${_.page.kind}:${_.page.path}`:`f:${_.path}`,rowClass:_=>_.kind==="file"?"qo-file":"picker-row",rowTitle:_=>_.kind==="page"?v0(_.page):void 0,completionOf:(_,I)=>_.kind==="page"?p0(_.page,I):null,narrowTo:(_,I)=>_.kind==="page"?w0(_.page,I):null,onPick:(_,I)=>{_.kind==="cmd"?(_.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:I}}):t({a:"close"}),_.c.run()):_.kind==="page"?(Nt.post(e,{type:"navigate",path:_.page.path}),t({a:"close"})):(bo({dispatch:t},{worktreeId:e,path:_.path,view:"file"}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:_=>_.kind==="file"&&d?oi({id:e,dir:d},_.path,{},{sock:n,dispatch:t}):_.kind==="page"&&p?x0(_.page,{worktreeId:e,repoId:p,dir:d},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(_,I)=>I.startsWith("/")?{complete:"completes the path",pick:(_==null?void 0:_.kind)==="page"?b0(_.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:u,empty:_=>_.startsWith(">")?"no matching command":_.startsWith("/")?m?"no pages yet; type a path":"no preview running":"no matches",row:(_,I,C)=>_.kind==="cmd"?_0(_.c,C.slice(1)):_.kind==="page"?h.jsx(y0,{row:_.page}):S0(_.path,_.status,C)})}function S0(e,t,n){const[o,s]=o2(e),a=n.trim()?r2(e,n.trim()):null;return h.jsxs(h.Fragment,{children:[h.jsx("span",{className:`xy ${t?kv(t.xy):""}`,children:t?yv(t.xy):""}),h.jsx("span",{className:"name",children:kc(o,a,s.length)}),h.jsx("span",{className:"dir row-dim",children:s&&h.jsxs(h.Fragment,{children:["‎",kc(s,a,0),"‎"]})}),t&&h.jsx(u0,{f:t})]})}const ji=e=>/[.!?]$/.test(e)?e:`${e}.`;function ia(e){const t=`PR #${e.number}`;if(e.state==="merged")return`${t} merged; main here is behind origin.`;if(e.state==="closed")return`${t} was closed without merging.`;if(e.automerge){const n=e.review==="review_required"?"it is approved and checks pass":"checks pass";return`${t} open; GitHub merges it when ${n}.`}return e.mergeable===!1?`${t} open; it conflicts with main.`:e.review==="changes_requested"?`${t} open; changes requested.`:e.checks==="fail"?`${t} open; checks failed.`:e.checks==="pending"?`${t} open; checks running.`:e.review==="review_required"?`${t} open; waiting on review.`:e.review==="approved"?`${t} approved${e.checks==="pass"?", checks pass":""}.`:`${t} open and ready to merge.`}function N0(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 T0=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function ry(e){var t,n;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const o=(n=(t=e.checkTail)==null?void 0:t.split(`
192
- `).find(s=>s.trim()))==null?void 0:n.trim();return`Check failed${o?`: ${ji(o)}`:"."}`}return null}function oy(e,t){const n=t>0?`${t} ${t===1?"file":"files"} changed`:"",o=e.check==="pass"?"check passed":"",s=[n,o].filter(Boolean).join(", ");return s?ji(T0(s)):""}function l2(e){return e.why?ji(T0(e.why)):null}function Jd(e){return ji(e)}function c2(e,t,n){const o=n==="now"?"just now":`${n} ago`;switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${ji(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${o}: not logged in.`:t.error?`Failed ${o}: ${ji(t.error)}`:`Failed ${o}.`;case"stopped":return`Stopped ${o}.`;case"done":return t.cut?`Ended early ${o} (${t.cut}).`:`Finished ${o}.`}}function I0(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?ji(t):c2(e.end,e.facts,xa(e.at))}function u2(e,t,n,o){return!!(e!=null&&e.recap)&&t===e.at&&n&&!o}const d2=/^[^\s]*$/;function f2(e,t){if(e.startsWith("!"))return null;if(e.startsWith("/")){const a=e.indexOf(" "),c=a===-1?e.length:a;if(t<=c)return{kind:"command",query:e.slice(1,t),from:0,to:c}}const n=e.lastIndexOf("@",Math.max(0,t-1));if(n===-1||n>=t||n>0&&!/\s/.test(e[n-1]??""))return null;const o=e.slice(n+1,t);if(!d2.test(o))return null;let s=t;for(;s<e.length&&!/\s/.test(e[s]??"");)s++;return{kind:"file",query:o,from:n,to:s}}function p2(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function h2(e,t){const n=t.trim().toLowerCase();if(!n)return e;const o=a=>e.map(c=>({c,score:a(c)})).filter(c=>c.score>0).sort((c,u)=>u.score-c.score||c.c.name.localeCompare(u.c.name)).map(c=>c.c),s=o(a=>Cf(a.name,n));return s.length>0?s:o(a=>Cf(a.description,n))}function bc(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 O0(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}const R0="application/x-toyon-source";function LP(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function m2(e,t){e.setData(R0,JSON.stringify(t))}const iy=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function g2(e,t){const n=e.getData(R0);if(!n||!t)return null;let o;try{o=JSON.parse(n)}catch{return null}if(!o||o.worktreeId!==t||typeof o.path!="string"||!o.path)return null;const{startLine:s,endLine:a,ref:c}=o;return!iy(s)||!iy(a)||a<s?null:{path:o.path,startLine:s,endLine:a,...typeof c=="string"?{ref:c}:{}}}const rc={el:null},k2=80,y2=2e3;let Hr=null,jf;const C0=(e,t)=>{clearTimeout(jf),jf=setTimeout(()=>Rp(e),t)};function j0(e,t){Hr??(Hr={refused:!1}),e.dispatch({a:"drag-files",v:t&&!Hr.refused}),C0(e,y2)}function v2(e){Hr&&C0(e,k2)}function Rp(e){clearTimeout(jf),Hr=null,e.dispatch({a:"drag-files",v:!1})}function w2(e){Hr&&(Hr.refused=!0,e.dispatch({a:"drag-files",v:!1}))}async function A0(e,t,n){var u;if(!t||n.length===0)return;const o=Uc(e,t,"image");if(o===0)return;const s=await Promise.allSettled(n.slice(0,o).map(Xj)),a=s.flatMap(d=>d.status==="fulfilled"?[d.value]:[]),c=s.find(d=>d.status==="rejected");a.length&&e.dispatch({a:"attach",id:t,items:a}),c?Na(e,String(((u=c.reason)==null?void 0:u.message)??c.reason)):n.length>o&&Na(e,`kept ${o} of ${n.length}: ${zf("image")}`)}async function $0(e,t,n){if(!t||n.length===0)return;const o=Uc(e,t,"paste");if(o!==0){for(const s of n.slice(0,o)){const a=await Gj(s);a===null?Na(e,`${s.name}: not a text file`):ap(e,t,a,{name:s.name})}n.length>o&&Na(e,`kept ${o} of ${n.length}: ${zf("paste")}`)}}function M0(e){const t=e.getState();return ep(cn(t,t.activeId),!!t.draft)}function b2(e,t){const n=(Hr==null?void 0:Hr.refused)??!1;if(Rp(e),n||t.length===0)return;const o=M0(e),s=t.filter(a=>a.type.startsWith("image/"));if(s.length)return void A0(e,o,s);$0(e,o,t)}function P0(e){const t=(Hr==null?void 0:Hr.refused)??!1;Rp(e),t||Na(e,"drop images on the chat to attach them")}const Na=(e,t)=>e.dispatch({a:"toast",toast:{ok:!1,message:t}}),sy=e=>!!e&&Array.from(e.types).includes("Files"),ay=e=>{var t;return e.target instanceof Node&&!!((t=rc.el)!=null&&t.contains(e.target))};function x2(){const e=Xn();O.useEffect(()=>{const t=a=>{a.defaultPrevented||!sy(a.dataTransfer)||(a.preventDefault(),j0(e,ay(a)&&!!M0(e)),a.dataTransfer&&(a.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},n=a=>{var c;a.defaultPrevented||!sy(a.dataTransfer)||(a.preventDefault(),ay(a)?b2(e,Array.from(((c=a.dataTransfer)==null?void 0:c.files)??[])):P0(e))},o=()=>v2(e),s=a=>{a.key==="Escape"&&w2(e)};return window.addEventListener("dragover",t),window.addEventListener("drop",n),window.addEventListener("dragleave",o),window.addEventListener("keydown",s,!0),()=>{window.removeEventListener("dragover",t),window.removeEventListener("drop",n),window.removeEventListener("dragleave",o),window.removeEventListener("keydown",s,!0)}},[e])}function _2(e,t){const n=Xn(),o=O.useRef(!1);return{onPaste:u=>{const d=Kj(u.clipboardData);if(d.length>0)return u.preventDefault(),void A0(n,e,d);const p=Vj(u.clipboardData);if(p.length>0)return u.preventDefault(),void $0(n,e,p);if(o.current)return;const m=u.clipboardData.getData("text/plain"),g=m.trim()?g2(u.clipboardData,t):null;!(g&&m.includes(`
193
- `))&&!N1(m)||(u.preventDefault(),ap(n,e,m,g?{source:g}:{}))},onPasteKey:u=>{o.current=(u.metaKey||u.ctrlKey)&&u.shiftKey&&u.key.toLowerCase()==="v"},onPasteKeyUp:()=>{o.current=!1}}}const ly=[],E2=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),S2=e=>({kind:"cmd",c:e});function N2(e,t,n,o){return e==="command"?o?n===0?"starting the agent to see what it offers…":"no matching command":"no session has run this agent yet, so it has offered no commands":t?"no matches":"listing files…"}function T2(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="changes"?"@changes ":`@${e.path} `}function L0({active:e,draft:t,greenfield:n}){var Mr,rn;const o=st(),s=nt(),a=Xn(),c=!!t,u=(e==null?void 0:e.worktree.id)??null,d=e==null?void 0:e.worktree.repoId,p=ep(e,c),m=Xt(p,"draft"),g=Xt(p,"attachments"),k=Xt(p,"walk"),w=Xt(u,"chat"),b=Xt(u,"queue"),_=sp(),I=Xt(_,"page"),C=Fc(),{onPaste:E,onPasteKey:Z,onPasteKeyUp:M}=_2(p,u),$=L=>p&&o({a:"set-draft",id:p,text:L}),D=z(L=>L.clientId),q=z(L=>L.repos.find(Ze=>Ze.id===(e==null?void 0:e.worktree.repoId))??null),J=z(L=>L.defaultAgent),se=!!e&&Zn(e.worktree),me=()=>se,[Oe,ae]=O.useState(me);Bt([u],()=>ae(me()));const ie=c||Oe||!!n,Y=!ie&&!!e&&!e.worktree.agent,de=ie||Y,ge=se?(t==null?void 0:t.agent)??J:(e==null?void 0:e.worktree.agent)??J,Ee=z(L=>L.agents.find(Ze=>Ze.id===(de?ge:e==null?void 0:e.worktree.agent))),X=(Ee==null?void 0:Ee.models)??ly,ce=(Ee==null?void 0:Ee.efforts)??ly,[ee,j]=n0(ge),[Q,Ie]=t0(ge),xe=z(L=>L.agents),V=(L,Ze)=>{if(L===ge){j(Ze);return}r0(L,Ze),c?o({a:"draft-agent",id:L}):s==null||s.send({t:"set-default-agent",agent:L})},be=Xt(u,"model"),Ae=Xt(u,"effort"),Pe=Xt(u,"usage")??(e==null?void 0:e.usage),[B]=i0(q),F=(t==null?void 0:t.profile)??B,[Te,lt]=E$(q),Pt=(e==null?void 0:e.worktree.mode)??lf,Ye=z(L=>L.picking),Ge=z(L=>L.termOpen),Ue=gv((e==null?void 0:e.procs)??[]),At=nn("composer"),Tt=Xt(u,"files"),ut=Xt(u,"git"),Vt=(ut==null?void 0:ut.files.length)??(e==null?void 0:e.dirty)??0,K=z(L=>u?L.shipping[u]:void 0),_e=!e||!q?null:ie?m$(se?q.defaultBranch:e.worktree.title,Vt):null,pt=!e||!q||ie||!$c(e)?null:g$(q.defaultBranch,e.behind),It=z(L=>L.rows.find(Ze=>Ze.repoId===d&&Ze.worktree!==void 0&&Zn(Ze.worktree))??null),vn=z(L=>It?L.shipping[It.id]:void 0),vt=It&&(se||ie)?k$(It.behind):null,Gt=((It==null?void 0:It.dirty)??0)>0,te=z(L=>c?tO(L.rows,d,ge,J):u),Be=Xt(te,"commands"),mt=Be.some(L=>L.name==="compact"),it=(e==null?void 0:e.agent)==="working"||(e==null?void 0:e.agent)==="waiting",rt=e==null?void 0:e.worktree.lastTurn,Rn=Xt(u,"recapFor"),Xe=!m.trim()&&g.length===0,wn=!c&&!n&&u2(rt,Rn,Xe,it)?rt:void 0,Lt=!c&&!n&&Xe&&!it&&e&&Xf(e.worktree)?e.worktree.landing:void 0,xr=Vt||(((Mr=ut==null?void 0:ut.committed)==null?void 0:Mr.length)??0),hn=!c&&!n&&Xe&&!it&&!!e,Dn=hn&&!!e.worktree.landed&&Vt===0&&((ut==null?void 0:ut.ahead)??0)===0,Zt=hn&&!Dn?e.worktree.pr:void 0,Fn=fs((q==null?void 0:q.config)??{}),bn=mt&&!it,Jn=()=>u&&(s==null?void 0:s.send({t:"chat",worktreeId:u,text:"/compact"})),R=()=>[{id:"compact",label:"compact the context",detail:"shrink the chat to a summary",disabled:mt?it?"wait for the turn to end":void 0:"this agent offers no compact command",onClick:Jn}],[ne,ve]=O.useState(0),[He,gt]=O.useState(null),[wt,Se]=O.useState(null),Ne=O.useRef(null),we=p?f2(m,ne):null,Rt=we!==null&&we.from!==He&&!k,Ot=we==null?void 0:we.kind,xn=we==null?void 0:we.query,er=O.useMemo(()=>{if(xn===void 0)return[];if(Ot==="command")return h2(Be,xn).slice(0,8).map(S2);const L=[],Ze=(ut==null?void 0:ut.files.length)??0;Ze>0&&"changes".startsWith(xn.toLowerCase())&&L.push({kind:"changes",n:Ze});for(const tt of E0(Tt??[],(ut==null?void 0:ut.files)??[],xn,8).rows)L.push({kind:"file",path:tt.path,status:tt.status});return L},[Ot,xn,Tt,ut,Be]),Cn=O.useRef(null),Wn=()=>{var L;return(L=Cn.current)==null?void 0:L.focus()};O.useEffect(()=>{if(!c)return;const L=requestAnimationFrame(()=>{var Ze;return(Ze=Cn.current)==null?void 0:Ze.focus()});return()=>cancelAnimationFrame(L)},[c]),Bt([n?e==null?void 0:e.worktree.id:null],()=>{if(!n)return;const L=requestAnimationFrame(()=>{var tt;const Ze=document.activeElement;(!Ze||Ze===document.body)&&((tt=Cn.current)==null||tt.focus())});return()=>cancelAnimationFrame(L)});const Cr=z(L=>L.focusRight),jr=O.useRef(Cr),lr=!!Qv();Bt([Cr],()=>{if(Cr===jr.current||(jr.current=Cr,lr!==!!n))return;const L=requestAnimationFrame(()=>{var Ze;return(Ze=Cn.current)==null?void 0:Ze.focus()});return()=>cancelAnimationFrame(L)});const uo=bp({results:er,keyOf:L=>L.kind==="cmd"?`c:${L.c.name}`:L.kind==="changes"?"changes":`f:${L.path}`,q:(we==null?void 0:we.query)??"",listRef:Ne,tabPicks:!0,onPick:L=>{if(!we)return;const{text:Ze,caret:tt}=p2(m,we,T2(L));$(Ze),gt(we.from),Se(L.kind==="cmd"&&L.c.hint?{name:L.c.name,hint:L.c.hint}:null),requestAnimationFrame(()=>{const Ft=Cn.current;Ft&&(Ft.focus(),Ft.setSelectionRange(tt,tt),ve(tt))})}}),kt=u?i$(m):null,tr=wt&&m===`/${wt.name} `?wt.hint:null,Lo=kt===""&&e?` a command to run in ${e.worktree.title}; its output goes on the transcript`:null,Kr=tr??Lo,Ar=(e==null?void 0:e.worktree.title)??"untitled",_n=(rn=rt==null?void 0:rt.recap)==null?void 0:rn.text,fo=()=>{u&&$o(s,o,{t:"land",worktreeId:u})},mn=u?Dn?{word:"close",line:`landed on ${(q==null?void 0:q.defaultBranch)??"main"}.`,tip:"Close this worktree when you are done here; its chat goes to the archive, and the toast offers restore.",run:()=>_a(s,o,[u])}:(Zt==null?void 0:Zt.state)==="open"?N0(Zt)?{word:"merge",line:Jd(_n??ia(Zt)),tip:`${ia(Zt)} Merge the PR now, by the method the repo allows.`,run:fo,ships:!0}:{word:"view",line:Jd(_n??ia(Zt)),tip:`${ia(Zt)} Open the PR on GitHub.`,run:()=>window.open(Zt.url,"_blank")}:Lt!=null&&Lt.ready&&!ry(Lt)?{word:"land",line:Jd(_n??Lt.subject??(oy(Lt,xr)||"ready")),tip:[oy(Lt,xr),`${Df(Fn,q==null?void 0:q.defaultBranch)}.`,"Tab edits the message first."].filter(Boolean).join(" "),run:fo,ships:!0}:null:null,$t=Lt?ry(Lt):null,zo=e?mn?"":Zt?ia(Zt):$t||(wn?I0(wn):n?`describe ${Ar}…`:c||ie?"describe a change":se?"message the agent; / for a command, ! for a shell command":`message agent on ${Ar}; / for a command, ! for a shell command`):"no worktree selected",$r=m!==""||Kr||!e?null:mn?mn.word==="land"&&Lt?l2(Lt):null:Zt||$t?_n??(Lt==null?void 0:Lt.subject)??null:wn?null:_e||(ie&&se&&!c?[h.jsx(Or,{k:yt("new")},"k")," drafts one with variants, batch, agent and profile"]:null),En=O.useRef(!1);O.useEffect(()=>{const L=Rt&&!En.current;En.current=Rt,L&&((we==null?void 0:we.kind)==="file"&&u?s==null||s.send({t:"list-files",worktreeId:u}):(we==null?void 0:we.kind)==="command"&&te&&Be.length===0&&(s==null||s.send({t:"list-commands",worktreeId:te})))},[Rt,we==null?void 0:we.kind,Be.length,u,te,s]);const Vr=()=>{if(!e)return;const L=[],Ze=I;if(Ze.url)try{const on=new URL(Ze.url);L.push(`current route: ${on.pathname}${on.search}`)}catch{}Ze.title&&L.push(`page title: ${Ze.title}`),Ze.errors.length&&L.push(`recent console errors:
194
- ${Ze.errors.map(on=>`- ${on}`).join(`
195
- `)}`);const tt=[];n&&tt.push(h$(e.worktree.title,q==null?void 0:q.configFile)),L.length>0&&tt.push(`[Live preview context, attached automatically. This is what the user is looking at right now:
196
- ${L.join(`
197
- `)}]`);const Ft=s$(w);return Ft&&tt.push(Ft),tt.length>0?tt.join(`
198
-
199
- `):void 0},pe=()=>{if(!e||!u||!p||!m.trim())return;if(kt!==null){kt&&(s==null||s.send({t:"exec",worktreeId:u,command:kt})),$("");return}if(t!=null&&t.batch&&g.length){o({a:"toast",toast:{ok:!1,message:"a batch takes no attachments; remove them or turn batch off"}});return}const L=m.trim(),Ze=Vr(),tt=g.length?g.map(qO):void 0;if(ie){const Ft={clientId:D,repoId:e.worktree.repoId,...se?{}:{baseWorktreeId:u},context:Ze,attachments:tt,agent:ge,profile:F,mode:Te,...ee?{model:ee}:{},...Q?{effort:Q}:{}};if(se&&ge!==J&&(s==null||s.send({t:"set-default-agent",agent:ge})),t!=null&&t.batch)s==null||s.send({t:"batch-worktrees",repoId:e.worktree.repoId,prompt:L,agent:ge,...ee?{model:ee}:{},...Q?{effort:Q}:{}});else if(t&&t.variants>1){const on=Math.random().toString(36).slice(2,10);for(let xo=0;xo<t.variants;xo++)s==null||s.send({t:"create-worktree",...Ft,prompt:L,variant:{group:on,index:xo+1,of:t.variants}})}else s==null||s.send({t:"create-worktree",...Ft,prompt:L})}else Y&&(s==null||s.send({t:"set-worktree-model",worktreeId:u,model:ee}),s==null||s.send({t:"set-worktree-effort",worktreeId:u,effort:Q})),s==null||s.send({t:"chat",worktreeId:u,text:L,context:Ze,attachments:tt});g.length&&o({a:"clear-attachments",id:p}),$(""),n&&o({a:"show-right"}),c&&o({a:"close-draft"})},Re=z(L=>L.autoSend);Bt([Re,u],()=>{!Re||Re!==u||!m.trim()||lr!==!!n||(o({a:"auto-sent"}),pe())});const et=()=>{const L=g[g.length-1];return!p||!L?!1:(o({a:"detach",id:p,key:L.key}),!0)},Qe=L=>{p&&(o({a:"walk",id:p,walk:L.walk,text:L.text}),requestAnimationFrame(()=>{var Ze;(Ze=Cn.current)==null||Ze.setSelectionRange(L.text.length,L.text.length),ve(L.text.length)}))},zt=()=>{p&&k&&o({a:"walk",id:p,walk:null,text:m})},Dt=ie?[]:w.map(L=>L.kind==="user"?L.attachments:void 0),nr=e?co(e.worktree):null;return h.jsxs("div",{className:"composer chat-input",children:[p&&Kx(g,Wx(Dt)).map(([L,Ze])=>{const tt=()=>o({a:"detach",id:p,key:L.key});return L.kind==="image"?h.jsx(Nw,{src:Jj(L),n:Ze,name:L.name,width:L.width,height:L.height,bytes:L.bytes,onRemove:tt},L.key):L.kind==="paste"?h.jsx(Tw,{n:Ze,name:L.name,source:L.source,lines:L.lines,chars:L.chars,preview:L.preview,onRemove:tt},L.key):h.jsx(Iw,{pick:L,dir:nr,tipText:L.html,onHover:Ft=>_&&Nt.post(_,Ft?{type:"highlight-selector",selector:L.selector,label:Jf(L)}:{type:"highlight-clear"}),onOpen:(Ft,on)=>u&&Bc(a,s,u,Ft,on),onRemove:tt},L.key)}),Rt&&we&&h.jsx(f$,{results:er,keyOf:L=>L.kind==="cmd"?`c:${L.c.name}`:L.kind==="changes"?"changes":`f:${L.path}`,rowClass:L=>L.kind==="file"?"qo-file":L.kind==="changes"?"picker-row":"picker-row picker-cmd",nav:uo,listRef:Ne,empty:N2(we.kind,Tt,Be.length,te!==null),row:L=>L.kind==="file"?S0(L.path,L.status,we.query):L.kind==="changes"?h.jsx(Pn,{label:"@changes",hint:`${L.n} uncommitted ${L.n===1?"file":"files"}`}):h.jsx(C$,{c:L.c,query:we.query})}),h.jsxs("div",{className:ot("composer-field",kt!==null&&"shell",k&&"recalled"),children:[h.jsx(Pa,{size:"lg",bare:!0,font:kt!==null?"mono":"ui",ref:Cn,value:m,onChange:L=>{$(L.target.value),ve(L.target.selectionStart??L.target.value.length),uo.setIndex(0),gt(null)},onKeyUp:L=>{M(),ve(L.currentTarget.selectionStart??0)},onClick:L=>{ve(L.currentTarget.selectionStart??0),zt()},onPaste:E,onKeyDown:L=>{if(Z(L),!L.nativeEvent.isComposing){if(Rt){if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),gt((we==null?void 0:we.from)??null);return}if(uo.onKeyDown(L))return}if(L.key==="ArrowUp"||L.key==="ArrowDown"){const Ze=b.at(-1);if(L.key==="ArrowUp"&&!k&&m===""&&u&&!c&&Ze!==void 0){L.preventDefault(),s==null||s.send({t:"unqueue",worktreeId:u,index:b.length-1}),Qe({walk:null,text:Ze});return}const tt=u?a$(w,k??null,m,L.key==="ArrowUp"?"up":"down"):null;if(tt){L.preventDefault(),(tt.walk!==k||tt.text!==m)&&Qe(tt);return}}if(k&&L.key==="Escape"){L.preventDefault(),L.stopPropagation(),Qe({walk:null,text:k.from});return}if(L.key==="Escape"&&it&&u&&!c){L.preventDefault(),L.stopPropagation(),s==null||s.send({t:"stop-agent",worktreeId:u});return}if(k&&E2.has(L.key)&&zt(),L.key==="Tab"&&!L.shiftKey&&m===""&&(Lt!=null&&Lt.subject)){L.preventDefault(),o({a:"edit-commit"});return}L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),pe()):L.key==="Backspace"&&m===""&&et()&&L.preventDefault()}},placeholder:$r||mn?"":zo,disabled:!e}),Kr&&h.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[h.jsx("span",{className:"picker-typed",children:m}),Kr]}),($r||mn)&&h.jsxs("div",{className:"composer-ghost","aria-hidden":mn?void 0:"true",children:[h.jsx("span",{className:"composer-placeholder",children:mn?h.jsxs(h.Fragment,{children:[h.jsx(De,{variant:"inline",tone:"strong",className:"composer-verb",busy:!!mn.ships&&K==="land",disabled:!!mn.ships&&!!K&&K!=="land",...St(mn.tip,void 0,{placement:"top"}),onClick:mn.run,children:mn.word}),`: ${mn.line}`]}):zo}),$r&&h.jsxs(h.Fragment,{children:[`
200
- `,h.jsx("span",{className:"composer-subline",children:$r})]})]})]}),h.jsxs("div",{className:"hint composer-knobs",children:[h.jsxs("span",{className:"spawn-left",children:[se&&!n&&!c&&e&&h.jsx(T$,{title:Ar,value:Oe?"new":"here",onChange:L=>ae(L==="new"),onClose:Wn}),de?se&&xe.length>1?h.jsx(o0,{agents:xe,agent:ge,model:ee,onChange:V,onClose:Wn}):h.jsx(Rf,{models:X,value:ee,onChange:j,onClose:Wn}):e&&h.jsx(Rf,{models:X,value:e.worktree.model??"",current:be,onChange:L=>s==null?void 0:s.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:L}),onClose:Wn}),de?h.jsx(Of,{efforts:ce,value:Q,onChange:Ie,onClose:Wn}):e&&h.jsx(Of,{efforts:ce,value:e.worktree.effort??"",current:Ae,onChange:L=>s==null?void 0:s.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:L}),onClose:Wn}),ie?h.jsx(ey,{value:Te,onChange:lt,onClose:Wn}):e&&h.jsx(ey,{value:Pt,onChange:L=>s==null?void 0:s.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:L}),onClose:Wn}),Pe&&!ie&&u&&h.jsx(Kt,{icon:h.jsx(p$,{fraction:Pe.used/Pe.size}),tone:"chrome",label:`${Math.round(100*Pe.used/Pe.size)}% of context`,detail:`${bc(Pe.used)} of ${bc(Pe.size)}${Pe.cost!==void 0?` · ${O0(Pe.cost)} this session`:""}${bn?" · click to compact":""}`,onClick:L=>{bn?Jn():At.openUnder(L.currentTarget,R)},...At.contextMenu(R)})]}),h.jsxs("span",{className:"spawn-tools",children:[!n&&h.jsx(Kt,{icon:"terminal",tone:"chrome",on:Ge,className:"composer-term",disabled:!e,label:Ue?Ue.tip:"Terminal",hint:yt("terminal"),badge:Ue&&h.jsx("span",{className:"composer-term-dot"}),onClick:()=>{o(Ue&&!Ge&&u?{a:"term-stream",id:u,stream:Ue.stream}:{a:"toggle-terminal"})},...At.contextMenu(()=>e&&u?u$(e.procs,u,Ge,{sock:s,dispatch:a.dispatch}):[])}),!n&&!C&&h.jsx(Kt,{icon:"pick",label:"Pick an element on the page to attach",hint:yt("pick"),on:Ye==="chat",disabled:!_,onClick:()=>_&&Ea(_,Ye,o,"chat")})]})]}),vt&&It&&h.jsxs("div",{className:"hint spawn-note",children:[h.jsx("span",{children:vt}),h.jsx(De,{variant:"outline",busy:vn==="pull-main",disabled:!!vn||Gt,"data-tip":Gt?`commit or discard the changes on ${q==null?void 0:q.defaultBranch} first`:"Fast-forward main to origin",onClick:()=>$o(s,o,{t:"pull-main",worktreeId:It.id}),children:"pull"})]}),pt&&e&&u&&h.jsxs("div",{className:"hint spawn-note",children:[h.jsx("span",{children:pt}),h.jsx(De,{variant:"outline",busy:K==="sync-main",disabled:!!K||Vt>0,"data-tip":Vt>0?"commit or discard the changes here first":`Merge ${q==null?void 0:q.defaultBranch} into this worktree`,onClick:()=>$o(s,o,{t:"sync-main",worktreeId:u}),children:"sync"})]})]})}const I2=[1,2,3];function O2({draft:e,base:t}){const n=st(),o=z(c=>Ai(c,t==null?void 0:t.repoId)),[s]=i0(o),a=t&&!Zn(t.worktree)?t.worktree.title:null;return h.jsx("div",{className:"chat-wrap",children:h.jsxs("div",{className:"draft-intro",children:[a&&h.jsxs("p",{className:"hint",children:["from ",h.jsx("b",{children:a}),", work not landed included"]}),h.jsxs("div",{className:"draft-row hint",children:[h.jsx(De,{variant:"ghost",tone:"chrome",on:e.batch,"data-tip":"An agent splits the prompt into a worktree per task",onClick:()=>n({a:"draft-batch",v:!e.batch}),children:"batch"}),h.jsxs("span",{className:"draft-variants",children:[I2.map(c=>h.jsx(De,{variant:"ghost",on:e.variants===c,disabled:e.batch,onClick:()=>n({a:"draft-variants",n:c}),children:c},c)),h.jsx("span",{"data-tip":"Run the same prompt in N parallel worktrees, keep the best",children:"variants"})]}),h.jsx("span",{className:"draft-runs",children:h.jsx(N$,{repo:o,value:e.profile??s,onChange:c=>n({a:"draft-profile",profile:c})})})]})]})})}function z0({placement:e,className:t,width:n}){const o=st(),s=$i(),a=ZO(),c=Ca(),u=e==="centre"&&(c!=null&&c.assumed)?c:null,d=z(p=>p.dragFiles);return h.jsxs("div",{className:ot(e==="dock"?"right-dock":"chat-centre",t,d&&"drop-over"),style:n===void 0?void 0:{width:n},ref:p=>{var m;p?rc.el=p:(m=rc.el)!=null&&m.isConnected||(rc.el=null)},children:[a?h.jsx(O2,{draft:a,base:s}):h.jsx(c$,{active:s,lead:u&&h.jsxs("p",{className:"hint chat-centre-note",children:[u.name," has ",h.jsx("code",{children:u.assumed})," and no dev server, so it is chat only for now."," ",h.jsx(De,{variant:"inline",onClick:()=>o({a:"open",overlay:{kind:"setup",repoId:u.id}}),children:"add a dev server"})]})}),h.jsx(L0,{active:s,draft:a})]})}function Af(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>Ln(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>Ln(t)}]}function $f(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>Ln(e)}]}function R2(e,t,{sock:n},o){return t?Hn([[{id:"source",label:"open source",onClick:o}],bs(`${e.dir}/${t}`,()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t})),[{id:"copy-path",label:"copy path",onClick:()=>Ln(t)}]]):[]}function D0({items:e,current:t,onPick:n,fill:o,font:s,end:a,label:c,owner:u}){const d=nn(u),p=O.useRef(null),m=g=>{var b,_;if(g.key!=="ArrowLeft"&&g.key!=="ArrowRight")return;g.preventDefault();const k=e.findIndex(I=>I.id===t),w=e[wp(k,g.key==="ArrowRight"?1:-1,e.length)];w&&(n(w.id),(_=(b=p.current)==null?void 0:b.querySelectorAll('[role="tab"]')[e.indexOf(w)])==null||_.focus())};return h.jsxs("div",{className:ot("tabs",o&&"tabs-fill",s==="mono"&&"tabs-mono"),children:[h.jsx("div",{className:"tabs-list",role:"tablist","aria-label":c,ref:p,onKeyDown:m,children:e.map(g=>{const k=g.id===t;return h.jsxs("div",{className:ot("tab",k&&!!g.trail&&"tab-trailed"),"data-state":Rr({current:k}),...g.menu?d.contextMenu(g.menu):{},children:[h.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":k,tabIndex:k?0:-1,onClick:()=>n(g.id),...g.tip,children:[g.lead,g.label]}),k&&g.trail&&h.jsx("span",{className:"tab-trail",children:g.trail})]},g.id)})}),a&&h.jsx("span",{className:"tabs-end",children:a})]})}function Cp({className:e,height:t,resizable:n=!0,onDragStart:o,title:s,tabs:a,actions:c,menu:u,full:d,onToggleFull:p,onClose:m,closeHint:g="esc",children:k}){const w=nn("pane"),b=p&&h.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:p,"data-tip":d?"Split view: show the preview above":"Full height: hide the preview",children:[h.jsx(Ct,{name:d?"split":"full",className:"icon-inline"})," ",d?"split":"full"]}),_=h.jsx(Kt,{icon:"close",label:"Close",hint:g,onClick:m});return h.jsxs("div",{className:`pane ${e}`,style:t===void 0?void 0:{height:t},children:[n&&h.jsx("div",{className:"pane-resize",onPointerDown:o}),h.jsx("div",{className:ot("pane-head",a&&"pane-head-tabs"),...w.contextMenu(()=>(u==null?void 0:u())??[]),children:a?h.jsx(D0,{...a,end:h.jsxs(h.Fragment,{children:[c,b,_]})}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"pane-title",children:s}),c,b,_]})}),k]})}function Ta(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());if(!t)return null;const n=t[1],o=n.length===3||n.length===4?[...n].map(a=>a+a).join(""):n;if(o.length!==6&&o.length!==8)return null;const s=Number.parseInt(o.slice(0,6),16);return[s>>16&255,s>>8&255,s&255]}function C2(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function cy([e,t,n]){const o=s=>{const a=s/255;return a<=.03928?a/12.92:((a+.055)/1.055)**2.4};return .2126*o(e)+.7152*o(t)+.0722*o(n)}function F0(e,t){if(C2(e))return null;const n=Ta(e);if(!n)return null;const o=Ta(t);if(!o)return null;const[s,a]=[cy(n),cy(o)];return`${((Math.max(s,a)+.05)/(Math.min(s,a)+.05)).toFixed(2)}:1`}function j2({worktreeId:e,height:t,full:n,onToggleFull:o,onDragStart:s}){const a=st(),c=nt(),u=z(p=>lo(p,e).design);O.useEffect(()=>{u||c==null||c.send({t:"design-scan",worktreeId:e})},[u,e,c]),O.useEffect(()=>()=>Nt.post(e,{type:"highlight-clear"}),[e]);const d={outline:p=>Nt.post(e,p),clear:()=>Nt.post(e,{type:"highlight-clear"}),open:p=>bo({dispatch:a},{worktreeId:e,path:p})};return h.jsx(Cp,{className:ot("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:s,title:u?h.jsx("span",{children:P2(u)}):void 0,onClose:()=>a({a:"toggle-design"}),full:n,onToggleFull:o,actions:h.jsxs(De,{variant:"outline",onClick:()=>c==null?void 0:c.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[h.jsx(Ct,{name:"reload",className:"icon-inline"})," rescan"]}),children:u?h.jsxs("div",{className:"design-body",style:M2,onMouseLeave:d.clear,children:[u.tokens.length===0&&u.literals.length>0?h.jsx(B2,{literals:u.literals,outline:d.outline,clear:d.clear}):h.jsx(F2,{tokens:u.tokens,coverage:u.coverage,outline:d.outline,clear:d.clear}),h.jsx(Q2,{index:u,outline:d.outline,clear:d.clear,onOpen:d.open}),h.jsx(X2,{index:u,outline:d.outline,clear:d.clear,onOpen:d.open})]}):h.jsx("div",{className:"empty",children:"reading the design system…"})})}const A2=720,$2=132,M2={"--design-column":`${A2}px`,"--design-cell":`${$2}px`};function P2(e){const t=Object.values(e.coverage.files).reduce((o,s)=>o+s,0),n=e.coverage.stylesheets;return`${t} file${t===1?"":"s"} read, ${n} stylesheet${n===1?"":"s"}`}const ds=e=>`${e} use${e===1?"":"s"}`;function Vc({title:e,note:t,children:n}){return h.jsxs("section",{className:"design-section",children:[h.jsxs("h2",{className:"design-h",children:[e,t&&h.jsx("span",{className:"design-note",children:t})]}),n]})}function xc({children:e}){return h.jsx("p",{className:"design-gap",children:e})}const L2=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function z2(e){return e.find(t=>t.kind==="color"&&Ta(t.resolved??t.value)!==null)}function D2(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),o="No custom properties, and no colors or sizes written out in the stylesheets.";return n>0?`${o} Sass, Less and Stylus variables are not read yet.`:o}function F2({tokens:e,coverage:t,outline:n,clear:o}){const s=z2(e),a=s&&(s.resolved??s.value),c=new Map;for(const d of e){const p=(d.resolved??d.value).trim().toLowerCase();c.set(p,[...c.get(p)??[],d.name])}const u=d=>(c.get((d.resolved??d.value).trim().toLowerCase())??[]).filter(p=>p!==d.name);return h.jsx(Vc,{title:"Tokens",children:e.length===0?h.jsx(xc,{children:D2(t)}):L2.map(({kind:d,label:p})=>{const m=e.filter(k=>k.kind===d);if(m.length===0)return null;const g=B0(m.map(k=>k.value));return h.jsxs("div",{className:"design-group",children:[d!=="font"&&h.jsx("span",{className:"design-group-name",children:p}),d==="font"?h.jsx(Z0,{groups:V2(m),outline:n,clear:o}):h.jsx("div",{className:"design-breakout",style:U0(m.length),children:h.jsx("div",{className:"design-grid",children:m.map(k=>{const w=k.resolved??k.value,b=k.kind==="color"&&a?F0(w,a):null;return h.jsx(H0,{kind:k.kind,name:k.name,lines:k.resolved?[k.value,k.resolved]:[k.value],actual:w,ratio:b,largest:g,tipText:q2(k,b,s,u(k)),menu:()=>Af(k.name,w),outline:n,clear:o},k.name)})})})]},d)})})}const U2=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function B2({literals:e,outline:t,clear:n}){const o=e.find(a=>a.ground&&Ta(a.value)!==null),s=G2(e);return h.jsxs(Vc,{title:"Values",note:"written out in the rules; no custom properties",children:[s.length>0&&h.jsx("div",{className:"design-group",children:h.jsx(Z0,{groups:s,outline:t,clear:n})}),U2.map(({role:a,kind:c,label:u})=>{const d=e.filter(m=>m.role===a);if(d.length===0)return null;const p=B0(d.map(m=>m.value));return h.jsxs("div",{className:"design-group",children:[h.jsx("span",{className:"design-group-name",children:u}),h.jsx("div",{className:"design-breakout",style:U0(d.length),children:h.jsx("div",{className:"design-grid",children:d.map(m=>{const g=c==="color"&&o?F0(m.value,o.value):null;return h.jsx(H0,{kind:c,name:m.value,lines:[ds(m.uses)],actual:m.value,ratio:g,largest:p,tipText:Y2(m,g,o),menu:()=>$f(m.value),outline:t,clear:n},m.value)})})})]},a)})]})}function U0(e){const t="var(--design-cell)",n=`min(round(down, 100%, ${t}), calc(${e} * ${t}))`,o=`round(down, var(--design-column), ${t})`,s=`round(down, max(0px, calc((${n} - ${o}) / 2)), ${t})`;return{width:n,marginLeft:`max(0px, calc((100% - var(--design-column)) / 2 - ${s}))`}}function B0(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const Z2=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function H2(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(o=>[o,n.getPropertyValue(o)])}const Mf=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function W2(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:Mf(e),size:null,lead:null};const n=Number(t[1]),o=t[2]?Number(t[2]):null,s=o===null?null:Math.round((t[3]?o:n*o)*100)/100;return{family:Mf(t[4]??""),size:n,lead:s}}function ef(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 K2(e,t){if(!e)return null;const n=Number.parseFloat(e),o=/^[\d.]+$/.test(e)?t*n:e.endsWith("px")?n:null;return o===null?null:Math.round(o*100)/100}function V2(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...W2(n.resolved??n.value)}));return[...new Set(t.map(n=>n.family))].map(n=>{const o=t.filter(a=>a.family===n),s=o.find(a=>a.size===null);return{family:n,stack:s?s.actual:n,name:s==null?void 0:s.token.name,label:s?s.token.name:n,tipText:s?`${s.token.name}
201
- ${s.actual}`:void 0,menu:()=>s?Af(s.token.name,s.actual):[],rows:o.filter(a=>a.size!==null).sort((a,c)=>(c.size??0)-(a.size??0)).map(a=>({key:a.token.name,sample:`${a.family} ${a.size}${a.lead===null?"":`/${a.lead}`}`,style:{font:a.actual},name:a.token.name,label:a.token.name,tipText:`${a.token.name}
202
- ${a.actual}`,menu:()=>Af(a.token.name,a.actual)}))}})}function G2(e){const t=e.filter(s=>s.role==="family"),n=e.filter(s=>s.role==="size");return[...new Set([...t.map(s=>s.value),...n.map(s=>s.family??"initial")])].map(s=>{const a=t.find(u=>u.value===s),c=s==="initial"?"default face":Mf(s);return{family:c,stack:s,name:a?ds(a.uses):void 0,label:c,tipText:a?`${a.value}
203
- ${ds(a.uses)}: ${a.selectors.join(", ")}`:void 0,menu:()=>a?$f(a.value):[],rows:n.filter(u=>(u.family??"initial")===s).sort((u,d)=>ef(d.value)-ef(u.value)).map(u=>{const d=ef(u.value),p=K2(u.lead,d),m=u.value.endsWith("px")?`${d}`:u.value;return{key:`${u.value}/${u.lead??""}`,sample:`${c} ${m}${p===null?"":`/${p}`}`,style:{fontFamily:s,fontSize:u.value,lineHeight:u.lead},name:ds(u.uses),label:u.value,tipText:`${u.value}${u.lead?` / ${u.lead}`:""}
204
- ${ds(u.uses)}: ${u.selectors.join(", ")}`,menu:()=>$f(u.value)}})}})}function Z0({groups:e,outline:t,clear:n}){const o=(a,c,u)=>t({type:"highlight-computed",props:H2(a.currentTarget.querySelector(".design-face-sample"),c?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:u}),s=nn("design");return h.jsx("div",{className:"design-faces",children:e.map(a=>h.jsxs("div",{className:"design-face-group",children:[h.jsxs("div",{className:"design-face-head row-edge",onMouseEnter:c=>o(c,!1,a.label),onMouseLeave:n,...s.contextMenu(a.menu),...a.tipText?St(a.tipText,void 0,{placement:"follow"}):{},children:[h.jsx("span",{className:"design-face-sample design-face-family",style:{fontFamily:a.stack},children:a.family}),a.name&&h.jsx("span",{className:"design-face-name row-dim",children:a.name})]}),a.rows.map(c=>h.jsxs("div",{className:"design-face row-edge",onMouseEnter:u=>o(u,!0,c.label),onMouseLeave:n,...s.contextMenu(c.menu),...St(c.tipText,void 0,{placement:"follow"}),children:[h.jsx("span",{className:"design-face-sample",style:c.style,children:c.sample}),h.jsx("span",{className:"design-face-name row-dim",children:c.name})]},c.key))]},a.stack))})}function H0({kind:e,name:t,lines:n,actual:o,ratio:s,largest:a,tipText:c,menu:u,outline:d,clear:p}){const m=e==="color"&&Ta(o)!==null,g=e==="length"?Number.parseFloat(o):Number.NaN,k=nn("design");return h.jsxs("div",{className:"design-cell","data-kind":e,...k.contextMenu(u),onMouseEnter:m?w=>{const b=w.currentTarget.querySelector(".design-fill"),_=b?getComputedStyle(b).backgroundColor:"";d({type:"highlight-computed",props:Z2.map(I=>[I,_]),match:"any",label:t})}:void 0,onMouseLeave:m?p:void 0,...St(c),children:[e==="color"&&h.jsx("div",{className:"design-sample",children:m&&h.jsx("span",{className:"design-fill",style:{background:o}})}),h.jsxs("div",{className:"design-plate",children:[h.jsx("span",{className:"design-cell-name",children:t}),n.map((w,b)=>h.jsxs("span",{className:"design-cell-line",children:[h.jsx("span",{className:"design-cell-value",children:w}),b===0&&s&&h.jsx("span",{className:"design-cell-note",children:s})]},w)),Number.isFinite(g)&&a>0&&h.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(g)/a*100)}%`}})]})]})}function q2(e,t,n,o=[]){const s=[e.name,e.resolved?`${e.value} resolves to ${e.resolved}`:e.value];if(o.length>0&&s.push(`same value as ${o.join(", ")}`),t&&n){const a=e.name===n.name;s.push(a?"the ground these ratios are measured against":`${t} against ${n.name}`)}return s.join(`
205
- `)}function Y2(e,t,n){const o=[e.value,`${ds(e.uses)}: ${e.selectors.join(", ")}`];return t&&n&&o.push(e===n?"the page background these ratios are measured against":`${t} against the page background`),o.join(`
206
- `)}function W0({shared:e,rest:t}){return e.length===0?h.jsx("ul",{className:"design-rows",children:t}):h.jsxs(h.Fragment,{children:[h.jsx("ul",{className:"design-rows",children:e}),t.length>0&&h.jsxs("details",{className:"design-tail",children:[h.jsxs("summary",{className:"row-edge",children:[h.jsx("span",{className:"design-count row-dim",children:t.length}),"used once or never"]}),h.jsx("ul",{className:"design-rows",children:t})]})]})}function Q2({index:e,outline:t,clear:n,onOpen:o}){const{components:s,typed:a}=e;if(s.length===0)return null;const c=s.filter(p=>p.imports>=2),u=s.filter(p=>p.imports<2),d=p=>h.jsx(K0,{count:p.imports,name:p.name,path:p.path,onEnter:()=>t({type:"highlight-file",path:p.path,ranges:null}),onLeave:n,onOpen:()=>o(p.path),children:p.variants.length>0&&h.jsx("span",{className:"design-variants",children:p.variants.map(m=>h.jsxs("span",{className:"design-variant",children:[m.prop,": ",m.values.join(" · ")]},m.prop))})},`${p.path}:${p.name}`);return h.jsxs(Vc,{title:"Components",note:`${c.length} reused of ${s.length}`,children:[!a&&h.jsx(xc,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),h.jsx(W0,{shared:c.map(d),rest:u.map(d)})]})}function X2({index:e,outline:t,clear:n,onOpen:o}){const{classes:s,coverage:a}=e,c=s.filter(k=>k.uses>0),u=s.filter(k=>k.uses>=2),d=s.filter(k=>k.uses<2),p=u.filter(k=>k.unwrapped).length,m=s.length?`${u.length} reused of ${s.length}`+(p?`, ${p} with no component of their name`:""):void 0,g=k=>h.jsx(J2,{cls:k,outline:t,clear:n,onOpen:o},k.name);return h.jsx(Vc,{title:"Classes",note:m,children:s.length===0?h.jsx(xc,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):c.length===0?h.jsx(xc,{children:a.classAttrs>0?`${a.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."}):h.jsx(W0,{shared:u.map(g),rest:d.map(g)})})}function J2({cls:e,outline:t,clear:n,onOpen:o}){return h.jsx(K0,{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&&o(e.path),children:e.unwrapped&&h.jsx("span",{className:"design-tag",children:"no component"})})}function K0({count:e,name:t,path:n,onEnter:o,onLeave:s,onOpen:a,children:c}){const u=$i(),d=nt();st();const p=nn("design");return h.jsx("li",{children:h.jsxs("button",{type:"button",className:"design-row row-edge",onMouseEnter:o,onFocus:o,onMouseLeave:s,onBlur:s,onClick:a,disabled:!n,...p.contextMenu(()=>u?R2({id:u.worktree.id,dir:co(u.worktree)},n,{sock:d},a):[]),children:[h.jsx("span",{className:"design-count row-dim",children:e}),h.jsx("span",{className:"design-name",children:t}),h.jsx("span",{className:"design-path row-dim",children:n}),c]})})}const eM="modulepreload",tM=function(e){return"/"+e},uy={},V0=function(t,n,o){let s=Promise.resolve();if(n&&n.length>0){let c=function(p){return Promise.all(p.map(m=>Promise.resolve(m).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),d=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));s=c(n.map(p=>{if(p=tM(p),p in uy)return;uy[p]=!0;const m=p.endsWith(".css"),g=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${g}`))return;const k=document.createElement("link");if(k.rel=m?"stylesheet":eM,m||(k.as="script"),k.crossOrigin="",k.href=p,d&&k.setAttribute("nonce",d),document.head.appendChild(k),m)return new Promise((w,b)=>{k.addEventListener("load",w),k.addEventListener("error",()=>b(Error(`Unable to preload CSS for ${p}`)))})}))}function a(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return s.then(c=>{for(const u of c||[])u.status==="rejected"&&a(u.reason);return t().catch(a)})};function nM({absPath:e,onReveal:t}){const n=nn("editor");return Xv(location.hostname)?h.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",...n.dropdown(()=>bs(e,t),"right"),children:["open in ",h.jsx(Ct,{name:"caret",className:"icon-inline"})]}):null}const rM=O.lazy(()=>V0(()=>import("./Editor-Cn-KsoFr.js").then(e=>e.E),__vite__mapDeps([0,1]))),oM={attach:()=>{},edited:()=>{},saveNow:()=>{}};function iM({editor:e,height:t,full:n,onToggleFull:o,onDragStart:s}){const a=st(),c=Xn(),u=nt(),d=IO(),p=Dc(),{worktreeId:m,path:g,ref:k}=e,w=z(q=>{var se;const J=(se=cn(q,m))==null?void 0:se.worktree;return J&&co(J)}),b=w?`${w}/${g}`:g,_=k!==void 0,I=O.useMemo(()=>(d==null?void 0:d.bind({worktreeId:m,path:g,...k?{ref:k}:{}}))??oM,[d,m,g,k]),C=z(q=>lo(q,m).changedRanges[g]);O.useEffect(()=>{!C&&!_&&(u==null||u.send({t:"changed-ranges",worktreeId:m,path:g}))},[m,g,C,_,u]);const E=(C==null?void 0:C.offset)??0,Z=e.disk,M=e.view??"diff",$=M==="file"?"diff":"file",D=e.line&&!e.line.fiber?e.line.n:void 0;return h.jsxs(Cp,{className:ot("editor-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:s,title:_?`${g} at ${k==null?void 0:k.slice(0,7)}`:g,menu:()=>w?oi({id:m,dir:w},g,{discard:!_,ref:k,showing:e.view??void 0},{sock:u,dispatch:a}):[],onClose:()=>a({a:"close-editor"}),full:n,onToggleFull:o,actions:h.jsxs(h.Fragment,{children:[h.jsxs(De,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>a({a:"editor-view",v:$}),"data-tip":M==="file"?"Diff view: show what changed":"File view: hide the diff",children:[h.jsx(Ct,{name:$==="diff"?"diff":"text",className:"icon-inline"})," ",$]}),h.jsx(nM,{absPath:b,onReveal:()=>u==null?void 0:u.send({t:"reveal",worktreeId:m,path:g})})]}),children:[Z&&h.jsx(sM,{editor:e,disk:Z,files:d}),h.jsx("div",{className:"editor-body",children:Z?Z.binary?h.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):Z.tooLarge?h.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):h.jsx(cp,{pane:!0,children:h.jsx(O.Suspense,{fallback:h.jsxs("div",{className:"empty",children:["loading ",M,"…"]}),children:h.jsx(rM,{file:{worktreeId:m,path:g,...k?{ref:k}:{}},disk:Z,view:M,openSeq:e.seq,line:D,focus:e.focus,readOnly:_||!Z.writable,theme:p,sync:I,onCopy:(q,J,se)=>m2(se,{worktreeId:m,path:q,...J,...k?{ref:k}:{}}),onChat:(q,J)=>YO(c,J&&{worktreeId:m,text:J.text,source:{path:q,startLine:J.startLine,endLine:J.endLine,...k?{ref:k}:{}}}),onLineHover:_?void 0:q=>{q==null?Nt.post(m,{type:"highlight-clear"}):Nt.post(m,{type:"highlight-file",path:g,ranges:[[q+E,q+E]]})}},`${m}
207
- ${k??""}
208
- ${g}`)})}):h.jsxs("div",{className:"empty",children:["loading ",g,"…"]})})]})}function sM({editor:e,disk:t,files:n}){const{worktreeId:o,path:s,ref:a,conflict:c}=e,u={worktreeId:o,path:s,...a?{ref:a}:{}};if(c){const d=c.version===null;return h.jsxs("div",{className:"editor-note",children:[h.jsx("span",{className:"editor-note-text",children:d?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),h.jsx(De,{variant:"outline",onClick:()=>n==null?void 0:n.reload(u),"data-tip":d?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:d?"close":"reload"}),h.jsx(De,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(u),"data-tip":d?"Save your edits as the file again":"Save your edits over the file on disk",children:"keep mine"})]})}return a===void 0&&!t.writable&&!t.binary&&!t.tooLarge?h.jsx("div",{className:"editor-note",children:h.jsx("span",{className:"hint",children:"read-only: Toyon does not run this worktree"})}):null}function jp(e,{sock:t}){var o;const n=[];return 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})}),!e.available&&!e.installing&&n.push({id:"install",label:e.onDemand&&e.reason==="not installed"?"install":"install again",onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}const aM=Qx.map(e=>({title:e,rows:e1(e).map(t=>[yt(t),fa[t].label])}));function lM(){const e=st(),t=nt(),n=nn("keys"),o=z(p=>p.themePrefs),s=z(p=>p.themes),a=op(),c=z(p=>p.agents),u=Ca(),d=p=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(p)};return h.jsxs(Sp,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[h.jsxs("div",{className:"keys-card",children:[h.jsxs("div",{children:[u&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"section-title keys-h",children:u.name}),h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"processes"}),h.jsx(De,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${u.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:u.id}}),...n.contextMenu(()=>Kc(u,u.id,{sock:t,dispatch:e})),children:h.jsx("span",{className:"keys-v",children:Object.keys(u.config.run).join(" + ")||"not set up"})})]})]}),h.jsx("div",{className:"section-title keys-h",children:"Agents"}),c.map(p=>h.jsx(cM,{agent:p},p.id))]}),h.jsxs("div",{children:[h.jsx("div",{className:"section-title keys-h",children:"Appearance"}),h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"mode"}),h.jsx(De,{variant:"field",mono:!0,onClick:()=>d({a:"open",overlay:{kind:"appearance"}}),children:yc[o.mode]})]}),h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"theme"}),h.jsx(De,{variant:"field",mono:!0,onClick:()=>d({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:jc(o,s,a).name})]})]})]}),h.jsx("div",{className:"keys-card",children:aM.map(p=>h.jsxs("div",{children:[h.jsx("div",{className:"section-title keys-h",children:p.title}),p.rows.map(([m,g])=>h.jsxs("div",{className:"keys-row",children:[h.jsx(Or,{k:m}),h.jsx("span",{className:"keys-d",children:g})]},m))]},p.title))})]})}function G0(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:"ready":e.installing?"installing":"not installed"}function q0(e){var n,o;return e.available?e.auth?[e.auth.detail,(n=e.auth.account)==null?void 0:n.email,(o=e.auth.account)==null?void 0:o.organization].filter(Boolean).join(" · ")||e.auth.label:"installed; it names the account it runs on the first time it runs":e.reason??"not installed"}function cM({agent:e}){const t=st(),n=nt(),o=nn("keys");return h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:e.name}),h.jsx(De,{variant:"field",mono:!0,"data-tip":q0(e),...o.contextMenu(()=>jp(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:G0(e)})]})}function uM({agentId:e}){const t=st(),n=nt(),o=Ca(),s=z(k=>k.home),a=z(k=>k.agents.find(w=>w.id===e)??null),c=z(k=>k.agentConfigs[e]??null),u=nn("keys");if(O.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...o?{repoId:o.id}:{}})},[n,e,o]),!a)return null;const d=jp(a,{sock:n}),p=()=>t({a:"close",back:!0}),m=k=>s&&k.startsWith(`${s}/`)?`~${k.slice(s.length)}`:k,g=k=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:k.id,...o?{repoId:o.id}:{}});return h.jsx(Sp,{bare:!0,boxClass:"keys-stack",onClose:p,children:h.jsxs("div",{className:"keys-card keys-settings",children:[h.jsx("div",{className:"agent-page-back",children:h.jsx(Kt,{icon:"back",label:"back to settings",hint:"esc",onClick:p})}),h.jsx("div",{className:"section-title keys-h",children:a.name}),h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"signed in"}),h.jsx(De,{variant:"field",mono:!0,"data-tip":q0(a),disabled:d.length===0,...u.dropdown(()=>d,"right"),children:G0(a)})]}),h.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),c===null?h.jsx("div",{className:"keys-setting",children:h.jsx("span",{className:"keys-d",children:"reading…"})}):c.servers.length===0?h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:"none configured"}),h.jsx("span",{className:"keys-d",children:"add one with the agent's own CLI, or a .mcp.json in the repo"})]}):c.servers.map(k=>h.jsx(dM,{s:k},`${k.scope}:${k.name}`)),c&&c.files.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),c.files.map(k=>h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{className:"keys-d",children:k.label}),k.exists?h.jsx(De,{variant:"field",mono:!0,"data-tip":`reveal ${m(k.path)} in Finder`,onClick:()=>g(k),children:m(k.path)}):h.jsxs("span",{className:"keys-d",children:["not present: ",m(k.path)]})]},k.id))]})]})})}function dM({s:e}){return h.jsxs("div",{className:"keys-setting",children:[h.jsx("span",{children:e.name}),h.jsx("span",{className:"keys-d",children:e.detail?`${e.scope} · ${e.detail}`:e.scope})]})}function fM(){const e=st(),t=nt(),n=z(s=>s.agents),o=z(s=>s.defaultAgent);return h.jsx(wr,{items:n,filter:(s,a)=>s.filter(c=>ys(a,c.name,c.id)),rowClass:s=>s.available?"picker-row":"picker-row dim",keyOf:s=>s.id,initialIndex:s=>Math.max(0,s.findIndex(a=>a.id===o)),onPick:s=>{s.available&&(t==null||t.send({t:"set-default-agent",agent:s.id}),e({a:"close"}))},onBack:()=>e({a:"close",back:!0}),rowMenu:s=>jp(s,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:s=>h.jsx(Pn,{label:s.name,current:s.id===o,hint:s.available?s.sandboxed?void 0:"unsandboxed":s.reason??"not installed"})})}const pM=["dark","light","system","daylight"],hM=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function mM(){const e=st(),t=nt(),n=z(d=>d.themePrefs),o=z(d=>d.themes),s=op(),a=z(d=>d.daylight),c=d=>{var p;return((p=o.find(m=>m.id===n[Qf({...n,mode:d},s)]))==null?void 0:p.name)??""},u=d=>{if(d==="system")return`${s.system?"dark":"light"} now · ${c(d)}`;if(d!=="daylight")return c(d);const p=a&&a.until>Date.now()?` · ${s.daylight?"light":"dark"} at ${hM.format(a.until)}`:"";return`${s.daylight?"dark":"light"} now${p} · ${c(d)}`};return h.jsx(wr,{items:pM,filter:(d,p)=>d.filter(m=>ys(p,yc[m])),rowClass:()=>"picker-row",keyOf:d=>d,initialIndex:d=>d.indexOf(n.mode),onActive:d=>e({a:"preview-theme",theme:d?jc({...n,mode:d},o,s):null}),onPick:d=>{t==null||t.send({t:"set-theme",prefs:{...n,mode:d}}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"light/dark mode",keys:{nav:"preview",pick:"keeps",back:"reverts"},row:d=>h.jsx(Pn,{label:yc[d],current:d===n.mode,hint:u(d)})})}const gM=[],kM=(e,t)=>[e.title,e.branch,e.prompt??""].some(n=>n.toLowerCase().includes(t));function yM({repoId:e}){const t=st(),n=nt(),o=z(c=>c.clientId),s=z(c=>c.archived[e]);O.useEffect(()=>{n==null||n.send({t:"list-archived",repoId:e})},[n,e]);const a=O.useCallback((c,u)=>{const d=u.trim().toLowerCase();return d?c.filter(p=>kM(p,d)):c},[]);return h.jsx(wr,{items:s??gM,filter:a,keyOf:c=>c.id,rowClass:c=>c.restorable?"picker-row":"picker-row dim",rowTitle:c=>c.prompt??c.title,onPick:c=>{c.restorable&&(Lc(n,c.id,o),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:c=>xf(c,o,{sock:n,dispatch:t}),placeholder:"find an archived worktree…",keys:c=>({nav:"moves",pick:c!=null&&c.restorable?"restores it":void 0,back:"closes"}),empty:c=>s?c.trim()?"no archived worktree matches":"nothing archived: removed worktrees land here":"looking…",row:c=>h.jsx(Pn,{label:c.title,hint:Fv(c)})})}function vM({worktreeId:e,hits:t}){const n=st(),o=nt(),s=z(u=>u.leftOpen),a=z(u=>{var p;const d=(p=cn(u,e))==null?void 0:p.worktree;return d?co(d):null}),c=O.useCallback((u,d)=>{const p=d.trim().toLowerCase();return p?u.filter(m=>`${m.path}:${m.line} ${m.text}`.toLowerCase().includes(p)):u},[]);return h.jsx(wr,{items:t,filter:c,keyOf:u=>`${u.path}:${u.line}`,rowClass:()=>"search-hit",rowTitle:u=>`${u.path}:${u.line}`,onPick:u=>{bo({dispatch:n},{worktreeId:e,path:u.path,view:"file",line:{n:u.line}}),s||n({a:"toggle-left"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:u=>a?oi({id:e,dir:a},u.path,{},{sock:o,dispatch:n}):[],placeholder:"lines that could write this element",keys:{pick:"opens the file",back:"closes"},row:u=>h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"search-loc",children:[u.path,":",u.line]}),h.jsx("span",{className:"search-text",children:u.text})]})})}const Gc=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function Y0(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 wM(e,t,n){const o=e.map(p=>p.path.slice(0,p.path.lastIndexOf("/"))).filter(Boolean),s=e.find(p=>p.id===t),a=s==null?void 0:s.path.slice(0,s.path.lastIndexOf("/")),c=new Map;for(const p of o)c.set(p,(c.get(p)??0)+1);let u="",d=0;for(const[p,m]of[...c].sort(([g],[k])=>g.localeCompare(k)))(m>d||m===d&&p===a)&&(u=p,d=m);return u?Q0(u,n):`~/${_y}`}function Q0(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function X0(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function bM(e){const t=e.query.trim(),n=()=>e.entries.map(c=>({kind:"dir",entry:c}));if(!Gc(t)){const c=e.repos.filter(g=>ys(t,g.name,g.path)).map(g=>({kind:"repo",repo:g})),u=e.pending.filter(g=>ys(t,g.name,g.url)).map(g=>({kind:"pending",pending:g})),d=[...c,...u];if(!t)return[...d,{kind:"new"}];const p=A1(t);if(p)return d.length>0?d:[{kind:"clone",url:p.url,name:p.name}];const m=g=>g.toLowerCase()===t.toLowerCase();return e.repos.some(g=>m(g.name))||e.pending.some(g=>m(g.name))||ka(t)?d:[...d,{kind:"create",name:t,parent:null}]}if(e.answered.trim()!==t||!e.target)return n();const{target:o}=e;if(t.endsWith("/"))return n();if(o.exists)return o.isRepo?[...n(),{kind:"open",path:t}]:n();if(!o.parentExists)return[];const{parent:s,name:a}=Y0(t);return ka(a)?n():[...n(),{kind:"create",name:a,parent:s}]}function Ia(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function J0(e,t){const n=Ia(e,t).replace(/\/+$/,"");return n.startsWith("/")?Q0(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function Pf(e,t){const n=Ia(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function xM(e){const t=e.query.trim(),n=t.lastIndexOf("/"),o=n<0?"":t.slice(0,n)||"/",s=Ia(o,e.home);if(!Gc(t)||!s.startsWith("/"))return[];const a=t.slice(n+1).toLowerCase(),c=e.answered.trim()===t?e.target:null,u=!c||(a?c.parentExists:c.exists&&c.isDir&&!c.isRepo),d=e.entries.filter(m=>{if(m.isRepo)return!1;const g=Ia(m.path,e.home);return(g.slice(0,g.lastIndexOf("/"))||"/")===s&&m.name.toLowerCase().startsWith(a)}),p=J0(o,e.home);return[...u?[{kind:"here",path:o}]:[],...p?[{kind:"up",path:p}]:[],...d.map(m=>({kind:"dir",entry:m}))]}function _M({project:e}){const t=st(),n=nt(),o=z(p=>p.paths),s=z(p=>p.home),a=O.useCallback(p=>{Gc(p)&&(n==null||n.send({t:"browse-path",path:p}))},[n]),c=O.useCallback((p,m)=>xM({query:m,entries:o.entries,target:o.target,answered:o.query,home:s}),[o,s]),u=ka(e.name)?null:e.name.trim(),d=p=>`${p.replace(/\/+$/,"")}/`;return h.jsx(wr,{initialQuery:d(e.parent),lead:h.jsx("span",{className:"picker-chip",children:u??"new project"}),items:[],filter:c,keyOf:p=>p.kind==="dir"?`d:${p.entry.path}`:`${p.kind}:${p.path}`,rowClass:()=>"picker-row folder-row",onQuery:a,completionOf:p=>p.kind==="dir"?d(p.entry.path):null,narrowTo:p=>p.kind==="dir"?d(p.entry.path):p.kind==="up"?d(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"?h.jsx(Pn,{label:`put ${u??"it"} in ${Pf(p.path,s)}`,hint:h.jsx("bdi",{children:u?X0(p.path,u):p.path})}):p.kind==="up"?h.jsx(Pn,{label:`up to ${Pf(p.path,s)}`,hint:h.jsx("bdi",{children:p.path})}):h.jsx(Pn,{label:p.entry.name})})}function eb({form:e}){var C;const t=st(),n=nt(),o=z(E=>E.repos),s=z(E=>E.newProject?null:E.activeRepoId),a=z(E=>E.rows),c=z(E=>E.paths),u=z(E=>E.home),d=z(E=>E.pending),p=O.useCallback(E=>{Gc(E)&&(n==null||n.send({t:"browse-path",path:E}))},[n]),m=O.useCallback((E,Z)=>bM({query:Z,repos:o,pending:d,entries:[...c.entries].sort((M,$)=>Number($.isRepo)-Number(M.isRepo)),target:c.target,answered:c.query}),[o,c,d]),g=E=>{const Z=a.filter(se=>se.repoId===E.id),M=Z.filter(ar).filter(se=>se.worktree.kind!=="spare"),$=M.filter(Mc).length,D=M.length-1,q=Z.length-Z.filter(ar).length;return[D>0?`${D} worktree${D===1?"":"s"}`:null,$>0?`${$} working`:null,q>0?`${q} discovered`:null].filter(Boolean).join(" · ")||void 0},k=()=>t({a:"close"}),w=()=>t({a:"close",back:!0}),b=E=>{t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:E})},_=(E,Z)=>{t({a:"open-repo"}),n==null||n.send({t:"create-repo",mode:"create",parent:E,name:Z})},I=(E,Z,M)=>t({a:"new-project",v:tp({mode:E,name:Z,parent:wM(o,s,u),...M?{url:M}:{}})});return h.jsx(wr,{anchored:e==="pill",initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:h.jsx("span",{className:"picker-chip",children:((C=o.find(E=>E.id===s))==null?void 0:C.name)??"no project"}),trailing:e==="disk"?void 0:h.jsx(Kt,{icon:"folder",label:"Find a project on disk",onClick:()=>t({a:"open",overlay:{kind:"projects",form:"disk"}})}),items:[],filter:m,initialIndex:E=>E.findIndex(Z=>Z.kind==="repo"&&Z.repo.id===s),keyOf:E=>E.kind==="repo"?E.repo.id:E.kind==="dir"?`d:${E.entry.path}`:E.kind==="open"?`open:${E.path}`:E.kind==="pending"?`p:${E.pending.id}`:E.kind==="clone"?`clone:${E.url}`:E.kind==="new"?"new-project":`new:${E.parent??""}/${E.name}`,rowClass:E=>ot("picker-row",E.kind==="new"&&"new-project-row"),onQuery:p,completionOf:E=>E.kind==="dir"?E.entry.isRepo?E.entry.path:`${E.entry.path}/`:null,narrowTo:E=>E.kind==="dir"&&!E.entry.isRepo?`${E.entry.path}/`:null,onPick:E=>{if(E.kind==="clone")return I("clone",E.name,E.url);if(E.kind==="create"&&!E.parent)return I("create",E.name);if(E.kind==="new")return I("create","");E.kind==="pending"?t({a:"watch-import",id:E.pending.id}):E.kind==="repo"?t({a:"activate-repo",id:E.repo.id}):E.kind==="open"?b(E.path):E.kind==="dir"?b(E.entry.path):E.parent&&_(E.parent,E.name),k()},onBack:w,rowMenu:E=>E.kind==="repo"?Kc(E.repo,s,{sock:n,dispatch:t}):E.kind==="pending"?I$(E.pending,{sock:n,dispatch:t}):[],placeholder:o.length>1?"switch project, or type a name or path":"type a name or a path to start",keys:E=>({complete:"completes the path",pick:(E==null?void 0:E.kind)==="dir"&&!E.entry.isRepo?"descends":(E==null?void 0:E.kind)==="pending"?"watches it":(E==null?void 0:E.kind)==="create"?E.parent?"creates it":"names it":(E==null?void 0:E.kind)==="clone"?"clones it":(E==null?void 0:E.kind)==="new"?"starts one":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:E=>E.kind==="repo"?h.jsx(Pn,{label:E.repo.name,current:E.repo.id===s,hint:g(E.repo)}):E.kind==="pending"?h.jsx(Pn,{label:E.pending.name,hint:E.pending.error?"import failed":"importing…"}):E.kind==="dir"?h.jsx(Pn,{label:E.entry.name,hint:E.entry.isRepo?"git repo":void 0}):E.kind==="open"?h.jsx(Pn,{label:`open ${E.path}`,hint:"register with this daemon"}):E.kind==="clone"?h.jsx(Pn,{label:`clone ${E.name}`,hint:EM(E.url)}):E.kind==="new"?h.jsx(Pn,{label:h.jsxs(h.Fragment,{children:[h.jsx(Ct,{name:"plus",className:"icon-inline"}),"new project"]})}):h.jsx(Pn,{label:`create ${E.name}`,hint:E.parent?`in ${E.parent}`:"new project"})})}function EM(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function SM(e){const t=[];if(e.pr){const o=e.pr.url;t.push({id:"open-pr",label:"open on GitHub",onClick:()=>window.open(o,"_blank")}),t.push({id:"copy-link",label:"copy link",onClick:()=>Ln(o)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>Ln(e.ref)}];return Hn([t,n])}const NM=[],TM={branch:"branch",remote:"globe",pr:"pr"};function IM({repoId:e}){const t=st(),n=nt(),o=z(g=>g.clientId),s=z(g=>g.refs[e]),a=z(g=>g.rows),c=g=>{var k;return((k=a.find(w=>w.id===g))==null?void 0:k.name)??"a worktree"},u=O.useCallback(g=>g,[]),d=O.useCallback(g=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:g.trim()}),[n,e]),p=g=>!s||s.query!==g.trim(),m=g=>g.openIn?`open in ${c(g.openIn)}`:g.merged?"merged":g.pr?`${g.pr.author}${g.pr.draft?" · draft":""}${g.pr.fork?" · fork":""}`:g.subject??"";return h.jsx(wr,{items:(s==null?void 0:s.refs)??NM,filter:u,onQuery:d,keyOf:g=>`${g.kind}:${g.ref}`,rowClass:()=>"picker-row ref-row",onPick:g=>{g.openIn?t({a:"activate",id:g.openIn}):n==null||n.send({t:"open-ref",repoId:e,kind:g.kind,ref:g.ref,clientId:o,...g.pr?{pr:{title:g.pr.title,url:g.pr.url}}:{}}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:SM,placeholder:"open a branch or PR…",keys:g=>({nav:"moves",pick:g!=null&&g.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:g=>p(g)?"looking…":g.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:g=>h.jsx(Pn,{label:h.jsxs(h.Fragment,{children:[h.jsx(Ct,{name:TM[g.kind],className:"icon-inline"}),g.name]}),hint:m(g)})})}const dy=[],tf=2;function OM({worktreeId:e}){const t=st(),n=nt(),o=Yv(e).search,s=z(p=>p.leftOpen),a=z(p=>{var g;const m=(g=cn(p,e))==null?void 0:g.worktree;return m?co(m):null}),c=O.useCallback((p,m)=>m.trim().length>=tf?p:dy,[]),u=O.useCallback(p=>{const m=p.trim();m.length>=tf&&(n==null||n.send({t:"search",worktreeId:e,query:m}))},[n,e]),d=p=>!o||o.query.trim()!==p.trim();return h.jsx(wr,{items:(o==null?void 0:o.hits)??dy,filter:c,onQuery:u,keyOf:p=>`${p.path}:${p.line}`,rowClass:()=>"search-hit",rowTitle:p=>`${p.path}:${p.line}`,onPick:p=>{bo({dispatch:t},{worktreeId:e,path:p.path,view:"file",line:{n:p.line}}),s||t({a:"toggle-left"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:p=>a?oi({id:e,dir:a},p.path,{},{sock:n,dispatch:t}):[],placeholder:"search in files…",keys:{pick:"opens the file",back:"closes"},empty:p=>p.trim().length<tf?"type at least two characters":d(p)?"searching…":"no matches",footer:(p,m)=>o!=null&&o.truncated&&!d(p)&&m.length>0?h.jsxs("div",{className:"empty",children:["showing the first ",m.length,"; narrow the search"]}):null,row:p=>h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"search-loc",children:[p.path,":",p.line]}),h.jsx("span",{className:"search-text",children:p.text})]})})}const fy=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function RM({slot:e}){const t=st(),n=nt(),o=z(E=>E.themePrefs),s=z(E=>E.themes),a=op(),c=Qf(o,a),u=o[e==="theme"?c:e],d=()=>t({a:"close"}),p=()=>t({a:"close",back:!0}),m=E=>t({a:"preview-theme",theme:E}),[g,k]=O.useState(null),[w,b]=O.useState(null),_=(E,Z)=>E[Z??c]??E.dark??E.light??null,I=O.useMemo(()=>zI(s),[s]),C=O.useMemo(()=>s.filter(E=>E.kind===e),[s,e]);return Bt([g,w],()=>{e==="theme"&&m(g?_(g,w):null)}),e!=="theme"?h.jsx(wr,{items:C,filter:(E,Z)=>E.filter(M=>ys(Z,M.name,M.id)),rowClass:()=>"picker-row",keyOf:E=>E.id,initialIndex:E=>E.findIndex(Z=>Z.id===u),onActive:m,onPick:E=>{n==null||n.send({t:"set-theme",prefs:{...o,[e]:E.id}}),d()},onBack:p,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:E=>h.jsx(Pn,{label:E.name,current:E.id===u,hint:fy(E)})}):h.jsx(wr,{items:I,filter:(E,Z)=>E.filter(M=>{var $,D;return ys(Z,M.name,($=M.dark)==null?void 0:$.name,(D=M.light)==null?void 0:D.name)}),rowClass:()=>"picker-row",keyOf:E=>{var Z,M;return E.name+(((Z=E.dark)==null?void 0:Z.id)??((M=E.light)==null?void 0:M.id))},initialIndex:E=>E.findIndex(Z=>{var M,$;return((M=Z.dark)==null?void 0:M.id)===u||(($=Z.light)==null?void 0:$.id)===u}),onActive:k,onSide:E=>{var Z;E.dark&&E.light&&b((((Z=_(E,w))==null?void 0:Z.kind)??c)==="dark"?"light":"dark")},onPick:E=>{n==null||n.send({t:"set-theme",prefs:DI(o,E)}),d()},onBack:p,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(E,Z)=>{var q,J;const M=_(E,Z?w:null),$=fy(E.dark??E.light),D=((q=E.dark)==null?void 0:q.id)===u||((J=E.light)==null?void 0:J.id)===u;return h.jsx(Pn,{label:E.name,current:D,hint:h.jsxs("span",{className:"theme-kinds",children:[$&&h.jsx("span",{children:$}),h.jsx("span",{className:"kind","data-state":Rr({current:Z&&(M==null?void 0:M.kind)==="dark"}),children:E.dark?"dark":""}),h.jsx("span",{className:"kind","data-state":Rr({current:Z&&(M==null?void 0:M.kind)==="light"}),children:E.light?"light":""})]})})}})}function CM(){const e=UO(),t=Ra(),n=z(s=>s.activeRepoId),o=z(s=>s.newProject);return h.jsxs(h.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&t&&h.jsx(a2,{worktreeId:t}),(e==null?void 0:e.kind)==="search"&&t&&h.jsx(OM,{worktreeId:t}),(e==null?void 0:e.kind)==="element-sources"&&h.jsx(vM,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&n&&h.jsx(IM,{repoId:n}),(e==null?void 0:e.kind)==="archived"&&h.jsx(yM,{repoId:e.repoId}),(e==null?void 0:e.kind)==="keys"&&h.jsx(lM,{}),(e==null?void 0:e.kind)==="theme"&&h.jsx(RM,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&h.jsx(mM,{}),(e==null?void 0:e.kind)==="agent"&&h.jsx(fM,{}),(e==null?void 0:e.kind)==="agent-page"&&h.jsx(uM,{agentId:e.agent}),(e==null?void 0:e.kind)==="commands"&&h.jsx(t2,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&h.jsx(eb,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&h.jsx(_M,{project:o})]})}function jM({worktreeId:e,procs:t,login:n,current:o,onRestart:s}){const a=nt();st();const c={sock:a},u=(p,m)=>h.jsx(Kt,{icon:"reload",label:m,onClick:()=>s(p)}),d={id:Ao,label:"login",tip:St("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:u(Ao,"Run the login again")};return n&&o===Ao?[d]:[{id:vo,label:"shell",tip:St("A shell in this worktree",void 0,{placement:"top"}),menu:()=>Qw(e,c),trail:u(vo,"Restart the shell")},...n?[d]:[],...t.map(p=>({id:p.name,label:p.name,lead:h.jsx("span",{className:`dot ${p.status}`}),tip:St(`${p.command}
209
- ${p.status} on :${p.port}`,void 0,{placement:"top"}),menu:()=>Ep(p,e,c),trail:u(p.name,`Restart ${p.name}`)}))]}const AM=O.lazy(()=>V0(()=>import("./XTerm-DSSGYyFZ.js"),__vite__mapDeps([2,3])));function $M({worktreeId:e,height:t,onDragStart:n}){const o=st(),s=nt(),a=Dc(),c=z($=>$.connected),u=z($=>$.focusTerm),d=$i(),p=(d==null?void 0:d.procs)??[],m=(d==null?void 0:d.login)??!1,g=Xt(e,"termStream"),[k,w]=O.useState(null);O.useEffect(()=>{g===vo||(g===Ao?m:p.some(D=>D.name===g))||o({a:"term-stream",id:e,stream:vo})},[p,m,g,e,o]);const b=$=>{$!==g&&(w(null),o({a:"term-stream",id:e,stream:$}))},_=O.useRef(!1),[I,C]=O.useState(0),E=$=>{$===vo&&$===g&&(_.current=!0),s==null||s.send({t:"term-restart",worktreeId:e,stream:$}),$===Ao&&$===g&&(w(null),C(D=>D+1))},Z=($,D)=>{if($)return w(null);if(_.current){_.current=!1,C(q=>q+1);return}w({code:D})},M=jM({worktreeId:e,procs:p,login:m,current:g,onRestart:E});return h.jsxs(Cp,{className:"term-pane",height:t,onDragStart:n,tabs:{items:M,current:g,onPick:b,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),children:[h.jsx("div",{className:"term-body",children:h.jsx(cp,{pane:!0,children:h.jsx(O.Suspense,{fallback:h.jsx("div",{className:"empty",children:"loading terminal…"}),children:h.jsx(AM,{worktreeId:e,stream:g,theme:a,sock:s,connected:c,focusReq:u,onAlive:Z,onEscape:()=>o({a:"toggle-terminal"})},`${g}:${I}`)})})}),k!==null&&h.jsx(lp,{pane:!0,title:g===vo?"the shell exited":g===Ao?"the login did not finish":`${g} exited`,body:k.code===void 0?void 0:`exit code ${k.code}`,action:h.jsx(De,{variant:"outline",onClick:()=>E(g),children:"restart"})})]})}function MM(e,t){const o=e.procs.filter(a=>a.status==="crashed"||a.status==="unreachable").map(a=>`- \`${a.name}\`: \`${a.command}\`, started with PORT=${a.port}. ${PM(a)}`),s=t.slice(-40).map(a=>`[${a.proc}] ${a.line}`).join(`
210
- `);return["The dev server in this worktree is not reachable, so the preview is empty.","",...o,"",s?`Last output:
211
- \`\`\`
212
- ${s}
213
- \`\`\``:"It produced no output.","","Find the cause and fix it. The command must run in the foreground and listen on the port in the PORT environment variable, which Toyon sets differently for each worktree. If the tool takes its port from a flag instead (Vite does), make the app read PORT, for Vite `server.port: Number(process.env.PORT)` with `strictPort: true`, or add the flag to the start command in toyon's settings file. When your turn ends toyon restarts the process and checks again."].join(`
214
- `)}function PM(e){return e.detail?e.detail:e.status==="crashed"?e.exitCode!=null?`It exited with code ${e.exitCode}.`:"It crashed.":"It never answered on that port."}function LM(e){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 \`${e.configFile}\` in this shape:`,"```json",'{ "setup": ["<install command>"], "run": { "web": "<start command>" } }',"```",'`setup` runs once in each new worktree. 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(`
215
- `)}function zM({worktree:e,log:t}){const n=nt(),o=st(),s=e.procs,a=d=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:d.name}),c=s.some(d=>d.status==="crashed"||d.status==="unreachable"),u=()=>n==null?void 0:n.send({t:"chat",worktreeId:e.id,text:MM(e,t)});return h.jsxs(Mi,{wide:!0,children:[s.length===0?h.jsx("div",{className:"status-line",children:"starting dev servers…"}):h.jsx("ul",{className:"boot-procs",children:s.map(d=>h.jsxs("li",{className:ot("boot-proc",(d.status==="crashed"||d.status==="unreachable")&&"boot-bad"),children:[h.jsx("span",{className:"boot-name",children:d.name}),h.jsx("span",{className:"boot-status",children:DM(d)}),(d.status==="crashed"||d.status==="unreachable")&&h.jsx(De,{variant:"outline",onClick:()=>a(d),children:"restart"}),d.detail&&h.jsx("div",{className:"boot-detail",children:d.detail})]},d.name))}),c&&h.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&h.jsx(De,{variant:"outline",size:"lg",onClick:u,children:"ask the agent to fix it"}),h.jsx(De,{onClick:()=>o({a:"open",overlay:{kind:"setup",repoId:e.repoId}}),children:"edit setup"})]}),t.length>0&&h.jsx("pre",{className:"status-tail",children:t.slice(-30).map(d=>`[${d.proc}] ${d.line}`).join(`
216
- `)})]})}function DM(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"}}function FM({row:e}){const t=nt(),n=z(a=>a.clientId),o=z(a=>a.home),s=o&&e.path.startsWith(`${o}/`)?`~${e.path.slice(o.length)}`:e.path;return h.jsxs(Mi,{wide:!0,children:[h.jsx("p",{className:"status-line",children:e.name}),h.jsxs("p",{children:["This worktree exists in git, but Toyon did not make it and is not running it: no dev servers, no preview, no agent. A shell at ",h.jsx("code",{children:s})," opens below."]}),e.locked?h.jsxs("p",{children:["Another tool is holding it",e.lockReason?`: ${e.lockReason}`:"",". Taking it over would put Toyon's dev servers in a directory something else is working in, so that stays off until the lock goes."]}):h.jsxs(h.Fragment,{children:[h.jsx("p",{children:"Taking it over gives it a port, starts the processes from the project's settings and lists it with your other worktrees. Your files are left alone: the install and setup commands do not re-run."}),h.jsx("div",{className:"status-actions",children:h.jsx(De,{variant:"outline",size:"lg",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})})]})]})}function UM({active:e}){const t=st(),n=nt(),o=Xn(),s=Ca(),a=z(d=>d.home),c=e.worktree.title,u=()=>{s!=null&&s.made&&(t({a:"new-project",v:{...tp({mode:s.made==="git"?"init":"create",name:s.name,parent:J0(s.path,a)??s.path}),phase:"unmaking",repoId:s.id,prompt:lo(o.getState(),e.worktree.id).draft}}),n==null||n.send({t:"unmake-repo",repoId:s.id}))};return h.jsxs(Mi,{anchor:"line",children:[h.jsx("p",{className:"form-title",children:s!=null&&s.made?h.jsx(De,{variant:"inline",onClick:u,...St("Rename or move this project"),children:c}):c}),h.jsx("div",{className:"form-body form-body-lg",children:h.jsx(L0,{active:e,greenfield:!0})})]})}function BM({pending:e}){const t=st(),n=nt(),o=!!e.error,s=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},a=O.useRef(null);return O.useEffect(()=>{var c;return(c=a.current)==null?void 0:c.scrollTo({top:a.current.scrollHeight})},[e.lines.length]),h.jsxs(Mi,{wide:!0,children:[h.jsxs("p",{className:"status-line",children:[o?"could not import":"importing"," ",e.name]}),h.jsxs("p",{children:["from ",h.jsx("code",{children:e.url})," into ",h.jsx("code",{children:e.parent})]}),o?h.jsx("p",{className:"import-error",children:e.error}):h.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),h.jsx("div",{className:"status-tail",ref:a,children:e.lines.length===0&&!o?h.jsx("span",{className:"import-idle",children:"starting git…"}):e.lines.map((c,u)=>h.jsx("div",{children:c},u))}),h.jsx("div",{className:"status-actions",children:h.jsx(De,{variant:"outline",size:"lg",onClick:s,children:o?"dismiss":"stop"})})]})}const ZM=150,HM=/^[^\s@]+@[^\s@]+$/,WM=14,py=[];function KM({project:e}){var B;const t=st(),n=nt(),o=z(F=>F.repos),s=z(F=>F.home),a=z(F=>F.folderDialog),c=z(F=>F.gitIdentity),u=z(F=>F.choosingFolder),d=z(F=>F.chosenFolder),p=z(F=>F.paths),m=z(F=>F.agents),g=z(F=>F.defaultAgent),[k,w]=O.useState({name:"",email:""}),[b,_]=O.useState(null),[I,C]=O.useState(null),E=O.useRef(null),Z=O.useRef(null),{mode:M,name:$,parent:D,prompt:q}=e,J=M==="clone",se=M==="init",me=e.phase==="editing",Oe=$.trim(),ae=se||!Oe?null:ka($),ie=!se&&Oe&&!ae?X0(D,Oe):null,Y=Pf(D,s),de=ie!==null&&p.query===ie&&((B=p.target)==null?void 0:B.exists)===!0,ge=!c&&!J,Ee=!ge||k.name.trim()!==""&&HM.test(k.email.trim()),X=me&&!b&&(se||Oe!==""&&!ae&&!de)&&Ee,ce=m.find(F=>F.id===g),[ee,j]=n0(g),[Q,Ie]=t0(g),xe=(F,Te)=>{if(F===g){j(Te);return}r0(F,Te),n==null||n.send({t:"set-default-agent",agent:F})};O.useEffect(()=>{if(!ie)return;const F=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:ie}),ZM);return()=>clearTimeout(F)},[ie,n]),Bt([e.phase],()=>{var F;e.phase==="editing"&&((F=E.current)==null||F.focus())}),Bt([M,$,D],()=>C(null));const V=()=>{X&&(t({a:"open-repo"}),t({a:"new-project-set",v:{phase:"creating"}}),n==null||n.send({t:"create-repo",mode:M,parent:D.trim(),name:Oe,...J&&e.url?{url:e.url}:{},...ge?{identity:{name:k.name.trim(),email:k.email.trim()}}:{}}))},be=F=>{const Te=o.find(lt=>lt.path===Ia(F,s));if(Te){t({a:"activate-repo",id:Te.id});return}t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:F})},Ae=F=>{C(null),a?(t({a:"choosing-folder",v:F}),n==null||n.send({t:"choose-folder",start:D,purpose:F})):t(F==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};Bt([d==null?void 0:d.seq],()=>{var Te,lt;if(!u||!d)return;t({a:"choosing-folder",v:!1});const F=d.folder;if(!F){(Te=E.current)==null||Te.focus();return}if(u==="open"&&F.kind==="project"){be(F.path);return}if(u==="open"&&F.kind==="folder"){C("that folder has files but is not a project yet; choose a project, or an empty folder to start one");return}if(_(F.kind==="project"?F.path:null),F.kind!=="project"){if(F.kind==="empty"&&!J){const Pt=Y0(F.path);t({a:"new-project-set",v:{mode:"init",parent:Pt.parent,name:Pt.name}});return}t({a:"new-project-set",v:{mode:J?"clone":"create",parent:F.path}}),(lt=E.current)==null||lt.focus()}});const Pe=I??(se?"the empty folder you chose becomes the project":b?"the folder you chose is already a project: open it, or choose another":de?`${Y} already has a folder called ${Oe}`:ae);return h.jsxs(Mi,{anchor:"line",children:[J&&h.jsx("p",{className:"new-project-url",children:e.url}),h.jsxs("div",{className:"form-head",children:[se?h.jsx("p",{className:"form-title",children:$}):h.jsx(Mo,{ref:E,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:$,placeholder:"Project name",disabled:!me,style:{width:`${Math.max($.length+1,WM)}ch`},onChange:F=>t({a:"new-project-set",v:{name:F.target.value}}),onKeyDown:F=>{var Te;F.key==="Enter"&&(F.preventDefault(),(Te=Z.current)==null||Te.focus())}}),h.jsxs("span",{className:"new-project-where",children:[h.jsx("span",{className:"hint",children:"in"}),h.jsx("span",{className:"new-project-parent",...St(D),children:Y}),h.jsx(Kt,{icon:"folder",label:a?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:u==="location",disabled:!me,onClick:()=>Ae("location")})]})]}),Pe&&h.jsx("p",{className:"hint",children:Pe}),h.jsx("div",{className:"form-body",children:h.jsx(Pa,{ref:Z,bare:!0,font:"ui",value:q,placeholder:`describe ${Oe||"the app"}…`,disabled:!me,onChange:F=>t({a:"new-project-set",v:{prompt:F.target.value}}),onKeyDown:F=>{F.key!=="Enter"||F.shiftKey||(F.preventDefault(),V())}})}),h.jsxs("div",{className:"hint form-knobs",children:[m.length>1?h.jsx(o0,{agents:m,agent:g,model:ee,onChange:xe}):h.jsx(Rf,{models:(ce==null?void 0:ce.models)??py,value:ee,onChange:j}),h.jsx(Of,{efforts:(ce==null?void 0:ce.efforts)??py,value:Q,onChange:Ie}),b?h.jsx(De,{variant:"outline",size:"lg",className:"form-go",autoFocus:!0,onClick:()=>be(b),children:"open it"}):h.jsx(De,{variant:"outline",size:"lg",className:"form-go",busy:e.phase==="creating",disabled:!X,onClick:V,...St(J?"Clone the project":q.trim()?"Make it and start on this":"Make the project","⏎"),children:J?"clone":"create"})]}),ge&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"new-project-identity",children:[h.jsx(Mo,{size:"md",font:"ui",rule:!0,value:k.name,placeholder:"Your name",autoComplete:"name",disabled:!me,onChange:F=>w({...k,name:F.target.value})}),h.jsx(Mo,{size:"md",font:"ui",rule:!0,type:"email",value:k.email,placeholder:"Email",autoComplete:"email",disabled:!me,onChange:F=>w({...k,email:F.target.value})})]}),h.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!J&&me&&h.jsx(De,{tone:"quiet",className:"new-project-open",onClick:()=>Ae("open"),children:"or open a folder you already have"})]})}function sa({label:e,hint:t,children:n}){return h.jsxs("label",{className:"form-row",children:[h.jsx("span",{className:"form-label",children:e}),h.jsxs("div",{className:"form-control",children:[n,t&&h.jsx("span",{className:"hint",children:t})]})]})}let VM=1;const nf=(e,t)=>({id:VM++,name:e,cmd:t});function GM({repo:e,onClose:t}){const n=nt(),o=Xn(),s=z(ie=>ie.rows.find(Y=>ar(Y)&&Y.repoId===e.id&&Y.worktree.kind==="main")??null);O.useEffect(()=>{if(!t)return;const ie=Y=>Y.key==="Escape"&&t();return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[t]);const[a]=O.useState(()=>Object.keys(e.config.run).length>0),[c,u]=O.useState(()=>{const ie=Object.entries(e.config.run).map(([Y,de])=>nf(Y,de));return ie.length>0?ie:[nf("web","")]}),[d,p]=O.useState(()=>(e.config.setup??[]).join(`
217
- `)),[m,g]=O.useState(()=>e.config.check??""),[k,w]=O.useState(()=>fs(e.config).land),[b,_]=O.useState(()=>fs(e.config).automerge),[I,C]=O.useState(()=>fs(e.config).merge??"default"),E=c.length>1,Z=c.some(ie=>ie.name.trim()&&ie.cmd.trim()),$=!!s&&!t&&!a&&!Z,D=(ie,Y)=>u(c.map((de,ge)=>ge===ie?{...de,...Y}:de)),q=()=>d.split(`
218
- `).map(ie=>ie.trim()).filter(Boolean),J=()=>{const{check:ie,land:Y,...de}=e.config,ge=e.remote?k:af,Ee={...ge!==af?{route:ge}:{},...ge==="pr"&&b?{automerge:!0}:{},...I!=="default"?{method:I}:{}};return{...de,setup:q(),...m.trim()?{check:m.trim()}:{},...Object.keys(Ee).length>0?{land:Ee}:{}}},se=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...J(),run:Object.fromEntries(c.filter(ie=>ie.name.trim()&&ie.cmd.trim()).map(ie=>[ie.name.trim(),ie.cmd.trim()]))}}),t==null||t()},me=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...J(),run:{}}}),t==null||t()},Oe=()=>s&&(n==null?void 0:n.send({t:"chat",worktreeId:s.id,text:LM(e)})),ae=(ie,Y)=>h.jsxs("div",{className:"setup-proc",children:[E&&h.jsx(Mo,{size:"md",rule:!0,className:"setup-name",value:ie.name,placeholder:"name",...St("Process name, shown in the status bar"),onChange:de=>D(Y,{name:de.target.value})}),h.jsx(Mo,{size:"md",rule:!0,className:"setup-cmd",value:ie.cmd,placeholder:"npm run dev",onChange:de=>D(Y,{cmd:de.target.value})}),E&&h.jsx(Kt,{icon:"close",label:"Remove",onClick:()=>u(c.filter((de,ge)=>ge!==Y))})]},ie.id);return h.jsxs(Mi,{children:[h.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),h.jsx(sa,{label:"install",hint:"once per new worktree; one command per line",children:h.jsx(Pa,{size:"md",rule:!0,rows:Math.max(1,d.split(`
219
- `).length),value:d,placeholder:"bun install",onChange:ie=>p(ie.target.value)})}),h.jsx(sa,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:h.jsx(Mo,{size:"md",rule:!0,value:m,placeholder:"bun run check",onChange:ie=>g(ie.target.value)})}),e.remote&&h.jsx(sa,{label:"land",hint:"how a worktree's work reaches main; one way per repo",children:h.jsxs("div",{className:"setup-land",children:[h.jsx(Ci,{value:k,options:u1.map(ie=>({id:ie.id,label:ie.name,description:ie.description})),onChange:w,hint:"click to change",placeholder:"how work lands"}),k==="pr"&&h.jsxs(De,{variant:"field",mono:!0,on:b,...St("GitHub merges the PR itself once its rules allow: checks, reviewers, or nothing"),onClick:()=>_(!b),children:["auto-merge ",b?"on":"off"]})]})}),h.jsx(sa,{label:"merge as",hint:"the default is a merge commit here; on GitHub, what the repo allows, squash first",children:h.jsx(Ci,{value:I,options:[{id:"default",label:"default",description:"a merge commit here; on GitHub what the repo allows"},...d1.map(ie=>({id:ie.id,label:ie.name,description:ie.description}))],onChange:C,hint:"click to change",placeholder:"how the commits arrive on main"})}),h.jsx(sa,{label:"start",hint:h.jsxs(h.Fragment,{children:["must listen on ",h.jsx("code",{...St("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&s&&h.jsxs(h.Fragment,{children:[" · from ",h.jsx(De,{mono:!0,tone:"quiet",...St(`open ${e.guess} in the editor pane`),onClick:()=>Bc(o,n,s.id,e.guess??"",1),children:e.guess})]})]}),children:c[0]&&ae(c[0],0)}),c.slice(1).map((ie,Y)=>h.jsxs("div",{className:"form-row",children:[h.jsx("span",{className:"form-label"}),h.jsx("div",{className:"form-control",children:ae(ie,Y+1)})]},ie.id)),h.jsxs("div",{className:"form-row",children:[h.jsx("span",{className:"form-label"}),h.jsxs(De,{tone:"quiet",onClick:()=>u([...c,nf("","")]),children:[h.jsx(Ct,{name:"plus",className:"icon-inline"})," another process"]})]}),h.jsxs("div",{className:"form-knobs",children:[h.jsx("span",{className:"form-sign",children:e.configFile}),t&&h.jsx(De,{onClick:t,children:"cancel"}),(!a||t)&&h.jsx(De,{...St("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:me,children:"no dev server"}),$&&s?h.jsx(De,{variant:"outline",size:"lg",disabled:s.agent!=="idle",...St("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:Oe,children:"let the agent work it out"}):h.jsxs(De,{variant:"outline",size:"lg",disabled:!Z,...t?St("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:se,children:[t?"save + restart":"start"," ",h.jsx(Ct,{name:"forward",className:"icon-inline"})]})]})]})}const hy={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"},qM="no access token for this address.\nrun `toyon` in your repo, or open the full URL\n(with #token=…) printed in ~/.toyon/daemon.log";function YM(e){return!e.connected&&(!e.heard||e.connectFailure)?e.hasToken?hy[e.connectFailure??"probing"]??hy.probing:qM:e.title===null?e.heard?`nothing open yet.
220
- press ${e.projectChord} to open a project, or type a name there to start a new one`:"":e.needsSetup&&e.busy?`building in ${e.title}; the preview appears once it starts`:e.needsSetup&&e.treeEmpty?`${e.title} is empty so far; say what to build`:e.treeEmpty&&e.landsFrom?`nothing runs on main until ${e.landsFrom} lands`:null}const QM=1500,XM={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class JM{constructor(t,n,o=XM){dt(this,"frames",new Map);this.send=t,this.sendTitle=n,this.timers=o}note(t,n,o){const s=this.frame(t);s.timer!==null&&(this.timers.clear(s.timer),s.timer=null),s.pending=null,o!==void 0&&(s.title=Dg(o));const a=Rc(n);if(!a){s.sent=null;return}if(a===s.sent){this.renamed(t,s);return}s.pending=a,s.timer=this.timers.set(()=>{s.timer=null,s.pending=null,s.sent=a,s.sentTitle=s.title,this.send(t,a,s.title)},QM)}title(t,n){const o=this.frame(t);o.title=Dg(n),o.pending===null&&this.renamed(t,o)}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 eP=TR();function tP(){const e=st(),t=Xn(),n=nt(),o=O.useRef(n);o.current=n;const[s]=O.useState(()=>new JM((te,Be,mt)=>{var it,rt;(it=o.current)==null||it.send({t:"visit",worktreeId:te,path:Be,title:mt}),Ev((rt=t.getState().local[te])==null?void 0:rt.pages)&&Nt.post(te,{type:"links"})},(te,Be,mt)=>{var it;return(it=o.current)==null?void 0:it.send({t:"page-title",worktreeId:te,path:Be,title:mt})}));O.useEffect(()=>()=>s.dispose(),[s]);const a=qv(),c=Ra(),u=$i(),d=z(te=>te.connected),p=z(te=>te.heard),m=z(te=>te.connectFailure),g=z(te=>te.remote),k=z(te=>te.editor),w=Qv(),b=BO(),_=ja(),I=z(te=>te.termOpen)&&!_,C=Fc(),E=z(te=>te.designOpen)&&!_&&!C,Z=z(te=>te.reloadReq),M=Dc(),$=O.useRef(M);$.current=M;const D=z(te=>te.zen),q=O.useRef(D);q.current=D;const J=Xt(c,"log"),se=z(te=>te.incompatible),me=WO(),Oe=z(te=>{var Be;return((Be=te.overlay)==null?void 0:Be.kind)==="setup"?te.repos.find(mt=>mt.id===te.overlay.repoId)??null:null}),ae=(u==null?void 0:u.worktree.empty)===!0,ie=!!u&&Mc(u),Y=me&&!ae&&!ie?me:null,de=Y??Oe,ge=z(te=>te.pending.find(Be=>Be.id===te.activeImportId)??null),[Ee,X]=O.useState([]),ce=O.useRef(new Map),ee=O.useRef(new Map);O.useEffect(()=>{Nt.post=(te,Be)=>{var mt,it;return(it=(mt=ce.current.get(te))==null?void 0:mt.contentWindow)==null?void 0:it.postMessage({__toyon:!0,...Be},ee.current.get(te)??"*")},Nt.broadcast=te=>{var Be;for(const[mt,it]of ce.current)(Be=it.contentWindow)==null||Be.postMessage({__toyon:!0,...te},ee.current.get(mt)??"*")}},[]),O.useEffect(()=>{const te=Be=>{var mt,it;if((mt=Be.data)!=null&&mt.__toyon)for(const[rt,Rn]of ce.current){if(Rn.contentWindow!==Be.source)continue;if(Be.origin!==ee.current.get(rt))return;const Xe=rI(Be.data);if(!Xe)return;switch(Xe.type){case"key":window.dispatchEvent(new KeyboardEvent("keydown",{key:Xe.key,metaKey:Xe.meta,ctrlKey:!!Xe.ctrl,shiftKey:!!Xe.shift,altKey:!!Xe.alt}));break;case"hmr":e({a:"hmr",id:rt});break;case"loaded":Nt.post(rt,tw($.current)),Nt.post(rt,{type:"zen",on:q.current}),e({a:"hmr",id:rt}),e({a:"page",id:rt,url:Xe.url,title:Xe.title,fresh:!0}),s.note(rt,Xe.url,Xe.title);break;case"navigated":e({a:"page",id:rt,url:Xe.url,...Xe.title!==void 0?{title:Xe.title}:{}}),s.note(rt,Xe.url,Xe.title);break;case"title":e({a:"page",id:rt,title:Xe.title}),s.title(rt,Xe.title);break;case"links":e({a:"links",id:rt,links:Xe.links});break;case"page-error":{const wn=Xe.source?` (${Yg(Xe.source)}:${Xe.line??"?"})`:"";e({a:"page",id:rt,error:`${Xe.message}${wn}`});break}case"picked":{const{type:wn,verb:Lt,site:xr,...hn}=Xe,Dn=xr==="call"?{file:hn.callFile,line:hn.callLine}:{file:hn.file,line:hn.line};if(Lt==="code"){e({a:"set-picking",v:!1});const Zt=(it=cn(t.getState(),rt))==null?void 0:it.worktree;Dn.file?Bc(t,n,rt,Yg(Dn.file,Zt&&co(Zt)),Dn.line??1):n==null||n.send({t:"find-element",worktreeId:rt,seq:dc(),element:hn.element})}else JO(t,rt,hn);break}case"pick-cancel":e({a:"set-picking",v:!1});break;case"drag-files":j0(t,!1);break;case"drop-files":P0(t);break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${Xe.path}: ${Xe.fileMatched} elements from this file, ${Xe.withSource} elements with source info on page, ranges=${JSON.stringify(Xe.ranges)}`);break}return}};return window.addEventListener("message",te),()=>window.removeEventListener("message",te)},[e,t,n,s]),O.useEffect(()=>{Nt.broadcast({type:"zen",on:D})},[D]);const j=O.useRef(new Map);Bt([Z==null?void 0:Z.id,Z==null?void 0:Z.n],()=>{if(!Z)return;const{id:te}=Z;clearTimeout(j.current.get(te)),j.current.set(te,setTimeout(()=>{j.current.delete(te),Nt.post(te,{type:"reload"})},1200))});const Q=ip(),Ie=Q&&!ar(Q)?Q:null,xe=!!u&&u.procs.some(te=>te.status==="running"),V=z(te=>te.spares),be=HO(),Ae=sp(),Pe=Ae!==null&&(Ae===(be==null?void 0:be.id)||Ae===c&&xe);O.useEffect(()=>{Ae&&Pe&&!Ee.includes(Ae)&&X(te=>[...te,Ae])},[Ae,Pe,Ee]);const B=[...a.filter(ar).filter(te=>Ee.includes(te.id)).map(te=>({id:te.worktree.id,port:te.worktree.proxyPort,title:te.worktree.title})),...V.filter(te=>Ee.includes(te.id)&&!a.some(Be=>Be.id===te.id)).map(te=>({id:te.id,port:te.proxyPort,title:"new worktree"}))],F=O.useRef(null),[Te,lt]=so(ft.editorHeight,0,te=>{const Be=Number(te);return Number.isFinite(Be)&&Be>=120?Be:0}),[Pt,Ye]=so(ft.designHeight,0,te=>{const Be=Number(te);return Number.isFinite(Be)&&Be>0?Be:0}),[Ge,Ue]=so(ft.designFull,!1,te=>te===null?void 0:te==="1"),[At,Tt]=so(ft.editorFull,!1,te=>te===null?void 0:te==="1"),[ut,Vt]=so(ft.termHeight,240,te=>{const Be=Number(te);return Number.isFinite(Be)&&Be>=140?Be:void 0}),K=z(te=>te.termTall);Bt([K],()=>{const te=F.current;K&&te&&Vt(Math.max(ut,Math.round(te.clientHeight/2)))});const _e=te=>(Be,mt)=>{const it=mt.parentElement,rt=F.current;if(!it||!rt)return null;let Rn=0;for(const wn of Array.from(rt.querySelectorAll(":scope > .pane")))wn!==it&&!wn.classList.contains("full")&&(Rn+=wn.offsetHeight);const Xe=Math.max(rt.clientHeight-Rn-80,te);return Math.min(Math.max(it.getBoundingClientRect().bottom-Be.clientY,te),Xe)},pt=ma(_e(120),te=>lt(Math.round(te))),It=ma(_e(160),te=>Ye(Math.round(te))),vn=ma(_e(140),te=>Vt(Math.round(te))),vt=z(te=>{var Be,mt;return(u==null?void 0:u.worktree.kind)==="main"?((mt=(Be=te.rows.find(it=>{var rt;return it.repoId===u.worktree.repoId&&((rt=it.worktree)==null?void 0:rt.kind)==="worktree"}))==null?void 0:Be.worktree)==null?void 0:mt.title)??null:null}),Gt=YM({connected:d,heard:p,connectFailure:m,hasToken:eP,projectChord:yt("project"),title:(u==null?void 0:u.worktree.title)??null,needsSetup:!!me,busy:ie,treeEmpty:ae,landsFrom:vt});return h.jsxs("div",{className:"center",ref:F,children:[h.jsx("div",{className:"center-area",style:{display:k&&At||E&&Ge?"none":void 0},children:h.jsxs("div",{className:"frames-wrap",children:[B.map(te=>h.jsx("iframe",{ref:Be=>{Be?(ce.current.set(te.id,Be),ee.current.set(te.id,new URL(Gg(te.id,te.port,g)).origin)):(ce.current.delete(te.id),ee.current.delete(te.id))},src:Gg(te.id,te.port,g),title:te.title,style:{display:te.id===Ae&&!de&&!ge&&!_&&!C?"block":"none"}},te.id)),b?h.jsx(KM,{project:b}):h.jsxs(h.Fragment,{children:[ge&&h.jsx(BM,{pending:ge},ge.id),w&&u&&!ge&&h.jsx(UM,{active:u},u.worktree.id),de&&!ge&&!w&&h.jsx(GM,{repo:de,onClose:Y?void 0:()=>e({a:"close"})},`${de.id}:${JSON.stringify(de.config)}`),Ie&&!de&&!ge&&h.jsx(FM,{row:Ie}),!xe&&!be&&!Ie&&!de&&!ge&&!w&&se&&h.jsx(lp,{title:fc.title,body:fc.body,action:h.jsx(De,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}),!xe&&!be&&!Ie&&!de&&!ge&&!w&&!se&&(Gt!==null?h.jsx(Mi,{wide:!0,children:h.jsx("p",{className:"status-line",children:Gt})}):C?h.jsx(z0,{placement:"centre"}):u&&h.jsx(zM,{worktree:u,log:J}))]})]})}),k&&h.jsx(iM,{editor:k,height:At?"100%":Te>0?Te:"45%",full:At,onToggleFull:()=>Tt(!At),onDragStart:pt}),E&&c&&h.jsx(j2,{worktreeId:c,height:Ge?"100%":Pt>0?Pt:"55%",full:Ge,onToggleFull:()=>Ue(!Ge),onDragStart:It},`design:${c}`),I&&c&&h.jsx($M,{worktreeId:c,height:ut,onDragStart:vn},`term:${c}`),h.jsx(CM,{})]})}function tb(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>Ln(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>Ln(e.subject)}]}function nP({active:e,ahead:t,behind:n,dirty:o}){var me,Oe;const s=nt(),a=st(),c=nn("changes"),u=ar(e)?e.worktree:null,d=e.id,p=z(ae=>ae.shipping[d]),[m,g]=O.useState("");Bt([d],()=>g(""));const k=O.useRef(null),w=(me=u==null?void 0:u.landing)!=null&&me.subject?u.landing.body?`${u.landing.subject}
221
-
222
- ${u.landing.body}`:u.landing.subject:null,b=()=>{m===""&&w&&g(w);const ae=k.current;ae&&(ae.focus(),requestAnimationFrame(()=>ae.setSelectionRange(ae.value.length,ae.value.length)))},_=z(ae=>ae.editCommit);Bt([_],()=>{_&&b()});const I=m.trim()||void 0,C=()=>{p||!I&&!w||($o(s,a,{t:"commit",worktreeId:d,message:I??w??""}),g(""))},E=()=>{p||$o(s,a,{t:"land",worktreeId:d,...I?{message:I}:{}})},Z=((Oe=u==null?void 0:u.landing)==null?void 0:Oe.check)==="fail",M=u==null?void 0:u.pr,$=(M==null?void 0:M.state)==="open",D=!!u&&Xf(u)&&(o||t>0)&&!Z&&!$,q=$c(e)&&!o&&n>0,J=z(ae=>ae.repos.find(ie=>ie.id===e.repoId)??null),se=Df(fs((J==null?void 0:J.config)??{}),J==null?void 0:J.defaultBranch);return h.jsxs("div",{className:"composer commit-box",children:[u&&o&&h.jsx("div",{className:"composer-field",children:h.jsx(Pa,{size:"lg",bare:!0,ref:k,value:m,onChange:ae=>g(ae.target.value),onKeyDown:ae=>{ae.key==="Enter"&&(ae.metaKey||ae.ctrlKey)?(ae.preventDefault(),C()):ae.key==="Tab"&&!ae.shiftKey&&m===""&&w&&(ae.preventDefault(),b())},placeholder:w??"commit message…"})}),h.jsxs("div",{className:"hint composer-knobs",children:[h.jsxs("span",{className:"commit-where",children:[h.jsx(Ct,{name:"branch",className:"icon-inline"}),h.jsx("span",{className:"branch-name",children:e.branch??"detached"}),n>0&&h.jsxs("span",{className:"badge-behind","data-tip":`${n} commit(s) behind main`,children:[n," behind"]}),t>0&&h.jsxs("span",{className:"badge-ahead","data-tip":`${t} commit(s) ahead of main`,children:[t," ahead"]}),(u==null?void 0:u.landed)&&h.jsxs("span",{className:"badge-landed","data-tip":"Merged into main",children:[h.jsx(Ct,{name:"check",className:"icon-inline"})," landed"]})]}),h.jsxs("span",{className:"commit-acts",children:[q&&h.jsxs(De,{variant:"outline",tone:"primary",busy:p==="sync-main",disabled:!!p,"data-tip":`Pull ${n} commit(s) from main into this worktree`,onClick:()=>$o(s,a,{t:"sync-main",worktreeId:d}),children:["sync ",h.jsx(Ct,{name:"pull",className:"icon-inline"})]}),u&&o&&h.jsx(De,{busy:p==="commit",disabled:!I&&!w||!!p,onClick:C,...St(w&&!I?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),u&&D&&h.jsx(De,{tone:"primary",busy:p==="land",disabled:!!p,"data-tip":se,onClick:E,children:"land"}),$&&N0(M)&&h.jsx(De,{tone:"primary",busy:p==="land",disabled:!!p,"data-tip":"Merge the PR now, by the method the repo allows",onClick:E,children:"merge"}),M&&h.jsxs(De,{"data-tip":`Open PR #${M.number} on GitHub`,onClick:()=>window.open(M.url,"_blank"),...c.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(M.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>Ln(M.url)}]),children:["view ",h.jsx(Ct,{name:"external",className:"icon-inline"})]})]})]})]})}const rP=O.memo(function({c:t,selected:n,onToggle:o}){const s=nn("changes");return h.jsxs("button",{className:"row row-sm log-row row-edge","data-state":Rr({current:n,cursor:n}),role:"option","aria-selected":n,tabIndex:-1,onClick:()=>o(t.sha),...s.contextMenu(()=>tb(t)),"data-tip":`${t.subject}
223
- ${t.short} · ${t.author}`,"data-tip-placement":"follow",children:[h.jsx("span",{className:"subject",children:t.subject}),h.jsx("span",{className:"at row-dim",children:xa(t.at)})]})}),my=[];function oP({width:e}){const t=nt(),n=st(),o=Ra(),s=$i(),a=z(K=>K.leftOpen),c=ja(),u=z(K=>K.focusLeft),d=Xt(o,"git"),p=z(K=>K.editor&&K.editor.worktreeId===o?K.editor.path:null),m=z(K=>K.editor&&K.editor.worktreeId===o?K.editor.ref??null:null),g=(d==null?void 0:d.files)??my,k=(d==null?void 0:d.committed)??my,w=g.length===0,[b,_]=O.useState("changes"),I=ip(),C=z(K=>{var _e;return((_e=Ai(K,I==null?void 0:I.repoId))==null?void 0:_e.defaultBranch)??"main"}),E=Xt(o,"commits"),Z=Xt(o,"commitFiles"),[M,$]=O.useState(null),D=O.useRef(null);D.current=M;const q=O.useRef(null),J=Xt(o,"changedRanges"),se=O.useCallback((K,_e)=>{if(!o)return;if(!_e){q.current=null,Nt.post(o,{type:"highlight-clear"});return}q.current=K;const pt=J[K];pt?Nt.post(o,{type:"highlight-file",path:K,ranges:qg(pt)}):t==null||t.send({t:"changed-ranges",worktreeId:o,path:K})},[o,J,t]);O.useEffect(()=>{const K=q.current;if(!K||!o)return;const _e=J[K];_e&&Nt.post(o,{type:"highlight-file",path:K,ranges:qg(_e)})},[J,o]);const me=O.useCallback((K,_e=!1)=>o&&bo({dispatch:n},{worktreeId:o,path:K,focus:_e}),[o,t,n]),Oe=O.useMemo(()=>[...g,...k],[g,k]),ae=O.useMemo(()=>{const K=[];for(const _e of E??[])if(K.push({commit:_e}),_e.sha===M)for(const pt of Z[_e.sha]??[])K.push({commit:_e,file:pt});return K},[E,M,Z]),ie=O.useMemo(()=>ae.filter(K=>!K.file&&K.commit.ahead).length,[ae]),Y=O.useMemo(()=>ae.findIndex(K=>!K.file&&!K.commit.ahead),[ae]),de=O.useRef(null),[ge,Ee]=O.useState(0),[X,ce]=O.useState(!1),ee=(K,_e)=>X?ge===K:_e;Bt([o,b],()=>Ee(0));const j=d==null?void 0:d.head,Q=O.useRef("");O.useEffect(()=>{if(b!=="history"||!o)return;const K=`${o}:${j??""}`;Q.current!==K&&(Q.current=K,t==null||t.send({t:"git-log",worktreeId:o}))},[b,o,j,t]);const Ie=O.useCallback(K=>{$(_e=>_e===K?null:K),o&&!Z[K]&&(t==null||t.send({t:"git-commit",worktreeId:o,sha:K}))},[o,Z,t]);Bt([ge,X],()=>{var K,_e;X&&((_e=(K=de.current)==null?void 0:K.querySelector('[data-state~="cursor"]'))==null||_e.scrollIntoView({block:"nearest"}))});const xe=O.useRef(-1);xe.current=Oe.findIndex(K=>K.path===p),O.useEffect(()=>{if(!u)return;xe.current>=0&&Ee(xe.current);const K=requestAnimationFrame(()=>{var _e;return(_e=de.current)==null?void 0:_e.focus()});return()=>cancelAnimationFrame(K)},[u]);const V=O.useCallback((K,_e=!1)=>{const pt=Oe[K];pt&&(Ee(K),me(pt.path,_e),se(pt.path,!0))},[Oe,me,se]),be=O.useCallback((K,_e=!1)=>{const pt=D.current;o&&pt&&bo({dispatch:n},{worktreeId:o,path:K,ref:pt,focus:_e})},[o,t,n]),Ae=O.useCallback(K=>{const _e=ae[K];_e&&(Ee(K),_e.file&&be(_e.file.path))},[ae,be]),Pe=O.useCallback(K=>{const _e=ae[K];_e&&(Ee(K),_e.file?be(_e.file.path,!0):Ie(_e.commit.sha))},[ae,be,Ie]),B=K=>{var pt,It;const _e=b==="history";if(K.key==="ArrowDown"||K.key==="ArrowUp"){K.preventDefault();const vn=wp(ge,K.key==="ArrowDown"?1:-1,_e?ae.length:Oe.length);_e?Ae(vn):V(vn)}else if(K.key==="Enter")K.preventDefault(),_e?Pe(ge):V(ge,!0);else if(K.key==="ArrowRight"||K.key==="ArrowLeft"){K.preventDefault();const vn=K.key==="ArrowRight";if(!_e){vn&&_("history");return}const vt=ae[ge];if(vn){if(!vt||vt.file)return;vt.commit.sha!==M?Ie(vt.commit.sha):(pt=ae[ge+1])!=null&&pt.file&&Ae(ge+1)}else vt&&vt.commit.sha===M?(vt.file&&Ee(ae.findIndex(Gt=>!Gt.file&&Gt.commit.sha===vt.commit.sha)),Ie(vt.commit.sha)):_("changes")}else K.key==="Escape"&&(K.stopPropagation(),p!==null?n({a:"close-editor"}):(It=document.activeElement)==null||It.blur())},F=s==null?void 0:s.worktree.id,Te=s?co(s.worktree):"",lt=O.useCallback(K=>F?oi({id:F,dir:Te},K,{discard:!0},{sock:t,dispatch:n}):[],[F,Te,t,n]),Pt=O.useCallback(K=>F?oi({id:F,dir:Te},K,{},{sock:t,dispatch:n}):[],[F,Te,t,n]),Ye=O.useCallback(K=>F?oi({id:F,dir:Te},K,{ref:D.current??void 0},{sock:t,dispatch:n}):[],[F,Te,t,n]),Ge=nn("changes"),Ue=()=>{if(b==="changes"){const _e=Oe[ge];return _e?(ge<g.length?lt:Pt)(_e.path):[]}const K=ae[ge];return K?K.file?Ye(K.file.path):tb(K.commit):[]},At=O.useCallback(K=>{Ee(Oe.findIndex(_e=>_e.path===K)),me(K)},[Oe,me]),Tt=O.useCallback(K=>{Ee(ae.findIndex(_e=>!_e.file&&_e.commit.sha===K)),Ie(K)},[ae,Ie]),ut=O.useCallback(K=>{Ee(ae.findIndex(_e=>{var pt;return((pt=_e.file)==null?void 0:pt.path)===K})),be(K)},[ae,be]),Vt=O.useCallback(()=>{},[]);return h.jsxs("div",{className:ot("left-dock",(!a||c)&&"collapsed"),style:{width:e},children:[h.jsx(D0,{fill:!0,owner:"changes-tabs",label:"changes panel",items:[{id:"changes",label:g.length>0?h.jsxs(h.Fragment,{children:["changes ",h.jsx("span",{className:"tab-count",children:g.length})]}):"changes"},{id:"history",label:"history"}],current:b,onPick:_}),h.jsxs("div",{className:ot("changes-list",b==="history"&&"history"),role:"listbox","aria-label":b==="history"?"commits":"changed files",tabIndex:0,ref:de,onKeyDown:B,onFocus:()=>ce(!0),onMouseDown:K=>{var It;if(K.button!==0)return;K.preventDefault();const _e=K.target.closest('[role="option"]'),pt=_e?Array.from(K.currentTarget.querySelectorAll('[role="option"]')).indexOf(_e):-1;pt>=0&&Ee(pt),(It=de.current)==null||It.focus()},onBlur:K=>!K.currentTarget.contains(K.relatedTarget)&&ce(!1),...Ge.contextMenu(K=>K==="keyboard"?Ue():[]),children:[b==="changes"&&g.length>0&&h.jsxs(h.Fragment,{children:[k.length>0&&h.jsxs("div",{className:"section-title",children:["uncommitted · ",g.length]}),g.map((K,_e)=>h.jsx(Qd,{f:K,active:ee(_e,!m&&K.path===p),selected:X&&ge===_e,onOpen:At,menu:lt,onHover:se},K.path))]}),b==="changes"&&k.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"section-title","data-tip":"Committed on this branch, not yet on main","data-tip-placement":"follow",children:["committed · ",k.length]}),k.map((K,_e)=>h.jsx(Qd,{f:K,active:ee(g.length+_e,!m&&K.path===p),selected:X&&ge===g.length+_e,onOpen:At,menu:Pt,onHover:se},`c-${K.path}`))]}),b==="changes"&&w&&k.length===0&&h.jsx("div",{className:"empty",children:"clean"}),b==="history"&&ae.map((K,_e)=>h.jsxs(O.Fragment,{children:[ie>0&&_e===0&&h.jsxs("div",{className:"section-title",children:["on this branch · ",ie]}),ie>0&&_e===Y&&h.jsx("div",{className:"section-title",children:C}),K.file?h.jsx(Qd,{f:K.file,active:ee(_e,m===K.commit.sha&&K.file.path===p),selected:X&&ge===_e,onOpen:ut,menu:Ye,onHover:Vt}):h.jsx(rP,{c:K.commit,selected:X&&ge===_e,onToggle:Tt})]},K.file?`${K.commit.sha}:${K.file.path}`:K.commit.sha)),b==="history"&&E===void 0&&h.jsx("div",{className:"empty",children:"reading history…"}),b==="history"&&(E==null?void 0:E.length)===0&&h.jsx("div",{className:"empty",children:"no commits yet"})]}),I&&h.jsx(nP,{active:I,ahead:(d==null?void 0:d.ahead)??0,behind:(d==null?void 0:d.behind)??0,dirty:!w})]})}function iP({width:e}){const t=z(o=>o.rightOpen),n=ja();return h.jsx(z0,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}const rf=e=>e>999?"1k+":String(e),of="Lost the daemon; retrying";function sP(){const e=st(),t=nt(),n=PO(),o=n[0]&&Zn(n[0].worktree)?n[0]:null,s=o?n.slice(1):n,[,a]=O.useState(0);O.useEffect(()=>{const B=setInterval(()=>a(F=>F+1),6e4);return()=>clearInterval(B)},[]);const c=z(B=>B.draft!==null),u=LO(),d=zO(),p=DO(),m=FO(),g=z(B=>B.clientId),k=z(B=>B.activeRepoId),w=z(B=>B.connected);O.useEffect(()=>{t&&w&&k&&t.send({t:"list-archived",repoId:k})},[t,w,k]);const b=Ra(),_=MO(),I=z(B=>B.leftOpen),C=z(B=>B.railOpen),E=z(B=>B.focusRail),Z=O.useRef(E),M=O.useRef(null);Bt([E],()=>{if(E===Z.current)return;Z.current=E;const B=requestAnimationFrame(()=>{var F,Te;return(Te=(F=M.current)==null?void 0:F.querySelector('[data-state~="current"]'))==null?void 0:Te.focus()});return()=>cancelAnimationFrame(B)});const $=z(B=>B.termOpen),D=z(B=>B.repos),q=z(B=>B.shipping),J=B=>D.find(F=>F.id===B.repoId)??null,se=nn("rail"),me=xv(),Oe=z(B=>B.home),ae=B=>Oe&&B.path.startsWith(`${Oe}/`)?`~${B.path.slice(Oe.length)}`:B.path,ie=(B,F)=>{const Te=B.usage,lt=[F,(Te==null?void 0:Te.cost)!==void 0?O0(Te.cost):null,Te?`${bc(Te.used)} of ${bc(Te.size)}`:null].filter(Boolean);return lt.length>0?lt.join(" · "):void 0},[Y,de]=O.useState(!1),[ge,Ee]=O.useState([]),X=B=>{ec(B.worktree)&&(de(!0),Ee(F=>F.includes(B.worktree.id)?F.filter(Te=>Te!==B.worktree.id):[...F,B.worktree.id]))},ce=()=>{de(!1),Ee([])};Bt([Y],()=>{const B=F=>F.key==="Escape"&&ce();return Y&&window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)});const ee=Hv(t,e),j={sock:t,dispatch:e},Q=B=>{de(!0),Ee(F=>B===b||F.includes(B)?F:[...F,B])},Ie=B=>ar(B)?Wv(B,J(B),{leftOpen:I,termOpen:$,shipping:q},j,{graft:Q}):SO(B,{termOpen:$,clientId:g},j),xe=h.jsxs("button",{type:"button",className:"row row-edge rail-new","data-state":Rr({current:c}),"data-tip":c?"The worktree being drafted; esc leaves it":"New worktree","data-tip-key":c?void 0:yt("new"),"data-tip-placement":"left",onClick:()=>e({a:"open-draft"}),onKeyDown:B=>{var Te,lt;if(B.key!=="ArrowUp"&&B.key!=="ArrowDown"||B.altKey||B.ctrlKey||B.metaKey)return;B.preventDefault();const F=B.key==="ArrowUp"?o:s[0];F&&(e({a:"activate",id:F.id}),(lt=(Te=B.currentTarget.parentElement)==null?void 0:Te.querySelector(`[data-wt="${F.id}"]`))==null||lt.focus())},children:[h.jsx("span",{className:"rail-gut",children:h.jsx(Ct,{name:"plus",className:"icon-inline"})}),h.jsx("span",{className:"rail-label",children:"new worktree"}),h.jsx(Or,{k:yt("new"),className:"rail-new-kbd"}),h.jsx("span",{className:"rail-glyph rail-new-strip",children:h.jsx(Ct,{name:"plus"})})]}),V=B=>h.jsxs("button",{type:"button",className:ot("row row-edge row-quiet rail-disc-item",(me==null?void 0:me.owner)==="rail"&&me.key===B.id&&"menu-open"),...St(B.restorable?"Restore":"Its commits were not kept",void 0,{placement:"left",detail:Fv(B)}),onClick:()=>{B.restorable&&Lc(t,B.id,g)},...se.contextMenu(()=>xf(B,g,j),B.id),children:[h.jsxs("span",{className:"rail-gut",children:[h.jsx("span",{className:"rail-at row-dim",children:xa(B.archivedAt)}),h.jsx("span",{className:"rail-more",...St("Actions"),onClick:F=>{F.stopPropagation(),se.openUnder(F.currentTarget,()=>xf(B,g,j),B.id)},children:h.jsx(Ct,{name:"more"})})]}),h.jsx("span",{className:"branch",children:B.title})]},B.id),be=[...n,...u],Ae={dirty:be.some(B=>(B.dirty??0)>0),behind:be.some(B=>(B.behind??0)>0),ahead:be.some(B=>(B.ahead??0)>0)},Pe=B=>{var Ye;const F=ar(B)?B:null,Te=B.id,lt=(me==null?void 0:me.owner)==="rail"&&me.key===Te,Pt=F&&Y&&ec(F.worktree)&&Te!==b;return h.jsxs("button",{type:"button",className:ot("row row-edge",F?"rail-item":"row-quiet rail-disc-item",lt&&"menu-open"),"data-state":Rr({current:Te===b&&!c,checked:ge.includes(Te)}),...F?St(_?of:QI(B,$v(J(F))),void 0,{placement:"left",detail:B.unseen&&F.worktree.lastTurn?`${I0(F.worktree.lastTurn)}
224
- ${ae(B)}`:ae(B),dot:_?void 0:la(B),lead:ie(B,Zn(F.worktree)?((Ye=J(F))==null?void 0:Ye.name)??null:null)}):_?St(of,void 0,{placement:"left",detail:ae(B)}):B.locked?St(`Held by ${B.lockReason??"another tool"}`,void 0,{placement:"left",detail:ae(B)}):St(ae(B),void 0,{placement:"left"}),"data-wt":Te,onKeyDown:Ge=>{var ut,Vt;if(!F||Y||Ge.key!=="ArrowUp"&&Ge.key!=="ArrowDown"||Ge.altKey||Ge.ctrlKey||Ge.metaKey)return;Ge.preventDefault();const Ue=Ge.key==="ArrowDown",At=n.findIndex(K=>K.id===Te);if(o&&At===(Ue?0:1)){c||e({a:"open-draft"});return}const Tt=n[At+(Ue?1:-1)];Tt&&(e({a:"activate",id:Tt.id}),(Vt=(ut=Ge.currentTarget.parentElement)==null?void 0:ut.querySelector(`[data-wt="${Tt.id}"]`))==null||Vt.focus())},onClick:Ge=>{F&&(Y||Ge.shiftKey)?Te===b?de(!0):X(F):e({a:"activate",id:Te})},...se.contextMenu(()=>Ie(B),Te),children:[h.jsx("span",{className:"rail-gut",children:Pt?h.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:ge.includes(Te),readOnly:!0,tabIndex:-1}):!Y&&h.jsxs(h.Fragment,{children:[F&&!Zn(F.worktree)&&h.jsx("span",{className:"rail-at row-dim",children:xa(wf(F.worktree))}),h.jsx("span",{className:"rail-more",...St("Actions"),onClick:Ge=>{Ge.stopPropagation(),se.openUnder(Ge.currentTarget,()=>Ie(B),Te)},children:h.jsx(Ct,{name:"more"})})]})}),h.jsx("span",{className:"branch",children:yf(B,F?J(F):null)}),(F==null?void 0:F.worktree.mode)&&F.worktree.mode!=="auto"&&h.jsx("span",{className:"rail-badge badge-mode","data-tip":`${F.worktree.mode} mode: the agent waits for you`,children:F.worktree.mode}),F&&(()=>{const Ge=J(F),Ue=Uv(F.worktree,Ge);return Ue&&Ue!==(Ge==null?void 0:Ge.config.defaultProfile)?h.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${Ue} profile`,children:Ue}):null})(),(F==null?void 0:F.worktree.variant)&&h.jsxs("span",{className:"rail-badge badge-variant clickable","data-tip":"Keep this variant, remove the others",onClick:Ge=>{Ge.stopPropagation(),ee.pickVariant(F)},children:[h.jsxs("span",{className:"num",children:["v",F.worktree.variant.index,"/",F.worktree.variant.of]}),h.jsx("span",{className:"act",children:"pick"})]}),h.jsxs("span",{className:"rail-counts",children:[Ae.dirty&&h.jsx("span",{className:"rail-count badge-dirty","data-tip":B.dirty?`${B.dirty} uncommitted`:void 0,children:B.dirty?`~${rf(B.dirty)}`:""}),Ae.behind&&h.jsx("span",{className:"rail-count row-dim","data-tip":B.behind?`${B.behind} behind ${B.worktree&&Zn(B.worktree)?"origin":"main"}`:void 0,children:B.behind?rf(B.behind):""}),Ae.ahead&&h.jsx("span",{className:"rail-count badge-ahead","data-tip":B.ahead?`${B.ahead} ahead of main`:void 0,children:B.ahead?`+${rf(B.ahead)}`:""})]}),(()=>{if(q[Te]&&la(B)!=="waiting")return h.jsx(nw,{size:"dot"});if(B.locked)return h.jsx("span",{className:"rail-glyph rail-lock row-dim",children:h.jsx(Ct,{name:"lock",className:"icon-inline"})});if(!F)return h.jsx("span",{className:"dot discovered"});const Ge=Y||_?null:gv(B.procs),Ue=B.unseen?" unseen":"";return!Ge||la(B)!=="crashed"?h.jsx("span",{className:`dot ${la(B)}${Ue}`}):h.jsx("span",{className:`dot crashed clickable${Ue}`,...St(Ge.tip),onClick:At=>{At.stopPropagation(),e({a:"activate",id:Te}),e({a:"term-stream",id:Te,stream:Ge.stream})}})})()]},Te)};return h.jsx("div",{className:ot("rail",(Y||(me==null?void 0:me.owner)==="rail")&&"hold",C&&"pinned",_&&"offline"),children:h.jsxs("div",{className:"rail-panel","data-tip":_?of:void 0,"data-tip-placement":"follow",children:[h.jsxs("div",{className:"rail-list",ref:M,children:[o&&Pe(o),!Y&&xe,s.map(Pe),Y&&h.jsxs("div",{className:"rail-graft",children:[(()=>{const B=n.find(lt=>lt.worktree.id===b&&ec(lt.worktree)),F=ge.filter(lt=>lt!==(B==null?void 0:B.worktree.id)),Te=F.map(lt=>{var Pt;return((Pt=n.find(Ye=>Ye.worktree.id===lt))==null?void 0:Pt.worktree.title)??lt}).join(", ");return h.jsxs(De,{size:"md",tone:"primary",disabled:!B||F.length===0,"data-tip":B?`Merge the checked worktrees into ${B.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{B&&window.confirm(`Graft ${Te} onto ${B.worktree.title}?
225
-
226
- Their branches are merged in, then their directories and branches are removed.`)&&(t==null||t.send({t:"graft",targetId:B.worktree.id,sourceIds:F}),ce())},children:["graft ",F.length]})})(),h.jsxs(De,{size:"md",disabled:!ge.some(B=>{var F;return(((F=n.find(Te=>Te.worktree.id===B))==null?void 0:F.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const B of ge){const F=n.find(Te=>Te.worktree.id===B);((F==null?void 0:F.behind)??0)>0&&$o(t,e,{t:F&&Zn(F.worktree)?"pull-main":"sync-main",worktreeId:B})}ce()},children:[h.jsx(Ct,{name:"pull",className:"icon-inline"})," sync"]}),h.jsx(De,{size:"md",tone:"danger",disabled:ge.length===0,"data-tip":"Remove all selected worktrees (their chats and work are archived)",onClick:()=>{window.confirm(`Remove ${ge.length} worktree(s)?
227
-
228
- Their directories and branches go. The chats, commits and any uncommitted changes are archived, and each can be restored.`)&&(_a(t,e,ge),ce())},children:"remove…"}),h.jsx(Kt,{icon:"close",label:"Cancel",hint:"esc",onClick:ce})]}),!Y&&u.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("button",{className:"rail-disc-head","aria-expanded":d,...St(`${u.length} worktree${u.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:"left"}),onClick:()=>e({a:"toggle-discovered"}),children:[h.jsx("span",{className:"rail-gut",children:h.jsx(Ct,{name:"caret",className:ot("icon-inline rail-disc-caret",!d&&"shut")})}),h.jsxs("span",{className:"rail-label",children:["discovered · ",u.length]})]}),d&&u.map(Pe)]}),!Y&&p.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button",className:"rail-disc-head","aria-expanded":m,...St(`${p.length} removed worktree${p.length===1?"":"s"}, kept with ${p.length===1?"its chat":"their chats"}`,void 0,{placement:"left"}),onClick:()=>e({a:"toggle-archived"}),children:[h.jsx("span",{className:"rail-gut",children:h.jsx(Ct,{name:"caret",className:ot("icon-inline rail-disc-caret",!m&&"shut")})}),h.jsxs("span",{className:"rail-label",children:["archived · ",p.length]})]}),m&&p.map(V)]})]}),h.jsx("div",{className:"rail-foot",children:h.jsx(Kt,{icon:"worktrees",label:"Worktree panel",hint:yt("rail"),tone:"chrome",on:C,onClick:()=>e({a:"toggle-rail"})})})]})})}function aP(e,t){const n=[];return e&&(n.push({id:"open-tab",label:"open in a new tab",onClick:()=>window.open(e,"_blank")}),n.push({id:"copy-url",label:"copy URL",onClick:()=>Ln(e)})),Hn([n,[{id:"reload",label:"reload preview",onClick:t.reload}]])}function lP({leftPx:e,rightPx:t}){const n=AO(),o=e+(n-e-t)/2,s=st(),a=nt(),c=Xn(),u=nn("bar"),d=$i(),p=Fc(),m=z(Z=>Z.zen)&&!p,g=z(Z=>Z.leftOpen),k=z(Z=>Z.rightOpen),w=ja(),b=z(Z=>Z.designOpen),_=z(Z=>{var M;return((M=Z.overlay)==null?void 0:M.kind)==="keys"}),I=dP(),C=(d==null?void 0:d.worktree.id)??null,E=!!d&&Lv(d);return h.jsxs("div",{className:"top-bar",children:[m&&h.jsx("span",{className:"bar-zen-title",children:(d==null?void 0:d.worktree.title)??"Toyon"}),!w&&h.jsx(Kt,{icon:"branch",label:"Changes panel",hint:yt("left"),tone:"chrome",on:g,onClick:()=>s({a:"toggle-left"})}),h.jsx(cP,{}),!p&&h.jsx(uP,{worktreeId:C,repoId:(d==null?void 0:d.repoId)??null,ready:E,left:o}),I&&h.jsxs(De,{"data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void I.prompt(),children:[h.jsx(Ct,{name:"download",className:"icon-inline"})," install app"]}),h.jsx("span",{className:"bar-grow"}),h.jsxs("span",{className:"bar-tools",children:[h.jsx(Kt,{icon:"settings",label:"Settings & shortcuts",hint:yt("keys"),tone:"chrome",on:_,"aria-controls":"keys-help","aria-expanded":_,onClick:()=>s({a:"toggle",overlay:{kind:"keys"}}),...u.contextMenu(()=>s0(c.getState(),{sock:a,dispatch:s}))}),!w&&!p&&h.jsx(Kt,{icon:"palette",label:"Design system",hint:yt("design"),tone:"chrome",on:b,onClick:()=>s({a:"toggle-design"})}),!w&&!p&&h.jsx(Kt,{icon:"chat",label:"Chat panel",hint:yt("composer"),tone:"chrome",on:k,onClick:()=>s({a:"toggle-right"})}),!p&&h.jsx(Kt,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:yt("zen"),tone:"chrome",on:m,onClick:()=>s({a:"toggle-zen"})})]})]})}function cP(){const e=st(),t=nt(),n=Ca(),o=z(p=>p.repos),s=nn("bar"),a=()=>Hn([[{id:"project",label:o.length>1?"switch project…":"open project…",key:yt("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?Kc(n,n.id,{sock:t,dispatch:e}):[]]),c=z(p=>{var m;return((m=p.overlay)==null?void 0:m.kind)==="projects"&&p.overlay.form==="pill"}),u=z(p=>p.heard),d=z(p=>p.newProject!==null);return h.jsxs("span",{className:"bar-project",children:[h.jsx(De,{tone:"chrome",className:"bar-pill",on:c,...St(o.length>1?"Switch project":"Open a project",yt("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...s.contextMenu(a),children:h.jsx("span",{className:"bar-project-name",children:d?"new project":(n==null?void 0:n.name)??(u?"open project":"")})}),c&&h.jsx(eb,{form:"pill"})]})}function uP({worktreeId:e,repoId:t,ready:n,left:o}){const s=Xt(e,"page").url,a=d0(s),c=st(),u=z(w=>{var b;return((b=w.overlay)==null?void 0:b.kind)==="routes"}),d=()=>{n&&e&&t&&!u&&c({a:"open",overlay:{kind:"routes"}})};Bt([e,n],()=>{u&&c({a:"close"})});const m=nn("bar").contextMenu(()=>n?aP(s,{reload:()=>e&&Nt.post(e,{type:"reload"})}):[]),g=z(w=>w.picking),k=sp();return h.jsxs("div",{className:"bar-center",style:{left:o},children:[h.jsx(Kt,{icon:"back",label:"Back",disabled:!n,onClick:()=>e&&Nt.post(e,{type:"back"}),...m}),h.jsx(Kt,{icon:"forward",label:"Forward",disabled:!n,onClick:()=>e&&Nt.post(e,{type:"forward"}),...m}),h.jsx(Kt,{icon:"reload",label:"Reload preview",disabled:!n,onClick:()=>e&&Nt.post(e,{type:"reload"}),...m}),h.jsxs("span",{className:"bar-route",children:[h.jsx(Mo,{className:"bar-path",value:n?a:"",readOnly:!0,disabled:!n,placeholder:n?"/":"",onMouseDown:w=>{w.button===0&&w.preventDefault()},onClick:d,onFocus:d,spellCheck:!1,...St("Go to a page",yt("routes"))}),u&&n&&e&&t&&h.jsx(e2,{worktreeId:e,repoId:t,url:s},e)]}),h.jsx(Kt,{icon:"inspect",label:"Pick an element to open its code",hint:yt("inspect"),also:{text:"Add an element to chat",key:yt("pick")},on:g==="code",disabled:!n||!k,onClick:()=>k&&Ea(k,g,c,"code")})]})}function dP(){const[e,t]=O.useState(null);return O.useEffect(()=>{if(vv())return;const n=s=>{s.preventDefault(),t(s)},o=()=>t(null);return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",o),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",o)}},[]),e}const fP=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function pP(){const e=xv(),t=Xn();return O.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||yr.close()},o=new MutationObserver(n);o.observe(document.body,{childList:!0,subtree:!0});const s=t.subscribe(n);return()=>{o.disconnect(),s()}},[e,t]),e?h.jsx(hP,{spec:e},e.id):null}function hP({spec:e}){const t=e.items,n=t.filter(Ni),[o,s]=O.useState(-1),a=O.useRef({idx:o,items:n});a.current={idx:o,items:n};const c=O.useRef(null),u=g=>{var k,w;{const b=()=>yr.close(),{idx:_,items:I}=a.current;if(fP.has(g.key))return;if(g.key==="ArrowDown"||g.key==="ArrowUp"){g.preventDefault(),g.stopPropagation();const C=g.key==="ArrowDown"?1:-1;s(iO(I,_,C));return}if((g.key==="Enter"||g.key===" ")&&_>=0&&I[_]&&!I[_].disabled){g.preventDefault(),g.stopPropagation(),I[_].onClick(),b();return}if(g.key==="Escape"){g.stopPropagation(),b();return}if(g.key.length===1&&!g.metaKey&&!g.ctrlKey&&!g.altKey){g.preventDefault(),g.stopPropagation();const C=Array.from(((k=c.current)==null?void 0:k.querySelectorAll(".menu-label"))??[],Z=>Z.textContent??""),E=dj(C,_,g.key);E>=0&&!((w=I[E])!=null&&w.disabled)&&s(E);return}b()}};O.useEffect(()=>{const g=()=>yr.close();return window.addEventListener("blur",g),window.addEventListener("resize",g),document.addEventListener("scroll",g,!0),()=>{window.removeEventListener("blur",g),window.removeEventListener("resize",g),document.removeEventListener("scroll",g,!0)}},[]);const{rect:d,placement:p}=lO(e),m=n.some(g=>g.checked);return h.jsx(Aa,{className:"menu",role:"menu",boxRef:c,anchor:()=>d,placement:p,track:!1,trigger:e.target,onDismiss:()=>yr.close(),onKey:u,onContextMenu:g=>g.preventDefault(),children:t.map((g,k)=>{if(!Ni(g))return h.jsx("hr",{className:"menu-sep"},`sep-${k}`);const w=n.indexOf(g);return h.jsx(mP,{item:g,gutter:m,cursor:w===o,onEnter:()=>s(w)},g.id)})})}function mP({item:e,gutter:t,cursor:n,onEnter:o}){const s=e.disabled!==void 0,a=e.detail??e.disabled;return h.jsxs("button",{...e.checked===void 0?{role:"menuitem"}:{role:"menuitemcheckbox","aria-checked":e.checked},"aria-disabled":s||void 0,className:ot("row",e.danger&&"danger",a!==void 0&&"row-tall",s&&"disabled"),"data-state":Rr({cursor:n,checked:e.checked}),onMouseEnter:s?void 0:o,onClick:()=>{s||(e.onClick(),yr.close())},children:[t&&h.jsx("span",{className:"menu-check",children:e.checked&&h.jsx(Ct,{name:"check",className:"icon-inline"})}),h.jsxs("span",{className:"menu-text",children:[h.jsx("span",{className:"menu-label",children:e.label}),a!==void 0&&h.jsx("span",{className:"menu-detail row-dim",children:a})]}),e.key&&h.jsx(Or,{k:e.key,className:"menu-key row-dim"})]})}function gP(e,t,n,o,s){const[a,...c]=e,u=a?[a.id,null,...c.map(k=>k.id)]:[],d=o?a?1:-1:n?u.indexOf(n):-1;if(d>=0){const k=u[(d+s+u.length)%u.length];return k?{activate:k}:{draft:!0}}if(o||!n)return null;const p=t.findIndex(k=>k.id===n);if(p<0)return null;const m=t[p+s];if(m)return{activate:m.id};const g=e[e.length-1];return s<0&&g?{activate:g.id}:null}function kP(e,t,n,o){const s=m=>e.map((g,k)=>m(g)&&g.id!==t?k:-1).filter(g=>g>=0),a=s(m=>m.agent==="waiting"),c=a.length>0?a:s(m=>!!m.unseen);if(c.length===0)return o<0?e[0]?{activate:e[0].id}:null:n?null:{draft:!0};const u=n?.5:e.findIndex(m=>m.id===t),d=o>0?c.find(m=>m>u)??c[0]:c.findLast(m=>m<u)??c[c.length-1],p=d===void 0?void 0:e[d];return p?{activate:p.id}:null}const Yl=e=>{var t;return!!((t=document.activeElement)!=null&&t.closest(e))},yP=new Set(["design","new","routes"]),vP=new Set(["project","commands","keys","zen"]);function wP(){const e=Xn(),t=nt();O.useEffect(()=>{const n=o=>{var d,p,m,g;const s=e.getState(),{dispatch:a}=e,c=Vx(o,{guest:!!((d=document.activeElement)!=null&&d.closest(".xterm"))});if(!(s.zen&&!wo(s)&&!s.overlay&&!s.picking&&(c==null?void 0:c.id)!=="zen"||(p=document.activeElement)!=null&&p.closest(".monaco-editor")&&c&&(o.altKey||yP.has(c.id)))){if(c){if(o.preventDefault(),s.newProject&&!vP.has(c.id))return;switch(c.id){case"worktree":{const k=Yx(c.digit,s.visible.length),w=k===null?void 0:s.visible[k];w&&a({a:"activate",id:w.id});break}case"wt-prev":case"wt-next":{const k=gP(s.visible,s.visibleDiscovered,s.activeId,!!s.draft,c.id==="wt-next"?1:-1);k&&"draft"in k?a({a:"open-draft"}):k&&a({a:"activate",id:k.activate});break}case"wt-unseen-prev":case"wt-unseen-next":{const k=kP(s.visible,s.activeId,!!s.draft,c.id==="wt-unseen-next"?1:-1);k&&"draft"in k?a({a:"open-draft"}):k&&a({a:"activate",id:k.activate});break}case"mark-unread":s.activeId&&!s.draft&&s.visible.some(k=>k.id===s.activeId)&&Zv(t,a,s.activeId);break;case"new":s.draft?a({a:"focus-right"}):a({a:"open-draft"});break;case"project":a({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((m=s.overlay)==null?void 0:m.kind)==="quick-open"?a({a:"close"}):s.activeId&&(t==null||t.send({t:"list-files",worktreeId:s.activeId}),a({a:"open",overlay:{kind:"quick-open"}}));break;case"routes":((g=s.overlay)==null?void 0:g.kind)==="routes"?a({a:"close"}):np(s)&&a({a:"open",overlay:{kind:"routes"}});break;case"pick":case"inspect":{const k=bf(s);k&&Ea(k,s.picking,a,c.id==="pick"?"chat":"code");break}case"search":s.activeId&&a({a:"toggle",overlay:{kind:"search"}});break;case"refs":s.activeRepoId&&a({a:"toggle",overlay:{kind:"refs"}});break;case"commands":a({a:"toggle",overlay:{kind:"commands"}});break;case"zen":a({a:"toggle-zen"});break;case"left":a(s.leftOpen&&Yl(".changes-list")?{a:"toggle-left"}:{a:"focus-left"});break;case"composer":a(s.rightOpen&&!wo(s)&&Yl(".chat-input")?{a:"toggle-right"}:{a:"focus-right"});break;case"rail":a(s.railOpen&&Yl(".rail-list")?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":a({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":a(s.termOpen&&Yl(".xterm")?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":a({a:"toggle-design"});break;case"term-tab":{const k=s.rows.find(I=>I.id===s.activeId);if(!k)break;const w=lo(s,s.activeId).termStream;if(k.login&&w===Ao)break;const b=[vo,...k.login?[Ao]:[],...k.procs.map(I=>I.name)],_=b.indexOf(w);a({a:"term-stream",id:k.id,stream:b[(_+1)%b.length]??vo});break}}}else if(o.key==="Escape")if(s.choosingFolder)t==null||t.send({t:"cancel-folder"}),a({a:"choosing-folder",v:!1});else if(s.overlay)a({a:"close",back:zv(s.overlay)});else if(s.newProject)s.newProject.phase==="editing"&&a({a:"close-new-project"});else if(s.picking){const k=bf(s);k&&Nt.post(k,{type:"pick-cancel"}),a({a:"set-picking",v:!1})}else s.draft?a({a:"close-draft"}):s.activeImportId?a({a:"watch-import",id:null}):s.termOpen?a({a:"toggle-terminal"}):s.editor?a({a:"close-editor"}):s.designOpen&&a({a:"toggle-design"})}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t]),O.useEffect(()=>{const n=o=>{if(o.key!=="Alt"&&o.key!=="Shift")return;const s=e.getState();s.picking&&s.activeId&&Nt.post(s.activeId,{type:"pick-mods",alt:o.altKey,shift:o.shiftKey})};return window.addEventListener("keydown",n),window.addEventListener("keyup",n),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",n)}},[e])}const bP=40,xP=280,_P=3,EP=2e3,SP=5e3,NP="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function TP(){const e=Xn(),t=st(),n=nt(),o=Ra(),s=z(V=>V.activeRepoId),a=$i(),c=ip(),u=z(V=>V.connected),d=z(V=>V.daylight),p=z(V=>{var be;return((be=V.daylight)==null?void 0:be.until)??0}),m=ja(),g=Fc(),k=z(V=>V.zen)&&!g,w=z(V=>V.leftOpen)&&!m,b=z(V=>V.rightOpen)&&!m&&!g,_=z(V=>V.railOpen),I=z(V=>V.panels),C=z(V=>V.lastActive),E=z(V=>V.discoveredOpen),Z=z(V=>V.archivedOpen),M=Dc(),$=z(V=>V.previewTheme!==null),D=z(V=>V.toast),q=z(V=>V.clientId),J=qv();O.useEffect(()=>Sa.install(window),[]);const se=O.useRef([]);O.useEffect(()=>{if(!n||!u||!o)return;const V=[o,...se.current.filter(be=>be!==o)];for(const be of V.splice(_P))n.send({t:"unsubscribe",worktreeId:be});se.current.includes(o)||n.send({t:"subscribe",worktreeId:o}),se.current=V},[o,u,n]),O.useEffect(()=>{if(!(!n||!u))for(const V of se.current)n.send({t:"subscribe",worktreeId:V})},[u,n]),O.useEffect(()=>{const V=new Set(J.map(be=>be.id));se.current=se.current.filter(be=>V.has(be))},[J]),O.useEffect(()=>{document.title=c?`${c.name} · Toyon`:"Toyon"},[c]);const me=!!(a!=null&&a.unseen),Oe=z(V=>V.unreadHold!==null&&V.unreadHold===V.activeId);O.useEffect(()=>{if(!n||!o||!me||Oe)return;let V;const be=()=>document.visibilityState==="visible"&&document.hasFocus(),Ae=()=>{clearTimeout(V),be()&&(t({a:"arrive",id:o}),V=setTimeout(()=>{be()&&n.send({t:"seen",worktreeId:o})},EP))},Pe=()=>clearTimeout(V);return Ae(),window.addEventListener("focus",Ae),window.addEventListener("blur",Pe),()=>{Pe(),window.removeEventListener("focus",Ae),window.removeEventListener("blur",Pe)}},[n,o,me,Oe,t]);const ae=O.useRef(0);O.useEffect(()=>{if(!n||!u||!s)return;const V=()=>{Date.now()-ae.current<SP||(ae.current=Date.now(),n.send({t:"refresh-git",repoId:s}))};return window.addEventListener("focus",V),()=>window.removeEventListener("focus",V)},[n,u,s]),O.useEffect(()=>{ew(M,{remember:!$}),Nt.broadcast(tw(M))},[M,$]),O.useEffect(()=>iR(V=>t({a:"system-dark",v:V})),[t]);const ie=O.useCallback(()=>{n==null||n.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[n]);O.useEffect(()=>{if(!u)return;ie();const V=()=>{document.visibilityState==="visible"&&ie()};return document.addEventListener("visibilitychange",V),()=>document.removeEventListener("visibilitychange",V)},[u,ie]),O.useEffect(()=>{if(!u||p<=Date.now())return;const V=setTimeout(ie,p-Date.now()+1e3);return()=>clearTimeout(V)},[u,p,ie]),O.useEffect(()=>{d&&d.until>0&&oR(d)},[d]),O.useEffect(()=>{if(o)try{localStorage.setItem(ft.active,o)}catch{}},[o]),O.useEffect(()=>{if(s)try{localStorage.setItem(ft.repo,s)}catch{}},[s]),O.useEffect(()=>{try{localStorage.setItem(ft.rail,_?"1":"0")}catch{}},[_]),O.useEffect(()=>{try{localStorage.setItem(ft.panels,JSON.stringify(I))}catch{}},[I]),O.useEffect(()=>{try{localStorage.setItem(ft.lastActive,JSON.stringify(C))}catch{}},[C]),O.useEffect(()=>{try{localStorage.setItem(ft.discoveredOpen,JSON.stringify(E))}catch{}},[E]),O.useEffect(()=>{try{localStorage.setItem(ft.archivedOpen,JSON.stringify(Z))}catch{}},[Z]),wP(),x2();const Y=O.useRef(null);O.useEffect(()=>{if(!D)return;D.ok&&D.url&&Y.current!==D.url&&(Y.current=D.url,window.open(D.url,"_blank"));const V=setTimeout(()=>t({a:"dismiss-toast"}),D.ok?5e3:12e3);return()=>clearTimeout(V)},[D,t]);const de=O.useRef(null);Bt([o],()=>{var lt,Pt,Ye,Ge;const V=de.current;if(de.current=o,!V||!o||V===o)return;const be=e.getState(),Ae=J.find(Ue=>Ue.id===V),Pe=J.find(Ue=>Ue.id===o),B=(Pt=(lt=Ae==null?void 0:Ae.worktree)==null?void 0:lt.variant)==null?void 0:Pt.group;if(!B||((Ge=(Ye=Pe==null?void 0:Pe.worktree)==null?void 0:Ye.variant)==null?void 0:Ge.group)!==B)return;const F=Ue=>{var At;try{const Tt=(At=be.local[Ue])==null?void 0:At.page.url;return Tt?new URL(Tt).pathname+new URL(Tt).search:"/"}catch{return"/"}},Te=F(V);Te!==F(o)&&Nt.post(o,{type:"navigate",path:Te})});const[ge,Ee]=so(ft.leftWidth,220,V=>V?Zl(Number(V),220):void 0),[X,ce]=so(ft.rightWidth,380,V=>V?Zl(Number(V),380):void 0),ee=ma(V=>Zl(V.clientX,220),Ee),j=m?0:_?xP:bP,Q=ma(V=>Zl(window.innerWidth-j-V.clientX,380),ce),xe=nn("app").contextMenu(()=>Dv(e.getState(),{sock:n,dispatch:t}));return h.jsxs("div",{className:ot("app",k&&"zen"),onContextMenu:V=>{V.defaultPrevented||V.target instanceof Element&&V.target.closest(NP)||xe.onContextMenu(V)},children:[h.jsx(_R,{}),h.jsx(pP,{}),h.jsx(lP,{leftPx:w?ge:0,rightPx:(b?X:0)+j}),h.jsxs("div",{className:"docks",children:[h.jsx(oP,{width:ge}),w&&h.jsx("div",{className:"dock-resize left",onPointerDown:ee}),h.jsx(tP,{}),b&&h.jsx("div",{className:"dock-resize right",onPointerDown:Q}),!g&&h.jsx(iP,{width:X}),!m&&h.jsx(sP,{})]}),D&&h.jsxs(Aa,{className:ot("toast",!D.ok&&"err"),role:"status",raiseKey:D,children:[D.message,h.jsx(Kt,{icon:"close",label:"Dismiss",tone:"quiet",className:"toast-dismiss",onClick:()=>t({a:"dismiss-toast"})}),D.removeIds&&D.removeIds.length>0&&h.jsx(De,{variant:"outline",size:"md",tone:"primary",className:"toast-action",onClick:V=>{V.stopPropagation(),_a(n,t,D.removeIds??[]),t({a:"dismiss-toast"})},children:D.removeIds.length>1?`clean up ${D.removeIds.length} worktrees`:"remove worktree"}),D.restoreId&&h.jsx(De,{variant:"outline",size:"md",tone:"primary",className:"toast-action",onClick:V=>{V.stopPropagation(),D.restoreId&&Lc(n,D.restoreId,q),t({a:"dismiss-toast"})},children:"restore"})]})]})}const Ql=new Map,IP={on(e,t){let n=Ql.get(e);return n||(n=new Set,Ql.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Ql.delete(e)}},deliver(e){for(const t of Ql.get(m1(e.worktreeId,e.stream))??[])t(e)}},OP=800;function RP(e,t,n,o){if(o.version===e.version)return"same";const s=t===e.text&&n===null;return o.version===null?s?"gone":"conflict":o.after===t||o.after===n?"adopt":s?"apply":"conflict"}const no=e=>`${e.worktreeId}
229
- ${e.ref??""}
230
- ${e.path}`;class CP{constructor(t){dt(this,"files",new Map);this.d=t}start(){var s;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const a=this.d.store.getState(),c=t;t=a,this.follow(c,a)}),o=()=>{const a=this.d.store.getState().editor;a&&this.refresh(no(a))};return(s=this.d.win)==null||s.addEventListener("focus",o),()=>{var a;n(),(a=this.d.win)==null||a.removeEventListener("focus",o)}}receive(t){const n=this.files.get(no(t)),o=n==null?void 0:n.out;!n||!o||o.seq!==t.seq||(n.out=null,t.t==="file-read"?this.read(n,t):o.write!==void 0&&this.written(n,o.write,t),this.next(n))}bind(t){const n=no(t);return{attach:o=>this.attach(n,o),edited:()=>this.edited(n),saveNow:()=>this.saveNow(n)}}reload(t){var s;const n=this.files.get(no(t)),o=n==null?void 0:n.conflict;!n||!o||(this.cancelTimer(n),n.pending=null,n.base={text:o.after,version:o.version},this.setConflict(n,null),o.version===null?this.d.store.dispatch({a:"close-editor"}):(s=n.buffer)==null||s.replace(o.after),this.next(n))}keepMine(t){const n=this.files.get(no(t)),o=n==null?void 0:n.conflict;!(n!=null&&n.buffer)||!o||(n.base={text:o.after,version:o.version},this.setConflict(n,null),n.pending=n.buffer.text(),this.next(n))}follow(t,n){t.connected&&!n.connected&&this.dropped();const o=n.editor,s=t.editor;if(s&&(!o||no(s)!==no(o))&&this.closed(no(s)),o&&(!s||s.seq!==o.seq)&&this.opened(o),!t.connected&&n.connected)for(const a of this.files.values())a.reread=!0,this.next(a);else o&&s&&s.seq===o.seq&&lo(t,o.worktreeId).git!==lo(n,o.worktreeId).git&&this.refresh(no(o))}opened(t){const n=no(t);let o=this.files.get(n);o||(o={file:{worktreeId:t.worktreeId,path:t.path,...t.ref?{ref:t.ref}:{}},open:!0,base:null,out:null,pending:null,reread:!1,writable:!1,conflict:null,buffer:null,timer:void 0},this.files.set(n,o)),o.open=!0,o.reread=!0,o.conflict&&this.d.store.dispatch({a:"editor-conflict",file:o.file,theirs:o.conflict}),this.next(o)}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.files.values())t.out&&(t.out.write!==void 0&&(t.pending??(t.pending=t.out.write)),t.out=null,t.reread=!0)}next(t){var a;if(t.out||!this.d.store.getState().connected)return;const{worktreeId:n,path:o,ref:s}=t.file;if(t.reread){t.reread=!1;const c=dc();t.out={seq:c},this.d.send({t:"read-file",worktreeId:n,path:o,ref:s,seq:c});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!s){const c=t.pending,u=dc();t.pending=null,t.out={seq:u,write:c},this.d.send({t:"write-file",worktreeId:n,path:o,content:c,base:((a=t.base)==null?void 0:a.version)??null,seq:u});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(no(t.file))}read(t,n){var k,w;const{file:o}=t;if(n.error){t.open&&this.d.store.dispatch({a:"editor-read",file:o,disk:null,error:n.error});return}const{before:s,after:a,version:c,writable:u,binary:d,tooLarge:p}=n;t.writable=u,t.open&&this.d.store.dispatch({a:"editor-read",file:o,disk:{before:s,after:a,version:c,writable:u,binary:d,tooLarge:p}});const m={after:t.buffer?t.buffer.normalize(a):a,version:c};if(!t.base){t.base={text:m.after,version:c};return}const g=((k=t.buffer)==null?void 0:k.text())??t.pending??t.base.text;switch(RP(t.base,g,t.pending,m)){case"same":break;case"adopt":t.base={text:m.after,version:c};break;case"apply":(w=t.buffer)==null||w.replace(m.after),t.base={text:m.after,version:c};break;case"gone":t.base={text:"",version:null},t.open&&this.d.store.dispatch({a:"close-editor"});break;case"conflict":this.setConflict(t,m);return}this.setConflict(t,null)}written(t,n,o){if(o.ok){t.base={text:n,version:o.version};return}if(o.reason==="changed"){t.pending??(t.pending=n),t.reread=!0;return}t.writable=!1,t.pending=null,this.d.store.dispatch({a:"toast",toast:{ok:!1,message:o.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}):n&&this.d.store.dispatch({a:"toast",toast:{ok:!1,message:`not saved: ${t.file.path} changed on disk; open it again to keep your edits`}}))}attach(t,n){const o=this.files.get(t);if(o){if(n){o.buffer=n,o.base&&(o.base={...o.base,text:n.normalize(o.base.text)}),o.conflict&&o.pending!==null&&n.replace(o.pending);return}o.buffer&&((o.timer!==void 0||o.conflict)&&(o.pending=o.buffer.text()),this.cancelTimer(o),o.buffer=null,this.next(o))}}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)},OP))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const o=n.buffer.text();o.length>k1||(n.pending=o,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}window.__toyonShell=!0;RO();const nb=eR();ew(nb);function Ii(e,t){try{return e.getItem(t)}catch{return null}}function jP(){const e=(n,o)=>typeof n=="boolean"?n:o,t={};try{const n=JSON.parse(Ii(localStorage,ft.panels)??"{}");if(!n||typeof n!="object")return t;for(const[o,s]of Object.entries(n))!s||typeof s!="object"||(t[o]={left:e(s.left,Hl.left),right:e(s.right,Hl.right),term:e(s.term,Hl.term),design:e(s.design,Hl.design)})}catch{}return t}function AP(){const e={};try{const t=JSON.parse(Ii(localStorage,ft.lastActive)??"{}");if(!t||typeof t!="object")return e;for(const[n,o]of Object.entries(t))typeof o=="string"&&o&&(e[n]=o)}catch{}return e}function gy(e){const t={};try{const n=JSON.parse(Ii(localStorage,e)??"{}");if(!n||typeof n!="object")return t;for(const[o,s]of Object.entries(n))typeof s=="boolean"&&(t[o]=s)}catch{}return t}function $P(){const e=Ii(sessionStorage,ft.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(ft.client,t)}catch{}return t}const Oi=NO(pO({cached:nb,systemDark:tR(),daylight:rR(),storedActive:Ii(localStorage,ft.active),storedRepo:Ii(localStorage,ft.repo),storedRailOpen:Ii(localStorage,ft.rail)==="1",storedPanels:jP(),storedLastActive:AP(),storedDiscoveredOpen:gy(ft.discoveredOpen),storedArchivedOpen:gy(ft.archivedOpen),clientId:$P()})),Ap=new RR(e=>{if(e.t==="hello"&&e.protocol!==xy){Oi.dispatch({a:"incompatible"}),Ap.dispose();return}if(x1(e)){IP.deliver(e);return}if(_1(e)){$p.receive(e);return}Oi.dispatch({a:"server",msg:e})},(e,t)=>Oi.dispatch({a:"connected",v:e,failure:t})),$p=new CP({store:Oi,send:e=>Ap.send(e),timers:{set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)},win:window});$p.start();window.addEventListener("vite:preloadError",NR);window.addEventListener("beforeunload",e=>{Oi.getState().rows.some(n=>n.agent==="working"||n.agent==="waiting")&&(e.preventDefault(),e.returnValue="an agent is still working")});const MP=(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;t&&typeof t=="object"&&t.t==="hello"&&t.protocol===xy&&Oi.dispatch({a:"server",msg:t})});MP.then(()=>qI.createRoot(document.getElementById("root")).render(h.jsx(ZI.StrictMode,{children:h.jsx(cp,{children:h.jsx(TO,{store:Oi,sock:Ap,files:$p,children:h.jsx(TP,{})})})})));"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{V0 as _,Yf as a,LP as b,IP as c,m1 as d,FI as h,h as j,Vx as m,O as r,AI as s,Oa as t,Bt as u,Bg as w};