toyon 0.8.1 → 0.10.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 (27) hide show
  1. package/dist/bridge.js +1 -1
  2. package/dist/cli.js +68 -15
  3. package/dist/daemon.js +1882 -561
  4. package/dist/shell/assets/{Editor-CrfFlcLA.js → Editor-DL0q1Bu5.js} +170 -170
  5. package/dist/shell/assets/{XTerm-CsuyFSMK.js → XTerm-C9YH4Lh2.js} +16 -16
  6. package/dist/shell/assets/{cssMode-CWkICf31.js → cssMode-Et22hXpa.js} +1 -1
  7. package/dist/shell/assets/{freemarker2-C2fP12sE.js → freemarker2-Clz20PcM.js} +1 -1
  8. package/dist/shell/assets/{grammar-5S_Kl1e8.js → grammar-CPvdB3az.js} +5 -5
  9. package/dist/shell/assets/{handlebars-CkRyqZGC.js → handlebars-B4nvXAx8.js} +1 -1
  10. package/dist/shell/assets/{html-C9iJKWKA.js → html-DPIGgBLK.js} +1 -1
  11. package/dist/shell/assets/{htmlMode-Dps-6NJd.js → htmlMode-C2LaVuEX.js} +1 -1
  12. package/dist/shell/assets/index-2QusTgw-.js +262 -0
  13. package/dist/shell/assets/index-TaJLoLSd.css +1 -0
  14. package/dist/shell/assets/{javascript-DM5EiBY7.js → javascript-CnwJfTbN.js} +1 -1
  15. package/dist/shell/assets/{jsonMode-ampRCTsW.js → jsonMode-8znCTiqR.js} +1 -1
  16. package/dist/shell/assets/{liquid-CEUat1ZS.js → liquid-Bdm-1CUh.js} +1 -1
  17. package/dist/shell/assets/{lspLanguageFeatures-ChupARNW.js → lspLanguageFeatures-B1DMU7yH.js} +1 -1
  18. package/dist/shell/assets/{mdx-DAglTq4w.js → mdx-Ktcqo9Jf.js} +1 -1
  19. package/dist/shell/assets/{python-DOPtAG-1.js → python-QX--d8LR.js} +1 -1
  20. package/dist/shell/assets/{razor-qRDOBjWc.js → razor-C0LrXteG.js} +1 -1
  21. package/dist/shell/assets/{tsMode-BD49NPBt.js → tsMode-BtYCp6db.js} +1 -1
  22. package/dist/shell/assets/{xml-p5Js1H7t.js → xml-BXbaQ9MG.js} +1 -1
  23. package/dist/shell/assets/{yaml-CctH9qfh.js → yaml-C6FhaU_C.js} +1 -1
  24. package/dist/shell/index.html +26 -2
  25. package/package.json +1 -1
  26. package/dist/shell/assets/index-BKyLPsvB.js +0 -258
  27. package/dist/shell/assets/index-DIDGdnCY.css +0 -1
@@ -0,0 +1,262 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Editor-DL0q1Bu5.js","assets/grammar-CPvdB3az.js","assets/Editor-CB2SckMT.css","assets/XTerm-C9YH4Lh2.js","assets/XTerm-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
+ var qN=Object.defineProperty;var GN=(e,t,n)=>t in e?qN(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var jt=(e,t,n)=>GN(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(o){if(o.ep)return;o.ep=!0;const a=n(o);fetch(o.href,a)}})();function wb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Op={exports:{}},wl={},$p={exports:{}},zt={};/**
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 ew;function VN(){if(ew)return zt;ew=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.iterator;function k($){return $===null||typeof $!="object"?null:($=h&&$[h]||$["@@iterator"],typeof $=="function"?$:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,x={};function _($,V,de){this.props=$,this.context=V,this.refs=x,this.updater=de||y}_.prototype.isReactComponent={},_.prototype.setState=function($,V){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,V,"setState")},_.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function N(){}N.prototype=_.prototype;function j($,V,de){this.props=$,this.context=V,this.refs=x,this.updater=de||y}var E=j.prototype=new N;E.constructor=j,v(E,_.prototype),E.isPureReactComponent=!0;var M=Array.isArray,K=Object.prototype.hasOwnProperty,U={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function I($,V,de){var me,he={},$e=null,ae=null;if(V!=null)for(me in V.ref!==void 0&&(ae=V.ref),V.key!==void 0&&($e=""+V.key),V)K.call(V,me)&&!R.hasOwnProperty(me)&&(he[me]=V[me]);var ve=arguments.length-2;if(ve===1)he.children=de;else if(1<ve){for(var Re=Array(ve),ee=0;ee<ve;ee++)Re[ee]=arguments[ee+2];he.children=Re}if($&&$.defaultProps)for(me in ve=$.defaultProps,ve)he[me]===void 0&&(he[me]=ve[me]);return{$$typeof:e,type:$,key:$e,ref:ae,props:he,_owner:U.current}}function C($,V){return{$$typeof:e,type:$.type,key:V,ref:$.ref,props:$.props,_owner:$._owner}}function P($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function z($){var V={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(de){return V[de]})}var q=/\/+/g;function se($,V){return typeof $=="object"&&$!==null&&$.key!=null?z(""+$.key):V.toString(36)}function pe($,V,de,me,he){var $e=typeof $;($e==="undefined"||$e==="boolean")&&($=null);var ae=!1;if($===null)ae=!0;else switch($e){case"string":case"number":ae=!0;break;case"object":switch($.$$typeof){case e:case t:ae=!0}}if(ae)return ae=$,he=he(ae),$=me===""?"."+se(ae,0):me,M(he)?(de="",$!=null&&(de=$.replace(q,"$&/")+"/"),pe(he,V,de,"",function(ee){return ee})):he!=null&&(P(he)&&(he=C(he,de+(!he.key||ae&&ae.key===he.key?"":(""+he.key).replace(q,"$&/")+"/")+$)),V.push(he)),1;if(ae=0,me=me===""?".":me+":",M($))for(var ve=0;ve<$.length;ve++){$e=$[ve];var Re=me+se($e,ve);ae+=pe($e,V,de,Re,he)}else if(Re=k($),typeof Re=="function")for($=Re.call($),ve=0;!($e=$.next()).done;)$e=$e.value,Re=me+se($e,ve++),ae+=pe($e,V,de,Re,he);else if($e==="object")throw V=String($),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.");return ae}function ue($,V,de){if($==null)return $;var me=[],he=0;return pe($,me,"","",function($e){return V.call(de,$e,he++)}),me}function xe($){if($._status===-1){var V=$._result;V=V(),V.then(function(de){($._status===0||$._status===-1)&&($._status=1,$._result=de)},function(de){($._status===0||$._status===-1)&&($._status=2,$._result=de)}),$._status===-1&&($._status=0,$._result=V)}if($._status===1)return $._result.default;throw $._result}var oe={current:null},A={transition:null},X={ReactCurrentDispatcher:oe,ReactCurrentBatchConfig:A,ReactCurrentOwner:U};function Z(){throw Error("act(...) is not supported in production builds of React.")}return zt.Children={map:ue,forEach:function($,V,de){ue($,function(){V.apply(this,arguments)},de)},count:function($){var V=0;return ue($,function(){V++}),V},toArray:function($){return ue($,function(V){return V})||[]},only:function($){if(!P($))throw Error("React.Children.only expected to receive a single React element child.");return $}},zt.Component=_,zt.Fragment=n,zt.Profiler=o,zt.PureComponent=j,zt.StrictMode=r,zt.Suspense=c,zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=X,zt.act=Z,zt.cloneElement=function($,V,de){if($==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+$+".");var me=v({},$.props),he=$.key,$e=$.ref,ae=$._owner;if(V!=null){if(V.ref!==void 0&&($e=V.ref,ae=U.current),V.key!==void 0&&(he=""+V.key),$.type&&$.type.defaultProps)var ve=$.type.defaultProps;for(Re in V)K.call(V,Re)&&!R.hasOwnProperty(Re)&&(me[Re]=V[Re]===void 0&&ve!==void 0?ve[Re]:V[Re])}var Re=arguments.length-2;if(Re===1)me.children=de;else if(1<Re){ve=Array(Re);for(var ee=0;ee<Re;ee++)ve[ee]=arguments[ee+2];me.children=ve}return{$$typeof:e,type:$.type,key:he,ref:$e,props:me,_owner:ae}},zt.createContext=function($){return $={$$typeof:l,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},$.Provider={$$typeof:a,_context:$},$.Consumer=$},zt.createElement=I,zt.createFactory=function($){var V=I.bind(null,$);return V.type=$,V},zt.createRef=function(){return{current:null}},zt.forwardRef=function($){return{$$typeof:u,render:$}},zt.isValidElement=P,zt.lazy=function($){return{$$typeof:m,_payload:{_status:-1,_result:$},_init:xe}},zt.memo=function($,V){return{$$typeof:p,type:$,compare:V===void 0?null:V}},zt.startTransition=function($){var V=A.transition;A.transition={};try{$()}finally{A.transition=V}},zt.unstable_act=Z,zt.useCallback=function($,V){return oe.current.useCallback($,V)},zt.useContext=function($){return oe.current.useContext($)},zt.useDebugValue=function(){},zt.useDeferredValue=function($){return oe.current.useDeferredValue($)},zt.useEffect=function($,V){return oe.current.useEffect($,V)},zt.useId=function(){return oe.current.useId()},zt.useImperativeHandle=function($,V,de){return oe.current.useImperativeHandle($,V,de)},zt.useInsertionEffect=function($,V){return oe.current.useInsertionEffect($,V)},zt.useLayoutEffect=function($,V){return oe.current.useLayoutEffect($,V)},zt.useMemo=function($,V){return oe.current.useMemo($,V)},zt.useReducer=function($,V,de){return oe.current.useReducer($,V,de)},zt.useRef=function($){return oe.current.useRef($)},zt.useState=function($){return oe.current.useState($)},zt.useSyncExternalStore=function($,V,de){return oe.current.useSyncExternalStore($,V,de)},zt.useTransition=function(){return oe.current.useTransition()},zt.version="18.3.1",zt}var tw;function vm(){return tw||(tw=1,$p.exports=VN()),$p.exports}/**
11
+ * @license React
12
+ * react-jsx-runtime.production.min.js
13
+ *
14
+ * Copyright (c) Facebook, Inc. and its affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var nw;function YN(){if(nw)return wl;nw=1;var e=vm(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function l(u,c,p){var m,h={},k=null,y=null;p!==void 0&&(k=""+p),c.key!==void 0&&(k=""+c.key),c.ref!==void 0&&(y=c.ref);for(m in c)r.call(c,m)&&!a.hasOwnProperty(m)&&(h[m]=c[m]);if(u&&u.defaultProps)for(m in c=u.defaultProps,c)h[m]===void 0&&(h[m]=c[m]);return{$$typeof:t,type:u,key:k,ref:y,props:h,_owner:o.current}}return wl.Fragment=n,wl.jsx=l,wl.jsxs=l,wl}var rw;function QN(){return rw||(rw=1,Op.exports=YN()),Op.exports}var f=QN();const XN=new Set(["edit","delete","move","execute"]),JN=new Set(["Edit","Write","MultiEdit","NotebookEdit","Bash"]);function vb(e){return e.kind?XN.has(e.kind):JN.has(e.name)}const eT=["read","edit","delete","move","search","execute","fetch"];function bm(e){return eT.includes(e??"")}function Td(e){if(!e||typeof e!="object")return!0;const t=e;return Object.keys(t).every(n=>n==="locations"&&Array.isArray(t[n])&&t[n].length===0)}const cc=[{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"}],wh="auto";function tT(e){return e.branch.startsWith("toyon/")}const po="shell",ps="login";function nT(e,t){return`${e}/${t}`}function rT(e,t,n,r=0){var a;let o=e;for(let l=r;l>0;l--){let u=o.length-1;for(;u>=0&&((a=o[u])==null?void 0:a.proc)!==t;)u--;if(u<0)break;o=o===e?[...o]:o,o.splice(u,1)}return n?[...o,{proc:t,line:n}]:o}const oT=["use","always","off"];function bb(e){return e.find(t=>t.id==="default")}function sT(e){const t=bb(e);if(t!=null&&t.description)return e.find(n=>n!==t&&n.name===t.description)}function tr(e){return e.worktree!==void 0}function ji(e){return e.kind==="main"}function uc(e){return e.kind==="spare"}function Cr(e){return uc(e)||ji(e)}function xm(e){return e.kind==="worktree"}function xb(e){return e.kind==="worktree"&&tT(e)}function bi(e){var t;return e.kind==="worktree"&&((t=e.from)==null?void 0:t.kind)!=="pr"}function Wu(e){return e.kind==="worktree"}function jd(e){return!!e.branch&&!e.locked&&!(e.worktree&&Cr(e.worktree))}const Gl=e=>{var t;return e.promptedAt??((t=e.lastTurn)==null?void 0:t.at)??e.createdAt},iT=e=>Cr(e)?0:1,aT=e=>e.variant?`group:${e.variant.group}`:`row:${e.id}`;function lT(e){const t=[],n=new Map;for(const r of e){const o=r.worktree,a=aT(o),l=n.get(a);if(l){l.rows.push(r),l.at=Math.max(l.at,Gl(o));continue}const u={tier:iT(o),at:Gl(o),rows:[r]};t.push(u),n.set(a,u)}return t.sort((r,o)=>r.tier-o.tier||o.at-r.at),t.flatMap(r=>r.rows.length>1?r.rows.sort((o,a)=>{var l,u;return(((l=o.worktree.variant)==null?void 0:l.index)??0)-(((u=a.worktree.variant)==null?void 0:u.index)??0)}):r.rows)}const ow="not opened in ";function cT(e){const t=e.lastIndexOf(ow);return t<0?{what:e}:{what:e.slice(0,t).replace(/,\s*$/,""),idle:e.slice(t+ow.length)}}const _b={image:6,paste:4,file:8,pick:8},uT={image:"image",paste:"paste",file:"file",pick:"element"},dT={image:"Image",paste:"Pasted text"},Eb=(e,t)=>`${dT[e]} ${t}`,_m=e=>`at most ${_b[e]} ${uT[e]}s per message`,fT=(e,t)=>e.filter(n=>n.kind===t).length,pT=(e,t)=>Math.max(0,_b[t]-fT(e,t));function Sb(e){const t={image:1,paste:1,file:1,pick:1};for(const n of e)for(const r of n??[])t[r.kind]=Math.max(t[r.kind],r.n+1);return t}function Nb(e,t){const n={...t};return e.map(r=>[r,n[r.kind]++])}function Tb(e,t){const n={...e};for(const r of t)n[r.kind]++;return n}function Em(e){return e>=1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}const Ku=[{id:"quick-open",key:"p"},{id:"commands",key:"p",shift:!0,bareAlias:"F1"},{id:"search",key:"f",shift:!0},{id:"chats",key:"g"},{id:"changes",key:"b",ctrlAlias:{key:"g",shift:!0}},{id:"files",key:"e",shift:!0},{id:"panel-tab-prev",key:"ArrowLeft",alt:!0,textKeeps:!0},{id:"panel-tab-next",key:"ArrowRight",alt:!0,textKeeps:!0},{id:"composer",key:"l"},{id:"rail",key:"k",shift:!0},{id:"keys",key:","},{id:"terminal",key:"j",ctrlAlias:{key:"`"}},{id:"design",key:"d"},{id:"term-tab",key:"`",ctrl:!0,shift:!0},{id:"pick",key:"e"},{id:"inspect",key:"i"},{id:"zen",key:"."},{id:"new",key:"k",aliases:["n"]},{id:"worktree",key:"1-9"},{id:"wt-prev",key:"ArrowUp",alt:!0,ctrlAlias:{key:"Tab",shift:!0},cmdShiftAlias:["[","{"]},{id:"wt-next",key:"ArrowDown",alt:!0,ctrlAlias:{key:"Tab"},cmdShiftAlias:["]","}"]},{id:"wt-unseen-prev",key:"ArrowUp",alt:!0,shift:!0},{id:"wt-unseen-next",key:"ArrowDown",alt:!0,shift:!0},{id:"wt-archive",key:"Backspace",alt:!0,textKeeps:!0,emptyGives:!0},{id:"mark-unread",key:"u",alt:!0,textKeeps:!0},{id:"project",key:"o",ctrlAlias:{key:"r",hostOnly:!0},cmdShiftAlias:["o"]},{id:"refs",key:"g",shift:!0},{id:"routes",key:"u"},{id:"reload",key:"r"},{id:"back",key:"ArrowLeft",textKeeps:!0},{id:"forward",key:"ArrowRight",textKeeps:!0},{id:"close",key:"w"}],hT=new Set(["zen","close","back","forward"]);function jb(e,{guest:t=!1}={}){var r,o;if(e.altKey){if(e.metaKey||e.ctrlKey)return null;const a=Ku.find(l=>l.alt&&!!l.shift===e.shiftKey&&(l.key===e.key||l.key.length===1&&e.code===`Key${l.key.toUpperCase()}`));return a&&a.id!=="worktree"?{id:a.id}:null}if(!e.metaKey&&!e.ctrlKey){if(e.shiftKey||t)return null;const a=Ku.find(l=>l.bareAlias===e.key);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 Ku){if(a.id==="worktree")continue;const l=a.ctrlAlias;if(l&&e.ctrlKey&&l.key===n&&!!l.shift===e.shiftKey&&!(t&&l.hostOnly))return{id:a.id};if(e.metaKey&&e.shiftKey&&((r=a.cmdShiftAlias)!=null&&r.includes(n)))return{id:a.id};if(!a.alt&&!(e.ctrlKey&&!a.ctrl||!!a.shift!==e.shiftKey)&&(a.key===n||(o=a.aliases)!=null&&o.includes(n)))return{id:a.id}}return null}function mT(e){return e.altKey||e.key.toLowerCase()!=="s"?!1:!!e.ctrlKey!==e.metaKey}function Cb(e){const t=Ku.find(n=>n.id===e);if(!t)throw new Error(`unknown chord ${e}`);return t}function gT(e,t){return e===t-1?"⌘9":e<8?`⌘${e+1}`:void 0}function kT(e,t){return t===0?null:e===9?t-1:e-1<t?e-1:null}function yT(e){const t=e;return t!=null&&t.tagName?t.isContentEditable||t.tagName==="TEXTAREA"?!0:t.tagName==="INPUT"&&!["button","checkbox","radio","range","submit","reset"].includes(t.type??""):!1}function wT(e){var n;const t=e;return(t==null?void 0:t.tagName)!=="TEXTAREA"&&(t==null?void 0:t.tagName)!=="INPUT"?!1:t.value===""&&!((n=t.closest)!=null&&n.call(t,".monaco-editor, .xterm"))}function vT(e,t){const n=Cb(e);return!!n.textKeeps&&yT(t)&&!(n.emptyGives&&wT(t))}const bT=["Find","Preview","Panels","Worktrees"],Pl={"quick-open":{label:"jump to file",section:"Find"},commands:{label:"command palette",section:"Find",advertise:{key:"F1",when:"firefox"}},search:{label:"search in files",section:"Find"},chats:{label:"search in chats",section:"Find"},changes:{label:"changes panel",section:"Panels"},files:{label:"files panel",section:"Panels"},"panel-tab-prev":{label:"previous panel tab",section:"Panels",hidden:!0},"panel-tab-next":{label:"next panel tab",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"},reload:{label:"reload the preview",section:"Preview"},back:{label:"back in the preview",section:"Preview",hidden:!0},forward:{label:"forward in the preview",section:"Preview",hidden:!0},close:{label:"close the pane",section:"Panels",hidden:!0},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 worth a look",section:"Worktrees",hidden:!0},"wt-unseen-next":{label:"next worktree worth a look",section:"Worktrees"},"wt-archive":{label:"archive worktree",section:"Worktrees"},"mark-unread":{label:"mark worktree unread",section:"Worktrees"},project:{label:"open project",section:"Worktrees"},refs:{label:"open a branch or PR",section:"Worktrees"}},xT={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Backspace:"⌫",Tab:"Tab"};function _T(e,t={}){var u;const n=Cb(e),r=Pl[e],o=r.advertise&&t[r.advertise.when]?r.advertise.key:n.key;if(o===n.bareAlias)return o;const a=o==="1-9"?"1-9":xT[o]??o.toUpperCase(),l=o!==n.key&&o===((u=n.ctrlAlias)==null?void 0:u.key)?n.ctrlAlias:void 0;return l?`⌃${l.shift?"⇧":""}${a}`:`${n.alt?"⌥":n.ctrl?"⌃":"⌘"}${n.shift?"⇧":""}${a}`}function ET(e){return Object.keys(Pl).filter(t=>Pl[t].section===e&&!Pl[t].hidden)}const sw={m:6e4,h:60*6e4};function ST(e){const[t,n]=NT(e);return`${t}${n.charAt(0)}`}function NT(e){const t=e/sw.h;if(t>=1&&Number.isInteger(t))return[t,"hour"];const n=e/sw.m;return n>=1&&Number.isInteger(n)?[n,"minute"]:n>=60?[Math.round(n),"minute"]:[Math.max(1,Math.round(e/1e3)),"second"]}const Vl={folder:{shared:".toyon/settings.json",local:".toyon/settings.local.json"},root:{shared:"toyon.json",local:"toyon.local.json"}};function Ab(e){return typeof e=="string"?e:e.cmd}function TT(e){return typeof e!="string"&&e.from==="trunk"}function jT(e){return[...e.setup??[],...e.teardown??[],...Object.values(e.run).map(Ab),...Object.values(e.profiles??{}).flatMap(n=>Object.values(n.env??{}))].some(n=>n.includes("TOYON_WORKTREE"))}function CT(e){return e===Vl.folder.local||e===Vl.root.local}function AT(e){return CT(e)?"local":"shared"}function IT(e,t){return(Object.values(Vl).find(r=>r.shared===e||r.local===e)??Vl.folder)[t]}function RT(e,t,n){return e.replace("{id}",t).replace("{port}",String(n))}const OT=4401,$T=25e4;function MT(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=0;for(;r<e.length-n&&r<t.length-n&&e[e.length-1-r]===t[t.length-1-r];)r++;const o=e.slice(0,n).map(a=>({mark:" ",value:a}));return o.push(...LT(e.slice(n,e.length-r),t.slice(n,t.length-r))),o.push(...e.slice(e.length-r).map(a=>({mark:" ",value:a}))),o}function LT(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)>$T)return[...e.map(u=>({mark:"-",value:u})),...t.map(u=>({mark:"+",value:u}))];const n=t.length+1,r=new Uint32Array((e.length+1)*n);for(let u=e.length-1;u>=0;u--)for(let c=t.length-1;c>=0;c--)r[u*n+c]=e[u]===t[c]?(r[(u+1)*n+c+1]??0)+1:Math.max(r[(u+1)*n+c]??0,r[u*n+c+1]??0);const o=[];let a=0,l=0;for(;a<e.length&&l<t.length;)e[a]===t[l]?(o.push({mark:" ",value:e[a]}),a++,l++):(r[(a+1)*n+l]??0)>=(r[a*n+l+1]??0)?(o.push({mark:"-",value:e[a]}),a++):(o.push({mark:"+",value:t[l]}),l++);for(;a<e.length;)o.push({mark:"-",value:e[a++]});for(;l<t.length;)o.push({mark:"+",value:t[l++]});return o}const PT=/[\p{L}\p{N}_$]+|\s+|[^\s\p{L}\p{N}_$]/gu;function iw(e){return e.match(PT)??[]}const DT=.4;function zT(e,t){if(e===t)return null;const n=MT(iw(e),iw(t));let r=0;for(const o of n)o.mark===" "&&(r+=o.value.length);return r<DT*Math.max(e.length,t.length)?null:{before:aw(n,"-"),after:aw(n,"+")}}function aw(e,t){const n=[];for(const r of e){if(r.mark!==" "&&r.mark!==t)continue;const o=r.mark===t,a=n[n.length-1];a&&a.changed===o?a.text+=r.value:n.push({text:r.value,changed:o})}for(let r=1;r<n.length-1;r++){const o=n[r];o&&(o.changed?o.changed=o.text.trim()!=="":o.changed=o.text.length<=2)}return Ib(n)}function lw(e){const t=[[]];for(const n of e){const r=n.text.split(`
19
+ `);for(const[o,a]of r.entries())o>0&&t.push([]),a&&t[t.length-1].push({text:a,changed:n.changed})}return t.map(Ib)}function Ib(e){const t=[];for(const n of e){const r=t[t.length-1];r&&r.changed===n.changed?r.text+=n.text:t.push({...n})}return t}const FT=[{id:"merge",name:"here",description:"onto main in this checkout; nothing is pushed"},{id:"push",name:"push",description:"onto main on origin, straight from the worktree; main here follows"},{id:"pr",name:"pull request",description:"the branch is pushed and a pull request opened on GitHub"}],BT=[{id:"merge",name:"merge commit",description:"the commits stay as they are, under one merge commit"},{id:"squash",name:"squash",description:"the work becomes one commit on main"},{id:"rebase",name:"rebase",description:"the commits go on main as they are, no merge commit"}],UT=[{id:"you",name:"you merge it",description:"the chat offers merge once GitHub would take the PR"},{id:"github",name:"GitHub merges it",description:"auto-merge: GitHub merges the PR itself once its rules allow (checks, reviewers, or nothing)"}],vh="merge",bh="merge";function _i(e){var n,r,o;const t=((n=e.land)==null?void 0:n.route)??vh;return{land:t,automerge:t==="pr"&&((r=e.land)==null?void 0:r.automerge)===!0,...(o=e.land)!=null&&o.method?{merge:e.land.method}:{}}}function Cd(e){return e.base??e.defaultBranch}function HT(e){return e.base!==void 0&&e.base!==e.defaultBranch}function Ju(e,t="main"){const n={merge:"merge into",squash:"squash onto",rebase:"rebase onto"}[e.merge??bh];switch(e.land){case"merge":return`Commit and ${n} ${t} here`;case"push":return`Commit, ${n} ${t} on origin and push it`;case"pr":return e.automerge?"Commit, push the branch and open a PR that GitHub merges when its rules allow":"Commit, push the branch and open a PR"}}const WT="https://toyon.cloud",KT=e=>`${WT}/#add=${encodeURIComponent(e)}`;function Rb(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function cw(e,t="|"){return e.map(n=>Mb(n)).join(t)}function xh(e,t){return typeof t=="bigint"?t.toString():t}function Ad(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ZT(e){return e==null}function Sm(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function qT(e,t){const n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}function qr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Zs(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function GT(e){return JSON.stringify(e)}function VT(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ob="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const YT=Ad(()=>{var e;if(Lo.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 Ql(e){if(Yl(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Yl(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function $b(e){return Ql(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const QT=new Set(["string","number","symbol"]);function Sa(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qs(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function st(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 Mb(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function XT(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const JT={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 ej(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const a=Zs(e._zod.def,{get shape(){const l={};for(const u of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,u))throw new Error(`Unrecognized key: "${String(u)}"`);t[u]&&qr(l,u,n.shape[u])}return qr(this,"shape",l),l},checks:[]});return qs(e,a)}function tj(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const a=Zs(e._zod.def,{get shape(){const l={...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 l[u]}return qr(this,"shape",l),l},checks:[]});return qs(e,a)}function nj(e,t){if(!Ql(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 l of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(a,l)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=Zs(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return qr(this,"shape",a),a}});return qs(e,o)}function rj(e,t){if(!Ql(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Zs(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return qr(this,"shape",r),r}});return qs(e,n)}function oj(e,t){var r,o;if(!((r=t==null?void 0:t._zod)!=null&&r.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((o=e._zod.def.checks)!=null&&o.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Zs(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return qr(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return qs(e,n)}function uw(e,t,n,r="partial"){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const u=Zs(t._zod.def,{get shape(){const c=t._zod.def.shape,p={...c};if(n)for(const m of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(c,m))throw new Error(`Unrecognized key: "${String(m)}"`);n[m]&&(p[m]=e?new e({type:"optional",innerType:c[m]}):c[m])}else for(const m of Reflect.ownKeys(c))p[m]=e?new e({type:"optional",innerType:c[m]}):c[m];return qr(this,"shape",p),p},checks:[]});return qs(t,u)}function sj(e,t,n){const r=Zs(t._zod.def,{get shape(){const o=t._zod.def.shape,a={...o};if(n)for(const l of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(a,l))throw new Error(`Unrecognized key: "${String(l)}"`);n[l]&&(a[l]=new e({type:"nonoptional",innerType:o[l]}))}else for(const l of Reflect.ownKeys(o))a[l]=new e({type:"nonoptional",innerType:o[l]});return qr(this,"shape",a),a}});return qs(t,r)}function ma(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function ij(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function Id(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function vl(e){return typeof e=="string"?e:e==null?void 0:e.message}function dw(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Oa(e,t,n){var k,y,v,x,_,N,j,E,M,K;var r;const o=(y=(k=e.inst)==null?void 0:k._zod)==null?void 0:y.traits;o!=null&&o.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const a=e.schema!==e.inst?(x=(v=e.schema)==null?void 0:v._zod.def)==null?void 0:x.error:void 0,l=e.message?e.message:vl((j=(N=(_=e.inst)==null?void 0:_._zod.def)==null?void 0:N.error)==null?void 0:j.call(N,e))??vl(a==null?void 0:a(e))??vl((E=t==null?void 0:t.error)==null?void 0:E.call(t,e))??vl((M=n.customError)==null?void 0:M.call(n,e))??vl((K=n.localeError)==null?void 0:K.call(n,e))??"Invalid input",{inst:u,schema:c,continue:p,input:m,...h}=e;return h.path??(h.path=[]),h.message=l,t!=null&&t.reportInput&&(h.input=m),h}const aj=/[\uD800-\uDBFF]/;function Nm(e){const t=e.length;if(!aj.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function Tm(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function lj(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 Xl(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function cj(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):uj(e,n,r.value)}}function Na(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Lb(e,t,n){return Na(e,t,n,!1)}function uj(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Na(this,t,n.bind(this))},set(r){Na(this,t,r)}})}function dj(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Mp,Ds=!1;const fj={configurable:!0,get(){Ds=!0}};function dn(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Mp!==e._zod){Mp=void 0;return}Mp=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,fj);const o=Ds;Ds=!1;try{const a=n(this);return Ds?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:a}),Ds=Ds||o,a}catch(a){throw delete this[t],Ds=Ds||o,a}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function pj(e,t,n,r){const o=dj(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const a={configurable:!0,writable:!0,enumerable:r,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:r,value:a})}})}const hj="~constantCatch";function mj(e){const t=()=>e;return t[hj]=!0,t}var fw;const Lp={value:void 0,enumerable:!1};let pw="captureStackTrace"in Error?Error:null;function gj(e){const t=pw;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return pw=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function ye(e,t,n,r){const o={};function a(k){this.def=k,this.constr=h,this.traits=new Set}a.prototype=o;const l=n,u=l&&new WeakSet;function c(k,y){if(!k._zod){Lp.value=new a(y);try{Object.defineProperty(k,"_zod",Lp)}finally{Lp.value=void 0}}if(k._zod.traits.has(e))return;if(k._zod.traits.add(e),t(k,y),u){const x=Object.getPrototypeOf(k),_=k._zod.constr.prototype;let N=x;for(;N&&N!==_;)N=Object.getPrototypeOf(N);const j=N??x;u.has(j)||(u.add(j),cj(j,l))}const v=h.prototype;for(const x in v)Object.prototype.hasOwnProperty.call(v,x)&&(x in k||(k[x]=v[x].bind(k)))}const p=(r==null?void 0:r.Parent)??Object;class m extends p{}Object.defineProperty(m,"name",{value:e});function h(k){var _;const y=r!=null&&r.Parent?gj(m):this;c(y,k);const v=y._zod.deferred;if(v){for(const N of v)N();y._zod.deferred=void 0}const x=(_=globalThis.__zod_globalConfig)==null?void 0:_.postProcessor;return x&&x(y),y}return Object.defineProperty(h,"init",{value:c}),Object.defineProperty(h,Symbol.hasInstance,{value:k=>{var y,v;return r!=null&&r.Parent&&k instanceof r.Parent?!0:(v=(y=k==null?void 0:k._zod)==null?void 0:y.traits)==null?void 0:v.has(e)}}),Object.defineProperty(h,"name",{value:e}),h}class wa extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Pb extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(fw=globalThis).__zod_globalConfig??(fw.__zod_globalConfig={});const Lo=globalThis.__zod_globalConfig;function Gs(e){return e&&Object.assign(Lo,e),Lo}function kj(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,xh,2)),e.message}function yj(e){this._zod.message=e}const wj={get:kj,set:yj,enumerable:!0,configurable:!0},Pp={value:void 0,enumerable:!1},Dp={value:void 0,enumerable:!1},hw=new WeakSet([Object.prototype,Error.prototype]),Db=(e,t)=>{e.name="$ZodError",Pp.value=e._zod,Object.defineProperty(e,"_zod",Pp),Dp.value=t,Object.defineProperty(e,"issues",Dp),Pp.value=void 0,Dp.value=void 0,Object.defineProperty(e,"message",wj);const n=Object.getPrototypeOf(e);hw.has(n)||(hw.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},zb=ye("$ZodError",Db),Fb=ye("$ZodError",Db,void 0,{Parent:Error});function vj(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 bj(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?vj(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function xj(e,t=n=>n.message){const n={_errors:[]},r=(o,a=[])=>{for(const l of o.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>r({issues:u},[...a,...l.path]));else if(l.code==="invalid_key")r({issues:l.issues},[...a,...l.path]);else if(l.code==="invalid_element")r({issues:l.issues},[...a,...l.path]);else{const u=[...a,...l.path];if(u.length===0)n._errors.push(t(l));else{let c=n,p=0;for(;p<u.length;){const m=u[p],h=p===u.length-1;if(m==="_errors"){h&&c._errors.push(t(l)),p++;continue}Object.prototype.hasOwnProperty.call(c,m)||Object.defineProperty(c,m,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const k=c[m];h&&k._errors.push(t(l)),c=k,p++}}}};return r(e),n}function Rd(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const jm=e=>{const t=(n,r,o,a)=>{const l=o?{...o,async:!1}:{async:!1},u=n._zod.run({value:r,issues:[]},l);if(u instanceof Promise)throw new wa;if(u.issues.length){const c=new((a==null?void 0:a.Err)??e)(u.issues.map(p=>Oa(p,l,Gs())));throw Ob(c,(a==null?void 0:a.callee)??t),c}return u.value};return t},Cm=e=>{const t=async(n,r,o,a)=>{const l=o?{...o,async:!0}:{async:!0};let u=n._zod.run({value:r,issues:[]},l);if(u instanceof Promise&&(u=await u),u.issues.length){const c=new((a==null?void 0:a.Err)??e)(u.issues.map(p=>Oa(p,l,Gs())));throw Ob(c,(a==null?void 0:a.callee)??t),c}return u.value};return t},Od=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new wa;return a.issues.length?{success:!1,error:new(e??zb)(a.issues.map(l=>Oa(l,o,Gs())))}:{success:!0,data:a.value}},_j=Od(Fb),$d=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},o);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(l=>Oa(l,o,Gs())))}:{success:!0,data:a.value}},Ej=$d(Fb),Sj=e=>{const t=jm(e),n=(r,o,a,l)=>{const u=a?{...a,direction:"backward"}:{direction:"backward"};return t(r,o,u,Rd(n,l))};return n},Nj=e=>{const t=jm(e),n=(r,o,a,l)=>t(r,o,a,Rd(n,l));return n},Tj=e=>{const t=Cm(e),n=async(r,o,a,l)=>{const u=a?{...a,direction:"backward"}:{direction:"backward"};return await t(r,o,u,Rd(n,l))};return n},jj=e=>{const t=Cm(e),n=async(r,o,a,l)=>await t(r,o,a,Rd(n,l));return n},Cj=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Od(e)(t,n,o)},Aj=e=>(t,n,r)=>Od(e)(t,n,r),Ij=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return $d(e)(t,n,o)},Rj=e=>async(t,n,r)=>$d(e)(t,n,r),Oj=/^[cC][0-9a-z]{6,}$/,$j=/^[0-9a-z]+$/,Mj=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Lj=/^[0-9a-vA-V]{20}$/,Pj=/^[A-Za-z0-9]{27}$/,Dj=/^[a-zA-Z0-9_-]{21}$/;function zj(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Fj=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Bj=/^([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})$/,mw=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)$/,Uj=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Hj="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Wj(){return new RegExp(Hj,"u")}const Kj=/^(?:(?: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])$/,Zj=/^(([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}|:))$/,qj=/^((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])$/,Gj=/^(([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])$/,Vj=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Bb=/^[A-Za-z0-9_-]*$/,Yj=/^https?$/,Qj=/^\+[1-9]\d{6,14}$/,Ub="(?:(?:\\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 Xj(e){return new RegExp(`^${e}$`)}const Jj=Xj(Ub);function _h(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 eC(e){return new RegExp(`^${_h(e)}$`)}function tC(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${_h({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${_h({precision:e.precision})}`:n;return new RegExp(`^${Ub}T(?:${r})$`)}const nC=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}$`)},rC=/^-?\d+$/,oC=/^-?\d+(?:\.\d+)?$/,sC=/^(?:true|false)$/i,iC=/^[^A-Z]*$/,aC=/^[^a-z]*$/,Gr=ye("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Am=e=>{const t=e.value;return!ZT(t)&&t.length!==void 0},ed={number:"number",bigint:"bigint",object:"date"},Hb=ye("$ZodCheckLessThan",(e,t)=>{Gr.init(e,t);const n=ed[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,a=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:ed[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Wb=ye("$ZodCheckGreaterThan",(e,t)=>{Gr.init(e,t);const n=ed[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,a=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:ed[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lC=ye("$ZodCheckMultipleOf",(e,t)=>{Gr.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):qT(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})}}),cC=ye("$ZodCheckNumberFormat",(e,t)=>{var l;Gr.init(e,t),t.format=t.format||"float64";const n=(l=t.format)==null?void 0:l.includes("int"),r=n?"int":"number",[o,a]=JT[t.format];e._zod.onattach.push(u=>{const c=u._zod.bag;c.format=t.format,c.minimum=o,c.maximum=a,n&&(c.pattern=rC)}),e._zod.check=u=>{const c=u.value;if(n){if(!Number.isInteger(c)){u.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?u.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):u.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}c<o&&u.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>a&&u.issues.push({origin:"number",input:c,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),uC=ye("$ZodCheckMaxLength",(e,t)=>{var n;Gr.init(e,t),(n=e._zod.def).when??(n.when=Am),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value,a=o.length;if((typeof o=="string"&&a>t.maximum?Nm(o):a)<=t.maximum)return;const u=Tm(o);r.issues.push({origin:u,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),dC=ye("$ZodCheckMinLength",(e,t)=>{var n;Gr.init(e,t),(n=e._zod.def).when??(n.when=Am),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value,a=o.length;if((typeof o=="string"&&a>=t.minimum&&a<t.minimum*2?Nm(o):a)>=t.minimum)return;const u=Tm(o);r.issues.push({origin:u,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),fC=ye("$ZodCheckLengthEquals",(e,t)=>{var n;Gr.init(e,t),(n=e._zod.def).when??(n.when=Am),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,a=o.length,l=typeof o=="string"&&a>=t.length&&a<=t.length*2?Nm(o):a;if(l===t.length)return;const u=Tm(o),c=l>t.length;r.issues.push({origin:u,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Md=ye("$ZodCheckStringFormat",(e,t)=>{var n,r;Gr.init(e,t),e._zod.onattach.push(o=>{const a=o._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=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),pC=ye("$ZodCheckRegex",(e,t)=>{Md.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})}}),hC=ye("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=iC),Md.init(e,t)}),mC=ye("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=aC),Md.init(e,t)}),gC=ye("$ZodCheckIncludes",(e,t)=>{Gr.init(e,t);const n=Sa(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const a=o._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),kC=ye("$ZodCheckStartsWith",(e,t)=>{Gr.init(e,t);const n=new RegExp(`^${Sa(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),yC=ye("$ZodCheckEndsWith",(e,t)=>{Gr.init(e,t);const n=new RegExp(`.*${Sa(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),wC=ye("$ZodCheckOverwrite",(e,t)=>{Gr.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class vC{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
20
+ `).filter(l=>l),o=Math.min(...r.map(l=>l.length-l.trimStart().length)),a=r.map(l=>l.slice(o)).map(l=>" ".repeat(this.indent*2)+l);for(const l of a)this.content.push(l)}compile(){const t=Function,n=(this==null?void 0:this.content)??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
21
+ ${n.join(`
22
+ `)}
23
+ };`)(...Object.values(this.closed))}}const bC={major:4,minor:5,patch:4},Cn=ye("$ZodType",(e,t)=>{var a;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=bC;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const l of o)for(const u of l._zod.onattach)u(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(a=e._zod.deferred)==null||a.push(()=>{e._zod.run=e._zod.parse});else{const l=(c,p,m)=>{if(c.memo)return c;let h=ma(c),k;for(const y of p){if(y._zod.def.when){if(ij(c)||!y._zod.def.when(c))continue}else if(h)continue;const v=c.issues.length,x=y._zod.check(c);if(x instanceof Promise&&(m==null?void 0:m.async)===!1)throw new wa;if(k||x instanceof Promise)k=(k??Promise.resolve()).then(async()=>{await x,c.issues.length!==v&&(dw(c.issues,v,e),h||(h=ma(c,v)))});else{if(c.issues.length===v)continue;dw(c.issues,v,e),h||(h=ma(c,v))}}return k?k.then(()=>c):c},u=(c,p,m)=>{if(ma(c))return c.aborted=!0,c;const h=l(p,o,m);if(h instanceof Promise){if(m.async===!1)throw new wa;return h.then(k=>e._zod.parse(k,m))}return e._zod.parse(h,m)};e._zod.run=(c,p)=>{if(p.skipChecks)return e._zod.parse(c,p);if(p.direction==="backward"){const h=e._zod.parse({value:c.value,issues:[]},{...p,skipChecks:!0});return h instanceof Promise?h.then(k=>u(k,c,p)):u(h,c,p)}const m=e._zod.parse(c,p);if(m instanceof Promise){if(p.async===!1)throw new wa;return m.then(h=>l(h,o,p))}return l(m,o,p)}}},{get"~standard"(){return Lb(this,"~standard",Kb(this))},set"~standard"(e){Na(this,"~standard",e)}}),gw=e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}};function Kb(e){return{validate:t=>{try{return gw(_j(e,t))}catch{return Ej(e,t).then(gw)}},vendor:"zod",version:1}}const Im=ye("$ZodString",(e,t)=>{var n;Cn.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??nC(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),An=ye("$ZodStringFormat",(e,t)=>{Md.init(e,t),Im.init(e,t)}),xC=ye("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Bj),An.init(e,t)}),_C=ye("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=mw(r))}else t.pattern??(t.pattern=mw());An.init(e,t)}),EC=ye("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Uj),An.init(e,t)}),Zb=1,qb=2;function SC(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===Yj.source&&!/^https?:\/\//i.test(e))return Zb;try{return new URL(e)}catch{return qb}}const NC=/[\t\n\r]/g;function TC(e){return e.replace(NC,"")}function jC(e,t){return t.lastIndex=0,t.test(e.hostname)}function CC(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const AC=ye("$ZodURL",(e,t)=>{An.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=SC(r,t);if(o===Zb){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===qb){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!jC(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!CC(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:TC(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),IC=ye("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Wj()),An.init(e,t)}),RC=ye("$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?Dj:zj(t.length)),An.init(e,t)}),OC=ye("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Oj),An.init(e,t)}),$C=ye("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=$j),An.init(e,t)}),MC=ye("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Mj),An.init(e,t)}),LC=ye("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Lj),An.init(e,t)}),PC=ye("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Pj),An.init(e,t)}),DC=ye("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=tC(t)),An.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(n=>{n._zod.bag.laxFormat=!0}))}),zC=ye("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Jj),An.init(e,t)}),FC=ye("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=eC(t)),An.init(e,t)}),BC=ye("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Fj),An.init(e,t)}),UC=ye("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Kj),An.init(e,t),e._zod.bag.format="ipv4"}),HC=/^[0-9a-fA-F:.]+$/;function Gb(e){if(!HC.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}const WC=ye("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Zj),An.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{Gb(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),KC=ye("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=qj),An.init(e,t)});function ZC(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`!==r||o<0||o>128?!1:Gb(n)}const qC=ye("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Gj),An.init(e,t),e._zod.check=n=>{ZC(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Vb(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const GC=ye("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Vj),An.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Vb(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function VC(e){if(!Bb.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Vb(n)}const YC=ye("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Bb),An.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{VC(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),QC=ye("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Qj),An.init(e,t)});function XC(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const JC=ye("$ZodJWT",(e,t)=>{An.init(e,t),e._zod.check=n=>{XC(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Yb=ye("$ZodNumber",(e,t)=>{Cn.init(e,t),e._zod.pattern=e._zod.bag.pattern??oC,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const a=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...a?{received:a}:{}}),n}}),eA=ye("$ZodNumberFormat",(e,t)=>{cC.init(e,t),Yb.init(e,t)}),tA=ye("$ZodBoolean",(e,t)=>{Cn.init(e,t),e._zod.pattern=sC,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),nA=ye("$ZodUnknown",(e,t)=>{Cn.init(e,t),e._zod.parse=n=>n}),rA=ye("$ZodNever",(e,t)=>{Cn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function kw(e,t,n){e.issues.length&&t.issues.push(...Id(n,e.issues)),t.value[n]=e.value}const oA=ye("$ZodArray",(e,t)=>{Cn.init(e,t);const n=Lo.memoizer;n==null||n.attach(e),e._zod.parse=(r,o)=>{const a=r.value;if(!Array.isArray(a))return r.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),o):Array(a.length);const l=[];for(let u=0;u<a.length;u++){const c=a[u],p=t.element._zod.run({value:c,issues:[]},o);p instanceof Promise?l.push(p.then(m=>kw(m,r,u))):kw(p,r,u)}return l.length?Promise.all(l).then(()=>r):r}});function td(e,t,n,r,o,a){const l=n in r,u=a==="optional";if(!(!l&&u&&o==="optional")){if(e.issues.length){if(o!==void 0&&u&&!l)return;t.issues.push(...Id(n,e.issues))}if(!l&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?l&&(t.value[n]=void 0):t.value[n]=e.value}}const sA=[];function Qb(e){var l,u,c,p;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:sA,o=r.length?[...t,...r]:t;for(const m of o)if(!((p=(c=(u=(l=e.shape)==null?void 0:l[m])==null?void 0:u._zod)==null?void 0:c.traits)!=null&&p.has("$ZodType")))throw new Error(`Invalid element at key "${String(m)}": expected a Zod schema`);const a=XT(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Xb(e,t,n,r,o,a){const l=[],u=o.keySet,c=o.catchall._zod,p=c.def.type,m=c.optin,h=c.optout;for(const k in t){if(u.has(k))continue;if(k==="__proto__"){p==="never"&&l.push(k);continue}if(p==="never"){l.push(k);continue}const y=c.run({value:t[k],issues:[]},r);y instanceof Promise?e.push(y.then(v=>td(v,n,k,t,m,h))):td(y,n,k,t,m,h)}return l.length&&n.issues.push({code:"unrecognized_keys",keys:l,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Eh=new WeakMap,iA=ye("$ZodObject",(e,t)=>{Cn.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const c=t.shape;Eh.set(t,c),Object.defineProperty(t,"shape",{get:()=>{const p={...c};return Object.defineProperty(t,"shape",{value:p}),Eh.set(t,p),p}})}const r=Ad(()=>Qb(t));dn(e,"propValues",c=>{const p=c.def.shape,m={};for(const h in p){const k=p[h]._zod;if(k.values){Object.prototype.hasOwnProperty.call(m,h)||qr(m,h,new Set);for(const y of k.values)m[h].add(y);k.optin!==void 0&&m[h].add(void 0)}}return m});const o=Yl,a=t.catchall;let l;const u=Lo.memoizer;u==null||u.attach(e),e._zod.parse=(c,p)=>{l??(l=r.value);const m=c.value;if(!o(m))return c.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),c;c.value=u?u.alloc(e,c,{},p):{};const h=[],k=l.shape;for(const y of l.allKeys){if(y==="__proto__")continue;const v=k[y],x=v._zod.optin,_=v._zod.optout,N=v._zod.run({value:m[y],issues:[]},p);N instanceof Promise?h.push(N.then(j=>td(j,c,y,m,x,_))):td(N,c,y,m,x,_)}return a?Xb(h,m,c,p,r.value,e):h.length?Promise.all(h).then(()=>c):c}}),aA=ye("$ZodObjectJIT",(e,t)=>{iA.init(e,t);const n=e._zod.parse,r=Ad(()=>Qb(t)),o=Lo.memoizer,a=y=>{var K,U;const v=r.value,x=v.symbolKeys,_=new vC(["payload","ctx"],{shape:y,inst:e,memo:o,syms:x}),N=R=>`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`,j=(R,I)=>`
24
+ for (let i = 0; i < ${R}.issues.length; i++) {
25
+ const iss = ${R}.issues[i];
26
+ iss.path = iss.path ? [${I}, ...iss.path] : [${I}];
27
+ payload.issues.push(iss);
28
+ }`;_.write("const input = payload.value;");const E=Object.create(null);let M=0;for(const R of v.allKeys)E[R]=`key_${M++}`;_.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const R of v.allKeys){if(R==="__proto__")continue;const I=E[R],C=typeof R=="symbol"?`syms[${x.indexOf(R)}]`:GT(R),P=`${C} in input`,z=y[R],q=(K=z==null?void 0:z._zod)==null?void 0:K.optin,se=q!==void 0,pe=((U=z==null?void 0:z._zod)==null?void 0:U.optout)==="optional";if(_.write(`const ${I} = ${N(C)};`),se&&pe){const ue=q==="optional"?`${I}_present`:`${I}.value !== undefined || ${I}_present`;_.write(`
29
+ const ${I}_present = ${P};
30
+ if (!${I}.issues.length || ${I}_present) {
31
+ if (${I}.issues.length) {${j(I,C)}
32
+ }
33
+
34
+ if (${ue}) {
35
+ newResult[${C}] = ${I}.value;
36
+ }
37
+ }
38
+
39
+ `)}else se?_.write(`
40
+ if (${I}.issues.length) {${j(I,C)}
41
+ }
42
+
43
+ if (${I}.value === undefined) {
44
+ if (${P}) {
45
+ newResult[${C}] = undefined;
46
+ }
47
+ } else {
48
+ newResult[${C}] = ${I}.value;
49
+ }
50
+
51
+ `):_.write(`
52
+ const ${I}_present = ${P};
53
+ if (${I}.issues.length) {${j(I,C)}
54
+ }
55
+ if (!${I}_present && !${I}.issues.length) {
56
+ payload.issues.push({
57
+ code: "invalid_type",
58
+ expected: "nonoptional",
59
+ input: undefined,
60
+ path: [${C}]
61
+ });
62
+ }
63
+
64
+ if (${I}_present) {
65
+ newResult[${C}] = ${I}.value;
66
+ }
67
+
68
+ `)}return _.write("payload.value = newResult;"),_.write("return payload;"),_.compile()};let l;const u=Yl,c=!Lo.jitless,m=c&&YT.value,h=t.catchall;let k;e._zod.parse=(y,v)=>{k??(k=r.value);const x=y.value;return u(x)?c&&m&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(l||(l=a(t.shape)),y=l(y,v),h?Xb([],x,y,v,k,e):y):n(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),y)}});function yw(e,t,n,r){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const o=e.filter(a=>!ma(a));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(a=>a.issues.map(l=>Oa(l,r,Gs())))}),t)}const Jb=ye("$ZodUnion",(e,t)=>{Cn.init(e,t),dn(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),dn(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),dn(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),dn(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(a=>a._zod.pattern);return new RegExp(`^(${o.map(a=>Sm(a.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let a=!1;const l=[];for(const u of t.options){const c=u._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)l.push(c),a=!0;else{if(c.issues.length===0)return c;l.push(c)}}return a?Promise.all(l).then(u=>yw(u,r,e,o)):yw(l,r,e,o)}}),lA=ye("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Jb.init(e,t);const n=e._zod.parse;dn(e,"propValues",o=>{const a={};for(const l of o.def.options){const u=l._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(l)}"`);for(const[c,p]of Object.entries(u)){Object.prototype.hasOwnProperty.call(a,c)||qr(a,c,new Set);for(const m of p)a[c].add(m)}}return a}),t.options.forEach((o,a)=>{const l=Eh.get(o._zod.def);if(l&&!Object.prototype.hasOwnProperty.call(l,t.discriminator))throw new Error(`Invalid discriminated union option at index "${a}"`)});const r=Ad(()=>{var l;const o=t.options,a=new Map;for(const u of o){const c=(l=u._zod.propValues)==null?void 0:l[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const p of c){if(a.has(p))throw new Error(`Duplicate discriminator value "${String(p)}"`);a.set(p,u)}}return a});e._zod.parse=(o,a)=>{const l=o.value;if(!Yl(l))return o.issues.push({code:"invalid_type",expected:"object",input:l,inst:e}),o;const u=r.value.get(l==null?void 0:l[t.discriminator]);return u?u._zod.run(o,a):t.unionFallback||a.direction==="backward"?n(o,a):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:l,path:[t.discriminator],inst:e}),o)}}),cA=ye("$ZodIntersection",(e,t)=>{Cn.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,a=t.left._zod.run({value:o,issues:[]},r),l=t.right._zod.run({value:o,issues:[]},r);return a instanceof Promise||l instanceof Promise?Promise.all([a,l]).then(([c,p])=>ww(n,c,p)):ww(n,a,l)}});function Sh(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(Ql(e)&&Ql(t)){const n=Object.keys(t),r=Object.keys(e).filter(a=>n.indexOf(a)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const a of r){if(a==="__proto__")continue;const l=Sh(e[a],t[a]);if(!l.valid)return{valid:!1,mergeErrorPath:[a,...l.mergeErrorPath]};o[a]=l.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],a=t[r],l=Sh(o,a);if(!l.valid)return{valid:!1,mergeErrorPath:[r,...l.mergeErrorPath]};n.push(l.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ww(e,t,n){const r=new Map;let o;const a=new Map,l=(p,m)=>{var k,y;let h;if(p.code==="unrecognized_keys"&&!((k=p.path)!=null&&k.length))o??(o=p),h=p.keys;else if(p.code==="invalid_key"&&p.origin==="record"&&((y=p.path)==null?void 0:y.length)===1){const v=String(p.path[0]);a.has(v)||a.set(v,p),h=[v]}else return!1;for(const v of h)r.has(v)||r.set(v,{}),r.get(v)[m]=!0;return!0};for(const p of t.issues)l(p,"l")||e.issues.push(p);for(const p of n.issues)l(p,"r")||e.issues.push(p);const u=[...r].filter(([,p])=>p.l&&p.r).map(([p])=>p);if(u.length){const p=o?u.filter(m=>o.keys.includes(m)):[];p.length&&e.issues.push({...o,keys:p});for(const m of u)!p.includes(m)&&a.has(m)&&e.issues.push(a.get(m))}const c=Sh(t.value,n.value);if(!c.valid){if(ma(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const uA=ye("$ZodTuple",(e,t)=>{Cn.init(e,t);const n=t.items,r=Lo.memoizer;r==null||r.attach(e),e._zod.parse=(o,a)=>{const l=o.value;if(!Array.isArray(l))return o.issues.push({input:l,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],a):[];const u=[],c=vw(n,"optin"),p=vw(n,"optout");if(!t.rest){if(l.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:l,inst:e,origin:"array"}),o;l.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:l,inst:e,origin:"array"})}const m=new Array(n.length);for(let h=0;h<n.length;h++){const k=n[h]._zod.run({value:l[h],issues:[]},a);k instanceof Promise?u.push(k.then(y=>{m[h]=y})):m[h]=k}if(t.rest){let h=n.length-1;const k=l.slice(n.length);for(const y of k){h++;const v=t.rest._zod.run({value:y,issues:[]},a);v instanceof Promise?u.push(v.then(x=>bw(x,o,h))):bw(v,o,h)}}return u.length?Promise.all(u).then(()=>xw(m,o,n,l,p)):xw(m,o,n,l,p)}});function vw(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 bw(e,t,n){e.issues.length&&t.issues.push(...Id(n,e.issues)),t.value[n]=e.value}function xw(e,t,n,r,o){for(let a=0;a<n.length;a++){const l=e[a],u=a<r.length;if(!u&&a>=o&&n[a]._zod.optin==="optional"){t.value.length=a;break}if(l.issues.length){if(!u&&a>=o){t.value.length=a;break}t.issues.push(...Id(a,l.issues))}t.value[a]=l.value}for(let a=t.value.length-1;a>=r.length&&(n[a]._zod.optout==="optional"&&t.value[a]===void 0);a--)t.value.length=a;return t}const dA=ye("$ZodEnum",(e,t)=>{Cn.init(e,t);const n=Rb(t.entries),r=new Set(n);e._zod.values=r;const o=n.filter(a=>QT.has(typeof a));e._zod.pattern=new RegExp(o.length?`^(${o.map(a=>Sa(a.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(a,l)=>{const u=a.value;return r.has(u)||a.issues.push({code:"invalid_value",values:n,input:u,inst:e}),a}}),fA=ye("$ZodLiteral",(e,t)=>{Cn.init(e,t);const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(t.values.length?`^(${t.values.map(r=>typeof r=="string"?Sa(r):r?Sa(r.toString()):String(r)).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(r,o)=>{const a=r.value;return n.has(a)||r.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),r}}),pA=ye("$ZodTransform",(e,t)=>{var n;Cn.init(e,t),e._zod.optin="optional",(n=Lo.memoizer)==null||n.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Pb(e.constructor.name);const a=t.transform(r.value,r);if(o.async)return(a instanceof Promise?a:Promise.resolve(a)).then(u=>(r.value=u,r));if(a instanceof Promise)throw new wa;return r.value=a,r}});function _w(e,t){return e.value=t.issues.length?void 0:t.value,e}const ex=ye("$ZodOptional",(e,t)=>{Cn.init(e,t),dn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",dn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),dn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Sm(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(a=>_w(n,a)):_w(n,o)}return t.innerType._zod.run(n,r)}}),hA=ye("$ZodExactOptional",(e,t)=>{ex.init(e,t),dn(e,"values",n=>n.def.innerType._zod.values),dn(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),mA=ye("$ZodNullable",(e,t)=>{Cn.init(e,t),dn(e,"optin",n=>n.def.innerType._zod.optin),dn(e,"optout",n=>n.def.innerType._zod.optout),dn(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Sm(r.source)}|null)$`):void 0}),dn(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),gA=ye("$ZodDefault",(e,t)=>{Cn.init(e,t),e._zod.optin="defaulted",dn(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>Ew(a,t)):Ew(o,t)}});function Ew(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const kA=ye("$ZodPrefault",(e,t)=>{Cn.init(e,t),e._zod.optin="defaulted",dn(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),yA=ye("$ZodNonOptional",(e,t)=>{Cn.init(e,t),dn(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(a=>Sw(a,e)):Sw(o,e)}});function Sw(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 Nw(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Oa(o,r,Gs()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const wA=ye("$ZodCatch",(e,t)=>{Cn.init(e,t),dn(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),dn(e,"optout",n=>n.def.innerType._zod.optout),dn(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(a=>Nw(n,a,t,r)):Nw(n,o,t,r)}}),vA=ye("$ZodPipe",(e,t)=>{Cn.init(e,t),dn(e,"values",n=>n.def.in._zod.values),dn(e,"optin",n=>n.def.in._zod.optin),dn(e,"optout",n=>n.def.out._zod.optout),dn(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const a=t.out._zod.run(n,r);return a instanceof Promise?a.then(l=>xu(l,t.in,r)):xu(a,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(a=>xu(a,t.out,r)):xu(o,t.out,r)}});function xu(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const bA=ye("$ZodReadonly",(e,t)=>{Cn.init(e,t),dn(e,"propValues",n=>n.def.innerType._zod.propValues),dn(e,"values",n=>n.def.innerType._zod.values),dn(e,"optin",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optin}),dn(e,"optout",n=>{var r,o;return(o=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:o.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Tw):Tw(o)}});function Tw(e){return e.memo||(e.value=Object.freeze(e.value)),e}const xA=ye("$ZodCustom",(e,t)=>{Gr.init(e,t),Cn.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(a=>jw(a,n,r,e));jw(o,n,r,e)}});function jw(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Xl(o))}}class _A extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Nh="~memo",Cw=[];function zp(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Aw=new WeakMap;function tx(e,t){const n=Aw.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1;const o=u=>{!r&&(u!=null&&u._zod)&&tx(u,t)&&(r=!0)},a=e._zod.def;switch(a.type){case"object":{for(const u of Reflect.ownKeys(a.shape))o(a.shape[u]);o(a.catchall);break}case"array":o(a.element);break;case"tuple":for(const u of a.items)o(u);o(a.rest);break;case"record":case"map":o(a.keyType),o(a.valueType);break;case"set":o(a.valueType);break;case"union":for(const u of a.options)o(u);break;case"intersection":o(a.left),o(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(a.innerType);break;case"pipe":o(a.in),o(a.out);break;case"function":o(a.input),o(a.output);break;case"lazy":o(e._zod.innerType);break;case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const u in a){const c=Object.getOwnPropertyDescriptor(a,u);if(!c||c.get)continue;const p=c.value;if(!(!p||typeof p!="object")){if(p._zod)o(p);else if(Array.isArray(p))for(const m of p)o(m)}}}return t.delete(e),Aw.set(e,r),r}function EA(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}let _u;const Eu=[],SA={alloc(e,t,n){const r=_u;if(!r)return n;_u=void 0;const o={value:n,issues:null};return r.set(t.value,o),Eu.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,a)=>{if(a.direction!=="backward"&&TA(a,o.value))throw new _A;return n(o,a)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const a=e._zod.parse,l=(u,c)=>{if(n===void 0&&(n=tx(e,new Set),!n))return e._zod.parse=a,e._zod.run===l&&(e._zod.run=a),a(u,c);const p=u.value;if(p===null||typeof p!="object")return a(u,c);let m=c[Nh];m||(m={buckets:new Map,backEdges:void 0},c[Nh]=m);let h;r===c?h=o:(h=EA(m,e),r=c,o=h);const k=h.get(p);if(k)return u.value=k.value,k.issues?k.issues.length&&u.issues.push(...zp(k.issues)):(u.memo=!0,m.backEdges??(m.backEdges=new Set),m.backEdges.add(k.value)),u;_u=h;const y=Eu.length,v=a(u,c);_u=void 0;const x=Eu.length>y?Eu.pop():void 0;return v instanceof Promise?v.then(_=>(x&&(x.issues=_.issues.length?zp(_.issues):Cw),_)):(x&&(x.issues=v.issues.length?zp(v.issues):Cw),v)};e._zod.parse=l,e._zod.run===a&&(e._zod.run=l)})}};function NA(){return SA}function TA(e,t){var r;const n=(r=e[Nh])==null?void 0:r.backEdges;return n!==void 0&&t!==null&&typeof t=="object"&&n.has(t)}const jA=()=>{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"},r={nan:"NaN"};function o(a,l){return a==="number"&&typeof l=="number"&&!Number.isFinite(l)?String(l):r[a]??a}return a=>{switch(a.code){case"invalid_type":{const l=o(a.expected),u=lj(a.input),c=o(u,a.input);return`Invalid input: expected ${l}, received ${c}`}case"invalid_value":return a.values.length===1?`Invalid input: expected ${Mb(a.values[0])}`:`Invalid option: expected one of ${cw(a.values,"|")}`;case"too_big":{const l=a.exact?"exactly ":a.inclusive?"<=":"<",u=t(a.origin);return u?`Too big: expected ${a.origin??"value"} to have ${l}${a.maximum.toString()} ${u.unit??"elements"}`:`Too big: expected ${a.origin??"value"} to be ${l}${a.maximum.toString()}`}case"too_small":{const l=a.exact?"exactly ":a.inclusive?">=":">",u=t(a.origin);return u?`Too small: expected ${a.origin} to have ${l}${a.minimum.toString()} ${u.unit}`:`Too small: expected ${a.origin} to be ${l}${a.minimum.toString()}`}case"invalid_format":{const l=a;return l.format==="starts_with"?`Invalid string: must start with "${l.prefix}"`:l.format==="ends_with"?`Invalid string: must end with "${l.suffix}"`:l.format==="includes"?`Invalid string: must include "${l.includes}"`:l.format==="regex"?`Invalid string: must match pattern ${l.pattern}`:`Invalid ${n[l.format]??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":""}: ${cw(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 CA(){return{localeError:jA()}}var Iw;class AA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function IA(){return new AA}(Iw=globalThis).__zod_globalRegistry??(Iw.__zod_globalRegistry=IA());const jl=globalThis.__zod_globalRegistry;function RA(e,t){return new e({type:"string",...st(t)})}function OA(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...st(t)})}function $A(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...st(t)})}function MA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...st(t)})}function LA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...st(t)})}function PA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...st(t)})}function DA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...st(t)})}function zA(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...st(t)})}function FA(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...st(t)})}function BA(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...st(t)})}function UA(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...st(t)})}function HA(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...st(t)})}function WA(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...st(t)})}function KA(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...st(t)})}function ZA(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...st(t)})}function qA(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...st(t)})}function GA(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...st(t)})}function VA(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...st(t)})}function YA(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...st(t)})}function QA(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...st(t)})}function XA(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...st(t)})}function JA(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...st(t)})}function eI(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...st(t)})}function tI(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...st(t)})}function nI(e,t){return new e({type:"string",format:"date",check:"string_format",...st(t)})}function rI(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...st(t)})}function oI(e,t){return new e({type:"string",format:"duration",check:"string_format",...st(t)})}function sI(e,t){return new e({type:"number",checks:[],...st(t)})}function iI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...st(t)})}function aI(e,t){return new e({type:"boolean",...st(t)})}function lI(e){return new e({type:"unknown"})}function cI(e,t){return new e({type:"never",...st(t)})}function Rw(e,t){return new Hb({check:"less_than",...st(t),value:e,inclusive:!1})}function Fp(e,t){return new Hb({check:"less_than",...st(t),value:e,inclusive:!0})}function Ow(e,t){return new Wb({check:"greater_than",...st(t),value:e,inclusive:!1})}function Bp(e,t){return new Wb({check:"greater_than",...st(t),value:e,inclusive:!0})}function $w(e,t){return new lC({check:"multiple_of",...st(t),value:e})}function nx(e,t){return new uC({check:"max_length",...st(t),maximum:e})}function nd(e,t){return new dC({check:"min_length",...st(t),minimum:e})}function rx(e,t){return new fC({check:"length_equals",...st(t),length:e})}function uI(e,t){return new pC({check:"string_format",format:"regex",...st(t),pattern:e})}function dI(e){return new hC({check:"string_format",format:"lowercase",...st(e)})}function fI(e){return new mC({check:"string_format",format:"uppercase",...st(e)})}function pI(e,t){return new gC({check:"string_format",format:"includes",...st(t),includes:e})}function hI(e,t){return new kC({check:"string_format",format:"starts_with",...st(t),prefix:e})}function mI(e,t){return new yC({check:"string_format",format:"ends_with",...st(t),suffix:e})}function $a(e){return new wC({check:"overwrite",tx:e})}function gI(e){return $a(t=>t.normalize(e))}function kI(){return $a(e=>e.trim())}function yI(){return $a(e=>e.toLowerCase())}function wI(){return $a(e=>e.toUpperCase())}function vI(){return $a(e=>VT(e))}function bI(e,t,n){return new e({type:"array",element:t,...st(n)})}function xI(e,t,n){return new e({type:"custom",check:"custom",fn:t,...st(n)})}function _I(e,t){const n=EI(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Xl(o,r.value,n._zod.def));else{const a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=n),a.continue??(a.continue=!n._zod.def.abort),r.issues.push(Xl(a))}},e(r.value,r)),t);return n}function EI(e,t){const n=new Gr({check:"custom",...st(t)});return n._zod.check=e,n}function Dl(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&qr(e,r,n[r]);return e}function ox(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)??jl,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 Ws(e,t,n,r,o){const a=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(a==="any")return!1;if(a===void 0||a==="throw")throw new Error(o);return Object.assign(n,a),!0}function dr(e,t,n={path:[],schemaPath:[]}){var m,h;var r;const o=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;const l={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,l),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const u=(h=(m=e._zod).toJSONSchema)==null?void 0:h.call(m);if(u)l.schema=u;else{const k={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,k);else{const v=l.schema,x=t.processors[o.type];if(!x)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);x(e,t,v,k)}const y=e._zod.parent;y&&(l.ref||(l.ref=y),dr(y,t,k),t.seen.get(y).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Dl(l.schema,c),t.io==="input"&&Rr(e)&&(delete l.schema.examples,delete l.schema.default),t.io==="input"&&"_prefault"in l.schema&&((r=l.schema).default??(r.default=l.schema._prefault)),delete l.schema._prefault,t.seen.get(e).schema}function Mw(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function sx(e,t){var l,u,c,p;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const m of e.seen.entries()){const h=(l=e.metadataRegistry.get(m[0]))==null?void 0:l.id;if(h){const k=r.get(h);if(k&&k!==m[0])throw new Error(`Duplicate schema id "${h}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(h,m[0])}}const o=m=>{var x;const h=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const _=(x=e.external.registry.get(m[0]))==null?void 0:x.id,N=e.external.uri??(E=>E);if(_)return{ref:N(_)};const j=m[1].defId??m[1].schema.id??`schema${e.counter++}`;return m[1].defId=j,{defId:j,ref:`${N("__shared")}#/${h}/${Mw(j)}`}}const k="#",y=`${k}/${h}/`;if(m[1]===n&&!m[1].schema.id)return{ref:k};const v=m[1].schema.id??`__schema${e.counter++}`;return{defId:v,ref:y+Mw(v)}},a=m=>{if(m[1].schema.$ref)return;const h=m[1],{ref:k,defId:y}=o(m);h.def={...h.schema},y&&(h.defId=y);const v=h.schema;for(const x in v)delete v[x];v.$ref=k};if(e.cycles==="throw")for(const m of e.seen.entries()){const h=m[1];if(h.cycle)throw new Error(`Cycle detected: #/${(u=h.cycle)==null?void 0:u.join("/")}/<root>
69
+
70
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const m of e.seen.entries()){const h=m[1];if(t===m[0]){a(m);continue}if(e.external){const y=(c=e.external.registry.get(m[0]))==null?void 0:c.id;if(t!==m[0]&&y){a(m);continue}}if((p=e.metadataRegistry.get(m[0]))==null?void 0:p.id){a(m);continue}if(h.cycle){a(m);continue}if(h.count>1&&e.reused==="ref"){a(m);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function ix(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;ix(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const a=r.type;for(const l of Array.isArray(a)?a:[a]){if(typeof l!="string")return;n.includes(l)||n.push(l)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const ax=new Set(["type","properties","required","additionalProperties"]),Lw=["oneOf","anyOf"];function Pw(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Th(e){var a;const t=[];for(const l of e){if(typeof l!="object"||l.type!=="object")return null;for(const u in l)if(!ax.has(u))return null;t.push(l)}const n={},r=new Set;for(const l of t){for(const u in l.properties){if(Object.prototype.hasOwnProperty.call(n,u))continue;const c=[];for(const m of t){const h=((a=m.properties)==null?void 0:a[u])??Pw(m);h!=null&&(c.some(k=>JSON.stringify(k)===JSON.stringify(h))||c.push(h))}const p=c.length===1?c[0]:Th(c)??{allOf:c};qr(n,u,p)}for(const u of l.required??[])r.add(u)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(l=>l.additionalProperties===!1))o.additionalProperties=!1;else{const l=[];for(const u of t){const c=Pw(u);c&&!l.some(p=>JSON.stringify(p)===JSON.stringify(c))&&l.push(c)}l.length===1?o.additionalProperties=l[0]:l.length>1&&(o.additionalProperties={allOf:l})}return o}function SI(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of ax)if(o in e)return;const n=t.filter(o=>Lw.some(a=>Array.isArray(o[a])));let r=null;if(!n.length)r=Th(t);else{const o=n[0],a=Lw.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;const l=t.filter(c=>c!==o),u=o[a].map(c=>Th([...l,c]));if(u.some(c=>!c))return;r={[a]:u}}r&&(delete e.allOf,Dl(e,r))}function lx(e,t){var u,c,p,m;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=h=>{const k=e.seen.get(h);if(k.ref===null)return;const y=k.def??k.schema,v={...y},x=k.ref;if(k.ref=null,x){r(x);const N=e.seen.get(x),j=N.schema;if(j.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(y.allOf=y.allOf??[],y.allOf.push(j)):Dl(y,j),Dl(y,v),h._zod.parent===x)for(const M in y)M==="$ref"||M==="allOf"||M in v||delete y[M];if(j.$ref&&N.def)for(const M in y)M==="$ref"||M==="allOf"||M in N.def&&JSON.stringify(y[M])===JSON.stringify(N.def[M])&&delete y[M]}const _=h._zod.parent;if(_&&_!==x){r(_);const N=e.seen.get(_);if(N!=null&&N.schema.$ref&&(y.$ref=N.schema.$ref,N.def))for(const j in y)j==="$ref"||j==="allOf"||j in N.def&&JSON.stringify(y[j])===JSON.stringify(N.def[j])&&delete y[j]}e.override({zodSchema:h,jsonSchema:y,path:k.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const h of[...e.seen.entries()].reverse())r(h[0]);if(e.target!=="openapi-3.0")for(const h of e.seen.entries())ix(h[1].def??h[1].schema);for(const h of e.deferred)h();if(e.intersections.length){const h=new Map;for(const k of e.seen.values())for(const y of[k.schema,k.def]){const v=y==null?void 0:y.allOf;if(!Array.isArray(v))continue;const x=h.get(v);x?x.push(y):h.set(v,[y])}for(const k of e.intersections)for(const y of h.get(k)??[])SI(y)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,(u=e.external)!=null&&u.uri){const h=(c=e.external.registry.get(t))==null?void 0:c.id;if(!h)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(h)}Dl(o,n.defId?n.schema:n.def??n.schema);const a=(p=e.metadataRegistry.get(t))==null?void 0:p.id;a!==void 0&&o.id===a&&delete o.id;const l=((m=e.external)==null?void 0:m.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const h of e.seen.entries()){const k=h[1];k.def&&k.defId&&(k.def.id===k.defId&&delete k.def.id,qr(l,k.defId,k.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?o.$defs=l:o.definitions=l);try{const h=JSON.parse(JSON.stringify(o));return Object.defineProperty(h,"~standard",{value:{...t["~standard"],jsonSchema:{input:rd(t,"input",e.processors),output:rd(t,"output",e.processors)}},enumerable:!1,writable:!1}),h}catch{throw new Error("Error converting schema to JSON.")}}function Rr(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Rr(r.element,n);if(r.type==="set")return Rr(r.valueType,n);if(r.type==="lazy")return Rr(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return Rr(r.innerType,n);if(r.type==="intersection")return Rr(r.left,n)||Rr(r.right,n);if(r.type==="record"||r.type==="map")return Rr(r.keyType,n)||Rr(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Rr(r.in,n)||Rr(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Rr(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Rr(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Rr(o,n))return!0;return!!(r.rest&&Rr(r.rest,n))}return!1}const NI=(e,t={})=>n=>{const r=ox({...n,processors:t});return dr(e,r),sx(r,e),lx(r,e)},rd=(e,t,n={})=>r=>{const{libraryOptions:o,target:a}=r??{},l=ox({...o??{},target:a,io:t,processors:n});return dr(e,l),sx(l,e),lx(l,e)},TI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jI=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:a,maximum:l,format:u,patterns:c,contentEncoding:p,laxFormat:m}=e._zod.bag;if(typeof a=="number"&&(o.minLength=a),typeof l=="number"&&(o.maxLength=l),u&&(o.format=TI[u]??u,o.format===""&&delete o.format,(u==="time"||m)&&delete o.format),p&&(o.contentEncoding=p),c&&c.size>0){const h=[...c];h.length===1?o.pattern=h[0].source:h.length>1&&(o.allOf=[...h.map(k=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:k.source}))])}},CI=(e,t,n,r)=>{const o=n,{minimum:a,maximum:l,format:u,multipleOf:c,exclusiveMaximum:p,exclusiveMinimum:m}=e._zod.bag;typeof u=="string"&&u.includes("int")?o.type="integer":o.type="number";const h=typeof m=="number"&&m>=(a??Number.NEGATIVE_INFINITY),k=typeof p=="number"&&p<=(l??Number.POSITIVE_INFINITY),y=t.target==="draft-04"||t.target==="openapi-3.0";h?y?(o.minimum=m,o.exclusiveMinimum=!0):o.exclusiveMinimum=m:typeof a=="number"&&(o.minimum=a),k?y?(o.maximum=p,o.exclusiveMaximum=!0):o.exclusiveMaximum=p:typeof l=="number"&&(o.maximum=l),typeof c=="number"&&(Number.isFinite(c)&&c!==0?o.multipleOf=Math.abs(c):Ws(e,t,o,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},AI=(e,t,n,r)=>{n.type="boolean"},II=(e,t,n,r)=>{n.not={}},RI=(e,t,n,r)=>{},OI=(e,t,n,r)=>{const o=e._zod.def,a=Rb(o.entries);if(a.length===0){n.not={};return}a.every(l=>typeof l=="number")&&(n.type="number"),a.every(l=>typeof l=="string")&&(n.type="string"),n.enum=a},$I=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const a=[];for(const l of o.values)if(l===void 0){if(Ws(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof l=="bigint"){if(Ws(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;a.push(Number(l))}else a.push(l);if(a.length!==0)if(a.length===1){const l=a[0];n.type=l===null?"null":typeof l,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[l]:n.const=l}else a.every(l=>typeof l=="number")&&(n.type="number"),a.every(l=>typeof l=="string")&&(n.type="string"),a.every(l=>typeof l=="boolean")&&(n.type="boolean"),a.every(l=>l===null)&&(n.type="null"),n.enum=a},MI=(e,t,n,r)=>{Ws(e,t,n,r,"Custom types cannot be represented in JSON Schema")},LI=(e,t,n,r)=>{Ws(e,t,n,r,"Transforms cannot be represented in JSON Schema")},PI=(e,t,n,r)=>{const o=n,a=e._zod.def,{minimum:l,maximum:u}=e._zod.bag;typeof l=="number"&&(o.minItems=l),typeof u=="number"&&(o.maxItems=u),o.type="array",o.items=dr(a.element,t,{...r,path:[...r.path,"items"]})};function od(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?od(t.out):t.type==="catch"?od(t.innerType):e._zod.optin}const DI=(e,t,n,r)=>{var m;const o=n,a=e._zod.def,l=a.shape;if(Object.getOwnPropertySymbols(l).length&&Ws(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const h in l)qr(o.properties,h,dr(l[h],t,{...r,path:[...r.path,"properties",h]}));const c=new Set(Object.keys(l)),p=new Set([...c].filter(h=>{const k=a.shape[h];return t.io==="input"?od(k)===void 0:k._zod.optout===void 0}));p.size>0&&(o.required=Array.from(p)),((m=a.catchall)==null?void 0:m._zod.def.type)==="never"?o.additionalProperties=!1:a.catchall?a.catchall&&(o.additionalProperties=dr(a.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},zI=(e,t,n,r)=>{const o=e._zod.def,a=o.inclusive===!1,l=o.options.map((u,c)=>dr(u,t,{...r,path:[...r.path,a?"oneOf":"anyOf",c]}));a?n.oneOf=l:n.anyOf=l},FI=(e,t,n,r)=>{const o=e._zod.def,a=dr(o.left,t,{...r,path:[...r.path,"allOf",0]}),l=dr(o.right,t,{...r,path:[...r.path,"allOf",1]}),u=p=>"allOf"in p&&Object.keys(p).length===1,c=[...u(a)?a.allOf:[a],...u(l)?l.allOf:[l]];n.allOf=c,t.intersections.push(c)},BI=(e,t,n,r)=>{const o=n,a=e._zod.def;o.type="array";const l=t.target==="draft-2020-12"?"prefixItems":"items",u=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=a.items.map((x,_)=>dr(x,t,{...r,path:[...r.path,l,_]})),p=a.rest?dr(a.rest,t,{...r,path:[...r.path,u,...t.target==="openapi-3.0"?[a.items.length]:[]]}):null;let m=a.items.length;for(;m>0;){const x=a.items[m-1];if(!(t.io==="input"?od(x)!==void 0:x._zod.optout==="optional"))break;m--}const h=a.items.length,k=!a.rest;t.target==="draft-2020-12"?(o.prefixItems=c,k?o.items=!1:p&&(o.items=p),m>0&&(o.minItems=m),k&&(o.maxItems=h)):t.target==="openapi-3.0"?(o.items={anyOf:c},p&&o.items.anyOf.push(p),m>0&&(o.minItems=m),k&&(o.maxItems=h)):(o.items=c,k?o.additionalItems=!1:p&&(o.additionalItems=p),m>0&&(o.minItems=m),k&&(o.maxItems=h));const{minimum:y,maximum:v}=e._zod.bag;typeof y=="number"&&(o.minItems=y),typeof v=="number"&&(o.maxItems=v)},UI=(e,t,n,r)=>{const o=e._zod.def,a=dr(o.innerType,t,r),l=t.seen.get(e);t.target==="openapi-3.0"?(l.ref=o.innerType,n.nullable=!0):n.anyOf=[a,{type:"null"}]},HI=(e,t,n,r)=>{const o=e._zod.def;dr(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType},Rm=Symbol();function cx(e,t,n,r,o){let a=!1;const l=JSON.stringify(e,(u,c)=>typeof c!="bigint"?c:(a=!0,null));return a?(Ws(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),Rm):JSON.parse(l)}const WI=(e,t,n,r)=>{const o=e._zod.def;dr(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType;const l=cx(o.defaultValue,e,t,n,r);l!==Rm&&(n.default=l)},KI=(e,t,n,r)=>{const o=e._zod.def;dr(o.innerType,t,r);const a=t.seen.get(e);if(a.ref=o.innerType,t.io!=="input")return;const l=cx(o.defaultValue,e,t,n,r);l!==Rm&&(n._prefault=l)},ZI=(e,t,n,r)=>{const o=e._zod.def;dr(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType;let l;try{l=o.catchValue(void 0)}catch{Ws(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=l},qI=(e,t,n,r)=>{const o=e._zod.def,a=o.in._zod.traits.has("$ZodTransform"),l=t.io==="input"?a?o.out:o.in:o.out;dr(l,t,r);const u=t.seen.get(e);u.ref=l},GI=(e,t,n,r)=>{const o=e._zod.def;dr(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType,n.readOnly=!0},ux=(e,t,n,r)=>{const o=e._zod.def;dr(o.innerType,t,r);const a=t.seen.get(e);a.ref=o.innerType},Dw=new WeakSet([Object.prototype,Error.prototype]);function Su(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const VI=(e,t)=>{zb.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Dw.has(n)||(Dw.add(n),Su(n,"format",r=>o=>xj(r,o)),Su(n,"flatten",r=>o=>bj(r,o)),Su(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,xh,2)}),Su(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,xh,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},yo=ye("ZodError",VI,void 0,{Parent:Error}),YI=jm(yo),QI=Cm(yo),XI=Od(yo),JI=$d(yo),eR=Sj(yo),tR=Nj(yo),nR=Tj(yo),rR=jj(yo),oR=Cj(yo),sR=Aj(yo),iR=Ij(yo),aR=Rj(yo);function lR(){Lo.localeError||Gs(CA())}function Ld(){Lo.memoizer||Gs({memoizer:NA()})}const zn=ye("ZodType",(e,t)=>(lR(),Cn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(Zs(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 qs(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(iO(e,t))},superRefine(e,t){return this.check(aO(e,t))},overwrite(e){return this.check($a(e))},optional(){return Bw(this)},exactOptional(){return GR(this)},nullable(){return Uw(this)},nullish(){return Bw(Uw(this))},nonoptional(e){return eO(this,e)},array(){return Si(this)},or(e){return zR([this,e])},and(e){return HR(this,e)},transform(e){return Hw(this,qR(e))},default(e){return QR(this,e)},prefault(e){return JR(this,e)},catch(e){return nO(this,e)},pipe(e){return Hw(this,e)},readonly(){return sO(this)},describe(e){const t=this.clone();return jl.add(t,{description:e}),t},meta(...e){if(e.length===0)return jl.get(this);const t=this.clone();return jl.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 Lb(this,"~standard",{...Kb(this),jsonSchema:{input:rd(this,"input"),output:rd(this,"output")}})},set"~standard"(e){Na(this,"~standard",e)},parse:function e(t,n){return YI(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await QI(this,t,n,{callee:e})},safeParse(e,t){return XI(this,e,t)},async safeParseAsync(e,t){return JI(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){Na(this,"spa",e)},encode:function e(t,n){return eR(this,t,n,{callee:e})},decode:function e(t,n){return tR(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await nR(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await rR(this,t,n,{callee:e})},safeEncode(e,t){return oR(this,e,t)},safeDecode(e,t){return sR(this,e,t)},async safeEncodeAsync(e,t){return iR(this,e,t)},async safeDecodeAsync(e,t){return aR(this,e,t)},toJSONSchema(e){return NI(this,{})(e)},get description(){var e;return(e=jl.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),dx=ye("_ZodString",(e,t)=>{Im.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(r,o,a)=>jI(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(uI(...e))},includes(...e){return this.check(pI(...e))},startsWith(...e){return this.check(hI(...e))},endsWith(...e){return this.check(mI(...e))},min(...e){return this.check(nd(...e))},max(...e){return this.check(nx(...e))},length(...e){return this.check(rx(...e))},nonempty(...e){return this.check(nd(1,...e))},lowercase(e){return this.check(dI(e))},uppercase(e){return this.check(fI(e))},trim(){return this.check(kI())},normalize(...e){return this.check(gI(...e))},toLowerCase(){return this.check(yI())},toUpperCase(){return this.check(wI())},slugify(){return this.check(vI())}}),cR=ye("ZodString",(e,t)=>{Im.init(e,t),dx.init(e,t)},{email(e){return this.check(OA(hR,e))},url(e){return this.check(zA(gR,e))},jwt(e){return this.check(eI(IR,e))},emoji(e){return this.check(FA(kR,e))},guid(e){return this.check($A(mR,e))},uuid(e){return this.check(MA(Nu,e))},uuidv4(e){return this.check(LA(Nu,e))},uuidv6(e){return this.check(PA(Nu,e))},uuidv7(e){return this.check(DA(Nu,e))},nanoid(e){return this.check(BA(yR,e))},cuid(e){return this.check(UA(wR,e))},cuid2(e){return this.check(HA(vR,e))},ulid(e){return this.check(WA(bR,e))},base64(e){return this.check(QA(jR,e))},base64url(e){return this.check(XA(CR,e))},xid(e){return this.check(KA(xR,e))},ksuid(e){return this.check(ZA(_R,e))},ipv4(e){return this.check(qA(ER,e))},ipv6(e){return this.check(GA(SR,e))},cidrv4(e){return this.check(VA(NR,e))},cidrv6(e){return this.check(YA(TR,e))},e164(e){return this.check(JA(AR,e))},datetime(e){return this.check(tI(uR,e))},date(e){return this.check(nI(dR,e))},time(e){return this.check(rI(fR,e))},duration(e){return this.check(oI(pR,e))}});function pn(e){return RA(cR,e)}const Fn=ye("ZodStringFormat",(e,t)=>{An.init(e,t),dx.init(e,t)}),uR=ye("ZodISODateTime",(e,t)=>{DC.init(e,t),Fn.init(e,t)}),dR=ye("ZodISODate",(e,t)=>{zC.init(e,t),Fn.init(e,t)}),fR=ye("ZodISOTime",(e,t)=>{FC.init(e,t),Fn.init(e,t)}),pR=ye("ZodISODuration",(e,t)=>{BC.init(e,t),Fn.init(e,t)}),hR=ye("ZodEmail",(e,t)=>{EC.init(e,t),Fn.init(e,t)}),mR=ye("ZodGUID",(e,t)=>{xC.init(e,t),Fn.init(e,t)}),Nu=ye("ZodUUID",(e,t)=>{_C.init(e,t),Fn.init(e,t)}),gR=ye("ZodURL",(e,t)=>{AC.init(e,t),Fn.init(e,t)}),kR=ye("ZodEmoji",(e,t)=>{IC.init(e,t),Fn.init(e,t)}),yR=ye("ZodNanoID",(e,t)=>{RC.init(e,t),Fn.init(e,t)}),wR=ye("ZodCUID",(e,t)=>{OC.init(e,t),Fn.init(e,t)}),vR=ye("ZodCUID2",(e,t)=>{$C.init(e,t),Fn.init(e,t)}),bR=ye("ZodULID",(e,t)=>{MC.init(e,t),Fn.init(e,t)}),xR=ye("ZodXID",(e,t)=>{LC.init(e,t),Fn.init(e,t)}),_R=ye("ZodKSUID",(e,t)=>{PC.init(e,t),Fn.init(e,t)}),ER=ye("ZodIPv4",(e,t)=>{UC.init(e,t),Fn.init(e,t)}),SR=ye("ZodIPv6",(e,t)=>{WC.init(e,t),Fn.init(e,t)}),NR=ye("ZodCIDRv4",(e,t)=>{KC.init(e,t),Fn.init(e,t)}),TR=ye("ZodCIDRv6",(e,t)=>{qC.init(e,t),Fn.init(e,t)}),jR=ye("ZodBase64",(e,t)=>{GC.init(e,t),Fn.init(e,t)}),CR=ye("ZodBase64URL",(e,t)=>{YC.init(e,t),Fn.init(e,t)}),AR=ye("ZodE164",(e,t)=>{QC.init(e,t),Fn.init(e,t)}),IR=ye("ZodJWT",(e,t)=>{JC.init(e,t),Fn.init(e,t)}),fx=ye("ZodNumber",(e,t)=>{Yb.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(r,o,a)=>CI(e,r,o,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(Ow(e,t))},gte(e,t){return this.check(Bp(e,t))},min(e,t){return this.check(Bp(e,t))},lt(e,t){return this.check(Rw(e,t))},lte(e,t){return this.check(Fp(e,t))},max(e,t){return this.check(Fp(e,t))},int(e){return this.check(zw(e))},safe(e){return this.check(zw(e))},positive(e){return this.check(Ow(0,e))},nonnegative(e){return this.check(Bp(0,e))},negative(e){return this.check(Rw(0,e))},nonpositive(e){return this.check(Fp(0,e))},multipleOf(e,t){return this.check($w(e,t))},step(e,t){return this.check($w(e,t))},finite(){return this}});function Ei(e){return sI(fx,e)}const RR=ye("ZodNumberFormat",(e,t)=>{eA.init(e,t),fx.init(e,t)});function zw(e){return iI(RR,e)}const OR=ye("ZodBoolean",(e,t)=>{tA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>AI(e,n,r)});function Io(e){return aI(OR,e)}const $R=ye("ZodUnknown",(e,t)=>{nA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>RI()});function Fw(){return lI($R)}const MR=ye("ZodNever",(e,t)=>{rA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>II(e,n,r)});function LR(e){return cI(MR,e)}const PR=ye("ZodArray",(e,t)=>{Ld(),oA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>PI(e,n,r,o),e.element=t.element},{min(e,t){return this.check(nd(e,t))},nonempty(e){return this.check(nd(1,e))},max(e,t){return this.check(nx(e,t))},length(e,t){return this.check(rx(e,t))},unwrap(){return this.element}});function Si(e,t){return bI(PR,e,t)}const DR=ye("ZodObject",(e,t)=>{Ld(),aA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>DI(e,n,r,o),pj(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return sd(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Fw()})},loose(){return this.clone({...this._zod.def,catchall:Fw()})},strict(){return this.clone({...this._zod.def,catchall:LR()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return nj(this,e)},safeExtend(e){return rj(this,e)},merge(e){return oj(this,e)},pick(e){return ej(this,e)},omit(e){return tj(this,e)},partial(...e){return uw(Om,this,e[0])},exactPartial(...e){return uw(mx,this,e[0],"exactPartial")},required(...e){return sj(gx,this,e[0])}});function Nr(e,t){const n={type:"object",shape:e??{},...st(t)};return new DR(n)}const px=ye("ZodUnion",(e,t)=>{Jb.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zI(e,n,r,o),e.options=t.options});function zR(e,t){return new px({type:"union",options:e,...st(t)})}const FR=ye("ZodDiscriminatedUnion",(e,t)=>{px.init(e,t),lA.init(e,t)});function BR(e,t,n){return new FR({type:"union",options:t,discriminator:e,...st(n)})}const UR=ye("ZodIntersection",(e,t)=>{cA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>FI(e,n,r,o)});function HR(e,t){return new UR({type:"intersection",left:e,right:t})}const WR=ye("ZodTuple",(e,t)=>{Ld(),uA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>BI(e,n,r,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){var t;const e=this._zod.def;if((t=e.checks)!=null&&t.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(n=>new Om({type:"optional",innerType:n}))})}});function hx(e,t,n){const r=t instanceof Cn,o=r?n:t,a=r?t:null;return new WR({type:"tuple",items:e,rest:a,...st(o)})}const jh=ye("ZodEnum",(e,t)=>{dA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(r,o,a)=>OI(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const a={};for(const l of r)if(n.has(l))a[l]=t.entries[l];else throw new Error(`Key ${l} not found in enum`);return new jh({...t,checks:[],...st(o),entries:a})},e.exclude=(r,o)=>{const a={...t.entries};for(const l of r)if(n.has(l))delete a[l];else throw new Error(`Key ${l} not found in enum`);return new jh({...t,checks:[],...st(o),entries:a})}});function sd(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new jh({type:"enum",entries:n,...st(t)})}const KR=ye("ZodLiteral",(e,t)=>{fA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$I(e,n,r,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function eo(e,t){return new KR({type:"literal",values:Array.isArray(e)?e:[e],...st(t)})}const ZR=ye("ZodTransform",(e,t)=>{Ld(),pA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>LI(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Pb(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(Xl(a,n.value,t));else{const l=a;l.fatal&&(l.continue=!1),l.code??(l.code="custom"),"input"in l||(l.input=n.value),l.inst??(l.inst=e),n.issues.push(Xl(l))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(a=>(n.value=a,n)):(n.value=o,n)}});function qR(e){return new ZR({type:"transform",transform:e})}const Om=ye("ZodOptional",(e,t)=>{ex.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ux(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Bw(e){return new Om({type:"optional",innerType:e})}const mx=ye("ZodExactOptional",(e,t)=>{hA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ux(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function GR(e){return new mx({type:"optional",innerType:e})}const VR=ye("ZodNullable",(e,t)=>{mA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>UI(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Uw(e){return new VR({type:"nullable",innerType:e})}const YR=ye("ZodDefault",(e,t)=>{gA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>WI(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function QR(e,t){return new YR({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():$b(t)}})}const XR=ye("ZodPrefault",(e,t)=>{kA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>KI(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function JR(e,t){return new XR({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():$b(t)}})}const gx=ye("ZodNonOptional",(e,t)=>{yA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>HI(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function eO(e,t){return new gx({type:"nonoptional",innerType:e,...st(t)})}const tO=ye("ZodCatch",(e,t)=>{wA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ZI(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nO(e,t){return new tO({type:"catch",innerType:e,catchValue:typeof t=="function"?t:mj(t)})}const rO=ye("ZodPipe",(e,t)=>{vA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qI(e,n,r,o),e.in=t.in,e.out=t.out});function Hw(e,t){return new rO({type:"pipe",in:e,out:t})}const oO=ye("ZodReadonly",(e,t)=>{bA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>GI(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function sO(e){return new oO({type:"readonly",innerType:e})}const kx=ye("ZodCustom",(e,t)=>{xA.init(e,t),zn.init(e,t),e._zod.processJSONSchema=(n,r,o)=>MI(e,n,r,o)});function iO(e,t={}){return xI(kx,e,t)}function aO(e,t){return _I(e,t)}function lO(e,t={}){const n=new kx({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...st(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}const cO=["off","tailscale","any"],uO={updates:!0,deploy:!0,remote:"any",agents:null,customAgents:!0,brandedListener:!0,planSignIn:!0};Nr({updates:Io().optional(),deploy:Io().optional(),remote:sd(cO).optional(),agents:Si(pn()).optional(),customAgents:Io().optional(),brandedListener:Io().optional(),planSignIn:Io().optional()});const dO={...uO,source:null,problem:null};function fO(e){const t=[];return e.updates||t.push("updates off"),e.deploy||t.push("deploy off"),e.remote!=="any"&&t.push(`remote ${e.remote}`),e.agents!==null&&t.push(`agents ${e.agents.join(", ")||"none"}`),e.customAgents||t.push("custom agents off"),e.brandedListener||t.push("toyon.localhost listener off"),e.planSignIn||t.push("plan sign-in off"),t}const Up=6e3,Ww=1500;function pO(e){if(e.length<=Up)return e;const t=e.length-Up;return`${e.slice(0,Ww)}
71
+ [${t} characters cut here]
72
+ ${e.slice(e.length-(Up-Ww))}`}const hO=e=>e.endsWith(".ts.net"),Kw=e=>e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function mO(e){if(e===null)return{ok:!0,text:"Your phone needs Tailscale on, signed in to the same tailnet."};if(e.length===0)return{ok:!1,text:"No phone has joined your tailnet. Install Tailscale on it and sign in to the same account first."};const t=e.filter(r=>r.online).map(r=>r.name);if(t.length>0)return{ok:!0,text:`${Kw(t)} ${t.length>1?"are":"is"} on your tailnet.`};const n=e.map(r=>r.name);return{ok:!1,text:`${Kw(n)} ${n.length>1?"are":"is"} not answering on your tailnet. Check Tailscale is on there.`}}const Ch=89,id=5e6,gO=["image/png","image/jpeg","image/gif","image/webp"],Zw=2576,Hp=5*1024*1024,kO=1200,yO=10,wO=1e5,qw=100*1024*1024,vO="pasted-text.txt";function bO(e){return e.t==="term-data"||e.t==="term-snapshot"||e.t==="term-exit"}function xO(e){return e.t==="file-read"||e.t==="file-written"||e.t==="file-blame"}const _O=80;function $m(e){var r;const t=e.split(`
73
+ `),n=((r=t.find(o=>o.trim().length>0))==null?void 0:r.trim())??"";return{chars:e.length,lines:t.length,preview:n.slice(0,_O)}}function yx(e){return e.length>=kO||e.split(`
74
+ `).length>=yO}function EO({startLine:e,endLine:t}){return e===t?`${e}`:`${e}-${t}`}function SO(e){return`${e.path.slice(e.path.lastIndexOf("/")+1)} (${EO(e)})`}const NO=/\u001B(?:\[[0-?]*[ -/]*[@-~]|\][^\u0007]*(?:\u0007|\u001B\\))/g;function TO(e){return e.replace(NO,"")}const wx="Projects";function jO(e){for(const t of e){const n=t.codePointAt(0)??0;if(n<32||n===127)return!0}return!1}function Jl(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":jO(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 CO=/^(?:https?|ssh|git|file):\/\/\S+$/i,vx=/^[\w.-]+@[\w.-]+:\S+$/;function AO(e){const t=e.trim();if(!CO.test(t)&&!vx.test(t))return null;const n=IO(t);return n&&!Jl(n)?{url:t,name:n}:null}function IO(e){var o;const t=((o=e.split(/[?#]/)[0])==null?void 0:o.replace(/\/+$/,""))??"";return((vx.test(t)?t.split(":")[1]??"":t).split("/").pop()??"").replace(/\.git$/i,"")}const RO=Nr({component:pn().nullable(),file:pn().nullable(),line:Ei().nullable(),callFile:pn().nullable().default(null),callLine:Ei().nullable().default(null),tag:pn(),selector:pn()}),OO=Nr({tag:pn().max(40),id:pn().max(200),classes:Si(pn().max(120)).max(16),text:pn().max(200),attrs:Si(hx([pn().max(40),pn().max(200)])).max(12)}),$O=hx([Ei(),Ei()]),MO=RO.extend({classes:pn(),text:pn(),html:pn(),route:pn(),element:OO}),LO=BR("type",[Nr({type:eo("loaded"),url:pn(),title:pn()}),Nr({type:eo("navigated"),url:pn(),title:pn().optional()}),Nr({type:eo("title"),title:pn()}),Nr({type:eo("links"),links:Si(Nr({path:pn().max(2048),text:pn().max(120)})).max(200)}),Nr({type:eo("hmr")}),Nr({type:eo("page-error"),message:pn(),source:pn().optional(),line:Ei().optional()}),MO.extend({type:eo("picked"),verb:sd(["chat","code"]).default("chat"),site:sd(["call","source"]).default("source")}),Nr({type:eo("pick-cancel")}),Nr({type:eo("highlight-miss"),path:pn(),fileMatched:Ei(),withSource:Ei(),ranges:Si($O).nullable()}),Nr({type:eo("drag-files")}),Nr({type:eo("drop-files"),files:Si(lO(File))}),Nr({type:eo("focus"),gesture:Io()}),Nr({type:eo("key"),key:pn(),code:pn().optional(),meta:Io(),ctrl:Io().optional(),shift:Io().optional(),alt:Io().optional(),up:Io().optional()})]);function PO(e){const t=LO.safeParse(e);return t.success?t.data:null}const Ma="shell",bx="check",DO="ToolSearch",Mm="AskUserQuestion",zO=/["“”]([^"“”]*)["“”]?|(\S+)/g;function xx(e){const t=new Set;for(const n of e.matchAll(zO)){const r=(n[1]??n[2]??"").replace(/\s+/g," ").trim().toLowerCase();r&&t.add(r)}return[...t]}const FO="now",BO="http://preview.invalid",UO=200;function Gw(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim().slice(0,UO).trim();return t||void 0}function Pd(e){let t;try{t=new URL(e,BO)}catch{return null}if(t.pathname.startsWith("/__toyon"))return null;const n=Vw(t.pathname)||"/",r=t.hash.startsWith("#/")?Vw(t.hash.split("?")[0]??""):"";return r.length>1?`${n}${r}`:n}const Vw=e=>e.replace(/\/+$/,""),HO={static:4,mixed:3.5,param:3,optional:2,"optional-static":2,splat:1},ad=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function _x(e){const t=/^\[\[\.\.\.([^\]]*)\]\]$/.exec(e);if(t)return{kind:"splat",name:t[1]||"path",min:0};const n=/^\[\.\.\.([^\]]*)\]$/.exec(e);if(n)return{kind:"splat",name:n[1]||"path",min:1};const r=/^\[\[([^\]]+)\]\]$/.exec(e)??/^:([\w-]+)\?$/.exec(e)??/^\{-\$([\w-]+)\}$/.exec(e);if(r)return{kind:"optional",name:r[1]};const o=/^\[([^\]=]+)(?:=[^\]]*)?\]$/.exec(e)??/^:([\w-]+)$/.exec(e)??/^\$([\w-]+)$/.exec(e);if(o)return{kind:"param",name:o[1]};if(e==="*"||e==="$")return{kind:"splat",name:"path",min:0};if(/^[^[{:$*?]+\?$/.test(e))return{kind:"optional-static",text:e.slice(0,-1)};if(/[[{]/.test(e)){const a=[];let l="",u=0;for(const p of e.matchAll(/\[([^\]=]+)(?:=[^\]]*)?\]|\{\$([\w-]+)\}/g)){const m=e.slice(u,p.index);m&&(a.push({text:m}),l+=ad(m)),a.push({name:p[1]??p[2]??"param"}),l+="[^/]+?",u=(p.index??0)+p[0].length}const c=e.slice(u);if(c&&(a.push({text:c}),l+=ad(c)),a.some(p=>"name"in p))return{kind:"mixed",pattern:l,parts:a}}return{kind:"static",text:e}}function WO(e){const t=e.split("/").filter(Boolean).map(_x);if(t.every(r=>r.kind==="static"))return null;let n="";for(const r of t)r.kind==="static"?n+=`/${ad(r.text)}`:r.kind==="optional-static"?n+=`(?:/${ad(r.text)})?`:r.kind==="param"?n+="/[^/]+":r.kind==="optional"?n+="(?:/[^/]+)?":r.kind==="splat"?n+=r.min?"/.+":"(?:/.*)?":n+=`/${r.pattern}`;return{path:e,re:new RegExp(`^${n}$`),specificity:t.reduce((r,o)=>r+HO[o.kind],0),statics:t.filter(r=>r.kind==="static").length}}function KO(e,t){let n=null;for(const r of e)r.statics===0||!r.re.test(t)||(!n||r.specificity>n.specificity)&&(n=r);return n}function Dd(e){let t="";const n=[],r=o=>{n.push([t.length,t.length+o.length]),t+=o};for(const o of e.split("/").filter(Boolean).map(_x))if(t+="/",o.kind==="static"||o.kind==="optional-static")t+=o.text;else if(o.kind==="mixed")for(const a of o.parts)"name"in a?r(a.name):t+=a.text;else r(o.name);return t||(t="/"),{text:t,params:n,literal:n.length>0?t.slice(0,n[0][0]):t}}const dc={id:"toyon-dark",family:"Toyon",name:"Toyon Dark",kind:"dark",source:"builtin",pair:"toyon-light",colors:{surface0:"#32302d",surface1:"#3d3835",surface2:"#504943",element0:"#504943",element1:"#675c55",border0:"#504943",border1:"#675c55",text0:"#e6dcb6",text1:"#9e927e",text2:"#6a6055",red:"#ff4929",orange:"#fa891e",yellow:"#fcbe03",green:"#78c945",aqua:"#4dc7a7",blue:"#69a9e8",purple:"#ca94ca",diffAdd:"#6fae5f29",diffDel:"#c07f6a29"},syntax:{comment:"#6a6055",keyword:"#df714e",string:"#a5bd4d",number:"#ca94ca",type:"#f5bf3a",function:"#6bc198",variable:"#81a99d"}},Ex={id:"toyon-light",family:"Toyon",name:"Toyon Light",kind:"light",source:"builtin",pair:"toyon-dark",colors:{surface0:"#f8f2e8",surface1:"#efe8dc",surface2:"#dfd7c9",element0:"#dfd7c9",element1:"#c7bdac",border0:"#dfd7c9",border1:"#c7bdac",text0:"#463627",text1:"#6e5e51",text2:"#b4aa9f",red:"#b02e15",orange:"#b15b02",yellow:"#ac7e02",green:"#3c8c03",aqua:"#01775c",blue:"#12689e",purple:"#865889",diffAdd:"#4f7a3d2e",diffDel:"#9c5a452e"},syntax:{comment:"#b4aa9f",keyword:"#b54d2d",string:"#697f1e",number:"#865889",type:"#ac7e02",function:"#397f5f",variable:"#57796f"}},ZO={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"}},qO={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"}},GO={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"}},VO={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"}},YO={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"}},QO={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"}},XO={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"}},JO={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"}},e$={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"}},t$={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"}},n$={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"}},r$={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"}},o$={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"}},s$={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"}},i$={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"}},a$={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"}},l$={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"}},c$=[XO,JO,e$,t$,n$,r$,o$,s$,i$,a$,l$],Zu=[dc,Ex,ZO,qO,GO,VO,YO,QO,...c$],u$={mode:"dark",light:Ex.id,dark:dc.id},d$=["surface0","surface1","surface2","element0","element1","border0","border1","text0","text1","text2","red","orange","yellow","green","aqua","blue","purple","diffAdd","diffDel"];function f$(e){return`--${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function Yw(e){const t=Tx(e);return t>.008856?116*t**(1/3)-16:903.3*t}function Sx(e,t){const n=Yw(e)+t,r=Ci(e);if(!r)return e;let o=0,a=2;for(let l=0;l<24;l++){const u=(o+a)/2,c=Ta(Math.min(255,r[0]*u),Math.min(255,r[1]*u),Math.min(255,r[2]*u));Yw(c)<n?o=u:a=u}return Ta(Math.min(255,r[0]*o),Math.min(255,r[1]*o),Math.min(255,r[2]*o))}function p$(e){return Sx(e.colors.surface1,-4)}function h$(e){return Sx(e.colors.surface0,-4)}function Qw(e){return _$(e,.55)}function m$(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 g$(e){const t={};for(const n of d$)t[f$(n)]=e.colors[n];t["--ink0"]=e.colors.text0,t["--ink1"]=e.colors.text1,t["--ink2"]=e.colors.text2;for(const[n,r]of Object.entries(m$(e)))t[`--syntax-${n}`]=r;return t["--accent"]=Lm(e),t["--fault"]=k$(e),t["--sunken"]=p$(e),t["--sunken-floor"]=h$(e),t["--scrim"]=x$(e.colors.surface0,.7),t["--shadow"]=e.kind==="dark"?"#00000066":"#0000002e",t["--diff-add-word"]=Qw(e.colors.diffAdd),t["--diff-del-word"]=Qw(e.colors.diffDel),t}function Lm(e){return Nx(e.accent??"")??e.colors.orange}function k$(e){return Lm(e)===Nx(e.colors.orange)?e.colors.red:e.colors.orange}function y$(e){return e==="system"||e==="daylight"}function Pm(e,t){return e.mode==="system"?t.system?"dark":"light":e.mode==="daylight"?t.daylight?"dark":"light":e.mode}function zd(e,t,n){const r=Pm(e,n);return t.find(o=>o.id===e[r])??Zu.find(o=>o.kind===r)??dc}function w$(e,t){if(e.pair){const l=t.find(u=>u.id===e.pair);if(l&&l.kind!==e.kind)return l}const n=e.kind==="dark"?"light":"dark",r=l=>l.toLowerCase().replace(/\b(dark|light)\b/g,"*").replace(/\s+/g," ").trim(),o=r(e.name);if(!o.includes("*"))return null;const a=e.id.startsWith("vscode:")?e.id.slice(0,e.id.lastIndexOf(":")+1):null;return t.find(l=>l.kind===n&&l.source===e.source&&(!a||l.id.startsWith(a))&&r(l.name)===o)??null}function v$(e){const t=[],n=new Set,r=o=>o.family??(o.name.replace(/\b(dark|light)\b/gi,"").replace(/\s+/g," ").trim()||o.name);for(const o of e){if(n.has(o.id))continue;const a=w$(o,e),l={name:r(o)};l[o.kind]=o,n.add(o.id),a&&(l[a.kind]=a,n.add(a.id)),t.push(l)}return t}function b$(e,t){const n={...e};return t.dark&&(n.dark=t.dark.id),t.light&&(n.light=t.light.id),!y$(n.mode)&&!t[n.mode]&&(n.mode=t.dark?"dark":"light"),n}function Ci(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());if(!t)return null;let n=t[1];if((n.length===3||n.length===4)&&(n=[...n].map(o=>o+o).join("")),n.length!==6&&n.length!==8)return null;const r=o=>parseInt(n.slice(o,o+2),16);return[r(0),r(2),r(4),n.length===8?r(6)/255:1]}function Nx(e){const t=Ci(e);return t?Ta(t[0],t[1],t[2],t[3]):null}function Ta(e,t,n,r=1){const o=a=>Math.round(Math.max(0,Math.min(255,a))).toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}${r>=1?"":o(r*255)}`}function x$(e,t){const n=Ci(e);return n?Ta(n[0],n[1],n[2],t):e}function _$(e,t){const n=Ci(e);return n?Ta(n[0],n[1],n[2],Math.min(1,n[3]*t)):e}function bB(e,t){const n=Ci(e),r=Ci(t);if(!n||!r)return e;const o=n[3];return Ta(n[0]*o+r[0]*(1-o),n[1]*o+r[1]*(1-o),n[2]*o+r[2]*(1-o))}function Tx(e){const t=Ci(e);if(!t)return 0;const n=r=>{const o=r/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}function E$(e){return Tx(e)>.179?"#1d2021":"#fbf1c7"}function Ah(e){if(e===null||e==="")return"the npm registry";try{return new URL(e).host}catch{return e}}function S$(e,t){const n=Xw(e),r=Xw(t);if(!n||!r)return!1;for(let o=0;o<3;o++){const a=n.nums[o]??0,l=r.nums[o]??0;if(a!==l)return a>l}return n.pre===r.pre?!1:n.pre===null?!0:r.pre===null?!1:n.pre>r.pre}function Xw(e){const t=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(e.trim());return t?{nums:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]??null}:null}const N$=[[/\.(png|jpe?g|gif|webp|avif|bmp|ico)$/i,"image"]];function T$(e){var t;return((t=N$.find(([n])=>n.test(e)))==null?void 0:t[1])??null}const j$=[[/\.(md|markdown)$/i,"markdown"],[/\.html?$/i,"html"]];function Fd(e){var t;return((t=j$.find(([n])=>n.test(e)))==null?void 0:t[1])??null}var S=vm();const C$=wb(S);var Tu={},Wp={exports:{}},Hr={},Kp={exports:{}},Zp={};/**
75
+ * @license React
76
+ * scheduler.production.min.js
77
+ *
78
+ * Copyright (c) Facebook, Inc. and its affiliates.
79
+ *
80
+ * This source code is licensed under the MIT license found in the
81
+ * LICENSE file in the root directory of this source tree.
82
+ */var Jw;function A$(){return Jw||(Jw=1,(function(e){function t(A,X){var Z=A.length;A.push(X);e:for(;0<Z;){var $=Z-1>>>1,V=A[$];if(0<o(V,X))A[$]=X,A[Z]=V,Z=$;else break e}}function n(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var X=A[0],Z=A.pop();if(Z!==X){A[0]=Z;e:for(var $=0,V=A.length,de=V>>>1;$<de;){var me=2*($+1)-1,he=A[me],$e=me+1,ae=A[$e];if(0>o(he,Z))$e<V&&0>o(ae,he)?(A[$]=ae,A[$e]=Z,$=$e):(A[$]=he,A[me]=Z,$=me);else if($e<V&&0>o(ae,Z))A[$]=ae,A[$e]=Z,$=$e;else break e}}return X}function o(A,X){var Z=A.sortIndex-X.sortIndex;return Z!==0?Z:A.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var c=[],p=[],m=1,h=null,k=3,y=!1,v=!1,x=!1,_=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(A){for(var X=n(p);X!==null;){if(X.callback===null)r(p);else if(X.startTime<=A)r(p),X.sortIndex=X.expirationTime,t(c,X);else break;X=n(p)}}function M(A){if(x=!1,E(A),!v)if(n(c)!==null)v=!0,xe(K);else{var X=n(p);X!==null&&oe(M,X.startTime-A)}}function K(A,X){v=!1,x&&(x=!1,N(I),I=-1),y=!0;var Z=k;try{for(E(X),h=n(c);h!==null&&(!(h.expirationTime>X)||A&&!z());){var $=h.callback;if(typeof $=="function"){h.callback=null,k=h.priorityLevel;var V=$(h.expirationTime<=X);X=e.unstable_now(),typeof V=="function"?h.callback=V:h===n(c)&&r(c),E(X)}else r(c);h=n(c)}if(h!==null)var de=!0;else{var me=n(p);me!==null&&oe(M,me.startTime-X),de=!1}return de}finally{h=null,k=Z,y=!1}}var U=!1,R=null,I=-1,C=5,P=-1;function z(){return!(e.unstable_now()-P<C)}function q(){if(R!==null){var A=e.unstable_now();P=A;var X=!0;try{X=R(!0,A)}finally{X?se():(U=!1,R=null)}}else U=!1}var se;if(typeof j=="function")se=function(){j(q)};else if(typeof MessageChannel<"u"){var pe=new MessageChannel,ue=pe.port2;pe.port1.onmessage=q,se=function(){ue.postMessage(null)}}else se=function(){_(q,0)};function xe(A){R=A,U||(U=!0,se())}function oe(A,X){I=_(function(){A(e.unstable_now())},X)}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(A){A.callback=null},e.unstable_continueExecution=function(){v||y||(v=!0,xe(K))},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return k},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(A){switch(k){case 1:case 2:case 3:var X=3;break;default:X=k}var Z=k;k=X;try{return A()}finally{k=Z}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,X){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var Z=k;k=A;try{return X()}finally{k=Z}},e.unstable_scheduleCallback=function(A,X,Z){var $=e.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?$+Z:$):Z=$,A){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=Z+V,A={id:m++,callback:X,priorityLevel:A,startTime:Z,expirationTime:V,sortIndex:-1},Z>$?(A.sortIndex=Z,t(p,A),n(c)===null&&A===n(p)&&(x?(N(I),I=-1):x=!0,oe(M,Z-$))):(A.sortIndex=V,t(c,A),v||y||(v=!0,xe(K))),A},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(A){var X=k;return function(){var Z=k;k=X;try{return A.apply(this,arguments)}finally{k=Z}}}})(Zp)),Zp}var ev;function I$(){return ev||(ev=1,Kp.exports=A$()),Kp.exports}/**
83
+ * @license React
84
+ * react-dom.production.min.js
85
+ *
86
+ * Copyright (c) Facebook, Inc. and its affiliates.
87
+ *
88
+ * This source code is licensed under the MIT license found in the
89
+ * LICENSE file in the root directory of this source tree.
90
+ */var tv;function R$(){if(tv)return Hr;tv=1;var e=vm(),t=I$();function n(s){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+s,d=1;d<arguments.length;d++)i+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+s+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function a(s,i){l(s,i),l(s+"Capture",i)}function l(s,i){for(o[s]=i,s=0;s<i.length;s++)r.add(i[s])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),c=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={},h={};function k(s){return c.call(h,s)?!0:c.call(m,s)?!1:p.test(s)?h[s]=!0:(m[s]=!0,!1)}function y(s,i,d,g){if(d!==null&&d.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return g?!1:d!==null?!d.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function v(s,i,d,g){if(i===null||typeof i>"u"||y(s,i,d,g))return!0;if(g)return!1;if(d!==null)switch(d.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 x(s,i,d,g,w,b,T){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=g,this.attributeNamespace=w,this.mustUseProperty=d,this.propertyName=s,this.type=i,this.sanitizeURL=b,this.removeEmptyString=T}var _={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){_[s]=new x(s,0,!1,s,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var i=s[0];_[i]=new x(i,1,!1,s[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(s){_[s]=new x(s,2,!1,s.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){_[s]=new x(s,2,!1,s,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(s){_[s]=new x(s,3,!1,s.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(s){_[s]=new x(s,3,!0,s,null,!1,!1)}),["capture","download"].forEach(function(s){_[s]=new x(s,4,!1,s,null,!1,!1)}),["cols","rows","size","span"].forEach(function(s){_[s]=new x(s,6,!1,s,null,!1,!1)}),["rowSpan","start"].forEach(function(s){_[s]=new x(s,5,!1,s.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function j(s){return s[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(s){var i=s.replace(N,j);_[i]=new x(i,1,!1,s,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s){var i=s.replace(N,j);_[i]=new x(i,1,!1,s,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(s){var i=s.replace(N,j);_[i]=new x(i,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(s){_[s]=new x(s,1,!1,s.toLowerCase(),null,!1,!1)}),_.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(s){_[s]=new x(s,1,!1,s.toLowerCase(),null,!0,!0)});function E(s,i,d,g){var w=_.hasOwnProperty(i)?_[i]:null;(w!==null?w.type!==0:g||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(v(i,d,w,g)&&(d=null),g||w===null?k(i)&&(d===null?s.removeAttribute(i):s.setAttribute(i,""+d)):w.mustUseProperty?s[w.propertyName]=d===null?w.type===3?!1:"":d:(i=w.attributeName,g=w.attributeNamespace,d===null?s.removeAttribute(i):(w=w.type,d=w===3||w===4&&d===!0?"":""+d,g?s.setAttributeNS(g,i,d):s.setAttribute(i,d))))}var M=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,K=Symbol.for("react.element"),U=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),z=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),pe=Symbol.for("react.suspense_list"),ue=Symbol.for("react.memo"),xe=Symbol.for("react.lazy"),oe=Symbol.for("react.offscreen"),A=Symbol.iterator;function X(s){return s===null||typeof s!="object"?null:(s=A&&s[A]||s["@@iterator"],typeof s=="function"?s:null)}var Z=Object.assign,$;function V(s){if($===void 0)try{throw Error()}catch(d){var i=d.stack.trim().match(/\n( *(at )?)/);$=i&&i[1]||""}return`
91
+ `+$+s}var de=!1;function me(s,i){if(!s||de)return"";de=!0;var d=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(le){var g=le}Reflect.construct(s,[],i)}else{try{i.call()}catch(le){g=le}s.call(i.prototype)}else{try{throw Error()}catch(le){g=le}s()}}catch(le){if(le&&g&&typeof le.stack=="string"){for(var w=le.stack.split(`
92
+ `),b=g.stack.split(`
93
+ `),T=w.length-1,F=b.length-1;1<=T&&0<=F&&w[T]!==b[F];)F--;for(;1<=T&&0<=F;T--,F--)if(w[T]!==b[F]){if(T!==1||F!==1)do if(T--,F--,0>F||w[T]!==b[F]){var G=`
94
+ `+w[T].replace(" at new "," at ");return s.displayName&&G.includes("<anonymous>")&&(G=G.replace("<anonymous>",s.displayName)),G}while(1<=T&&0<=F);break}}}finally{de=!1,Error.prepareStackTrace=d}return(s=s?s.displayName||s.name:"")?V(s):""}function he(s){switch(s.tag){case 5:return V(s.type);case 16:return V("Lazy");case 13:return V("Suspense");case 19:return V("SuspenseList");case 0:case 2:case 15:return s=me(s.type,!1),s;case 11:return s=me(s.type.render,!1),s;case 1:return s=me(s.type,!0),s;default:return""}}function $e(s){if(s==null)return null;if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case R:return"Fragment";case U:return"Portal";case C:return"Profiler";case I:return"StrictMode";case se:return"Suspense";case pe:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case z:return(s.displayName||"Context")+".Consumer";case P:return(s._context.displayName||"Context")+".Provider";case q:var i=s.render;return s=s.displayName,s||(s=i.displayName||i.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case ue:return i=s.displayName||null,i!==null?i:$e(s.type)||"Memo";case xe:i=s._payload,s=s._init;try{return $e(s(i))}catch{}}return null}function ae(s){var i=s.type;switch(s.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 s=i.render,s=s.displayName||s.name||"",i.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return $e(i);case 8:return i===I?"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 ve(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function Re(s){var i=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function ee(s){var i=Re(s)?"checked":"value",d=Object.getOwnPropertyDescriptor(s.constructor.prototype,i),g=""+s[i];if(!s.hasOwnProperty(i)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var w=d.get,b=d.set;return Object.defineProperty(s,i,{configurable:!0,get:function(){return w.call(this)},set:function(T){g=""+T,b.call(this,T)}}),Object.defineProperty(s,i,{enumerable:d.enumerable}),{getValue:function(){return g},setValue:function(T){g=""+T},stopTracking:function(){s._valueTracker=null,delete s[i]}}}}function Y(s){s._valueTracker||(s._valueTracker=ee(s))}function Pe(s){if(!s)return!1;var i=s._valueTracker;if(!i)return!0;var d=i.getValue(),g="";return s&&(g=Re(s)?s.checked?"true":"false":s.value),s=g,s!==d?(i.setValue(s),!0):!1}function We(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function Fe(s,i){var d=i.checked;return Z({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??s._wrapperState.initialChecked})}function pt(s,i){var d=i.defaultValue==null?"":i.defaultValue,g=i.checked!=null?i.checked:i.defaultChecked;d=ve(i.value!=null?i.value:d),s._wrapperState={initialChecked:g,initialValue:d,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function Ge(s,i){i=i.checked,i!=null&&E(s,"checked",i,!1)}function vt(s,i){Ge(s,i);var d=ve(i.value),g=i.type;if(d!=null)g==="number"?(d===0&&s.value===""||s.value!=d)&&(s.value=""+d):s.value!==""+d&&(s.value=""+d);else if(g==="submit"||g==="reset"){s.removeAttribute("value");return}i.hasOwnProperty("value")?qt(s,i.type,d):i.hasOwnProperty("defaultValue")&&qt(s,i.type,ve(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(s.defaultChecked=!!i.defaultChecked)}function at(s,i,d){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var g=i.type;if(!(g!=="submit"&&g!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+s._wrapperState.initialValue,d||i===s.value||(s.value=i),s.defaultValue=i}d=s.name,d!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,d!==""&&(s.name=d)}function qt(s,i,d){(i!=="number"||We(s.ownerDocument)!==s)&&(d==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+d&&(s.defaultValue=""+d))}var an=Array.isArray;function qe(s,i,d,g){if(s=s.options,i){i={};for(var w=0;w<d.length;w++)i["$"+d[w]]=!0;for(d=0;d<s.length;d++)w=i.hasOwnProperty("$"+s[d].value),s[d].selected!==w&&(s[d].selected=w),w&&g&&(s[d].defaultSelected=!0)}else{for(d=""+ve(d),i=null,w=0;w<s.length;w++){if(s[w].value===d){s[w].selected=!0,g&&(s[w].defaultSelected=!0);return}i!==null||s[w].disabled||(i=s[w])}i!==null&&(i.selected=!0)}}function J(s,i){if(i.dangerouslySetInnerHTML!=null)throw Error(n(91));return Z({},i,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function we(s,i){var d=i.value;if(d==null){if(d=i.children,i=i.defaultValue,d!=null){if(i!=null)throw Error(n(92));if(an(d)){if(1<d.length)throw Error(n(93));d=d[0]}i=d}i==null&&(i=""),d=i}s._wrapperState={initialValue:ve(d)}}function Xe(s,i){var d=ve(i.value),g=ve(i.defaultValue);d!=null&&(d=""+d,d!==s.value&&(s.value=d),i.defaultValue==null&&s.defaultValue!==d&&(s.defaultValue=d)),g!=null&&(s.defaultValue=""+g)}function et(s){var i=s.textContent;i===s._wrapperState.initialValue&&i!==""&&i!==null&&(s.value=i)}function Wt(s){switch(s){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Qt(s,i){return s==null||s==="http://www.w3.org/1999/xhtml"?Wt(i):s==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var ge,Me=(function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,d,g,w){MSApp.execUnsafeLocalFunction(function(){return s(i,d,g,w)})}:s})(function(s,i){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=i;else{for(ge=ge||document.createElement("div"),ge.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=ge.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;i.firstChild;)s.appendChild(i.firstChild)}});function hn(s,i){if(i){var d=s.firstChild;if(d&&d===s.lastChild&&d.nodeType===3){d.nodeValue=i;return}}s.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(s){Rt.forEach(function(i){i=i+s.charAt(0).toUpperCase()+s.substring(1),It[i]=It[s]})});function In(s,i,d){return i==null||typeof i=="boolean"||i===""?"":d||typeof i!="number"||i===0||It.hasOwnProperty(s)&&It[s]?(""+i).trim():i+"px"}function Dt(s,i){s=s.style;for(var d in i)if(i.hasOwnProperty(d)){var g=d.indexOf("--")===0,w=In(d,i[d],g);d==="float"&&(d="cssFloat"),g?s.setProperty(d,w):s[d]=w}}var gn=Z({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 kt(s,i){if(i){if(gn[s]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(n(137,s));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 Gt(s,i){if(s.indexOf("-")===-1)return typeof i.is=="string";switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var tn=null;function nn(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var Un=null,_t=null,Kt=null;function Rn(s){if(s=ol(s)){if(typeof Un!="function")throw Error(n(280));var i=s.stateNode;i&&(i=Pc(i),Un(s.stateNode,s.type,i))}}function H(s){_t?Kt?Kt.push(s):Kt=[s]:_t=s}function fe(){if(_t){var s=_t,i=Kt;if(Kt=_t=null,Rn(s),i)for(s=0;s<i.length;s++)Rn(i[s])}}function Ie(s,i){return s(i)}function rt(){}var te=!1;function Ne(s,i,d){if(te)return s(i,d);te=!0;try{return Ie(s,i,d)}finally{te=!1,(_t!==null||Kt!==null)&&(rt(),fe())}}function be(s,i){var d=s.stateNode;if(d===null)return null;var g=Pc(d);if(g===null)return null;d=g[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":(g=!g.disabled)||(s=s.type,g=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!g;break e;default:s=!1}if(s)return null;if(d&&typeof d!="function")throw Error(n(231,i,typeof d));return d}var _e=!1;if(u)try{var Oe={};Object.defineProperty(Oe,"passive",{get:function(){_e=!0}}),window.addEventListener("test",Oe,Oe),window.removeEventListener("test",Oe,Oe)}catch{_e=!1}function Mt(s,i,d,g,w,b,T,F,G){var le=Array.prototype.slice.call(arguments,3);try{i.apply(d,le)}catch(Te){this.onError(Te)}}var Tt=!1,ht=null,wn=!1,Ke=null,Kn={onError:function(s){Tt=!0,ht=s}};function Nt(s,i,d,g,w,b,T,F,G){Tt=!1,ht=null,Mt.apply(Kn,arguments)}function Sn(s,i,d,g,w,b,T,F,G){if(Nt.apply(this,arguments),Tt){if(Tt){var le=ht;Tt=!1,ht=null}else throw Error(n(198));wn||(wn=!0,Ke=le)}}function Nn(s){var i=s,d=s;if(s.alternate)for(;i.return;)i=i.return;else{s=i;do i=s,(i.flags&4098)!==0&&(d=i.return),s=i.return;while(s)}return i.tag===3?d:null}function Hn(s){if(s.tag===13){var i=s.memoizedState;if(i===null&&(s=s.alternate,s!==null&&(i=s.memoizedState)),i!==null)return i.dehydrated}return null}function Lt(s){if(Nn(s)!==s)throw Error(n(188))}function Xt(s){var i=s.alternate;if(!i){if(i=Nn(s),i===null)throw Error(n(188));return i!==s?null:s}for(var d=s,g=i;;){var w=d.return;if(w===null)break;var b=w.alternate;if(b===null){if(g=w.return,g!==null){d=g;continue}break}if(w.child===b.child){for(b=w.child;b;){if(b===d)return Lt(w),s;if(b===g)return Lt(w),i;b=b.sibling}throw Error(n(188))}if(d.return!==g.return)d=w,g=b;else{for(var T=!1,F=w.child;F;){if(F===d){T=!0,d=w,g=b;break}if(F===g){T=!0,g=w,d=b;break}F=F.sibling}if(!T){for(F=b.child;F;){if(F===d){T=!0,d=b,g=w;break}if(F===g){T=!0,g=b,d=w;break}F=F.sibling}if(!T)throw Error(n(189))}}if(d.alternate!==g)throw Error(n(190))}if(d.tag!==3)throw Error(n(188));return d.stateNode.current===d?s:i}function mn(s){return s=Xt(s),s!==null?Gn(s):null}function Gn(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var i=Gn(s);if(i!==null)return i;s=s.sibling}return null}var On=t.unstable_scheduleCallback,sr=t.unstable_cancelCallback,Mr=t.unstable_shouldYield,wo=t.unstable_requestPaint,on=t.unstable_now,Do=t.unstable_getCurrentPriorityLevel,so=t.unstable_ImmediatePriority,Zn=t.unstable_UserBlockingPriority,Vn=t.unstable_NormalPriority,je=t.unstable_LowPriority,Be=t.unstable_IdlePriority,yt=null,xt=null;function ln(s){if(xt&&typeof xt.onCommitFiberRoot=="function")try{xt.onCommitFiberRoot(yt,s,void 0,(s.current.flags&128)===128)}catch{}}var ot=Math.clz32?Math.clz32:De,B=Math.log,ce=Math.LN2;function De(s){return s>>>=0,s===0?32:31-(B(s)/ce|0)|0}var lt=64,ut=4194304;function Bt(s){switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return s&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return s}}function kn(s,i){var d=s.pendingLanes;if(d===0)return 0;var g=0,w=s.suspendedLanes,b=s.pingedLanes,T=d&268435455;if(T!==0){var F=T&~w;F!==0?g=Bt(F):(b&=T,b!==0&&(g=Bt(b)))}else T=d&~w,T!==0?g=Bt(T):b!==0&&(g=Bt(b));if(g===0)return 0;if(i!==0&&i!==g&&(i&w)===0&&(w=g&-g,b=i&-i,w>=b||w===16&&(b&4194240)!==0))return i;if((g&4)!==0&&(g|=d&16),i=s.entangledLanes,i!==0)for(s=s.entanglements,i&=g;0<i;)d=31-ot(i),w=1<<d,g|=s[d],i&=~w;return g}function vn(s,i){switch(s){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 Lr(s,i){for(var d=s.suspendedLanes,g=s.pingedLanes,w=s.expirationTimes,b=s.pendingLanes;0<b;){var T=31-ot(b),F=1<<T,G=w[T];G===-1?((F&d)===0||(F&g)!==0)&&(w[T]=vn(F,i)):G<=i&&(s.expiredLanes|=F),b&=~F}}function Vr(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function vo(){var s=lt;return lt<<=1,(lt&4194240)===0&&(lt=64),s}function wr(s){for(var i=[],d=0;31>d;d++)i.push(s);return i}function Pr(s,i,d){s.pendingLanes|=i,i!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,i=31-ot(i),s[i]=d}function Yn(s,i){var d=s.pendingLanes&~i;s.pendingLanes=i,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=i,s.mutableReadLanes&=i,s.entangledLanes&=i,i=s.entanglements;var g=s.eventTimes;for(s=s.expirationTimes;0<d;){var w=31-ot(d),b=1<<w;i[w]=0,g[w]=-1,s[w]=-1,d&=~b}}function bo(s,i){var d=s.entangledLanes|=i;for(s=s.entanglements;d;){var g=31-ot(d),w=1<<g;w&i|s[g]&i&&(s[g]|=i),d&=~w}}var Pt=0;function tt(s){return s&=-s,1<s?4<s?(s&268435455)!==0?16:536870912:4:1}var es,bn,Ut,vr,Qn,Ee=!1,O=[],D=null,ne=null,ke=null,Ce=new Map,Ue=new Map,wt=[],cn="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 Vt(s,i){switch(s){case"focusin":case"focusout":D=null;break;case"dragenter":case"dragleave":ne=null;break;case"mouseover":case"mouseout":ke=null;break;case"pointerover":case"pointerout":Ce.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ue.delete(i.pointerId)}}function Tn(s,i,d,g,w,b){return s===null||s.nativeEvent!==b?(s={blockedOn:i,domEventName:d,eventSystemFlags:g,nativeEvent:b,targetContainers:[w]},i!==null&&(i=ol(i),i!==null&&bn(i)),s):(s.eventSystemFlags|=g,i=s.targetContainers,w!==null&&i.indexOf(w)===-1&&i.push(w),s)}function ts(s,i,d,g,w){switch(i){case"focusin":return D=Tn(D,s,i,d,g,w),!0;case"dragenter":return ne=Tn(ne,s,i,d,g,w),!0;case"mouseover":return ke=Tn(ke,s,i,d,g,w),!0;case"pointerover":var b=w.pointerId;return Ce.set(b,Tn(Ce.get(b)||null,s,i,d,g,w)),!0;case"gotpointercapture":return b=w.pointerId,Ue.set(b,Tn(Ue.get(b)||null,s,i,d,g,w)),!0}return!1}function $n(s){var i=si(s.target);if(i!==null){var d=Nn(i);if(d!==null){if(i=d.tag,i===13){if(i=Hn(d),i!==null){s.blockedOn=i,Qn(s.priority,function(){Ut(d)});return}}else if(i===3&&d.stateNode.current.memoizedState.isDehydrated){s.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Mn(s){if(s.blockedOn!==null)return!1;for(var i=s.targetContainers;0<i.length;){var d=Pi(s.domEventName,s.eventSystemFlags,i[0],s.nativeEvent);if(d===null){d=s.nativeEvent;var g=new d.constructor(d.type,d);tn=g,d.target.dispatchEvent(g),tn=null}else return i=ol(d),i!==null&&bn(i),s.blockedOn=d,!1;i.shift()}return!0}function Xs(s,i,d){Mn(s)&&d.delete(i)}function Ha(){Ee=!1,D!==null&&Mn(D)&&(D=null),ne!==null&&Mn(ne)&&(ne=null),ke!==null&&Mn(ke)&&(ke=null),Ce.forEach(Xs),Ue.forEach(Xs)}function zo(s,i){s.blockedOn===i&&(s.blockedOn=null,Ee||(Ee=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Ha)))}function Fo(s){function i(w){return zo(w,s)}if(0<O.length){zo(O[0],s);for(var d=1;d<O.length;d++){var g=O[d];g.blockedOn===s&&(g.blockedOn=null)}}for(D!==null&&zo(D,s),ne!==null&&zo(ne,s),ke!==null&&zo(ke,s),Ce.forEach(i),Ue.forEach(i),d=0;d<wt.length;d++)g=wt[d],g.blockedOn===s&&(g.blockedOn=null);for(;0<wt.length&&(d=wt[0],d.blockedOn===null);)$n(d),d.blockedOn===null&&wt.shift()}var Yr=M.ReactCurrentBatchConfig,Js=!0;function Wa(s,i,d,g){var w=Pt,b=Yr.transition;Yr.transition=null;try{Pt=1,Li(s,i,d,g)}finally{Pt=w,Yr.transition=b}}function Ka(s,i,d,g){var w=Pt,b=Yr.transition;Yr.transition=null;try{Pt=4,Li(s,i,d,g)}finally{Pt=w,Yr.transition=b}}function Li(s,i,d,g){if(Js){var w=Pi(s,i,d,g);if(w===null)_f(s,i,g,Za,d),Vt(s,g);else if(ts(w,s,i,d,g))g.stopPropagation();else if(Vt(s,g),i&4&&-1<cn.indexOf(s)){for(;w!==null;){var b=ol(w);if(b!==null&&es(b),b=Pi(s,i,d,g),b===null&&_f(s,i,g,Za,d),b===w)break;w=b}w!==null&&g.stopPropagation()}else _f(s,i,g,null,d)}}var Za=null;function Pi(s,i,d,g){if(Za=null,s=nn(g),s=si(s),s!==null)if(i=Nn(s),i===null)s=null;else if(d=i.tag,d===13){if(s=Hn(i),s!==null)return s;s=null}else if(d===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;s=null}else i!==s&&(s=null);return Za=s,null}function ei(s){switch(s){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Do()){case so:return 1;case Zn:return 4;case Vn:case je:return 16;case Be:return 536870912;default:return 16}default:return 16}}var xo=null,Di=null,ti=null;function ir(){if(ti)return ti;var s,i=Di,d=i.length,g,w="value"in xo?xo.value:xo.textContent,b=w.length;for(s=0;s<d&&i[s]===w[s];s++);var T=d-s;for(g=1;g<=T&&i[d-g]===w[b-g];g++);return ti=w.slice(s,1<g?1-g:void 0)}function zi(s){var i=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&i===13&&(s=13)):s=i,s===10&&(s=13),32<=s||s===13?s:0}function ys(){return!0}function Fi(){return!1}function gr(s){function i(d,g,w,b,T){this._reactName=d,this._targetInst=w,this.type=g,this.nativeEvent=b,this.target=T,this.currentTarget=null;for(var F in s)s.hasOwnProperty(F)&&(d=s[F],this[F]=d?d(b):b[F]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?ys:Fi,this.isPropagationStopped=Fi,this}return Z(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=ys)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=ys)},persist:function(){},isPersistent:ys}),i}var ws={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ni=gr(ws),ri=Z({},ws,{view:0,detail:0}),bc=gr(ri),Bi,qa,oi,Ui=Z({},ri,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:xn,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==oi&&(oi&&s.type==="mousemove"?(Bi=s.screenX-oi.screenX,qa=s.screenY-oi.screenY):qa=Bi=0,oi=s),Bi)},movementY:function(s){return"movementY"in s?s.movementY:qa}}),Hi=gr(Ui),xc=Z({},Ui,{dataTransfer:0}),uf=gr(xc),df=Z({},ri,{relatedTarget:0}),Wi=gr(df),_c=Z({},ws,{animationName:0,elapsedTime:0,pseudoElement:0}),Ec=gr(_c),Sc=Z({},ws,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),Nc=gr(Sc),Tc=Z({},ws,{data:0}),Ga=gr(Tc),jc={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},W={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"},Ve={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ht(s){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(s):(s=Ve[s])?!!i[s]:!1}function xn(){return Ht}var ar=Z({},ri,{key:function(s){if(s.key){var i=jc[s.key]||s.key;if(i!=="Unidentified")return i}return s.type==="keypress"?(s=zi(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?W[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:xn,charCode:function(s){return s.type==="keypress"?zi(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?zi(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Bo=gr(ar),ff=Z({},Ui,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Cc=gr(ff),LS=Z({},ri,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:xn}),PS=gr(LS),DS=Z({},ws,{propertyName:0,elapsedTime:0,pseudoElement:0}),zS=gr(DS),FS=Z({},Ui,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),BS=gr(FS),US=[9,13,27,32],pf=u&&"CompositionEvent"in window,Va=null;u&&"documentMode"in document&&(Va=document.documentMode);var HS=u&&"TextEvent"in window&&!Va,Zg=u&&(!pf||Va&&8<Va&&11>=Va),qg=" ",Gg=!1;function Vg(s,i){switch(s){case"keyup":return US.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yg(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Ki=!1;function WS(s,i){switch(s){case"compositionend":return Yg(i);case"keypress":return i.which!==32?null:(Gg=!0,qg);case"textInput":return s=i.data,s===qg&&Gg?null:s;default:return null}}function KS(s,i){if(Ki)return s==="compositionend"||!pf&&Vg(s,i)?(s=ir(),ti=Di=xo=null,Ki=!1,s):null;switch(s){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 Zg&&i.locale!=="ko"?null:i.data;default:return null}}var ZS={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 Qg(s){var i=s&&s.nodeName&&s.nodeName.toLowerCase();return i==="input"?!!ZS[s.type]:i==="textarea"}function Xg(s,i,d,g){H(g),i=$c(i,"onChange"),0<i.length&&(d=new ni("onChange","change",null,d,g),s.push({event:d,listeners:i}))}var Ya=null,Qa=null;function qS(s){gk(s,0)}function Ac(s){var i=Yi(s);if(Pe(i))return s}function GS(s,i){if(s==="change")return i}var Jg=!1;if(u){var hf;if(u){var mf="oninput"in document;if(!mf){var ek=document.createElement("div");ek.setAttribute("oninput","return;"),mf=typeof ek.oninput=="function"}hf=mf}else hf=!1;Jg=hf&&(!document.documentMode||9<document.documentMode)}function tk(){Ya&&(Ya.detachEvent("onpropertychange",nk),Qa=Ya=null)}function nk(s){if(s.propertyName==="value"&&Ac(Qa)){var i=[];Xg(i,Qa,s,nn(s)),Ne(qS,i)}}function VS(s,i,d){s==="focusin"?(tk(),Ya=i,Qa=d,Ya.attachEvent("onpropertychange",nk)):s==="focusout"&&tk()}function YS(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Ac(Qa)}function QS(s,i){if(s==="click")return Ac(i)}function XS(s,i){if(s==="input"||s==="change")return Ac(i)}function JS(s,i){return s===i&&(s!==0||1/s===1/i)||s!==s&&i!==i}var _o=typeof Object.is=="function"?Object.is:JS;function Xa(s,i){if(_o(s,i))return!0;if(typeof s!="object"||s===null||typeof i!="object"||i===null)return!1;var d=Object.keys(s),g=Object.keys(i);if(d.length!==g.length)return!1;for(g=0;g<d.length;g++){var w=d[g];if(!c.call(i,w)||!_o(s[w],i[w]))return!1}return!0}function rk(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function ok(s,i){var d=rk(s);s=0;for(var g;d;){if(d.nodeType===3){if(g=s+d.textContent.length,s<=i&&g>=i)return{node:d,offset:i-s};s=g}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=rk(d)}}function sk(s,i){return s&&i?s===i?!0:s&&s.nodeType===3?!1:i&&i.nodeType===3?sk(s,i.parentNode):"contains"in s?s.contains(i):s.compareDocumentPosition?!!(s.compareDocumentPosition(i)&16):!1:!1}function ik(){for(var s=window,i=We();i instanceof s.HTMLIFrameElement;){try{var d=typeof i.contentWindow.location.href=="string"}catch{d=!1}if(d)s=i.contentWindow;else break;i=We(s.document)}return i}function gf(s){var i=s&&s.nodeName&&s.nodeName.toLowerCase();return i&&(i==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||i==="textarea"||s.contentEditable==="true")}function eN(s){var i=ik(),d=s.focusedElem,g=s.selectionRange;if(i!==d&&d&&d.ownerDocument&&sk(d.ownerDocument.documentElement,d)){if(g!==null&&gf(d)){if(i=g.start,s=g.end,s===void 0&&(s=i),"selectionStart"in d)d.selectionStart=i,d.selectionEnd=Math.min(s,d.value.length);else if(s=(i=d.ownerDocument||document)&&i.defaultView||window,s.getSelection){s=s.getSelection();var w=d.textContent.length,b=Math.min(g.start,w);g=g.end===void 0?b:Math.min(g.end,w),!s.extend&&b>g&&(w=g,g=b,b=w),w=ok(d,b);var T=ok(d,g);w&&T&&(s.rangeCount!==1||s.anchorNode!==w.node||s.anchorOffset!==w.offset||s.focusNode!==T.node||s.focusOffset!==T.offset)&&(i=i.createRange(),i.setStart(w.node,w.offset),s.removeAllRanges(),b>g?(s.addRange(i),s.extend(T.node,T.offset)):(i.setEnd(T.node,T.offset),s.addRange(i)))}}for(i=[],s=d;s=s.parentNode;)s.nodeType===1&&i.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<i.length;d++)s=i[d],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var tN=u&&"documentMode"in document&&11>=document.documentMode,Zi=null,kf=null,Ja=null,yf=!1;function ak(s,i,d){var g=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;yf||Zi==null||Zi!==We(g)||(g=Zi,"selectionStart"in g&&gf(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),Ja&&Xa(Ja,g)||(Ja=g,g=$c(kf,"onSelect"),0<g.length&&(i=new ni("onSelect","select",null,i,d),s.push({event:i,listeners:g}),i.target=Zi)))}function Ic(s,i){var d={};return d[s.toLowerCase()]=i.toLowerCase(),d["Webkit"+s]="webkit"+i,d["Moz"+s]="moz"+i,d}var qi={animationend:Ic("Animation","AnimationEnd"),animationiteration:Ic("Animation","AnimationIteration"),animationstart:Ic("Animation","AnimationStart"),transitionend:Ic("Transition","TransitionEnd")},wf={},lk={};u&&(lk=document.createElement("div").style,"AnimationEvent"in window||(delete qi.animationend.animation,delete qi.animationiteration.animation,delete qi.animationstart.animation),"TransitionEvent"in window||delete qi.transitionend.transition);function Rc(s){if(wf[s])return wf[s];if(!qi[s])return s;var i=qi[s],d;for(d in i)if(i.hasOwnProperty(d)&&d in lk)return wf[s]=i[d];return s}var ck=Rc("animationend"),uk=Rc("animationiteration"),dk=Rc("animationstart"),fk=Rc("transitionend"),pk=new Map,hk="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 vs(s,i){pk.set(s,i),a(i,[s])}for(var vf=0;vf<hk.length;vf++){var bf=hk[vf],nN=bf.toLowerCase(),rN=bf[0].toUpperCase()+bf.slice(1);vs(nN,"on"+rN)}vs(ck,"onAnimationEnd"),vs(uk,"onAnimationIteration"),vs(dk,"onAnimationStart"),vs("dblclick","onDoubleClick"),vs("focusin","onFocus"),vs("focusout","onBlur"),vs(fk,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("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 el="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(" "),oN=new Set("cancel close invalid load scroll toggle".split(" ").concat(el));function mk(s,i,d){var g=s.type||"unknown-event";s.currentTarget=d,Sn(g,i,void 0,s),s.currentTarget=null}function gk(s,i){i=(i&4)!==0;for(var d=0;d<s.length;d++){var g=s[d],w=g.event;g=g.listeners;e:{var b=void 0;if(i)for(var T=g.length-1;0<=T;T--){var F=g[T],G=F.instance,le=F.currentTarget;if(F=F.listener,G!==b&&w.isPropagationStopped())break e;mk(w,F,le),b=G}else for(T=0;T<g.length;T++){if(F=g[T],G=F.instance,le=F.currentTarget,F=F.listener,G!==b&&w.isPropagationStopped())break e;mk(w,F,le),b=G}}}if(wn)throw s=Ke,wn=!1,Ke=null,s}function _n(s,i){var d=i[Cf];d===void 0&&(d=i[Cf]=new Set);var g=s+"__bubble";d.has(g)||(kk(i,s,2,!1),d.add(g))}function xf(s,i,d){var g=0;i&&(g|=4),kk(d,s,g,i)}var Oc="_reactListening"+Math.random().toString(36).slice(2);function tl(s){if(!s[Oc]){s[Oc]=!0,r.forEach(function(d){d!=="selectionchange"&&(oN.has(d)||xf(d,!1,s),xf(d,!0,s))});var i=s.nodeType===9?s:s.ownerDocument;i===null||i[Oc]||(i[Oc]=!0,xf("selectionchange",!1,i))}}function kk(s,i,d,g){switch(ei(i)){case 1:var w=Wa;break;case 4:w=Ka;break;default:w=Li}d=w.bind(null,i,d,s),w=void 0,!_e||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(w=!0),g?w!==void 0?s.addEventListener(i,d,{capture:!0,passive:w}):s.addEventListener(i,d,!0):w!==void 0?s.addEventListener(i,d,{passive:w}):s.addEventListener(i,d,!1)}function _f(s,i,d,g,w){var b=g;if((i&1)===0&&(i&2)===0&&g!==null)e:for(;;){if(g===null)return;var T=g.tag;if(T===3||T===4){var F=g.stateNode.containerInfo;if(F===w||F.nodeType===8&&F.parentNode===w)break;if(T===4)for(T=g.return;T!==null;){var G=T.tag;if((G===3||G===4)&&(G=T.stateNode.containerInfo,G===w||G.nodeType===8&&G.parentNode===w))return;T=T.return}for(;F!==null;){if(T=si(F),T===null)return;if(G=T.tag,G===5||G===6){g=b=T;continue e}F=F.parentNode}}g=g.return}Ne(function(){var le=b,Te=nn(d),Ae=[];e:{var Se=pk.get(s);if(Se!==void 0){var Ze=ni,Qe=s;switch(s){case"keypress":if(zi(d)===0)break e;case"keydown":case"keyup":Ze=Bo;break;case"focusin":Qe="focus",Ze=Wi;break;case"focusout":Qe="blur",Ze=Wi;break;case"beforeblur":case"afterblur":Ze=Wi;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ze=Hi;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ze=uf;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ze=PS;break;case ck:case uk:case dk:Ze=Ec;break;case fk:Ze=zS;break;case"scroll":Ze=bc;break;case"wheel":Ze=BS;break;case"copy":case"cut":case"paste":Ze=Nc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ze=Cc}var Je=(i&4)!==0,qn=!Je&&s==="scroll",re=Je?Se!==null?Se+"Capture":null:Se;Je=[];for(var Q=le,ie;Q!==null;){ie=Q;var Le=ie.stateNode;if(ie.tag===5&&Le!==null&&(ie=Le,re!==null&&(Le=be(Q,re),Le!=null&&Je.push(nl(Q,Le,ie)))),qn)break;Q=Q.return}0<Je.length&&(Se=new Ze(Se,Qe,null,d,Te),Ae.push({event:Se,listeners:Je}))}}if((i&7)===0){e:{if(Se=s==="mouseover"||s==="pointerover",Ze=s==="mouseout"||s==="pointerout",Se&&d!==tn&&(Qe=d.relatedTarget||d.fromElement)&&(si(Qe)||Qe[ns]))break e;if((Ze||Se)&&(Se=Te.window===Te?Te:(Se=Te.ownerDocument)?Se.defaultView||Se.parentWindow:window,Ze?(Qe=d.relatedTarget||d.toElement,Ze=le,Qe=Qe?si(Qe):null,Qe!==null&&(qn=Nn(Qe),Qe!==qn||Qe.tag!==5&&Qe.tag!==6)&&(Qe=null)):(Ze=null,Qe=le),Ze!==Qe)){if(Je=Hi,Le="onMouseLeave",re="onMouseEnter",Q="mouse",(s==="pointerout"||s==="pointerover")&&(Je=Cc,Le="onPointerLeave",re="onPointerEnter",Q="pointer"),qn=Ze==null?Se:Yi(Ze),ie=Qe==null?Se:Yi(Qe),Se=new Je(Le,Q+"leave",Ze,d,Te),Se.target=qn,Se.relatedTarget=ie,Le=null,si(Te)===le&&(Je=new Je(re,Q+"enter",Qe,d,Te),Je.target=ie,Je.relatedTarget=qn,Le=Je),qn=Le,Ze&&Qe)t:{for(Je=Ze,re=Qe,Q=0,ie=Je;ie;ie=Gi(ie))Q++;for(ie=0,Le=re;Le;Le=Gi(Le))ie++;for(;0<Q-ie;)Je=Gi(Je),Q--;for(;0<ie-Q;)re=Gi(re),ie--;for(;Q--;){if(Je===re||re!==null&&Je===re.alternate)break t;Je=Gi(Je),re=Gi(re)}Je=null}else Je=null;Ze!==null&&yk(Ae,Se,Ze,Je,!1),Qe!==null&&qn!==null&&yk(Ae,qn,Qe,Je,!0)}}e:{if(Se=le?Yi(le):window,Ze=Se.nodeName&&Se.nodeName.toLowerCase(),Ze==="select"||Ze==="input"&&Se.type==="file")var nt=GS;else if(Qg(Se))if(Jg)nt=XS;else{nt=YS;var dt=VS}else(Ze=Se.nodeName)&&Ze.toLowerCase()==="input"&&(Se.type==="checkbox"||Se.type==="radio")&&(nt=QS);if(nt&&(nt=nt(s,le))){Xg(Ae,nt,d,Te);break e}dt&&dt(s,Se,le),s==="focusout"&&(dt=Se._wrapperState)&&dt.controlled&&Se.type==="number"&&qt(Se,"number",Se.value)}switch(dt=le?Yi(le):window,s){case"focusin":(Qg(dt)||dt.contentEditable==="true")&&(Zi=dt,kf=le,Ja=null);break;case"focusout":Ja=kf=Zi=null;break;case"mousedown":yf=!0;break;case"contextmenu":case"mouseup":case"dragend":yf=!1,ak(Ae,d,Te);break;case"selectionchange":if(tN)break;case"keydown":case"keyup":ak(Ae,d,Te)}var ft;if(pf)e:{switch(s){case"compositionstart":var bt="onCompositionStart";break e;case"compositionend":bt="onCompositionEnd";break e;case"compositionupdate":bt="onCompositionUpdate";break e}bt=void 0}else Ki?Vg(s,d)&&(bt="onCompositionEnd"):s==="keydown"&&d.keyCode===229&&(bt="onCompositionStart");bt&&(Zg&&d.locale!=="ko"&&(Ki||bt!=="onCompositionStart"?bt==="onCompositionEnd"&&Ki&&(ft=ir()):(xo=Te,Di="value"in xo?xo.value:xo.textContent,Ki=!0)),dt=$c(le,bt),0<dt.length&&(bt=new Ga(bt,s,null,d,Te),Ae.push({event:bt,listeners:dt}),ft?bt.data=ft:(ft=Yg(d),ft!==null&&(bt.data=ft)))),(ft=HS?WS(s,d):KS(s,d))&&(le=$c(le,"onBeforeInput"),0<le.length&&(Te=new Ga("onBeforeInput","beforeinput",null,d,Te),Ae.push({event:Te,listeners:le}),Te.data=ft))}gk(Ae,i)})}function nl(s,i,d){return{instance:s,listener:i,currentTarget:d}}function $c(s,i){for(var d=i+"Capture",g=[];s!==null;){var w=s,b=w.stateNode;w.tag===5&&b!==null&&(w=b,b=be(s,d),b!=null&&g.unshift(nl(s,b,w)),b=be(s,i),b!=null&&g.push(nl(s,b,w))),s=s.return}return g}function Gi(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function yk(s,i,d,g,w){for(var b=i._reactName,T=[];d!==null&&d!==g;){var F=d,G=F.alternate,le=F.stateNode;if(G!==null&&G===g)break;F.tag===5&&le!==null&&(F=le,w?(G=be(d,b),G!=null&&T.unshift(nl(d,G,F))):w||(G=be(d,b),G!=null&&T.push(nl(d,G,F)))),d=d.return}T.length!==0&&s.push({event:i,listeners:T})}var sN=/\r\n?/g,iN=/\u0000|\uFFFD/g;function wk(s){return(typeof s=="string"?s:""+s).replace(sN,`
95
+ `).replace(iN,"")}function Mc(s,i,d){if(i=wk(i),wk(s)!==i&&d)throw Error(n(425))}function Lc(){}var Ef=null,Sf=null;function Nf(s,i){return s==="textarea"||s==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Tf=typeof setTimeout=="function"?setTimeout:void 0,aN=typeof clearTimeout=="function"?clearTimeout:void 0,vk=typeof Promise=="function"?Promise:void 0,lN=typeof queueMicrotask=="function"?queueMicrotask:typeof vk<"u"?function(s){return vk.resolve(null).then(s).catch(cN)}:Tf;function cN(s){setTimeout(function(){throw s})}function jf(s,i){var d=i,g=0;do{var w=d.nextSibling;if(s.removeChild(d),w&&w.nodeType===8)if(d=w.data,d==="/$"){if(g===0){s.removeChild(w),Fo(i);return}g--}else d!=="$"&&d!=="$?"&&d!=="$!"||g++;d=w}while(d);Fo(i)}function bs(s){for(;s!=null;s=s.nextSibling){var i=s.nodeType;if(i===1||i===3)break;if(i===8){if(i=s.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return s}function bk(s){s=s.previousSibling;for(var i=0;s;){if(s.nodeType===8){var d=s.data;if(d==="$"||d==="$!"||d==="$?"){if(i===0)return s;i--}else d==="/$"&&i++}s=s.previousSibling}return null}var Vi=Math.random().toString(36).slice(2),Uo="__reactFiber$"+Vi,rl="__reactProps$"+Vi,ns="__reactContainer$"+Vi,Cf="__reactEvents$"+Vi,uN="__reactListeners$"+Vi,dN="__reactHandles$"+Vi;function si(s){var i=s[Uo];if(i)return i;for(var d=s.parentNode;d;){if(i=d[ns]||d[Uo]){if(d=i.alternate,i.child!==null||d!==null&&d.child!==null)for(s=bk(s);s!==null;){if(d=s[Uo])return d;s=bk(s)}return i}s=d,d=s.parentNode}return null}function ol(s){return s=s[Uo]||s[ns],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function Yi(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(n(33))}function Pc(s){return s[rl]||null}var Af=[],Qi=-1;function xs(s){return{current:s}}function En(s){0>Qi||(s.current=Af[Qi],Af[Qi]=null,Qi--)}function yn(s,i){Qi++,Af[Qi]=s.current,s.current=i}var _s={},br=xs(_s),Dr=xs(!1),ii=_s;function Xi(s,i){var d=s.type.contextTypes;if(!d)return _s;var g=s.stateNode;if(g&&g.__reactInternalMemoizedUnmaskedChildContext===i)return g.__reactInternalMemoizedMaskedChildContext;var w={},b;for(b in d)w[b]=i[b];return g&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=i,s.__reactInternalMemoizedMaskedChildContext=w),w}function zr(s){return s=s.childContextTypes,s!=null}function Dc(){En(Dr),En(br)}function xk(s,i,d){if(br.current!==_s)throw Error(n(168));yn(br,i),yn(Dr,d)}function _k(s,i,d){var g=s.stateNode;if(i=i.childContextTypes,typeof g.getChildContext!="function")return d;g=g.getChildContext();for(var w in g)if(!(w in i))throw Error(n(108,ae(s)||"Unknown",w));return Z({},d,g)}function zc(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||_s,ii=br.current,yn(br,s),yn(Dr,Dr.current),!0}function Ek(s,i,d){var g=s.stateNode;if(!g)throw Error(n(169));d?(s=_k(s,i,ii),g.__reactInternalMemoizedMergedChildContext=s,En(Dr),En(br),yn(br,s)):En(Dr),yn(Dr,d)}var rs=null,Fc=!1,If=!1;function Sk(s){rs===null?rs=[s]:rs.push(s)}function fN(s){Fc=!0,Sk(s)}function Es(){if(!If&&rs!==null){If=!0;var s=0,i=Pt;try{var d=rs;for(Pt=1;s<d.length;s++){var g=d[s];do g=g(!0);while(g!==null)}rs=null,Fc=!1}catch(w){throw rs!==null&&(rs=rs.slice(s+1)),On(so,Es),w}finally{Pt=i,If=!1}}return null}var Ji=[],ea=0,Bc=null,Uc=0,io=[],ao=0,ai=null,os=1,ss="";function li(s,i){Ji[ea++]=Uc,Ji[ea++]=Bc,Bc=s,Uc=i}function Nk(s,i,d){io[ao++]=os,io[ao++]=ss,io[ao++]=ai,ai=s;var g=os;s=ss;var w=32-ot(g)-1;g&=~(1<<w),d+=1;var b=32-ot(i)+w;if(30<b){var T=w-w%5;b=(g&(1<<T)-1).toString(32),g>>=T,w-=T,os=1<<32-ot(i)+w|d<<w|g,ss=b+s}else os=1<<b|d<<w|g,ss=s}function Rf(s){s.return!==null&&(li(s,1),Nk(s,1,0))}function Of(s){for(;s===Bc;)Bc=Ji[--ea],Ji[ea]=null,Uc=Ji[--ea],Ji[ea]=null;for(;s===ai;)ai=io[--ao],io[ao]=null,ss=io[--ao],io[ao]=null,os=io[--ao],io[ao]=null}var Qr=null,Xr=null,jn=!1,Eo=null;function Tk(s,i){var d=fo(5,null,null,0);d.elementType="DELETED",d.stateNode=i,d.return=s,i=s.deletions,i===null?(s.deletions=[d],s.flags|=16):i.push(d)}function jk(s,i){switch(s.tag){case 5:var d=s.type;return i=i.nodeType!==1||d.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(s.stateNode=i,Qr=s,Xr=bs(i.firstChild),!0):!1;case 6:return i=s.pendingProps===""||i.nodeType!==3?null:i,i!==null?(s.stateNode=i,Qr=s,Xr=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(d=ai!==null?{id:os,overflow:ss}:null,s.memoizedState={dehydrated:i,treeContext:d,retryLane:1073741824},d=fo(18,null,null,0),d.stateNode=i,d.return=s,s.child=d,Qr=s,Xr=null,!0):!1;default:return!1}}function $f(s){return(s.mode&1)!==0&&(s.flags&128)===0}function Mf(s){if(jn){var i=Xr;if(i){var d=i;if(!jk(s,i)){if($f(s))throw Error(n(418));i=bs(d.nextSibling);var g=Qr;i&&jk(s,i)?Tk(g,d):(s.flags=s.flags&-4097|2,jn=!1,Qr=s)}}else{if($f(s))throw Error(n(418));s.flags=s.flags&-4097|2,jn=!1,Qr=s}}}function Ck(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;Qr=s}function Hc(s){if(s!==Qr)return!1;if(!jn)return Ck(s),jn=!0,!1;var i;if((i=s.tag!==3)&&!(i=s.tag!==5)&&(i=s.type,i=i!=="head"&&i!=="body"&&!Nf(s.type,s.memoizedProps)),i&&(i=Xr)){if($f(s))throw Ak(),Error(n(418));for(;i;)Tk(s,i),i=bs(i.nextSibling)}if(Ck(s),s.tag===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(n(317));e:{for(s=s.nextSibling,i=0;s;){if(s.nodeType===8){var d=s.data;if(d==="/$"){if(i===0){Xr=bs(s.nextSibling);break e}i--}else d!=="$"&&d!=="$!"&&d!=="$?"||i++}s=s.nextSibling}Xr=null}}else Xr=Qr?bs(s.stateNode.nextSibling):null;return!0}function Ak(){for(var s=Xr;s;)s=bs(s.nextSibling)}function ta(){Xr=Qr=null,jn=!1}function Lf(s){Eo===null?Eo=[s]:Eo.push(s)}var pN=M.ReactCurrentBatchConfig;function sl(s,i,d){if(s=d.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(n(309));var g=d.stateNode}if(!g)throw Error(n(147,s));var w=g,b=""+s;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===b?i.ref:(i=function(T){var F=w.refs;T===null?delete F[b]:F[b]=T},i._stringRef=b,i)}if(typeof s!="string")throw Error(n(284));if(!d._owner)throw Error(n(290,s))}return s}function Wc(s,i){throw s=Object.prototype.toString.call(i),Error(n(31,s==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":s))}function Ik(s){var i=s._init;return i(s._payload)}function Rk(s){function i(re,Q){if(s){var ie=re.deletions;ie===null?(re.deletions=[Q],re.flags|=16):ie.push(Q)}}function d(re,Q){if(!s)return null;for(;Q!==null;)i(re,Q),Q=Q.sibling;return null}function g(re,Q){for(re=new Map;Q!==null;)Q.key!==null?re.set(Q.key,Q):re.set(Q.index,Q),Q=Q.sibling;return re}function w(re,Q){return re=Rs(re,Q),re.index=0,re.sibling=null,re}function b(re,Q,ie){return re.index=ie,s?(ie=re.alternate,ie!==null?(ie=ie.index,ie<Q?(re.flags|=2,Q):ie):(re.flags|=2,Q)):(re.flags|=1048576,Q)}function T(re){return s&&re.alternate===null&&(re.flags|=2),re}function F(re,Q,ie,Le){return Q===null||Q.tag!==6?(Q=Tp(ie,re.mode,Le),Q.return=re,Q):(Q=w(Q,ie),Q.return=re,Q)}function G(re,Q,ie,Le){var nt=ie.type;return nt===R?Te(re,Q,ie.props.children,Le,ie.key):Q!==null&&(Q.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===xe&&Ik(nt)===Q.type)?(Le=w(Q,ie.props),Le.ref=sl(re,Q,ie),Le.return=re,Le):(Le=hu(ie.type,ie.key,ie.props,null,re.mode,Le),Le.ref=sl(re,Q,ie),Le.return=re,Le)}function le(re,Q,ie,Le){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==ie.containerInfo||Q.stateNode.implementation!==ie.implementation?(Q=jp(ie,re.mode,Le),Q.return=re,Q):(Q=w(Q,ie.children||[]),Q.return=re,Q)}function Te(re,Q,ie,Le,nt){return Q===null||Q.tag!==7?(Q=gi(ie,re.mode,Le,nt),Q.return=re,Q):(Q=w(Q,ie),Q.return=re,Q)}function Ae(re,Q,ie){if(typeof Q=="string"&&Q!==""||typeof Q=="number")return Q=Tp(""+Q,re.mode,ie),Q.return=re,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case K:return ie=hu(Q.type,Q.key,Q.props,null,re.mode,ie),ie.ref=sl(re,null,Q),ie.return=re,ie;case U:return Q=jp(Q,re.mode,ie),Q.return=re,Q;case xe:var Le=Q._init;return Ae(re,Le(Q._payload),ie)}if(an(Q)||X(Q))return Q=gi(Q,re.mode,ie,null),Q.return=re,Q;Wc(re,Q)}return null}function Se(re,Q,ie,Le){var nt=Q!==null?Q.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number")return nt!==null?null:F(re,Q,""+ie,Le);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case K:return ie.key===nt?G(re,Q,ie,Le):null;case U:return ie.key===nt?le(re,Q,ie,Le):null;case xe:return nt=ie._init,Se(re,Q,nt(ie._payload),Le)}if(an(ie)||X(ie))return nt!==null?null:Te(re,Q,ie,Le,null);Wc(re,ie)}return null}function Ze(re,Q,ie,Le,nt){if(typeof Le=="string"&&Le!==""||typeof Le=="number")return re=re.get(ie)||null,F(Q,re,""+Le,nt);if(typeof Le=="object"&&Le!==null){switch(Le.$$typeof){case K:return re=re.get(Le.key===null?ie:Le.key)||null,G(Q,re,Le,nt);case U:return re=re.get(Le.key===null?ie:Le.key)||null,le(Q,re,Le,nt);case xe:var dt=Le._init;return Ze(re,Q,ie,dt(Le._payload),nt)}if(an(Le)||X(Le))return re=re.get(ie)||null,Te(Q,re,Le,nt,null);Wc(Q,Le)}return null}function Qe(re,Q,ie,Le){for(var nt=null,dt=null,ft=Q,bt=Q=0,hr=null;ft!==null&&bt<ie.length;bt++){ft.index>bt?(hr=ft,ft=null):hr=ft.sibling;var rn=Se(re,ft,ie[bt],Le);if(rn===null){ft===null&&(ft=hr);break}s&&ft&&rn.alternate===null&&i(re,ft),Q=b(rn,Q,bt),dt===null?nt=rn:dt.sibling=rn,dt=rn,ft=hr}if(bt===ie.length)return d(re,ft),jn&&li(re,bt),nt;if(ft===null){for(;bt<ie.length;bt++)ft=Ae(re,ie[bt],Le),ft!==null&&(Q=b(ft,Q,bt),dt===null?nt=ft:dt.sibling=ft,dt=ft);return jn&&li(re,bt),nt}for(ft=g(re,ft);bt<ie.length;bt++)hr=Ze(ft,re,bt,ie[bt],Le),hr!==null&&(s&&hr.alternate!==null&&ft.delete(hr.key===null?bt:hr.key),Q=b(hr,Q,bt),dt===null?nt=hr:dt.sibling=hr,dt=hr);return s&&ft.forEach(function(Os){return i(re,Os)}),jn&&li(re,bt),nt}function Je(re,Q,ie,Le){var nt=X(ie);if(typeof nt!="function")throw Error(n(150));if(ie=nt.call(ie),ie==null)throw Error(n(151));for(var dt=nt=null,ft=Q,bt=Q=0,hr=null,rn=ie.next();ft!==null&&!rn.done;bt++,rn=ie.next()){ft.index>bt?(hr=ft,ft=null):hr=ft.sibling;var Os=Se(re,ft,rn.value,Le);if(Os===null){ft===null&&(ft=hr);break}s&&ft&&Os.alternate===null&&i(re,ft),Q=b(Os,Q,bt),dt===null?nt=Os:dt.sibling=Os,dt=Os,ft=hr}if(rn.done)return d(re,ft),jn&&li(re,bt),nt;if(ft===null){for(;!rn.done;bt++,rn=ie.next())rn=Ae(re,rn.value,Le),rn!==null&&(Q=b(rn,Q,bt),dt===null?nt=rn:dt.sibling=rn,dt=rn);return jn&&li(re,bt),nt}for(ft=g(re,ft);!rn.done;bt++,rn=ie.next())rn=Ze(ft,re,bt,rn.value,Le),rn!==null&&(s&&rn.alternate!==null&&ft.delete(rn.key===null?bt:rn.key),Q=b(rn,Q,bt),dt===null?nt=rn:dt.sibling=rn,dt=rn);return s&&ft.forEach(function(ZN){return i(re,ZN)}),jn&&li(re,bt),nt}function qn(re,Q,ie,Le){if(typeof ie=="object"&&ie!==null&&ie.type===R&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case K:e:{for(var nt=ie.key,dt=Q;dt!==null;){if(dt.key===nt){if(nt=ie.type,nt===R){if(dt.tag===7){d(re,dt.sibling),Q=w(dt,ie.props.children),Q.return=re,re=Q;break e}}else if(dt.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===xe&&Ik(nt)===dt.type){d(re,dt.sibling),Q=w(dt,ie.props),Q.ref=sl(re,dt,ie),Q.return=re,re=Q;break e}d(re,dt);break}else i(re,dt);dt=dt.sibling}ie.type===R?(Q=gi(ie.props.children,re.mode,Le,ie.key),Q.return=re,re=Q):(Le=hu(ie.type,ie.key,ie.props,null,re.mode,Le),Le.ref=sl(re,Q,ie),Le.return=re,re=Le)}return T(re);case U:e:{for(dt=ie.key;Q!==null;){if(Q.key===dt)if(Q.tag===4&&Q.stateNode.containerInfo===ie.containerInfo&&Q.stateNode.implementation===ie.implementation){d(re,Q.sibling),Q=w(Q,ie.children||[]),Q.return=re,re=Q;break e}else{d(re,Q);break}else i(re,Q);Q=Q.sibling}Q=jp(ie,re.mode,Le),Q.return=re,re=Q}return T(re);case xe:return dt=ie._init,qn(re,Q,dt(ie._payload),Le)}if(an(ie))return Qe(re,Q,ie,Le);if(X(ie))return Je(re,Q,ie,Le);Wc(re,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,Q!==null&&Q.tag===6?(d(re,Q.sibling),Q=w(Q,ie),Q.return=re,re=Q):(d(re,Q),Q=Tp(ie,re.mode,Le),Q.return=re,re=Q),T(re)):d(re,Q)}return qn}var na=Rk(!0),Ok=Rk(!1),Kc=xs(null),Zc=null,ra=null,Pf=null;function Df(){Pf=ra=Zc=null}function zf(s){var i=Kc.current;En(Kc),s._currentValue=i}function Ff(s,i,d){for(;s!==null;){var g=s.alternate;if((s.childLanes&i)!==i?(s.childLanes|=i,g!==null&&(g.childLanes|=i)):g!==null&&(g.childLanes&i)!==i&&(g.childLanes|=i),s===d)break;s=s.return}}function oa(s,i){Zc=s,Pf=ra=null,s=s.dependencies,s!==null&&s.firstContext!==null&&((s.lanes&i)!==0&&(Fr=!0),s.firstContext=null)}function lo(s){var i=s._currentValue;if(Pf!==s)if(s={context:s,memoizedValue:i,next:null},ra===null){if(Zc===null)throw Error(n(308));ra=s,Zc.dependencies={lanes:0,firstContext:s}}else ra=ra.next=s;return i}var ci=null;function Bf(s){ci===null?ci=[s]:ci.push(s)}function $k(s,i,d,g){var w=i.interleaved;return w===null?(d.next=d,Bf(i)):(d.next=w.next,w.next=d),i.interleaved=d,is(s,g)}function is(s,i){s.lanes|=i;var d=s.alternate;for(d!==null&&(d.lanes|=i),d=s,s=s.return;s!==null;)s.childLanes|=i,d=s.alternate,d!==null&&(d.childLanes|=i),d=s,s=s.return;return d.tag===3?d.stateNode:null}var Ss=!1;function Uf(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Mk(s,i){s=s.updateQueue,i.updateQueue===s&&(i.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,effects:s.effects})}function as(s,i){return{eventTime:s,lane:i,tag:0,payload:null,callback:null,next:null}}function Ns(s,i,d){var g=s.updateQueue;if(g===null)return null;if(g=g.shared,(Jt&2)!==0){var w=g.pending;return w===null?i.next=i:(i.next=w.next,w.next=i),g.pending=i,is(s,d)}return w=g.interleaved,w===null?(i.next=i,Bf(g)):(i.next=w.next,w.next=i),g.interleaved=i,is(s,d)}function qc(s,i,d){if(i=i.updateQueue,i!==null&&(i=i.shared,(d&4194240)!==0)){var g=i.lanes;g&=s.pendingLanes,d|=g,i.lanes=d,bo(s,d)}}function Lk(s,i){var d=s.updateQueue,g=s.alternate;if(g!==null&&(g=g.updateQueue,d===g)){var w=null,b=null;if(d=d.firstBaseUpdate,d!==null){do{var T={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};b===null?w=b=T:b=b.next=T,d=d.next}while(d!==null);b===null?w=b=i:b=b.next=i}else w=b=i;d={baseState:g.baseState,firstBaseUpdate:w,lastBaseUpdate:b,shared:g.shared,effects:g.effects},s.updateQueue=d;return}s=d.lastBaseUpdate,s===null?d.firstBaseUpdate=i:s.next=i,d.lastBaseUpdate=i}function Gc(s,i,d,g){var w=s.updateQueue;Ss=!1;var b=w.firstBaseUpdate,T=w.lastBaseUpdate,F=w.shared.pending;if(F!==null){w.shared.pending=null;var G=F,le=G.next;G.next=null,T===null?b=le:T.next=le,T=G;var Te=s.alternate;Te!==null&&(Te=Te.updateQueue,F=Te.lastBaseUpdate,F!==T&&(F===null?Te.firstBaseUpdate=le:F.next=le,Te.lastBaseUpdate=G))}if(b!==null){var Ae=w.baseState;T=0,Te=le=G=null,F=b;do{var Se=F.lane,Ze=F.eventTime;if((g&Se)===Se){Te!==null&&(Te=Te.next={eventTime:Ze,lane:0,tag:F.tag,payload:F.payload,callback:F.callback,next:null});e:{var Qe=s,Je=F;switch(Se=i,Ze=d,Je.tag){case 1:if(Qe=Je.payload,typeof Qe=="function"){Ae=Qe.call(Ze,Ae,Se);break e}Ae=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=Je.payload,Se=typeof Qe=="function"?Qe.call(Ze,Ae,Se):Qe,Se==null)break e;Ae=Z({},Ae,Se);break e;case 2:Ss=!0}}F.callback!==null&&F.lane!==0&&(s.flags|=64,Se=w.effects,Se===null?w.effects=[F]:Se.push(F))}else Ze={eventTime:Ze,lane:Se,tag:F.tag,payload:F.payload,callback:F.callback,next:null},Te===null?(le=Te=Ze,G=Ae):Te=Te.next=Ze,T|=Se;if(F=F.next,F===null){if(F=w.shared.pending,F===null)break;Se=F,F=Se.next,Se.next=null,w.lastBaseUpdate=Se,w.shared.pending=null}}while(!0);if(Te===null&&(G=Ae),w.baseState=G,w.firstBaseUpdate=le,w.lastBaseUpdate=Te,i=w.shared.interleaved,i!==null){w=i;do T|=w.lane,w=w.next;while(w!==i)}else b===null&&(w.shared.lanes=0);fi|=T,s.lanes=T,s.memoizedState=Ae}}function Pk(s,i,d){if(s=i.effects,i.effects=null,s!==null)for(i=0;i<s.length;i++){var g=s[i],w=g.callback;if(w!==null){if(g.callback=null,g=d,typeof w!="function")throw Error(n(191,w));w.call(g)}}}var il={},Ho=xs(il),al=xs(il),ll=xs(il);function ui(s){if(s===il)throw Error(n(174));return s}function Hf(s,i){switch(yn(ll,i),yn(al,s),yn(Ho,il),s=i.nodeType,s){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:Qt(null,"");break;default:s=s===8?i.parentNode:i,i=s.namespaceURI||null,s=s.tagName,i=Qt(i,s)}En(Ho),yn(Ho,i)}function sa(){En(Ho),En(al),En(ll)}function Dk(s){ui(ll.current);var i=ui(Ho.current),d=Qt(i,s.type);i!==d&&(yn(al,s),yn(Ho,d))}function Wf(s){al.current===s&&(En(Ho),En(al))}var Ln=xs(0);function Vc(s){for(var i=s;i!==null;){if(i.tag===13){var d=i.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.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===s)break;for(;i.sibling===null;){if(i.return===null||i.return===s)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var Kf=[];function Zf(){for(var s=0;s<Kf.length;s++)Kf[s]._workInProgressVersionPrimary=null;Kf.length=0}var Yc=M.ReactCurrentDispatcher,qf=M.ReactCurrentBatchConfig,di=0,Pn=null,lr=null,fr=null,Qc=!1,cl=!1,ul=0,hN=0;function xr(){throw Error(n(321))}function Gf(s,i){if(i===null)return!1;for(var d=0;d<i.length&&d<s.length;d++)if(!_o(s[d],i[d]))return!1;return!0}function Vf(s,i,d,g,w,b){if(di=b,Pn=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,Yc.current=s===null||s.memoizedState===null?yN:wN,s=d(g,w),cl){b=0;do{if(cl=!1,ul=0,25<=b)throw Error(n(301));b+=1,fr=lr=null,i.updateQueue=null,Yc.current=vN,s=d(g,w)}while(cl)}if(Yc.current=eu,i=lr!==null&&lr.next!==null,di=0,fr=lr=Pn=null,Qc=!1,i)throw Error(n(300));return s}function Yf(){var s=ul!==0;return ul=0,s}function Wo(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return fr===null?Pn.memoizedState=fr=s:fr=fr.next=s,fr}function co(){if(lr===null){var s=Pn.alternate;s=s!==null?s.memoizedState:null}else s=lr.next;var i=fr===null?Pn.memoizedState:fr.next;if(i!==null)fr=i,lr=s;else{if(s===null)throw Error(n(310));lr=s,s={memoizedState:lr.memoizedState,baseState:lr.baseState,baseQueue:lr.baseQueue,queue:lr.queue,next:null},fr===null?Pn.memoizedState=fr=s:fr=fr.next=s}return fr}function dl(s,i){return typeof i=="function"?i(s):i}function Qf(s){var i=co(),d=i.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=s;var g=lr,w=g.baseQueue,b=d.pending;if(b!==null){if(w!==null){var T=w.next;w.next=b.next,b.next=T}g.baseQueue=w=b,d.pending=null}if(w!==null){b=w.next,g=g.baseState;var F=T=null,G=null,le=b;do{var Te=le.lane;if((di&Te)===Te)G!==null&&(G=G.next={lane:0,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),g=le.hasEagerState?le.eagerState:s(g,le.action);else{var Ae={lane:Te,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null};G===null?(F=G=Ae,T=g):G=G.next=Ae,Pn.lanes|=Te,fi|=Te}le=le.next}while(le!==null&&le!==b);G===null?T=g:G.next=F,_o(g,i.memoizedState)||(Fr=!0),i.memoizedState=g,i.baseState=T,i.baseQueue=G,d.lastRenderedState=g}if(s=d.interleaved,s!==null){w=s;do b=w.lane,Pn.lanes|=b,fi|=b,w=w.next;while(w!==s)}else w===null&&(d.lanes=0);return[i.memoizedState,d.dispatch]}function Xf(s){var i=co(),d=i.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=s;var g=d.dispatch,w=d.pending,b=i.memoizedState;if(w!==null){d.pending=null;var T=w=w.next;do b=s(b,T.action),T=T.next;while(T!==w);_o(b,i.memoizedState)||(Fr=!0),i.memoizedState=b,i.baseQueue===null&&(i.baseState=b),d.lastRenderedState=b}return[b,g]}function zk(){}function Fk(s,i){var d=Pn,g=co(),w=i(),b=!_o(g.memoizedState,w);if(b&&(g.memoizedState=w,Fr=!0),g=g.queue,Jf(Hk.bind(null,d,g,s),[s]),g.getSnapshot!==i||b||fr!==null&&fr.memoizedState.tag&1){if(d.flags|=2048,fl(9,Uk.bind(null,d,g,w,i),void 0,null),pr===null)throw Error(n(349));(di&30)!==0||Bk(d,i,w)}return w}function Bk(s,i,d){s.flags|=16384,s={getSnapshot:i,value:d},i=Pn.updateQueue,i===null?(i={lastEffect:null,stores:null},Pn.updateQueue=i,i.stores=[s]):(d=i.stores,d===null?i.stores=[s]:d.push(s))}function Uk(s,i,d,g){i.value=d,i.getSnapshot=g,Wk(i)&&Kk(s)}function Hk(s,i,d){return d(function(){Wk(i)&&Kk(s)})}function Wk(s){var i=s.getSnapshot;s=s.value;try{var d=i();return!_o(s,d)}catch{return!0}}function Kk(s){var i=is(s,1);i!==null&&jo(i,s,1,-1)}function Zk(s){var i=Wo();return typeof s=="function"&&(s=s()),i.memoizedState=i.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:dl,lastRenderedState:s},i.queue=s,s=s.dispatch=kN.bind(null,Pn,s),[i.memoizedState,s]}function fl(s,i,d,g){return s={tag:s,create:i,destroy:d,deps:g,next:null},i=Pn.updateQueue,i===null?(i={lastEffect:null,stores:null},Pn.updateQueue=i,i.lastEffect=s.next=s):(d=i.lastEffect,d===null?i.lastEffect=s.next=s:(g=d.next,d.next=s,s.next=g,i.lastEffect=s)),s}function qk(){return co().memoizedState}function Xc(s,i,d,g){var w=Wo();Pn.flags|=s,w.memoizedState=fl(1|i,d,void 0,g===void 0?null:g)}function Jc(s,i,d,g){var w=co();g=g===void 0?null:g;var b=void 0;if(lr!==null){var T=lr.memoizedState;if(b=T.destroy,g!==null&&Gf(g,T.deps)){w.memoizedState=fl(i,d,b,g);return}}Pn.flags|=s,w.memoizedState=fl(1|i,d,b,g)}function Gk(s,i){return Xc(8390656,8,s,i)}function Jf(s,i){return Jc(2048,8,s,i)}function Vk(s,i){return Jc(4,2,s,i)}function Yk(s,i){return Jc(4,4,s,i)}function Qk(s,i){if(typeof i=="function")return s=s(),i(s),function(){i(null)};if(i!=null)return s=s(),i.current=s,function(){i.current=null}}function Xk(s,i,d){return d=d!=null?d.concat([s]):null,Jc(4,4,Qk.bind(null,i,s),d)}function ep(){}function Jk(s,i){var d=co();i=i===void 0?null:i;var g=d.memoizedState;return g!==null&&i!==null&&Gf(i,g[1])?g[0]:(d.memoizedState=[s,i],s)}function ey(s,i){var d=co();i=i===void 0?null:i;var g=d.memoizedState;return g!==null&&i!==null&&Gf(i,g[1])?g[0]:(s=s(),d.memoizedState=[s,i],s)}function ty(s,i,d){return(di&21)===0?(s.baseState&&(s.baseState=!1,Fr=!0),s.memoizedState=d):(_o(d,i)||(d=vo(),Pn.lanes|=d,fi|=d,s.baseState=!0),i)}function mN(s,i){var d=Pt;Pt=d!==0&&4>d?d:4,s(!0);var g=qf.transition;qf.transition={};try{s(!1),i()}finally{Pt=d,qf.transition=g}}function ny(){return co().memoizedState}function gN(s,i,d){var g=As(s);if(d={lane:g,action:d,hasEagerState:!1,eagerState:null,next:null},ry(s))oy(i,d);else if(d=$k(s,i,d,g),d!==null){var w=Ir();jo(d,s,g,w),sy(d,i,g)}}function kN(s,i,d){var g=As(s),w={lane:g,action:d,hasEagerState:!1,eagerState:null,next:null};if(ry(s))oy(i,w);else{var b=s.alternate;if(s.lanes===0&&(b===null||b.lanes===0)&&(b=i.lastRenderedReducer,b!==null))try{var T=i.lastRenderedState,F=b(T,d);if(w.hasEagerState=!0,w.eagerState=F,_o(F,T)){var G=i.interleaved;G===null?(w.next=w,Bf(i)):(w.next=G.next,G.next=w),i.interleaved=w;return}}catch{}finally{}d=$k(s,i,w,g),d!==null&&(w=Ir(),jo(d,s,g,w),sy(d,i,g))}}function ry(s){var i=s.alternate;return s===Pn||i!==null&&i===Pn}function oy(s,i){cl=Qc=!0;var d=s.pending;d===null?i.next=i:(i.next=d.next,d.next=i),s.pending=i}function sy(s,i,d){if((d&4194240)!==0){var g=i.lanes;g&=s.pendingLanes,d|=g,i.lanes=d,bo(s,d)}}var eu={readContext:lo,useCallback:xr,useContext:xr,useEffect:xr,useImperativeHandle:xr,useInsertionEffect:xr,useLayoutEffect:xr,useMemo:xr,useReducer:xr,useRef:xr,useState:xr,useDebugValue:xr,useDeferredValue:xr,useTransition:xr,useMutableSource:xr,useSyncExternalStore:xr,useId:xr,unstable_isNewReconciler:!1},yN={readContext:lo,useCallback:function(s,i){return Wo().memoizedState=[s,i===void 0?null:i],s},useContext:lo,useEffect:Gk,useImperativeHandle:function(s,i,d){return d=d!=null?d.concat([s]):null,Xc(4194308,4,Qk.bind(null,i,s),d)},useLayoutEffect:function(s,i){return Xc(4194308,4,s,i)},useInsertionEffect:function(s,i){return Xc(4,2,s,i)},useMemo:function(s,i){var d=Wo();return i=i===void 0?null:i,s=s(),d.memoizedState=[s,i],s},useReducer:function(s,i,d){var g=Wo();return i=d!==void 0?d(i):i,g.memoizedState=g.baseState=i,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:i},g.queue=s,s=s.dispatch=gN.bind(null,Pn,s),[g.memoizedState,s]},useRef:function(s){var i=Wo();return s={current:s},i.memoizedState=s},useState:Zk,useDebugValue:ep,useDeferredValue:function(s){return Wo().memoizedState=s},useTransition:function(){var s=Zk(!1),i=s[0];return s=mN.bind(null,s[1]),Wo().memoizedState=s,[i,s]},useMutableSource:function(){},useSyncExternalStore:function(s,i,d){var g=Pn,w=Wo();if(jn){if(d===void 0)throw Error(n(407));d=d()}else{if(d=i(),pr===null)throw Error(n(349));(di&30)!==0||Bk(g,i,d)}w.memoizedState=d;var b={value:d,getSnapshot:i};return w.queue=b,Gk(Hk.bind(null,g,b,s),[s]),g.flags|=2048,fl(9,Uk.bind(null,g,b,d,i),void 0,null),d},useId:function(){var s=Wo(),i=pr.identifierPrefix;if(jn){var d=ss,g=os;d=(g&~(1<<32-ot(g)-1)).toString(32)+d,i=":"+i+"R"+d,d=ul++,0<d&&(i+="H"+d.toString(32)),i+=":"}else d=hN++,i=":"+i+"r"+d.toString(32)+":";return s.memoizedState=i},unstable_isNewReconciler:!1},wN={readContext:lo,useCallback:Jk,useContext:lo,useEffect:Jf,useImperativeHandle:Xk,useInsertionEffect:Vk,useLayoutEffect:Yk,useMemo:ey,useReducer:Qf,useRef:qk,useState:function(){return Qf(dl)},useDebugValue:ep,useDeferredValue:function(s){var i=co();return ty(i,lr.memoizedState,s)},useTransition:function(){var s=Qf(dl)[0],i=co().memoizedState;return[s,i]},useMutableSource:zk,useSyncExternalStore:Fk,useId:ny,unstable_isNewReconciler:!1},vN={readContext:lo,useCallback:Jk,useContext:lo,useEffect:Jf,useImperativeHandle:Xk,useInsertionEffect:Vk,useLayoutEffect:Yk,useMemo:ey,useReducer:Xf,useRef:qk,useState:function(){return Xf(dl)},useDebugValue:ep,useDeferredValue:function(s){var i=co();return lr===null?i.memoizedState=s:ty(i,lr.memoizedState,s)},useTransition:function(){var s=Xf(dl)[0],i=co().memoizedState;return[s,i]},useMutableSource:zk,useSyncExternalStore:Fk,useId:ny,unstable_isNewReconciler:!1};function So(s,i){if(s&&s.defaultProps){i=Z({},i),s=s.defaultProps;for(var d in s)i[d]===void 0&&(i[d]=s[d]);return i}return i}function tp(s,i,d,g){i=s.memoizedState,d=d(g,i),d=d==null?i:Z({},i,d),s.memoizedState=d,s.lanes===0&&(s.updateQueue.baseState=d)}var tu={isMounted:function(s){return(s=s._reactInternals)?Nn(s)===s:!1},enqueueSetState:function(s,i,d){s=s._reactInternals;var g=Ir(),w=As(s),b=as(g,w);b.payload=i,d!=null&&(b.callback=d),i=Ns(s,b,w),i!==null&&(jo(i,s,w,g),qc(i,s,w))},enqueueReplaceState:function(s,i,d){s=s._reactInternals;var g=Ir(),w=As(s),b=as(g,w);b.tag=1,b.payload=i,d!=null&&(b.callback=d),i=Ns(s,b,w),i!==null&&(jo(i,s,w,g),qc(i,s,w))},enqueueForceUpdate:function(s,i){s=s._reactInternals;var d=Ir(),g=As(s),w=as(d,g);w.tag=2,i!=null&&(w.callback=i),i=Ns(s,w,g),i!==null&&(jo(i,s,g,d),qc(i,s,g))}};function iy(s,i,d,g,w,b,T){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(g,b,T):i.prototype&&i.prototype.isPureReactComponent?!Xa(d,g)||!Xa(w,b):!0}function ay(s,i,d){var g=!1,w=_s,b=i.contextType;return typeof b=="object"&&b!==null?b=lo(b):(w=zr(i)?ii:br.current,g=i.contextTypes,b=(g=g!=null)?Xi(s,w):_s),i=new i(d,b),s.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=tu,s.stateNode=i,i._reactInternals=s,g&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=w,s.__reactInternalMemoizedMaskedChildContext=b),i}function ly(s,i,d,g){s=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(d,g),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(d,g),i.state!==s&&tu.enqueueReplaceState(i,i.state,null)}function np(s,i,d,g){var w=s.stateNode;w.props=d,w.state=s.memoizedState,w.refs={},Uf(s);var b=i.contextType;typeof b=="object"&&b!==null?w.context=lo(b):(b=zr(i)?ii:br.current,w.context=Xi(s,b)),w.state=s.memoizedState,b=i.getDerivedStateFromProps,typeof b=="function"&&(tp(s,i,b,d),w.state=s.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof w.getSnapshotBeforeUpdate=="function"||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(i=w.state,typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount(),i!==w.state&&tu.enqueueReplaceState(w,w.state,null),Gc(s,d,w,g),w.state=s.memoizedState),typeof w.componentDidMount=="function"&&(s.flags|=4194308)}function ia(s,i){try{var d="",g=i;do d+=he(g),g=g.return;while(g);var w=d}catch(b){w=`
96
+ Error generating stack: `+b.message+`
97
+ `+b.stack}return{value:s,source:i,stack:w,digest:null}}function rp(s,i,d){return{value:s,source:null,stack:d??null,digest:i??null}}function op(s,i){try{console.error(i.value)}catch(d){setTimeout(function(){throw d})}}var bN=typeof WeakMap=="function"?WeakMap:Map;function cy(s,i,d){d=as(-1,d),d.tag=3,d.payload={element:null};var g=i.value;return d.callback=function(){lu||(lu=!0,wp=g),op(s,i)},d}function uy(s,i,d){d=as(-1,d),d.tag=3;var g=s.type.getDerivedStateFromError;if(typeof g=="function"){var w=i.value;d.payload=function(){return g(w)},d.callback=function(){op(s,i)}}var b=s.stateNode;return b!==null&&typeof b.componentDidCatch=="function"&&(d.callback=function(){op(s,i),typeof g!="function"&&(js===null?js=new Set([this]):js.add(this));var T=i.stack;this.componentDidCatch(i.value,{componentStack:T!==null?T:""})}),d}function dy(s,i,d){var g=s.pingCache;if(g===null){g=s.pingCache=new bN;var w=new Set;g.set(i,w)}else w=g.get(i),w===void 0&&(w=new Set,g.set(i,w));w.has(d)||(w.add(d),s=MN.bind(null,s,i,d),i.then(s,s))}function fy(s){do{var i;if((i=s.tag===13)&&(i=s.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return s;s=s.return}while(s!==null);return null}function py(s,i,d,g,w){return(s.mode&1)===0?(s===i?s.flags|=65536:(s.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(i=as(-1,1),i.tag=2,Ns(d,i,1))),d.lanes|=1),s):(s.flags|=65536,s.lanes=w,s)}var xN=M.ReactCurrentOwner,Fr=!1;function Ar(s,i,d,g){i.child=s===null?Ok(i,null,d,g):na(i,s.child,d,g)}function hy(s,i,d,g,w){d=d.render;var b=i.ref;return oa(i,w),g=Vf(s,i,d,g,b,w),d=Yf(),s!==null&&!Fr?(i.updateQueue=s.updateQueue,i.flags&=-2053,s.lanes&=~w,ls(s,i,w)):(jn&&d&&Rf(i),i.flags|=1,Ar(s,i,g,w),i.child)}function my(s,i,d,g,w){if(s===null){var b=d.type;return typeof b=="function"&&!Np(b)&&b.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(i.tag=15,i.type=b,gy(s,i,b,g,w)):(s=hu(d.type,null,g,i,i.mode,w),s.ref=i.ref,s.return=i,i.child=s)}if(b=s.child,(s.lanes&w)===0){var T=b.memoizedProps;if(d=d.compare,d=d!==null?d:Xa,d(T,g)&&s.ref===i.ref)return ls(s,i,w)}return i.flags|=1,s=Rs(b,g),s.ref=i.ref,s.return=i,i.child=s}function gy(s,i,d,g,w){if(s!==null){var b=s.memoizedProps;if(Xa(b,g)&&s.ref===i.ref)if(Fr=!1,i.pendingProps=g=b,(s.lanes&w)!==0)(s.flags&131072)!==0&&(Fr=!0);else return i.lanes=s.lanes,ls(s,i,w)}return sp(s,i,d,g,w)}function ky(s,i,d){var g=i.pendingProps,w=g.children,b=s!==null?s.memoizedState:null;if(g.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},yn(la,Jr),Jr|=d;else{if((d&1073741824)===0)return s=b!==null?b.baseLanes|d:d,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:s,cachePool:null,transitions:null},i.updateQueue=null,yn(la,Jr),Jr|=s,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},g=b!==null?b.baseLanes:d,yn(la,Jr),Jr|=g}else b!==null?(g=b.baseLanes|d,i.memoizedState=null):g=d,yn(la,Jr),Jr|=g;return Ar(s,i,w,d),i.child}function yy(s,i){var d=i.ref;(s===null&&d!==null||s!==null&&s.ref!==d)&&(i.flags|=512,i.flags|=2097152)}function sp(s,i,d,g,w){var b=zr(d)?ii:br.current;return b=Xi(i,b),oa(i,w),d=Vf(s,i,d,g,b,w),g=Yf(),s!==null&&!Fr?(i.updateQueue=s.updateQueue,i.flags&=-2053,s.lanes&=~w,ls(s,i,w)):(jn&&g&&Rf(i),i.flags|=1,Ar(s,i,d,w),i.child)}function wy(s,i,d,g,w){if(zr(d)){var b=!0;zc(i)}else b=!1;if(oa(i,w),i.stateNode===null)ru(s,i),ay(i,d,g),np(i,d,g,w),g=!0;else if(s===null){var T=i.stateNode,F=i.memoizedProps;T.props=F;var G=T.context,le=d.contextType;typeof le=="object"&&le!==null?le=lo(le):(le=zr(d)?ii:br.current,le=Xi(i,le));var Te=d.getDerivedStateFromProps,Ae=typeof Te=="function"||typeof T.getSnapshotBeforeUpdate=="function";Ae||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(F!==g||G!==le)&&ly(i,T,g,le),Ss=!1;var Se=i.memoizedState;T.state=Se,Gc(i,g,T,w),G=i.memoizedState,F!==g||Se!==G||Dr.current||Ss?(typeof Te=="function"&&(tp(i,d,Te,g),G=i.memoizedState),(F=Ss||iy(i,d,F,g,Se,G,le))?(Ae||typeof T.UNSAFE_componentWillMount!="function"&&typeof T.componentWillMount!="function"||(typeof T.componentWillMount=="function"&&T.componentWillMount(),typeof T.UNSAFE_componentWillMount=="function"&&T.UNSAFE_componentWillMount()),typeof T.componentDidMount=="function"&&(i.flags|=4194308)):(typeof T.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=g,i.memoizedState=G),T.props=g,T.state=G,T.context=le,g=F):(typeof T.componentDidMount=="function"&&(i.flags|=4194308),g=!1)}else{T=i.stateNode,Mk(s,i),F=i.memoizedProps,le=i.type===i.elementType?F:So(i.type,F),T.props=le,Ae=i.pendingProps,Se=T.context,G=d.contextType,typeof G=="object"&&G!==null?G=lo(G):(G=zr(d)?ii:br.current,G=Xi(i,G));var Ze=d.getDerivedStateFromProps;(Te=typeof Ze=="function"||typeof T.getSnapshotBeforeUpdate=="function")||typeof T.UNSAFE_componentWillReceiveProps!="function"&&typeof T.componentWillReceiveProps!="function"||(F!==Ae||Se!==G)&&ly(i,T,g,G),Ss=!1,Se=i.memoizedState,T.state=Se,Gc(i,g,T,w);var Qe=i.memoizedState;F!==Ae||Se!==Qe||Dr.current||Ss?(typeof Ze=="function"&&(tp(i,d,Ze,g),Qe=i.memoizedState),(le=Ss||iy(i,d,le,g,Se,Qe,G)||!1)?(Te||typeof T.UNSAFE_componentWillUpdate!="function"&&typeof T.componentWillUpdate!="function"||(typeof T.componentWillUpdate=="function"&&T.componentWillUpdate(g,Qe,G),typeof T.UNSAFE_componentWillUpdate=="function"&&T.UNSAFE_componentWillUpdate(g,Qe,G)),typeof T.componentDidUpdate=="function"&&(i.flags|=4),typeof T.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof T.componentDidUpdate!="function"||F===s.memoizedProps&&Se===s.memoizedState||(i.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||F===s.memoizedProps&&Se===s.memoizedState||(i.flags|=1024),i.memoizedProps=g,i.memoizedState=Qe),T.props=g,T.state=Qe,T.context=G,g=le):(typeof T.componentDidUpdate!="function"||F===s.memoizedProps&&Se===s.memoizedState||(i.flags|=4),typeof T.getSnapshotBeforeUpdate!="function"||F===s.memoizedProps&&Se===s.memoizedState||(i.flags|=1024),g=!1)}return ip(s,i,d,g,b,w)}function ip(s,i,d,g,w,b){yy(s,i);var T=(i.flags&128)!==0;if(!g&&!T)return w&&Ek(i,d,!1),ls(s,i,b);g=i.stateNode,xN.current=i;var F=T&&typeof d.getDerivedStateFromError!="function"?null:g.render();return i.flags|=1,s!==null&&T?(i.child=na(i,s.child,null,b),i.child=na(i,null,F,b)):Ar(s,i,F,b),i.memoizedState=g.state,w&&Ek(i,d,!0),i.child}function vy(s){var i=s.stateNode;i.pendingContext?xk(s,i.pendingContext,i.pendingContext!==i.context):i.context&&xk(s,i.context,!1),Hf(s,i.containerInfo)}function by(s,i,d,g,w){return ta(),Lf(w),i.flags|=256,Ar(s,i,d,g),i.child}var ap={dehydrated:null,treeContext:null,retryLane:0};function lp(s){return{baseLanes:s,cachePool:null,transitions:null}}function xy(s,i,d){var g=i.pendingProps,w=Ln.current,b=!1,T=(i.flags&128)!==0,F;if((F=T)||(F=s!==null&&s.memoizedState===null?!1:(w&2)!==0),F?(b=!0,i.flags&=-129):(s===null||s.memoizedState!==null)&&(w|=1),yn(Ln,w&1),s===null)return Mf(i),s=i.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?((i.mode&1)===0?i.lanes=1:s.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(T=g.children,s=g.fallback,b?(g=i.mode,b=i.child,T={mode:"hidden",children:T},(g&1)===0&&b!==null?(b.childLanes=0,b.pendingProps=T):b=mu(T,g,0,null),s=gi(s,g,d,null),b.return=i,s.return=i,b.sibling=s,i.child=b,i.child.memoizedState=lp(d),i.memoizedState=ap,s):cp(i,T));if(w=s.memoizedState,w!==null&&(F=w.dehydrated,F!==null))return _N(s,i,T,g,F,w,d);if(b){b=g.fallback,T=i.mode,w=s.child,F=w.sibling;var G={mode:"hidden",children:g.children};return(T&1)===0&&i.child!==w?(g=i.child,g.childLanes=0,g.pendingProps=G,i.deletions=null):(g=Rs(w,G),g.subtreeFlags=w.subtreeFlags&14680064),F!==null?b=Rs(F,b):(b=gi(b,T,d,null),b.flags|=2),b.return=i,g.return=i,g.sibling=b,i.child=g,g=b,b=i.child,T=s.child.memoizedState,T=T===null?lp(d):{baseLanes:T.baseLanes|d,cachePool:null,transitions:T.transitions},b.memoizedState=T,b.childLanes=s.childLanes&~d,i.memoizedState=ap,g}return b=s.child,s=b.sibling,g=Rs(b,{mode:"visible",children:g.children}),(i.mode&1)===0&&(g.lanes=d),g.return=i,g.sibling=null,s!==null&&(d=i.deletions,d===null?(i.deletions=[s],i.flags|=16):d.push(s)),i.child=g,i.memoizedState=null,g}function cp(s,i){return i=mu({mode:"visible",children:i},s.mode,0,null),i.return=s,s.child=i}function nu(s,i,d,g){return g!==null&&Lf(g),na(i,s.child,null,d),s=cp(i,i.pendingProps.children),s.flags|=2,i.memoizedState=null,s}function _N(s,i,d,g,w,b,T){if(d)return i.flags&256?(i.flags&=-257,g=rp(Error(n(422))),nu(s,i,T,g)):i.memoizedState!==null?(i.child=s.child,i.flags|=128,null):(b=g.fallback,w=i.mode,g=mu({mode:"visible",children:g.children},w,0,null),b=gi(b,w,T,null),b.flags|=2,g.return=i,b.return=i,g.sibling=b,i.child=g,(i.mode&1)!==0&&na(i,s.child,null,T),i.child.memoizedState=lp(T),i.memoizedState=ap,b);if((i.mode&1)===0)return nu(s,i,T,null);if(w.data==="$!"){if(g=w.nextSibling&&w.nextSibling.dataset,g)var F=g.dgst;return g=F,b=Error(n(419)),g=rp(b,g,void 0),nu(s,i,T,g)}if(F=(T&s.childLanes)!==0,Fr||F){if(g=pr,g!==null){switch(T&-T){case 4:w=2;break;case 16:w=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:w=32;break;case 536870912:w=268435456;break;default:w=0}w=(w&(g.suspendedLanes|T))!==0?0:w,w!==0&&w!==b.retryLane&&(b.retryLane=w,is(s,w),jo(g,s,w,-1))}return Sp(),g=rp(Error(n(421))),nu(s,i,T,g)}return w.data==="$?"?(i.flags|=128,i.child=s.child,i=LN.bind(null,s),w._reactRetry=i,null):(s=b.treeContext,Xr=bs(w.nextSibling),Qr=i,jn=!0,Eo=null,s!==null&&(io[ao++]=os,io[ao++]=ss,io[ao++]=ai,os=s.id,ss=s.overflow,ai=i),i=cp(i,g.children),i.flags|=4096,i)}function _y(s,i,d){s.lanes|=i;var g=s.alternate;g!==null&&(g.lanes|=i),Ff(s.return,i,d)}function up(s,i,d,g,w){var b=s.memoizedState;b===null?s.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:g,tail:d,tailMode:w}:(b.isBackwards=i,b.rendering=null,b.renderingStartTime=0,b.last=g,b.tail=d,b.tailMode=w)}function Ey(s,i,d){var g=i.pendingProps,w=g.revealOrder,b=g.tail;if(Ar(s,i,g.children,d),g=Ln.current,(g&2)!==0)g=g&1|2,i.flags|=128;else{if(s!==null&&(s.flags&128)!==0)e:for(s=i.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&_y(s,d,i);else if(s.tag===19)_y(s,d,i);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===i)break e;for(;s.sibling===null;){if(s.return===null||s.return===i)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}g&=1}if(yn(Ln,g),(i.mode&1)===0)i.memoizedState=null;else switch(w){case"forwards":for(d=i.child,w=null;d!==null;)s=d.alternate,s!==null&&Vc(s)===null&&(w=d),d=d.sibling;d=w,d===null?(w=i.child,i.child=null):(w=d.sibling,d.sibling=null),up(i,!1,w,d,b);break;case"backwards":for(d=null,w=i.child,i.child=null;w!==null;){if(s=w.alternate,s!==null&&Vc(s)===null){i.child=w;break}s=w.sibling,w.sibling=d,d=w,w=s}up(i,!0,d,null,b);break;case"together":up(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function ru(s,i){(i.mode&1)===0&&s!==null&&(s.alternate=null,i.alternate=null,i.flags|=2)}function ls(s,i,d){if(s!==null&&(i.dependencies=s.dependencies),fi|=i.lanes,(d&i.childLanes)===0)return null;if(s!==null&&i.child!==s.child)throw Error(n(153));if(i.child!==null){for(s=i.child,d=Rs(s,s.pendingProps),i.child=d,d.return=i;s.sibling!==null;)s=s.sibling,d=d.sibling=Rs(s,s.pendingProps),d.return=i;d.sibling=null}return i.child}function EN(s,i,d){switch(i.tag){case 3:vy(i),ta();break;case 5:Dk(i);break;case 1:zr(i.type)&&zc(i);break;case 4:Hf(i,i.stateNode.containerInfo);break;case 10:var g=i.type._context,w=i.memoizedProps.value;yn(Kc,g._currentValue),g._currentValue=w;break;case 13:if(g=i.memoizedState,g!==null)return g.dehydrated!==null?(yn(Ln,Ln.current&1),i.flags|=128,null):(d&i.child.childLanes)!==0?xy(s,i,d):(yn(Ln,Ln.current&1),s=ls(s,i,d),s!==null?s.sibling:null);yn(Ln,Ln.current&1);break;case 19:if(g=(d&i.childLanes)!==0,(s.flags&128)!==0){if(g)return Ey(s,i,d);i.flags|=128}if(w=i.memoizedState,w!==null&&(w.rendering=null,w.tail=null,w.lastEffect=null),yn(Ln,Ln.current),g)break;return null;case 22:case 23:return i.lanes=0,ky(s,i,d)}return ls(s,i,d)}var Sy,dp,Ny,Ty;Sy=function(s,i){for(var d=i.child;d!==null;){if(d.tag===5||d.tag===6)s.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===i)break;for(;d.sibling===null;){if(d.return===null||d.return===i)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},dp=function(){},Ny=function(s,i,d,g){var w=s.memoizedProps;if(w!==g){s=i.stateNode,ui(Ho.current);var b=null;switch(d){case"input":w=Fe(s,w),g=Fe(s,g),b=[];break;case"select":w=Z({},w,{value:void 0}),g=Z({},g,{value:void 0}),b=[];break;case"textarea":w=J(s,w),g=J(s,g),b=[];break;default:typeof w.onClick!="function"&&typeof g.onClick=="function"&&(s.onclick=Lc)}kt(d,g);var T;d=null;for(le in w)if(!g.hasOwnProperty(le)&&w.hasOwnProperty(le)&&w[le]!=null)if(le==="style"){var F=w[le];for(T in F)F.hasOwnProperty(T)&&(d||(d={}),d[T]="")}else le!=="dangerouslySetInnerHTML"&&le!=="children"&&le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&le!=="autoFocus"&&(o.hasOwnProperty(le)?b||(b=[]):(b=b||[]).push(le,null));for(le in g){var G=g[le];if(F=w!=null?w[le]:void 0,g.hasOwnProperty(le)&&G!==F&&(G!=null||F!=null))if(le==="style")if(F){for(T in F)!F.hasOwnProperty(T)||G&&G.hasOwnProperty(T)||(d||(d={}),d[T]="");for(T in G)G.hasOwnProperty(T)&&F[T]!==G[T]&&(d||(d={}),d[T]=G[T])}else d||(b||(b=[]),b.push(le,d)),d=G;else le==="dangerouslySetInnerHTML"?(G=G?G.__html:void 0,F=F?F.__html:void 0,G!=null&&F!==G&&(b=b||[]).push(le,G)):le==="children"?typeof G!="string"&&typeof G!="number"||(b=b||[]).push(le,""+G):le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&(o.hasOwnProperty(le)?(G!=null&&le==="onScroll"&&_n("scroll",s),b||F===G||(b=[])):(b=b||[]).push(le,G))}d&&(b=b||[]).push("style",d);var le=b;(i.updateQueue=le)&&(i.flags|=4)}},Ty=function(s,i,d,g){d!==g&&(i.flags|=4)};function pl(s,i){if(!jn)switch(s.tailMode){case"hidden":i=s.tail;for(var d=null;i!==null;)i.alternate!==null&&(d=i),i=i.sibling;d===null?s.tail=null:d.sibling=null;break;case"collapsed":d=s.tail;for(var g=null;d!==null;)d.alternate!==null&&(g=d),d=d.sibling;g===null?i||s.tail===null?s.tail=null:s.tail.sibling=null:g.sibling=null}}function _r(s){var i=s.alternate!==null&&s.alternate.child===s.child,d=0,g=0;if(i)for(var w=s.child;w!==null;)d|=w.lanes|w.childLanes,g|=w.subtreeFlags&14680064,g|=w.flags&14680064,w.return=s,w=w.sibling;else for(w=s.child;w!==null;)d|=w.lanes|w.childLanes,g|=w.subtreeFlags,g|=w.flags,w.return=s,w=w.sibling;return s.subtreeFlags|=g,s.childLanes=d,i}function SN(s,i,d){var g=i.pendingProps;switch(Of(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _r(i),null;case 1:return zr(i.type)&&Dc(),_r(i),null;case 3:return g=i.stateNode,sa(),En(Dr),En(br),Zf(),g.pendingContext&&(g.context=g.pendingContext,g.pendingContext=null),(s===null||s.child===null)&&(Hc(i)?i.flags|=4:s===null||s.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Eo!==null&&(xp(Eo),Eo=null))),dp(s,i),_r(i),null;case 5:Wf(i);var w=ui(ll.current);if(d=i.type,s!==null&&i.stateNode!=null)Ny(s,i,d,g,w),s.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!g){if(i.stateNode===null)throw Error(n(166));return _r(i),null}if(s=ui(Ho.current),Hc(i)){g=i.stateNode,d=i.type;var b=i.memoizedProps;switch(g[Uo]=i,g[rl]=b,s=(i.mode&1)!==0,d){case"dialog":_n("cancel",g),_n("close",g);break;case"iframe":case"object":case"embed":_n("load",g);break;case"video":case"audio":for(w=0;w<el.length;w++)_n(el[w],g);break;case"source":_n("error",g);break;case"img":case"image":case"link":_n("error",g),_n("load",g);break;case"details":_n("toggle",g);break;case"input":pt(g,b),_n("invalid",g);break;case"select":g._wrapperState={wasMultiple:!!b.multiple},_n("invalid",g);break;case"textarea":we(g,b),_n("invalid",g)}kt(d,b),w=null;for(var T in b)if(b.hasOwnProperty(T)){var F=b[T];T==="children"?typeof F=="string"?g.textContent!==F&&(b.suppressHydrationWarning!==!0&&Mc(g.textContent,F,s),w=["children",F]):typeof F=="number"&&g.textContent!==""+F&&(b.suppressHydrationWarning!==!0&&Mc(g.textContent,F,s),w=["children",""+F]):o.hasOwnProperty(T)&&F!=null&&T==="onScroll"&&_n("scroll",g)}switch(d){case"input":Y(g),at(g,b,!0);break;case"textarea":Y(g),et(g);break;case"select":case"option":break;default:typeof b.onClick=="function"&&(g.onclick=Lc)}g=w,i.updateQueue=g,g!==null&&(i.flags|=4)}else{T=w.nodeType===9?w:w.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=Wt(d)),s==="http://www.w3.org/1999/xhtml"?d==="script"?(s=T.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof g.is=="string"?s=T.createElement(d,{is:g.is}):(s=T.createElement(d),d==="select"&&(T=s,g.multiple?T.multiple=!0:g.size&&(T.size=g.size))):s=T.createElementNS(s,d),s[Uo]=i,s[rl]=g,Sy(s,i,!1,!1),i.stateNode=s;e:{switch(T=Gt(d,g),d){case"dialog":_n("cancel",s),_n("close",s),w=g;break;case"iframe":case"object":case"embed":_n("load",s),w=g;break;case"video":case"audio":for(w=0;w<el.length;w++)_n(el[w],s);w=g;break;case"source":_n("error",s),w=g;break;case"img":case"image":case"link":_n("error",s),_n("load",s),w=g;break;case"details":_n("toggle",s),w=g;break;case"input":pt(s,g),w=Fe(s,g),_n("invalid",s);break;case"option":w=g;break;case"select":s._wrapperState={wasMultiple:!!g.multiple},w=Z({},g,{value:void 0}),_n("invalid",s);break;case"textarea":we(s,g),w=J(s,g),_n("invalid",s);break;default:w=g}kt(d,w),F=w;for(b in F)if(F.hasOwnProperty(b)){var G=F[b];b==="style"?Dt(s,G):b==="dangerouslySetInnerHTML"?(G=G?G.__html:void 0,G!=null&&Me(s,G)):b==="children"?typeof G=="string"?(d!=="textarea"||G!=="")&&hn(s,G):typeof G=="number"&&hn(s,""+G):b!=="suppressContentEditableWarning"&&b!=="suppressHydrationWarning"&&b!=="autoFocus"&&(o.hasOwnProperty(b)?G!=null&&b==="onScroll"&&_n("scroll",s):G!=null&&E(s,b,G,T))}switch(d){case"input":Y(s),at(s,g,!1);break;case"textarea":Y(s),et(s);break;case"option":g.value!=null&&s.setAttribute("value",""+ve(g.value));break;case"select":s.multiple=!!g.multiple,b=g.value,b!=null?qe(s,!!g.multiple,b,!1):g.defaultValue!=null&&qe(s,!!g.multiple,g.defaultValue,!0);break;default:typeof w.onClick=="function"&&(s.onclick=Lc)}switch(d){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}}g&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return _r(i),null;case 6:if(s&&i.stateNode!=null)Ty(s,i,s.memoizedProps,g);else{if(typeof g!="string"&&i.stateNode===null)throw Error(n(166));if(d=ui(ll.current),ui(Ho.current),Hc(i)){if(g=i.stateNode,d=i.memoizedProps,g[Uo]=i,(b=g.nodeValue!==d)&&(s=Qr,s!==null))switch(s.tag){case 3:Mc(g.nodeValue,d,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&Mc(g.nodeValue,d,(s.mode&1)!==0)}b&&(i.flags|=4)}else g=(d.nodeType===9?d:d.ownerDocument).createTextNode(g),g[Uo]=i,i.stateNode=g}return _r(i),null;case 13:if(En(Ln),g=i.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(jn&&Xr!==null&&(i.mode&1)!==0&&(i.flags&128)===0)Ak(),ta(),i.flags|=98560,b=!1;else if(b=Hc(i),g!==null&&g.dehydrated!==null){if(s===null){if(!b)throw Error(n(318));if(b=i.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(n(317));b[Uo]=i}else ta(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;_r(i),b=!1}else Eo!==null&&(xp(Eo),Eo=null),b=!0;if(!b)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=d,i):(g=g!==null,g!==(s!==null&&s.memoizedState!==null)&&g&&(i.child.flags|=8192,(i.mode&1)!==0&&(s===null||(Ln.current&1)!==0?cr===0&&(cr=3):Sp())),i.updateQueue!==null&&(i.flags|=4),_r(i),null);case 4:return sa(),dp(s,i),s===null&&tl(i.stateNode.containerInfo),_r(i),null;case 10:return zf(i.type._context),_r(i),null;case 17:return zr(i.type)&&Dc(),_r(i),null;case 19:if(En(Ln),b=i.memoizedState,b===null)return _r(i),null;if(g=(i.flags&128)!==0,T=b.rendering,T===null)if(g)pl(b,!1);else{if(cr!==0||s!==null&&(s.flags&128)!==0)for(s=i.child;s!==null;){if(T=Vc(s),T!==null){for(i.flags|=128,pl(b,!1),g=T.updateQueue,g!==null&&(i.updateQueue=g,i.flags|=4),i.subtreeFlags=0,g=d,d=i.child;d!==null;)b=d,s=g,b.flags&=14680066,T=b.alternate,T===null?(b.childLanes=0,b.lanes=s,b.child=null,b.subtreeFlags=0,b.memoizedProps=null,b.memoizedState=null,b.updateQueue=null,b.dependencies=null,b.stateNode=null):(b.childLanes=T.childLanes,b.lanes=T.lanes,b.child=T.child,b.subtreeFlags=0,b.deletions=null,b.memoizedProps=T.memoizedProps,b.memoizedState=T.memoizedState,b.updateQueue=T.updateQueue,b.type=T.type,s=T.dependencies,b.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),d=d.sibling;return yn(Ln,Ln.current&1|2),i.child}s=s.sibling}b.tail!==null&&on()>ca&&(i.flags|=128,g=!0,pl(b,!1),i.lanes=4194304)}else{if(!g)if(s=Vc(T),s!==null){if(i.flags|=128,g=!0,d=s.updateQueue,d!==null&&(i.updateQueue=d,i.flags|=4),pl(b,!0),b.tail===null&&b.tailMode==="hidden"&&!T.alternate&&!jn)return _r(i),null}else 2*on()-b.renderingStartTime>ca&&d!==1073741824&&(i.flags|=128,g=!0,pl(b,!1),i.lanes=4194304);b.isBackwards?(T.sibling=i.child,i.child=T):(d=b.last,d!==null?d.sibling=T:i.child=T,b.last=T)}return b.tail!==null?(i=b.tail,b.rendering=i,b.tail=i.sibling,b.renderingStartTime=on(),i.sibling=null,d=Ln.current,yn(Ln,g?d&1|2:d&1),i):(_r(i),null);case 22:case 23:return Ep(),g=i.memoizedState!==null,s!==null&&s.memoizedState!==null!==g&&(i.flags|=8192),g&&(i.mode&1)!==0?(Jr&1073741824)!==0&&(_r(i),i.subtreeFlags&6&&(i.flags|=8192)):_r(i),null;case 24:return null;case 25:return null}throw Error(n(156,i.tag))}function NN(s,i){switch(Of(i),i.tag){case 1:return zr(i.type)&&Dc(),s=i.flags,s&65536?(i.flags=s&-65537|128,i):null;case 3:return sa(),En(Dr),En(br),Zf(),s=i.flags,(s&65536)!==0&&(s&128)===0?(i.flags=s&-65537|128,i):null;case 5:return Wf(i),null;case 13:if(En(Ln),s=i.memoizedState,s!==null&&s.dehydrated!==null){if(i.alternate===null)throw Error(n(340));ta()}return s=i.flags,s&65536?(i.flags=s&-65537|128,i):null;case 19:return En(Ln),null;case 4:return sa(),null;case 10:return zf(i.type._context),null;case 22:case 23:return Ep(),null;case 24:return null;default:return null}}var ou=!1,Er=!1,TN=typeof WeakSet=="function"?WeakSet:Set,Ye=null;function aa(s,i){var d=s.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(g){Wn(s,i,g)}else d.current=null}function fp(s,i,d){try{d()}catch(g){Wn(s,i,g)}}var jy=!1;function jN(s,i){if(Ef=Js,s=ik(),gf(s)){if("selectionStart"in s)var d={start:s.selectionStart,end:s.selectionEnd};else e:{d=(d=s.ownerDocument)&&d.defaultView||window;var g=d.getSelection&&d.getSelection();if(g&&g.rangeCount!==0){d=g.anchorNode;var w=g.anchorOffset,b=g.focusNode;g=g.focusOffset;try{d.nodeType,b.nodeType}catch{d=null;break e}var T=0,F=-1,G=-1,le=0,Te=0,Ae=s,Se=null;t:for(;;){for(var Ze;Ae!==d||w!==0&&Ae.nodeType!==3||(F=T+w),Ae!==b||g!==0&&Ae.nodeType!==3||(G=T+g),Ae.nodeType===3&&(T+=Ae.nodeValue.length),(Ze=Ae.firstChild)!==null;)Se=Ae,Ae=Ze;for(;;){if(Ae===s)break t;if(Se===d&&++le===w&&(F=T),Se===b&&++Te===g&&(G=T),(Ze=Ae.nextSibling)!==null)break;Ae=Se,Se=Ae.parentNode}Ae=Ze}d=F===-1||G===-1?null:{start:F,end:G}}else d=null}d=d||{start:0,end:0}}else d=null;for(Sf={focusedElem:s,selectionRange:d},Js=!1,Ye=i;Ye!==null;)if(i=Ye,s=i.child,(i.subtreeFlags&1028)!==0&&s!==null)s.return=i,Ye=s;else for(;Ye!==null;){i=Ye;try{var Qe=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(Qe!==null){var Je=Qe.memoizedProps,qn=Qe.memoizedState,re=i.stateNode,Q=re.getSnapshotBeforeUpdate(i.elementType===i.type?Je:So(i.type,Je),qn);re.__reactInternalSnapshotBeforeUpdate=Q}break;case 3:var ie=i.stateNode.containerInfo;ie.nodeType===1?ie.textContent="":ie.nodeType===9&&ie.documentElement&&ie.removeChild(ie.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Le){Wn(i,i.return,Le)}if(s=i.sibling,s!==null){s.return=i.return,Ye=s;break}Ye=i.return}return Qe=jy,jy=!1,Qe}function hl(s,i,d){var g=i.updateQueue;if(g=g!==null?g.lastEffect:null,g!==null){var w=g=g.next;do{if((w.tag&s)===s){var b=w.destroy;w.destroy=void 0,b!==void 0&&fp(i,d,b)}w=w.next}while(w!==g)}}function su(s,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var d=i=i.next;do{if((d.tag&s)===s){var g=d.create;d.destroy=g()}d=d.next}while(d!==i)}}function pp(s){var i=s.ref;if(i!==null){var d=s.stateNode;switch(s.tag){case 5:s=d;break;default:s=d}typeof i=="function"?i(s):i.current=s}}function Cy(s){var i=s.alternate;i!==null&&(s.alternate=null,Cy(i)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(i=s.stateNode,i!==null&&(delete i[Uo],delete i[rl],delete i[Cf],delete i[uN],delete i[dN])),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}function Ay(s){return s.tag===5||s.tag===3||s.tag===4}function Iy(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Ay(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function hp(s,i,d){var g=s.tag;if(g===5||g===6)s=s.stateNode,i?d.nodeType===8?d.parentNode.insertBefore(s,i):d.insertBefore(s,i):(d.nodeType===8?(i=d.parentNode,i.insertBefore(s,d)):(i=d,i.appendChild(s)),d=d._reactRootContainer,d!=null||i.onclick!==null||(i.onclick=Lc));else if(g!==4&&(s=s.child,s!==null))for(hp(s,i,d),s=s.sibling;s!==null;)hp(s,i,d),s=s.sibling}function mp(s,i,d){var g=s.tag;if(g===5||g===6)s=s.stateNode,i?d.insertBefore(s,i):d.appendChild(s);else if(g!==4&&(s=s.child,s!==null))for(mp(s,i,d),s=s.sibling;s!==null;)mp(s,i,d),s=s.sibling}var kr=null,No=!1;function Ts(s,i,d){for(d=d.child;d!==null;)Ry(s,i,d),d=d.sibling}function Ry(s,i,d){if(xt&&typeof xt.onCommitFiberUnmount=="function")try{xt.onCommitFiberUnmount(yt,d)}catch{}switch(d.tag){case 5:Er||aa(d,i);case 6:var g=kr,w=No;kr=null,Ts(s,i,d),kr=g,No=w,kr!==null&&(No?(s=kr,d=d.stateNode,s.nodeType===8?s.parentNode.removeChild(d):s.removeChild(d)):kr.removeChild(d.stateNode));break;case 18:kr!==null&&(No?(s=kr,d=d.stateNode,s.nodeType===8?jf(s.parentNode,d):s.nodeType===1&&jf(s,d),Fo(s)):jf(kr,d.stateNode));break;case 4:g=kr,w=No,kr=d.stateNode.containerInfo,No=!0,Ts(s,i,d),kr=g,No=w;break;case 0:case 11:case 14:case 15:if(!Er&&(g=d.updateQueue,g!==null&&(g=g.lastEffect,g!==null))){w=g=g.next;do{var b=w,T=b.destroy;b=b.tag,T!==void 0&&((b&2)!==0||(b&4)!==0)&&fp(d,i,T),w=w.next}while(w!==g)}Ts(s,i,d);break;case 1:if(!Er&&(aa(d,i),g=d.stateNode,typeof g.componentWillUnmount=="function"))try{g.props=d.memoizedProps,g.state=d.memoizedState,g.componentWillUnmount()}catch(F){Wn(d,i,F)}Ts(s,i,d);break;case 21:Ts(s,i,d);break;case 22:d.mode&1?(Er=(g=Er)||d.memoizedState!==null,Ts(s,i,d),Er=g):Ts(s,i,d);break;default:Ts(s,i,d)}}function Oy(s){var i=s.updateQueue;if(i!==null){s.updateQueue=null;var d=s.stateNode;d===null&&(d=s.stateNode=new TN),i.forEach(function(g){var w=PN.bind(null,s,g);d.has(g)||(d.add(g),g.then(w,w))})}}function To(s,i){var d=i.deletions;if(d!==null)for(var g=0;g<d.length;g++){var w=d[g];try{var b=s,T=i,F=T;e:for(;F!==null;){switch(F.tag){case 5:kr=F.stateNode,No=!1;break e;case 3:kr=F.stateNode.containerInfo,No=!0;break e;case 4:kr=F.stateNode.containerInfo,No=!0;break e}F=F.return}if(kr===null)throw Error(n(160));Ry(b,T,w),kr=null,No=!1;var G=w.alternate;G!==null&&(G.return=null),w.return=null}catch(le){Wn(w,i,le)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)$y(i,s),i=i.sibling}function $y(s,i){var d=s.alternate,g=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(To(i,s),Ko(s),g&4){try{hl(3,s,s.return),su(3,s)}catch(Je){Wn(s,s.return,Je)}try{hl(5,s,s.return)}catch(Je){Wn(s,s.return,Je)}}break;case 1:To(i,s),Ko(s),g&512&&d!==null&&aa(d,d.return);break;case 5:if(To(i,s),Ko(s),g&512&&d!==null&&aa(d,d.return),s.flags&32){var w=s.stateNode;try{hn(w,"")}catch(Je){Wn(s,s.return,Je)}}if(g&4&&(w=s.stateNode,w!=null)){var b=s.memoizedProps,T=d!==null?d.memoizedProps:b,F=s.type,G=s.updateQueue;if(s.updateQueue=null,G!==null)try{F==="input"&&b.type==="radio"&&b.name!=null&&Ge(w,b),Gt(F,T);var le=Gt(F,b);for(T=0;T<G.length;T+=2){var Te=G[T],Ae=G[T+1];Te==="style"?Dt(w,Ae):Te==="dangerouslySetInnerHTML"?Me(w,Ae):Te==="children"?hn(w,Ae):E(w,Te,Ae,le)}switch(F){case"input":vt(w,b);break;case"textarea":Xe(w,b);break;case"select":var Se=w._wrapperState.wasMultiple;w._wrapperState.wasMultiple=!!b.multiple;var Ze=b.value;Ze!=null?qe(w,!!b.multiple,Ze,!1):Se!==!!b.multiple&&(b.defaultValue!=null?qe(w,!!b.multiple,b.defaultValue,!0):qe(w,!!b.multiple,b.multiple?[]:"",!1))}w[rl]=b}catch(Je){Wn(s,s.return,Je)}}break;case 6:if(To(i,s),Ko(s),g&4){if(s.stateNode===null)throw Error(n(162));w=s.stateNode,b=s.memoizedProps;try{w.nodeValue=b}catch(Je){Wn(s,s.return,Je)}}break;case 3:if(To(i,s),Ko(s),g&4&&d!==null&&d.memoizedState.isDehydrated)try{Fo(i.containerInfo)}catch(Je){Wn(s,s.return,Je)}break;case 4:To(i,s),Ko(s);break;case 13:To(i,s),Ko(s),w=s.child,w.flags&8192&&(b=w.memoizedState!==null,w.stateNode.isHidden=b,!b||w.alternate!==null&&w.alternate.memoizedState!==null||(yp=on())),g&4&&Oy(s);break;case 22:if(Te=d!==null&&d.memoizedState!==null,s.mode&1?(Er=(le=Er)||Te,To(i,s),Er=le):To(i,s),Ko(s),g&8192){if(le=s.memoizedState!==null,(s.stateNode.isHidden=le)&&!Te&&(s.mode&1)!==0)for(Ye=s,Te=s.child;Te!==null;){for(Ae=Ye=Te;Ye!==null;){switch(Se=Ye,Ze=Se.child,Se.tag){case 0:case 11:case 14:case 15:hl(4,Se,Se.return);break;case 1:aa(Se,Se.return);var Qe=Se.stateNode;if(typeof Qe.componentWillUnmount=="function"){g=Se,d=Se.return;try{i=g,Qe.props=i.memoizedProps,Qe.state=i.memoizedState,Qe.componentWillUnmount()}catch(Je){Wn(g,d,Je)}}break;case 5:aa(Se,Se.return);break;case 22:if(Se.memoizedState!==null){Py(Ae);continue}}Ze!==null?(Ze.return=Se,Ye=Ze):Py(Ae)}Te=Te.sibling}e:for(Te=null,Ae=s;;){if(Ae.tag===5){if(Te===null){Te=Ae;try{w=Ae.stateNode,le?(b=w.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none"):(F=Ae.stateNode,G=Ae.memoizedProps.style,T=G!=null&&G.hasOwnProperty("display")?G.display:null,F.style.display=In("display",T))}catch(Je){Wn(s,s.return,Je)}}}else if(Ae.tag===6){if(Te===null)try{Ae.stateNode.nodeValue=le?"":Ae.memoizedProps}catch(Je){Wn(s,s.return,Je)}}else if((Ae.tag!==22&&Ae.tag!==23||Ae.memoizedState===null||Ae===s)&&Ae.child!==null){Ae.child.return=Ae,Ae=Ae.child;continue}if(Ae===s)break e;for(;Ae.sibling===null;){if(Ae.return===null||Ae.return===s)break e;Te===Ae&&(Te=null),Ae=Ae.return}Te===Ae&&(Te=null),Ae.sibling.return=Ae.return,Ae=Ae.sibling}}break;case 19:To(i,s),Ko(s),g&4&&Oy(s);break;case 21:break;default:To(i,s),Ko(s)}}function Ko(s){var i=s.flags;if(i&2){try{e:{for(var d=s.return;d!==null;){if(Ay(d)){var g=d;break e}d=d.return}throw Error(n(160))}switch(g.tag){case 5:var w=g.stateNode;g.flags&32&&(hn(w,""),g.flags&=-33);var b=Iy(s);mp(s,b,w);break;case 3:case 4:var T=g.stateNode.containerInfo,F=Iy(s);hp(s,F,T);break;default:throw Error(n(161))}}catch(G){Wn(s,s.return,G)}s.flags&=-3}i&4096&&(s.flags&=-4097)}function CN(s,i,d){Ye=s,My(s)}function My(s,i,d){for(var g=(s.mode&1)!==0;Ye!==null;){var w=Ye,b=w.child;if(w.tag===22&&g){var T=w.memoizedState!==null||ou;if(!T){var F=w.alternate,G=F!==null&&F.memoizedState!==null||Er;F=ou;var le=Er;if(ou=T,(Er=G)&&!le)for(Ye=w;Ye!==null;)T=Ye,G=T.child,T.tag===22&&T.memoizedState!==null?Dy(w):G!==null?(G.return=T,Ye=G):Dy(w);for(;b!==null;)Ye=b,My(b),b=b.sibling;Ye=w,ou=F,Er=le}Ly(s)}else(w.subtreeFlags&8772)!==0&&b!==null?(b.return=w,Ye=b):Ly(s)}}function Ly(s){for(;Ye!==null;){var i=Ye;if((i.flags&8772)!==0){var d=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:Er||su(5,i);break;case 1:var g=i.stateNode;if(i.flags&4&&!Er)if(d===null)g.componentDidMount();else{var w=i.elementType===i.type?d.memoizedProps:So(i.type,d.memoizedProps);g.componentDidUpdate(w,d.memoizedState,g.__reactInternalSnapshotBeforeUpdate)}var b=i.updateQueue;b!==null&&Pk(i,b,g);break;case 3:var T=i.updateQueue;if(T!==null){if(d=null,i.child!==null)switch(i.child.tag){case 5:d=i.child.stateNode;break;case 1:d=i.child.stateNode}Pk(i,T,d)}break;case 5:var F=i.stateNode;if(d===null&&i.flags&4){d=F;var G=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":G.autoFocus&&d.focus();break;case"img":G.src&&(d.src=G.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var le=i.alternate;if(le!==null){var Te=le.memoizedState;if(Te!==null){var Ae=Te.dehydrated;Ae!==null&&Fo(Ae)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Er||i.flags&512&&pp(i)}catch(Se){Wn(i,i.return,Se)}}if(i===s){Ye=null;break}if(d=i.sibling,d!==null){d.return=i.return,Ye=d;break}Ye=i.return}}function Py(s){for(;Ye!==null;){var i=Ye;if(i===s){Ye=null;break}var d=i.sibling;if(d!==null){d.return=i.return,Ye=d;break}Ye=i.return}}function Dy(s){for(;Ye!==null;){var i=Ye;try{switch(i.tag){case 0:case 11:case 15:var d=i.return;try{su(4,i)}catch(G){Wn(i,d,G)}break;case 1:var g=i.stateNode;if(typeof g.componentDidMount=="function"){var w=i.return;try{g.componentDidMount()}catch(G){Wn(i,w,G)}}var b=i.return;try{pp(i)}catch(G){Wn(i,b,G)}break;case 5:var T=i.return;try{pp(i)}catch(G){Wn(i,T,G)}}}catch(G){Wn(i,i.return,G)}if(i===s){Ye=null;break}var F=i.sibling;if(F!==null){F.return=i.return,Ye=F;break}Ye=i.return}}var AN=Math.ceil,iu=M.ReactCurrentDispatcher,gp=M.ReactCurrentOwner,uo=M.ReactCurrentBatchConfig,Jt=0,pr=null,Xn=null,yr=0,Jr=0,la=xs(0),cr=0,ml=null,fi=0,au=0,kp=0,gl=null,Br=null,yp=0,ca=1/0,cs=null,lu=!1,wp=null,js=null,cu=!1,Cs=null,uu=0,kl=0,vp=null,du=-1,fu=0;function Ir(){return(Jt&6)!==0?on():du!==-1?du:du=on()}function As(s){return(s.mode&1)===0?1:(Jt&2)!==0&&yr!==0?yr&-yr:pN.transition!==null?(fu===0&&(fu=vo()),fu):(s=Pt,s!==0||(s=window.event,s=s===void 0?16:ei(s.type)),s)}function jo(s,i,d,g){if(50<kl)throw kl=0,vp=null,Error(n(185));Pr(s,d,g),((Jt&2)===0||s!==pr)&&(s===pr&&((Jt&2)===0&&(au|=d),cr===4&&Is(s,yr)),Ur(s,g),d===1&&Jt===0&&(i.mode&1)===0&&(ca=on()+500,Fc&&Es()))}function Ur(s,i){var d=s.callbackNode;Lr(s,i);var g=kn(s,s===pr?yr:0);if(g===0)d!==null&&sr(d),s.callbackNode=null,s.callbackPriority=0;else if(i=g&-g,s.callbackPriority!==i){if(d!=null&&sr(d),i===1)s.tag===0?fN(Fy.bind(null,s)):Sk(Fy.bind(null,s)),lN(function(){(Jt&6)===0&&Es()}),d=null;else{switch(tt(g)){case 1:d=so;break;case 4:d=Zn;break;case 16:d=Vn;break;case 536870912:d=Be;break;default:d=Vn}d=Gy(d,zy.bind(null,s))}s.callbackPriority=i,s.callbackNode=d}}function zy(s,i){if(du=-1,fu=0,(Jt&6)!==0)throw Error(n(327));var d=s.callbackNode;if(ua()&&s.callbackNode!==d)return null;var g=kn(s,s===pr?yr:0);if(g===0)return null;if((g&30)!==0||(g&s.expiredLanes)!==0||i)i=pu(s,g);else{i=g;var w=Jt;Jt|=2;var b=Uy();(pr!==s||yr!==i)&&(cs=null,ca=on()+500,hi(s,i));do try{ON();break}catch(F){By(s,F)}while(!0);Df(),iu.current=b,Jt=w,Xn!==null?i=0:(pr=null,yr=0,i=cr)}if(i!==0){if(i===2&&(w=Vr(s),w!==0&&(g=w,i=bp(s,w))),i===1)throw d=ml,hi(s,0),Is(s,g),Ur(s,on()),d;if(i===6)Is(s,g);else{if(w=s.current.alternate,(g&30)===0&&!IN(w)&&(i=pu(s,g),i===2&&(b=Vr(s),b!==0&&(g=b,i=bp(s,b))),i===1))throw d=ml,hi(s,0),Is(s,g),Ur(s,on()),d;switch(s.finishedWork=w,s.finishedLanes=g,i){case 0:case 1:throw Error(n(345));case 2:mi(s,Br,cs);break;case 3:if(Is(s,g),(g&130023424)===g&&(i=yp+500-on(),10<i)){if(kn(s,0)!==0)break;if(w=s.suspendedLanes,(w&g)!==g){Ir(),s.pingedLanes|=s.suspendedLanes&w;break}s.timeoutHandle=Tf(mi.bind(null,s,Br,cs),i);break}mi(s,Br,cs);break;case 4:if(Is(s,g),(g&4194240)===g)break;for(i=s.eventTimes,w=-1;0<g;){var T=31-ot(g);b=1<<T,T=i[T],T>w&&(w=T),g&=~b}if(g=w,g=on()-g,g=(120>g?120:480>g?480:1080>g?1080:1920>g?1920:3e3>g?3e3:4320>g?4320:1960*AN(g/1960))-g,10<g){s.timeoutHandle=Tf(mi.bind(null,s,Br,cs),g);break}mi(s,Br,cs);break;case 5:mi(s,Br,cs);break;default:throw Error(n(329))}}}return Ur(s,on()),s.callbackNode===d?zy.bind(null,s):null}function bp(s,i){var d=gl;return s.current.memoizedState.isDehydrated&&(hi(s,i).flags|=256),s=pu(s,i),s!==2&&(i=Br,Br=d,i!==null&&xp(i)),s}function xp(s){Br===null?Br=s:Br.push.apply(Br,s)}function IN(s){for(var i=s;;){if(i.flags&16384){var d=i.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var g=0;g<d.length;g++){var w=d[g],b=w.getSnapshot;w=w.value;try{if(!_o(b(),w))return!1}catch{return!1}}}if(d=i.child,i.subtreeFlags&16384&&d!==null)d.return=i,i=d;else{if(i===s)break;for(;i.sibling===null;){if(i.return===null||i.return===s)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function Is(s,i){for(i&=~kp,i&=~au,s.suspendedLanes|=i,s.pingedLanes&=~i,s=s.expirationTimes;0<i;){var d=31-ot(i),g=1<<d;s[d]=-1,i&=~g}}function Fy(s){if((Jt&6)!==0)throw Error(n(327));ua();var i=kn(s,0);if((i&1)===0)return Ur(s,on()),null;var d=pu(s,i);if(s.tag!==0&&d===2){var g=Vr(s);g!==0&&(i=g,d=bp(s,g))}if(d===1)throw d=ml,hi(s,0),Is(s,i),Ur(s,on()),d;if(d===6)throw Error(n(345));return s.finishedWork=s.current.alternate,s.finishedLanes=i,mi(s,Br,cs),Ur(s,on()),null}function _p(s,i){var d=Jt;Jt|=1;try{return s(i)}finally{Jt=d,Jt===0&&(ca=on()+500,Fc&&Es())}}function pi(s){Cs!==null&&Cs.tag===0&&(Jt&6)===0&&ua();var i=Jt;Jt|=1;var d=uo.transition,g=Pt;try{if(uo.transition=null,Pt=1,s)return s()}finally{Pt=g,uo.transition=d,Jt=i,(Jt&6)===0&&Es()}}function Ep(){Jr=la.current,En(la)}function hi(s,i){s.finishedWork=null,s.finishedLanes=0;var d=s.timeoutHandle;if(d!==-1&&(s.timeoutHandle=-1,aN(d)),Xn!==null)for(d=Xn.return;d!==null;){var g=d;switch(Of(g),g.tag){case 1:g=g.type.childContextTypes,g!=null&&Dc();break;case 3:sa(),En(Dr),En(br),Zf();break;case 5:Wf(g);break;case 4:sa();break;case 13:En(Ln);break;case 19:En(Ln);break;case 10:zf(g.type._context);break;case 22:case 23:Ep()}d=d.return}if(pr=s,Xn=s=Rs(s.current,null),yr=Jr=i,cr=0,ml=null,kp=au=fi=0,Br=gl=null,ci!==null){for(i=0;i<ci.length;i++)if(d=ci[i],g=d.interleaved,g!==null){d.interleaved=null;var w=g.next,b=d.pending;if(b!==null){var T=b.next;b.next=w,g.next=T}d.pending=g}ci=null}return s}function By(s,i){do{var d=Xn;try{if(Df(),Yc.current=eu,Qc){for(var g=Pn.memoizedState;g!==null;){var w=g.queue;w!==null&&(w.pending=null),g=g.next}Qc=!1}if(di=0,fr=lr=Pn=null,cl=!1,ul=0,gp.current=null,d===null||d.return===null){cr=1,ml=i,Xn=null;break}e:{var b=s,T=d.return,F=d,G=i;if(i=yr,F.flags|=32768,G!==null&&typeof G=="object"&&typeof G.then=="function"){var le=G,Te=F,Ae=Te.tag;if((Te.mode&1)===0&&(Ae===0||Ae===11||Ae===15)){var Se=Te.alternate;Se?(Te.updateQueue=Se.updateQueue,Te.memoizedState=Se.memoizedState,Te.lanes=Se.lanes):(Te.updateQueue=null,Te.memoizedState=null)}var Ze=fy(T);if(Ze!==null){Ze.flags&=-257,py(Ze,T,F,b,i),Ze.mode&1&&dy(b,le,i),i=Ze,G=le;var Qe=i.updateQueue;if(Qe===null){var Je=new Set;Je.add(G),i.updateQueue=Je}else Qe.add(G);break e}else{if((i&1)===0){dy(b,le,i),Sp();break e}G=Error(n(426))}}else if(jn&&F.mode&1){var qn=fy(T);if(qn!==null){(qn.flags&65536)===0&&(qn.flags|=256),py(qn,T,F,b,i),Lf(ia(G,F));break e}}b=G=ia(G,F),cr!==4&&(cr=2),gl===null?gl=[b]:gl.push(b),b=T;do{switch(b.tag){case 3:b.flags|=65536,i&=-i,b.lanes|=i;var re=cy(b,G,i);Lk(b,re);break e;case 1:F=G;var Q=b.type,ie=b.stateNode;if((b.flags&128)===0&&(typeof Q.getDerivedStateFromError=="function"||ie!==null&&typeof ie.componentDidCatch=="function"&&(js===null||!js.has(ie)))){b.flags|=65536,i&=-i,b.lanes|=i;var Le=uy(b,F,i);Lk(b,Le);break e}}b=b.return}while(b!==null)}Wy(d)}catch(nt){i=nt,Xn===d&&d!==null&&(Xn=d=d.return);continue}break}while(!0)}function Uy(){var s=iu.current;return iu.current=eu,s===null?eu:s}function Sp(){(cr===0||cr===3||cr===2)&&(cr=4),pr===null||(fi&268435455)===0&&(au&268435455)===0||Is(pr,yr)}function pu(s,i){var d=Jt;Jt|=2;var g=Uy();(pr!==s||yr!==i)&&(cs=null,hi(s,i));do try{RN();break}catch(w){By(s,w)}while(!0);if(Df(),Jt=d,iu.current=g,Xn!==null)throw Error(n(261));return pr=null,yr=0,cr}function RN(){for(;Xn!==null;)Hy(Xn)}function ON(){for(;Xn!==null&&!Mr();)Hy(Xn)}function Hy(s){var i=qy(s.alternate,s,Jr);s.memoizedProps=s.pendingProps,i===null?Wy(s):Xn=i,gp.current=null}function Wy(s){var i=s;do{var d=i.alternate;if(s=i.return,(i.flags&32768)===0){if(d=SN(d,i,Jr),d!==null){Xn=d;return}}else{if(d=NN(d,i),d!==null){d.flags&=32767,Xn=d;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{cr=6,Xn=null;return}}if(i=i.sibling,i!==null){Xn=i;return}Xn=i=s}while(i!==null);cr===0&&(cr=5)}function mi(s,i,d){var g=Pt,w=uo.transition;try{uo.transition=null,Pt=1,$N(s,i,d,g)}finally{uo.transition=w,Pt=g}return null}function $N(s,i,d,g){do ua();while(Cs!==null);if((Jt&6)!==0)throw Error(n(327));d=s.finishedWork;var w=s.finishedLanes;if(d===null)return null;if(s.finishedWork=null,s.finishedLanes=0,d===s.current)throw Error(n(177));s.callbackNode=null,s.callbackPriority=0;var b=d.lanes|d.childLanes;if(Yn(s,b),s===pr&&(Xn=pr=null,yr=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||cu||(cu=!0,Gy(Vn,function(){return ua(),null})),b=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||b){b=uo.transition,uo.transition=null;var T=Pt;Pt=1;var F=Jt;Jt|=4,gp.current=null,jN(s,d),$y(d,s),eN(Sf),Js=!!Ef,Sf=Ef=null,s.current=d,CN(d),wo(),Jt=F,Pt=T,uo.transition=b}else s.current=d;if(cu&&(cu=!1,Cs=s,uu=w),b=s.pendingLanes,b===0&&(js=null),ln(d.stateNode),Ur(s,on()),i!==null)for(g=s.onRecoverableError,d=0;d<i.length;d++)w=i[d],g(w.value,{componentStack:w.stack,digest:w.digest});if(lu)throw lu=!1,s=wp,wp=null,s;return(uu&1)!==0&&s.tag!==0&&ua(),b=s.pendingLanes,(b&1)!==0?s===vp?kl++:(kl=0,vp=s):kl=0,Es(),null}function ua(){if(Cs!==null){var s=tt(uu),i=uo.transition,d=Pt;try{if(uo.transition=null,Pt=16>s?16:s,Cs===null)var g=!1;else{if(s=Cs,Cs=null,uu=0,(Jt&6)!==0)throw Error(n(331));var w=Jt;for(Jt|=4,Ye=s.current;Ye!==null;){var b=Ye,T=b.child;if((Ye.flags&16)!==0){var F=b.deletions;if(F!==null){for(var G=0;G<F.length;G++){var le=F[G];for(Ye=le;Ye!==null;){var Te=Ye;switch(Te.tag){case 0:case 11:case 15:hl(8,Te,b)}var Ae=Te.child;if(Ae!==null)Ae.return=Te,Ye=Ae;else for(;Ye!==null;){Te=Ye;var Se=Te.sibling,Ze=Te.return;if(Cy(Te),Te===le){Ye=null;break}if(Se!==null){Se.return=Ze,Ye=Se;break}Ye=Ze}}}var Qe=b.alternate;if(Qe!==null){var Je=Qe.child;if(Je!==null){Qe.child=null;do{var qn=Je.sibling;Je.sibling=null,Je=qn}while(Je!==null)}}Ye=b}}if((b.subtreeFlags&2064)!==0&&T!==null)T.return=b,Ye=T;else e:for(;Ye!==null;){if(b=Ye,(b.flags&2048)!==0)switch(b.tag){case 0:case 11:case 15:hl(9,b,b.return)}var re=b.sibling;if(re!==null){re.return=b.return,Ye=re;break e}Ye=b.return}}var Q=s.current;for(Ye=Q;Ye!==null;){T=Ye;var ie=T.child;if((T.subtreeFlags&2064)!==0&&ie!==null)ie.return=T,Ye=ie;else e:for(T=Q;Ye!==null;){if(F=Ye,(F.flags&2048)!==0)try{switch(F.tag){case 0:case 11:case 15:su(9,F)}}catch(nt){Wn(F,F.return,nt)}if(F===T){Ye=null;break e}var Le=F.sibling;if(Le!==null){Le.return=F.return,Ye=Le;break e}Ye=F.return}}if(Jt=w,Es(),xt&&typeof xt.onPostCommitFiberRoot=="function")try{xt.onPostCommitFiberRoot(yt,s)}catch{}g=!0}return g}finally{Pt=d,uo.transition=i}}return!1}function Ky(s,i,d){i=ia(d,i),i=cy(s,i,1),s=Ns(s,i,1),i=Ir(),s!==null&&(Pr(s,1,i),Ur(s,i))}function Wn(s,i,d){if(s.tag===3)Ky(s,s,d);else for(;i!==null;){if(i.tag===3){Ky(i,s,d);break}else if(i.tag===1){var g=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(js===null||!js.has(g))){s=ia(d,s),s=uy(i,s,1),i=Ns(i,s,1),s=Ir(),i!==null&&(Pr(i,1,s),Ur(i,s));break}}i=i.return}}function MN(s,i,d){var g=s.pingCache;g!==null&&g.delete(i),i=Ir(),s.pingedLanes|=s.suspendedLanes&d,pr===s&&(yr&d)===d&&(cr===4||cr===3&&(yr&130023424)===yr&&500>on()-yp?hi(s,0):kp|=d),Ur(s,i)}function Zy(s,i){i===0&&((s.mode&1)===0?i=1:(i=ut,ut<<=1,(ut&130023424)===0&&(ut=4194304)));var d=Ir();s=is(s,i),s!==null&&(Pr(s,i,d),Ur(s,d))}function LN(s){var i=s.memoizedState,d=0;i!==null&&(d=i.retryLane),Zy(s,d)}function PN(s,i){var d=0;switch(s.tag){case 13:var g=s.stateNode,w=s.memoizedState;w!==null&&(d=w.retryLane);break;case 19:g=s.stateNode;break;default:throw Error(n(314))}g!==null&&g.delete(i),Zy(s,d)}var qy;qy=function(s,i,d){if(s!==null)if(s.memoizedProps!==i.pendingProps||Dr.current)Fr=!0;else{if((s.lanes&d)===0&&(i.flags&128)===0)return Fr=!1,EN(s,i,d);Fr=(s.flags&131072)!==0}else Fr=!1,jn&&(i.flags&1048576)!==0&&Nk(i,Uc,i.index);switch(i.lanes=0,i.tag){case 2:var g=i.type;ru(s,i),s=i.pendingProps;var w=Xi(i,br.current);oa(i,d),w=Vf(null,i,g,s,w,d);var b=Yf();return i.flags|=1,typeof w=="object"&&w!==null&&typeof w.render=="function"&&w.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,zr(g)?(b=!0,zc(i)):b=!1,i.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,Uf(i),w.updater=tu,i.stateNode=w,w._reactInternals=i,np(i,g,s,d),i=ip(null,i,g,!0,b,d)):(i.tag=0,jn&&b&&Rf(i),Ar(null,i,w,d),i=i.child),i;case 16:g=i.elementType;e:{switch(ru(s,i),s=i.pendingProps,w=g._init,g=w(g._payload),i.type=g,w=i.tag=zN(g),s=So(g,s),w){case 0:i=sp(null,i,g,s,d);break e;case 1:i=wy(null,i,g,s,d);break e;case 11:i=hy(null,i,g,s,d);break e;case 14:i=my(null,i,g,So(g.type,s),d);break e}throw Error(n(306,g,""))}return i;case 0:return g=i.type,w=i.pendingProps,w=i.elementType===g?w:So(g,w),sp(s,i,g,w,d);case 1:return g=i.type,w=i.pendingProps,w=i.elementType===g?w:So(g,w),wy(s,i,g,w,d);case 3:e:{if(vy(i),s===null)throw Error(n(387));g=i.pendingProps,b=i.memoizedState,w=b.element,Mk(s,i),Gc(i,g,null,d);var T=i.memoizedState;if(g=T.element,b.isDehydrated)if(b={element:g,isDehydrated:!1,cache:T.cache,pendingSuspenseBoundaries:T.pendingSuspenseBoundaries,transitions:T.transitions},i.updateQueue.baseState=b,i.memoizedState=b,i.flags&256){w=ia(Error(n(423)),i),i=by(s,i,g,d,w);break e}else if(g!==w){w=ia(Error(n(424)),i),i=by(s,i,g,d,w);break e}else for(Xr=bs(i.stateNode.containerInfo.firstChild),Qr=i,jn=!0,Eo=null,d=Ok(i,null,g,d),i.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(ta(),g===w){i=ls(s,i,d);break e}Ar(s,i,g,d)}i=i.child}return i;case 5:return Dk(i),s===null&&Mf(i),g=i.type,w=i.pendingProps,b=s!==null?s.memoizedProps:null,T=w.children,Nf(g,w)?T=null:b!==null&&Nf(g,b)&&(i.flags|=32),yy(s,i),Ar(s,i,T,d),i.child;case 6:return s===null&&Mf(i),null;case 13:return xy(s,i,d);case 4:return Hf(i,i.stateNode.containerInfo),g=i.pendingProps,s===null?i.child=na(i,null,g,d):Ar(s,i,g,d),i.child;case 11:return g=i.type,w=i.pendingProps,w=i.elementType===g?w:So(g,w),hy(s,i,g,w,d);case 7:return Ar(s,i,i.pendingProps,d),i.child;case 8:return Ar(s,i,i.pendingProps.children,d),i.child;case 12:return Ar(s,i,i.pendingProps.children,d),i.child;case 10:e:{if(g=i.type._context,w=i.pendingProps,b=i.memoizedProps,T=w.value,yn(Kc,g._currentValue),g._currentValue=T,b!==null)if(_o(b.value,T)){if(b.children===w.children&&!Dr.current){i=ls(s,i,d);break e}}else for(b=i.child,b!==null&&(b.return=i);b!==null;){var F=b.dependencies;if(F!==null){T=b.child;for(var G=F.firstContext;G!==null;){if(G.context===g){if(b.tag===1){G=as(-1,d&-d),G.tag=2;var le=b.updateQueue;if(le!==null){le=le.shared;var Te=le.pending;Te===null?G.next=G:(G.next=Te.next,Te.next=G),le.pending=G}}b.lanes|=d,G=b.alternate,G!==null&&(G.lanes|=d),Ff(b.return,d,i),F.lanes|=d;break}G=G.next}}else if(b.tag===10)T=b.type===i.type?null:b.child;else if(b.tag===18){if(T=b.return,T===null)throw Error(n(341));T.lanes|=d,F=T.alternate,F!==null&&(F.lanes|=d),Ff(T,d,i),T=b.sibling}else T=b.child;if(T!==null)T.return=b;else for(T=b;T!==null;){if(T===i){T=null;break}if(b=T.sibling,b!==null){b.return=T.return,T=b;break}T=T.return}b=T}Ar(s,i,w.children,d),i=i.child}return i;case 9:return w=i.type,g=i.pendingProps.children,oa(i,d),w=lo(w),g=g(w),i.flags|=1,Ar(s,i,g,d),i.child;case 14:return g=i.type,w=So(g,i.pendingProps),w=So(g.type,w),my(s,i,g,w,d);case 15:return gy(s,i,i.type,i.pendingProps,d);case 17:return g=i.type,w=i.pendingProps,w=i.elementType===g?w:So(g,w),ru(s,i),i.tag=1,zr(g)?(s=!0,zc(i)):s=!1,oa(i,d),ay(i,g,w),np(i,g,w,d),ip(null,i,g,!0,s,d);case 19:return Ey(s,i,d);case 22:return ky(s,i,d)}throw Error(n(156,i.tag))};function Gy(s,i){return On(s,i)}function DN(s,i,d,g){this.tag=s,this.key=d,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=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fo(s,i,d,g){return new DN(s,i,d,g)}function Np(s){return s=s.prototype,!(!s||!s.isReactComponent)}function zN(s){if(typeof s=="function")return Np(s)?1:0;if(s!=null){if(s=s.$$typeof,s===q)return 11;if(s===ue)return 14}return 2}function Rs(s,i){var d=s.alternate;return d===null?(d=fo(s.tag,i,s.key,s.mode),d.elementType=s.elementType,d.type=s.type,d.stateNode=s.stateNode,d.alternate=s,s.alternate=d):(d.pendingProps=i,d.type=s.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=s.flags&14680064,d.childLanes=s.childLanes,d.lanes=s.lanes,d.child=s.child,d.memoizedProps=s.memoizedProps,d.memoizedState=s.memoizedState,d.updateQueue=s.updateQueue,i=s.dependencies,d.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},d.sibling=s.sibling,d.index=s.index,d.ref=s.ref,d}function hu(s,i,d,g,w,b){var T=2;if(g=s,typeof s=="function")Np(s)&&(T=1);else if(typeof s=="string")T=5;else e:switch(s){case R:return gi(d.children,w,b,i);case I:T=8,w|=8;break;case C:return s=fo(12,d,i,w|2),s.elementType=C,s.lanes=b,s;case se:return s=fo(13,d,i,w),s.elementType=se,s.lanes=b,s;case pe:return s=fo(19,d,i,w),s.elementType=pe,s.lanes=b,s;case oe:return mu(d,w,b,i);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case P:T=10;break e;case z:T=9;break e;case q:T=11;break e;case ue:T=14;break e;case xe:T=16,g=null;break e}throw Error(n(130,s==null?s:typeof s,""))}return i=fo(T,d,i,w),i.elementType=s,i.type=g,i.lanes=b,i}function gi(s,i,d,g){return s=fo(7,s,g,i),s.lanes=d,s}function mu(s,i,d,g){return s=fo(22,s,g,i),s.elementType=oe,s.lanes=d,s.stateNode={isHidden:!1},s}function Tp(s,i,d){return s=fo(6,s,null,i),s.lanes=d,s}function jp(s,i,d){return i=fo(4,s.children!==null?s.children:[],s.key,i),i.lanes=d,i.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},i}function FN(s,i,d,g,w){this.tag=i,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=wr(0),this.expirationTimes=wr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=wr(0),this.identifierPrefix=g,this.onRecoverableError=w,this.mutableSourceEagerHydrationData=null}function Cp(s,i,d,g,w,b,T,F,G){return s=new FN(s,i,d,F,G),i===1?(i=1,b===!0&&(i|=8)):i=0,b=fo(3,null,null,i),s.current=b,b.stateNode=s,b.memoizedState={element:g,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},Uf(b),s}function BN(s,i,d){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:U,key:g==null?null:""+g,children:s,containerInfo:i,implementation:d}}function Vy(s){if(!s)return _s;s=s._reactInternals;e:{if(Nn(s)!==s||s.tag!==1)throw Error(n(170));var i=s;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(zr(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(n(171))}if(s.tag===1){var d=s.type;if(zr(d))return _k(s,d,i)}return i}function Yy(s,i,d,g,w,b,T,F,G){return s=Cp(d,g,!0,s,w,b,T,F,G),s.context=Vy(null),d=s.current,g=Ir(),w=As(d),b=as(g,w),b.callback=i??null,Ns(d,b,w),s.current.lanes=w,Pr(s,w,g),Ur(s,g),s}function gu(s,i,d,g){var w=i.current,b=Ir(),T=As(w);return d=Vy(d),i.context===null?i.context=d:i.pendingContext=d,i=as(b,T),i.payload={element:s},g=g===void 0?null:g,g!==null&&(i.callback=g),s=Ns(w,i,T),s!==null&&(jo(s,w,T,b),qc(s,w,T)),T}function ku(s){if(s=s.current,!s.child)return null;switch(s.child.tag){case 5:return s.child.stateNode;default:return s.child.stateNode}}function Qy(s,i){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var d=s.retryLane;s.retryLane=d!==0&&d<i?d:i}}function Ap(s,i){Qy(s,i),(s=s.alternate)&&Qy(s,i)}function UN(){return null}var Xy=typeof reportError=="function"?reportError:function(s){console.error(s)};function Ip(s){this._internalRoot=s}yu.prototype.render=Ip.prototype.render=function(s){var i=this._internalRoot;if(i===null)throw Error(n(409));gu(s,i,null,null)},yu.prototype.unmount=Ip.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var i=s.containerInfo;pi(function(){gu(null,s,null,null)}),i[ns]=null}};function yu(s){this._internalRoot=s}yu.prototype.unstable_scheduleHydration=function(s){if(s){var i=vr();s={blockedOn:null,target:s,priority:i};for(var d=0;d<wt.length&&i!==0&&i<wt[d].priority;d++);wt.splice(d,0,s),d===0&&$n(s)}};function Rp(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function wu(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function Jy(){}function HN(s,i,d,g,w){if(w){if(typeof g=="function"){var b=g;g=function(){var le=ku(T);b.call(le)}}var T=Yy(i,g,s,0,null,!1,!1,"",Jy);return s._reactRootContainer=T,s[ns]=T.current,tl(s.nodeType===8?s.parentNode:s),pi(),T}for(;w=s.lastChild;)s.removeChild(w);if(typeof g=="function"){var F=g;g=function(){var le=ku(G);F.call(le)}}var G=Cp(s,0,!1,null,null,!1,!1,"",Jy);return s._reactRootContainer=G,s[ns]=G.current,tl(s.nodeType===8?s.parentNode:s),pi(function(){gu(i,G,d,g)}),G}function vu(s,i,d,g,w){var b=d._reactRootContainer;if(b){var T=b;if(typeof w=="function"){var F=w;w=function(){var G=ku(T);F.call(G)}}gu(i,T,s,w)}else T=HN(d,i,s,w,g);return ku(T)}es=function(s){switch(s.tag){case 3:var i=s.stateNode;if(i.current.memoizedState.isDehydrated){var d=Bt(i.pendingLanes);d!==0&&(bo(i,d|1),Ur(i,on()),(Jt&6)===0&&(ca=on()+500,Es()))}break;case 13:pi(function(){var g=is(s,1);if(g!==null){var w=Ir();jo(g,s,1,w)}}),Ap(s,1)}},bn=function(s){if(s.tag===13){var i=is(s,134217728);if(i!==null){var d=Ir();jo(i,s,134217728,d)}Ap(s,134217728)}},Ut=function(s){if(s.tag===13){var i=As(s),d=is(s,i);if(d!==null){var g=Ir();jo(d,s,i,g)}Ap(s,i)}},vr=function(){return Pt},Qn=function(s,i){var d=Pt;try{return Pt=s,i()}finally{Pt=d}},Un=function(s,i,d){switch(i){case"input":if(vt(s,d),i=d.name,d.type==="radio"&&i!=null){for(d=s;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<d.length;i++){var g=d[i];if(g!==s&&g.form===s.form){var w=Pc(g);if(!w)throw Error(n(90));Pe(g),vt(g,w)}}}break;case"textarea":Xe(s,d);break;case"select":i=d.value,i!=null&&qe(s,!!d.multiple,i,!1)}},Ie=_p,rt=pi;var WN={usingClientEntryPoint:!1,Events:[ol,Yi,Pc,H,fe,_p]},yl={findFiberByHostInstance:si,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},KN={bundleType:yl.bundleType,version:yl.version,rendererPackageName:yl.rendererPackageName,rendererConfig:yl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=mn(s),s===null?null:s.stateNode},findFiberByHostInstance:yl.findFiberByHostInstance||UN,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 bu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!bu.isDisabled&&bu.supportsFiber)try{yt=bu.inject(KN),xt=bu}catch{}}return Hr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=WN,Hr.createPortal=function(s,i){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Rp(i))throw Error(n(200));return BN(s,i,null,d)},Hr.createRoot=function(s,i){if(!Rp(s))throw Error(n(299));var d=!1,g="",w=Xy;return i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(g=i.identifierPrefix),i.onRecoverableError!==void 0&&(w=i.onRecoverableError)),i=Cp(s,1,!1,null,null,d,!1,g,w),s[ns]=i.current,tl(s.nodeType===8?s.parentNode:s),new Ip(i)},Hr.findDOMNode=function(s){if(s==null)return null;if(s.nodeType===1)return s;var i=s._reactInternals;if(i===void 0)throw typeof s.render=="function"?Error(n(188)):(s=Object.keys(s).join(","),Error(n(268,s)));return s=mn(i),s=s===null?null:s.stateNode,s},Hr.flushSync=function(s){return pi(s)},Hr.hydrate=function(s,i,d){if(!wu(i))throw Error(n(200));return vu(null,s,i,!0,d)},Hr.hydrateRoot=function(s,i,d){if(!Rp(s))throw Error(n(405));var g=d!=null&&d.hydratedSources||null,w=!1,b="",T=Xy;if(d!=null&&(d.unstable_strictMode===!0&&(w=!0),d.identifierPrefix!==void 0&&(b=d.identifierPrefix),d.onRecoverableError!==void 0&&(T=d.onRecoverableError)),i=Yy(i,null,s,1,d??null,w,!1,b,T),s[ns]=i.current,tl(s),g)for(s=0;s<g.length;s++)d=g[s],w=d._getVersion,w=w(d._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[d,w]:i.mutableSourceEagerHydrationData.push(d,w);return new yu(i)},Hr.render=function(s,i,d){if(!wu(i))throw Error(n(200));return vu(null,s,i,!1,d)},Hr.unmountComponentAtNode=function(s){if(!wu(s))throw Error(n(40));return s._reactRootContainer?(pi(function(){vu(null,null,s,!1,function(){s._reactRootContainer=null,s[ns]=null})}),!0):!1},Hr.unstable_batchedUpdates=_p,Hr.unstable_renderSubtreeIntoContainer=function(s,i,d,g){if(!wu(d))throw Error(n(200));if(s==null||s._reactInternals===void 0)throw Error(n(38));return vu(s,i,d,!1,g)},Hr.version="18.3.1-next-f1338f8080-20240426",Hr}var nv;function O$(){if(nv)return Wp.exports;nv=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wp.exports=R$(),Wp.exports}var rv;function $$(){if(rv)return Tu;rv=1;var e=O$();return Tu.createRoot=e.createRoot,Tu.hydrateRoot=e.hydrateRoot,Tu}var M$=$$();function L$(e,t){const n=e.filter(o=>o.id!==t),r=n.filter(o=>o.agent==="waiting"||o.unseen).length;return r===0?null:{n:r,tier:n.some(o=>o.agent==="waiting")?"waiting":"unseen"}}function jx(e,t,n){const r=p=>e.map((m,h)=>p(m)&&m.id!==t?h:-1).filter(m=>m>=0),a=[()=>r(p=>p.agent==="waiting"),()=>r(p=>!!p.unseen),()=>r(p=>p.agent==="working")].reduce((p,m)=>p.length>0?p:m(),[]),l=e.findIndex(p=>p.id===t),u=n>0?a.find(p=>p>l)??a[0]:a.findLast(p=>p<l)??a[a.length-1],c=u===void 0?void 0:e[u];return c?{activate:c.id}:null}function Dm(e,t,n){const r=jx(e,t,n);if(r)return r;const o=e[0];return o&&o.id!==t?{activate:o.id}:null}function Cx(e){return(e.key==="Enter"||e.key==="NumpadEnter")&&(e.metaKey||e.ctrlKey)&&!e.altKey?!1:e.metaKey||e.ctrlKey||e.altKey}function Ax(e){const t=e.findLast(n=>n.kind==="ask"&&!n.outcome);return(t==null?void 0:t.kind)==="ask"?t:null}function Ix(e){return e==="cancelled"||e==="expired"}function P$(e){const t=e.findLast(n=>n.kind==="ask"||n.kind==="user");return(t==null?void 0:t.kind)!=="ask"||t.ask.kind!=="question"?null:Ix(t.outcome)?t:null}function D$(e){if(e.ask.kind==="permission")return e.ask.title;const t=e.ask.questions.map(n=>n.header).filter(n=>!!n);return t.length>0?t.join(", "):e.ask.message}function z$(e){return e.map(()=>({selected:[]}))}function ov(e,t,n,r){return e.map((o,a)=>{if(a!==t)return o;const l=o.selected.includes(n);return r?{...o,selected:l?o.selected.filter(u=>u!==n):[...o.selected,n]}:{...o,selected:[n]}})}function Rx(e,t,n){return e.map((r,o)=>{if(o!==t)return r;const{note:a,...l}=r;return n===void 0?l:{...l,note:n}})}function sv(e,t,n,r){return e.map((o,a)=>a!==t?o:{selected:n&&!r?[]:o.selected,note:o.note??""})}function iv(e,t){const n=e[t];return n&&n.note!==void 0&&!n.note.trim()?Rx(e,t,void 0):e}function Ox(e){return e?e.options.length+(e.note?1:0):0}function F$(e,t){return!!(e!=null&&e.note)&&t===e.options.length}function $x(e,t){return!!e&&e.note!==void 0&&(t||e.selected.length===0)}function va(e){var t;return!!e&&(e.selected.length>0||!!((t=e.note)!=null&&t.trim()))}function ju(e,t){return e.every((n,r)=>!n.required||va(t[r]))}function Mx(e,t){var o;const n=((t==null?void 0:t.selected)??[]).map(a=>{var l;return Dx(((l=e.options.find(u=>u.value===a))==null?void 0:l.label)??a)}),r=(o=t==null?void 0:t.note)==null?void 0:o.trim();return n.length===0?r||"skipped":r?`${n.join(", ")}: ${r}`:n.join(", ")}function Lx(e,t){return e.map((n,r)=>{const o=Mx(n,t==null?void 0:t[r]);return e.length>1&&n.header?`${n.header} · ${o}`:o})}function B$(e){return e.outcome!=="answered"||e.ask.kind!=="question"?null:{message:e.ask.message,questions:e.ask.questions,answers:e.answers}}function U$(e,t){return t>=1&&t<=Ox(e)?t-1:-1}function ga(e,t){if(!e)return 0;if($x(t,!!e.multi)&&e.note)return e.options.length;const n=t!=null&&t.selected[0]?e.options.findIndex(r=>r.value===t.selected[0]):-1;return n===-1?0:n}function H$(e,t,n){return Math.max(0,Math.min(n-1,e+t))}function W$(e,t,n){const r=e.length;for(let o=1;o<=r;o++){const a=(n+o)%r;if(!va(t[a]))return a}return-1}function zl(e){return e.length>1?e.length:-1}function K$(e){return e.length+(zl(e)===-1?0:1)}function av(e,t,n){const r=W$(e,t,n);if(r!==-1)return{current:r,cursor:ga(e[r],t[r]),send:!1};const o=zl(e);return o!==-1?{current:o,cursor:0,send:!1}:{current:n,cursor:ga(e[n],t[n]),send:!0}}const Px=/\s*\(recommended\)\s*$/i;function Z$(e){return Px.test(e)}function Dx(e){return e.replace(Px,"")}function Ih(e,t,n){const r=location.hostname;return n!==null&&r===n.host?`${RT(n.previews,e,t)}/`:r.endsWith(".localhost")?`http://w${e}.${r}:${t}/`:r==="127.0.0.1"||r==="localhost"?`http://127.0.0.1:${t}/`:`${location.protocol}//${r}:${t}/`}function lv(e){return e.ranges.map(([t,n])=>[t+e.offset,n+e.offset])}function cv(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 Cu(e,t){return!Number.isFinite(e)||e<=0?t:Math.min(Math.max(e,170),Math.floor(window.innerWidth*.5))}function fc(e){return e.agent==="working"||e.agent==="waiting"}function Ks(e){var t,n,r;return e.agent==="waiting"?"waiting":e.agent==="working"?"working":e.agent==="error"||((n=(t=e.worktree)==null?void 0:t.lastTurn)==null?void 0:n.end)==="failed"?"failed":(r=e.worktree)!=null&&r.landed?"landed":e.procs.some(o=>o.status==="crashed"||o.status==="unreachable")?"crashed":e.procs.some(o=>o.status==="running")?"running":e.procs.some(o=>o.status==="starting")?"starting":e.procs.some(o=>o.status==="asleep")?"asleep":"idle"}const q$={waiting:"Waiting for you",working:"Agent working",failed:"Agent failed",landed:"Landed",crashed:"Crashed",running:"Running",starting:"Starting",asleep:"Asleep",idle:"Idle"};function zm(e,t=!1){const n=Ks(e);return n==="idle"&&t?"Not set up":q$[n]}const G$={starting:"Starting",running:"Running",unreachable:"Not answering",crashed:"Crashed",stopped:"Stopped",asleep:"Asleep"};function V$(e){return G$[e]}function zx(e,t){return t&&Ks(e)!=="waiting"?t:null}const Y$={land:"Landing",commit:"Committing","sync-main":"Syncing with main","pull-main":"Pulling"};function Fm(e){return Y$[e]}function Fx(e){const t=e.filter(o=>o.status==="crashed"||o.status==="unreachable"),n=t[0];if(!n)return null;const r=t.map(o=>o.status==="unreachable"?`${o.name} never answered on :${o.port}`:`${o.name} crashed on :${o.port}`).join(", ");return{dead:t,tip:`${r} · click to open its tab`,stream:n.name}}function Q$(e){const t=e.lastIndexOf("/");return t<0?{name:e,dir:""}:{name:e.slice(t+1),dir:e.slice(0,t)}}const Bx=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}).compare;function ld(e){const t=[];for(let n=e.indexOf("/");n!==-1;n=e.indexOf("/",n+1))t.push(e.slice(0,n));return t}function Ux(e){const t=new Set;for(const n of e)for(const r of ld(n))t.add(r);return[...t].sort(Bx)}function Bm(e){return e.includes("A")||e==="??"?"added":e.includes("D")?"deleted":""}function Um(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 X$=/Firefox\//.test(navigator.userAgent);function Bd(){const e=t=>{var n;return((n=globalThis.matchMedia)==null?void 0:n.call(globalThis,`(display-mode: ${t})`).matches)??!1};return e("standalone")||e("window-controls-overlay")}const J$=/Chrome\//.test(navigator.userAgent)&&Bd(),Et=e=>_T(e,{firefox:X$,pwa:J$});function Hm(e){return e.component?`<${e.component} />`:`<${e.tag}>`}function Rh(e,t){return e.worktree&&Cr(e.worktree)&&t?t.defaultBranch:e.name}function Hx(e){const t=Math.max(0,e/1e3),n=(l,u)=>`${l} ${u}${l===1?"":"s"}`;if(t<60)return"a moment";const r=t/60;if(r<60)return n(Math.floor(r),"minute");const o=r/60;if(o<24)return n(Math.floor(o),"hour");const a=o/24;return a<7?n(Math.floor(a),"day"):a<365?n(Math.floor(a/7),"week"):n(Math.floor(a/365),"year")}function ro(e){const t=Math.max(0,(Date.now()-e)/1e3);if(t<60)return"now";const n=t/60;if(n<60)return`${Math.floor(n)}m`;const r=n/60;if(r<24)return`${Math.floor(r)}h`;const o=r/24;return o<7?`${Math.floor(o)}d`:o<365?`${Math.floor(o/7)}w`:`${Math.floor(o/365)}y`}function ba(e){const t=Math.max(0,Math.floor(e));return t<100?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function e2(e,t,n,r){var l;if(!t)return null;const o=e.filter(tr).filter(u=>u.repoId===t&&(u.worktree.agent??r)===n);return((l=o.find(u=>Cr(u.worktree))??o[0])==null?void 0:l.id)??null}const t2=200;function n2(e,t){const n=new Map(e.map(r=>[r.path,r]));for(const r of t){if(n.size>=t2)break;const o=Pd(r.path);o&&!n.has(o)&&n.set(o,{path:o,text:r.text})}return n.size===e.length?e:[...n.values()]}function Wx(e){return e!==void 0&&!e.routes.some(t=>!t.endpoint)}const cd=e=>"uploading"in e&&e.uploading===!0;function Fl(e){switch(e.kind){case"image":case"file":{const{key:t,local:n,uploading:r,...o}=e;return o}case"paste":{const{key:t,chars:n,lines:r,preview:o,...a}=e;return a}case"pick":{const{key:t,...n}=e;return n}}}const r2=e=>e.filter(t=>!cd(t)).map(Fl);let o2=0;function Oh(e,t){const n=new Map(t.filter(o=>!cd(o)).map(o=>[JSON.stringify(Fl(o)),o]));return[...e.map(o=>{const a=JSON.stringify(o),l=n.get(a);if(l)return n.delete(a),l;const u=`d${++o2}`;return o.kind==="paste"?{...o,key:u,...$m(o.text)}:{...o,key:u}}),...t.filter(cd)]}const qu=["files","changes","history"],s2=e=>qu.includes(e),Kx=e=>!!(e!=null&&e.carry)&&!e.batch&&e.variants===1,pc=e=>(e==null?void 0:e.worktree.id)??null,La=Object.freeze({chat:[],log:[],queue:[],page:{errors:[]},turn:{edits:!1,hmr:!1},changedRanges:{},commitFiles:{},search:null,design:null,draft:"",attachments:[],commands:[],termStream:po}),Wm=e=>({...e,phase:"editing",repoId:null,prompt:""}),uv=()=>Wm({mode:"create",name:"",parent:`~/${wx}`}),i2=Object.freeze({changes:!1,changesTab:"files",chat:!0,term:!1,design:!1});function a2(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.changes=="boolean"&&s2(t.changesTab)&&typeof t.chat=="boolean"&&typeof t.term=="boolean"&&typeof t.design=="boolean"}function Wr(e,t){const n=e.layout;let r=!1;for(const o of Object.keys(t))t[o]!==n[o]&&(r=!0);return r?{...e,layout:{...n,...t}}:e}function Km(e,t){return{...e,layout:t,changesAuto:!1}}const Ai=e=>Fd(e)?"preview":"file",l2=(e,t)=>e===t||!!e&&!!t&&e.at===t.at&&(e.at!=="tree"||t.at!=="tree"||e.worktreeId===t.worktreeId&&e.dir===t.dir),bl=(e,t)=>e.worktreeId===t.worktreeId&&e.path===t.path&&e.ref===t.ref&&e.since===t.since;function Zx(e,t,n,r){var a;if(!r.fiber)return r;const o=(a=go(e,t).changedRanges[n])==null?void 0:a.offset;return o===void 0?r:{n:r.n-o}}function c2(e){const t=e.cached??dc,n={connected:!1,connectFailure:null,repos:[],rows:[],activeRepoId:null,visible:[],archiving:[],shipping:{},visibleDiscovered:[],discoveredOpen:e.storedDiscoveredOpen??{},archivedOpen:e.storedArchivedOpen??{},committedShut:e.storedCommittedShut??{},turnOpen:e.storedTurnOpen??{},treeOpen:e.storedTreeOpen??{},treeReveal:null,refs:{},chats:{},archived:{},archivedPage:null,lastActive:e.storedLastActive??{},pendingOpen:!1,activeId:null,clientId:e.clientId,storedActive:e.storedActive??null,storedRepo:e.storedRepo??null,heard:!1,local:{},editor:null,openUrl:null,reloadReq:null,dragFiles:null,picking:!1,overlay:null,paletteReturn:null,incompatible:!1,layout:i2,focusChanges:0,editCommit:0,focusChat:0,walked:0,railOpen:e.storedRailOpen??!1,chatSide:e.storedChatSide??"left",focusRail:0,railPeek:!1,unreadHold:null,layouts:e.storedLayouts??{},screen:e.storedActive&&e.storedPhoneRow?"chat":"home",frame:e.frame??"desk",touch:e.touch??!1,reading:!1,changesAuto:!0,zen:!1,focusTerm:0,termRun:null,termTall:0,themes:Zu.some(o=>o.id===t.id)?Zu:[...Zu,t],themePrefs:{...u$,mode:t.kind,[t.kind]:t.id},previewTheme:null,systemDark:e.systemDark??!0,daylight:e.daylight??null,paths:{query:"",entries:[],target:null},home:"",folderDialog:!1,keepAwake:null,remote:null,managed:dO,paired:!1,pairings:0,gitIdentity:!0,self:null,rebuilt:!1,update:null,updateCheck:null,version:"",install:"none",registry:null,choosingFolder:!1,newProject:null,autoSend:null,chosenFolder:null,pending:[],activeImportId:null,agents:[],defaultAgent:"claude",agentChosen:!1,agentConfigs:{},draft:null,trunks:{},visits:{}},r=e.storedRepo?n.layouts[e.storedRepo]:void 0;return r?Km(n,r):n}function qx(e){var t;return{system:e.systemDark,daylight:((t=e.daylight)==null?void 0:t.dark)??e.systemDark}}function u2(e){return e.previewTheme??zd(e.themePrefs,e.themes,qx(e))}function go(e,t){return t&&e.local[t]||La}function ms(e,t){return t&&e.rows.find(n=>n.id===t)||null}function fn(e,t){const n=ms(e,t);return n&&tr(n)?n:null}function Gx(e){var o;const t=fn(e,e.activeId);if(!t||!ji(t.worktree)||t.agent!=="idle"||!((o=ja(e,t.repoId))!=null&&o.empty))return!1;const n=Pa(e,t.repoId),r=e.rows.some(a=>{var l;return a.repoId===t.repoId&&((l=a.worktree)==null?void 0:l.kind)==="worktree"});return!!(n!=null&&n.needsSetup)&&!r&&go(e,t.id).chat.length===0}function Ud(e){return e.newProject!==null||Gx(e)}function d2(e){return e.incompatible||Ud(e)}function f2(e){return(!e.needsSetup||!!e.assumed)&&Object.keys(e.config.run).length===0}function ud(e){return!!(e!=null&&e.needsSetup)&&!e.assumed}function mo(e){const t=e.activeRepoId?e.repos.find(n=>n.id===e.activeRepoId):void 0;return!!t&&f2(t)}function Vx(e){return e.layout.chat&&!mo(e)&&!e.archivedPage&&!Qx(e)?{a:"toggle-chat"}:{a:"focus-chat"}}function Go(e){return mo(e)?e:Wr(e,{chat:!0})}function Pa(e,t){return t&&e.repos.find(n=>n.id===t)||null}function Yx(e,t){if(!t)return null;const n=e.rows.filter(tr).filter(r=>r.repoId===t);return n.find(r=>uc(r.worktree))??n.find(r=>ji(r.worktree))??null}function ja(e,t){return t&&e.trunks[t]||null}function Cl(e){return mo(e)||e.archivedPage?null:e.activeId}function Zm(e){return e.procs.some(t=>t.status==="running"||t.status==="starting")}function dd(e){if(e.archivedPage)return null;const t=fn(e,e.activeId);return t&&Zm(t)?{worktreeId:t.worktree.id,repoId:t.repoId}:null}function p2(e,t,n){const r=e.filter(tr),o=n.length?r.filter(a=>!n.includes(a.id)):r;return lT(t?o.filter(a=>a.repoId===t):o)}function h2(e,t){const n=e.filter(r=>!tr(r));return t?n.filter(r=>r.repoId===t):n}function Bl(e,t,n=e.rows){var u;const r=n.filter(tr),o=e.archiving.length?r.filter(c=>!e.archiving.includes(c.id)):r,a=t?e.lastActive[t]:void 0;if(a&&o.some(c=>c.id===a))return a;const l=t?o.filter(c=>c.repoId===t):o;return((u=l.find(c=>uc(c.worktree))??l.find(c=>ji(c.worktree))??l[0])==null?void 0:u.id)??null}function dv(e,t){const n=Object.entries(e),r=n.filter(([o])=>!t(o));return r.length===n.length?e:Object.fromEntries(r)}function fv(e,t,n){const r={};for(const l of t)l.shipping&&(r[l.id]=l.shipping);for(const l of Object.values(n))l.shipping&&(r[l.id]=l.shipping);for(const[l,u]of Object.entries(e))!u.sent||r[l]||(t.some(c=>c.id===l)||t1({trunks:n},l))&&(r[l]=u);const o=Object.keys(r);return o.length===Object.keys(e).length&&o.every(l=>m2(e[l],r[l]))?e:r}const m2=(e,t)=>!!e&&!!t&&e.op===t.op&&e.step===t.step&&e.sent===t.sent;function Al(e,t){var p;const n=ms(e,t),r=(n==null?void 0:n.repoId)??e.activeRepoId,o=n&&tr(n)?{...e.lastActive,[n.repoId]:n.id}:e.lastActive,a=e.activeId!==t?e.activeId:null,l=a?e.local[a]:void 0,u=l&&((p=l.mark)==null?void 0:p.by)==="reveal"?Ul(l,"reveal"):null,c=a&&u?{...e.local,[a]:u}:e.local;return{...e,activeId:t,activeRepoId:r,lastActive:o,editor:null,archivedPage:null,local:c}}function Ca(e){return ko(e)?"history":e.layout.changesTab}function g2(e,t){const n=Ca(e);if(ko(e))return n;const r=qu.length;return qu[(qu.indexOf(n)+t+r)%r]??"changes"}function Qx(e){if(e.archivedPage)return null;const t=ms(e,e.activeId);return t&&!tr(t)?t:null}function ko(e){var t;return!e.archivedPage||!e.activeRepoId?null:((t=e.archived[e.activeRepoId])==null?void 0:t.find(n=>n.id===e.archivedPage))??null}function Ul(e,t){var o;if(((o=e.mark)==null?void 0:o.by)!==t)return e;const{mark:n,...r}=e;return r}const Xx=e=>e.kind==="theme"||e.kind==="appearance"||e.kind==="keep-awake"||e.kind==="agent"||e.kind==="agent-page"||e.kind==="choose-folder";function ec(e){if(!e.sending)return e;const{sending:t,...n}=e;return n}function k2(e,t){const n=Object.keys(e.local).filter(o=>{var a;return((a=e.local[o])==null?void 0:a.sending)&&(!t||o===t)});if(n.length===0)return e;const r={...e.local};for(const o of n)r[o]=ec(r[o]);return{...e,local:r}}function y2(e,t,n,r){var l;let o=e;const a=n?(l=o[n])==null?void 0:l.sending:void 0;if(a&&n&&r&&r!==n){const u=o[r]??La,c=u.chat.some(p=>p.kind==="user")?{}:a;o={...o,[n]:ec(o[n]),[r]:{...u,sending:c}}}for(const u of t){const c=o[u.id];c!=null&&c.sending&&!c.sending.message&&(u.agent==="working"||u.agent==="waiting")&&(o={...o,[u.id]:ec(c)})}return o}function Ct(e,t,n){return{...e,local:{...e.local,[t]:n(e.local[t]??La)}}}function pv(e,t){const n=e.find(r=>r.kind==="tool"&&!r.done&&!r.parentToolId&&!r.background);if(n)return(t==null?void 0:t.id)===n.id?t:{id:n.id,at:Date.now()}}function w2(e,t){const n=t.type==="agent-question"||t.type==="agent-permission",r=t.type==="agent-ask-end"?t.id:null;if(!n&&!r)return e;const o=t.type==="agent-ask-end"&&Ix(t.outcome),{ask:a,askParked:l,askRevived:u,...c}=e;return{...c,...a&&!n&&(a.id!==r||o)?{ask:a}:{},...l&&!n&&l!==r?{askParked:l}:{},...u&&!n?{askRevived:u}:{}}}function v2(e,t,n){return Ct(e,t,r=>({...r,chat:[...r.chat,n],chatAt:Date.now()}))}function Jx(e,t,n){return v2(Go(e),t,{kind:"error",text:n})}function $h(e,t){const n=pc(fn(e,e.activeId));return n?Ct(Go(e),n,r=>({...r,notice:t})):e}function hv(e,t,n){return fn(e,t)?Jx(e,t,n):$h(e,n)}function b2(e,t){const n=e.paletteReturn;return!t||!n?{overlay:null,paletteReturn:null}:{overlay:{kind:n.mode},paletteReturn:n}}function x2(e){const t=e.activeRepoId;if(!t)return e;const n=e.layouts[t];return n?Km(e,n):e.frame==="desk"?{...e,layouts:{...e.layouts,[t]:e.layout}}:e}function _2(e){return e.a==="server"&&e.msg.t==="git-status"}function E2(e){return{variants:1,batch:!1,agent:e.defaultAgent}}function S2(e){const t=fn(e,e.activeId);return!!t&&Cr(t.worktree)&&!e.archivedPage&&!Ud(e)?e.draft?e:{...e,draft:E2(e)}:e.draft?{...e,draft:null}:e}function e1(e){var r;const t=e.archivedPage,n=t!==null&&((r=e.editor)==null?void 0:r.worktreeId)===t&&fn(e,t)===null;return{...e,archivedPage:null,...n?{editor:null}:{}}}function xa(e,t){let n=S2(N2(e,t));return n.unreadHold!==null&&n.activeId!==n.unreadHold&&(n={...n,unreadHold:null}),n.archivedPage!==null&&(ko(n)===null||fn(n,n.archivedPage)!==null)&&(n=e1(n)),n.activeRepoId!==e.activeRepoId?n=x2(n):n.frame==="desk"&&n.activeRepoId&&!_2(t)&&n.layout!==e.layout&&(n={...n,layouts:{...n.layouts,[n.activeRepoId]:n.layout}}),n.rows===e.rows&&n.activeRepoId===e.activeRepoId&&n.archiving===e.archiving?n:{...n,visible:p2(n.rows,n.activeRepoId,n.archiving),visibleDiscovered:h2(n.rows,n.activeRepoId)}}function N2(e,t){var n,r,o,a,l,u;switch(t.a){case"connected":return{...e,connected:t.v,connectFailure:t.v?null:t.failure===void 0?e.connectFailure:t.failure};case"activate":return{...Al(e,t.id),screen:t.id?"chat":"home"};case"open-draft":{if(Ud(e))return e;const c=((n=Yx(e,e.activeRepoId))==null?void 0:n.id)??null;return c?Go({...Al(e,c),overlay:null,paletteReturn:null,focusChat:e.focusChat+1,screen:"chat"}):e}case"draft-carry":return e.draft?{...e,draft:{...e.draft,carry:t.v}}:e;case"draft-variants":return e.draft?{...e,draft:{...e.draft,variants:t.n}}:e;case"draft-batch":return e.draft?{...e,draft:{...e.draft,batch:t.v}}:e;case"draft-agent":return e.draft?{...e,draft:{...e.draft,agent:t.id}}:e;case"draft-profile":return e.draft?{...e,draft:{...e.draft,profile:t.profile}}:e;case"open-archived":return!e.activeRepoId||!((r=e.archived[e.activeRepoId])!=null&&r.some(c=>c.id===t.id))?e:{...e,archivedPage:t.id,editor:null,screen:"chat"};case"close-archived":return e.archivedPage?e1(e):e;case"restoring":return Ct(e,t.id,c=>({...c,restoring:t.text}));case"sending":return Ct(e,t.id,c=>({...c,sending:{message:t.message}}));case"sent-box":return Ct(e,t.id,({notice:c,...p})=>({...Ul(p,"walk"),draft:"",attachments:[],sent:(p.sent??0)+1}));case"archive-worktrees":{const c=t.ids.filter(E=>!e.archiving.includes(E)&&fn(e,E));if(c.length===0)return e;const p={...e,archiving:[...e.archiving,...c]};if(!e.activeId||!c.includes(e.activeId))return p;const m=e.visible.filter(E=>E.id===e.activeId||!p.archiving.includes(E.id)),h=m.findIndex(E=>E.id===e.activeId),k=E=>E.id!==e.activeId&&xm(E.worktree)&&!!E.worktree.landed&&E.agent==="idle",y=E=>{var M;return(M=m.find((K,U)=>U>h&&E(K))??m.find(E))==null?void 0:M.id},v=y(E=>E.id!==e.activeId&&E.agent==="waiting"),x=y(k),_=(o=jx(m,e.activeId,1))==null?void 0:o.activate,N=(a=m.map((E,M)=>({id:E.id,i:M,far:Math.abs(M-h),up:!Cr(E.worktree)&&Ks(E)==="running"})).filter(E=>E.up&&E.far>0).sort((E,M)=>E.far-M.far||M.i-E.i)[0])==null?void 0:a.id,j=Al(p,v??x??_??N??Bl(p,e.activeRepoId));return e.frame==="phone"?{...j,screen:"home"}:j}case"shipping":return e.shipping[t.id]||!(ms(e,t.id)||t1(e,t.id))?e:{...e,shipping:{...e.shipping,[t.id]:{op:t.op,sent:!0}}};case"activate-repo":{if(!Pa(e,t.id))return e;const c=e.newProject?{...e,newProject:null}:e;if(t.id===e.activeRepoId)return c;const p=Bl(c,t.id);return{...Al(c,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,editor:null};case"new-project-set":{if(!e.newProject)return e;const c="name"in t.v||"parent"in t.v||"url"in t.v||"mode"in t.v,{error:p,...m}=e.newProject;return{...e,newProject:{...c?m:e.newProject,...t.v}}}case"close-new-project":return e.newProject&&e.repos.length>0?{...e,newProject:null,choosingFolder:!1}:e;case"auto-sent":return e.autoSend?{...e,autoSend:null}:e;case"watch-import":return{...e,activeImportId:t.id};case"close-editor":return{...e,editor:null};case"open-file":{const c=t.v,p=e.editor,m=p&&bl(p,c)?p:null,h=c.line&&Zx(e,c.worktreeId,c.path,c.line);return{...e,editor:{worktreeId:c.worktreeId,path:c.path,...c.ref?{ref:c.ref}:{},...c.since?{since:c.since}:{},view:c.view??(m==null?void 0:m.view)??null,seq:c.seq,disk:(m==null?void 0:m.disk)??null,...h?{line:h}:{},focus:c.focus,conflict:(m==null?void 0:m.conflict)??null,blame:(m==null?void 0:m.blame)??null}}}case"open-loose":{const c=t.v,p={before:c.text,after:c.text,version:null,writable:c.source.kind!=="bytes"&&!c.tooLarge&&!c.binary,binary:c.binary,tooLarge:c.tooLarge};return{...e,editor:{worktreeId:c.worktreeId,path:c.name,view:Ai(c.name),seq:c.seq,disk:p,focus:!0,conflict:null,blame:null,loose:{source:c.source}}}}case"editor-read":{const c=e.editor;if(!c||c.loose||!bl(c,t.file))return e;const p=t.disk;if(!p){const k=Jx(e,c.worktreeId,t.error??`could not read ${c.path}`);return c.disk?k:{...k,editor:null}}const m=Ai(c.path),h=p.before===""?c.view&&c.view!=="diff"?c.view:m:c.view??(p.before===p.after?m:"diff");return{...e,editor:{...c,view:h,disk:p}}}case"editor-conflict":{const c=e.editor;return c&&!c.loose&&bl(c,t.file)?{...e,editor:{...c,conflict:t.theirs}}:e}case"editor-view":return e.editor?{...e,editor:{...e.editor,view:t.v,line:void 0}}:e;case"editor-refused":{const c=e.editor;if(!c||!bl(c,t.file))return e;const p=c.loose&&c.disk?{...c.disk,writable:!1}:c.disk;return{...e,editor:{...c,refused:t.message,disk:p}}}case"editor-blame":{const c=e.editor;return c&&!c.loose&&bl(c,t.file)?{...e,editor:{...c,blame:t.blame}}:e}case"notice":return Ct(Go(e),t.id,c=>({...c,notice:t.text}));case"link-refused":return Ct(e,t.id,({refusedLink:c,...p})=>t.v?{...p,refusedLink:t.v}:p);case"ask-draft":return Ct(e,t.id,c=>({...c,ask:t.ask}));case"ask-park":return Ct(e,t.id,c=>({...c,askParked:t.askId}));case"ask-unpark":return Ct(e,t.id,({askParked:c,...p})=>p);case"ask-revive":return Ct(e,t.id,({askRevived:c,...p})=>t.askId?{...p,askRevived:t.askId}:p);case"opened-url":return e.openUrl?{...e,openUrl:null}:e;case"set-draft":return Ct(e,t.id,c=>{const{notice:p,...m}=Ul(c,"walk");return{...m,draft:t.text,...p!==void 0&&t.text===""?{notice:p}:{}}});case"walk":return Ct(e,t.id,c=>({...Ul(c,"walk"),draft:t.text,...t.walk?{mark:{by:"walk",at:t.walk.at,from:t.walk.from}}:{}}));case"reveal":return Ct(Go(e),t.id,c=>{var p;return{...c,mark:{by:"reveal",seq:t.seq,n:((p=c.mark)==null?void 0:p.by)==="reveal"?c.mark.n+1:1}}});case"attach":return Ct(Go(e),t.id,({notice:c,...p})=>({...p,attachments:[...p.attachments,...t.items]}));case"attached":return(l=e.local[t.id])!=null&&l.attachments.some(c=>c.key===t.key)?Ct(e,t.id,c=>({...c,attachments:c.attachments.map(p=>p.key===t.key?t.item:p)})):e;case"detach":return Ct(e,t.id,({notice:c,...p})=>({...p,attachments:p.attachments.filter(m=>m.key!==t.key)}));case"clear-attachments":return Ct(e,t.id,({notice:c,...p})=>p.attachments.length?{...p,attachments:[]}:p);case"hmr":return Ct(e,t.id,c=>({...c,turn:{...c.turn,hmr:!0}}));case"page":return Ct(e,t.id,c=>({...c,page:{url:t.url??c.page.url,title:t.title??c.page.title,errors:t.fresh?[]:t.error?[...c.page.errors.slice(-2),t.error]:c.page.errors}}));case"links":return Ct(e,t.id,c=>{const p=n2(c.links??[],t.links);return p===c.links?c:{...c,links:p}});case"drag-files":return l2(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:Xx(t.overlay)?e.paletteReturn:null};case"choosing-folder":return{...e,choosingFolder:t.v};case"close":return{...e,previewTheme:null,...b2(e,t.back)};case"toggle":return((u=e.overlay)==null?void 0:u.kind)===t.overlay.kind?xa(e,{a:"close"}):xa(e,{a:"open",overlay:t.overlay});case"palette-return":return{...e,paletteReturn:t.v};case"toggle-changes":return{...Wr(e,{changes:!e.layout.changes}),changesAuto:!1};case"focus-changes":return{...Wr(e,{changes:!0,changesTab:t.tab&&!ko(e)?t.tab:e.layout.changesTab}),changesAuto:!1,focusChanges:e.focusChanges+1};case"changes-tab":return Wr(e,{changesTab:t.v});case"edit-commit":return{...Wr(e,{changes:!0}),changesAuto:!1,editCommit:e.editCommit+1};case"toggle-chat":return mo(e)?e:Wr(e,{chat:!e.layout.chat});case"focus-chat":return{...Go(e),focusChat:e.focusChat+1};case"walked":return{...e,walked:e.walked+1};case"show-chat":return Go(e);case"hold-unread":return{...e,unreadHold:t.id};case"toggle-rail":return{...e,railOpen:!e.railOpen};case"toggle-chat-side":return{...e,chatSide:e.chatSide==="left"?"right":"left"};case"update-check":return{...e,updateCheck:"asking"};case"update-check-settle":return e.updateCheck===t.check?{...e,updateCheck:null}:e;case"focus-rail":return{...e,railOpen:!0,focusRail:e.focusRail+1,screen:"home"};case"screen":return e.screen===t.to&&!e.editor?e:{...t.to==="changes"&&e.screen!=="changes"?Wr(e,{changesTab:"changes"}):e,screen:t.to,editor:null};case"frame":{if(e.frame===t.v)return e;const c={...e,frame:t.v};if(t.v!=="desk"||!c.activeRepoId)return c;const p=c.layouts[c.activeRepoId];return p?Km(c,p):c}case"touch":return e.touch===t.v?e:{...e,touch:t.v};case"reading":return e.reading===t.on?e:{...e,reading:t.on};case"rail-peek":return e.railPeek===t.on?e:{...e,railPeek:t.on};case"toggle-discovered":{const c=e.activeRepoId;return c?{...e,discoveredOpen:{...e.discoveredOpen,[c]:!e.discoveredOpen[c]}}:e}case"toggle-archived":{const c=e.activeRepoId;return c?{...e,archivedOpen:{...e.archivedOpen,[c]:!e.archivedOpen[c]}}:e}case"toggle-committed":{const c=e.activeRepoId;return c?{...e,committedShut:{...e.committedShut,[c]:!e.committedShut[c]}}:e}case"toggle-turn":{const c=e.activeRepoId;return c?{...e,turnOpen:{...e.turnOpen,[c]:!e.turnOpen[c]}}:e}case"tree-folder":{const c=e.treeOpen[t.worktreeId]??[];if(c.includes(t.path)===t.open)return e;const p=t.open?[...c,t.path]:c.filter(h=>h!==t.path),m={...e.treeOpen};return p.length>0?m[t.worktreeId]=p:delete m[t.worktreeId],{...e,treeOpen:m}}case"tree-reveal":{const c=e.treeOpen[t.worktreeId]??[],p=[];for(let k=t.path.indexOf("/");k!==-1;k=t.path.indexOf("/",k+1))p.push(t.path.slice(0,k));p.push(t.path);const m=p.filter(k=>!c.includes(k)),h=m.length?{...e.treeOpen,[t.worktreeId]:[...c,...m]}:e.treeOpen;return{...Wr(e,{changes:!0,changesTab:"files"}),changesAuto:!1,focusChanges:e.focusChanges+1,treeOpen:h,treeReveal:{worktreeId:t.worktreeId,path:t.path}}}case"files-asked":return Ct(e,t.worktreeId,c=>({...c,filesFor:t.key}));case"toggle-zen":return mo(e)?e:{...e,zen:!e.zen};case"toggle-terminal":return Wr(e,{term:!e.layout.term});case"focus-terminal":return{...Wr(e,{term:!0}),focusTerm:e.focusTerm+1};case"toggle-design":return mo(e)?e:Wr(e,{design:!e.layout.design});case"term-stream":return Ct({...Wr(e,{term:!0}),termTall:t.tall?e.termTall+1:e.termTall},t.id,c=>({...c,termStream:t.stream}));case"term-run":return Ct({...Wr(e,{term:!0}),focusTerm:e.focusTerm+1,termRun:{id:t.id,command:t.command}},t.id,c=>({...c,termStream:po}));case"term-ran":return e.termRun?{...e,termRun:null}:e;case"preview-theme":return{...e,previewTheme:t.theme};case"system-dark":return{...e,systemDark:t.v};case"incompatible":return{...e,incompatible:!0,connected:!1};case"server":return I2(e,t.msg)}}function mv(e,t){const n=Object.entries(e),r=n.filter(([o])=>t.some(a=>a.id===o));return r.length===n.length?e:Object.fromEntries(r)}function gv(e,t,n){const r=new Set(t.map(l=>l.id));n&&r.add(n);const o=([l,u])=>r.has(l)||!!u.draft||u.attachments.length>0,a=Object.entries(e);return a.every(o)?e:Object.fromEntries(a.filter(o))}function T2(e,t,n){var o;let r=e;for(const a of n){if(!((o=a.worktree)!=null&&o.landed)||t.some(u=>{var c;return u.id===a.id&&((c=u.worktree)==null?void 0:c.landed)}))continue;const l=r[a.id];!(l!=null&&l.git)||l.git.files.length===0||(r===e&&(r={...e}),r[a.id]={...l,git:{...l.git,files:[]}})}return r}function j2(e,t){let n=e;for(const[r,o]of Object.entries(t)){const a=n[r];a!=null&&a.draft||(n===e&&(n={...e}),n[r]={...a??La,draft:o})}return n}function C2(e,t){let n=e;for(const[r,o]of Object.entries(t)){const a=n[r];a!=null&&a.attachments.length||(n===e&&(n={...e}),n[r]={...a??La,attachments:Oh(o,[])})}return n}function A2(e,t){const n=new Set(t.map(r=>r.id));return Object.values(e).every(r=>n.has(r))?e:Object.fromEntries(Object.entries(e).filter(([,r])=>n.has(r)))}function ki(e,t){const n=new Set(t.map(r=>r.id));return Object.keys(e).every(r=>n.has(r))?e:Object.fromEntries(Object.entries(e).filter(([r])=>n.has(r)))}function kv(e){const t=e.newProject;if((t==null?void 0:t.phase)!=="creating"||!t.repoId)return e;const n=Yx(e,t.repoId);return n?t.prompt.trim()?{...Ct(e,n.id,o=>({...o,draft:t.prompt})),newProject:null,autoSend:n.id}:{...e,newProject:null}:e}function t1(e,t){return Object.values(e.trunks).some(n=>n.id===t)}function I2(e,t){var n,r,o,a,l,u,c,p,m,h,k;switch(t.t){case"hello":{const y=j=>!!j&&t.rows.some(E=>E.id===j),v=j=>!!j&&t.repos.some(E=>E.id===j),x=v(e.activeRepoId)?e.activeRepoId:v(e.storedRepo)?e.storedRepo:null,_=y(e.activeId)?e.activeId:y(e.storedActive)?e.storedActive:Bl(e,x,t.rows),N=t.rows.find(j=>j.id===_);return{...e,heard:!0,repos:t.repos,rows:t.rows,activeId:_,activeRepoId:(N==null?void 0:N.repoId)??x??((n=t.repos[0])==null?void 0:n.id)??null,trunks:t.trunks,archiving:e.archiving.length?[]:e.archiving,shipping:fv({},t.rows,t.trunks),local:gv(C2(j2(e.local,t.drafts),t.attachments),t.rows,e.archivedPage),lastActive:A2(e.lastActive,t.rows),treeOpen:mv(e.treeOpen,t.rows),discoveredOpen:ki(e.discoveredOpen,t.repos),archivedOpen:ki(e.archivedOpen,t.repos),committedShut:ki(e.committedShut,t.repos),turnOpen:ki(e.turnOpen,t.repos),refs:ki(e.refs,t.repos),chats:ki(e.chats,t.repos),archived:ki(e.archived,t.repos),themes:t.themes??e.themes,themePrefs:t.themePrefs??e.themePrefs,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen,home:t.home,folderDialog:t.folderDialog,keepAwake:t.keepAwake,remote:t.remote,managed:t.managed,paired:t.paired,gitIdentity:t.gitIdentity,newProject:e.newProject??(t.repos.length===0&&t.rows.length===0&&t.pending.length===0?uv():null),pending:t.pending,visits:t.visits,self:t.self,update:t.update,updateCheck:e.updateCheck==="asking"?null:e.updateCheck,version:t.version,install:t.install,registry:t.registry,activeImportId:t.pending.some(j=>j.id===e.activeImportId)?e.activeImportId:null}}case"self":{const y=((r=e.self)==null?void 0:r.building)===!0&&e.self.rebuild&&!((o=t.self)!=null&&o.building);return{...e,self:t.self,rebuilt:e.rebuilt||y&&((a=t.self)==null?void 0:a.buildFailed)===void 0}}case"paired":return{...e,paired:!0,pairings:e.pairings+1};case"update":return{...e,update:t.update};case"update-checked":return{...e,updateCheck:t.check};case"visits":return{...e,visits:{...e.visits,[t.repoId]:t.pages}};case"themes":return{...e,themes:t.themes,themePrefs:t.prefs};case"daylight":return{...e,daylight:{dark:t.dark,until:t.until}};case"keep-awake":return{...e,keepAwake:t.mode};case"agents":return{...e,agents:t.agents,defaultAgent:t.defaultAgent,agentChosen:t.agentChosen};case"agent-config":{const{t:y,...v}=t;return{...e,agentConfigs:{...e.agentConfigs,[v.agent]:v}}}case"pending-repos":{const y=new Set(e.pending.map(j=>j.id)),v=t.pending.find(j=>!y.has(j.id)),x=v&&e.pendingOpen?v.id:e.activeImportId,_=t.pending.some(j=>j.id===x),N=t.pending.some(j=>j.id===x&&j.error);return{...e,pending:t.pending,activeImportId:_?x:null,pendingOpen:N?!1:e.pendingOpen,newProject:v&&e.pendingOpen&&((l=e.newProject)==null?void 0:l.phase)==="creating"?null:e.newProject}}case"path-entries":return{...e,paths:{query:t.query,entries:t.entries,target:t.target}};case"folder-chosen":return{...e,chosenFolder:{seq:(((u=e.chosenFolder)==null?void 0:u.seq)??0)+1,folder:t.folder}};case"refs":return{...e,refs:{...e.refs,[t.repoId]:{query:t.query,refs:t.refs}}};case"chat-hits":return{...e,chats:{...e.chats,[t.repoId]:{query:t.query,hits:t.hits,truncated:t.truncated}}};case"archived":return{...e,archived:{...e.archived,[t.repoId]:t.items}};case"draft":return t.clientId===e.clientId?e:Ct(e,t.boxId,y=>{var v;return y.draft===t.text||((v=y.mark)==null?void 0:v.by)==="walk"?y:{...y,draft:t.text}});case"attachments":return t.clientId===e.clientId?e:Ct(e,t.boxId,y=>({...y,attachments:Oh(t.items,y.attachments)}));case"repos":{const y=new Set(e.repos.map(E=>E.id)),v=t.repos.find(E=>!y.has(E.id));let x=e.activeRepoId,_=e.pendingOpen,N=e.newProject;v&&(_||!x)?(x=v.id,_=!1,N&&N.phase!=="unmaking"&&(N={...N,phase:"creating",repoId:v.id})):t.repos.some(E=>E.id===x)||(x=((c=t.repos[0])==null?void 0:c.id)??null),(N==null?void 0:N.phase)==="unmaking"&&!t.repos.some(E=>E.id===(N==null?void 0:N.repoId))&&(N={...N,phase:"editing",repoId:null}),t.repos.length===0&&!N&&(N=uv());const j=e.gitIdentity||t.repos.some(E=>E.made&&!y.has(E.id));return x===e.activeRepoId?{...e,repos:t.repos,pendingOpen:_,newProject:N,gitIdentity:j}:kv({...e,repos:t.repos,pendingOpen:_,newProject:N,gitIdentity:j,activeRepoId:x,activeId:Bl(e,x),editor:null})}case"worktrees":{let y=e.activeId;(!y||!t.rows.some(E=>E.id===y))&&(y=Bl(e,e.activeRepoId,t.rows));const v=new Set(e.rows.map(E=>E.id)),x=E=>{var M;return((M=E.worktree)==null?void 0:M.kind)==="worktree"&&E.worktree.createdBy===e.clientId},_=t.rows.find(E=>!v.has(E.id)&&x(E)),N=!!y&&e.rows.some(E=>{var M;return E.id===y&&((M=E.worktree)==null?void 0:M.kind)==="spare"})&&t.rows.some(E=>E.id===y&&x(E));_&&e.rows.length>0&&!N&&(y=_.id);const j=e.archiving.filter(E=>t.rows.some(M=>M.id===E));return kv({...Al({...e,rows:t.rows,trunks:t.trunks,archiving:j.length===e.archiving.length?e.archiving:j,shipping:fv(e.shipping,t.rows,t.trunks),local:y2(T2(gv(e.local,t.rows,e.archivedPage),e.rows,t.rows),t.rows,e.activeId,y===(_==null?void 0:_.id)?_.id:void 0),treeOpen:mv(e.treeOpen,t.rows)},y),editor:y===e.activeId?e.editor:null,archivedPage:_?null:e.archivedPage})}case"proc":{const y=e.rows.map(v=>v.id===t.worktreeId?{...v,procs:R2(v.procs,t.proc)}:v);return{...e,rows:y}}case"log":return Ct(e,t.worktreeId,y=>({...y,log:rT(y.log.slice(-400),t.proc,t.line,t.retract)}));case"agent":{const y=t.event,v=t.worktreeId;let x=Ct(e,v,_=>{const N=wv(_.chat,y,t.seq),E=y.type==="tool-start"||y.type==="tool-end"||y.type==="turn-end"||y.type==="tool-update"&&y.background?pv(N,_.running):_.running;let M=_.turn;y.type==="turn-start"?M={edits:!1,hmr:!1}:y.type==="tool-start"&&vb(y)&&(M={...M,edits:!0});const K=y.type==="session-info"&&y.model?y.model:_.model,U=y.type==="session-info"&&y.effort?y.effort:_.effort,R=y.type==="usage"?{...yv(y),heard:Date.now()}:_.usage,{restoring:I,...C}=_,P=e.rows.find(ue=>ue.id===v),z=(P==null?void 0:P.agent)==="working"||(P==null?void 0:P.agent)==="waiting",q=C.sending?z?ec(C):{...C,sending:{}}:C,se=y.type==="turn-end"||y.type==="agent-error",pe=w2(y.type==="user-message"?q:se?ec(_):_,y);return{...y.type==="user-message"?Ul(pe,"reveal"):pe,chat:N,...N!==_.chat?{chatAt:Date.now()}:{},...E!==_.running?{running:E}:{},turn:M,...K!==_.model?{model:K}:{},...U!==_.effort?{effort:U}:{},...R!==_.usage?{usage:R}:{}}});if(y.type==="turn-end"){const _=x.local[v].turn;_.edits&&!_.hmr&&(x={...x,reloadReq:{id:v,n:(((p=x.reloadReq)==null?void 0:p.n)??0)+1}})}return(y.type==="agent-question"||y.type==="agent-permission")&&v===e.activeId&&(x=Go(x)),x}case"backfill":{let y=[],v;for(const{seq:_,event:N}of t.events)y=wv(y,N,_),N.type==="usage"&&(v=yv(N));const x=_=>t.events.some(({event:N})=>N.type==="user-message"&&N.text===_);return Ct(e,t.worktreeId,({restoring:_,sending:N,...j})=>({...j,...N&&!(N.message&&x(N.message.text))?{sending:N}:{},chat:y,chatAt:Date.now(),running:pv(y,j.running),log:t.log??j.log,...v?{usage:v}:{},..._!==void 0&&!x(_)?{restoring:_}:{}}))}case"git-status":{let y=e.layout.changes,v=e.changesAuto;e.changesAuto&&t.worktreeId===e.activeId&&!y&&(t.files.length>0||(((m=t.committed)==null?void 0:m.length)??0)>0)&&(y=!0,v=!1);const x=t.worktreeId===e.archivedPage?ko(e):null;x&&(t.files.length>0||(((h=t.committed)==null?void 0:h.length)??0)>0||x.landed)&&(y=!0);const _=Ct(e,t.worktreeId,N=>({...N,git:{files:t.files,committed:t.committed,turn:t.turn,ahead:t.ahead,behind:t.behind,unpushed:t.unpushed,head:t.head},changedRanges:{}}));return{...Wr(_,{changes:y}),changesAuto:v}}case"changed-ranges":{const y=Ct(e,t.worktreeId,x=>({...x,changedRanges:{...x.changedRanges,[t.path]:{ranges:t.ranges,offset:t.lineOffset}}})),v=y.editor;return!((k=v==null?void 0:v.line)!=null&&k.fiber)||v.worktreeId!==t.worktreeId||v.path!==t.path?y:{...y,editor:{...v,line:Zx(y,v.worktreeId,v.path,v.line)}}}case"shipped":{const y=t.worktreeId,v={...e,shipping:dv(e.shipping,x=>{var _;return x===y&&((_=e.shipping[x])==null?void 0:_.sent)===!0}),openUrl:t.ok&&t.url?t.url:e.openUrl};return!t.ok&&!t.asked?y?hv(v,y,t.message):$h(v,t.message):v}case"files":return Ct(e,t.worktreeId,y=>({...y,files:t.paths,submodules:t.submodules,ignored:t.ignored}));case"search-results":return Ct(e,t.worktreeId,y=>({...y,search:{query:t.query,hits:t.hits,truncated:t.truncated}}));case"element-sources":{if(e.editor&&e.editor.seq>t.seq)return e;const[y]=t.hits;if(!y)return Ct(e,t.worktreeId,x=>({...x,notice:"nothing in the source matches this element"}));if(!t.sure)return xa(e,{a:"open",overlay:{kind:"element-sources",worktreeId:t.worktreeId,hits:t.hits}});const v=xa(e,{a:"open-file",v:{worktreeId:t.worktreeId,path:y.path,view:"file",line:{n:y.line},focus:!0,seq:t.seq}});return v.layout.changes?v:xa(v,{a:"toggle-changes"})}case"design-index":return Ct(e,t.worktreeId,y=>({...y,design:t.index}));case"routes":return Ct(e,t.worktreeId,y=>({...y,pages:{routes:t.routes,unseen:t.unseen}}));case"queue":return Ct(e,t.worktreeId,y=>({...y,queue:t.items}));case"agent-commands":return Ct(e,t.worktreeId,y=>({...y,commands:t.commands}));case"git-log":return Ct(e,t.worktreeId,y=>({...y,commits:t.commits}));case"git-commit":return Ct(e,t.worktreeId,y=>({...y,commitFiles:{...y.commitFiles,[t.sha]:t.files}}));case"error":{const y=t.worktreeId,v=e.newProject,x=(v==null?void 0:v.phase)==="creating"&&!v.repoId,_={...k2(e,y),archiving:y?e.archiving.includes(y)?e.archiving.filter(N=>N!==y):e.archiving:e.archiving.length?[]:e.archiving,shipping:dv(e.shipping,N=>!y||N===y),newProject:x?{...v,phase:"editing",error:t.message}:(v==null?void 0:v.phase)==="unmaking"?null:v,pendingOpen:x?!1:e.pendingOpen,updateCheck:!y&&e.updateCheck==="asking"?null:e.updateCheck};return x?_:y?hv(_,y,t.message):$h(_,t.message)}case"unsent":return Ct(Go(e),t.boxId,({restoring:y,sending:v,...x})=>({...x,draft:x.draft||t.text,attachments:[...Oh(t.items,[]),...x.attachments],notice:t.message}));default:return e}}function R2(e,t){const n=e.findIndex(o=>o.name===t.name);if(n===-1)return[...e,t];const r=e.slice();return r[n]=t,r}function yv(e){return{used:e.used,size:e.size,...e.cost!==void 0?{cost:e.cost}:{}}}function O2(e,t){const n=t.trim();return n!==""&&(e.trim()===n||e.trim().endsWith(`: ${n}`))}function wv(e,t,n){var a,l;const r=e[e.length-1],o=n===void 0?{}:{seq:n};switch(t.type){case"fix-asked":return[...e,{kind:"asked",why:t.why,...t.toolId?{toolId:t.toolId}:{}}];case"user-message":return[...e,{kind:"user",text:t.text,...(a=t.attachments)!=null&&a.length?{attachments:t.attachments}:{},...o}];case"text-delta":{const u=t.messageId?{messageId:t.messageId}:{};if((r==null?void 0:r.kind)==="assistant")return[...e.slice(0,-1),{...r,text:r.text+t.text,...u}];const c=t.messageId===void 0?-1:$2(e,t.messageId);if(c!==-1){const p=e.slice(),m=p[c];return p[c]={...m,text:m.text+t.text},p}return[...e,{kind:"assistant",text:t.text,...o,...u}]}case"thinking-delta":return(r==null?void 0:r.kind)==="thinking"?[...e.slice(0,-1),{...r,text:r.text+t.text}]:[...e,{kind:"thinking",text:t.text}];case"tool-start":return[...e,{kind:"tool",id:t.toolId,name:t.name,input:t.input,done:!1,...t.kind?{toolKind:t.kind}:{},...t.title?{title:t.title}:{},...t.parentToolId?{parentToolId:t.parentToolId}:{},...t.subagent?{subagent:!0}:{}}];case"tool-update":{const u=e.findLastIndex(m=>m.kind==="tool"&&m.id===t.toolId);if(u===-1)return e;const c=e.slice(),p=c[u];return c[u]={...p,...t.name?{name:t.name}:{},...t.title?{title:t.title}:{},...t.input!==void 0?{input:t.input}:{},...t.kind?{toolKind:t.kind}:{},...t.background?{background:!0}:{}},c}case"tool-delta":{const u=e.findLastIndex(m=>m.kind==="tool"&&m.id===t.toolId);if(u===-1)return e;const c=e.slice(),p=c[u];return c[u]={...p,output:(p.output??"")+t.text},c}case"tool-end":{const u=e.findLastIndex(m=>m.kind==="tool"&&m.id===t.toolId);if(u===-1)return e;const c=e.slice(),p=c[u];return c[u]={...p,output:t.output,isError:t.isError,...(l=t.images)!=null&&l.length?{images:t.images}:{},...t.detached?{detached:!0}:{},...t.fixable?{fixable:t.fixable}:{},done:!0},c}case"agent-error":return(r==null?void 0:r.kind)==="assistant"&&O2(t.message,r.text)?[...e.slice(0,-1),{kind:"error",text:t.message}]:[...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"landed":return[...e,{kind:"landed",text:t.message,archiveIds:t.archiveIds,ts:t.ts}];case"restored":return[...e,{kind:"restored",archivedAt:t.archivedAt,branch:t.branch,uncommitted:t.uncommitted,ts:t.ts}];case"adopted":return[...e,{kind:"adopted",branch:t.branch,ts:t.ts}];case"agent-auth-required":return[...e,{kind:"auth",agent:t.agent,agentName:t.agentName,methods:t.methods,...t.rejected?{rejected:!0}:{},...t.withheld?{withheld:!0}:{},done:!1}];case"agent-auth-ok":return e.some(u=>u.kind==="auth"&&!u.done)?e.map(u=>u.kind==="auth"&&!u.done?{...u,done:!0}:u):e;case"agent-question":return vv(e,t.toolId,{kind:"ask",id:t.id,ask:{kind:"question",message:t.message,questions:t.questions}});case"agent-permission":{const u={kind:"ask",id:t.id,ask:{kind:"permission",title:t.title,...t.detail?{detail:t.detail}:{},...t.plan?{plan:t.plan}:{},choices:t.choices}},c=e.findLast(p=>p.kind==="tool"&&p.id===t.toolId);return(c==null?void 0:c.kind)!=="tool"||t.plan||c.toolKind==="switch_mode"?vv(e,t.toolId,u):[...e,{...u,toolId:c.id}]}case"agent-ask-end":{const u=e.findLastIndex(m=>m.kind==="ask"&&m.id===t.id&&!m.outcome);if(u===-1)return e;const c=e[u];if(c.toolId&&M2(c,t.choiceId))return[...e.slice(0,u),...e.slice(u+1)];const p=e.slice();return p[u]={...p[u],outcome:t.outcome,...t.answers?{answers:t.answers}:{},...t.choiceId?{choiceId:t.choiceId}:{}},p}case"turn-end":{const u=c=>c.kind==="tool"&&!c.done&&!c.background;return e.some(u)?e.map(c=>u(c)?{...c,done:!0}:c):e}default:return e}}function $2(e,t){var o;let n=e.length-1;for(;n>=0&&((o=e[n])==null?void 0:o.kind)==="user";)n--;const r=e[n];return(r==null?void 0:r.kind)==="assistant"&&r.messageId===t?n:-1}function M2(e,t){var n;return e.ask.kind!=="permission"||!t?!1:!!((n=e.ask.choices.find(r=>r.id===t))!=null&&n.kind.startsWith("allow"))}function vv(e,t,n){const r=t?e.findLastIndex(o=>o.kind==="tool"&&o.id===t):-1;return r===-1?[...e,n]:[...e.slice(0,r),...e.slice(r+1),n]}function L2(e){let t=e;const n=new Set;return{getState:()=>t,dispatch(r){const o=xa(t,r);if(o!==t){t=o;for(const a of n)a()}},subscribe(r){return n.add(r),()=>n.delete(r)}}}const n1=S.createContext(null),r1=S.createContext(null),o1=S.createContext(null);function P2({store:e,sock:t,files:n,children:r}){return f.jsx(n1.Provider,{value:e,children:f.jsx(r1.Provider,{value:t,children:f.jsx(o1.Provider,{value:n,children:r})})})}function Bn(){const e=S.useContext(n1);if(!e)throw new Error("useStore outside <StoreProvider>");return e}function L(e){const t=Bn();return S.useSyncExternalStore(t.subscribe,()=>e(t.getState()))}function qm(){const e=L(n=>n.systemDark),t=L(n=>{var r;return(r=n.daylight)==null?void 0:r.dark});return{system:e,daylight:t??e}}function ct(){return Bn().dispatch}function it(){return S.useContext(r1)}function s1(){return S.useContext(o1)}const mt={active:"toyon-active",phoneRow:"toyon-phone-row",repo:"toyon-repo",lastActive:"toyon-last",discoveredOpen:"toyon-disc",archivedOpen:"toyon-arch",committedShut:"toyon-committed-shut",turnOpen:"toyon-turn-open",treeOpen:"toyon-tree",token:"toyon-token",theme:"toyon-theme",daylight:"toyon-sun",changesWidth:"toyon-changes-w",chatWidth:"toyon-chat-w",editorHeight:"toyon-dh",editorFull:"toyon-dfull",designHeight:"toyon-dsh",designFull:"toyon-dsfull",termHeight:"toyon-th",rail:"toyon-rail",railWidth:"toyon-rail-w",chatSide:"toyon-chat-side",clipboardOffer:"toyon-clipboard-offer",layouts:"toyon-layouts",client:"toyon-client",profilePrefix:"toyon-profile-",modePrefix:"toyon-mode-",modelPrefix:"toyon-model-",effortPrefix:"toyon-effort-"},D2="orch-";function z2(){for(const[e,t]of[[localStorage,["active","token","theme","editorHeight","editorFull"]],[sessionStorage,["client"]]])for(const n of t){const r=mt[n],o=D2+r.slice(6);try{const a=e.getItem(o);a!==null&&(e.getItem(r)===null&&e.setItem(r,a),e.removeItem(o))}catch{}}}function F2(e=!1,t=!0){const n=S.useRef(null);return S.useEffect(()=>{if(!t)return;const r=()=>{const a=n.current;!a||document.activeElement===a||(a.focus(),e&&a instanceof HTMLInputElement&&a.select())};r();const o=requestAnimationFrame(r);return()=>cancelAnimationFrame(o)},[e,t]),n}function ho(e,t,n){const r=()=>{try{return n(localStorage.getItem(e))??t}catch{return t}},[o,a]=S.useState(()=>({key:e,value:r()}));return o.key!==e&&a({key:e,value:r()}),[o.key===e?o.value:r(),c=>{a({key:e,value:c});try{localStorage.setItem(e,typeof c=="boolean"?c?"1":"0":String(c))}catch{}}]}function _a(e,t){return n=>{n.preventDefault(),document.body.classList.add("resizing");const r=n.currentTarget;r.classList.add("active");const o=l=>{const u=e(l,r);u!==null&&t(u)},a=()=>{document.body.classList.remove("resizing"),r.classList.remove("active"),window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",a)};window.addEventListener("pointermove",o),window.addEventListener("pointerup",a)}}function i1(e,t){const[n,r]=S.useState(!1);return S.useEffect(()=>{if(!e){r(!1);return}const o=setTimeout(()=>r(!0),t);return()=>clearTimeout(o)},[e,t]),n}function Gm(e,t){const[n,r]=S.useState(void 0);return S.useEffect(()=>{if(e===void 0){r(void 0);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}const Vm=1500;function Aa(e){const[t,n]=S.useState(()=>Date.now()),r=e!==void 0;return S.useEffect(()=>{if(!r)return;n(Date.now());const o=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(o)},[r]),r?Math.max(0,Math.floor((t-e)/1e3)):0}function B2(){const[e,t]=S.useState(window.innerWidth);return S.useEffect(()=>{const n=()=>t(window.innerWidth);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),e}function U2(e){const t=S.useRef(null);return S.useLayoutEffect(()=>{const n=t.current;if(!n)return;t.current=null;const r=n.closest(e);if(!r)return;const o=r.getBoundingClientRect(),a=n.getBoundingClientRect(),l=a.bottom-o.bottom;if(l<=0)return;const u=parseFloat(getComputedStyle(r).paddingTop)||0;r.scrollTop+=Math.min(l,Math.max(0,a.top-o.top-u))}),n=>{t.current=n}}const Au=40,H2=1200;function a1(e,t){const n=S.useRef(!0),r=S.useRef(null),o=S.useRef(0),[a,l]=S.useState(!1),[u,c]=S.useState(!1),[p,m]=S.useState(!1),[h,k]=S.useState(null),y=S.useCallback(M=>{n.current=M,e.current&&(e.current.style.overflowAnchor=M?"none":"")},[e]),v=S.useRef(null),x=S.useRef(null);gt([t],()=>{n.current||m(!0)});const _=S.useCallback(()=>{const M=e.current;M&&(y(M.scrollHeight-M.scrollTop-M.clientHeight<Au),l(!n.current),c(M.scrollTop>=Au),n.current&&m(!1))},[e,y]),N=S.useCallback(M=>{M!==0&&(k(M<0?"up":"down"),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>k(null),H2))},[]),j=S.useCallback(()=>{const M=e.current;M&&(M.scrollTop=M.scrollHeight,r.current=M.scrollTop,o.current=M.clientHeight,y(!0),l(!1),m(!1))},[e,y]),E=S.useCallback(()=>{e.current&&(e.current.scrollTop=0)},[e]);return S.useEffect(()=>{const M=e.current;if(!M)return;y(n.current);const K=()=>{n.current&&M.scrollTop===r.current?c(M.scrollTop>=Au):_()};M.addEventListener("scroll",K,{passive:!0});const U=q=>N(q.deltaY),R=q=>{var se;v.current=((se=q.touches[0])==null?void 0:se.clientY)??null},I=q=>{var pe;const se=(pe=q.touches[0])==null?void 0:pe.clientY;se===void 0||v.current===null||(N(v.current-se),v.current=se)};M.addEventListener("wheel",U,{passive:!0}),M.addEventListener("touchstart",R,{passive:!0}),M.addEventListener("touchmove",I,{passive:!0});const C=()=>{M.scrollTop=M.scrollHeight,r.current=M.scrollTop,o.current=M.clientHeight},P=new ResizeObserver(()=>{n.current&&C()});P.observe(M);for(const q of M.children)P.observe(q);const z=new MutationObserver(q=>{for(const pe of q){for(const ue of pe.addedNodes)ue instanceof Element&&P.observe(ue);for(const ue of pe.removedNodes)ue instanceof Element&&P.unobserve(ue)}const se=M.scrollHeight-M.scrollTop;n.current&&(se-M.clientHeight<Au||Math.abs(se-o.current)<1)&&C()});return z.observe(M,{childList:!0}),()=>{M.removeEventListener("scroll",K),M.removeEventListener("wheel",U),M.removeEventListener("touchstart",R),M.removeEventListener("touchmove",I),z.disconnect(),P.disconnect(),x.current&&clearTimeout(x.current)}},[e,_,N,y]),{offEnd:a,offStart:u,away:p,moving:h,pinned:()=>n.current,jump:j,start:E,read:_}}function bv(e,t,n){const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t,n),r.toString().length}function xv(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=0,o=null;for(let a=n.nextNode();a;a=n.nextNode()){if(r+a.data.length>=t)return[a,t-r];r+=a.data.length,o=a}return o?[o,o.data.length]:[e,0]}function l1(e,t){S.useLayoutEffect(()=>{const n=e.current;if(!n)return;const r=window.getSelection(),o=k=>!!k&&n.contains(k),a=r&&r.rangeCount>0&&o(r.anchorNode)?bv(n,r.anchorNode,r.anchorOffset):null,l=r&&r.rangeCount>0&&o(r.focusNode)?bv(n,r.focusNode,r.focusOffset):null,u=r&&(a!==null||l!==null)?[r.anchorNode,r.anchorOffset,r.focusNode,r.focusOffset]:null;if(n.innerHTML=t,!r||!u)return;const[c,p]=a===null?[u[0],u[1]]:xv(n,a),[m,h]=l===null?[u[2],u[3]]:xv(n,l);c&&m&&r.setBaseAndExtent(c,p,m,h)},[e,t])}function gt(e,t){const n=S.useRef(t);n.current=t,S.useEffect(()=>n.current(),e)}function c1(e){const[t,n]=S.useState({left:0,right:0});return S.useLayoutEffect(()=>{if(!e)return;const r=()=>{const a=e.getBoundingClientRect();let{left:l,right:u}=a;const c=e.closest("[data-pinned]");if(c){const m=c.getBoundingClientRect(),h=c.offsetWidth/m.width;l=c.offsetLeft+(l-m.left)*h,u=c.offsetLeft+(u-m.left)*h}const p={left:Math.round(l),right:Math.round(u)};n(m=>m.left===p.left&&m.right===p.right?m:p)};r();const o=new ResizeObserver(r);return o.observe(e),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},[e]),t}function _v(){const[e,t]=S.useState(null);return[t,c1(e)]}function xB(e){e.ctrlKey&&e.stopPropagation()}function W2(e){S.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;r&&(t.scale<1.01?delete r.dataset.zoomed:r.dataset.zoomed="")};return n(),t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)},[e])}function K2(e){S.useEffect(()=>{const t=window.visualViewport;if(!t)return;const n=()=>{const r=e.current;if(r){if(t.scale<1.01){delete r.dataset.pinned;return}r.dataset.pinned="",r.style.setProperty("--pin-x",`${t.offsetLeft}px`),r.style.setProperty("--pin-y",`${t.offsetTop}px`),r.style.setProperty("--pin-scale",String(1/t.scale))}};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n)}},[e])}const Da=()=>L(e=>e.activeId),u1=()=>i1(!L(e=>e.connected),900),gs=()=>L(e=>fn(e,e.activeId)),Ym=()=>L(e=>ms(e,e.activeId)),d1=()=>L(e=>e.rows),Qm=()=>L(e=>e.visible),Z2=()=>L(e=>e.visibleDiscovered),q2=()=>L(e=>e.activeRepoId?e.discoveredOpen[e.activeRepoId]??!1:!1),Ev=[],G2=()=>L(e=>e.activeRepoId?e.archived[e.activeRepoId]??Ev:Ev),V2=()=>L(e=>e.activeRepoId?e.archivedOpen[e.activeRepoId]??!1:!1),Y2=()=>L(e=>!(e.activeRepoId&&e.committedShut[e.activeRepoId])),Q2=()=>L(e=>!!(e.activeRepoId&&e.turnOpen[e.activeRepoId])),$i=()=>L(ko),Xm=()=>L(Qx),za=()=>L(e=>Pa(e,e.activeRepoId)),f1=e=>L(t=>go(t,e)),Ot=(e,t)=>L(n=>go(n,e)[t]),X2=()=>L(e=>e.overlay),Hd=()=>L(u2),p1=()=>L(Gx),hc=()=>L(d2),mc=()=>L(mo),J2=()=>L(e=>e.newProject),Vs=()=>L(e=>e.touch),eM=()=>L(e=>e.draft),Jm=()=>L(Cl),tM=()=>L(e=>{const t=ms(e,e.activeId),n=t?e.repos.find(r=>r.id===t.repoId):null;return ud(n)?n:null});function nM(e){return e.image?{kind:"image",blob:e.image,sig:`image:${e.image.type}:${e.image.size}`}:e.text&&yx(e.text)?{kind:"text",text:e.text,sig:`text:${e.text}`}:null}function rM(){try{return localStorage.getItem(mt.clipboardOffer)==="1"}catch{return!1}}let hs={access:"none",on:typeof localStorage<"u"&&rM(),offer:null},Mh="";const Lh=new Set;function Wd(e){hs={...hs,...e};for(const t of Lh)t()}async function oM(){let e,t;for(const n of await navigator.clipboard.read()){const r=n.types.find(o=>o.startsWith("image/"));r?e??(e=await n.getType(r)):n.types.includes("text/plain")&&(t??(t=await(await n.getType("text/plain")).text()))}return nM({image:e,text:t})}async function Kd({taken:e=!1,asking:t=!1}={}){if(!hs.on||!(hs.access==="granted"||t&&hs.access==="prompt"))return;let n;try{n=await oM()}catch{return}e&&(Mh=(n==null?void 0:n.sig)??""),Wd({offer:n&&n.sig!==Mh?n:null})}const sM=()=>void Kd();let Sv=!1;function iM(){var e,t;Sv||(Sv=!0,!(!((e=navigator.clipboard)!=null&&e.read)||!((t=navigator.permissions)!=null&&t.query))&&navigator.permissions.query({name:"clipboard-read"}).then(n=>{const r=()=>{Wd({access:n.state,...n.state==="denied"?{offer:null}:{}})};n.onchange=r,r(),window.addEventListener("focus",sM),document.hasFocus()&&Kd()},()=>{}))}function aM(e){return Lh.add(e),iM(),()=>{Lh.delete(e)}}const lM=()=>hs;function cM(e){try{localStorage.setItem(mt.clipboardOffer,e?"1":"0")}catch{}Wd({on:e,offer:null}),e&&Kd({asking:!0})}function h1(){hs.offer&&(Mh=hs.offer.sig),Wd({offer:null})}const uM=()=>void Kd({taken:!0});function dM(){return S.useSyncExternalStore(aM,()=>hs.offer)}const m1="application/x-toyon-source";function _B(e){const t=e.endColumn===1&&e.endLineNumber>e.startLineNumber?e.endLineNumber-1:e.endLineNumber;return{startLine:e.startLineNumber,endLine:t}}function fM(e,t){e.setData(m1,JSON.stringify(t))}const Nv=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1;function pM(e,t){const n=e.getData(m1);if(!n||!t)return null;let r;try{r=JSON.parse(n)}catch{return null}if(!r||r.worktreeId!==t||typeof r.path!="string"||!r.path)return null;const{startLine:o,endLine:a,ref:l}=r;return!Nv(o)||!Nv(a)||a<o?null:{path:r.path,startLine:o,endLine:a,...typeof l=="string"?{ref:l}:{}}}const g1=e=>({left:e.x,top:e.y,right:e.x,bottom:e.y});function hM(e,t){return t.matchWidth===void 0?void 0:Math.max(0,e.right-e.left+t.matchWidth)}const mM=new Set(["top","bottom"]),qp={top:"bottom",bottom:"top",left:"right",right:"left"};function Gp(e,t,n,r,o){const a=n==="top"||n==="left";return o?a?e.end+r-t:e.start-r:a?e.start-r-t:e.end+r}function Tv(e,t,n,r,o){return n==="top"||n==="left"?e>=o:e+t<=r-o}function Vp(e,t,n,r){return n==="center"?e.start+(e.end-e.start)/2-t/2:n==="start"?e.start-r:e.end+r-t}function jv(e,t,n,r,o){return n==="start"?e+t<=r-o:e>=o}const Cv=(e,t,n,r)=>n||!r?e:t,Av=(e,t,n,r)=>Math.max(r,Math.min(e,n-r-t));function gM(e,t,n,r){const{offset:o=0,alignOffset:a=0,cover:l=!1,flip:u="none",margin:c=8}=r,p=mM.has(r.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},h=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=r.side;if(u==="side"||u==="both"){const _=Gp(m.a,m.size,k,o,l),N=Gp(m.a,m.size,qp[k],o,l);k=Cv(k,qp[k],Tv(_,m.size,k,m.limit,c),Tv(N,m.size,qp[k],m.limit,c))}let y=r.align??"center";if((u==="align"||u==="both")&&y!=="center"){const _=y==="start"?"end":"start",N=Vp(h.a,h.size,y,a),j=Vp(h.a,h.size,_,a);y=Cv(y,_,jv(N,h.size,y,h.limit,c),jv(j,h.size,_,h.limit,c))}const v=Av(Gp(m.a,m.size,k,o,l),m.size,m.limit,c),x=Av(Vp(h.a,h.size,y,a),h.size,h.limit,c);return p?{x,y:v,side:k,align:y}:{x:v,y:x,side:k,align:y}}function kM(e,t,n){var a,l;const r=e.length;if(r===0)return-1;let o=t<0?n===1?0:r-1:(t+n+r)%r;for(let u=0;u<r&&((a=e[o])!=null&&a.disabled);u++)o=(o+n+r)%r;return(l=e[o])!=null&&l.disabled?-1:o}const k1={sep:!0},Ni=e=>!("sep"in e);function Zd(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 Dn=e=>Zd(e.flatMap((t,n)=>n?[k1,...t]:t));let da=null,yM=0;const Ph=new Set,Iv=()=>{for(const e of Ph)e()},Zr={get:()=>da,subscribe(e){return Ph.add(e),()=>{Ph.delete(e)}},open(e){const t=Zd(e.items);if(t.length===0)return Zr.close();da={...e,items:t,id:++yM},Iv()},close(){da&&(da=null,Iv())},toggle(e){da&&da.target===e.target?Zr.close():Zr.open(e)}};function y1(){return S.useSyncExternalStore(Zr.subscribe,Zr.get)}function w1(e){const t=e.nativeEvent;return t&&"pointerType"in t?t.pointerType==="":e.clientX===0&&e.clientY===0}function wM(e,t){return w1(e)?{anchor:(t.querySelector('[data-state~="cursor"]')??t).getBoundingClientRect()}:{at:{x:e.clientX,y:e.clientY}}}function vM(e){const t=e.anchor;return t?{rect:t,placement:{side:"bottom",align:e.align==="right"?"end":"start",offset:4,margin:4}}:{rect:g1(e.at??{x:0,y:0}),placement:{side:"bottom",align:"start",margin:4}}}function sn(e){return S.useMemo(()=>({contextMenu(t,n){return{onContextMenu:r=>{const o=Zd(t(w1(r)?"keyboard":"pointer",r.target));if(o.length===0)return;r.preventDefault(),r.stopPropagation();const a=r.currentTarget;Zr.open({items:o,owner:e,key:n,target:a,...wM(r,a)})}}},dropdown(t,n="left"){return{"aria-haspopup":"menu",onClick:r=>{r.stopPropagation();const o=r.currentTarget;Zr.toggle({items:t(),owner:e,target:o,toggles:!0,anchor:o.getBoundingClientRect(),align:n})}}},openUnder(t,n,r){Zr.open({items:n(),owner:e,key:r,target:t,toggles:!0,anchor:t.getBoundingClientRect(),align:"left"})}}),[e])}const v1=e=>({id:"open-out",label:Bd()?"open in the browser":"open in a new tab",onClick:()=>window.open(e,"_blank")}),Zt=e=>{var t;return void((t=navigator.clipboard)==null?void 0:t.writeText(e).catch(()=>{}))};function b1(e,t){const n=navigator.clipboard;if(n){if(typeof ClipboardItem>"u"||!n.write){e==="text/plain"&&t.then(r=>r.text()).then(Zt,()=>{});return}n.write([new ClipboardItem({[e]:t})]).catch(()=>{})}}const bM=e=>b1("text/plain",fetch(e).then(t=>t.blob())),xM=e=>b1("image/png",_M(e));async function _M(e){const t=await(await fetch(e)).blob();if(t.type==="image/png")return t;const n=await createImageBitmap(t);try{const r=document.createElement("canvas");return r.width=n.width,r.height=n.height,r.getContext("2d").drawImage(n,0,0),await new Promise((o,a)=>r.toBlob(l=>l?o(l):a(new Error("could not encode image")),"image/png"))}finally{n.close()}}const EM=[{label:"Zed",scheme:"zed"},{label:"VS Code",scheme:"vscode"},{label:"Cursor",scheme:"cursor"}];function eg(e){return e==="127.0.0.1"||e==="localhost"||e==="[::1]"||e.endsWith(".localhost")}function Ii(e,t,n=location.hostname){if(!eg(n))return[];const r=EM.map(o=>({id:`open:${o.scheme}`,label:`open in ${o.label}`,onClick:()=>{window.location.href=`${o.scheme}://file${e}`}}));return r.push(...qd(t,n)),r}function qd(e,t=location.hostname){return!e||!eg(t)?[]:[{id:"reveal",label:"reveal in Finder",onClick:e}]}function SM(e,t){const n=[];for(const r of t)r.xy.includes("D")?n.push(`-${r.path}`):/[?ARC]/.test(r.xy)&&n.push(`+${r.path}`);return`${e??""}
98
+ ${n.sort().join(`
99
+ `)}`}function Gd(e,t,{sock:n,dispatch:r}){var l,u;if(!n)return;const o=t.local[e]??La,a=SM((l=o.git)==null?void 0:l.head,((u=o.git)==null?void 0:u.files)??[]);o.filesFor!==a&&(r({a:"files-asked",worktreeId:e,key:a}),n.send({t:"list-files",worktreeId:e}))}const NM=["diff","file","preview"],x1=(e,t)=>NM.filter(n=>!(n==="preview"&&!Fd(e))&&!(n==="diff"&&t));let TM=0;const $o=()=>++TM;function nr({dispatch:e},{focus:t=!0,...n}){e({a:"open-file",v:{...n,focus:t,seq:$o()}})}const Dh=new Map;function _1(e,t,n=""){const{sock:r}=e;if(!r)return Promise.resolve("not connected to the daemon");const o=$o();return new Promise(a=>{Dh.set(o,l=>{l.ok?(nr(e,{...t,view:Ai(t.path)}),a(null)):a(l.reason==="changed"?"a file is already there":l.message??"the file was not made")}),r.send({t:"write-file",...t,content:n,base:null,seq:o})})}function jM(e){const t=Dh.get(e.seq);return t?(Dh.delete(e.seq),t(e),!0):!1}function CM({dispatch:e},t){e({a:"tree-reveal",...t})}function fs(e,t,{discard:n=!1,ref:r,since:o,showing:a,added:l=!1,kept:u=!1,select:c},p){const{sock:m,dispatch:h}=p,k=x1(t,l).filter(j=>j!==a).map(j=>({id:`view:${j}`,label:`view ${j}`,onClick:()=>a?h({a:"editor-view",v:j}):nr(p,{worktreeId:e.id,path:t,view:j,ref:r,since:o})})),y=`${e.dir}/${t}`,v=u?[]:Ii(y,()=>m==null?void 0:m.send({t:"reveal",worktreeId:e.id,path:t}));return Dn([k,[{id:"copy-path",label:"copy path",onClick:()=>Zt(y)}],v,c?[{id:"select",label:"select…",onClick:()=>c(t)}]:[],n?[{id:"discard",label:"discard changes…",danger:!0,onClick:()=>{window.confirm(E1([t]))&&(m==null||m.send({t:"discard-files",worktreeId:e.id,paths:[t]}))}}]:[]])}function E1(e){if(e.length===1)return`Discard uncommitted changes to ${e[0]}?`;const t=e.slice(0,12),n=e.length-t.length,r=[...t,...n>0?[`and ${n} more`]:[]].join(`
100
+ `);return`Discard uncommitted changes to ${e.length} files?
101
+
102
+ ${r}`}function Po(){const e=location.hash.match(/token=([a-f0-9]+)/);if(e!=null&&e[1]){try{localStorage.setItem(mt.token,e[1])}catch{}return e[1]}try{return localStorage.getItem(mt.token)??sessionStorage.getItem(mt.token)??""}catch{return""}}function S1(){return Po()!==""}function Gu(e,t){return`/attachments/${e}/${t}?token=${Po()}`}function fd(e){return`/uploads/${e}?token=${Po()}`}async function Rv(e,t){try{await t.slice(0,1).arrayBuffer()}catch{return"could not be read"}try{const n=await fetch(`/uploads?kind=${e}`,{method:"POST",headers:{authorization:`Bearer ${Po()}`,"content-type":t.type||"application/octet-stream"},body:t});return n.status>=502&&n.status<=504?null:n.ok?await n.json():await n.text()||"could not be attached"}catch{return null}}function tg(e,t,n){const r=t.split("/").map(encodeURIComponent).join("/");return`/files/${e}/${r}?token=${Po()}&v=${encodeURIComponent(n??"")}`}function AM(e,t){return`/loose/${encodeURIComponent(e)}?token=${Po()}&v=${encodeURIComponent(t??"")}`}async function IM(e=!1){try{const t=await fetch(`/restart?token=${Po()}${e?`&${FO}`:""}`,{method:"POST"});return t.ok?null:await t.text()||"Toyon did not restart"}catch{return null}}async function N1(){try{const e=await fetch(`/restart?token=${Po()}`,{signal:AbortSignal.timeout(2e3)});if(!e.ok)return null;const{waiting:t,asking:n}=await e.json();return Array.isArray(t)?{waiting:t,asking:Array.isArray(n)?n:[]}:null}catch{return null}}async function RM(){try{const e=await fetch("/pair/phones",{headers:{authorization:`Bearer ${Po()}`}});return e.ok?await e.json():null}catch{return null}}async function OM(){try{const e=await fetch("/pair",{method:"POST",headers:{authorization:`Bearer ${Po()}`}});return e.ok?await e.json():await e.text()||"Toyon did not make a code"}catch{return"Toyon is not answering; try again once it is back."}}async function zh(){try{const e=await fetch("/health",{signal:AbortSignal.timeout(2e3)});return e.ok?(await e.json()).pid??null:null}catch{return null}}const $M=1e3,MM=3e4,LM=1500,Ov=50,PM=e=>e.t==="chat"||e.t==="create-worktree"||e.t==="restore-worktree"||e.t==="batch-worktrees";class DM{constructor(t,n){jt(this,"ws",null);jt(this,"queue",[]);jt(this,"closed",!1);jt(this,"attempt",0);jt(this,"timer",null);jt(this,"downAt",null);jt(this,"downCode",0);jt(this,"sayTimer",null);jt(this,"sentDown",new Set);jt(this,"wake",()=>{var n;if(this.closed||document.visibilityState!=="visible"||((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN)return;this.timer&&clearTimeout(this.timer),this.timer=null,this.attempt=0,this.downAt!==null&&(this.downAt=Date.now(),this.onStatus(!1,null),this.armSay());const t=this.ws;this.connect(),t==null||t.close()});this.onMsg=t,this.onStatus=n,this.connect(),document.addEventListener("visibilitychange",this.wake),window.addEventListener("online",this.wake)}async diagnose(t){if(t===OT)return"unauthorized";try{return(await fetch("/health",{signal:AbortSignal.timeout(2e3)})).ok?"blocked":"down"}catch{return"down"}}say(t){this.downAt??(this.downAt=Date.now()),this.downCode=t,this.armSay()}armSay(){if(this.downAt===null)return;const t=this.downAt,n=()=>!this.closed&&this.downAt===t&&document.visibilityState==="visible";this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=setTimeout(()=>{n()&&this.diagnose(this.downCode).then(r=>{n()&&this.onStatus(!1,r)})},Math.max(0,t+LM-Date.now()))}connect(){if(this.closed)return;const n=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws?token=${Po()}`,r=new WebSocket(n);this.ws=r;let o=!1;r.onmessage=a=>{if(!o){o=!0,this.attempt=0,this.downAt=null,this.sayTimer&&clearTimeout(this.sayTimer),this.sayTimer=null,this.onStatus(!0);for(const l of this.queue)r.send(l.raw);this.queue=[]}try{this.onMsg(JSON.parse(a.data))}catch{}},r.onclose=a=>{if(this.ws!==r||(this.onStatus(!1),this.closed))return;this.say(a.code);const l=Math.min(MM,$M*2**this.attempt++);this.timer=setTimeout(()=>this.connect(),l/2+Math.random()*(l/2))},r.onerror=()=>r.close()}send(t){const n=JSON.stringify(t);if(this.ws&&this.ws.readyState===WebSocket.OPEN){this.ws.send(n);return}if(t.t.startsWith("term-"))return;const r=t.t==="subscribe"||t.t==="unsubscribe"?`sub:${t.worktreeId}`:t.t==="view"?"view":null;r&&(this.queue=this.queue.filter(o=>o.key!==r)),PM(t)&&t.boxId&&this.sentDown.add(t.boxId),this.queue.push({key:r,raw:n}),this.queue.length>Ov&&this.queue.splice(0,this.queue.length-Ov)}sentWhileDown(){const t=[...this.sentDown];return this.sentDown.clear(),t}dispose(){var t;this.closed=!0,this.timer&&clearTimeout(this.timer),this.sayTimer&&clearTimeout(this.sayTimer),document.removeEventListener("visibilitychange",this.wake),window.removeEventListener("online",this.wake),(t=this.ws)==null||t.close()}}const oo=(e,t,n)=>e.dispatch({a:"notice",id:t,text:n});function Vd(e,t,n){var o;const r=pT(((o=e.getState().local[t])==null?void 0:o.attachments)??[],n);return r===0&&oo(e,t,_m(n)),r}const zM=1e3,FM=1e4;async function T1(e,t,n,r){var p;const{local:o,...a}=n;e.dispatch({a:"attach",id:t,items:[{...n,upload:"",uploading:!0}]});const l=()=>{var m;return!!((m=e.getState().local[t])!=null&&m.attachments.some(h=>h.key===n.key))};let u=await Rv(n.kind,r);const c=u===null;c&&oo(e,t,`${n.name}: Toyon is not answering; it attaches once it is back`);for(let m=zM;u===null&&l();m=Math.min(m*2,FM))await new Promise(h=>setTimeout(h,m)),l()&&(u=await Rv(n.kind,r));if(u!==null)if(typeof u=="string")e.dispatch({a:"detach",id:t,key:n.key}),oo(e,t,`${n.name}: ${u}`);else{const m=a.kind==="file"?{...a,...u}:{...a,upload:u.upload,bytes:u.bytes};e.dispatch({a:"attached",id:t,key:n.key,item:m});const h=(p=e.getState().local[t])==null?void 0:p.notice;c&&(h!=null&&h.startsWith(`${n.name}: Toyon is not answering`))&&oo(e,t,"")}o&&URL.revokeObjectURL(o)}function ng(e,t,n){if(!t||n.length===0)return;const r=Vd(e,t,"file");if(r!==0){for(const o of n.slice(0,r)){const a=o.name||"file";if(o.size>qw){oo(e,t,`${a}: larger than ${Em(qw)}`);continue}const l={kind:"file",key:crypto.randomUUID(),upload:"",name:a,bytes:o.size,text:!1};T1(e,t,l,o)}n.length>r&&oo(e,t,`kept ${r} of ${n.length}: ${_m("file")}`)}}function rg(e,t,n,r={}){if(!t)return;const o=TO(r.source?n.replace(/\r?\n$/,""):n);if(o.length>wO)return r.source?oo(e,t,"that paste is too large; save it in the worktree and reference it with @path"):ng(e,t,[new File([o],vO,{type:"text/plain"})]);Vd(e,t,"paste")!==0&&e.dispatch({a:"attach",id:t,items:[{kind:"paste",key:crypto.randomUUID(),text:o,...r,...$m(o)}]})}function j1(e,t,n,r){e.dispatch({a:"set-draft",id:n,text:""}),t==null||t.send({t:"unqueue",worktreeId:n,index:r,edit:!0})}function $v(e,t){var a;const n=e.getState(),r=fn(n,n.activeId),o=pc(r);if(t&&o&&t.worktreeId===(r==null?void 0:r.worktree.id)&&t.text.trim()){const l="source"in t?{source:t.source}:{name:t.name};(((a=n.local[o])==null?void 0:a.attachments)??[]).some(c=>{var y;if(c.kind!=="paste")return!1;if(!("source"in t))return c.name===t.name&&c.text===t.text;const{path:p,startLine:m,endLine:h,ref:k}=t.source;return((y=c.source)==null?void 0:y.path)===p&&c.source.startLine===m&&c.source.endLine===h&&c.source.ref===k})||rg(e,o,t.text,l)}e.dispatch(t?{a:"focus-chat"}:Vx(n))}function Yd(e,t){return t!==e.activeId?null:pc(fn(e,t))}const og=(e,t)=>`@${e}${t?"/":""}`;function sg(e,t,n){var u;const r=e.getState(),o=Yd(r,t);if(!o)return;const a=((u=r.local[o])==null?void 0:u.draft)??"",l=a===""||/\s$/.test(a)?"":" ";e.dispatch({a:"set-draft",id:o,text:`${a}${l}${n}`}),e.dispatch({a:"focus-chat"})}function C1(e,t,n,r){sg(e,t,`${og(n,r)} `)}function BM(e,t,n){n.length!==0&&sg(e,t,`${n.map(r=>og(r,!1)).join(" ")} `)}function Mv(e,t,n){sg(e,t,n)}function UM(e,t){return fn(e,t)?t:null}function HM(e,t){var r;const n=(r=fn(e,t))==null?void 0:r.worktree;return n?[n.path]:[]}function Lv(e,t){if(!e)return e;const n=t.find(r=>e.startsWith(`${r}/`));return n?e.slice(n.length+1):e}function WM(e,t,n){var k;e.dispatch({a:"set-picking",v:!1});const r=e.getState(),o=UM(r,t);if(!o)return;const{classes:a,route:l,element:u,...c}=n,p=HM(r,t),m={...c,file:Lv(c.file,p),callFile:Lv(c.callFile,p)};!(((k=r.local[o])==null?void 0:k.attachments)??[]).some(y=>y.kind==="pick"&&y.selector===m.selector)&&Vd(e,o,"pick")>0&&e.dispatch({a:"attach",id:o,items:[{kind:"pick",key:crypto.randomUUID(),...m}]}),e.dispatch({a:"focus-chat"})}function KM(e,t=[],n=[]){const r={path:"",name:"",kind:"folder",children:[],ignored:!1},o=new Map([["",r]]),a=c=>{const p=o.get(c);if(p)return p;const m=c.lastIndexOf("/"),h={path:c,name:c.slice(m+1),kind:"folder",children:[],ignored:!1};return a(m===-1?"":c.slice(0,m)).children.push(h),o.set(c,h),h},l=(c,p,m=!1)=>{const h=c.lastIndexOf("/");a(h===-1?"":c.slice(0,h)).children.push({path:c,name:c.slice(h+1),kind:p,children:[],ignored:m})};for(const c of e)l(c,"file");for(const c of t)l(c,"submodule");for(const c of n)c.endsWith("/")?l(c.slice(0,-1),"ignored",!0):l(c,"file",!0);const u=c=>{const p=m=>m.kind==="file"?1:0;c.children.sort((m,h)=>p(m)-p(h)||Bx(m.name,h.name));for(const m of c.children)m.kind==="folder"&&u(m)};return u(r),r.children}function ZM(e,t){const n=[],r=(o,a)=>{for(const l of o){const u=l.kind==="folder"&&t(l.path);n.push({path:l.path,name:l.name,depth:a,kind:l.kind,open:u,ignored:l.ignored}),u&&r(l.children,a+1)}};return r(e,0),n}const A1=e=>{const t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)};function qM(e,t){const n=t.trim().replace(/^(\.\/|\/)+/,"");return n===""?{error:"name the file"}:n.endsWith("/")?{error:"name a file: its folders are made with it"}:n.split("/").some(o=>o===""||o==="."||o==="..")?{error:"a plain path, inside the worktree"}:{path:e?`${e}/${n}`:n}}function GM(e){const t=new Map,n=new Set;for(const r of e){const o=r.path.endsWith("/")?r.path.slice(0,-1):r.path;o===r.path?t.set(o,r):n.add(o);for(const a of ld(o))n.add(a)}return{files:t,folders:n}}const I1=new Set(gO),VM=/^image\.[a-z0-9]+$/i,YM=e=>VM.test(e.name),QM=(e,t)=>e===t||e.name===t.name&&e.size===t.size&&e.type===t.type&&e.lastModified===t.lastModified;function XM(e){if(!e)return[];const t=[];for(const a of Array.from(e.items??[])){if(a.kind!=="file"||!a.type.startsWith("image/"))continue;const l=a.getAsFile();l&&t.push(l)}if(t.length===0)for(const a of Array.from(e.files??[]))a.type.startsWith("image/")&&t.push(a);const n=[];for(const a of t)n.some(l=>QM(l,a))||n.push(a);const r=n.filter(a=>!YM(a));if(r.length>0)return r;const o=n.find(a=>I1.has(a.type))??n[0];return o?[o]:[]}function JM(e){if(!e)return[];const t=[];for(const n of Array.from(e.items??[])){if(n.kind!=="file"||n.type.startsWith("image/"))continue;const r=n.getAsFile();r&&t.push(r)}if(t.length===0)for(const n of Array.from(e.files??[]))n.type.startsWith("image/")||t.push(n);return t}async function eL(e,t){if(e.size>t)return null;try{return new TextDecoder("utf-8",{fatal:!0}).decode(await e.arrayBuffer())}catch{return null}}async function tL(e){try{return await createImageBitmap(e)}catch{throw new Error(`${e.name||"image"}: not a readable image`)}}function Pv(e,t,n){const r=document.createElement("canvas");return r.width=Math.max(1,Math.round(e.width*t)),r.height=Math.max(1,Math.round(e.height*t)),r.getContext("2d").drawImage(e,0,0,r.width,r.height),new Promise((o,a)=>r.toBlob(l=>l?o(l):a(new Error("could not encode image")),n,.9))}async function nL(e){const t=await tL(e);try{const n=Math.max(t.width,t.height);let r=e,o=e.type,a=t.width,l=t.height;if(!I1.has(o)||n>Zw||e.size>Hp){const u=o==="image/jpeg"?"image/jpeg":"image/png";let c=Math.min(1,Zw/n);for(r=await Pv(t,c,u);r.size>Hp&&c>.1;)c*=.7,r=await Pv(t,c,u);if(r.size>Hp)throw new Error(`${e.name||"image"}: too large even after downscaling`);o=u,a=Math.max(1,Math.round(t.width*c)),l=Math.max(1,Math.round(t.height*c))}return{blob:r,name:e.name||`pasted.${o==="image/jpeg"?"jpg":"png"}`,mimeType:o,width:a,height:l}}finally{t.close()}}const Hl={el:null},rL=80,oL=2e3;let Xo=null,Fh;const R1=(e,t)=>{clearTimeout(Fh),Fh=setTimeout(()=>ag(e),t)};function ig(e,t){Xo??(Xo={refused:!1}),e.dispatch({a:"drag-files",v:Xo.refused?null:t}),R1(e,oL)}function sL(e){Xo&&R1(e,rL)}function ag(e){clearTimeout(Fh),Xo=null,e.dispatch({a:"drag-files",v:null})}function iL(e){Xo&&(Xo.refused=!0,e.dispatch({a:"drag-files",v:null}))}const O1="application/x-toyon-path";let xi=null;function aL(e){xi=e}function $1(e){xi=null,Xo&&ag(e)}const Dv=e=>xi!==null&&Array.from(e.dataTransfer.types).includes(O1);function lL(e){return{onDragOver:t=>{if(!Dv(t)||!xi)return;t.preventDefault();const n=Yd(e.getState(),xi.worktreeId)!==null;t.dataTransfer.dropEffect=n?"copy":"none",n&&ig(e,{at:"chat"})},onDrop:t=>{if(!Dv(t)||!xi)return;t.preventDefault();const{worktreeId:n,path:r,folder:o}=xi;$1(e),C1(e,n,r,o)}}}let cL=0;function uL(e){const{blob:t,...n}=e;return{kind:"image",key:`img${++cL}`,...n,upload:"",bytes:t.size,local:URL.createObjectURL(t)}}async function Qd(e,t,n){var l;if(!t||n.length===0)return;const r=Vd(e,t,"image");if(r===0)return;const o=await Promise.allSettled(n.slice(0,r).map(nL));for(const u of o)u.status==="fulfilled"&&T1(e,t,uL(u.value),u.value.blob);const a=o.find(u=>u.status==="rejected");a?oo(e,t,String(((l=a.reason)==null?void 0:l.message)??a.reason)):n.length>r&&oo(e,t,`kept ${r} of ${n.length}: ${_m("image")}`)}function dL(e,t,n){n.kind==="image"?Qd(e,t,[new File([n.blob],"image.png",{type:n.blob.type})]):rg(e,t,n.text),h1()}function M1(e,t,n){const r=o=>o.type.startsWith("image/");Qd(e,t,n.filter(r)),ng(e,t,n.filter(o=>!r(o)))}function fL(e,t,{images:n=!1}={}){const r=document.createElement("input");r.type="file",r.multiple=!0,n&&(r.accept="image/*"),r.onchange=()=>M1(e,t,Array.from(r.files??[])),r.click()}function gc(e){const t=e.getState();return pc(fn(t,t.activeId))}function pL(e,t){const n=gc(e);M1(e,n,t.filter(o=>!o.folder).map(o=>o.file));const r=t.find(o=>o.folder);n&&r&&oo(e,n,`${r.file.name}: a folder cannot be attached; drop its files`)}const Bh=Promise.resolve(null);function hL(e){var n,r,o;if(!e)return[];const t=[];for(const a of Array.from(e.items)){if(a.kind!=="file")continue;const l=a.getAsFile();if(!l)continue;const u=((n=a.getAsFileSystemHandle)==null?void 0:n.call(a).then(c=>(c==null?void 0:c.kind)==="file"?c:null,()=>null))??Bh;t.push({file:l,handle:u,folder:((o=(r=a.webkitGetAsEntry)==null?void 0:r.call(a))==null?void 0:o.isDirectory)===!0})}if(t.length===0)for(const a of Array.from(e.files))t.push({file:a,handle:Bh});return t}const mL=e=>e.map(t=>({file:t,handle:Bh}));async function L1(e){const t=id*4;if(e.size>t)return{text:"",tooLarge:!0};const n=await eL(e,t);return n===null?null:n.length>id?{text:"",tooLarge:!0}:{text:n,tooLarge:!1}}async function gL(e,t){const n=gc(e),r=e.getState().activeId,o=m=>n&&oo(e,n,m),a=t.filter(m=>m.file.type.startsWith("image/")).map(m=>m.file);a.length&&Qd(e,n,a);const l=t.filter(m=>!m.file.type.startsWith("image/")),u=l[0];if(!u||!r)return;const c=await L1(u.file);if(!c)return void o(`${u.file.name}: not a text file`);const p=await u.handle;e.dispatch({a:"open-loose",v:{worktreeId:r,name:u.file.name,...c,binary:!1,source:p?{kind:"handle",handle:p}:{kind:"bytes"},seq:$o()}}),l.length>1&&o(`opened ${u.file.name}; one file opens at a time`)}async function kL(e,t,n,r){const o=Yd(e.getState(),n.worktreeId)??gc(e),a=u=>o&&oo(e,o,u),l={sock:t,dispatch:u=>e.dispatch(u)};for(const{file:u}of r){const c=await L1(u);if(!c){a(`${u.name}: not a text file`);continue}if(c.tooLarge){a(`${u.name}: too large to add here`);continue}const p=n.dir?`${n.dir}/${u.name}`:u.name,m=await _1(l,{worktreeId:n.worktreeId,path:p},c.text);m&&a(`${u.name}: ${m}`)}}function yL(e){const t=gc(e);t&&oo(e,t,"drop a file on the chat to attach it, on the preview to open it, or on a folder to add it")}function P1(e,t,n,r){const o=(Xo==null?void 0:Xo.refused)??!1;ag(e),!(o||r.length===0)&&(n?n.at==="chat"?pL(e,r):n.at==="centre"?gL(e,r):kL(e,t,n,r):yL(e))}const zv=e=>!!e&&Array.from(e.types).includes("Files");function Fv(e,t){var a;const n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!n)return null;if((a=Hl.el)!=null&&a.contains(n))return gc(e)?{at:"chat"}:null;const r=n.closest(".tree"),o=r==null?void 0:r.dataset.worktree;if(r&&o){const l=n.closest("[data-path]"),u=l==null?void 0:l.dataset.kind;if(u==="submodule")return null;const c=(l==null?void 0:l.dataset.path)??"";return{at:"tree",worktreeId:o,dir:u==="file"?A1(c):c}}return!n.closest(".center-root")||n.closest('[data-pane="terminal"], [data-pane="design"]')?null:e.getState().activeId?{at:"centre"}:null}function wL(){const e=Bn(),t=it();S.useEffect(()=>{const n=l=>{l.defaultPrevented||!zv(l.dataTransfer)||(l.preventDefault(),ig(e,Fv(e,l.target)),l.dataTransfer&&(l.dataTransfer.dropEffect=e.getState().dragFiles?"copy":"none"))},r=l=>{l.defaultPrevented||!zv(l.dataTransfer)||(l.preventDefault(),P1(e,t,Fv(e,l.target),hL(l.dataTransfer)))},o=()=>sL(e),a=l=>{l.key==="Escape"&&iL(e)};return window.addEventListener("dragover",n),window.addEventListener("drop",r),window.addEventListener("dragleave",o),window.addEventListener("keydown",a,!0),()=>{window.removeEventListener("dragover",n),window.removeEventListener("drop",r),window.removeEventListener("dragleave",o),window.removeEventListener("keydown",a,!0)}},[e,t])}function vL(e,t){const n=Bn(),r=S.useRef(!1);return{onPaste:u=>{uM();const c=XM(u.clipboardData);if(c.length>0)return u.preventDefault(),void Qd(n,e,c);const p=JM(u.clipboardData);if(p.length>0)return u.preventDefault(),ng(n,e,p);if(r.current)return;const m=u.clipboardData.getData("text/plain"),h=m.trim()?pM(u.clipboardData,t):null;!(h&&m.includes(`
103
+ `))&&!yx(m)||(u.preventDefault(),rg(n,e,m,h?{source:h}:{}))},onPasteKey:u=>{r.current=(u.metaKey||u.ctrlKey)&&u.shiftKey&&u.key.toLowerCase()==="v"},onPasteKeyUp:()=>{r.current=!1}}}function He(...e){return e.filter(Boolean).join(" ")}const bL={branch:"M4.5 5.1v5.8 M11.5 6.6c0 2.6-7 1.6-7 4.3 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 3.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",chat:"M2.5 3.5a1.5 1.5 0 0 1 1.5-1.5h8a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H7l-3.2 2.6V11H4a1.5 1.5 0 0 1-1.5-1.5z",settings:"M12.38 6.99 14.05 7.26 14.05 8.74 12.38 9.01 11.82 10.38 12.81 11.76 11.76 12.81 10.38 11.82 9.01 12.38 8.74 14.05 7.26 14.05 6.99 12.38 5.62 11.82 4.24 12.81 3.19 11.76 4.18 10.38 3.62 9.01 1.95 8.74 1.95 7.26 3.62 6.99 4.18 5.62 3.19 4.24 4.24 3.19 5.62 4.18 6.99 3.62 7.26 1.95 8.74 1.95 9.01 3.62 10.38 4.18 11.76 3.19 12.81 4.24 11.82 5.62z M8 6.4a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z",zen:"M2 6V3a1 1 0 0 1 1-1h3 M10 2h3a1 1 0 0 1 1 1v3 M14 10v3a1 1 0 0 1-1 1h-3 M6 14H3a1 1 0 0 1-1-1v-3",back:"M9.5 3.5 5 8l4.5 4.5",forward:"M6.5 3.5 11 8l-4.5 4.5",reload:"M13.5 2.5v3.5H10 M12.4 9.2a4.8 4.8 0 1 1-1-4.9l2.1 1.7",pick:"M8 4.2a3.8 3.8 0 1 0 0 7.6 3.8 3.8 0 1 0 0-7.6z M8 1.5v2.7 M8 11.8v2.7 M1.5 8h2.7 M11.8 8h2.7",inspect:"M6.5 13.5h-3a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v3 M8.2 8.2l5.3 2-2.3.9-.9 2.3z",terminal:"M2 3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z M4.8 5.6 7.4 8l-2.6 2.4 M8.6 10.6h2.8",close:"M4.2 4.2 11.8 11.8 M11.8 4.2 4.2 11.8",edit:"M10.6 2.6 13.4 5.4 5.8 13H3v-2.8z M9.2 4l2.8 2.8 M3 10.2l2.8 2.8",check:"M3.4 8.4 6.4 11.4 12.6 4.6",split:"M2.5 2.5h11v11h-11z M2.5 8h11",full:"M2.5 2.5h11v11h-11z",more:"M3.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M7.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M11.55 8a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",caret:"M4.5 6.5 8 10l3.5-3.5","caret-up":"M4.5 9.5 8 6l3.5 3.5",stop:"M4.5 4.5h7v7h-7z",send:"M8 13V3.2 M4 7.2 8 3.2l4 4",external:"M9 3h4v4 M13 3 8 8 M11.5 9.5V13H3V4.5h3.5",plus:"M8 3.5v9 M3.5 8h9",download:"M8 2.5v7.4 M4.9 6.8 8 9.9l3.1-3.1 M3 13h10",copy:"M5.5 5.5h8v8h-8z M10.5 5.5v-3h-8v8h3",pull:"M8 3.2v7.4 M4.9 7.4 8 10.6l3.1-3.2",layers:"M6 2.5h7.5V10 M2.5 6h8v7.5h-8z",text:"M3.5 3.5h9 M3.5 6.5h9 M3.5 9.5h9 M3.5 12.5h5",file:"M4.5 2.5h4.5l2.5 2.5v8.5h-7z M9 2.5V5h2.5",diff:"M8 2.8v5 M5.5 5.3h5 M5.5 11.2h5",folder:"M2.2 3.9a1 1 0 0 1 1-1h2.9l1.5 1.7h5.2a1 1 0 0 1 1 1v5.9a1 1 0 0 1-1 1H3.2a1 1 0 0 1-1-1z",book:"M8 4.6c-1.2-1-2.7-1.4-4.4-1.3v7.6c1.7-.1 3.2.3 4.4 1.3 1.2-1 2.7-1.4 4.4-1.3V3.3c-1.7-.1-3.2.3-4.4 1.3z M8 4.6v8.6",trash:"M3.6 4.6h8.8 M6.4 4.6V3.2a.7.7 0 0 1 .7-.7h1.8a.7.7 0 0 1 .7.7v1.4 M5 4.6l.55 8.1a.9.9 0 0 0 .9.84h3.1a.9.9 0 0 0 .9-.84L11 4.6",move:"M2.8 8h9.2 M8.9 4.9 12 8l-3.1 3.1",search:"M7.2 2.6a4.6 4.6 0 1 0 0 9.2 4.6 4.6 0 1 0 0-9.2z M10.5 10.5 13.5 13.5",run:"M3.4 4.2 7.6 8l-4.2 3.8 M9 11.8h4",bulb:"M4.8 8.8a4 4 0 1 1 6.4 0L9.5 10.6v1.4H6.5v-1.4z M6.7 13.8h2.6",spawn:"M2.5 8h3.3 M5.8 8c2.2 0 2.2-3.6 4.4-3.6h1.5 M5.8 8c2.2 0 2.2 3.6 4.4 3.6h1.5 M12.05 4.4a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z M12.05 11.6a.45 .45 0 1 0 .9 0a.45 .45 0 1 0-.9 0z",globe:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M2.2 8h11.6 M8 2.2c-3 3.4-3 8.2 0 11.6 3-3.4 3-8.2 0-11.6z",worktrees:"M3.8 2.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 4h5.4 M3.8 6.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 8h5.4 M3.8 10.95a1.05 1.05 0 1 0 0 2.1 1.05 1.05 0 1 0 0-2.1z M7.4 12h5.4",swap:"M3 6.2h9.2 M9.7 3.7 12.2 6.2 9.7 8.7 M13 10.2H3.8 M6.3 7.7 3.8 10.2l2.5 2.5",palette:"M2.3 8.4C2.3 4.7 5 2.2 8.5 2.2c3.4 0 5.2 2.2 5.2 4.6 0 1.9-1.4 2.6-2.7 2.8-.9.15-1.3.7-1.1 1.4.2.9-.5 2.2-2.1 2.2-3.2 0-5.5-2-5.5-4.8z M5 6.2a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M7.8 4.9a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z M11 5.8a.5.5 0 1 0 0 1 .5.5 0 1 0 0-1z",lock:"M4.4 7.3h7.2v6.1H4.4z M6.2 7.3V5.5a1.8 1.8 0 0 1 3.6 0v1.8",phone:"M5.4 2.2h5.2a1.2 1.2 0 0 1 1.2 1.2v9.2a1.2 1.2 0 0 1-1.2 1.2H5.4a1.2 1.2 0 0 1-1.2-1.2V3.4a1.2 1.2 0 0 1 1.2-1.2z M7.1 11.6h1.8",pr:"M4.5 5.1v5.8 M4.5 1.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M4.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9a1.6 1.6 0 1 0 0 3.2 1.6 1.6 0 1 0 0-3.2z M11.5 10.9V6.6a2 2 0 0 0-2-2H8 M9.6 2.9 7.9 4.6l1.7 1.7",clock:"M8 2.2a5.8 5.8 0 1 0 0 11.6 5.8 5.8 0 1 0 0-11.6z M8 4.8V8l2.2 1.4",archive:"M2.4 3.2h11.2v2.8H2.4z M3.4 6v6.1a.9.9 0 0 0 .9.9h7.4a.9.9 0 0 0 .9-.9V6 M6.6 8.6h2.8",attach:"M13.7 7.4 8.2 12.9a3.6 3.6 0 0 1-5.1-5.1l5.5-5.5a2.4 2.4 0 0 1 3.4 3.4l-5.5 5.5a1.2 1.2 0 0 1-1.7-1.7l5.1-5.1",dot:"M8 4.6a3.4 3.4 0 1 0 0 6.8 3.4 3.4 0 1 0 0-6.8z"};function St({name:e,className:t}){return f.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:f.jsx("path",{d:bL[e]})})}function kc({size:e="inline",variant:t="ring",className:n}){return f.jsx("span",{className:He("spinner",e==="dot"&&"spinner-dot",t==="squares"&&"spinner-squares",n),"aria-hidden":"true"})}const xL='button, a[href], input, textarea, select, summary, label, [role="button"], [role="menuitem"]';function Bv(e){var n;const t=e;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,xL))??t??null}function _L(e,t){var r,o,a;if(e.box.contains(t)||(r=e.trigger)!=null&&r.contains(t))return!0;const n=(a=(o=t.closest)==null?void 0:o.call(t,"[aria-controls]"))==null?void 0:a.getAttribute("aria-controls");return!!n&&n===e.box.id}function EL(e,t){if(!t)return null;for(let n=e.length-1;n>=0;n--){const r=e[n];if(r!=null&&r.box.contains(t))return r}return null}function SL(e,t){const n=new Set;for(const r of e)if(_L(r,t))for(let o=r;o;o=o.parent)n.add(o);return e.filter(r=>!n.has(r)&&r.dismiss).reverse()}const NL=e=>{setTimeout(e,0)};function TL({schedule:e=NL}={}){let t=[],n=null,r=!1;const o=new Set,a=()=>{for(const u of[...o])u()},l=u=>{var c;for(const p of[...t].reverse())(c=p.dismiss)==null||c.call(p,u)};return{register(u){const c=u.trigger??(u.from===void 0?n:null),p={box:u.box,trigger:c,parent:EL(t,u.from??c),dismiss:u.dismiss,onKey:u.onKey,back:u.back};return t=[...t,p],a(),p},unregister(u){t=t.filter(c=>c!==u),a()},top:()=>t[t.length-1]??null,open:()=>t,watch(u){return o.add(u),()=>o.delete(u)},shut(u){var c;u.back?u.back():(c=u.dismiss)==null||c.call(u,"outside")},install(u){const c=u.document,p=x=>{var j;const _=x.target,N=_?SL(t,_):[];for(const E of N)(j=E.dismiss)==null||j.call(E,"outside");r=N.length>0&&x.pointerType==="touch",r&&x.preventDefault(),n=Bv(x.target)},m=()=>e(()=>n=null),h=()=>{r=!1,m()},k=x=>{if(r){r=!1,x.preventDefault(),x.stopPropagation();return}n||(n=Bv(x.target),m())},y=x=>{var N;const _=t[t.length-1];(N=_==null?void 0:_.onKey)==null||N.call(_,x)},v=()=>e(()=>{var x;((x=c.activeElement)==null?void 0:x.tagName)==="IFRAME"&&l("frame")});return c.addEventListener("pointerdown",p,!0),c.addEventListener("pointerup",m,!0),c.addEventListener("pointercancel",h,!0),c.addEventListener("click",k,!0),u.addEventListener("keydown",y,!0),u.addEventListener("blur",v),()=>{c.removeEventListener("pointerdown",p,!0),c.removeEventListener("pointerup",m,!0),c.removeEventListener("pointercancel",h,!0),c.removeEventListener("click",k,!0),u.removeEventListener("keydown",y,!0),u.removeEventListener("blur",v)}}}}const pd=TL(),Yp=typeof HTMLElement<"u"&&"showPopover"in HTMLElement.prototype,Uv=e=>(e==null?void 0:e.getBoundingClientRect())??null;function jL(e,t,n,r){const o=e.querySelector(t);if(!o)return null;const a=e.getBoundingClientRect(),l=o.getBoundingClientRect();return{offset:n==="top"?a.bottom-l.bottom:l.top-a.top,alignOffset:r==="end"?a.right-l.right:l.left-a.left}}function Ys({className:e,anchor:t,placement:n,coverBy:r,track:o=t==="parent",raiseKey:a,onDismiss:l,onKey:u,onBack:c,trigger:p,from:m,boxRef:h,handle:k,children:y,...v}){const x=S.useRef(null),_=S.useRef({anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:u,onBack:c,trigger:p,from:m});_.current={anchor:t,placement:n,coverBy:r,onDismiss:l,onKey:u,onBack:c,trigger:p,from:m};const N=S.useCallback(()=>{const E=x.current,{anchor:M,placement:K,coverBy:U}=_.current;if(!E||!M||!K)return;const R=M==="parent"?Uv(E.parentElement):M();if(!R)return;const I=hM(R,K);I!==void 0&&(E.style.width=`${I}px`);for(let C=0;C<2;C++){const P=U?jL(E,U,E.dataset.side??"",E.dataset.align??""):null,z=gM(R,{w:E.offsetWidth,h:E.offsetHeight},{w:window.innerWidth,h:window.innerHeight},P?{...K,...P}:K);E.style.left=`${z.x}px`,E.style.top=`${z.y}px`;const q=E.dataset.side!==z.side||E.dataset.align!==z.align;if(E.dataset.side=z.side,E.dataset.align=z.align,!q)break}},[]);S.useImperativeHandle(k,()=>({update:N}),[N]),S.useLayoutEffect(()=>{const E=x.current;if(!E)return;h&&(h.current=E),Yp&&(E.popover="manual",E.matches(":popover-open")||E.showPopover());const{onDismiss:M,onKey:K,onBack:U,trigger:R,from:I}=_.current,C=M||K?pd.register({box:E,trigger:R,from:I,dismiss:M?P=>{var z,q;return(q=(z=_.current).onDismiss)==null?void 0:q.call(z,P)}:void 0,onKey:K?P=>{var z,q;return(q=(z=_.current).onKey)==null?void 0:q.call(z,P)}:void 0,back:U?()=>{var P,z;return(z=(P=_.current).onBack)==null?void 0:z.call(P)}:void 0}):null;return()=>{C&&pd.unregister(C),h&&(h.current=null),Yp&&E.isConnected&&E.matches(":popover-open")&&E.hidePopover()}},[h]),S.useLayoutEffect(N),S.useLayoutEffect(()=>{if(!o)return;let E=0,M="";const K=()=>{const U=x.current,{anchor:R}=_.current,I=U&&R?R==="parent"?Uv(U.parentElement):R():null;if(U&&I){const C=`${I.left},${I.top},${I.right},${I.bottom},${U.offsetWidth},${U.offsetHeight},${window.innerWidth},${window.innerHeight}`;C!==M&&(M=C,N())}E=requestAnimationFrame(K)};return E=requestAnimationFrame(K),()=>cancelAnimationFrame(E)},[o,N]);const j=S.useRef(!0);return gt([a],()=>{if(j.current){j.current=!1;return}const E=x.current;!Yp||!(E!=null&&E.matches(":popover-open"))||(E.hidePopover(),E.showPopover(),N())}),f.jsx("div",{ref:x,className:He("float",e),...v,children:y})}const CL=/^[⌘⇧⌥⌃]+/;function Or({k:e,chip:t=!1,className:n}){var l;const r=(l=e.match(CL))==null?void 0:l[0],o=r?e.slice(r.length):e,a=["kbd",t?"kbd-chip":"",n??""].filter(Boolean).join(" ");return f.jsxs("kbd",{className:a,children:[r&&f.jsx("span",{className:"kbd-mod",children:r}),o]})}function $t(e,t,{placement:n,detail:r,card:o,dot:a,name:l,aside:u,also:c}={}){const p=l?`${e}: ${l}`:e,m=(Array.isArray(r)?r:[r]).filter(k=>!!k),h=[p,...m,...u??[]].join(", ");return{"data-tip":e,"data-tip-key":t,"data-tip-placement":n,"data-tip-detail":m.length?m.join(`
104
+ `):void 0,"data-tip-card":o||l||u!=null&&u.length?"":void 0,"data-tip-dot":a,"data-tip-name":l,"data-tip-aside":u!=null&&u.length?u.join(`
105
+ `):void 0,"data-tip-also":c==null?void 0:c.text,"data-tip-also-key":c==null?void 0:c.key,"aria-label":t?`${h} (${t})`:h}}const AL=120,IL=600,RL=150,Hv=6,OL=18,Qp=8;function Wv(e){const t=e.dataset.tipPlacement;return t==="follow"||t==="top"||t==="bottom"||t==="left"||t==="right"?t:"bottom"}function $L(e){return e==="follow"?{side:"bottom",align:"start",offset:OL,alignOffset:-12,flip:"both",margin:Qp}:e==="left"||e==="right"?{side:e,align:"start",offset:Hv,flip:"both",margin:Qp}:{side:e,align:"center",offset:Hv,flip:"side",margin:Qp}}function ML(e,t){return e.placement==="follow"?g1(t):e.el.getBoundingClientRect()}function D1(){var c;const[e,t]=S.useState(null),n=S.useRef(null),r=S.useRef(null),o=S.useRef({x:0,y:0}),a=Vs();if(S.useEffect(()=>{if(a)return;let p=0,m=0,h=null,k=!1,y=0;const v=()=>{window.clearTimeout(p),window.clearTimeout(m)},x=()=>{v(),k&&(y=Date.now()),k=!1,h=null,t(null)},_=(I,C)=>{var z,q;const P=I.dataset.tip;if(!P)return x();v(),k=!0,t({el:I,text:P,key:I.dataset.tipKey,detail:(z=I.dataset.tipDetail)==null?void 0:z.split(`
106
+ `),card:I.dataset.tipCard!==void 0,dot:I.dataset.tipDot,name:I.dataset.tipName,aside:(q=I.dataset.tipAside)==null?void 0:q.split(`
107
+ `),also:I.dataset.tipAlso&&I.dataset.tipAlsoKey?{text:I.dataset.tipAlso,key:I.dataset.tipAlsoKey}:void 0,placement:C})},N=I=>{const C=I.target;return C instanceof Element?C.closest("[data-tip]"):null},j=I=>{o.current={x:I.clientX,y:I.clientY};const C=N(I);if(C===h)return;if(v(),h=C,!C){k&&(m=window.setTimeout(x,RL));return}const P=Wv(C);if(k||Date.now()-y<IL)return _(C,P);p=window.setTimeout(()=>_(C,P),AL)},E=I=>{I.relatedTarget||x()},M=I=>{const C=N(I);if(C!=null&&C.matches(":focus-visible")){v(),h=C;const P=Wv(C);_(C,P==="follow"?"bottom":P)}},K=()=>x(),U=I=>{I.key!=="Shift"&&I.key!=="Control"&&I.key!=="Alt"&&I.key!=="Meta"&&x()},R=I=>{h&&I.target instanceof Node&&I.target.contains(h)&&x()};return document.addEventListener("mouseover",j),document.addEventListener("mouseout",E),document.addEventListener("mousedown",x),document.addEventListener("keydown",U),document.addEventListener("scroll",R,!0),document.addEventListener("focusin",M),document.addEventListener("focusout",K),window.addEventListener("blur",x),()=>{v(),document.removeEventListener("mouseover",j),document.removeEventListener("mouseout",E),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",U),document.removeEventListener("scroll",R,!0),document.removeEventListener("focusin",M),document.removeEventListener("focusout",K),window.removeEventListener("blur",x)}},[a]),S.useLayoutEffect(()=>{e&&!e.el.isConnected&&t(null)},[e]),S.useEffect(()=>{if((e==null?void 0:e.placement)!=="follow")return;const p=m=>{var h;o.current={x:m.clientX,y:m.clientY},(h=r.current)==null||h.update()};return document.addEventListener("mousemove",p),()=>document.removeEventListener("mousemove",p)},[e]),!e)return null;const l=f.jsxs(f.Fragment,{children:[e.dot==="spinner"?f.jsx(kc,{size:"dot",className:"tooltip-dot"}):e.dot&&f.jsx("span",{className:`dot ${e.dot} tooltip-dot`}),e.text]}),u=f.jsxs(f.Fragment,{children:[l,e.key&&f.jsx(Or,{k:e.key,className:"tooltip-key"})]});return f.jsxs(Ys,{className:He("tooltip",e.card&&"tooltip-card"),role:"tooltip",boxRef:n,handle:r,anchor:()=>ML(e,o.current),placement:$L(e.placement),track:!1,raiseKey:e,children:[e.also?f.jsxs("div",{className:"tooltip-pair",children:[f.jsx("span",{children:l}),e.key?f.jsx(Or,{k:e.key,className:"tooltip-key"}):f.jsx("span",{}),f.jsx("span",{className:"tooltip-also",children:e.also.text}),f.jsx(Or,{k:e.also.key,className:"tooltip-key"})]}):e.name?f.jsxs("div",{className:"tooltip-head",children:[f.jsx("span",{children:u}),f.jsx("span",{className:"tooltip-name",children:e.name})]}):u,(c=e.detail)==null?void 0:c.map(p=>f.jsx("div",{className:"tooltip-detail",children:p},p)),e.aside&&f.jsx("div",{className:"tooltip-foot",children:e.aside.map(p=>f.jsx("span",{children:p},p))})]})}const LL={sm:"",md:"btn-md",lg:"btn-lg"},PL={ghost:"",outline:"btn-outline",field:"btn-outline btn-field",inline:"btn-inline"},z1={primary:"tone-primary",quiet:"tone-quiet",danger:"tone-danger",strong:"tone-strong",chrome:"tone-chrome"};function ze({variant:e="ghost",size:t="sm",tone:n,on:r,mono:o,busy:a,className:l,type:u="button",disabled:c,children:p,...m}){const h=He("btn",PL[e],LL[t],n&&z1[n],r&&"on",o&&"btn-mono",a&&"btn-busy",l);return f.jsxs("button",{className:h,type:u,disabled:a||c,"aria-busy":a||void 0,...m,children:[a&&f.jsx(kc,{}),p]})}function At({icon:e,label:t,hint:n,detail:r,also:o,badge:a,tone:l,on:u,className:c,type:p="button",...m}){const h=He("btn-icon",l&&z1[l],u&&"on",c);return f.jsxs("button",{className:h,type:p,...$t(t,n,{detail:r,also:o}),...m,children:[typeof e=="string"?f.jsx(St,{name:e}):e,a]})}function Fa(e,t,n){return n===0?0:(e+t+n)%n}function Kv(e,t,n){return e>=0?Fa(e,t,n):n===0?-1:t>0?0:n-1}function F1(e,t,n){var a;const r=e.length,o=n.toLowerCase();for(let l=1;l<=r;l++){const u=(Math.max(t,-1)+l)%r;if((a=e[u])!=null&&a.trim().toLowerCase().startsWith(o))return u}return-1}function Xp(e,t){return e&&e.length>t.length&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length):null}function DL(e,t){if(e==null)return null;if(typeof e=="string"){const o=Xp(e,t);return o?{text:o,accept:o,params:[]}:null}const n=Xp(e.show,t);if(!n)return null;const r=(e.params??[]).map(([o,a])=>[Math.max(o,t.length)-t.length,a-t.length]).filter(([o,a])=>a>o);return{text:n,accept:Xp(e.accept,t),params:r}}function B1(e){const{results:t,keyOf:n,q:r,onPick:o,listRef:a,onActive:l,onSide:u,completionOf:c,narrowTo:p,setQ:m,tabPicks:h,onIdlePick:k}=e,[y,v]=S.useState(()=>{var U;return e.idle?-1:Math.max(0,((U=e.initialIndex)==null?void 0:U.call(e,t))??0)}),x=y>=0&&t[y]?n(t[y]):null,_=S.useRef(l);_.current=l,gt([x],()=>{var U,R,I;(R=(U=a.current)==null?void 0:U.querySelector('.picker-item[data-state~="cursor"]'))==null||R.scrollIntoView({block:"nearest"}),(I=_.current)==null||I.call(_,y>=0?t[y]??null:null)});const N=y<0?-1:Math.min(y,Math.max(0,t.length-1)),j=N>=0?t[N]??null:null,E=j?DL(c==null?void 0:c(j,r),r):null,M=U=>{const R=p==null?void 0:p(U,r);if(R==null)return o(U,r);m==null||m(R),v(0)};return{index:N,active:j,ghost:E,setIndex:v,pick:M,onKeyDown:U=>{if(U.key==="ArrowDown")U.preventDefault(),v(Kv(N,1,t.length));else if(U.key==="ArrowUp")U.preventDefault(),v(Kv(N,-1,t.length));else if((U.key==="ArrowLeft"||U.key==="ArrowRight")&&u&&j)U.preventDefault(),u(j,U.key==="ArrowLeft"?-1:1);else if(U.key==="Tab"&&(E!=null&&E.accept))U.preventDefault(),m==null||m(r+E.accept),v(0);else if(U.key==="Tab"&&h&&j)U.preventDefault(),M(j);else if(U.key==="Enter"&&j)U.preventDefault(),M(j);else if(U.key==="Enter"&&N<0&&k)U.preventDefault(),k(r);else return!1;return!0}}}function rr(e){const t=Object.keys(e).filter(n=>e[n]);return t.length>0?t.join(" "):void 0}const zL=new Set(["Shift","Meta","Control","Alt","CapsLock","Fn"]);function U1(){const e=y1(),t=Bn();return S.useEffect(()=>{if(!e)return;const n=()=>{e.target.isConnected||Zr.close()},r=new MutationObserver(n);r.observe(document.body,{childList:!0,subtree:!0});const o=t.subscribe(n);return()=>{r.disconnect(),o()}},[e,t]),e?f.jsx(FL,{spec:e},e.id):null}function FL({spec:e}){const t=e.items,n=t.filter(Ni),[r,o]=S.useState(-1),a=S.useRef({idx:r,items:n});a.current={idx:r,items:n};const l=S.useRef(null),u=h=>{var k,y;{const v=()=>Zr.close(),{idx:x,items:_}=a.current;if(zL.has(h.key))return;if(h.key==="ArrowDown"||h.key==="ArrowUp"){h.preventDefault(),h.stopPropagation();const N=h.key==="ArrowDown"?1:-1;o(kM(_,x,N));return}if((h.key==="Enter"||h.key===" ")&&x>=0&&_[x]&&!_[x].disabled){h.preventDefault(),h.stopPropagation(),_[x].onClick(),v();return}if(h.key==="Escape"){h.stopPropagation(),v();return}if(h.key.length===1&&!h.metaKey&&!h.ctrlKey&&!h.altKey){h.preventDefault(),h.stopPropagation();const N=Array.from(((k=l.current)==null?void 0:k.querySelectorAll(".menu-label"))??[],E=>E.textContent??""),j=F1(N,x,h.key);j>=0&&!((y=_[j])!=null&&y.disabled)&&o(j);return}v()}};S.useEffect(()=>{const h=()=>Zr.close();return window.addEventListener("blur",h),window.addEventListener("resize",h),document.addEventListener("scroll",h,!0),()=>{window.removeEventListener("blur",h),window.removeEventListener("resize",h),document.removeEventListener("scroll",h,!0)}},[]);const{rect:c,placement:p}=vM(e),m=n.some(h=>h.checked);return f.jsx(Ys,{className:"menu",role:"menu",boxRef:l,anchor:()=>c,placement:p,track:!1,from:e.target,trigger:e.toggles?e.target:null,onDismiss:()=>Zr.close(),onKey:u,onContextMenu:h=>h.preventDefault(),children:t.map((h,k)=>{if(!Ni(h))return f.jsx("hr",{className:"menu-sep"},`sep-${k}`);const y=n.indexOf(h);return f.jsx(BL,{item:h,gutter:m,cursor:y===r,onEnter:()=>o(y)},h.id)})})}function BL({item:e,gutter:t,cursor:n,onEnter:r}){const o=e.disabled!==void 0,a=e.detail??e.disabled;return f.jsxs("button",{...e.checked===void 0?{role:"menuitem"}:{role:"menuitemcheckbox","aria-checked":e.checked},"aria-disabled":o||void 0,className:He("row row-keyed",e.danger&&"danger",a!==void 0&&"row-tall",o&&"disabled"),"data-state":rr({cursor:n,checked:e.checked}),onMouseMove:o||n?void 0:r,onClick:()=>{o||(e.onClick(),Zr.close())},children:[t&&f.jsx("span",{className:"menu-check",children:e.checked&&f.jsx(St,{name:"check",className:"icon-inline"})}),f.jsxs("span",{className:"menu-text",children:[f.jsx("span",{className:"menu-label",children:e.label}),a!==void 0&&f.jsx("span",{className:"menu-detail row-dim",children:a})]}),e.key&&f.jsx(Or,{k:e.key,className:"menu-key row-dim"})]})}function Xd({items:e,current:t,onPick:n,fill:r,font:o,segmented:a,quiet:l,end:u,label:c,owner:p}){const m=sn(p),h=S.useRef(null),k=Math.max(0,e.findIndex(v=>v.id===t)),y=v=>{var N,j;if(v.key!=="ArrowLeft"&&v.key!=="ArrowRight")return;v.preventDefault();const x=e.findIndex(E=>E.id===t),_=e[Fa(x,v.key==="ArrowRight"?1:-1,e.length)];_&&(n(_.id),(j=(N=h.current)==null?void 0:N.querySelectorAll('[role="tab"]')[e.indexOf(_)])==null||j.focus())};return f.jsxs("div",{className:He("tabs",r&&"tabs-fill",o==="mono"&&"tabs-mono",a&&"tabs-segmented",l&&"tabs-quiet"),children:[f.jsx("div",{className:"tabs-list",role:"tablist","aria-label":c,ref:h,onKeyDown:y,style:a?{"--tabs-at":k,"--tabs-count":e.length}:void 0,children:e.map(v=>{const x=v.id===t;return f.jsxs("div",{className:He("tab",x&&!!v.trail&&"tab-trailed",v.fit&&"tab-fit",v.far&&"tab-far"),"data-state":rr({current:x}),...v.menu?m.contextMenu(v.menu):{},children:[f.jsxs("button",{type:"button",className:"tab-btn",role:"tab","aria-selected":x,tabIndex:x?0:-1,onClick:()=>n(v.id),...v.tip,...v.ariaLabel?{"aria-label":v.ariaLabel}:{},children:[v.lead,v.label]}),x&&v.trail&&f.jsx("span",{className:"tab-trail",children:v.trail})]},v.id)})}),u&&f.jsx("span",{className:"tabs-end",children:u})]})}function Qs({anchor:e="top",wide:t,children:n}){return f.jsx("div",{className:He("view",e==="line"&&"view-anchored",t&&"view-wide"),children:n})}const Zv={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"},UL="no access token for this address.\non a phone, run `toyon pair` on the machine and scan the code: it works once and lasts 2 minutes.\notherwise run `toyon` in your repo, or open the full URL\n(with #token=…) printed in ~/.toyon/daemon.log";function H1(e){return!e.connected&&(!e.heard||e.connectFailure)?e.hasToken?Zv[e.connectFailure??"probing"]??Zv.probing:UL:e.title===null?e.heard?`nothing open yet.
108
+ press ${e.projectChord} to open a project, or type a name there to start a new one`:"":null}function HL(e){const t=H1(e);return t!==null?t:e.needsSetup&&e.busy?`building in ${e.title}; the preview appears once it starts`:e.needsSetup&&e.treeEmpty?`${e.title} is empty so far; say what to build`:e.treeEmpty&&e.landsFrom?`nothing runs on main until ${e.landsFrom} lands`:null}const Yt={post:(e,t)=>{},broadcast:e=>{}};function tc(e,t,n,r){const o=t===r;Yt.post(e,o?{type:"pick-cancel"}:{type:"pick-start",verb:r}),n({a:"set-picking",v:o?!1:r})}function W1(e){return[{id:"copy-sha",label:`copy ${e.short}`,onClick:()=>Zt(e.sha)},{id:"copy-subject",label:"copy subject",onClick:()=>Zt(e.subject)}]}function Jd(e,t,n){var o,a;const r=e[t];if(!r)return null;if(n==="ArrowRight")return r.open===void 0?null:r.open?(((o=e[t+1])==null?void 0:o.depth)??-1)>r.depth?{do:"to",at:t+1}:null:{do:"open",at:t};if(r.open)return{do:"close",at:t};for(let l=t-1;l>=0;l--)if((((a=e[l])==null?void 0:a.depth)??0)<r.depth)return{do:"to",at:l};return null}function ef(e){return e!=null&&e.config.profiles?Object.keys(e.config.profiles):[]}function K1(e,t){const n=ef(t);if(n.length!==0)return e.profile&&n.includes(e.profile)?e.profile:t==null?void 0:t.config.defaultProfile}const WL=e=>Ju(_i((e==null?void 0:e.config)??{}),e==null?void 0:e.defaultBranch).toLowerCase();function Hs(e,t,n){t({a:"shipping",id:n.worktreeId,op:n.t}),e==null||e.send(n)}const Z1=e=>e.dirty===void 0||e.ahead===void 0||e.dirty>0||e.ahead>0;function Ti(e,t,n){if(n.length!==0){t({a:"archive-worktrees",ids:n});for(const r of n)e==null||e.send({t:"archive-worktree",worktreeId:r})}}function q1(e,t,n){t({a:"hold-unread",id:n}),e==null||e.send({t:"mark-unread",worktreeId:n})}function lg(e,t){return{rename(n){if(!xb(n.worktree))return;const r=window.prompt("Rename worktree (its branch follows as a slug):",n.worktree.title);r!=null&&r.trim()&&(e==null||e.send({t:"rename-worktree",worktreeId:n.worktree.id,title:r.trim()}))},pickVariant(n){const r=n.worktree.variant;if(!r)return;const o=r.of-1;window.confirm(`Keep "${n.worktree.title}" and archive ${o} sibling variant(s)? Their directories and branches go; their chats and changes are kept.`)&&(e==null||e.send({t:"pick-variant",worktreeId:n.worktree.id}))},setProfile(n,r){e==null||e.send({t:"set-worktree-profile",worktreeId:n.worktree.id,profile:r})},ownProcs(n){e==null||e.send({t:"own-procs",worktreeId:n.worktree.id})},shareProcs(n){const r=(n.worktree.owns??[]).join(", ");window.confirm(`Stop this worktree's own ${r} and use main's?
109
+
110
+ What they hold that main's do not (a database of their own) is not carried over.`)&&(e==null||e.send({t:"share-procs",worktreeId:n.worktree.id}))},archive(n){if(!xm(n.worktree))return;if(!Z1(n))return Ti(e,t,[n.worktree.id]);window.confirm(`Archive worktree "${n.worktree.title}"?
111
+
112
+ Its directory and branch (${n.worktree.branch}) go. The chat, the commits and any uncommitted changes are kept, and the project menu can restore it.`)&&Ti(e,t,[n.worktree.id])}}}function G1(e,t,n,{sock:r,dispatch:o},a){var K,U;const l=e.worktree.id,u=lg(r,o),c=[],p=[],m=[],h=[],k=[],y=[],v=[];fc(e)&&c.push({id:"stop",label:"stop agent",onClick:()=>r==null?void 0:r.send({t:"stop-agent",worktreeId:l})});const x=!n.shipping[l],_=n.frame==="phone";((e.dirty??0)>0||(e.ahead??0)>0||!_&&!n.layout.changes)&&p.push({id:"changes",label:`view changes${(e.dirty??0)>0?` (${e.dirty})`:""}`,onClick:()=>{o({a:"activate",id:l}),_?o({a:"screen",to:"changes"}):n.layout.changes||o({a:"toggle-changes"})}}),_||p.push({id:"terminal",label:"open terminal",onClick:()=>{o({a:"activate",id:l}),o({a:"focus-terminal"})}}),p.push(...qd(()=>r==null?void 0:r.send({t:"reveal",worktreeId:l}),a.hostname)),_||m.push({id:"copy-path",label:"copy path",onClick:()=>Zt(e.path)}),m.push({id:"copy-branch",label:"copy branch name",onClick:()=>Zt(e.worktree.branch)});const{transcript:N,sessionId:j}=e;!_&&N&&!Cr(e.worktree)&&m.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Zt(N)}),!_&&j&&m.push({id:"copy-session",label:"copy session id",onClick:()=>Zt(j)});const E=K1(e.worktree,t);for(const R of uc(e.worktree)?[]:ef(t))h.push({id:`profile:${R}`,label:`run with ${R}`,checked:R===E,onClick:()=>u.setProfile(e,R)});if(!ji(e.worktree)&&((K=e.borrowed)!=null&&K.length)&&h.push({id:"own-procs",label:`run ${e.borrowed.join(", ")} here`,detail:"on main now",onClick:()=>u.ownProcs(e)}),!ji(e.worktree)&&((U=e.worktree.owns)!=null&&U.length)&&h.push({id:"share-procs",label:`use main's ${e.worktree.owns.join(", ")}…`,detail:"runs here now",danger:!0,onClick:()=>u.shareProcs(e)}),xb(e.worktree)&&k.push({id:"rename",label:"rename…",onClick:()=>u.rename(e)}),e.worktree.variant&&k.push({id:"keep",label:"keep this variant…",onClick:()=>u.pickVariant(e)}),a.graft&&Wu(e.worktree)){const R=a.graft;k.push({id:"graft",label:"graft with…",onClick:()=>R(l)})}k.push({id:"unread",label:"mark as unread",key:Et("mark-unread"),disabled:e.unseen?"already unread":void 0,onClick:()=>q1(r,o,l)});const M=x?void 0:"waiting on the one in progress";return jd(e)&&(e.behind??0)>0&&y.push({id:"sync",label:`sync from main (${e.behind} behind)`,disabled:M,onClick:()=>Hs(r,o,{t:"sync-main",worktreeId:l})}),bi(e.worktree)&&y.push({id:"land",label:"land",detail:WL(t),disabled:M,onClick:()=>Hs(r,o,{t:"land",worktreeId:l})}),xm(e.worktree)&&v.push({id:"archive",label:Z1(e)?"archive…":"archive",key:Et("wt-archive"),danger:!0,onClick:()=>u.archive(e)}),Dn([c,p,m,h,k,y,v])}function KL(e,t,{sock:n,dispatch:r},o){const a=[],l=t.frame==="phone",u=[{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 jd(e)&&(e.behind??0)>0&&a.push({id:"sync",label:`sync from main (${e.behind} behind)`,onClick:()=>n==null?void 0:n.send({t:"sync-main",worktreeId:e.id})}),l||a.push({id:"shell",label:"open a shell here",onClick:()=>{r({a:"activate",id:e.id}),r({a:"focus-terminal"})}}),a.push(...qd(()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id}),o)),Dn([u,a,l?[]:[{id:"copy-path",label:"copy path",onClick:()=>Zt(e.path)}]])}const ZL={sm:"",md:"field-md",lg:"field-lg"};function V1({size:e="sm",font:t,bare:n,rule:r,className:o}){const a=t??(e==="lg"?"ui":"mono");return He("field",ZL[e],a==="ui"&&"field-ui",a==="lead"&&"field-lead",n&&"field-bare",r&&"field-rule",o)}const Mo=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:a,...l},u){return f.jsx("input",{ref:u,className:V1({size:t,font:n,bare:r,rule:o,className:a}),...l})}),Ia=S.forwardRef(function({size:t,font:n,bare:r,rule:o,className:a,...l},u){return f.jsx("textarea",{ref:u,className:V1({size:t,font:n,bare:r,rule:o,className:a}),...l})});function qL(e,t){const n=t??0;return n===0?null:`${n} behind ${e}`}function Y1(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Q1(e,t){if(t.fetchFailed)return`could not reach origin${t.fetchedAt?` since ${Y1(t.fetchedAt)}`:""}: ${t.fetchFailed}`;const n=t.behind??0;return n===0?null:t.stale==="diverged"?`${e} has diverged from origin`:t.stale==="dirty"&&t.dirty>0?`${n} behind origin; an uncommitted file on ${e} is in the pull's way`:`${n} behind origin`}function GL(e){return e.stale!=="diverged"}const Jo=e=>/[.!?]$/.test(e)?e:`${e}.`;function us(e){const t=`PR #${e.number}`;if(e.state==="merged")return`${t} merged.`;if(e.state==="closed")return`${t} was closed without merging.`;if(e.automerge){const n=e.review==="review_required"?"it is approved and checks pass":"checks pass";return`${t} open; GitHub merges it when ${n}.`}return e.mergeable===!1?`${t} open; it conflicts with main.`:e.review==="changes_requested"?`${t} open; changes requested.`:e.checks==="fail"?`${t} open; checks failed.`:e.checks==="pending"?`${t} open; checks running.`:e.review==="review_required"?`${t} open; waiting on review.`:e.review==="approved"?`${t} approved${e.checks==="pass"?", checks pass":""}.`:`${t} open and ready to merge.`}function X1(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 J1=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function cg(e,t,n){return t===0||e!=null&&e.subject?null:!e||e.stale?"unwritten":e.check==="pending"?"pending":e.check==="fail"?null:e.unanswered||n?"unanswered":"unasked"}function e_(e,t,n=null){return e!=null&&e.stale?`The work changed since this was written. ${t?"Run the check again and refresh":"Refresh"} the message.`:n==="unanswered"?`The model did not answer with a message. ${t?"Run the check again and ask":"Ask"} for it again.`:`${t?"Run the repo's check here, then write":"Write"} the recap and the commit message.`}function VL(e){return e?`No commit message: ${e} has no quick model to write one. Write it in the changes panel.`:"No commit message yet: write one in the changes panel."}function Iu(e,t=0,n=!0,r){var o,a;if(e.check==="pending")return"Checking the work…";if(e.check==="fail"){const l=(a=(o=e.checkTail)==null?void 0:o.split(`
113
+ `).find(u=>u.trim()))==null?void 0:a.trim();return`Check failed${l?`: ${Jo(l)}`:"."}`}return cg(e,t,n)==="unasked"?VL(r):null}function qv(e,t){const n=YL(e,t);return n?Jo(J1(n)):""}function YL(e,t){const n=t>0?`${t} ${t===1?"file":"files"} changed`:"",r=e.check==="pass"?"check passed":"";return[n,r].filter(Boolean).join(", ")}const t_=e=>/^[A-Z][a-z]+(\s|$)/.test(e)?`${e.charAt(0).toLowerCase()}${e.slice(1)}`:e;function QL(e,t){const n=t??0;return n>0?`${n} behind ${e}; land takes it in first.`:""}function XL(e){return e>0?Jo(J1(`${e} ${e===1?"file":"files"} changed`)):""}function JL(e,t=null){return e.stale?"Changed since this was written.":t==="unanswered"?"No message yet: the model did not answer.":e.why?`Not ready: ${Jo(t_(e.why))}`:null}function Ru(e){return Jo(e)}const qo=e=>e==="now"?"just now":`${e} ago`;function eP(e,t,n){switch(e){case"asking":return`Waiting on you${n==="now"?"":` for ${n}`}${t.ask?`: ${Jo(t.ask)}`:"."}`;case"failed":return t.auth?`Stopped ${qo(n)}: not logged in.`:t.error?`Failed ${qo(n)}: ${Jo(t.error)}`:`Failed ${qo(n)}.`;case"stopped":return t.planBack?`Sent the plan back ${qo(n)}. Say what to change.`:`Stopped ${qo(n)}.`;case"done":return t.cut?`Ended early ${qo(n)} (${t.cut}).`:`Finished ${qo(n)}.`}}function ug(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?Jo(t):eP(e.end,e.facts,ro(e.at))}function tP(e){var n;const t=(n=e.recap)==null?void 0:n.text;return t?`Last stop, ${qo(ro(e.at))}: ${Jo(t_(t))}`:void 0}function nc(e,t){var n,r;return(r=(n=e==null?void 0:e.worktree)==null?void 0:n.runs)==null?void 0:r.find(o=>o.kind===t)}function dg(e){return(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="detached"}function n_(e){const t=e&&e.status!=="terminated"?e.since:void 0,n=Gm(t,Vm);return t!==void 0&&n===t?e:void 0}function r_(e,t){const n=e.stage?[e.stage]:[];switch(e.status){case"queued":return[...n,"queued"];case"running":return[...n,`${ba(t)} of ${ST(e.timeoutMs)}`];case"detached":return[...n,ba(t),"detached"];case"terminated":return[e.why??"stopped"]}}function Uh(e,t,n){return[e,...r_(t,n)].join(" · ")}const o_={queued:"Asked for, not started yet.",running:"Running under the daemon's watch. It is killed at the ceiling.",detached:"The daemon restarted under it. It runs on, unwatched, until it ends or is stopped.",terminated:"Killed: at its ceiling, or by a stop."};function s_(e){switch(e){case"setup":return"Stop this setup command; the next one runs";case"check":return"Stop the check; it reads as failed until it runs again";case"commit":return"Stop the commit and the hooks it is running; nothing is committed"}}function nP({active:e,ahead:t,behind:n,unpushed:r,dirty:o}){var at,qt,an;const a=it(),l=ct(),u=sn("changes"),c=tr(e)?e.worktree:null,p=e.id,m=L(qe=>{var J;return(J=qe.shipping[p])==null?void 0:J.op}),h=L(qe=>{var J;return(J=qe.shipping[p])==null?void 0:J.step}),k=Gm(h,Vm),y=nc(e,"commit"),v=nc(e,"check"),x=m?y:v,_=n_(x),N=Aa(dg(_)?_==null?void 0:_.since:void 0),[j,E]=S.useState("");gt([p],()=>E(""));const M=S.useRef(null),K=(at=c==null?void 0:c.landing)!=null&&at.subject?c.landing.body?`${c.landing.subject}
114
+
115
+ ${c.landing.body}`:c.landing.subject:null,U=()=>{j===""&&K&&E(K);const qe=M.current;qe&&(qe.focus(),requestAnimationFrame(()=>qe.setSelectionRange(qe.value.length,qe.value.length)))},R=L(qe=>qe.editCommit);gt([R],()=>{R&&U()});const I=j.trim()||void 0,C=L(qe=>{var J;return!!((J=qe.agents.find(we=>we.id===((c==null?void 0:c.agent)??qe.defaultAgent)))!=null&&J.quick)}),P=c==null?void 0:c.landing,z=I?null:cg(P,o?1:0,C),q=(P==null?void 0:P.check)==="pending",se=!!(P!=null&&P.stale),pe=()=>{m||a==null||a.send({t:"judge",worktreeId:p})},ue=()=>{m||!I&&!K||(Hs(a,l,{t:"commit",worktreeId:p,message:I??K??""}),E(""))},xe=()=>{m||Hs(a,l,{t:"land",worktreeId:p,...I?{message:I}:{}})},oe=((qt=c==null?void 0:c.landing)==null?void 0:qt.check)==="fail",A=c==null?void 0:c.pr,X=(A==null?void 0:A.state)==="open",Z=X&&(o||r>0),$=q||se||!!z,V=!!c&&bi(c)&&(o||t>0)&&!oe&&!X&&!$,de=!!c&&Z&&!oe&&!$,me=!!c&&bi(c)&&!q&&(se||z==="unwritten"||z==="unanswered")&&e.agent!=="working"&&e.agent!=="waiting",he=L(qe=>qe.repos.find(J=>J.id===e.repoId)??null),$e=Ju(_i((he==null?void 0:he.config)??{}),he==null?void 0:he.defaultBranch),ae=he?Cd(he):"main",ve=jd(e)?qL(ae,n):null,Re=e.agent==="working"||e.agent==="waiting",ee=o?c?Re?"the agent is mid-turn: sync when it is done":void 0:"commit or discard the changes here first":void 0,Y=X&&!Z&&X1(A),Pe=V?"land":de?"update":Y?"merge":(A==null?void 0:A.state)==="merged"?"pull":"land",Fe=m==="commit"?k??"commit":m==="land"?k?`${Pe}: ${k}`:Pe:null,pt=x?_?r_(_,N).join(" · "):null:q&&!m?"writing the message":null,Ge=_&&(_.status==="running"||_.status==="detached")?_:null,vt=Ge&&f.jsx(At,{icon:"stop",tone:"danger",label:s_(Ge.kind),onClick:()=>a==null?void 0:a.send({t:"run-stop",worktreeId:p,kind:Ge.kind})});return f.jsxs("div",{className:"composer commit-box",children:[c&&o&&f.jsx("div",{className:"composer-field",children:f.jsx(Ia,{size:"lg",bare:!0,ref:M,value:j,onChange:qe=>E(qe.target.value),onKeyDown:qe=>{qe.key==="Enter"&&(qe.metaKey||qe.ctrlKey)?(qe.preventDefault(),ue()):qe.key==="Tab"&&!qe.shiftKey&&j===""&&K&&(qe.preventDefault(),U())},placeholder:K??(z==="unanswered"?"no message yet: the model did not answer. Check again, or write one here":z==="unasked"?"no message yet: write one here to commit or land":"commit message…")})}),f.jsxs("div",{className:"hint composer-knobs",children:[f.jsxs("span",{className:"commit-where",children:[f.jsx(St,{name:"branch",className:"icon-inline"}),f.jsx("span",{className:"branch-name",children:e.branch??"detached"}),t>0&&f.jsxs("span",{className:"badge-ahead","data-tip":`${t} commit(s) ahead of ${ae}`,children:[t," ahead"]}),(c==null?void 0:c.landed)&&f.jsxs("span",{className:"badge-landed","data-tip":`Merged into ${ae}`,children:[f.jsx(St,{name:"check",className:"icon-inline"})," landed"]})]}),f.jsxs("span",{className:"commit-acts",children:[Fe?f.jsx("span",{className:"live-text",children:Fe}):f.jsxs(f.Fragment,{children:[c&&o&&f.jsx(ze,{disabled:!I&&!K||!!m,onClick:ue,...$t(K&&!I?"Commit with the suggested message":"git add -A && git commit","⌘⏎"),children:"commit"}),c&&V&&f.jsx(ze,{tone:"primary",disabled:!!m,"data-tip":$e,onClick:xe,children:"land"}),me&&f.jsx(ze,{tone:"primary",disabled:!!m,"data-tip":e_(P,!!((an=he==null?void 0:he.config.check)!=null&&an.trim()),z),onClick:pe,children:"check"}),q&&f.jsx("span",{className:"live-text",children:"check"}),de&&A&&f.jsx(ze,{tone:"primary",disabled:!!m,"data-tip":`Commit, take ${ae} in and push the branch; PR #${A.number} takes the new commits`,onClick:xe,children:"update"}),Y&&f.jsx(ze,{tone:"primary",disabled:!!m,"data-tip":"Merge the PR now, by the method the repo allows",onClick:xe,children:"merge"})]}),A&&f.jsxs(ze,{"data-tip":`Open PR #${A.number} on GitHub`,onClick:()=>window.open(A.url,"_blank"),...u.contextMenu(()=>[{id:"open-pr",label:"open on GitHub",onClick:()=>window.open(A.url,"_blank")},{id:"copy-link",label:"copy link",onClick:()=>Zt(A.url)}]),children:["view ",f.jsx(St,{name:"external",className:"icon-inline"})]})]})]}),(ve||pt)&&f.jsxs("div",{className:"composer-notes",children:[pt&&f.jsxs("div",{className:"hint composer-note","data-tip":_?o_[_.status]:void 0,children:[f.jsx("span",{children:pt}),vt]}),ve&&f.jsxs("div",{className:"hint composer-note",children:[f.jsx("span",{children:ve}),m==="sync-main"?f.jsx("span",{className:"live-text",children:k?`sync: ${k}`:"sync"}):f.jsx(ze,{variant:"outline",disabled:!!m||!!ee,"data-tip":ee??`Merge ${ae} into this worktree${o?", uncommitted changes kept":""}`,onClick:()=>Hs(a,l,{t:"sync-main",worktreeId:p}),children:"sync"})]})]})]})}const rP=S.memo(function({c:t,id:n,selected:r,onToggle:o}){const a=sn("changes");return f.jsxs("button",{className:"row row-sm log-row row-edge",id:n,"data-state":rr({current:r,cursor:r}),role:"option","aria-selected":r,tabIndex:-1,onClick:()=>o(t.sha),...a.contextMenu(()=>W1(t)),"data-tip":`${t.subject}
116
+ ${t.short} · ${t.author}`,"data-tip-placement":"follow",children:[f.jsx("span",{className:"subject",children:t.subject}),f.jsx("span",{className:"at row-dim",children:ro(t.at)})]})});function oP(e,t){const n=ms(e,t);if(!n||!tr(n))return"take this worktree over to change files here";if(ji(n.worktree))return"start a worktree to change files"}function i_(e,t,n,r){return{id:"new-file",label:"new file…",disabled:oP(e.getState(),t),onClick:()=>r(n)}}function sP(e,t,n,r){const{worktreeId:o,dir:a,path:l,folder:u,newIn:c}=e,p=Yd(t.getState(),o)?void 0:"take this worktree over to talk to an agent here",m=og(l,u),h=[...u?[]:[{id:"open",label:"open",onClick:()=>nr(n,{worktreeId:o,path:l,view:Ai(l)})}],{id:"add-to-chat",label:"add to chat",disabled:p,onClick:()=>C1(t,o,l,u)}],k=[i_(t,o,c,r),{id:"ask-rename",label:"ask the agent to rename…",disabled:p,onClick:()=>Mv(t,o,`Rename ${m} to `)},{id:"ask-delete",label:"ask the agent to delete…",disabled:p,onClick:()=>Mv(t,o,`Delete ${m} and update whatever still uses it`)}],y=[...qd(()=>{var v;return(v=n.sock)==null?void 0:v.send({t:"reveal",worktreeId:o,path:l})}),{id:"copy-path",label:"copy path",onClick:()=>Zt(`${a}/${l}`)},{id:"copy-relative-path",label:"copy relative path",onClick:()=>Zt(l)}];return Dn([h,y,k])}function iP(e,t,n,r){return Dn([[i_(t,e.worktreeId,"",r)],Ii(e.dir,()=>{var o;return(o=n.sock)==null?void 0:o.send({t:"reveal",worktreeId:e.worktreeId})})])}const Ou=[],aP=[],Gv=new Set,Vv=e=>`tree-row-${e}`;function lP({worktreeId:e,dir:t,openPath:n,openRef:r,rootRef:o}){const a=Bn(),l=it(),u=ct(),c=Ot(e,"files"),p=Ot(e,"submodules"),m=Ot(e,"ignored"),h=Ot(e,"git"),k=(h==null?void 0:h.files)??aP;gt([e,h,l],()=>Gd(e,a.getState(),{sock:l,dispatch:u}));const y=L(ee=>{var Y;return((Y=ee.dragFiles)==null?void 0:Y.at)==="tree"&&ee.dragFiles.worktreeId===e?ee.dragFiles.dir:null}),v=L(ee=>ee.treeOpen[e]??Ou),x=S.useMemo(()=>new Set(v),[v]),[_,N]=S.useState(Gv);gt([e,n,r],()=>N(n&&!r?new Set(ld(n).filter(ee=>!x.has(ee))):Gv));const j=S.useCallback(ee=>x.has(ee)||_.has(ee),[x,_]),E=S.useCallback(ee=>{const Y=x.has(ee)||_.has(ee);if(Y&&_.has(ee)){const Pe=new Set(_);Pe.delete(ee),N(Pe)}u({a:"tree-folder",worktreeId:e,path:ee,open:!Y})},[x,_,e,u]),M=S.useMemo(()=>KM(c??Ou,p??Ou,m??Ou),[c,p,m]),K=S.useMemo(()=>ZM(M,j),[M,j]),U=S.useMemo(()=>GM(k),[k]),R=L(ee=>ee.treeReveal),I=R&&R.worktreeId===e?R:null,[C,P]=S.useState(()=>(I==null?void 0:I.path)??null),[z,q]=S.useState({worktreeId:e,linked:I});(z.worktreeId!==e||z.linked!==I)&&(q({worktreeId:e,linked:I}),P((I==null?void 0:I.path)??null));const[se,pe]=S.useState(!1),ue=S.useMemo(()=>{if(C===null)return-1;const ee=K.findIndex(Y=>Y.path===C);if(ee>=0)return ee;for(const Y of ld(C).reverse()){const Pe=K.findIndex(We=>We.path===Y);if(Pe>=0)return Pe}return-1},[K,C]);gt([ue,se],()=>{var ee,Y;se&&((Y=(ee=o.current)==null?void 0:ee.querySelector('[data-state~="cursor"]'))==null||Y.scrollIntoView({block:"nearest"}))});const xe=S.useCallback((ee,Y)=>nr({dispatch:u},{worktreeId:e,path:ee,view:Ai(ee),focus:Y}),[e,l,u]),oe=S.useCallback(ee=>{P(ee.path),ee.kind==="folder"?E(ee.path):ee.kind==="file"&&xe(ee.path,!1)},[E,xe]),A=ee=>{var We;if(ee.metaKey||ee.ctrlKey||ee.altKey)return;const Y=K[ue],Pe=Fe=>{const pt=K[Fe];pt&&(P(pt.path),pt.kind==="file"&&xe(pt.path,!1))};switch(ee.key){case"ArrowDown":case"ArrowUp":ee.preventDefault(),Pe(ue<0?0:Fa(ue,ee.key==="ArrowDown"?1:-1,K.length));return;case" ":ee.preventDefault(),(Y==null?void 0:Y.kind)==="file"?xe(Y.path,!1):(Y==null?void 0:Y.kind)==="folder"&&E(Y.path);return;case"Enter":ee.preventDefault(),(Y==null?void 0:Y.kind)==="file"?xe(Y.path,!0):(Y==null?void 0:Y.kind)==="folder"&&E(Y.path);return;case"ArrowRight":case"ArrowLeft":{ee.preventDefault();const Fe=K.map(Ge=>Ge.kind==="folder"?{depth:Ge.depth,open:Ge.open}:{depth:Ge.depth}),pt=Jd(Fe,ue,ee.key);(pt==null?void 0:pt.do)==="to"?Pe(pt.at):pt&&Y&&E(Y.path);return}case"Escape":ee.stopPropagation(),n!==null?u({a:"close-editor"}):(We=document.activeElement)==null||We.blur();return}if(ee.key.length===1){const Fe=F1(K.map(pt=>pt.name),ue,ee.key);Fe>=0&&(ee.preventDefault(),Pe(Fe))}},[X,Z]=S.useState(null),$=S.useRef(0),V=S.useCallback(ee=>{ee&&!j(ee)&&E(ee),$.current++,Z({dir:ee,error:null,busy:!1})},[j,E]),de=S.useCallback(()=>{$.current++,Z(null)},[]),me=S.useCallback(ee=>{if(!X||X.busy)return;const Y=qM(X.dir,ee);if("error"in Y){Z({...X,error:Y.error});return}const Pe=++$.current;Z({...X,error:null,busy:!0}),_1({sock:l,dispatch:u},{worktreeId:e,path:Y.path}).then(We=>{We===null&&P(Y.path),Pe===$.current&&Z(We===null?null:{...X,error:We,busy:!1})})},[X,e,l,u]),he=sn("tree"),$e=S.useCallback(ee=>sP({worktreeId:e,dir:t,path:ee.path,folder:ee.kind!=="file",newIn:ee.kind==="folder"||ee.kind==="ignored"?ee.path:A1(ee.path)},a,{sock:l,dispatch:u},V),[e,t,a,l,u,V]),ae=S.useCallback((ee,Y)=>{ee.kind==="file"&&Yt.post(e,Y?{type:"highlight-file",path:ee.path,ranges:null}:{type:"highlight-clear"})},[e]),ve=S.useCallback((ee,Y)=>{Y.dataTransfer.setData(O1,ee.path),Y.dataTransfer.setData("text/plain",ee.path),Y.dataTransfer.effectAllowed="copy",aL({worktreeId:e,path:ee.path,folder:ee.kind!=="file"})},[e]),Re=S.useCallback(()=>$1(a),[a]);return f.jsx("div",{className:He("tree",y===""&&"drop-over"),role:"tree","aria-label":"files","data-worktree":e,"aria-activedescendant":se&&ue>=0?Vv(ue):void 0,tabIndex:0,ref:o,onKeyDown:A,onFocus:()=>{var ee;pe(!0),C===null&&P(n&&K.some(Y=>Y.path===n)?n:((ee=K[0])==null?void 0:ee.path)??null)},onBlur:ee=>!ee.currentTarget.contains(ee.relatedTarget)&&pe(!1),onMouseDown:ee=>{if(ee.button!==0)return;const Y=ee.target.closest("[data-path]");(Y==null?void 0:Y.dataset.path)!==void 0&&P(Y.dataset.path)},...he.contextMenu(ee=>{const Y=K[ue];return ee==="keyboard"&&Y?$e(Y):iP({worktreeId:e,dir:t},a,{sock:l},V)}),children:c===void 0?f.jsx("div",{className:"empty",children:"listing files…"}):K.length===0&&!X?f.jsx("div",{className:"empty",children:"no files"}):cP(K.map((ee,Y)=>f.jsx(dP,{row:ee,id:Vv(Y),status:U.files.get(ee.path),changedInside:ee.kind!=="file"&&U.folders.has(ee.path),current:se?Y===ue:!r&&ee.path===n,cursor:se&&Y===ue,dropOver:y===ee.path,onPress:oe,menu:$e,onHover:ae,onDragStart:ve,onDragEnd:Re},ee.path)),X&&(()=>{var Y;const ee=X.dir===""?-1:K.findIndex(Pe=>Pe.path===X.dir);return{at:ee,node:f.jsx(uP,{depth:ee>=0?(((Y=K[ee])==null?void 0:Y.depth)??0)+1:0,error:X.error,onSubmit:me,onCancel:de},"new-file")}})())})}function cP(e,t){return t?[...e.slice(0,t.at+1),t.node,...e.slice(t.at+1)]:e}function uP({depth:e,error:t,onSubmit:n,onCancel:r}){const[o,a]=S.useState(""),l={"--tree-depth":e},u=e===0||void 0;return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"row row-sm tree-row row-rails","data-kind":"file","data-root":u,style:l,children:[f.jsx("span",{className:"tree-caret row-dim"}),f.jsx(Mo,{bare:!0,font:"mono",autoFocus:!0,className:"tree-new-name","aria-label":"new file name","aria-invalid":t!==null||void 0,placeholder:"name",value:o,onChange:c=>a(c.target.value),onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"?(c.preventDefault(),n(o)):c.key==="Escape"&&(c.preventDefault(),r())},onBlur:r})]}),t&&f.jsxs("div",{className:"tree-row tree-new-error row-rails","data-root":u,style:l,children:[f.jsx("span",{className:"tree-caret"}),f.jsx("span",{className:"hint",children:t})]})]})}const dP=S.memo(function({row:t,id:n,status:r,changedInside:o,current:a,cursor:l,dropOver:u,onPress:c,menu:p,onHover:m,onDragStart:h,onDragEnd:k}){const y=sn("tree"),v=t.kind==="submodule",x=v?"A submodule: its files belong to its own repository":t.kind==="ignored"?"Ignored by git, so what is inside is not listed":null;return f.jsxs("div",{role:"treeitem",id:n,"aria-level":t.depth+1,"aria-expanded":t.kind==="folder"?t.open:void 0,"aria-selected":l,className:He("row row-sm tree-row row-rails row-edge",u&&"drop-over"),"data-state":rr({current:a,cursor:l}),"data-kind":t.kind,"data-path":t.path,style:{"--tree-depth":t.depth},draggable:!v,onDragStart:_=>h(t,_),onDragEnd:k,onClick:()=>c(t),onMouseEnter:()=>m(t,!0),onMouseLeave:()=>m(t,!1),...y.contextMenu(()=>p(t)),...x?$t(x):{},children:[f.jsx("span",{className:"tree-caret row-dim",children:t.kind==="folder"&&f.jsx(St,{name:"caret",className:He("icon-inline disc-caret",!t.open&&"shut")})}),f.jsx("span",{className:He("tree-name",(v||t.ignored)&&"row-dim"),children:t.name}),r?f.jsx("span",{className:`xy ${Bm(r.xy)}`,children:Um(r.xy)}):o&&f.jsx("span",{className:"dot tree-changed"})]})});function a_({f:e}){return e.add===void 0&&e.del===void 0?null:f.jsxs("span",{className:"counts",children:[e.add?f.jsxs("span",{className:"add",children:["+",e.add]}):null,e.del?f.jsxs("span",{className:"del",children:["−",e.del]}):null]})}const $u=S.memo(function({f:t,id:n,active:r,selected:o,checking:a=!1,checked:l=!1,onOpen:u,onCheck:c,menu:p,onHover:m}){const h=sn("changes"),{name:k,dir:y}=Q$(t.path);return f.jsxs("button",{className:"row row-sm git-file row-edge",id:n,"data-state":rr({current:r,cursor:o,checked:l}),role:"option","aria-selected":o,tabIndex:-1,onClick:v=>c&&(a||v.shiftKey)?c(t.path):u(t.path),...h.contextMenu(()=>p(t.path)),onMouseEnter:()=>m(t.path,!0),onMouseLeave:()=>m(t.path,!1),children:[a&&f.jsx("input",{type:"checkbox",className:"changes-check",checked:l,readOnly:!0,tabIndex:-1}),f.jsx("span",{className:`xy ${Bm(t.xy)}`,children:Um(t.xy)}),f.jsxs("span",{className:"path","data-tip":y?t.path:void 0,children:[f.jsx("span",{className:"name",children:k}),y&&f.jsx("span",{className:"dir row-dim",children:y})]}),f.jsx(a_,{f:t})]})}),fP={added:"A",changed:"M",removed:"D"},pP={added:"added",changed:"",removed:"deleted"},hP=S.memo(function({tests:t,id:n,cursor:r,onPick:o}){return t.map((a,l)=>f.jsxs("button",{className:"row row-sm changes-test row-rails row-edge",id:`${n}-t${l}`,"data-state":rr({current:r===l,cursor:r===l}),"data-sub":!0,role:"option","aria-selected":r===l,tabIndex:-1,onClick:()=>o(l),"data-tip":[...a.group,a.name].join(" · "),"data-tip-placement":"follow",children:[f.jsx("span",{className:`xy ${pP[a.change]}`,children:fP[a.change]}),f.jsx("span",{className:"name",children:a.name})]},l))}),Yv=new Set(["test","tests","__tests__","spec","e2e","__snapshots__","__mocks__","fixtures","testdata"]),mP=/([._-]tests?\.[^.]+$)|([._]specs?\.[^.]+$)|(^tests?[._-])|(^conftest\.py$)|(\.snap$)|([a-z0-9](Tests?|Spec)\.[^.]+$)/;function hd(e){const t=(e.endsWith("/")?e.slice(0,-1):e).split("/"),n=t.pop()??"";return e.endsWith("/")&&Yv.has(n.toLowerCase())?!0:t.some(r=>Yv.has(r.toLowerCase()))||mP.test(n)}function Mu(e){const t=e.filter(n=>!hd(n.path));return t.length===0||t.length===e.length?{files:e,source:t.length}:{files:[...t,...e.filter(n=>hd(n.path))],source:t.length}}const Hh="(?<q>[\"'`])(?<name>(?:\\\\.|(?!\\k<q>).)*)\\k<q>",Qv={tests:[new RegExp(`^\\s*(?:test|it)(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Hh}`)],groups:[new RegExp(`^\\s*describe(?:\\.(?!each\\b)\\w+)*(?:\\.each\\(.*\\))?\\(\\s*${Hh}`)]},gP={js:Qv,py:{tests:[/^\s*(?:async\s+)?def\s+(?<name>test\w*)\s*\(/],groups:[/^\s*class\s+(?<name>Test\w*)/]},go:{tests:[/^func\s+(?<name>(?:Test|Benchmark|Fuzz|Example)\w*)\s*\(/,/^\s+\w+\.Run\(\s*"(?<name>(?:\\.|[^"\\])*)"/]},rs:{mark:/^\s*#\[(?:\w+::)*(?:test|rstest|test_case)\b/,tests:[/\bfn\s+(?<name>\w+)/]},jvm:{mark:/^\s*@(?:Test|ParameterizedTest|RepeatedTest|TestFactory)\b/,tests:[/\b(?:void|fun)\s+(?<name>`[^`]+`|\w+)\s*\(/]},cs:{mark:/^\s*\[(?:Test|TestCase|Fact|Theory|TestMethod)\b/,tests:[/\b(?:void|Task)\s+(?<name>\w+)\s*\(/]},rb:{tests:[new RegExp(`^\\s*(?:it|specify|test|scenario)\\s*\\(?\\s*${Hh}`),/^\s*def\s+(?<name>test_\w+)/],groups:[/^\s*(?:RSpec\.)?(?:describe|context|feature)\s*\(?\s*(?<name>"[^"]*"|'[^']*'|[\w:]+)/]},exs:{tests:[/^\s*test\s+"(?<name>(?:\\.|[^"\\])*)"/],groups:[/^\s*describe\s+"(?<name>(?:\\.|[^"\\])*)"/]},swift:{tests:[/^\s*(?:@Test\s+)?func\s+(?<name>test\w*)\s*\(/]},php:{tests:[/\bfunction\s+(?<name>test\w*)\s*\(/,...Qv.tests]}},kP={js:"js",jsx:"js",mjs:"js",cjs:"js",ts:"js",tsx:"js",mts:"js",cts:"js",py:"py",go:"go",rs:"rs",java:"jvm",kt:"jvm",cs:"cs",rb:"rb",exs:"exs",swift:"swift",php:"php"},yP=3,wP=/^\s*(?:[)}\]]|end\b)/,Jp=e=>e.length-e.trimStart().length;function Xv(e,t){var n,r;for(const o of t??[]){const a=(r=(n=o.exec(e))==null?void 0:n.groups)==null?void 0:r.name;if(a!==void 0)return a.replace(/^(["'`])(.*)\1$/,"$2")}return null}function Jv(e,t){const n=t.split(`
117
+ `),r=[],o=[];let a=Number.NEGATIVE_INFINITY;return n.forEach((l,u)=>{var k,y,v;if(l.trim()==="")return;const c=Jp(l);for(;o.length>0&&(((k=o.at(-1))==null?void 0:k.indent)??0)>=c;)o.pop();(y=e.mark)!=null&&y.test(l)&&(a=u);const m=!e.mark||u-a<=yP?Xv(l,e.tests):null,h=m??Xv(l,e.groups);if(h!==null){if(m!==null){a=Number.NEGATIVE_INFINITY;let x=u+1;for(;x<n.length&&(((v=n[x])==null?void 0:v.trim())===""||Jp(n[x]??"")>c);)x++;x<n.length&&Jp(n[x]??"")===c&&wP.test(n[x]??"")&&x++;const _=n.slice(u,x).map(N=>N.trim()).join(`
118
+ `).trim();r.push({group:o.map(N=>N.name),name:h,line:u,end:x,body:_})}o.push({indent:c,name:h})}}),r}function e0(e){const t=new Map;for(const n of e){const r=[...n.group,n.name].join(`
119
+ `);let o=0;for(;t.has(`${r}
120
+ ${o}`);)o++;t.set(`${r}
121
+ ${o}`,n)}return t}function vP(e,t,n){const r=gP[kP[e.slice(e.lastIndexOf(".")+1).toLowerCase()]??""];if(!r)return[];const o=e0(Jv(r,t)),a=e0(Jv(r,n)),l=[];for(const[m,h]of a){const k=o.get(m);(k==null?void 0:k.body)!==h.body&&l.push({name:h.name,group:h.group,change:k?"changed":"added",line:h.line+1})}const u=n.split(`
122
+ `).length;let c=1;for(const[m,h]of o){const k=a.get(m);k?c=Math.min(k.end+1,u):l.push({name:h.name,group:h.group,change:"removed",line:c})}const p=m=>m.change==="removed"?0:1;return l.sort((m,h)=>m.line-h.line||p(m)-p(h))}const Lu=[];function bP(e,t,n,r){const o=t?n>0?"no changes of its own":`same as ${e}`:"no changes";if(!r)return o;const a=ro(r.at);return`${o}, last commit ${a==="now"?"just now":`${a} ago`}`}const t0='[role="option"]:not([data-sub])',n0=[];function l_({width:e,placement:t="dock"}){const n=t==="screen",r=it(),o=ct(),a=Bn(),l=Da(),u=$i(),c=(u==null?void 0:u.id)??l,p=gs(),m=L(B=>B.layout.changes),h=hc(),k=L(B=>B.focusChanges),y=Ot(c,"git"),v=L(B=>B.editor&&B.editor.worktreeId===c?B.editor.path:null),x=L(B=>B.editor&&B.editor.worktreeId===c?B.editor.ref??null:null),_=L(B=>B.editor&&B.editor.worktreeId===c?B.editor.since??null:null),N=(y==null?void 0:y.files)??Lu,j=(y==null?void 0:y.committed)??Lu,{files:E,source:M}=S.useMemo(()=>Mu(N),[N]),K=j.length>0,U=Y2(),{files:R,source:I}=S.useMemo(()=>Mu(U?j:Lu),[j,U]),C=y==null?void 0:y.turn,P=C==null?void 0:C.base,z=Q2(),{files:q,source:se}=S.useMemo(()=>Mu(C&&z?C.files:Lu),[C,z]),pe=E.length,ue=E.length+q.length,xe=L(B=>B.editor&&B.editor.worktreeId===c?B.editor.disk:null),oe=S.useMemo(()=>v!==null&&xe&&hd(v)?vP(v,xe.before,xe.after):n0,[v,xe]),[A,X]=S.useState(!1);gt([v,x,_],()=>X(!1));const Z=M>0?E.length-M:0,$=I>0?R.length-I:0,V=se>0?q.length-se:0,de=E.length===0,me=S.useMemo(()=>{if(E.length===0)return;const B=E.reduce((ut,Bt)=>ut+(Bt.add??0),0),ce=E.reduce((ut,Bt)=>ut+(Bt.del??0),0),De=[B>0&&`+${B}`,ce>0&&`−${ce}`].filter(Boolean).join(" "),lt=`${E.length} uncommitted ${E.length===1?"file":"files"}`;return De?`${lt}, ${De}`:lt},[E]),he=!!y&&de&&!K,$e=L(Ca),ae=u!==null||$e==="changes",ve=u!==null||$e==="history",Re=S.useCallback(B=>o({a:"changes-tab",v:B}),[o]),ee=S.useRef($e);ee.current=$e;const Y=S.useRef(null),Pe=Ym(),We=L(B=>{const ce=Pa(B,Pe==null?void 0:Pe.repoId);return ce?Cd(ce):"main"}),Fe=Ot(c,"commits"),pt=Ot(c,"commitFiles"),[Ge,vt]=S.useState(null),at=S.useRef(null);at.current=Ge;const qt=S.useRef(null),an=Ot(c,"changedRanges"),qe=S.useCallback((B,ce)=>{if(!c||u)return;if(!ce){qt.current=null,Yt.post(c,{type:"highlight-clear"});return}qt.current=B;const De=an[B];De?Yt.post(c,{type:"highlight-file",path:B,ranges:lv(De)}):r==null||r.send({t:"changed-ranges",worktreeId:c,path:B})},[c,u,an,r]);S.useEffect(()=>{const B=qt.current;if(!B||!c)return;const ce=an[B];ce&&Yt.post(c,{type:"highlight-file",path:B,ranges:lv(ce)})},[an,c]);const J=u&&E.length>0?(y==null?void 0:y.head)??null:null,we=S.useCallback((B,ce=!1,De)=>c&&nr({dispatch:o},{worktreeId:c,path:B,focus:ce,ref:J??void 0,since:De}),[c,J,r,o]),Xe=S.useMemo(()=>u?E:[...E,...q,...R],[u,E,q,R]),et=S.useMemo(()=>{const B=[];for(const ce of Fe??[])if(B.push({commit:ce}),ce.sha===Ge)for(const De of Mu(pt[ce.sha]??[]).files)B.push({commit:ce,file:De});return B},[Fe,Ge,pt]),Wt=S.useMemo(()=>et.filter(B=>!B.file&&B.commit.ahead).length,[et]),Qt=S.useMemo(()=>et.findIndex(B=>!B.file&&!B.commit.ahead),[et]),ge=u?Xe.length:0,Me=(ae?Xe.length:0)+(ve?et.length:0),hn=S.useMemo(()=>{const B=new Map;if(!u||E.length===0&&et.every(De=>De.commit.landedAt))return B;let ce;return et.forEach((De,lt)=>{const ut=!!De.commit.landedAt;ut!==ce&&(ce=ut,B.set(lt,ut?"landed":"not landed"))}),B},[u,E,et]),It=S.useRef(null),[{row:Rt,at:In},Dt]=S.useReducer((B,ce)=>typeof ce=="number"?{row:ce,at:-1}:ce,{row:0,at:-1}),[gn,kt]=S.useState(!1),Gt=(B,ce)=>gn?Sn(B):ce,tn=B=>`changes-row-${B}`,[nn,Un]=S.useState(!1),[_t,Kt]=S.useState([]),Rn=S.useCallback(()=>{Un(!1),Kt([])},[]),H=S.useCallback(B=>{Un(!0),Kt(ce=>ce.includes(B)?ce.filter(De=>De!==B):[...ce,B])},[]),fe=S.useMemo(()=>E.filter(B=>_t.includes(B.path)).map(B=>B.path),[E,_t]);gt([E],()=>Kt(B=>{const ce=B.filter(De=>E.some(lt=>lt.path===De));return ce.length===B.length?B:ce})),gt([nn],()=>{if(!nn)return;const B=ce=>ce.key==="Escape"&&Rn();return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)}),gt([c,$e],()=>{Dt(0),Rn()});const Ie=y==null?void 0:y.head,rt=S.useRef("");S.useEffect(()=>{if(!(ve||he)||!c)return;const B=`${c}:${Ie??""}`;rt.current!==B&&(rt.current=B,r==null||r.send({t:"git-log",worktreeId:c}))},[ve,he,c,Ie,r]);const te=S.useCallback(B=>{vt(ce=>ce===B?null:B),c&&!pt[B]&&(r==null||r.send({t:"git-commit",worktreeId:c,sha:B}))},[c,pt,r]);gt([Rt,In,gn],()=>{var B,ce;gn&&((ce=(B=It.current)==null?void 0:B.querySelector('[data-state~="cursor"]'))==null||ce.scrollIntoView({block:"nearest"}))});const Ne=S.useRef(-1),be=B=>B>=pe&&B<ue?P:void 0,_e=B=>{var ce;return((ce=Xe[B])==null?void 0:ce.path)===v&&(_??void 0)===be(B)&&(B<pe?x===J:!x)};Ne.current=ae?Xe.findIndex((B,ce)=>_e(ce)):-1,S.useEffect(()=>{if(!k)return;const B=ee.current==="files";Ne.current>=0&&Dt(Ne.current);const ce=requestAnimationFrame(()=>{var De;return(De=(B?Y:It).current)==null?void 0:De.focus()});return()=>cancelAnimationFrame(ce)},[k]);const Oe=S.useCallback((B,ce=!1)=>{const De=Xe[B];De&&(Dt(B),we(De.path,ce,B>=pe&&B<ue?P:void 0),qe(De.path,!0))},[Xe,we,qe,pe,ue,P]),Mt=S.useCallback((B,ce=!1)=>{const De=at.current;c&&De&&nr({dispatch:o},{worktreeId:c,path:B,ref:De,focus:ce})},[c,r,o]),Tt=S.useCallback(B=>{const ce=et[B-ge];ce&&(Dt(B),ce.file&&Mt(ce.file.path))},[et,ge,Mt]),ht=S.useCallback(B=>{const ce=et[B-ge];ce&&(Dt(B),ce.file?Mt(ce.file.path,!0):te(ce.commit.sha))},[et,ge,Mt,te]),wn=B=>ve&&B>=ge,Ke=B=>{if(v===null)return!1;if(ae&&B<Xe.length)return _e(B);const ce=wn(B)?et[B-ge]:void 0;return!!(ce!=null&&ce.file)&&x===ce.commit.sha&&ce.file.path===v},Kn=B=>Ke(B)&&!A?oe:n0,Nt=In<Kn(Rt).length?In:-1,Sn=B=>gn&&Rt===B&&Nt<0,Nn=()=>{var ce,De;const B=[];for(let lt=0;lt<Me;lt++){const ut=wn(lt)?et[lt-ge]:void 0,Bt=ut?(ce=ut.file)==null?void 0:ce.path:(De=Xe[lt])==null?void 0:De.path,kn=ut!=null&&ut.file?1:0,vn=Kn(lt);ut&&!ut.file?B.push({row:lt,at:-1,depth:kn,open:ut.commit.sha===Ge}):Bt!==void 0&&hd(Bt)?B.push({row:lt,at:-1,depth:kn,open:vn.length>0}):B.push({row:lt,at:-1,depth:kn});for(let Lr=0;Lr<vn.length;Lr++)B.push({row:lt,at:Lr,depth:kn+1})}return B},Hn=(B,ce=!1)=>{const De=oe[B];!De||!c||v===null||nr({dispatch:o},{worktreeId:c,path:v,ref:x??void 0,since:_??void 0,line:{n:De.line},focus:ce})},Lt=B=>Kn(B).length>0&&f.jsx(hP,{tests:oe,id:tn(B),cursor:gn&&Rt===B?Nt:-1,onPick:ce=>{Dt({row:B,at:ce}),Hn(ce)}}),Xt=B=>{var ce;if(nn&&B.key==="Escape")B.preventDefault(),B.stopPropagation(),Rn();else if(nn&&B.key===" "){B.preventDefault();const De=ae&&Rt<E.length?E[Rt]:void 0;De&&H(De.path)}else if(B.key==="ArrowDown"&&Nt+1<Kn(Rt).length)B.preventDefault(),Dt({row:Rt,at:Nt+1}),Hn(Nt+1);else if(B.key==="ArrowUp"&&Nt>=0)B.preventDefault(),Nt===0?Dt(Rt):(Dt({row:Rt,at:Nt-1}),Hn(Nt-1));else if(B.key==="Enter"&&Nt>=0)B.preventDefault(),Hn(Nt,!0);else if(B.key==="ArrowDown"||B.key==="ArrowUp"){B.preventDefault();const De=Fa(Rt,B.key==="ArrowDown"?1:-1,Me);wn(De)?Tt(De):Oe(De)}else if(B.key==="Enter")B.preventDefault(),wn(Rt)?ht(Rt):Oe(Rt,!0);else if(B.key==="ArrowRight"||B.key==="ArrowLeft"){B.preventDefault();const De=Nn(),lt=Jd(De,De.findIndex(kn=>kn.row===Rt&&kn.at===Nt),B.key),ut=lt&&De[lt.at];if(!lt||!ut)return;const Bt=wn(ut.row)?et[ut.row-ge]:void 0;lt.do==="to"?ut.at>=0?(Dt({row:ut.row,at:ut.at}),Hn(ut.at)):Bt!=null&&Bt.file&&ut.row>Rt?Tt(ut.row):Dt(ut.row):Bt&&!Bt.file?te(Bt.commit.sha):lt.do==="close"?X(!0):Ke(ut.row)?X(!1):Bt!=null&&Bt.file?Tt(ut.row):Oe(ut.row)}else B.key==="Escape"&&(B.stopPropagation(),v!==null?o({a:"close-editor"}):(ce=document.activeElement)==null||ce.blur())},mn=u?u.id:p==null?void 0:p.worktree.id,Gn=u?u.path:p?p.worktree.path:"",On=u!==null,sr=S.useCallback(B=>mn?fs({id:mn,dir:Gn},B,{discard:!On,kept:On,ref:J??void 0,select:On?void 0:H},{sock:r,dispatch:o}):[],[mn,Gn,On,J,H,r,o]),Mr=S.useCallback(B=>mn?fs({id:mn,dir:Gn},B,{kept:On},{sock:r,dispatch:o}):[],[mn,Gn,On,r,o]),wo=S.useCallback(B=>mn?fs({id:mn,dir:Gn},B,{kept:On,since:P},{sock:r,dispatch:o}):[],[mn,Gn,On,P,r,o]),on=S.useCallback(B=>mn?fs({id:mn,dir:Gn},B,{ref:at.current??void 0,kept:On},{sock:r,dispatch:o}):[],[mn,Gn,On,r,o]),Do=sn("changes"),so=()=>{if(ae&&Rt<Xe.length){const ce=Xe[Rt];return ce?(Rt<pe?sr:Rt<ue?wo:Mr)(ce.path):[]}const B=wn(Rt)?et[Rt-ge]:void 0;return B?B.file?on(B.file.path):W1(B.commit):[]},Zn=(B,ce)=>{const De=Xe.findIndex((lt,ut)=>ut>=B&&lt.path===ce);Dt(De),_e(De)&&oe.length>0?X(lt=>!lt):we(ce,!1,be(De))},Vn=S.useRef(Zn);Vn.current=Zn;const je=S.useCallback(B=>Vn.current(0,B),[]),Be=S.useCallback(B=>Vn.current(pe,B),[pe]),yt=S.useCallback(B=>Vn.current(ue,B),[ue]),xt=S.useCallback(B=>{Dt(ge+et.findIndex(ce=>!ce.file&&ce.commit.sha===B)),te(B)},[et,ge,te]),ln=S.useCallback(B=>{Dt(ge+et.findIndex(ce=>{var De;return((De=ce.file)==null?void 0:De.path)===B})),B===v&&x===at.current&&oe.length>0?X(ce=>!ce):Mt(B)},[et,ge,Mt,v,x,oe]),ot=S.useCallback(()=>{},[]);return f.jsxs("div",{className:He("changes-dock",n&&"changes-screen",!n&&(!m||h)&&"collapsed"),style:n?void 0:{width:e},children:[!u&&f.jsx(Xd,{fill:!n,quiet:n,owner:"changes-tabs",label:"changes panel",items:[{id:"files",label:f.jsx(St,{name:"folder",className:"icon-inline"}),fit:!0,ariaLabel:"files",tip:$t("files",Et("files"))},{id:"changes",label:"changes",tip:$t("changes",Et("changes"),{detail:me})},{id:"history",label:"history"}],current:$e,onPick:Re}),$e==="files"&&c?f.jsx(lP,{worktreeId:c,dir:p?p.worktree.path:(Pe==null?void 0:Pe.path)??"",openPath:v,openRef:x,rootRef:Y}):f.jsxs("div",{className:He("changes-list",ve&&"history"),role:"listbox","aria-label":u?"kept work":ve?"commits":"changed files","aria-activedescendant":gn&&Rt>=0&&Rt<Me?Nt<0?tn(Rt):`${tn(Rt)}-t${Nt}`:void 0,tabIndex:0,ref:It,onKeyDown:Xt,onFocus:()=>kt(!0),onMouseDown:B=>{var lt;if(B.button!==0)return;B.preventDefault();const ce=B.target.closest(t0),De=ce?Array.from(B.currentTarget.querySelectorAll(t0)).indexOf(ce):-1;De>=0&&Dt(De),(lt=It.current)==null||lt.focus()},onBlur:B=>!B.currentTarget.contains(B.relatedTarget)&&kt(!1),...Do.contextMenu(B=>B==="keyboard"?so():[]),children:[ae&&E.length>0&&f.jsxs(f.Fragment,{children:[(K||u)&&f.jsx("div",{className:"section-title section-row",children:"uncommitted"}),E.map((B,ce)=>f.jsxs(S.Fragment,{children:[Z>0&&ce===M&&f.jsx("div",{className:"section-title changes-sub",children:"tests"}),f.jsx($u,{f:B,id:tn(ce),active:Gt(ce,Ke(ce)),selected:Sn(ce),checking:nn,checked:_t.includes(B.path),onOpen:je,onCheck:On?void 0:H,menu:sr,onHover:qe}),Lt(ce)]},B.path))]}),ae&&!u&&C&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":z,"data-tip":"What changed since your last message","data-tip-placement":"follow",onClick:()=>o({a:"toggle-turn"}),onKeyDown:B=>(B.key==="Enter"||B.key===" ")&&B.stopPropagation(),children:["last turn",f.jsx(St,{name:"caret",className:He("icon-inline disc-caret",!z&&"shut")})]}),q.map((B,ce)=>f.jsxs(S.Fragment,{children:[V>0&&ce===se&&f.jsx("div",{className:"section-title changes-sub",children:"tests"}),f.jsx($u,{f:B,id:tn(pe+ce),active:Gt(pe+ce,Ke(pe+ce)),selected:Sn(pe+ce),onOpen:Be,menu:wo,onHover:qe}),Lt(pe+ce)]},`t-${B.path}`))]}),ae&&!u&&K&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",className:"section-title section-row section-fold","aria-expanded":U,"data-tip":`Committed on this branch, not yet on ${We}`,"data-tip-placement":"follow",onClick:()=>o({a:"toggle-committed"}),onKeyDown:B=>(B.key==="Enter"||B.key===" ")&&B.stopPropagation(),children:["committed",f.jsx(St,{name:"caret",className:He("icon-inline disc-caret",!U&&"shut")})]}),R.map((B,ce)=>f.jsxs(S.Fragment,{children:[$>0&&ce===I&&f.jsx("div",{className:"section-title changes-sub",children:"tests"}),f.jsx($u,{f:B,id:tn(ue+ce),active:Gt(ue+ce,Ke(ue+ce)),selected:Sn(ue+ce),onOpen:yt,menu:Mr,onHover:qe}),Lt(ue+ce)]},`c-${B.path}`))]}),ae&&!u&&he&&f.jsx("div",{className:"empty",children:bP(We,!!Pe&&jd(Pe),(y==null?void 0:y.behind)??0,Fe==null?void 0:Fe[0])}),ve&&et.map((B,ce)=>f.jsxs(S.Fragment,{children:[u&&hn.has(ce)&&f.jsx("div",{className:"section-title section-row",children:hn.get(ce)}),!u&&Wt>0&&ce===0&&f.jsx("div",{className:"section-title section-row",children:"on this branch"}),!u&&Wt>0&&ce===Qt&&f.jsx("div",{className:"section-title section-row",children:We}),B.file?f.jsxs(f.Fragment,{children:[f.jsx($u,{f:B.file,id:tn(ge+ce),active:Gt(ge+ce,Ke(ge+ce)),selected:Sn(ge+ce),onOpen:ln,menu:on,onHover:ot}),Lt(ge+ce)]}):f.jsx(rP,{c:B.commit,id:tn(ge+ce),selected:Sn(ge+ce),onToggle:xt})]},B.file?`${B.commit.sha}:${B.file.path}`:B.commit.sha)),ve&&Fe===void 0&&f.jsx("div",{className:"empty",children:"reading history…"}),ve&&(Fe==null?void 0:Fe.length)===0&&E.length===0&&f.jsx("div",{className:"empty",children:"no commits yet"})]}),nn&&f.jsxs("div",{className:"changes-pick",children:[f.jsxs(ze,{size:"md",tone:"danger",disabled:fe.length===0,"data-tip":"Throw away the uncommitted changes to every checked file",onClick:()=>{!mn||fe.length===0||window.confirm(E1(fe))&&(r==null||r.send({t:"discard-files",worktreeId:mn,paths:fe}),Rn())},children:["discard ",fe.length,"…"]}),f.jsx(ze,{size:"md",disabled:fe.length===0,"data-tip":"Name every checked file in the chat",onClick:()=>{mn&&BM(a,mn,fe),Rn()},children:"add to chat"}),f.jsx(At,{icon:"close",label:"Cancel",hint:"esc",onClick:Rn})]}),Pe&&!u&&f.jsx(nP,{active:Pe,ahead:(y==null?void 0:y.ahead)??0,behind:(y==null?void 0:y.behind)??0,unpushed:(y==null?void 0:y.unpushed)??Pe.unpushed??0,dirty:!de})]})}function r0(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 yc(e){return e>0&&e<.005?"<$0.01":`$${e.toFixed(2)}`}function xP(e){const t=`${Math.round(100*e)}% full`;return e<.5?`${t}: plenty of room, no need yet`:e<.8?`${t}: worth doing between tasks`:`${t}: do it before the next task`}function _P(e){if(!(e<.5))return e<.8?"worth compacting between tasks":"compact before the next task"}function EP(e){const t=e.auto?"Auto archived":"Archived",n=e.auto?"Merged, auto archived":"Merged",r=e.landed?n:e.uncommitted?`${t} with uncommitted changes`:t;return e.restorable?r:`${r}, commits not kept`}function c_(e){const t=[e.landed?"merged":e.uncommitted?"uncommitted changes":null];return e.restorable||t.push("commits not kept"),e.cost!==void 0&&t.push(yc(e.cost)),t.push(ro(e.archivedAt)),t.filter(Boolean).join(" · ")}function u_(e,t,n){e==null||e.send({t:"restore-worktree",archiveId:t,clientId:n})}function Vu(e,t,{sock:n,dispatch:r}){const o=[{id:"restore",label:"restore",disabled:e.restorable?void 0:"its commits were not kept",onClick:()=>{u_(n,e.id,t.clientId),r({a:"close"})}}],a=[{id:"copy-branch",label:"copy branch name",onClick:()=>Zt(e.branch)}],{sessionId:l}=e;return t.frame!=="phone"&&(a.push({id:"copy-transcript",label:"copy transcript path",onClick:()=>Zt(e.transcript)}),l&&a.push({id:"copy-session",label:"copy session id",onClick:()=>Zt(l)})),Dn([o,a,[{id:"delete",label:"delete for good…",danger:!0,onClick:()=>{window.confirm(`Delete "${e.title}" for good?
123
+
124
+ Its chat, attachments and kept commits are deleted, and it can no longer be restored.`)&&(n==null||n.send({t:"delete-archived",archiveId:e.id}))}}]])}const SP=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function d_(e){const[t,n]=S.useState(()=>Date.now());return S.useEffect(()=>{const r=setInterval(()=>n(Date.now()),6e4);return()=>clearInterval(r)},[]),`${Hx(t-e)} ago`}function Fs({icon:e,word:t,tone:n,at:r,below:o,children:a,...l}){const u=r!==void 0?{"data-tip":`${t} ${SP.format(r)}`,"data-tip-placement":"follow"}:null;return f.jsxs("div",{...u,...l,className:"daemon-row row-edge","data-tone":n,children:[f.jsxs("div",{className:"daemon-head",children:[f.jsxs("span",{className:"daemon-tag",children:[f.jsx(St,{name:e,className:"icon-inline"}),t]}),a]}),o]})}function NP({item:e}){const t=it(),n=L(u=>u.clientId),r=e.uncommitted?"its chat, commits and uncommitted changes":"its chat and commits",o=e.cost!==void 0?`; the session cost ${yc(e.cost)}`:"",a=e.restorable?`Toyon kept ${r}${o}. A message sent below restores it first.`:`Its commits were not kept, so there is nothing to restore${o}; its row's menu on the rail can delete it for good.`,l=d_(e.archivedAt);return f.jsxs(Fs,{icon:"archive",word:"archived",tone:"quiet",at:e.archivedAt,below:f.jsx("div",{className:"daemon-below row-dim",children:a}),children:[f.jsxs("span",{className:"daemon-text",children:[l,e.landed?", after it was merged into main":""]}),e.restorable&&f.jsx(ze,{variant:"inline",tone:"strong",onClick:()=>u_(t,e.id,n),children:"restore"})]})}function Ra(e,t,n,r,o){const{layout:a}=e.getState();nr({dispatch:e.dispatch},{worktreeId:n,path:r,view:"file",line:{n:o,fiber:!0}}),a.changes||e.dispatch({a:"toggle-changes"})}function TP(e){let t=0;return e.map(n=>{const r={start:t,len:n};return t+=n,r})}function jP(e,t){if(!t)return[];const n=new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"giu"),r=[];for(const o of e.matchAll(n))r.push({start:o.index,end:o.index+o[0].length});return r}function o0(e,t,n){let r=0,o=e.length-1;for(;r<o;){const l=r+o>>1,u=e[l];(n?t>u.start+u.len:t>=u.start+u.len)?r=l+1:o=l}const a=e[r];return{i:r,at:t-a.start}}function CP(e,t){return{from:o0(e,t.start,!1),to:o0(e,t.end,!0)}}function s0(e,t){if(e.length===0)return-1;const n=e.findIndex(r=>r.start>=t);return n===-1?0:n}function AP(e,t,n){return t===0?-1:(e+n+t)%t}function fg(e){return e.key==="f"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function IP({label:e,query:t,onQuery:n,seed:r,seq:o,status:a,none:l,onStep:u,onClose:c}){const p=S.useRef(null);return gt([o],()=>{var m,h;r&&n(r),(m=p.current)==null||m.focus(),(h=p.current)==null||h.select()}),f.jsxs("div",{className:"find",children:[f.jsx(Mo,{ref:p,autoFocus:!0,value:t,onChange:m=>n(m.target.value),placeholder:"find…","aria-label":e,className:"find-field",spellCheck:!1,onKeyDown:m=>{if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),c();return}if(m.key==="Enter"){m.preventDefault(),u(m.shiftKey?-1:1);return}if(fg(m)){m.preventDefault(),m.stopPropagation(),m.currentTarget.select();return}m.key.toLowerCase()==="g"&&(m.metaKey||m.ctrlKey)&&!m.altKey&&(m.preventDefault(),m.stopPropagation(),u(m.shiftKey?-1:1))}}),f.jsx("span",{className:"find-count","aria-live":"polite",children:a}),f.jsx(At,{icon:"caret",label:"Previous match",hint:"⇧↩",className:"find-prev",disabled:l,onClick:()=>u(-1)}),f.jsx(At,{icon:"caret",label:"Next match",hint:"↩",disabled:l,onClick:()=>u(1)}),f.jsx(At,{icon:"close",label:"Close",hint:"esc",onClick:c})]})}const f_="find",p_="find-current",h_=typeof CSS<"u"&&"highlights"in CSS;function RP(e){const t=e.parentElement;return t?typeof t.checkVisibility=="function"?t.checkVisibility():!0:!1}function OP(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[];for(let r=t.nextNode();r;r=t.nextNode()){const o=r;o.data.length>0&&RP(o)&&n.push(o)}return n}const Wh={matches:[],ranges:[]};function $P(e,t){if(!t)return Wh;const n=OP(e),r=jP(n.map(l=>l.data).join(""),t),o=TP(n.map(l=>l.data.length)),a=r.map(l=>{const{from:u,to:c}=CP(o,l),p=document.createRange();return p.setStart(n[u.i],u.at),p.setEnd(n[c.i],c.at),p});return{matches:r,ranges:a}}function MP(e,t){h_&&(CSS.highlights.set(f_,new Highlight(...e.filter((n,r)=>r!==t))),CSS.highlights.set(p_,new Highlight(...e[t]?[e[t]]:[])))}function LP(){h_&&(CSS.highlights.delete(f_),CSS.highlights.delete(p_))}function PP(e,t){if(e.length===0)return-1;const n=t.getBoundingClientRect().top,r=e.findIndex(o=>o.getBoundingClientRect().bottom>=n);return r===-1?0:r}const i0=48;function DP(e,t){const n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.top>=r.top+i0&&n.bottom<=r.bottom-i0||(e.scrollTop+=n.top-r.top-r.height/3)}function m_({root:e,body:t,seed:n,seq:r,onClose:o}){const[a,l]=S.useState(n),[u,c]=S.useState(Wh),[p,m]=S.useState(-1),h=S.useRef({found:Wh,at:-1}),k=S.useRef(""),y=S.useRef(!1),[v,x]=S.useState(0);S.useLayoutEffect(()=>{const E=t.current;if(!E)return;let M=0;const K=new MutationObserver(()=>{M||(M=requestAnimationFrame(()=>{M=0,x(U=>U+1)}))});return K.observe(E,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),()=>{K.disconnect(),M&&cancelAnimationFrame(M)}},[t]),S.useLayoutEffect(()=>{const E=t.current;if(!E)return;const M=$P(E,a),K=a!==k.current;k.current=a,K&&(y.current=!0);const{found:U,at:R}=h.current;let I;K?U.matches[R]?I=s0(M.matches,U.matches[R].start):I=e.current?PP(M.ranges,e.current):s0(M.matches,0):I=Math.min(R,M.matches.length-1),h.current={found:M,at:I},c(M),m(I)},[a,v]),S.useLayoutEffect(()=>{MP(u.ranges,p);const E=u.ranges[p];E&&(y.current&&e.current&&DP(e.current,E),y.current=!1)},[u,p,e]),S.useLayoutEffect(()=>LP,[]);const _=u.matches.length,N=E=>{if(_===0)return;y.current=!0;const M=AP(h.current.at,_,E);h.current={...h.current,at:M},m(M)},j=()=>o(u.ranges[p]??null);return f.jsx(IP,{label:"find in this document",query:a,onQuery:l,seed:n,seq:r,status:a?_===0?"no matches":`${p+1}/${_}`:"",none:_===0,onStep:N,onClose:j})}function g_(e){return e.key==="a"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function k_(e,t,n,r){S.useEffect(()=>{let o=!1;const a=u=>{o=!!e.current&&u.target instanceof Node&&e.current.contains(u.target)},l=u=>{const c=e.current;if(!c||u.defaultPrevented||!t(u))return;const p=document.activeElement;!(p&&p!==document.body?c.contains(p):o)&&!(r!=null&&r(p))||(u.preventDefault(),n(c,u))};return window.addEventListener("pointerdown",a,!0),window.addEventListener("keydown",l),()=>{window.removeEventListener("pointerdown",a,!0),window.removeEventListener("keydown",l)}},[e,t,n,r])}function zP(e){k_(e,g_,y_)}function Kh(e){const t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount===0||!e.contains(t.getRangeAt(0).commonAncestorContainer))return null;const n=t.toString().replace(/^\n+|\n+$/g,"");return n.trim()?n:null}function y_(e){const t=document.createRange();t.selectNodeContents(e);const n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}const w_=({open:e,remove:t})=>[e?[{id:"open",label:"open full size",onClick:e}]:[],t?[{id:"remove",label:"remove",onClick:t}]:[]];function rc(e,t={}){return Dn([[{id:"copy-image",label:"copy image",onClick:()=>xM(e)}],...w_(t)])}function v_(e,t={}){const{text:n,href:r}=e;return Dn([n!==void 0?[{id:"copy-text",label:"copy text",onClick:()=>Zt(n)}]:r?[{id:"copy-text",label:"copy text",onClick:()=>bM(r)}]:[],...w_(t)])}function FP(e){return[v1(e),{id:"copy-link",label:"copy link",onClick:()=>Zt(e)}]}function Zh(e){return e?[{id:"copy-code",label:"copy code",onClick:()=>Zt(e)}]:[]}function xl(e,t,{dispatch:n,sock:r},o={}){const a=o.link,l=(a==null?void 0:a.kind)==="file"&&t?()=>r==null?void 0:r.send({t:"reveal",worktreeId:t,path:a.file.path}):void 0,u=a?a.kind==="file"?md(a.file.path,o.dir??null,l):a.kind==="path"||a.kind==="outside"?md(a.path,o.dir??null):[FP(a.href)]:[],c=[{id:"copy",label:"copy message",onClick:()=>Zt(e.text)}],p=[];return e.kind==="user"&&t&&p.push({id:"draft",label:"edit in composer",onClick:()=>{const m=e.seq;if(m===void 0||!r)return n({a:"set-draft",id:t,text:e.text});n({a:"set-draft",id:t,text:""}),r.send({t:"redraft",worktreeId:t,seq:m})}}),Dn([Zh(o.code),...u,c,p])}function md(e,t,n){const r=e.startsWith("/")?e:t?`${t}/${e}`:null;return[r?Ii(r,n):[],[{id:"copy-path",label:"copy path",onClick:()=>Zt(e)}]]}function BP(e,t){return Dn(md(e,t))}function UP(e,t={}){const n=e.callFile??e.file,r=n?md(n,t.dir??null):[],o=t.remove?[{id:"remove",label:"remove",onClick:t.remove}]:[];return Dn([...r,o])}const a0=8,HP=.7,WP=100,KP=400,ZP=260,qP=80,GP=220;function l0({dx:e,dy:t}){return Math.abs(e)<a0&&Math.abs(t)<a0?null:Math.abs(t)>Math.abs(e)?"away":"other"}function VP(e,t){const n=e.filter(a=>t-a.t<=WP),r=n[0],o=n[n.length-1];return!r||!o||o.t===r.t?0:(o.y-r.y)/(o.t-r.t)}const YP=e=>Math.abs(e)>=HP;function QP(e,t){return Math.min(GP,Math.max(qP,e/Math.abs(t)))}function XP(e,t,n){const r=S.useRef(n);r.current=n,S.useEffect(()=>{const o=e.current;if(!o)return;let a=null,l=!1,u=[],c=0;const p=(x,_,N)=>{N!==void 0&&o.style.setProperty("--swipe-ms",`${N}ms`),o.dataset.swipe!==_&&(o.dataset.swipe=_,o.offsetWidth),o.style.setProperty("--swipe-y",`${x}px`),o.style.setProperty("--swipe-fade",`${Math.min(1,Math.abs(x)/(window.innerHeight/2))}`)},m=()=>{o.style.removeProperty("--swipe-y"),o.style.removeProperty("--swipe-fade"),o.style.removeProperty("--swipe-ms"),delete o.dataset.swipe},h=()=>{const x=l;a=null,l=!1,u=[],x&&(p(0,"settle"),c=window.setTimeout(m,ZP))},k=x=>{var j;const _=x.touches[0],N=x.target;if(x.touches.length!==1||!_||(((j=window.visualViewport)==null?void 0:j.scale)??1)>1.01)return h();o.dataset.swipe==="leave"||!(N===o||N!=null&&N.closest(t))||(window.clearTimeout(c),a={x:_.clientX,y:_.clientY,at:x.timeStamp},u=[{y:_.clientY,t:x.timeStamp}])},y=x=>{const _=x.touches[0];if(!a||!_)return;const N=_.clientX-a.x,j=_.clientY-a.y;if(!l){const E=l0({dx:N,dy:j});if(E==="other"&&(a=null),E!=="away")return;l=!0}x.preventDefault(),u.push({y:_.clientY,t:x.timeStamp}),u.length>16&&u.shift(),p(j,"drag")},v=x=>{const _=x.changedTouches[0];if(!a||!_)return;const N=_.clientY-a.y,j=x.timeStamp-a.at;if(!l&&j<KP&&x.target!==o&&l0({dx:_.clientX-a.x,dy:N})===null){x.preventDefault(),a=null,r.current();return}const M=VP(u,x.timeStamp);if(!l||!YP(M))return h();a=null,l=!1,u=[];const K=Math.sign(M)*window.innerHeight,U=QP(Math.abs(K-N),M);p(K,"leave",U),c=window.setTimeout(()=>r.current(),U)};return o.addEventListener("touchstart",k,{passive:!0}),o.addEventListener("touchmove",y,{passive:!1}),o.addEventListener("touchend",v),o.addEventListener("touchcancel",h),()=>{window.clearTimeout(c),o.removeEventListener("touchstart",k),o.removeEventListener("touchmove",y),o.removeEventListener("touchend",v),o.removeEventListener("touchcancel",h)}},[e,t])}function pg({owner:e,onClose:t,menu:n,children:r}){const o=sn(e),a=S.useRef(null);return XP(a,"img",t),f.jsxs(Ys,{className:"attach-full scrim",boxRef:a,onDismiss:t,onKey:l=>{l.key==="Escape"&&(l.stopPropagation(),t())},onClick:l=>{l.target===l.currentTarget&&t()},...n&&o.contextMenu(n),children:[r,f.jsx(At,{icon:"close",label:"Close",tone:"quiet",onClick:t})]})}/*! @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 c0(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function JP(e){if(Array.isArray(e))return e}function e4(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,a,l,u=[],c=!0,p=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(u.push(r.value),u.length!==t);c=!0);}catch(m){p=!0,o=m}finally{try{if(!c&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(p)throw o}}return u}}function t4(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
125
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function n4(e,t){return JP(e)||e4(e,t)||r4(e,t)||t4()}function r4(e,t){if(e){if(typeof e=="string")return c0(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)?c0(e,t):void 0}}const b_=Object.entries,u0=Object.setPrototypeOf,o4=Object.isFrozen,s4=Object.getPrototypeOf,i4=Object.getOwnPropertyDescriptor;let ur=Object.freeze,mr=Object.seal,ha=Object.create,x_=typeof Reflect<"u"&&Reflect,qh=x_.apply,Gh=x_.construct;ur||(ur=function(t){return t});mr||(mr=function(t){return t});qh||(qh=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),a=2;a<r;a++)o[a-2]=arguments[a];return t.apply(n,o)});Gh||(Gh=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});const wi=or(Array.prototype.forEach),a4=or(Array.prototype.lastIndexOf),d0=or(Array.prototype.pop),_l=or(Array.prototype.push),l4=or(Array.prototype.splice),Ea=Array.isArray,Il=or(String.prototype.toLowerCase),eh=or(String.prototype.toString),f0=or(String.prototype.match),El=or(String.prototype.replace),p0=or(String.prototype.indexOf),c4=or(String.prototype.trim),u4=or(Number.prototype.toString),d4=or(Boolean.prototype.toString),h0=typeof BigInt>"u"?null:or(BigInt.prototype.toString),m0=typeof Symbol>"u"?null:or(Symbol.prototype.toString),Kr=or(Object.prototype.hasOwnProperty),Sl=or(Object.prototype.toString),Sr=or(RegExp.prototype.test),yi=f4(TypeError);function or(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return qh(e,t,r)}}function f4(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Gh(e,n)}}function en(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Il;if(u0&&u0(e,null),!Ea(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const a=n(o);a!==o&&(o4(t)||(t[r]=a),o=a)}e[o]=!0}return e}function p4(e){for(let t=0;t<e.length;t++)Kr(e,t)||(e[t]=null);return e}function no(e){const t=ha(null);for(const r of b_(e)){var n=n4(r,2);const o=n[0],a=n[1];Kr(e,o)&&(Ea(a)?t[o]=p4(a):a&&typeof a=="object"&&a.constructor===Object?t[o]=no(a):t[o]=a)}return t}function h4(e){switch(typeof e){case"string":return e;case"number":return u4(e);case"boolean":return d4(e);case"bigint":return h0?h0(e):"0";case"symbol":return m0?m0(e):"Symbol()";case"undefined":return Sl(e);case"function":case"object":{if(e===null)return Sl(e);const t=e,n=Ao(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Sl(r)}return Sl(e)}default:return Sl(e)}}function Ao(e,t){for(;e!==null;){const r=i4(e,t);if(r){if(r.get)return or(r.get);if(typeof r.value=="function")return or(r.value)}e=s4(e)}function n(){return null}return n}function m4(e){try{return Sr(e,""),!0}catch{return!1}}const g0=ur(["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"]),th=ur(["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"]),nh=ur(["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"]),g4=ur(["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"]),rh=ur(["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"]),k4=ur(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),k0=ur(["#text"]),y0=ur(["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"]),oh=ur(["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"]),w0=ur(["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"]),Pu=ur(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),y4=mr(/{{[\w\W]*|^[\w\W]*}}/g),w4=mr(/<%[\w\W]*|^[\w\W]*%>/g),v4=mr(/\${[\w\W]*/g),b4=mr(/^data-[\-\w.\u00B7-\uFFFF]+$/),x4=mr(/^aria-[\-\w]+$/),v0=mr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),_4=mr(/^(?:\w+script|data):/i),E4=mr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),S4=mr(/^html$/i),N4=mr(/^[a-z][.\w]*(-[.\w]+)+$/i),b0=mr(/<[/\w!]/g),x0=mr(/<[/\w]/g),T4=mr(/<\/no(script|embed|frames)/i),j4=mr(/\/>/i),to={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},__=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],C4=ur(en({},__)),A4=(function(){const e={};return wi(__,t=>{e[t]=mr(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),ur(e)})(),I4=function(){return typeof window>"u"?null:window},R4=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},_0=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},$s=function(t,n,r,o){return Kr(t,n)&&Ea(t[n])?en(o.base?no(o.base):{},t[n],o.transform):r},sh=function(t,n,r){const o=Kr(t,n)?t[n]:void 0;return o&&typeof o=="object"?no(o):r()};function E_(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:I4();const t=Ee=>E_(Ee);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==to.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript;e.DocumentFragment;const a=e.HTMLTemplateElement,l=e.Node,u=e.Element,c=e.NodeFilter,p=e.NamedNodeMap;p===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const m=e.DOMParser,h=e.trustedTypes,k=u.prototype,y=Ao(k,"cloneNode"),v=Ao(k,"remove"),x=Ao(k,"nextSibling"),_=Ao(k,"childNodes"),N=Ao(k,"parentNode"),j=Ao(k,"shadowRoot"),E=Ao(k,"attributes"),M=l&&l.prototype?Ao(l.prototype,"nodeType"):null,K=l&&l.prototype?Ao(l.prototype,"nodeName"):null,U=l&&l.prototype?Ao(l.prototype,"ownerDocument"):null,R=function(O){return M?M(O):O.nodeType},I=function(O){return K?K(O):O.nodeName};if(typeof a=="function"){const Ee=n.createElement("template");Ee.content&&Ee.content.ownerDocument&&(n=Ee.content.ownerDocument)}let C,P="",z,q=!1,se=0;const pe=function(){if(se>0)throw yi('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.')},ue=function(O){pe(),se++;try{return C.createHTML(O)}finally{se--}},xe=function(O){pe(),se++;try{return C.createScriptURL(O)}finally{se--}},oe=function(){return q||(z=R4(h,o),q=!0),z},A=n,X=A.implementation,Z=A.createNodeIterator,$=A.createDocumentFragment,V=A.getElementsByTagName,de=r.importNode;let me=_0();t.isSupported=typeof b_=="function"&&typeof N=="function"&&X&&X.createHTMLDocument!==void 0;const he=y4,$e=w4,ae=v4,ve=b4,Re=x4,ee=_4,Y=E4,Pe=N4;let We=v0,Fe=null;const pt=en({},[...g0,...th,...nh,...rh,...k0]);let Ge=null;const vt=en({},[...y0,...oh,...w0,...Pu]);let at=Object.seal(ha(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),qt=null,an=null;const qe=Object.seal(ha(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let J=!0,we=!0,Xe=!1,et=!0,Wt=!1,Qt=!0,ge=!1,Me=!1,hn=null,It=null,Rt=!1,In=!1,Dt=!1,gn=!1,kt=!0,Gt=!1;const tn="user-content-";let nn=!0,Un=!1,_t={},Kt=null;const Rn=en({},["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 H=null;const fe=en({},["audio","video","img","source","image","track"]);let Ie=null;const rt=en({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),te="http://www.w3.org/1998/Math/MathML",Ne="http://www.w3.org/2000/svg",be="http://www.w3.org/1999/xhtml";let _e=be,Oe=!1,Mt=null;const Tt=en({},[te,Ne,be],eh),ht=ur(["mi","mo","mn","ms","mtext"]);let wn=en({},ht);const Ke=ur(["annotation-xml"]);let Kn=en({},Ke);const Nt=en({},["title","style","font","a","script"]);let Sn=null;const Nn=["application/xhtml+xml","text/html"],Hn="text/html";let Lt=null,Xt=null;const mn=n.createElement("form"),Gn=function(O){return O instanceof RegExp||O instanceof Function},On=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Xt&&Xt===O)return;(!O||typeof O!="object")&&(O={}),O=no(O),Sn=Nn.indexOf(O.PARSER_MEDIA_TYPE)===-1?Hn:O.PARSER_MEDIA_TYPE,Lt=Sn==="application/xhtml+xml"?eh:Il,Fe=$s(O,"ALLOWED_TAGS",pt,{transform:Lt}),Ge=$s(O,"ALLOWED_ATTR",vt,{transform:Lt}),Mt=$s(O,"ALLOWED_NAMESPACES",Tt,{transform:eh}),Ie=$s(O,"ADD_URI_SAFE_ATTR",rt,{transform:Lt,base:rt}),H=$s(O,"ADD_DATA_URI_TAGS",fe,{transform:Lt,base:fe}),Kt=$s(O,"FORBID_CONTENTS",Rn,{transform:Lt}),qt=$s(O,"FORBID_TAGS",no({}),{transform:Lt}),an=$s(O,"FORBID_ATTR",no({}),{transform:Lt}),_t=Kr(O,"USE_PROFILES")?O.USE_PROFILES&&typeof O.USE_PROFILES=="object"?no(O.USE_PROFILES):O.USE_PROFILES:!1,J=O.ALLOW_ARIA_ATTR!==!1,we=O.ALLOW_DATA_ATTR!==!1,Xe=O.ALLOW_UNKNOWN_PROTOCOLS||!1,et=O.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Wt=O.SAFE_FOR_TEMPLATES||!1,Qt=O.SAFE_FOR_XML!==!1,ge=O.WHOLE_DOCUMENT||!1,In=O.RETURN_DOM||!1,Dt=O.RETURN_DOM_FRAGMENT||!1,gn=O.RETURN_TRUSTED_TYPE||!1,Rt=O.FORCE_BODY||!1,kt=O.SANITIZE_DOM!==!1,Gt=O.SANITIZE_NAMED_PROPS||!1,nn=O.KEEP_CONTENT!==!1,Un=O.IN_PLACE||!1,We=m4(O.ALLOWED_URI_REGEXP)?O.ALLOWED_URI_REGEXP:v0,_e=typeof O.NAMESPACE=="string"?O.NAMESPACE:be,wn=sh(O,"MATHML_TEXT_INTEGRATION_POINTS",()=>en({},ht)),Kn=sh(O,"HTML_INTEGRATION_POINTS",()=>en({},Ke));const D=sh(O,"CUSTOM_ELEMENT_HANDLING",()=>ha(null));if(at=ha(null),Kr(D,"tagNameCheck")&&Gn(D.tagNameCheck)&&(at.tagNameCheck=D.tagNameCheck),Kr(D,"attributeNameCheck")&&Gn(D.attributeNameCheck)&&(at.attributeNameCheck=D.attributeNameCheck),Kr(D,"allowCustomizedBuiltInElements")&&typeof D.allowCustomizedBuiltInElements=="boolean"&&(at.allowCustomizedBuiltInElements=D.allowCustomizedBuiltInElements),mr(at),Wt&&(we=!1),Dt&&(In=!0),_t&&(Fe=en({},k0),Ge=ha(null),_t.html===!0&&(en(Fe,g0),en(Ge,y0)),_t.svg===!0&&(en(Fe,th),en(Ge,oh),en(Ge,Pu)),_t.svgFilters===!0&&(en(Fe,nh),en(Ge,oh),en(Ge,Pu)),_t.mathMl===!0&&(en(Fe,rh),en(Ge,w0),en(Ge,Pu))),qe.tagCheck=null,qe.attributeCheck=null,Kr(O,"ADD_TAGS")&&(typeof O.ADD_TAGS=="function"?qe.tagCheck=O.ADD_TAGS:Ea(O.ADD_TAGS)&&(Fe===pt&&(Fe=no(Fe)),en(Fe,O.ADD_TAGS,Lt))),Kr(O,"ADD_ATTR")&&(typeof O.ADD_ATTR=="function"?qe.attributeCheck=O.ADD_ATTR:Ea(O.ADD_ATTR)&&(Ge===vt&&(Ge=no(Ge)),en(Ge,O.ADD_ATTR,Lt))),Kr(O,"ADD_FORBID_CONTENTS")&&Ea(O.ADD_FORBID_CONTENTS)&&(Kt===Rn&&(Kt=no(Kt)),en(Kt,O.ADD_FORBID_CONTENTS,Lt)),nn&&(Fe["#text"]=!0),ge&&en(Fe,["html","head","body"]),Fe.table&&(en(Fe,["tbody"]),delete qt.tbody),O.TRUSTED_TYPES_POLICY){if(typeof O.TRUSTED_TYPES_POLICY.createHTML!="function")throw yi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof O.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw yi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const ne=C;C=O.TRUSTED_TYPES_POLICY;try{P=ue("")}catch(ke){throw C=ne,ke}}else O.TRUSTED_TYPES_POLICY===null?(C=void 0,P=""):(C===void 0&&(C=oe()),C&&typeof P=="string"&&(P=ue("")));ur&&ur(O),Xt=O},sr=en({},[...th,...nh,...g4]),Mr=en({},[...rh,...k4]),wo=function(O,D,ne){return D.namespaceURI===be?O==="svg":D.namespaceURI===te?O==="svg"&&(ne==="annotation-xml"||wn[ne]):!!sr[O]},on=function(O,D,ne){return D.namespaceURI===be?O==="math":D.namespaceURI===Ne?O==="math"&&Kn[ne]:!!Mr[O]},Do=function(O,D,ne){return D.namespaceURI===Ne&&!Kn[ne]||D.namespaceURI===te&&!wn[ne]?!1:!Mr[O]&&(Nt[O]||!sr[O])},so=function(O){let D=N(O);(!D||!D.tagName)&&(D={namespaceURI:_e,tagName:"template"});const ne=Il(O.tagName),ke=Il(D.tagName);return Mt[O.namespaceURI]?O.namespaceURI===Ne?wo(ne,D,ke):O.namespaceURI===te?on(ne,D,ke):O.namespaceURI===be?Do(ne,D,ke):!!(Sn==="application/xhtml+xml"&&Mt[O.namespaceURI]):!1},Zn=function(O){_l(t.removed,{element:O});try{N(O).removeChild(O)}catch{if(v(O),!N(O))throw yi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Vn=function(O,D,ne){try{O.removeAttributeNode(D)}catch{try{O.removeAttribute(ne)}catch{}}},je=function(O){xt(O);const D=_(O);if(D){const ke=[];wi(D,Ce=>{_l(ke,Ce)}),wi(ke,Ce=>{try{v(Ce)}catch{}})}const ne=E(O);if(ne)for(let ke=ne.length-1;ke>=0;--ke){const Ce=ne[ke],Ue=Ce&&Ce.name;typeof Ue=="string"&&Vn(O,Ce,Ue)}},Be=function(O,D,ne){if(!ne)try{ne=D.getAttributeNode(O)}catch{ne=null}_l(t.removed,{attribute:ne||null,from:D});try{ne?D.removeAttributeNode(ne):D.removeAttribute(O)}catch{try{D.removeAttribute(O)}catch{}}if(O==="is")if(In||Dt)try{Zn(D)}catch{}else try{D.setAttribute(O,"")}catch{}},yt=function(O){const D=E(O);if(D)for(let ne=D.length-1;ne>=0;--ne){const ke=D[ne],Ce=ke&&ke.name;typeof Ce!="string"||Ge[Lt(Ce)]||Vn(O,ke,Ce)}},xt=function(O){const D=[O];for(;D.length>0;){const ne=D.pop();R(ne)===to.element&&yt(ne);const Ce=_(ne);if(Ce)for(let Ue=Ce.length-1;Ue>=0;--Ue)D.push(Ce[Ue])}},ln=function(O,D){return Qt?O==="patchsrc"?!0:O==="for"&&D!=="label"&&D!=="output":!1},ot=function(O){if(!Qt)return;const D=[O];for(;D.length>0;){const ne=D.pop(),ke=R(ne);if(ke===to.processingInstruction||ke===to.comment&&Sr(x0,ne.data)){try{v(ne)}catch{}continue}if(ke===to.element){const Ue=ne,wt=Lt(I(ne));try{Ue.hasAttribute&&Ue.hasAttribute("patchsrc")&&Ue.removeAttribute("patchsrc"),Ue.hasAttribute&&Ue.hasAttribute("for")&&ln("for",wt)&&Ue.removeAttribute("for")}catch{}}const Ce=_(ne);if(Ce)for(let Ue=Ce.length-1;Ue>=0;--Ue)D.push(Ce[Ue])}},B=function(O){let D=null,ne=null;if(Rt)O="<remove></remove>"+O;else{const Ue=f0(O,/^[\r\n\t ]+/);ne=Ue&&Ue[0]}Sn==="application/xhtml+xml"&&_e===be&&(O='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+O+"</body></html>");const ke=C?ue(O):O;if(_e===be)try{D=new m().parseFromString(ke,Sn)}catch{}if(!D||!D.documentElement){D=X.createDocument(_e,"template",null);try{D.documentElement.innerHTML=Oe?P:ke}catch{}}const Ce=D.body||D.documentElement;return O&&ne&&Ce.insertBefore(n.createTextNode(ne),Ce.childNodes[0]||null),_e===be?V.call(D,ge?"html":"body")[0]:ge?D.documentElement:Ce},ce=function(O){const D=U?U(O):O.ownerDocument;return Z.call(D||O,O,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},De=function(O){return O=El(O,he," "),O=El(O,$e," "),O=El(O,ae," "),O},lt=function(O){var D;O.normalize();const ne=U?U(O):O.ownerDocument,ke=Z.call(ne||O,O,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let Ce=ke.nextNode();for(;Ce;)Ce.data=De(Ce.data),Ce=ke.nextNode();const Ue=(D=O.querySelectorAll)===null||D===void 0?void 0:D.call(O,"template");Ue&&wi(Ue,wt=>{Bt(wt.content)&&lt(wt.content)})},ut=function(O){const D=K?K(O):null;return typeof D!="string"||Lt(D)!=="form"?!1:typeof O.nodeName!="string"||typeof O.textContent!="string"||typeof O.removeChild!="function"||O.attributes!==E(O)||typeof O.removeAttribute!="function"||typeof O.setAttribute!="function"||typeof O.namespaceURI!="string"||typeof O.insertBefore!="function"||typeof O.hasChildNodes!="function"||O.nodeType!==M(O)||O.childNodes!==_(O)},Bt=function(O){if(!M||typeof O!="object"||O===null)return!1;try{return M(O)===to.documentFragment}catch{return!1}},kn=function(O){if(!M||typeof O!="object"||O===null)return!1;try{return typeof M(O)=="number"}catch{return!1}};function vn(Ee,O,D){Ee.length!==0&&wi(Ee,ne=>{ne.call(t,O,D,Xt)})}const Lr=function(O,D){return!!(Qt&&O.hasChildNodes()&&!kn(O.firstElementChild)&&Sr(b0,O.textContent)&&Sr(b0,O.innerHTML)||Qt&&O.namespaceURI===be&&C4[D]&&(kn(O.firstElementChild)||typeof O.textContent=="string"&&Sr(A4[D],O.textContent))||O.nodeType===to.processingInstruction||Qt&&O.nodeType===to.comment&&Sr(x0,O.data))},Vr=function(O,D){if(O instanceof RegExp)return Sr(O,D);if(O instanceof Function){for(var ne=arguments.length,ke=new Array(ne>2?ne-2:0),Ce=2;Ce<ne;Ce++)ke[Ce-2]=arguments[Ce];return!!O(D,...ke)}return!1},vo=function(O,D,ne){if(!qt[D]&&tt(D)&&Vr(at.tagNameCheck,D))return!1;if(nn&&!Kt[D]){const ke=N(O),Ce=_(O);if(Ce&&ke){const Ue=Ce.length;for(let wt=Ue-1;wt>=0;--wt){const cn=O===ne?y(Ce[wt],!0):Ce[wt];ke.insertBefore(cn,x(O))}}}return Zn(O),!0},wr=function(O,D,ne,ke){return O.length===0?D:D===ne||D===ke?no(D):D},Pr=function(O,D){return O===D||N(O)!==null?!1:(Un&&xt(O),!0)},Yn=function(O,D){if(vn(me.beforeSanitizeElements,O,null),Pr(O,D))return!0;if(ut(O))return Zn(O),!0;const ne=Lt(I(O));if(Fe=wr(me.uponSanitizeElement,Fe,pt,hn),vn(me.uponSanitizeElement,O,{tagName:ne,allowedTags:Fe}),Pr(O,D))return!0;if(Lr(O,ne))return Zn(O),!0;if(qt[ne]||!(qe.tagCheck instanceof Function&&qe.tagCheck(ne))&&!Fe[ne]){const Ce=vo(O,ne,D);return Ce===!1&&vn(me.afterSanitizeElements,O,null),Ce}if(R(O)===to.element&&!so(O)||(ne==="noscript"||ne==="noembed"||ne==="noframes")&&Sr(T4,O.innerHTML))return Zn(O),!0;if(Wt&&O.nodeType===to.text){const Ce=De(O.textContent);O.textContent!==Ce&&(_l(t.removed,{element:O.cloneNode()}),O.textContent=Ce)}return vn(me.afterSanitizeElements,O,null),!1},bo=function(O,D,ne){if(an[D]||ln(D,O)||kt&&(D==="id"||D==="name")&&(ne in n||ne in mn))return!1;const ke=Ge[D]||qe.attributeCheck instanceof Function&&qe.attributeCheck(D,O);return we&&Sr(ve,D)||J&&Sr(Re,D)?!0:ke?Ie[D]||Sr(We,El(ne,Y,""))||(D==="src"||D==="xlink:href"||D==="href")&&O!=="script"&&p0(ne,"data:")===0&&H[O]||Xe&&!Sr(ee,El(ne,Y,""))?!0:!ne:tt(O)&&Vr(at.tagNameCheck,O)&&Vr(at.attributeNameCheck,D,O)||D==="is"&&at.allowCustomizedBuiltInElements&&Vr(at.tagNameCheck,ne)},Pt=en({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),tt=function(O){return!Pt[Il(O)]&&Sr(Pe,O)},es=function(O,D,ne,ke){if(C&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!ne)switch(h.getAttributeType(O,D)){case"TrustedHTML":return ue(ke);case"TrustedScriptURL":return xe(ke)}return ke},bn=function(O,D,ne,ke){try{ne?O.setAttributeNS(ne,D,ke):O.setAttribute(D,ke),ut(O)?Zn(O):d0(t.removed)}catch{Be(D,O)}},Ut=function(O){vn(me.beforeSanitizeAttributes,O,null);const D=O.attributes;if(!D||ut(O))return;Ge=wr(me.uponSanitizeAttribute,Ge,vt,It);const ne={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ge,forceKeepAttr:void 0};let ke=D.length;const Ce=Lt(O.nodeName);for(;ke--;){const Ue=D[ke],wt=Ue.name,cn=Ue.namespaceURI,Vt=Ue.value,Tn=Lt(wt),ts=Vt;let $n=wt==="value"?ts:c4(ts);if(ne.attrName=Tn,ne.attrValue=$n,ne.keepAttr=!0,ne.forceKeepAttr=void 0,vn(me.uponSanitizeAttribute,O,ne),$n=ne.attrValue,Gt&&(Tn==="id"||Tn==="name")&&p0($n,tn)!==0&&(Be(wt,O,Ue),$n=tn+$n),Qt&&Sr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,$n)){Be(wt,O,Ue);continue}if(Tn==="attributename"&&f0($n,"href")){Be(wt,O,Ue);continue}if(!ne.forceKeepAttr){if(!ne.keepAttr){Be(wt,O,Ue);continue}if(!et&&Sr(j4,$n)){Be(wt,O,Ue);continue}if(Wt&&($n=De($n)),!bo(Ce,Tn,$n)){Be(wt,O,Ue);continue}$n=es(Ce,Tn,cn,$n),$n!==ts&&bn(O,wt,cn,$n)}}vn(me.afterSanitizeAttributes,O,null)},vr=function(O){let D=null;const ne=ce(O);for(vn(me.beforeSanitizeShadowDOM,O,null);D=ne.nextNode();)if(vn(me.uponSanitizeShadowNode,D,null),Yn(D,O),Ut(D),Bt(D.content)&&vr(D.content),R(D)===to.element){const ke=j(D);Bt(ke)&&(Qn(ke),vr(ke))}vn(me.afterSanitizeShadowDOM,O,null)},Qn=function(O){const D=[{node:O,shadow:null}];for(;D.length>0;){const ne=D.pop();if(ne.shadow){vr(ne.shadow);continue}const ke=ne.node,Ue=R(ke)===to.element,wt=_(ke);if(wt)for(let cn=wt.length-1;cn>=0;--cn)D.push({node:wt[cn],shadow:null});if(Ue){const cn=K?K(ke):null;if(typeof cn=="string"&&Lt(cn)==="template"){const Vt=ke.content;Bt(Vt)&&D.push({node:Vt,shadow:null})}}if(Ue){const cn=j(ke);Bt(cn)&&D.push({node:null,shadow:cn},{node:cn,shadow:null})}}};return t.sanitize=function(Ee){let O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},D=null,ne=null,ke=null,Ce=null;if(Oe=!Ee,Oe&&(Ee="<!-->"),typeof Ee!="string"&&!kn(Ee)&&(Ee=h4(Ee),typeof Ee!="string"))throw yi("dirty is not a string, aborting");if(!t.isSupported)return Ee;Me?(Fe=hn,Ge=It):On(O),(me.uponSanitizeElement.length>0||me.uponSanitizeAttribute.length>0)&&(Fe=no(Fe)),me.uponSanitizeAttribute.length>0&&(Ge=no(Ge)),t.removed=[];const Ue=Un&&typeof Ee!="string"&&kn(Ee);if(Ue){ot(Ee);const Vt=I(Ee);if(typeof Vt=="string"){const Tn=Lt(Vt);if(!Fe[Tn]||qt[Tn])throw je(Ee),yi("root node is forbidden and cannot be sanitized in-place")}if(ut(Ee))throw je(Ee),yi("root node is clobbered and cannot be sanitized in-place");try{Qn(Ee)}catch(Tn){throw je(Ee),Tn}}else if(kn(Ee))D=B("<!---->"),ne=D.ownerDocument.importNode(Ee,!0),ne.nodeType===to.element&&ne.nodeName==="BODY"||ne.nodeName==="HTML"?D=ne:D.appendChild(ne),Qn(ne);else{if(!In&&!Wt&&!ge&&Ee.indexOf("<")===-1)return C&&gn?ue(Ee):Ee;if(D=B(Ee),!D)return In?null:gn?P:""}D&&Rt&&Zn(D.firstChild);const wt=Ue?Ee:D;try{const Vt=ce(wt);for(;ke=Vt.nextNode();)Yn(ke,wt),Ut(ke),Bt(ke.content)&&vr(ke.content)}catch(Vt){throw Ue&&(je(Ee),wi(t.removed,Tn=>{Tn.element&&xt(Tn.element)})),Vt}if(Ue)return wi(t.removed,Vt=>{Vt.element&&xt(Vt.element)}),Wt&&lt(Ee),Ee;if(In){if(Wt&&lt(D),Dt)for(Ce=$.call(D.ownerDocument);D.firstChild;)Ce.appendChild(D.firstChild);else Ce=D;return(Ge.shadowroot||Ge.shadowrootmode)&&(Ce=de.call(r,Ce,!0)),Ce}let cn=ge?D.outerHTML:D.innerHTML;return ge&&Fe["!doctype"]&&D.ownerDocument&&D.ownerDocument.doctype&&D.ownerDocument.doctype.name&&Sr(S4,D.ownerDocument.doctype.name)&&(cn="<!DOCTYPE "+D.ownerDocument.doctype.name+`>
126
+ `+cn),Wt&&(cn=De(cn)),C&&gn?ue(cn):cn},t.setConfig=function(){let Ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};On(Ee),Me=!0,hn=Fe,It=Ge},t.clearConfig=function(){Xt=null,Me=!1,hn=null,It=null,C=z,P=""},t.isValidAttribute=function(Ee,O,D){Xt||On({});const ne=Lt(Ee),ke=Lt(O);return bo(ne,ke,D)},t.addHook=function(Ee,O){typeof O=="function"&&Kr(me,Ee)&&_l(me[Ee],O)},t.removeHook=function(Ee,O){if(Kr(me,Ee)){if(O!==void 0){const D=a4(me[Ee],O);return D===-1?void 0:l4(me[Ee],D,1)[0]}return d0(me[Ee])}},t.removeHooks=function(Ee){Kr(me,Ee)&&(me[Ee]=[])},t.removeAllHooks=function(){me=_0()},t}var O4=E_();function hg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Mi=hg();function S_(e){Mi=e}var vi={exec:()=>null};function fa(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),o=t[r];return o||(o=e(r),t[r]=o),o}}function Ft(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,a)=>{let l=typeof a=="string"?a:a.source;return l=l.replace(jr.caret,"$1"),n=n.replace(o,l),r},getRegex:()=>new RegExp(n,t)};return r}var $4=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),jr={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:fa(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:fa(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:fa(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:fa(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:fa(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:fa(e=>new RegExp(`^ {0,${e}}>`))},M4=/^(?:[ \t]*(?:\n|$))+/,L4=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,P4=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,wc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,D4=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,mg=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,N_=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,T_=Ft(N_).replace(/bull/g,mg).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(),z4=Ft(N_).replace(/bull/g,mg).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(),gg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,F4=/^[^\n]+/,kg=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,B4=Ft(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",kg).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),U4=Ft(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,mg).getRegex(),tf="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",yg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,H4=Ft("^ {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",yg).replace("tag",tf).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),j_=e=>Ft(gg).replace("hr",wc).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",tf).getRegex(),W4=j_(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),K4=j_(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Z4=Ft(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",K4).getRegex(),wg={blockquote:Z4,code:L4,def:B4,fences:P4,heading:D4,hr:wc,html:H4,lheading:T_,list:U4,newline:M4,paragraph:W4,table:vi,text:F4},E0=Ft("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",wc).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",tf).getRegex(),q4={...wg,lheading:z4,table:E0,paragraph:Ft(gg).replace("hr",wc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",E0).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",tf).getRegex()},G4={...wg,html:Ft(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",yg).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:vi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ft(gg).replace("hr",wc).replace("heading",` *#{1,6} *[^
127
+ ]`).replace("lheading",T_).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},V4=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Y4=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,C_=/^( {2,}|\\)\n(?!\s*$)/,Q4=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ks=/[\p{P}\p{S}]/u,Ba=/[\s\p{P}\p{S}]/u,vc=/[^\s\p{P}\p{S}]/u,X4=Ft(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ba).getRegex(),J4=/[\p{Pi}\p{Ps}"']/u,A_=/(?!~)[\p{P}\p{S}]/u,eD=/(?!~)[\s\p{P}\p{S}]/u,tD=/(?:[^\s\p{P}\p{S}]|~)/u,nD=Ft(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",$4?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),I_=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,rD=Ft(I_,"u").replace(/punct/g,ks).getRegex(),oD=Ft(I_,"u").replace(/punct/g,A_).getRegex(),sD=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,iD=Ft(sD,"u").replace(/openQuote/g,J4).replace(/punct/g,ks).getRegex(),R_="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",aD=Ft(R_,"gu").replace(/notPunctSpace/g,vc).replace(/punctSpace/g,Ba).replace(/punct/g,ks).getRegex(),lD=Ft(R_,"gu").replace(/notPunctSpace/g,tD).replace(/punctSpace/g,eD).replace(/punct/g,A_).getRegex(),cD="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",uD=Ft(cD,"gu").replace(/notPunctSpace/g,vc).replace(/punctSpace/g,Ba).replace(/punct/g,ks).getRegex(),dD=Ft("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,vc).replace(/punctSpace/g,Ba).replace(/punct/g,ks).getRegex(),fD="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",pD=Ft(fD,"gu").replace(/notPunctSpace/g,vc).replace(/punctSpace/g,Ba).replace(/punct/g,ks).getRegex(),hD=Ft(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ks).getRegex(),mD="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",gD=Ft(mD,"gu").replace(/notPunctSpace/g,vc).replace(/punctSpace/g,Ba).replace(/punct/g,ks).getRegex(),kD=Ft(/\\(punct)/,"gu").replace(/punct/g,ks).getRegex(),yD=Ft(/^<(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(),wD=Ft(yg).replace("(?:-->|$)","-->").getRegex(),vD=Ft("^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",wD).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),gd=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,bD=Ft(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",gd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),O_=Ft(/^!?\[(label)\]\[(ref)\]/).replace("label",gd).replace("ref",kg).getRegex(),$_=Ft(/^!?\[(ref)\](?:\[\])?/).replace("ref",kg).getRegex(),xD=Ft("reflink|nolink(?!\\()","g").replace("reflink",O_).replace("nolink",$_).getRegex(),S0=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,vg={_backpedal:vi,anyPunctuation:kD,autolink:yD,blockSkip:nD,br:C_,code:Y4,del:vi,delLDelim:vi,delRDelim:vi,emStrongLDelim:rD,emStrongRDelimAst:aD,emStrongRDelimUnd:dD,escape:V4,link:bD,nolink:$_,punctuation:X4,reflink:O_,reflinkSearch:xD,tag:vD,text:Q4,url:vi},_D={...vg,emStrongLDelim:iD,emStrongRDelimAst:uD,emStrongRDelimUnd:pD,link:Ft(/^!?\[(label)\]\((.*?)\)/).replace("label",gd).getRegex(),reflink:Ft(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",gd).getRegex()},Vh={...vg,emStrongRDelimAst:lD,emStrongLDelim:oD,delLDelim:hD,delRDelim:gD,url:Ft(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",S0).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:Ft(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",S0).getRegex()},ED={...Vh,br:Ft(C_).replace("{2,}","*").getRegex(),text:Ft(Vh.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Du={normal:wg,gfm:q4,pedantic:G4},Nl={normal:vg,gfm:Vh,breaks:ED,pedantic:_D},SD={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},N0=e=>SD[e];function Zo(e,t){if(t){if(jr.escapeTest.test(e))return e.replace(jr.escapeReplace,N0)}else if(jr.escapeTestNoEncode.test(e))return e.replace(jr.escapeReplaceNoEncode,N0);return e}function T0(e){try{e=encodeURI(e).replace(jr.percentDecode,"%")}catch{return null}return e}function j0(e,t){var a;let n=e.replace(jr.findPipe,(l,u,c)=>{let p=!1,m=u;for(;--m>=0&&c[m]==="\\";)p=!p;return p?"|":" |"}),r=n.split(jr.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!((a=r.at(-1))!=null&&a.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(jr.slashPipe,"|");return r}function Ms(e,t,n){let r=e.length;if(r===0)return"";let o=0;for(;o<r&&e.charAt(r-o-1)===t;)o++;return e.slice(0,r-o)}function C0(e){let t=e.split(`
128
+ `),n=t.length-1;for(;n>=0&&jr.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
129
+ `)}function ND(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function TD(e,t=0){let n=t,r="";for(let o of e)if(o===" "){let a=4-n%4;r+=" ".repeat(a),n+=a}else r+=o,n++;return r}function A0(e,t,n,r,o){let a=t.href,l=t.title||null,u=e[1].replace(o.other.outputLinkReplace,"$1"),c=e[0].charAt(0)==="!";r.state.inLink=!0;let p=r.state.linkEmitted,m=r.state.inRawBlock;r.state.linkEmitted=!1;let h=r.inlineTokens(u),k=r.state.linkEmitted;if(r.state.linkEmitted=p,r.state.inLink=!1,!c){if(k){r.state.inRawBlock=m;return}r.state.linkEmitted=!0}return{type:c?"image":"link",raw:n,href:a,title:l,text:u,tokens:h}}function jD(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
130
+ `).map(a=>{let l=a.match(n.other.beginningSpace);if(l===null)return a;let[u]=l;return u.length>=o.length?a.slice(o.length):a}).join(`
131
+ `)}var kd=class{constructor(e){jt(this,"options");jt(this,"rules");jt(this,"lexer");this.options=e||Mi}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]:C0(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=jD(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Ms(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Ms(t[0],`
132
+ `),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:Ms(t[0],`
133
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Ms(t[0],`
134
+ `).split(`
135
+ `),r="",o="",a=[];for(;n.length>0;){let l=!1,u=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))u.push(n[c]),l=!0;else if(!l)u.push(n[c]);else break;n=n.slice(c);let p=u.join(`
136
+ `),m=p.replace(this.rules.other.blockquoteSetextReplace,`
137
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
138
+ ${p}`:p,o=o?`${o}
139
+ ${m}`:m;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(m,a,!0),this.lexer.state.top=h,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 y=k,v=n.join(`
140
+ `),x=y.raw+`
141
+ `+v.replace(this.rules.other.blockquoteSetextReplace2,""),_=this.blockquote(x);a[a.length-1]=_,r=`${r}
142
+ ${v}`,o=o.substring(0,o.length-y.text.length)+_.text;break}else if((k==null?void 0:k.type)==="list"){let y=k,v=y.raw+`
143
+ `+n.join(`
144
+ `),x=this.list(v);a[a.length-1]=x,r=r.substring(0,r.length-k.raw.length)+x.raw,o=o.substring(0,o.length-y.raw.length)+x.raw,n=v.substring(a.at(-1).raw.length).split(`
145
+ `);continue}}return{type:"blockquote",raw:r,tokens:a,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let a=this.rules.other.listItemRegex(n),l=!1;for(;e;){let c=!1,p="",m="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let h=TD(t[2].split(`
146
+ `,1)[0],t[1].length),k=e.split(`
147
+ `,1)[0],y=!h.trim(),v=0;if(this.options.pedantic?(v=2,m=h.trimStart()):y?v=t[1].length+1:(v=h.search(this.rules.other.nonSpaceChar),v=v>4?1:v,m=h.slice(v),v+=t[1].length),y&&this.rules.other.blankLine.test(k)&&(p+=k+`
148
+ `,e=e.substring(k.length+1),c=!0),!c){let x=this.rules.other.nextBulletRegex(v),_=this.rules.other.hrRegex(v),N=this.rules.other.fencesBeginRegex(v),j=this.rules.other.headingBeginRegex(v),E=this.rules.other.htmlBeginRegex(v),M=this.rules.other.blockquoteBeginRegex(v);for(;e;){let K=e.split(`
149
+ `,1)[0],U;if(k=K,this.options.pedantic?(k=k.replace(this.rules.other.listReplaceNesting," "),U=k):U=k.replace(this.rules.other.tabCharGlobal," "),N.test(k)||j.test(k)||E.test(k)||M.test(k)||x.test(k)||_.test(k))break;if(U.search(this.rules.other.nonSpaceChar)>=v||!k.trim())m+=`
150
+ `+U.slice(v);else{if(y||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(h)||j.test(h)||_.test(h))break;m+=`
151
+ `+k}y=!k.trim(),p+=K+`
152
+ `,e=e.substring(K.length+1),h=U.slice(v)}}o.loose||(l?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(l=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(m),loose:!1,text:m,tokens:[]}),o.raw+=p}let u=o.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let c of o.items)if(this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]),!o.loose){let p=c.tokens.filter(h=>h.type==="space"),m=p.length>0&&p.some(h=>this.rules.other.anyLine.test(h.raw));o.loose=m}for(let c of o.items){let p=c.tokens[0];if(c.task&&((p==null?void 0:p.type)==="text"||(p==null?void 0:p.type)==="paragraph")){c.text=c.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 h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let m=this.rules.other.listTaskCheckbox.exec(c.raw);if(m){let h={type:"checkbox",raw:m[0]+" ",checked:m[0]!=="[ ]"};c.checked=h.checked,o.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=h.raw+c.tokens[0].raw,c.tokens[0].text=h.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(h)):c.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):c.tokens.unshift(h)}}else c.task&&(c.task=!1)}if(o.loose)for(let c of o.items){c.loose=!0;for(let p of c.tokens)p.type==="text"&&(p.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=C0(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:Ms(t[0],`
153
+ `),href:r,title:o}}}table(e){var l;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=j0(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=(l=t[3])!=null&&l.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
154
+ `):[],a={type:"table",raw:Ms(t[0],`
155
+ `),header:[],align:[],rows:[]};if(n.length===r.length){for(let u of r)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 o)a.rows.push(j0(u,a.header.length).map((c,p)=>({text:c,tokens:this.lexer.inline(c),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:Ms(t[0],`
156
+ `),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)===`
157
+ `?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=Ms(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=ND(t[2],"()");if(a===-2)return;if(a>-1){let l=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(r);a&&(r=a[1],o=a[3])}else o=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),A0(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=t[r.toLowerCase()];if(!o){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return A0(n,o,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,a,l,u=o,c=0,p=r[0][0],m=n===p,h=p==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*e.length+o);(r=h.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a)continue;if(l=[...a].length,r[3]||r[4]){u+=l;continue}else if(r[5]||r[6]){if(o%3&&!((o+l)%3)){c+=l;continue}if(m)break}if(u-=l,u>0)continue;l=Math.min(l,l+u+c);let k=[...r[0]][0].length,y=e.slice(0,o+r.index+k+l);if(Math.min(o,l)%2){let x=y.slice(1,-1);return{type:"em",raw:y,text:x,tokens:this.lexer.inlineTokens(x)}}let v=y.slice(2,-2);return{type:"strong",raw:y,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,a,l,u=o,c=this.rules.inline.delRDelim;for(c.lastIndex=0,t=t.slice(-1*e.length+o);(r=c.exec(t))!==null;){if(a=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!a||(l=[...a].length,l!==o))continue;if(r[3]||r[4]){u+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u);let p=[...r[0]][0].length,m=e.slice(0,o+r.index+p+l),h=m.slice(o,-o);return{type:"del",raw:m,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,o;if(t[2]==="@")r=t[0],o="mailto:"+r;else{let a;do a=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(a!==t[0]);r=t[0],t[1]==="www."?o="http://"+t[0]:o=t[0]}return{type:"link",raw:t[0],text:r,href:o,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},Ro=class Yh{constructor(t){jt(this,"tokens");jt(this,"options");jt(this,"state");jt(this,"inlineQueue");jt(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Mi,this.options.tokenizer=this.options.tokenizer||new kd,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:jr,block:Du.normal,inline:Nl.normal};this.options.pedantic?(n.block=Du.pedantic,n.inline=Nl.pedantic):this.options.gfm&&(n.block=Du.gfm,this.options.breaks?n.inline=Nl.breaks:n.inline=Nl.gfm),this.tokenizer.rules=n}static get rules(){return{block:Du,inline:Nl}}static lex(t,n){return new Yh(n).lex(t)}static lexInline(t,n){return new Yh(n).inlineTokens(t)}lex(t){t=t.replace(jr.carriageReturn,`
158
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var a,l,u;this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(jr.tabCharGlobal," ").replace(jr.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let c;if((l=(a=this.options.extensions)==null?void 0:a.block)!=null&&l.some(m=>(c=m.call({lexer:this},t,n))?(t=t.substring(c.raw.length),n.push(c),!0):!1))continue;if(c=this.tokenizer.space(t)){t=t.substring(c.raw.length);let m=n.at(-1);c.raw.length===1&&m!==void 0?m.raw+=`
159
+ `:n.push(c);continue}if(c=this.tokenizer.code(t)){t=t.substring(c.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(`
160
+ `)?"":`
161
+ `)+c.raw,m.text+=`
162
+ `+c.text,this.inlineQueue.at(-1).src=m.text):n.push(c);continue}if(c=this.tokenizer.fences(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.heading(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.hr(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.blockquote(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.list(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.html(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.def(t)){t=t.substring(c.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(`
163
+ `)?"":`
164
+ `)+c.raw,m.text+=`
165
+ `+c.raw,this.inlineQueue.at(-1).src=m.text):this.tokens.links[c.tag]||(this.tokens.links[c.tag]={href:c.href,title:c.title},n.push(c));continue}if(c=this.tokenizer.table(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.lheading(t)){t=t.substring(c.raw.length),n.push(c);continue}let p=t;if((u=this.options.extensions)!=null&&u.startBlock){let m=1/0,h=t.slice(1),k;this.options.extensions.startBlock.forEach(y=>{k=y.call({lexer:this},h),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&&(c=this.tokenizer.paragraph(p))){let m=n.at(-1);r&&(m==null?void 0:m.type)==="paragraph"?(m.raw+=(m.raw.endsWith(`
166
+ `)?"":`
167
+ `)+c.raw,m.text+=`
168
+ `+c.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=m.text):n.push(c),r=p.length!==t.length,t=t.substring(c.raw.length);continue}if(c=this.tokenizer.text(t)){t=t.substring(c.raw.length);let m=n.at(-1);(m==null?void 0:m.type)==="text"?(m.raw+=(m.raw.endsWith(`
169
+ `)?"":`
170
+ `)+c.raw,m.text+=`
171
+ `+c.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=m.text):n.push(c);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}linkInText(t){if(!t.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let r of t.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(r[0])&&t.charAt(r.index-1)!=="!")return!0;for(let r of t.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let o=r[0],a=o.lastIndexOf("[");if(!(o.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,o.slice(a+1,-1)))&&!(a>1&&this.linkInText(o.slice(1,a-1))))return!0}return!1}inlineTokens(t,n=[]){var u,c,p,m,h;this.tokenizer.lexer=this;let r=t;if(this.tokens.links&&t.includes("[")){let k=this.tokenizer.rules.inline.reflinkSearch,y=v=>{let x=v.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,v.slice(x+1,-1)))return v;if(x>1&&v.charAt(0)!=="!"){let _=v.slice(1,x-1);if(this.linkInText(_))return"["+_.replace(k,y)+"]["+"a".repeat(v.length-x-2)+"]"}return"["+"a".repeat(v.length-2)+"]"};r=r.replace(k,y)}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,k=>"+".repeat(k.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(k,y,v)=>{let x=v?v.length:0;return k.slice(0,x)+"["+"a".repeat(k.length-x-2)+"]"}),r=((c=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:c.call({lexer:this},r))??r;let o=!1,a="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}o||(a=""),o=!1;let k;if((m=(p=this.options.extensions)==null?void 0:p.inline)!=null&&m.some(v=>(k=v.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 v=n.at(-1);k.type==="text"&&(v==null?void 0:v.type)==="text"?(v.raw+=k.raw,v.text+=k.text):n.push(k);continue}if(k=this.tokenizer.emStrong(t,r,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,r,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 y=t;if((h=this.options.extensions)!=null&&h.startInline){let v=1/0,x=t.slice(1),_;this.options.extensions.startInline.forEach(N=>{_=N.call({lexer:this},x),typeof _=="number"&&_>=0&&(v=Math.min(v,_))}),v<1/0&&v>=0&&(y=t.substring(0,v+1))}if(k=this.tokenizer.inlineText(y)){t=t.substring(k.raw.length),k.raw.slice(-1)!=="_"&&(a=k.raw.slice(-1)),o=!0;let v=n.at(-1);(v==null?void 0:v.type)==="text"?(v.raw+=k.raw,v.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)}},yd=class{constructor(e){jt(this,"options");jt(this,"parser");this.options=e||Mi}space(e){return""}code({text:e,lang:t,escaped:n}){var a;let r=(a=(t||"").match(jr.notSpaceStart))==null?void 0:a[0],o=e.replace(jr.endingNewline,"")+`
172
+ `;return r?'<pre><code class="language-'+Zo(r)+'">'+(n?o:Zo(o,!0))+`</code></pre>
173
+ `:"<pre><code>"+(n?o:Zo(o,!0))+`</code></pre>
174
+ `}blockquote({tokens:e}){return`<blockquote>
175
+ ${this.parser.parse(e)}</blockquote>
176
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
177
+ `}hr(e){return`<hr>
178
+ `}list(e){let t=e.ordered,n=e.start,r="";for(let l=0;l<e.items.length;l++){let u=e.items[l];r+=this.listitem(u)}let o=t?"ol":"ul",a=t&&n!==1?' start="'+n+'"':"";return"<"+o+a+`>
179
+ `+r+"</"+o+`>
180
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
181
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
182
+ `}table(e){let t="",n="";for(let o=0;o<e.header.length;o++)n+=this.tablecell(e.header[o]);t+=this.tablerow({text:n});let r="";for(let o=0;o<e.rows.length;o++){let a=e.rows[o];n="";for(let l=0;l<a.length;l++)n+=this.tablecell(a[l]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
183
+ <thead>
184
+ `+t+`</thead>
185
+ `+r+`</table>
186
+ `}tablerow({text:e}){return`<tr>
187
+ ${e}</tr>
188
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
189
+ `}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>${Zo(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),o=T0(e);if(o===null)return r;e=o;let a='<a href="'+e+'"';return t&&(a+=' title="'+Zo(t)+'"'),a+=">"+r+"</a>",a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=T0(e);if(o===null)return Zo(n);e=o;let a=`<img src="${e}" alt="${Zo(n)}"`;return t&&(a+=` title="${Zo(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Zo(e.text)}},bg=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}},Oo=class Qh{constructor(t){jt(this,"options");jt(this,"renderer");jt(this,"textRenderer");this.options=t||Mi,this.options.renderer=this.options.renderer||new yd,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new bg}static parse(t,n){return new Qh(n).parse(t)}static parseInline(t,n){return new Qh(n).parseInline(t)}parse(t){var r,o;this.renderer.parser=this;let n="";for(let a=0;a<t.length;a++){let l=t[a];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[l.type]){let c=l,p=this.options.extensions.renderers[c.type].call({parser:this},c);if(p!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(c.type)){n+=p||"";continue}}let u=l;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 c='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}parseInline(t,n=this.renderer){var o,a;this.renderer.parser=this;let r="";for(let l=0;l<t.length;l++){let u=t[l];if((a=(o=this.options.extensions)==null?void 0:o.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)){r+=p||"";continue}}let c=u;switch(c.type){case"escape":{r+=n.text(c);break}case"html":{r+=n.html(c);break}case"link":{r+=n.link(c);break}case"image":{r+=n.image(c);break}case"checkbox":{r+=n.checkbox(c);break}case"strong":{r+=n.strong(c);break}case"em":{r+=n.em(c);break}case"codespan":{r+=n.codespan(c);break}case"br":{r+=n.br(c);break}case"del":{r+=n.del(c);break}case"text":{r+=n.text(c);break}default:{let p='Token with "'+c.type+'" type was not found.';if(this.options.silent)return console.error(p),"";throw new Error(p)}}}return r}},Hu,Rl=(Hu=class{constructor(e){jt(this,"options");jt(this,"block");this.options=e||Mi}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Ro.lex:Ro.lexInline}provideParser(e=this.block){return e?Oo.parse:Oo.parseInline}},jt(Hu,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),jt(Hu,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Hu),CD=class{constructor(...e){jt(this,"defaults",hg());jt(this,"options",this.setOptions);jt(this,"parse",this.parseMarkdown(!0));jt(this,"parseInline",this.parseMarkdown(!1));jt(this,"Parser",Oo);jt(this,"Renderer",yd);jt(this,"TextRenderer",bg);jt(this,"Lexer",Ro);jt(this,"Tokenizer",kd);jt(this,"Hooks",Rl);this.use(...e)}walkTokens(e,t){var r,o;let n=[];for(let a of e)switch(n=n.concat(t.call(this,a)),a.type){case"table":{let l=a;for(let u of l.header)n=n.concat(this.walkTokens(u.tokens,t));for(let u of l.rows)for(let c of u)n=n.concat(this.walkTokens(c.tokens,t));break}case"list":{let l=a;n=n.concat(this.walkTokens(l.items,t));break}default:{let l=a;(o=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&o[l.type]?this.defaults.extensions.childTokens[l.type].forEach(u=>{let c=l[u].flat(1/0);n=n.concat(this.walkTokens(c,t))}):l.tokens&&(n=n.concat(this.walkTokens(l.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let a=t.renderers[o.name];a?t.renderers[o.name]=function(...l){let u=o.renderer.apply(this,l);return u===!1&&(u=a.apply(this,l)),u}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[o.level];a?a.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){let o=this.defaults.renderer||new yd(this.defaults);for(let a in n.renderer){if(!(a in o))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let l=a,u=n.renderer[l],c=o[l];o[l]=(...p)=>{let m=u.apply(o,p);return m===!1&&(m=c.apply(o,p)),m||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new kd(this.defaults);for(let a in n.tokenizer){if(!(a in o))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let l=a,u=n.tokenizer[l],c=o[l];o[l]=(...p)=>{let m=u.apply(o,p);return m===!1&&(m=c.apply(o,p)),m}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new Rl;for(let a in n.hooks){if(!(a in o))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let l=a,u=n.hooks[l],c=o[l];Rl.passThroughHooks.has(a)?o[l]=p=>{if(this.defaults.async&&Rl.passThroughHooksRespectAsync.has(a))return(async()=>{let h=await u.call(o,p);return c.call(o,h)})();let m=u.call(o,p);return c.call(o,m)}:o[l]=(...p)=>{if(this.defaults.async)return(async()=>{let h=await u.apply(o,p);return h===!1&&(h=await c.apply(o,p)),h})();let m=u.apply(o,p);return m===!1&&(m=c.apply(o,p)),m}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,a=n.walkTokens;r.walkTokens=function(l){let u=[];return u.push(a.call(this,l)),o&&(u=u.concat(o.call(this,l))),u}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ro.lex(e,t??this.defaults)}parser(e,t){return Oo.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},a=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.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(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let l=o.hooks?await o.hooks.preprocess(t):t,u=await(o.hooks?await o.hooks.provideLexer(e):e?Ro.lex:Ro.lexInline)(l,o),c=o.hooks?await o.hooks.processAllTokens(u):u;o.walkTokens&&await Promise.all(this.walkTokens(c,o.walkTokens));let p=await(o.hooks?await o.hooks.provideParser(e):e?Oo.parse:Oo.parseInline)(c,o);return o.hooks?await o.hooks.postprocess(p):p})().catch(a);try{o.hooks&&(t=o.hooks.preprocess(t));let l=(o.hooks?o.hooks.provideLexer(e):e?Ro.lex:Ro.lexInline)(t,o);o.hooks&&(l=o.hooks.processAllTokens(l)),o.walkTokens&&this.walkTokens(l,o.walkTokens);let u=(o.hooks?o.hooks.provideParser(e):e?Oo.parse:Oo.parseInline)(l,o);return o.hooks&&(u=o.hooks.postprocess(u)),u}catch(l){return a(l)}}}onError(e,t){return n=>{if(n.message+=`
190
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Zo(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Ri=new CD;function un(e,t){return Ri.parse(e,t)}un.options=un.setOptions=function(e){return Ri.setOptions(e),un.defaults=Ri.defaults,S_(un.defaults),un};un.getDefaults=hg;un.defaults=Mi;function AD(...e){return Ri.use(...e),un.defaults=Ri.defaults,S_(un.defaults),un}un.use=AD;un.walkTokens=function(e,t){return Ri.walkTokens(e,t)};un.parseInline=Ri.parseInline;un.Parser=Oo;un.parser=Oo.parse;un.Renderer=yd;un.TextRenderer=bg;un.Lexer=Ro;un.lexer=Ro.lex;un.Tokenizer=kd;un.Hooks=Rl;un.parse=un;un.options;un.setOptions;un.walkTokens;un.parseInline;Oo.parse;Ro.lex;const M_="#toyon-link-pending",ID=/!?\[([^[\]\n]*)(?:\]\(([^()\s]*))?$/;function RD(e){const t=e.lastIndexOf(`
191
+ `)+1,n=e.slice(t),r=ID.exec(n);return!r||OD(e.slice(0,t))||$D(n.slice(0,r.index))?e:`${e.slice(0,t)}${n.slice(0,r.index)}[${r[1]}](${M_})`}function OD(e){let t=!1;for(const n of e.split(`
192
+ `))/^\s*(```|~~~)/.test(n)&&(t=!t);return t}function $D(e){let t=0;for(const n of e)n==="`"&&t++;return t%2===1}const ih="__[a-z][a-z0-9_]*[a-z0-9]__",MD=new RegExp(`^(?:${ih}\\.)+${ih}|^${ih}(?=\\.\\w|\\(|["'])`),LD={name:"dunder",level:"inline",start:e=>e.indexOf("__"),tokenizer(e){const t=MD.exec(e);if(t)return{type:"dunder",raw:t[0],text:t[0]}},renderer:e=>e.text};function xg(e,t){if(!t||t.startsWith("#")||t.startsWith("/")||/^[a-z][a-z\d+.-]*:/i.test(t))return null;const n=t.split(/[?#]/)[0]??"";if(!n)return null;const r=e?e.split("/"):[];for(const o of n.split("/"))if(!(o===""||o==="."))if(o===".."){if(!r.length)return null;r.pop()}else r.push(decodeURIComponent(o));return r.length?r.join("/"):null}const L_=e=>e.slice(0,Math.max(0,e.lastIndexOf("/")));function P_(e,t){let n;try{n=decodeURIComponent(t)}catch{return null}const r=n.match(/#L(\d+)(?:-L?\d+)?$/i);r?n=n.slice(0,r.index):n=n.split(/[?#]/)[0]??"";const o=n.match(/:(\d+)(?::\d+)?$/);o&&(n=n.slice(0,o.index));const a=e.replace(/\/+$/,"");if(!a||!n.startsWith(`${a}/`))return null;const l=n.endsWith("/"),u=n.slice(a.length+1).replace(/\/+$/,"");if(!u||u.split("/").some(m=>m===".."))return null;if(l)return{path:u,folder:!0};const c=(r==null?void 0:r[1])??(o==null?void 0:o[1]),p=c?Number.parseInt(c,10):void 0;return p&&p>0?{path:u,line:p}:{path:u}}function D_(e){if(!e.startsWith("/")||e.startsWith("//"))return null;let t;try{t=decodeURIComponent(e)}catch{return null}const n=t.match(/:(\d+)(?::\d+)?$/);if(!n)return{path:t};const r=Number.parseInt(n[1]??"",10),o=t.slice(0,n.index);return r>0?{path:o,line:r}:{path:o}}function PD(e){return e.length<2||!e.startsWith("/")||e.startsWith("//")||/\s/.test(e)?null:e}function DD(e){if(e.header.some(n=>n.text.trim()))return!1;let t="";for(const n of e.rows){let r="";for(const o of n)r+=this.tablecell(o);t+=this.tablerow({text:r})}return`<table>
193
+ <tbody>${t}</tbody></table>
194
+ `}function zD(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const o={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),l={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},u={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,o]};o.contains.push(u);const c={match:/\\"/},p={className:"string",begin:/'/,end:/'/},m={match:/\\'/},h={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},k=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],y=e.SHEBANG({binary:`(${k.join("|")})`,relevance:10}),v={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},x=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],_=["true","false"],N={match:/(\/[a-z._-]+)+/},j=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],E=["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"],K=["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:x,literal:_,built_in:[...j,...E,"set","shopt",...M,...K]},contains:[y,e.SHEBANG(),v,h,a,l,N,u,c,p,m,n]}}const FD=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_-]*/}}),BD=["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"],UD=["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"],HD=[...BD,...UD],WD=["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(),KD=["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(),ZD=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),qD=["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 GD(e){const t=e.regex,n=FD(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},o="and or not only",a=/@-?\w[\w]*(-\w+)*/,l="[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,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+l,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+KD.join("|")+")"},{begin:":(:)?("+ZD.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+qD.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:o,attribute:WD.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+HD.join("|")+")\\b"}]}}function VD(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 YD(e){const t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const o={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},a={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},u={begin:/\[/,end:/\]/,contains:[r,a,o,l,n,"self"],relevance:0},c=/[A-Za-z0-9_-]+/,p=/"(\\"|[^"])*"/,m=/'[^']*'/,h=t.either(c,p,m),k=t.concat(h,"(\\s*\\.\\s*",h,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:k,className:"attr",starts:{end:/$/,contains:[r,u,a,o,l,n]}}]}}const I0="[A-Za-z$_][0-9A-Za-z$_]*",QD=["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"],XD=["true","false","null","undefined","NaN","Infinity"],z_=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],F_=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],B_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],JD=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],ez=[].concat(B_,z_,F_);function tz(e){const t=e.regex,n=(A,{after:X})=>{const Z="</"+A[0].slice(1);return A.input.indexOf(Z,X)!==-1},r=I0,o={begin:"<>",end:"</>"},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(A,X)=>{const Z=A[0].length+A.index,$=A.input[Z];if($==="<"||$===","){X.ignoreMatch();return}$===">"&&(n(A,{after:Z})||X.ignoreMatch());let V;const de=A.input.substring(Z);if(V=de.match(/^\s*=/)){X.ignoreMatch();return}if((V=de.match(/^\s+extends\s+/))&&V.index===0){X.ignoreMatch();return}}},u={$pattern:I0,keyword:QD,literal:XD,built_in:ez,"variable.language":JD},c="[0-9](_?[0-9])*",p=`\\.(${c})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",h={className:"number",variants:[{begin:`(\\b(${m})((${p})|\\.)?|(${p}))[eE][+-]?(${c})\\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:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"xml"}},v={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"css"}},x={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,k]},j={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},E=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,v,x,_,{match:/\$\d+/},h];k.contains=E.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(E)});const M=[].concat(j,k.contains),K=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(M)}]),U={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:K},R={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},I={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...z_,...F_]}},C={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[U],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function q(A){return t.concat("(?!",A.join("|"),")")}const se={match:t.concat(/\b/,q([...B_,"super","import","await"].map(A=>`${A}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},pe={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ue={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},U]},xe="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",oe={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(xe)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[U]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:K,CLASS_REFERENCE:I},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),C,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,v,x,_,j,{match:/\$\d+/},h,I,{scope:"attr",match:r+t.lookahead(":"),relevance:0},oe,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[j,e.REGEXP_MODE,{className:"function",begin:xe,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:K}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:a},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},P,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[U,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},pe,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[U]},se,z,R,ue,{match:/\$[(.]/}]}}const nz="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",rz={scope:"number",match:nz,relevance:0};function oz(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],o={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:r},contains:[t,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,o,rz,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function sz(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},o={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},a={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,c={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}]},h=e.inherit(p,{contains:[]}),k=e.inherit(m,{contains:[]});p.contains.push(k),m.contains.push(h);let y=[n,c];return[p,m,h,k].forEach(N=>{N.contains=N.contains.concat(y)}),y=y.concat(p,m),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:y},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:y}]}]},n,a,r,p,m,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},o,c,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function iz(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],u={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},p={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},m={begin:/\{\{/,relevance:0},h={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,c,m,p]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,c,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])*",y=`(\\b(${k}))?\\.(${k})|\\b(${k})\\.`,v=`\\b|${r.join("|")}`,x={className:"number",relevance:0,variants:[{begin:`(\\b(${k})|(${y}))[eE][+-]?(${k})[jJ]?(?=${v})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${v})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${v})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${v})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${v})`},{begin:`\\b(${k})[jJ](?=${v})`}]},_={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},N={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",c,x,h,e.HASH_COMMENT_MODE]}]};return p.contains=[h,x,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[c,x,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},h,_,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[N]},{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:[x,N,h]}]}}function az(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),a={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,o,t.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",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"],c=["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:c,built_in:p},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,r],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:p,type:m}},{scope:"punctuation",begin:"->"},a]}}const wd="[A-Za-z$_][0-9A-Za-z$_]*",U_=["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"],H_=["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"],K_=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Z_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],q_=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],G_=[].concat(Z_,W_,K_);function lz(e){const t=e.regex,n=(A,{after:X})=>{const Z="</"+A[0].slice(1);return A.input.indexOf(Z,X)!==-1},r=wd,o={begin:"<>",end:"</>"},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(A,X)=>{const Z=A[0].length+A.index,$=A.input[Z];if($==="<"||$===","){X.ignoreMatch();return}$===">"&&(n(A,{after:Z})||X.ignoreMatch());let V;const de=A.input.substring(Z);if(V=de.match(/^\s*=/)){X.ignoreMatch();return}if((V=de.match(/^\s+extends\s+/))&&V.index===0){X.ignoreMatch();return}}},u={$pattern:wd,keyword:U_,literal:H_,built_in:G_,"variable.language":q_},c="[0-9](_?[0-9])*",p=`\\.(${c})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",h={className:"number",variants:[{begin:`(\\b(${m})((${p})|\\.)?|(${p}))[eE][+-]?(${c})\\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:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"xml"}},v={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"css"}},x={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,k],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,k]},j={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},E=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,v,x,_,{match:/\$\d+/},h];k.contains=E.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(E)});const M=[].concat(j,k.contains),K=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(M)}]),U={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:K},R={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},I={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_,...K_]}},C={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[U],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function q(A){return t.concat("(?!",A.join("|"),")")}const se={match:t.concat(/\b/,q([...Z_,"super","import","await"].map(A=>`${A}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},pe={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ue={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},U]},xe="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",oe={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(xe)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[U]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:K,CLASS_REFERENCE:I},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),C,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,v,x,_,j,{match:/\$\d+/},h,I,{scope:"attr",match:r+t.lookahead(":"),relevance:0},oe,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[j,e.REGEXP_MODE,{className:"function",begin:xe,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:K}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:a},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},P,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[U,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},pe,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[U]},se,z,R,ue,{match:/\$[(.]/}]}}function cz(e){const t=e.regex,n=lz(e),r=wd,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:o},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],p={$pattern:wd,keyword:U_.concat(c),literal:H_,built_in:G_.concat(o),"variable.language":q_},m={className:"meta",begin:"@"+r},h=(x,_,N)=>{const j=x.contains.findIndex(E=>E.label===_);if(j===-1)throw new Error("can not find mode to replace");x.contains.splice(j,1,N)};Object.assign(n.keywords,p),n.exports.PARAMS_CONTAINS.push(m);const k=n.contains.find(x=>x.scope==="attr"),y=Object.assign({},k,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,k,y]),n.contains=n.contains.concat([m,a,l,y]),h(n,"shebang",e.SHEBANG()),h(n,"use_strict",u);const v=n.contains.find(x=>x.label==="func.def");return v.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function uz(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,o={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=e.inherit(a,{begin:/\(/,end:/\)/}),u=e.inherit(e.APOS_STRING_MODE,{className:"string"}),c=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),p={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[o]},{begin:/'/,end:/'/,contains:[o]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,c,u,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[a,l,c,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{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 dz(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},o={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},a={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},u=e.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),k={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},v={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},x={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},_=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},k,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},v,x,a,l],N=[..._];return N.pop(),N.push(u),y.contains=N,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:_}}var ah,R0;function fz(){if(R0)return ah;R0=1;function e(H){return H instanceof Map?H.clear=H.delete=H.set=function(){throw new Error("map is read-only")}:H instanceof Set&&(H.add=H.clear=H.delete=function(){throw new Error("set is read-only")}),Object.freeze(H),Object.getOwnPropertyNames(H).forEach(fe=>{const Ie=H[fe],rt=typeof Ie;(rt==="object"||rt==="function")&&!Object.isFrozen(Ie)&&e(Ie)}),H}class t{constructor(fe){fe.data===void 0&&(fe.data={}),this.data=fe.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(H){return H.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(H,...fe){const Ie=Object.create(null);for(const rt in H)Ie[rt]=H[rt];return fe.forEach(function(rt){for(const te in rt)Ie[te]=rt[te]}),Ie}const o="</span>",a=H=>!!H.scope,l=(H,{prefix:fe})=>{if(H.startsWith("language:"))return H.replace("language:","language-");if(H.includes(".")){const Ie=H.split(".");return[`${fe}${Ie.shift()}`,...Ie.map((rt,te)=>`${rt}${"_".repeat(te+1)}`)].join(" ")}return`${fe}${H}`};class u{constructor(fe,Ie){this.buffer="",this.classPrefix=Ie.classPrefix,fe.walk(this)}addText(fe){this.buffer+=n(fe)}openNode(fe){if(!a(fe))return;const Ie=l(fe.scope,{prefix:this.classPrefix});this.span(Ie)}closeNode(fe){a(fe)&&(this.buffer+=o)}value(){return this.buffer}span(fe){this.buffer+=`<span class="${fe}">`}}const c=(H={})=>{const fe={children:[]};return Object.assign(fe,H),fe};class p{constructor(){this.rootNode=c(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(fe){this.top.children.push(fe)}openNode(fe){const Ie=c({scope:fe});this.add(Ie),this.stack.push(Ie)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(fe){return this.constructor._walk(fe,this.rootNode)}static _walk(fe,Ie){return typeof Ie=="string"?fe.addText(Ie):Ie.children&&(fe.openNode(Ie),Ie.children.forEach(rt=>this._walk(fe,rt)),fe.closeNode(Ie)),fe}static _collapse(fe){typeof fe!="string"&&fe.children&&(fe.children.every(Ie=>typeof Ie=="string")?fe.children=[fe.children.join("")]:fe.children.forEach(Ie=>{p._collapse(Ie)}))}}class m extends p{constructor(fe){super(),this.options=fe}addText(fe){fe!==""&&this.add(fe)}startScope(fe){this.openNode(fe)}endScope(){this.closeNode()}__addSublanguage(fe,Ie){const rt=fe.root;Ie&&(rt.scope=`language:${Ie}`),this.add(rt)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function h(H){return H?typeof H=="string"?H:H.source:null}function k(H){return x("(?=",H,")")}function y(H){return x("(?:",H,")*")}function v(H){return x("(?:",H,")?")}function x(...H){return H.map(Ie=>h(Ie)).join("")}function _(H){const fe=H[H.length-1];return typeof fe=="object"&&fe.constructor===Object?(H.splice(H.length-1,1),fe):{}}function N(...H){return"("+(_(H).capture?"":"?:")+H.map(rt=>h(rt)).join("|")+")"}function j(H){return new RegExp(H.toString()+"|").exec("").length-1}function E(H,fe){const Ie=H&&H.exec(fe);return Ie&&Ie.index===0}const M=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function K(H,{joinWith:fe}){let Ie=0;return H.map(rt=>{Ie+=1;const te=Ie;let Ne=h(rt),be="";for(;Ne.length>0;){const _e=M.exec(Ne);if(!_e){be+=Ne;break}be+=Ne.substring(0,_e.index),Ne=Ne.substring(_e.index+_e[0].length),_e[0][0]==="\\"&&_e[1]?be+="\\"+String(Number(_e[1])+te):(be+=_e[0],_e[0]==="("&&Ie++)}return be}).map(rt=>`(${rt})`).join(fe)}const U=/\b\B/,R="[a-zA-Z]\\w*",I="[a-zA-Z_]\\w*",C="\\b\\d+(\\.\\d+)?",P="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",z="\\b(0b[01]+)",q="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",se=(H={})=>{const fe=/^#![ ]*\//;return H.binary&&(H.begin=x(fe,/.*\b/,H.binary,/\b.*/)),r({scope:"meta",begin:fe,end:/$/,relevance:0,"on:begin":(Ie,rt)=>{Ie.index!==0&&rt.ignoreMatch()}},H)},pe={begin:"\\\\[\\s\\S]",relevance:0},ue={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[pe]},xe={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[pe]},oe={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/},A=function(H,fe,Ie={}){const rt=r({scope:"comment",begin:H,end:fe,contains:[]},Ie);rt.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 te=N("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 rt.contains.push({begin:x(/[ ]+/,"(",te,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),rt},X=A("//","$"),Z=A("/\\*","\\*/"),$=A("#","$"),V={scope:"number",begin:C,relevance:0},de={scope:"number",begin:P,relevance:0},me={scope:"number",begin:z,relevance:0},he={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[pe,{begin:/\[/,end:/\]/,relevance:0,contains:[pe]}]},$e={scope:"title",begin:R,relevance:0},ae={scope:"title",begin:I,relevance:0},ve={begin:"\\.\\s*"+I,relevance:0};var ee=Object.freeze({__proto__:null,APOS_STRING_MODE:ue,BACKSLASH_ESCAPE:pe,BINARY_NUMBER_MODE:me,BINARY_NUMBER_RE:z,COMMENT:A,C_BLOCK_COMMENT_MODE:Z,C_LINE_COMMENT_MODE:X,C_NUMBER_MODE:de,C_NUMBER_RE:P,END_SAME_AS_BEGIN:function(H){return Object.assign(H,{"on:begin":(fe,Ie)=>{Ie.data._beginMatch=fe[1]},"on:end":(fe,Ie)=>{Ie.data._beginMatch!==fe[1]&&Ie.ignoreMatch()}})},HASH_COMMENT_MODE:$,IDENT_RE:R,MATCH_NOTHING_RE:U,METHOD_GUARD:ve,NUMBER_MODE:V,NUMBER_RE:C,PHRASAL_WORDS_MODE:oe,QUOTE_STRING_MODE:xe,REGEXP_MODE:he,RE_STARTERS_RE:q,SHEBANG:se,TITLE_MODE:$e,UNDERSCORE_IDENT_RE:I,UNDERSCORE_TITLE_MODE:ae});function Y(H,fe){H.input[H.index-1]==="."&&fe.ignoreMatch()}function Pe(H,fe){H.className!==void 0&&(H.scope=H.className,delete H.className)}function We(H,fe){fe&&H.beginKeywords&&(H.begin="\\b("+H.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",H.__beforeBegin=Y,H.keywords=H.keywords||H.beginKeywords,delete H.beginKeywords,H.relevance===void 0&&(H.relevance=0))}function Fe(H,fe){Array.isArray(H.illegal)&&(H.illegal=N(...H.illegal))}function pt(H,fe){if(H.match){if(H.begin||H.end)throw new Error("begin & end are not supported with match");H.begin=H.match,delete H.match}}function Ge(H,fe){H.relevance===void 0&&(H.relevance=1)}const vt=(H,fe)=>{if(!H.beforeMatch)return;if(H.starts)throw new Error("beforeMatch cannot be used with starts");const Ie=Object.assign({},H);Object.keys(H).forEach(rt=>{delete H[rt]}),H.keywords=Ie.keywords,H.begin=x(Ie.beforeMatch,k(Ie.begin)),H.starts={relevance:0,contains:[Object.assign(Ie,{endsParent:!0})]},H.relevance=0,delete Ie.beforeMatch},at=["of","and","for","in","not","or","if","then","parent","list","value"],qt="keyword";function an(H,fe,Ie=qt){const rt=Object.create(null);return typeof H=="string"?te(Ie,H.split(" ")):Array.isArray(H)?te(Ie,H):Object.keys(H).forEach(function(Ne){Object.assign(rt,an(H[Ne],fe,Ne))}),rt;function te(Ne,be){fe&&(be=be.map(_e=>_e.toLowerCase())),be.forEach(function(_e){const Oe=_e.split("|");rt[Oe[0]]=[Ne,qe(Oe[0],Oe[1])]})}}function qe(H,fe){return fe?Number(fe):J(H)?0:1}function J(H){return at.includes(H.toLowerCase())}const we={},Xe=H=>{console.error(H)},et=(H,...fe)=>{console.log(`WARN: ${H}`,...fe)},Wt=(H,fe)=>{we[`${H}/${fe}`]||(console.log(`Deprecated as of ${H}. ${fe}`),we[`${H}/${fe}`]=!0)},Qt=new Error;function ge(H,fe,{key:Ie}){let rt=0;const te=H[Ie],Ne={},be={};for(let _e=1;_e<=fe.length;_e++)be[_e+rt]=te[_e],Ne[_e+rt]=!0,rt+=j(fe[_e-1]);H[Ie]=be,H[Ie]._emit=Ne,H[Ie]._multi=!0}function Me(H){if(Array.isArray(H.begin)){if(H.skip||H.excludeBegin||H.returnBegin)throw Xe("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Qt;if(typeof H.beginScope!="object"||H.beginScope===null)throw Xe("beginScope must be object"),Qt;ge(H,H.begin,{key:"beginScope"}),H.begin=K(H.begin,{joinWith:""})}}function hn(H){if(Array.isArray(H.end)){if(H.skip||H.excludeEnd||H.returnEnd)throw Xe("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Qt;if(typeof H.endScope!="object"||H.endScope===null)throw Xe("endScope must be object"),Qt;ge(H,H.end,{key:"endScope"}),H.end=K(H.end,{joinWith:""})}}function It(H){H.scope&&typeof H.scope=="object"&&H.scope!==null&&(H.beginScope=H.scope,delete H.scope)}function Rt(H){It(H),typeof H.beginScope=="string"&&(H.beginScope={_wrap:H.beginScope}),typeof H.endScope=="string"&&(H.endScope={_wrap:H.endScope}),Me(H),hn(H)}function In(H){function fe(be,_e){return new RegExp(h(be),"m"+(H.case_insensitive?"i":"")+(H.unicodeRegex?"u":"")+(_e?"g":""))}class Ie{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(_e,Oe){Oe.position=this.position++,this.matchIndexes[this.matchAt]=Oe,this.regexes.push([Oe,_e]),this.matchAt+=j(_e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const _e=this.regexes.map(Oe=>Oe[1]);this.matcherRe=fe(K(_e,{joinWith:"|"}),!0),this.lastIndex=0}exec(_e){this.matcherRe.lastIndex=this.lastIndex;const Oe=this.matcherRe.exec(_e);if(!Oe)return null;const Mt=Oe.findIndex((ht,wn)=>wn>0&&ht!==void 0),Tt=this.matchIndexes[Mt];return Oe.splice(0,Mt),Object.assign(Oe,Tt)}}class rt{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(_e){if(this.multiRegexes[_e])return this.multiRegexes[_e];const Oe=new Ie;return this.rules.slice(_e).forEach(([Mt,Tt])=>Oe.addRule(Mt,Tt)),Oe.compile(),this.multiRegexes[_e]=Oe,Oe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(_e,Oe){this.rules.push([_e,Oe]),Oe.type==="begin"&&this.count++}exec(_e){const Oe=this.getMatcher(this.regexIndex);Oe.lastIndex=this.lastIndex;let Mt=Oe.exec(_e);if(this.resumingScanAtSamePosition()&&!(Mt&&Mt.index===this.lastIndex)){const Tt=this.getMatcher(0);Tt.lastIndex=this.lastIndex+1,Mt=Tt.exec(_e)}return Mt&&(this.regexIndex+=Mt.position+1,this.regexIndex===this.count&&this.considerAll()),Mt}}function te(be){const _e=new rt;return be.contains.forEach(Oe=>_e.addRule(Oe.begin,{rule:Oe,type:"begin"})),be.terminatorEnd&&_e.addRule(be.terminatorEnd,{type:"end"}),be.illegal&&_e.addRule(be.illegal,{type:"illegal"}),_e}function Ne(be,_e){const Oe=be;if(be.isCompiled)return Oe;[Pe,pt,Rt,vt].forEach(Tt=>Tt(be,_e)),H.compilerExtensions.forEach(Tt=>Tt(be,_e)),be.__beforeBegin=null,[We,Fe,Ge].forEach(Tt=>Tt(be,_e)),be.isCompiled=!0;let Mt=null;return typeof be.keywords=="object"&&be.keywords.$pattern&&(be.keywords=Object.assign({},be.keywords),Mt=be.keywords.$pattern,delete be.keywords.$pattern),Mt=Mt||/\w+/,be.keywords&&(be.keywords=an(be.keywords,H.case_insensitive)),Oe.keywordPatternRe=fe(Mt,!0),_e&&(be.begin||(be.begin=/\B|\b/),Oe.beginRe=fe(Oe.begin),!be.end&&!be.endsWithParent&&(be.end=/\B|\b/),be.end&&(Oe.endRe=fe(Oe.end)),Oe.terminatorEnd=h(Oe.end)||"",be.endsWithParent&&_e.terminatorEnd&&(Oe.terminatorEnd+=(be.end?"|":"")+_e.terminatorEnd)),be.illegal&&(Oe.illegalRe=fe(be.illegal)),be.contains||(be.contains=[]),be.contains=[].concat(...be.contains.map(function(Tt){return gn(Tt==="self"?be:Tt)})),be.contains.forEach(function(Tt){Ne(Tt,Oe)}),be.starts&&Ne(be.starts,_e),Oe.matcher=te(Oe),Oe}if(H.compilerExtensions||(H.compilerExtensions=[]),H.contains&&H.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return H.classNameAliases=r(H.classNameAliases||{}),Ne(H)}function Dt(H){return H?H.endsWithParent||Dt(H.starts):!1}function gn(H){return H.variants&&!H.cachedVariants&&(H.cachedVariants=H.variants.map(function(fe){return r(H,{variants:null},fe)})),H.cachedVariants?H.cachedVariants:Dt(H)?r(H,{starts:H.starts?r(H.starts):null}):Object.isFrozen(H)?r(H):H}var kt="11.11.2";class Gt extends Error{constructor(fe,Ie){super(fe),this.name="HTMLInjectionError",this.html=Ie}}const tn=n,nn=r,Un=Symbol("nomatch"),_t=7,Kt=function(H){const fe=Object.create(null),Ie=Object.create(null),rt=[];let te=!0;const Ne="Could not find the language '{}', did you forget to load/include a language module?",be={disableAutodetect:!0,name:"Plain text",contains:[]};let _e={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:m};function Oe(je){return _e.noHighlightRe.test(je)}function Mt(je){let Be=je.className+" ";Be+=je.parentNode?je.parentNode.className:"";const yt=_e.languageDetectRe.exec(Be);if(yt){const xt=sr(yt[1]);return xt||(et(Ne.replace("{}",yt[1])),et("Falling back to no-highlight mode for this block.",je)),xt?yt[1]:"no-highlight"}return Be.split(/\s+/).find(xt=>Oe(xt)||sr(xt))}function Tt(je,Be,yt){let xt="",ln="";typeof Be=="object"?(xt=je,yt=Be.ignoreIllegals,ln=Be.language):(Wt("10.7.0","highlight(lang, code, ...args) has been deprecated."),Wt("10.7.0",`Please use highlight(code, options) instead.
195
+ https://github.com/highlightjs/highlight.js/issues/2277`),ln=je,xt=Be),yt===void 0&&(yt=!0);const ot={code:xt,language:ln};Zn("before:highlight",ot);const B=ot.result?ot.result:ht(ot.language,ot.code,yt);return B.code=ot.code,Zn("after:highlight",B),B}function ht(je,Be,yt,xt){const ln=Object.create(null);function ot(D,ne){return D.keywords[ne]}function B(){if(!tt.keywords){bn.addText(Ut);return}let D=0;tt.keywordPatternRe.lastIndex=0;let ne=tt.keywordPatternRe.exec(Ut),ke="";for(;ne;){ke+=Ut.substring(D,ne.index);const Ce=Yn.case_insensitive?ne[0].toLowerCase():ne[0],Ue=ot(tt,Ce);if(Ue){const[wt,cn]=Ue;if(bn.addText(ke),ke="",ln[Ce]=(ln[Ce]||0)+1,ln[Ce]<=_t&&(vr+=cn),wt.startsWith("_"))ke+=ne[0];else{const Vt=Yn.classNameAliases[wt]||wt;lt(ne[0],Vt)}}else ke+=ne[0];D=tt.keywordPatternRe.lastIndex,ne=tt.keywordPatternRe.exec(Ut)}ke+=Ut.substring(D),bn.addText(ke)}function ce(){if(Ut==="")return;let D=null;if(typeof tt.subLanguage=="string"){if(!fe[tt.subLanguage]){bn.addText(Ut);return}D=ht(tt.subLanguage,Ut,!0,es[tt.subLanguage]),es[tt.subLanguage]=D._top}else D=Ke(Ut,tt.subLanguage.length?tt.subLanguage:null);tt.relevance>0&&(vr+=D.relevance),bn.__addSublanguage(D._emitter,D.language)}function De(){tt.subLanguage!=null?ce():B(),Ut=""}function lt(D,ne){D!==""&&(bn.startScope(ne),bn.addText(D),bn.endScope())}function ut(D,ne){let ke=1;const Ce=ne.length-1;for(;ke<=Ce;){if(!D._emit[ke]){ke++;continue}const Ue=Yn.classNameAliases[D[ke]]||D[ke],wt=ne[ke];Ue?lt(wt,Ue):(Ut=wt,B(),Ut=""),ke++}}function Bt(D,ne){return D.scope&&typeof D.scope=="string"&&bn.openNode(Yn.classNameAliases[D.scope]||D.scope),D.beginScope&&(D.beginScope._wrap?(lt(Ut,Yn.classNameAliases[D.beginScope._wrap]||D.beginScope._wrap),Ut=""):D.beginScope._multi&&(ut(D.beginScope,ne),Ut="")),tt=Object.create(D,{parent:{value:tt}}),tt}function kn(D,ne,ke){let Ce=E(D.endRe,ke);if(Ce){if(D["on:end"]){const Ue=new t(D);D["on:end"](ne,Ue),Ue.isMatchIgnored&&(Ce=!1)}if(Ce){for(;D.endsParent&&D.parent;)D=D.parent;return D}}if(D.endsWithParent)return kn(D.parent,ne,ke)}function vn(D){return tt.matcher.regexIndex===0?(Ut+=D[0],1):(O=!0,0)}function Lr(D){const ne=D[0],ke=D.rule,Ce=new t(ke),Ue=[ke.__beforeBegin,ke["on:begin"]];for(const wt of Ue)if(wt&&(wt(D,Ce),Ce.isMatchIgnored))return vn(ne);return ke.skip?Ut+=ne:(ke.excludeBegin&&(Ut+=ne),De(),!ke.returnBegin&&!ke.excludeBegin&&(Ut=ne)),Bt(ke,D),ke.returnBegin?0:ne.length}function Vr(D){const ne=D[0],ke=Be.substring(D.index),Ce=kn(tt,D,ke);if(!Ce)return Un;const Ue=tt;tt.endScope&&tt.endScope._wrap?(De(),lt(ne,tt.endScope._wrap)):tt.endScope&&tt.endScope._multi?(De(),ut(tt.endScope,D)):Ue.skip?Ut+=ne:(Ue.returnEnd||Ue.excludeEnd||(Ut+=ne),De(),Ue.excludeEnd&&(Ut=ne));do tt.scope&&bn.closeNode(),!tt.skip&&!tt.subLanguage&&(vr+=tt.relevance),tt=tt.parent;while(tt!==Ce.parent);return Ce.starts&&Bt(Ce.starts,D),Ue.returnEnd?0:ne.length}function vo(){const D=[];for(let ne=tt;ne!==Yn;ne=ne.parent)ne.scope&&D.unshift(ne.scope);D.forEach(ne=>bn.openNode(ne))}let wr={};function Pr(D,ne){const ke=ne&&ne[0];if(Ut+=D,ke==null)return De(),0;if(wr.type==="begin"&&ne.type==="end"&&wr.index===ne.index&&ke===""){if(Ut+=Be.slice(ne.index,ne.index+1),!te){const Ce=new Error(`0 width match regex (${je})`);throw Ce.languageName=je,Ce.badRule=wr.rule,Ce}return 1}if(wr=ne,ne.type==="begin")return Lr(ne);if(ne.type==="illegal"&&!yt){const Ce=new Error('Illegal lexeme "'+ke+'" for mode "'+(tt.scope||"<unnamed>")+'"');throw Ce.mode=tt,Ce}else if(ne.type==="end"){const Ce=Vr(ne);if(Ce!==Un)return Ce}if(ne.type==="illegal"&&ke==="")return ne.index===Be.length||(Ut+=`
196
+ `),1;if(Ee>1e5&&Ee>ne.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ut+=ke,ke.length}const Yn=sr(je);if(!Yn)throw Xe(Ne.replace("{}",je)),new Error('Unknown language: "'+je+'"');const bo=In(Yn);let Pt="",tt=xt||bo;const es={},bn=new _e.__emitter(_e);vo();let Ut="",vr=0,Qn=0,Ee=0,O=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(Be,bn);else{for(tt.matcher.considerAll();;){Ee++,O?O=!1:tt.matcher.considerAll(),tt.matcher.lastIndex=Qn;const D=tt.matcher.exec(Be);if(!D)break;const ne=Be.substring(Qn,D.index),ke=Pr(ne,D);Qn=D.index+ke}Pr(Be.substring(Qn))}return bn.finalize(),Pt=bn.toHTML(),{language:je,value:Pt,relevance:vr,illegal:!1,_emitter:bn,_top:tt}}catch(D){if(D.message&&D.message.includes("Illegal"))return{language:je,value:tn(Be),illegal:!0,relevance:0,_illegalBy:{message:D.message,index:Qn,context:Be.slice(Qn-100,Qn+100),mode:D.mode,resultSoFar:Pt},_emitter:bn};if(te)return{language:je,value:tn(Be),illegal:!1,relevance:0,errorRaised:D,_emitter:bn,_top:tt};throw D}}function wn(je){const Be={value:tn(je),illegal:!1,relevance:0,_top:be,_emitter:new _e.__emitter(_e)};return Be._emitter.addText(je),Be}function Ke(je,Be){Be=Be||_e.languages||Object.keys(fe);const yt=wn(je),xt=Be.filter(sr).filter(wo).map(De=>ht(De,je,!1));xt.unshift(yt);const ln=xt.sort((De,lt)=>{if(De.relevance!==lt.relevance)return lt.relevance-De.relevance;if(De.language&&lt.language){if(sr(De.language).supersetOf===lt.language)return 1;if(sr(lt.language).supersetOf===De.language)return-1}return 0}),[ot,B]=ln,ce=ot;return ce.secondBest=B,ce}function Kn(je,Be,yt){const xt=Be&&Ie[Be]||yt;je.classList.add("hljs"),je.classList.add(`language-${xt}`)}function Nt(je){let Be=null;const yt=Mt(je);if(Oe(yt))return;if(Zn("before:highlightElement",{el:je,language:yt}),je.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",je);return}if(je.children.length>0&&(_e.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(je)),_e.throwUnescapedHTML))throw new Gt("One of your code blocks includes unescaped HTML.",je.innerHTML);Be=je;const xt=Be.textContent,ln=yt?Tt(xt,{language:yt,ignoreIllegals:!0}):Ke(xt);je.innerHTML=ln.value,je.dataset.highlighted="yes",Kn(je,yt,ln.language),je.result={language:ln.language,re:ln.relevance,relevance:ln.relevance},ln.secondBest&&(je.secondBest={language:ln.secondBest.language,relevance:ln.secondBest.relevance}),Zn("after:highlightElement",{el:je,result:ln,text:xt})}function Sn(je){_e=nn(_e,je)}const Nn=()=>{Xt(),Wt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Hn(){Xt(),Wt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Lt=!1;function Xt(){function je(){Xt()}if(document.readyState==="loading"){Lt||window.addEventListener("DOMContentLoaded",je,!1),Lt=!0;return}document.querySelectorAll(_e.cssSelector).forEach(Nt)}function mn(je,Be){let yt=null;try{yt=Be(H)}catch(xt){if(Xe("Language definition for '{}' could not be registered.".replace("{}",je)),te)Xe(xt);else throw xt;yt=be}yt.name||(yt.name=je),fe[je]=yt,yt.rawDefinition=Be.bind(null,H),yt.aliases&&Mr(yt.aliases,{languageName:je})}function Gn(je){delete fe[je];for(const Be of Object.keys(Ie))Ie[Be]===je&&delete Ie[Be]}function On(){return Object.keys(fe)}function sr(je){return je=(je||"").toLowerCase(),fe[je]||fe[Ie[je]]}function Mr(je,{languageName:Be}){typeof je=="string"&&(je=[je]),je.forEach(yt=>{Ie[yt.toLowerCase()]=Be})}function wo(je){const Be=sr(je);return Be&&!Be.disableAutodetect}function on(je){je["before:highlightBlock"]&&!je["before:highlightElement"]&&(je["before:highlightElement"]=Be=>{je["before:highlightBlock"](Object.assign({block:Be.el},Be))}),je["after:highlightBlock"]&&!je["after:highlightElement"]&&(je["after:highlightElement"]=Be=>{je["after:highlightBlock"](Object.assign({block:Be.el},Be))})}function Do(je){on(je),rt.push(je)}function so(je){const Be=rt.indexOf(je);Be!==-1&&rt.splice(Be,1)}function Zn(je,Be){const yt=je;rt.forEach(function(xt){xt[yt]&&xt[yt](Be)})}function Vn(je){return Wt("10.7.0","highlightBlock will be removed entirely in v12.0"),Wt("10.7.0","Please use highlightElement now."),Nt(je)}Object.assign(H,{highlight:Tt,highlightAuto:Ke,highlightAll:Xt,highlightElement:Nt,highlightBlock:Vn,configure:Sn,initHighlighting:Nn,initHighlightingOnLoad:Hn,registerLanguage:mn,unregisterLanguage:Gn,listLanguages:On,getLanguage:sr,registerAliases:Mr,autoDetection:wo,inherit:nn,addPlugin:Do,removePlugin:so}),H.debugMode=function(){te=!1},H.safeMode=function(){te=!0},H.versionString=kt,H.regex={concat:x,lookahead:k,either:N,optional:v,anyNumberOfTimes:y};for(const je in ee)typeof ee[je]=="object"&&e(ee[je]);return Object.assign(H,ee),H},Rn=Kt({});return Rn.newInstance=()=>Kt({}),ah=Rn,Rn.HighlightJS=Rn,Rn.default=Rn,ah}var pz=fz();const hz=wb(pz),O0={},mz="hljs-";function gz(e){const t=hz.newInstance();return e&&a(e),{highlight:n,highlightAuto:r,listLanguages:o,register:a,registerAlias:l,registered:u};function n(c,p,m){const h=m||O0,k=typeof h.prefix=="string"?h.prefix:mz;if(!t.getLanguage(c))throw new Error("Unknown language: `"+c+"` is not registered");t.configure({__emitter:kz,classPrefix:k});const y=t.highlight(p,{ignoreIllegals:!0,language:c});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const v=y._emitter.root,x=v.data;return x.language=y.language,x.relevance=y.relevance,v}function r(c,p){const h=(p||O0).subset||o();let k=-1,y=0,v;for(;++k<h.length;){const x=h[k];if(!t.getLanguage(x))continue;const _=n(x,c,p);_.data&&_.data.relevance!==void 0&&_.data.relevance>y&&(y=_.data.relevance,v=_)}return v||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function a(c,p){if(typeof c=="string")t.registerLanguage(c,p);else{let m;for(m in c)Object.hasOwn(c,m)&&t.registerLanguage(m,c[m])}}function l(c,p){if(typeof c=="string")t.registerAliases(typeof p=="string"?p:[...p],{languageName:c});else{let m;for(m in c)if(Object.hasOwn(c,m)){const h=c[m];t.registerAliases(typeof h=="string"?h:[...h],{languageName:m})}}}function u(c){return!!t.getLanguage(c)}}class kz{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(l,u){return u?l+"_".repeat(u):n.options.classPrefix+l}),o=this.stack[this.stack.length-1],a={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(a),this.stack.push(a)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const V_=gz({bash:zD,css:GD,go:VD,ini:YD,javascript:tz,json:oz,markdown:sz,python:iz,rust:az,typescript:cz,xml:uz,yaml:dz}),$0={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 _g(e,t){const n=e&&($0[e]??(V_.registered(e)?e:null));if(n)return n;const r=t.lastIndexOf("."),o=r<0?"":t.slice(r+1).toLowerCase();return(o?$0[o]:null)??null}const yz=/^(?:diff --git a\/\S+ b\/(\S+)|\+\+\+ (?:b\/)?(\S+))$/gm;function wz(e){const t=new Set;for(const n of e.matchAll(yz)){const r=n[1]??n[2]??"";r&&r!=="/dev/null"&&t.add(r)}return t.size===1?[...t][0]:""}const vz={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 Y_(e,t){const n=[[]],r=(a,l)=>{const u=a.split(`
197
+ `);for(const[c,p]of u.entries()){if(c>0&&n.push([]),!p)continue;const m=n[n.length-1],h=m[m.length-1];h&&h.scope===l?h.text+=p:m.push({text:p,scope:l})}},o=(a,l)=>{for(const u of a)u.type==="text"?r(u.value,l):u.type==="element"&&o(u.children,bz(u)??l)};try{o(V_.highlight(t,e).children,"")}catch{return e.split(`
198
+ `).map(a=>a?[{text:a,scope:""}]:[])}return n}function bz(e){var r;const t=((r=e.properties)==null?void 0:r.className)??[];let n=null;for(const o of t){const a=vz[o.startsWith("hljs-")?o.slice(5):o];a&&(n=a)}return n}const M0=/^\d+\t/;function Eg(e,t){if(!t)return[];const n=e.split(`
199
+ `),r=M0.test(n[0]??""),o=r?n.map(l=>{var u;return((u=M0.exec(l))==null?void 0:u[0])??""}):[],a=r?n.map((l,u)=>l.slice(o[u].length)).join(`
200
+ `):e;return Y_(a,t).map((l,u)=>{const c=l.map(m=>({text:m.text,changed:!1,scope:m.scope})),p=o[u];return p?[{text:p,changed:!1,scope:""},...c]:c})}function xz(e,t){var r;const n=new Array(e.length);if(t){let o=0;for(let a=0;a<=e.length;a++){const l=(r=e[a])==null?void 0:r.kind;a<e.length&&l!=="hunk"&&l!=="meta"||(_z(e,o,a,t,n),o=a+1)}}return e.map((o,a)=>Ez(o.spans,n[a],o.text))}function _z(e,t,n,r,o){var a,l;for(const u of["del","add"]){const c=[];for(let h=t;h<n;h++){const k=(a=e[h])==null?void 0:a.kind;(k===""||k===u)&&c.push(h)}if(c.length===0)continue;const p=c.map(h=>{var k;return((k=e[h])==null?void 0:k.text)??""}).join(`
201
+ `),m=Y_(p,r);for(const[h,k]of c.entries())(u==="add"||((l=e[k])==null?void 0:l.kind)==="del")&&(o[k]=m[h])}}function Ez(e,t,n){if(!(e!=null&&e.length)&&!(t!=null&&t.length))return n?[{text:n,changed:!1,scope:""}]:[];const r=[],o=e!=null&&e.length?e:[{text:n,changed:!1}],a=t!=null&&t.length?t:[{text:n,scope:""}];let l=0,u=0,c=0,p=0;for(;l<o.length&&u<a.length;){const m=o[l],h=a[u],k=Math.min(m.text.length-c,h.text.length-p);if(k>0){const y={text:m.text.slice(c,c+k),changed:m.changed,scope:h.scope},v=r[r.length-1];v&&v.changed===y.changed&&v.scope===y.scope?v.text+=y.text:r.push(y)}c+=k,p+=k,c>=m.text.length&&(l++,c=0),p>=h.text.length&&(u++,p=0)}return r}un.use({extensions:[LD],renderer:{code({text:e,lang:t}){const n=_g((t??"").trim().toLowerCase().split(/\s+/)[0]??"","");return n?`<pre><code>${Eg(e,n).map(o=>o.map(a=>a.scope?`<span class="sy-${a.scope}">${L0(a.text)}</span>`:L0(a.text)).join("")).join(`
202
+ `)}</code></pre>
203
+ `:!1},table:DD}});const L0=e=>e.replace(/[&<>]/g,t=>t==="&"?"&amp;":t==="<"?"&lt;":"&gt;"),Q_=O4(window);let ds=null;Q_.addHook("afterSanitizeAttributes",e=>{const t=e.tagName==="A"?e.getAttribute("href")??"":"";if(t===M_){e.removeAttribute("href"),e.classList.add("link-pending","live-text");return}/^https?:/i.test(t)&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noreferrer"));const n=ds!=null&&ds.fileRoot?P_(ds.fileRoot,t):null,r=n?null:D_(t);if(n?(e.classList.add("file-link"),e.setAttribute("data-tip",n.folder?`${n.path}/`:`${n.path}${n.line?`:${n.line}`:""}`),e.setAttribute("data-tip-placement","follow")):r&&(e.classList.add("file-link"),e.setAttribute("data-tip",`${r.path}${r.line?`:${r.line}`:""}`),e.setAttribute("data-tip-placement","follow")),e.tagName==="CODE"&&!e.closest("pre, a")){const a=PD(e.textContent??"");a&&e.setAttribute("data-path",a)}const o=ds==null?void 0:ds.base;if(e.tagName==="IMG"&&o){const a=xg(o.dir,e.getAttribute("src")??"");a&&e.setAttribute("src",tg(o.worktreeId,a,o.version))}});function Wl(e,t){ds=t??null;const n=t!=null&&t.streaming?RD(e):e;try{return Q_.sanitize(un.parse(n,{async:!1}))}finally{ds=null}}function Sg(e,t){var m,h,k;const[n,r]=S.useState(()=>Wl(e,t)),o=S.useRef(0),a=(m=t==null?void 0:t.base)==null?void 0:m.worktreeId,l=(h=t==null?void 0:t.base)==null?void 0:h.dir,u=(k=t==null?void 0:t.base)==null?void 0:k.version,c=t==null?void 0:t.fileRoot,p=t==null?void 0:t.streaming;return S.useEffect(()=>{const y=a!==void 0&&l!==void 0?{worktreeId:a,dir:l,version:u??null}:void 0,v=y||c||p?{base:y,fileRoot:c,streaming:p}:void 0,x=performance.now()-o.current;if(x>=100){o.current=performance.now(),r(Wl(e,v));return}const _=setTimeout(()=>{o.current=performance.now(),r(Wl(e,v))},100-x);return()=>clearTimeout(_)},[e,a,l,u,c,p]),n}const X_=e=>e.replace(/\n$/,""),Sz=1500,P0=4;function J_(e){return e.closest(".md pre")}function Xh(e){const t=J_(e);return t?X_(t.textContent??""):null}function Nz(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{pre:t,top:r.top-n.top+e.scrollTop+P0,right:n.left+e.clientLeft+e.clientWidth-r.right+P0}}function Ng(e){const[t,n]=S.useState(null),[r,o]=S.useState(null);if(S.useEffect(()=>{const p=e.current;if(!p)return;const m=k=>{if(!(k.target instanceof Element)||k.target.closest(".code-copy"))return;const y=J_(k.target);n(y&&p.contains(y)?Nz(p,y):null)},h=()=>n(null);return p.addEventListener("pointerover",m),p.addEventListener("pointerleave",h),()=>{p.removeEventListener("pointerover",m),p.removeEventListener("pointerleave",h)}},[e]),S.useEffect(()=>{if(!r)return;const p=setTimeout(()=>o(null),Sz);return()=>clearTimeout(p)},[r]),!(t!=null&&t.pre.isConnected))return null;const{pre:a,top:l,right:u}=t,c=r===a;return f.jsx(At,{className:"code-copy",style:{top:l,right:u},icon:c?"check":"copy",label:c?"Copied":"Copy code",onClick:()=>{Zt(X_(a.textContent??"")),o(a)}})}function Tz(e){return!e||e===document.body?!1:e.closest(".monaco-editor, .xterm")?!0:(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.closest(".chat-input")}function eE(e,t){gt([t],()=>{const o=requestAnimationFrame(()=>{var a;Tz(document.activeElement)||(a=e.current)==null||a.focus()});return()=>cancelAnimationFrame(o)});const n=S.useRef(!1),r=S.useCallback(()=>{requestAnimationFrame(()=>{var o;document.activeElement===document.body&&((o=e.current)==null||o.focus())})},[e]);return S.useEffect(()=>{const o=()=>{n.current=!0},a=()=>{n.current=!1,r()};return window.addEventListener("pointerdown",o,!0),window.addEventListener("pointerup",a,!0),window.addEventListener("pointercancel",a,!0),()=>{window.removeEventListener("pointerdown",o,!0),window.removeEventListener("pointerup",a,!0),window.removeEventListener("pointercancel",a,!0)}},[r]),o=>{!o.relatedTarget&&!n.current&&r()}}function jz({item:e,worktreeId:t,rootRef:n,onAnswer:r}){return e.ask.kind==="question"?f.jsx(Cz,{item:e,ask:e.ask,worktreeId:t,root:n,onAnswer:r}):f.jsx(Az,{item:e,ask:e.ask,worktreeId:t,root:n})}const tE=e=>e.length===1&&e>="1"&&e<="9",Ol=e=>e.key==="Enter"||e.key==="NumpadEnter";function Cz({item:e,ask:t,worktreeId:n,root:r,onAnswer:o}){const a=eE(r,e.id),l=it(),u=ct(),{message:c,questions:p}=t,m=Ot(n,"ask"),h=S.useMemo(()=>(m==null?void 0:m.id)===e.id?m:{id:e.id,draft:z$(p),current:0},[m,e.id,p]),{draft:k,current:y}=h,v=y===zl(p),x=p[y],_=k[y],N=!!(x!=null&&x.multi),[j,E]=S.useState(()=>ga(x,_)),M=Vs(),K=S.useRef(null);S.useEffect(()=>{const A=window.visualViewport;if(!A)return;const X=()=>{K.current&&K.current===document.activeElement&&K.current.scrollIntoView({block:"nearest"})};return A.addEventListener("resize",X),()=>A.removeEventListener("resize",X)},[]);const U=(A,X)=>u({a:"ask-draft",id:n,ask:{id:e.id,draft:A,current:X}}),R=A=>{if(!o)return l==null?void 0:l.send({t:"agent-answer",worktreeId:n,askId:e.id,...A?{answers:A}:{}});A&&o(A)},I=()=>u(o?{a:"ask-revive",id:n}:{a:"ask-park",id:n,askId:e.id}),C=()=>{ju(p,k)&&R(k)},P=A=>{E(ga(p[A],k[A])),U(k,A)},z=A=>{x!=null&&x.note&&(U(sv(k,y,A,N),y),requestAnimationFrame(()=>{var X;return(X=K.current)==null?void 0:X.focus()}))},q=()=>{if(!(x!=null&&x.note))return;const A=x.options[j];if(!A||N)return z(!A);U(sv(ov(k,y,A.value,!1),y,!1,!1),y),requestAnimationFrame(()=>{var X;return(X=K.current)==null?void 0:X.focus()})},se=A=>{if(F$(x,A))return E(A),z(!0);const X=x==null?void 0:x.options[A];if(!x||!X)return;const Z=ov(k,y,X.value,N);if(N){E(A),U(Z,y);return}const $=av(p,Z,y);E($.cursor),U(Z,$.current),$.send&&ju(p,Z)&&R(Z)},pe=A=>{var X,Z;if(A.target instanceof HTMLTextAreaElement){if(A.key==="Escape"||A.key==="Tab"&&!A.shiftKey){A.preventDefault(),A.stopPropagation();const $=iv(k,y);$!==k&&(U($,y),E(ga(x,$[y]))),(X=r.current)==null||X.focus()}else if(Ol(A)&&(A.metaKey||A.ctrlKey))A.preventDefault(),C();else if(Ol(A)&&!A.shiftKey){A.preventDefault();const $=iv(k,y);if((Z=r.current)==null||Z.focus(),!va($[y])){$!==k&&(U($,y),E(ga(x,$[y])));return}const V=av(p,$,y);E(V.cursor),U($,V.current),V.send&&ju(p,$)&&R($)}return}if(!Cx(A)){if(A.key==="Escape")return A.preventDefault(),A.stopPropagation(),I();if(Ol(A)&&(A.metaKey||A.ctrlKey))return A.preventDefault(),C();if(Ol(A)||A.key===" "&&N)return A.preventDefault(),v?C():se(j);if(A.key==="ArrowUp"||A.key==="ArrowDown")return A.preventDefault(),x?E(Fa(j,A.key==="ArrowUp"?-1:1,Ox(x))):void 0;if(A.key==="ArrowLeft"||A.key==="ArrowRight"||A.key==="Tab"){A.preventDefault();const $=A.key==="ArrowLeft"||A.key==="Tab"&&A.shiftKey;return P(H$(y,$?-1:1,K$(p)))}if(A.key==="n"&&(x!=null&&x.note))return A.preventDefault(),q();if(A.key==="s"&&!o)return A.preventDefault(),R();if(tE(A.key)){const $=v?Number(A.key)<=p.length?Number(A.key)-1:-1:U$(x,Number(A.key));return $===-1?void 0:(A.preventDefault(),v?P($):se($))}}},ue=A=>p.length===1&&!A.multi,xe=(A,X)=>f.jsxs("div",{className:"ask-foot",children:[(!A||!ue(A))&&f.jsx(ze,{variant:"outline",size:"md",disabled:!ju(p,k),onClick:C,children:"send"}),(A==null?void 0:A.note)&&X&&X.selected.length>0&&X.note===void 0&&f.jsxs(ze,{tone:"quiet",size:"md",onClick:()=>z(!1),children:[f.jsx(Or,{k:"n",chip:!0}),"add a note"]}),!o&&f.jsxs(ze,{tone:"quiet",size:"md",onClick:()=>R(),children:[f.jsx(Or,{k:"s",chip:!0}),"skip"]})]}),oe=(A,X)=>{const Z=X===y,$=k[X],V=$x($,!!A.multi),de=Z?A.options[j]:void 0,me=rr({cursor:Z&&!M&&j===A.options.length,checked:V}),he=()=>j!==A.options.length&&E(A.options.length),$e=ve=>f.jsx(Ia,{ref:Z?K:void 0,bare:!0,font:"ui",rows:1,className:"ask-own-field",enterKeyHint:zl(p)===-1?"send":"next",placeholder:ve,value:($==null?void 0:$.note)??"",onChange:Re=>U(Rx(k,X,Re.target.value),X)}),ae=ve=>{var Re;ve.target instanceof HTMLTextAreaElement||(ve.preventDefault(),(Re=ve.currentTarget.querySelector("textarea"))==null||Re.focus())};return f.jsxs("div",{className:He("ask-page",!Z&&"ask-page-off"),children:[f.jsx("div",{className:"ask-head",children:f.jsx("div",{className:"ask-text",children:A.text||c})}),f.jsxs("div",{className:"ask-options",children:[A.options.map((ve,Re)=>{const ee=$==null?void 0:$.selected.includes(ve.value),Y=rr({cursor:Z&&!M&&Re===j,checked:ee}),Pe=()=>Re!==j&&E(Re),We=f.jsxs(f.Fragment,{children:[f.jsx(Or,{k:String(Re+1),className:"ask-num row-dim"}),f.jsxs("span",{className:"ask-label",children:[Dx(ve.label),Z$(ve.label)&&f.jsx("span",{className:"badge-recommended",children:"recommended"})]}),!M&&A.note&&!A.multi&&f.jsxs("span",{className:He("ask-hint row-dim",Z&&Re===j&&($==null?void 0:$.note)===void 0&&"on"),children:[f.jsx(Or,{k:"n"})," add a note"]}),ve.description&&f.jsx("span",{className:"ask-desc",children:ve.description})]});return ee&&!V&&($==null?void 0:$.note)!==void 0?f.jsxs("div",{className:"picker-item ask-opt row-edge","data-state":Y,onMouseMove:Pe,onMouseDown:ae,children:[We,$e("a note for the agent, sent with your pick")]},ve.value):f.jsx("button",{type:"button",className:"picker-item ask-opt row-edge","data-state":Y,onMouseMove:Pe,onClick:()=>{var Fe;se(Re),(Fe=r.current)==null||Fe.focus()},children:We},ve.value)}),A.note&&!V&&f.jsxs("button",{type:"button",className:"picker-item ask-opt row-edge","data-state":me,onMouseMove:he,onClick:()=>se(A.options.length),children:[f.jsx(Or,{k:String(A.options.length+1),className:"ask-num row-dim"}),f.jsx("span",{className:"ask-label",children:A.note.label}),f.jsx("span",{className:"ask-desc row-dim",children:"your own answer"})]}),A.note&&V&&($==null?void 0:$.note)!==void 0&&f.jsxs("div",{className:"picker-item ask-opt row-edge","data-state":me,onMouseMove:he,onMouseDown:ae,children:[f.jsx(Or,{k:String(A.options.length+1),className:"ask-num row-dim"}),f.jsx("span",{className:"ask-label",children:A.note.label}),$e("your own answer")]})]}),(de==null?void 0:de.preview)&&f.jsx("pre",{className:"ask-preview",children:de.preview}),xe(A,$)]},A.id)};return f.jsxs("div",{ref:r,className:"ask-box",tabIndex:-1,onKeyDown:pe,onBlur:a,children:[p.length>1&&f.jsx("div",{className:"ask-tabs",children:f.jsx(Xd,{label:"questions",owner:"ask",items:[...p.map((A,X)=>({id:String(X),label:A.header||`question ${X+1}`,lead:f.jsx("span",{className:He("dot ask-step",va(k[X])&&"answered")})})),{id:String(p.length),label:"send",far:!0}],current:String(y),onPick:A=>{var X;P(Number(A)),(X=r.current)==null||X.focus()}})}),f.jsxs("div",{className:"ask-pages",children:[p.map(oe),zl(p)!==-1&&f.jsxs("div",{className:He("ask-page",!v&&"ask-page-off"),children:[f.jsx("div",{className:"ask-head",children:f.jsx("div",{className:"ask-text",children:"Send these answers?"})}),f.jsx("div",{className:"ask-options",children:p.map((A,X)=>{const Z=va(k[X]);return f.jsxs("button",{type:"button",className:"picker-item ask-opt ask-sum",onClick:()=>{var $;P(X),($=r.current)==null||$.focus()},children:[f.jsx(Or,{k:String(X+1),className:"ask-num row-dim"}),f.jsxs("span",{className:"ask-label",children:[f.jsx("span",{className:"row-dim",children:A.header||`question ${X+1}`})," ",f.jsx("span",{className:He(!Z&&"row-dim"),children:Z?Mx(A,k[X]):"no answer yet"})]})]},A.id)})}),xe()]})]})]})}function Az({item:e,ask:t,worktreeId:n,root:r}){const o=eE(r,e.id),a=it(),l=ct(),u=L(j=>j.activeId),[c,p]=S.useState(0),m=Vs(),h=t.plan,k=S.useMemo(()=>t.detail&&!h?Wl(t.detail):"",[t.detail,h]),y=S.useRef(null),v=Ng(y),x=()=>{h&&u===n&&nr({dispatch:l},{worktreeId:n,path:h,view:"preview",focus:!1})};gt([e.id,h],x);const _=j=>{const E=t.choices[j];E&&(a==null||a.send({t:"agent-decide",worktreeId:n,askId:e.id,choiceId:E.id}))},N=j=>{if(!Cx(j)){if(j.key==="Escape")return j.preventDefault(),j.stopPropagation(),l({a:"ask-park",id:n,askId:e.id});if(Ol(j))return j.preventDefault(),_(c);if(j.key==="ArrowUp"||j.key==="ArrowDown")return j.preventDefault(),p(Fa(c,j.key==="ArrowUp"?-1:1,t.choices.length));tE(j.key)&&t.choices[Number(j.key)-1]&&(j.preventDefault(),_(Number(j.key)-1))}};return f.jsxs("div",{ref:r,className:"ask-box",tabIndex:-1,onKeyDown:N,onBlur:o,children:[f.jsx("div",{className:"ask-head",children:f.jsx("div",{className:"ask-text",children:t.title})}),k&&f.jsxs("div",{ref:y,className:"ask-detail md",children:[f.jsx("div",{dangerouslySetInnerHTML:{__html:k}}),v]}),f.jsx("div",{className:"ask-options",children:t.choices.map((j,E)=>f.jsxs("button",{type:"button",className:He("picker-item ask-opt row-edge",j.kind.startsWith("reject")&&"deny"),"data-state":rr({cursor:!m&&E===c}),onMouseMove:()=>E!==c&&p(E),onClick:()=>_(E),children:[f.jsx(Or,{k:String(E+1),className:"ask-num row-dim"}),f.jsx("span",{className:"ask-label",children:j.name})]},j.id))})]})}const Iz={skipped:"you skipped this",cancelled:"the turn was stopped before you answered",expired:"Toyon restarted before you answered"};function Rz({item:e}){if(!e.outcome)return null;const t=Iz[e.outcome];if(e.ask.kind==="permission"){const{title:n,choices:r}=e.ask,o=r.find(a=>a.id===e.choiceId);return f.jsxs("div",{className:"ask-closed",children:[!e.toolId&&f.jsx("div",{className:"ask-lead",children:n}),f.jsx("div",{className:"ask-answered",children:o?o.name:t??"closed"})]})}return f.jsxs("div",{className:"ask-closed",children:[f.jsx("div",{className:"ask-lead",children:e.ask.message}),f.jsx("div",{className:"ask-answered",children:t??"closed"})]})}const Oz=e=>e.t==="open-path"||e.t==="open-loose",ka=new Map,$z=16;function Mz({sock:e,dispatch:t},n,r){const o=$o();ka.set(o,{worktreeId:n,href:r.href});for(const a of ka.keys()){if(ka.size<=$z)break;ka.delete(a)}t({a:"link-refused",id:n,v:null}),e==null||e.send({t:"open-by-path",path:r.path,seq:o})}function Lz(e,t){const n=ka.get(t.seq);n&&(ka.delete(t.seq),e.dispatch({a:"link-refused",id:n.worktreeId,v:{href:n.href,message:t.message}}))}function Pz(e,t,n){var a;const r=e.getState();if(n.t==="open-path"){const l={dispatch:c=>e.dispatch(c)};if(ms(r,n.worktreeId)){r.activeId!==n.worktreeId&&e.dispatch({a:"activate",id:n.worktreeId}),nr(l,{worktreeId:n.worktreeId,path:n.path});return}const u=Object.keys(r.trunks).find(c=>{var p;return((p=r.trunks[c])==null?void 0:p.id)===n.worktreeId});if(!u)return;if(((a=ms(r,r.activeId))==null?void 0:a.repoId)!==u){const c=r.rows.find(p=>p.repoId===u);if(!c)return;e.dispatch({a:"activate",id:c.id})}nr(l,{worktreeId:n.worktreeId,path:n.path});return}const o=r.activeId;if(!o){e.dispatch({a:"server",msg:{t:"error",message:`open a project first; ${n.name} needs a window to open in`}});return}e.dispatch({a:"open-loose",v:{worktreeId:o,name:n.name,text:n.text,binary:n.binary,tooLarge:n.tooLarge,source:{kind:"grant",id:n.id,path:n.path,version:n.version},seq:$o()}})}function Tg(e,t){const n=e.closest("a, code[data-path]");if(!n)return null;const r=n.getAttribute("data-path");if(r)return{kind:"path",path:r};const o=n.getAttribute("href");if(!o)return null;const a=t?P_(t,o):null;if(a)return{kind:"file",file:a};const l=D_(o);return l?{kind:"outside",href:o,...l}:{kind:"out",href:o}}function jg(e,t,n,r){const o=Tg(e.target,t);if((o==null?void 0:o.kind)==="outside"&&n){e.preventDefault(),Mz(r,n,o);return}if((o==null?void 0:o.kind)!=="file"||!n)return;const a=o.file;if(e.preventDefault(),a.folder){CM(r,{worktreeId:n,path:a.path});return}nr(r,{worktreeId:n,path:a.path,...a.line?{line:{n:a.line}}:{}})}const Dz=150,zz=e=>({side:e,align:"center",offset:12,flip:"side",margin:8});function nE({chip:e,className:t,children:n}){const[r,o]=S.useState(!1),a=L(u=>u.chatSide);S.useEffect(()=>{const u=e.current;if(!u)return;let c=0;const p=()=>{window.clearTimeout(c),o(!1)},m=()=>{window.clearTimeout(c),c=window.setTimeout(()=>o(!0),Dz)};return u.addEventListener("mouseenter",m),u.addEventListener("mouseleave",p),u.addEventListener("mousedown",p),()=>{window.clearTimeout(c),u.removeEventListener("mouseenter",m),u.removeEventListener("mouseleave",p),u.removeEventListener("mousedown",p)}},[e]);const l=()=>{var m;const u=e.current;if(!u)return null;const c=u.getBoundingClientRect(),p=((m=u.closest(".chat-log"))==null?void 0:m.getBoundingClientRect())??c;return{left:p.left,right:p.right,top:c.top,bottom:c.bottom}};return r?f.jsx(Ys,{className:He("chip-peek",t),anchor:l,placement:zz(a==="left"?"right":"left"),track:!0,children:n}):null}function Cg({className:e,label:t,tip:n,peek:r,full:o,menu:a,removeLabel:l,onRemove:u}){const c=S.useRef(null),[p,m]=S.useState(!1),h=sn("chat"),k=o!==void 0;return f.jsxs("div",{ref:c,className:He("pick-chip row row-sm",e),"data-tip":k?"Open full size":n,"data-tip-placement":"follow",...h.contextMenu(()=>a({open:k?()=>m(!0):void 0,remove:u})),children:[k?f.jsx("button",{type:"button",className:"chip-link",onClick:()=>m(!0),children:t}):t,u&&f.jsx(At,{icon:"close",label:l,tone:"quiet",onClick:u}),k&&r!==void 0&&f.jsx(nE,{chip:c,children:r}),p&&k&&f.jsx(pg,{owner:"chat",onClose:()=>m(!1),menu:()=>a(),children:o})]})}const Fz=/^ {0,3}(`{3,}|~{3,})/,Bz=/^#{1,6} \S/,Uz=/^\s*(?:[-*+]|\d+[.)]) \S/,Hz=/^> ?\S/,Wz=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,Kz=/\[[^\]\n]+\]\((?:https?:|\.{0,2}\/|#)[^)\s]*\)/,Zz=/\*\*[^\s*][^*\n]*\*\*/;function qz(e){var a,l;const t=e.split(`
204
+ `),n=new Set;let r=null,o=0;for(let u=0;u<t.length;u++){const c=t[u],p=(a=Fz.exec(c))==null?void 0:a[1];if(r){p!=null&&p.startsWith(r)&&(r=null,n.add("fence"));continue}if(p){r=p;continue}Bz.test(c)&&!((l=t[u+1])!=null&&l.trim())&&n.add("heading"),Uz.test(c)&&++o===2&&n.add("list"),Hz.test(c)&&n.add("quote"),Wz.test(c)&&n.add("table"),Kz.test(c)&&n.add("link"),Zz.test(c)&&n.add("bold")}return n.size}function Gz(e,t){if(t)return Fd(t)==="markdown"?"rendered":"plain";const n=qz(e);return n>=2?"rendered":n===1?"source":"plain"}function Ag({n:e,name:t,source:n,lines:r,chars:o,preview:a,text:l,href:u,onRemove:c,className:p=""}){const m=(n==null?void 0:n.path)??t??"",h=m.includes("/")?m.slice(0,m.lastIndexOf("/")):"",k=n?[h,n.ref?`at ${n.ref.slice(0,7)}`:""].filter(Boolean).join(" "):[h,`${r} ${r===1?"line":"lines"}`,`${o.toLocaleString()} chars`,a].filter(Boolean).join(" · "),y=f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"text",className:"icon-inline"}),f.jsxs("span",{className:"pick-target",children:[f.jsx("b",{children:t?t.slice(t.lastIndexOf("/")+1):n?SO(n):Eb("paste",e)}),k&&f.jsxs("span",{className:"pick-file row-dim",children:[" · ",k]})]})]}),v=l!==void 0||u!==void 0;return f.jsx(Cg,{className:He("paste-chip",p),label:y,tip:a||void 0,peek:v?f.jsx(sE,{text:l,href:u}):void 0,full:v?f.jsx(oE,{text:l,href:u,path:m||void 0}):void 0,menu:x=>v_({text:l,href:u},x),removeLabel:"Remove attachment",onRemove:c})}function rE(e,t){const[n,r]=S.useState(e??null),[o,a]=S.useState(!1);return S.useEffect(()=>{if(e!==void 0||!t)return;let l=!0;return fetch(t).then(u=>u.ok?u.text():Promise.reject(new Error(String(u.status)))).then(u=>{l&&r(u)}).catch(()=>{l&&a(!0)}),()=>{l=!1}},[e,t]),{text:e??n,failed:o}}function oE({text:e,href:t,path:n}){const{text:r,failed:o}=rE(e,t),a=S.useMemo(()=>r?Gz(r,n):"plain",[r,n]),[l,u]=S.useState(null);if(o)return f.jsx("p",{className:"paste-full hint",children:"Toyon could not read that back."});if(!r||a==="plain")return f.jsx("pre",{className:"paste-full paste-text",children:r});const c=l??a==="rendered";return f.jsxs("div",{className:"paste-full paste-doc",children:[f.jsx("div",{className:"paste-doc-head",children:f.jsxs(ze,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>u(!c),"data-tip":c?"Text: read it as it was sent":"Preview: read it rendered",children:[f.jsx(St,{name:c?"text":"book",className:"icon-inline"})," ",c?"text":"preview"]})}),c?f.jsx(Vz,{text:r}):f.jsx("pre",{className:"paste-doc-body paste-text",children:r})]})}function Vz({text:e}){const t=S.useMemo(()=>Wl(e),[e]);return f.jsx("div",{className:"paste-doc-body md md-preview",onClick:n=>{const r=n.target.closest("a");r&&r.target!=="_blank"&&n.preventDefault()},dangerouslySetInnerHTML:{__html:t}})}const Yz=2e4;function sE({text:e,href:t}){const{text:n}=rE(e,t);return n?f.jsx("pre",{className:"paste-peek paste-text",children:n.slice(0,Yz)}):null}function Ig({name:e,bytes:t,href:n,uploading:r,onRemove:o,className:a=""}){return f.jsx(Cg,{className:He("file-chip",a),label:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"file",className:"icon-inline"}),f.jsxs("span",{className:"pick-target",children:[f.jsx("b",{children:e}),f.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",Em(t),r&&" · uploading"]})]})]}),tip:e,peek:n?f.jsx(sE,{href:n}):void 0,full:n?f.jsx(oE,{href:n,path:e}):void 0,menu:l=>v_({href:n},l),removeLabel:"Remove attachment",onRemove:o})}function iE(e){return e.replace(/^([\t ]*)\*\*(\S(?:[^\n]*\S)?)\*\*([\t ]*)$/gm,"$1$2$3")}const aE=120,Qz=/^\*\*(\S(?:[^\n]*\S)?)\*\*$/;function lE(e){var n,r;const t=[];for(const o of e.split(/\n[\t ]*\n/)){const a=o.trim();if(!a)continue;const l=((r=(n=Qz.exec(a))==null?void 0:n[1])==null?void 0:r.replace(/`/g,""))??"";if(!l||l.length>aE)return[];t.push(l)}return t}function cE(e){const t=lE(e);if(t.length)return t.at(-1);const n=iE(e).trim().replace(/`/g,"");return n&&!n.includes(`
205
+ `)&&n.length<=aE?n:""}const Xz={read:"read",edit:"edit",delete:"delete",move:"move",search:"search",execute:"run",think:"think",fetch:"fetch",switch_mode:"mode",other:"tool"},D0={read:"book",edit:"edit",delete:"trash",move:"move",search:"search",execute:"run",think:"bulb",fetch:"globe",switch_mode:"swap",other:"dot"},z0=new Map([[Mm,"chat"],["Monitor","clock"],["TaskOutput","terminal"],["Skill","layers"]]),Jh={grep:"search",rg:"search",ag:"search",ack:"search",find:"search",fd:"search",cat:"book",head:"book",tail:"book",nl:"book",less:"book",bat:"book",ls:"folder",tree:"folder",mkdir:"folder",rm:"trash",rmdir:"trash",mv:"move",curl:"globe",wget:"globe",git:"branch"},Jz=/(^|\s)(-[A-Za-z]*[iI]|--in-place)/,F0=String.raw`(?:"[^"]*"|'[^']*'|[^\s;&|]+)`,B0=new RegExp(String.raw`^\s*(?:(?:cd|echo)\s+${F0}\s*(?:&&|;)|mkdir(?:\s+${F0})+\s*(?:&&|;)|(?:export\s+)?[A-Za-z_]\w*=(?:"[^"]*"|'[^']*'|[^\s;&|()\`]*)\s*(?:&&|;|(?=\s)))\s*`),e3=/^python[\d.]*$/,t3=new RegExp(`open\\([^)]*,\\s*["'][wax]|(?<!std(?:out|err))\\.write\\(|\\.write_text\\(`);function uE(e){let t=e;for(let n=t.replace(B0,"");n!==t;n=t.replace(B0,""))t=n;return t}const n3=new RegExp("(?<![0-9&])>{1,2}\\s*(?!\\/dev\\/null|&)[^\\s&>]"),dE=/&&|;|\n|\|/;function r3(e){return e.split(dE).some(t=>/^\s*(?:\S*\/)?sed\s/.test(t)&&Jz.test(t))}function o3(e){return e.split(/&&|;|\n/).map(t=>uE(t).trim().split(/\s+/)[0]??"").filter(Boolean).every(t=>Jh[t.slice(t.lastIndexOf("/")+1)]==="trash")}function s3(e){const t=uE(e).trim(),n=t.split(/\s+/)[0]??"",r=n.slice(n.lastIndexOf("/")+1),o=r==="sed"?r3(e)?void 0:"book":Jh[r];if(o==="book"||o==="search"){const a=t.split(dE)[0]??"";if(n3.test(a))return r==="cat"&&a.includes("<<")?"edit":void 0}if(!(o==="trash"&&!o3(t)))return o||(e3.test(r)?t.includes("<<")&&t3.test(t)?"edit":void 0:Jh[r])}function Yo(e,t){const n=e.input,r=n?n[t]:void 0;return typeof r=="string"?r:""}const i3=/^(?:\/(?:usr\/)?bin\/)?(?:ba|z|da)?sh\s+(?:-[a-zA-Z]+\s+)*(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\s*$/;function a3(e){const t=i3.exec(e.trim());return t?t[1]!==void 0?t[1]:(t[2]??"").replace(/\\(["\\$`])/g,"$1"):e}const l3="Guardian Review";function fE(e){return e.toolKind==="think"&&e.title===l3}function c3(e){const t=o=>{var l,u;return((u=(l=[...e.matchAll(new RegExp(`^${o}:[ \\t]*(.+)$`,"gm"))].at(-1))==null?void 0:l[1])==null?void 0:u.trim().toLowerCase())??""},n=t("Status"),r=t("Risk");return!n||n==="in progress"?"reviewing":r?`${n}, ${r} risk`:n}function oc(e,t=[]){const n=a3(Yo(e,"command")),o=pE(e)||n||Yo(e,"path")||Yo(e,"pattern")||(e.title&&e.title!==e.name?e.title:""),a=Rg(Yo(e,"description")||o,t),l=e.toolKind&&e.toolKind in D0?e.toolKind:"other",u=Xz[l],c=e.name===Mm,p=(l!=="other"||c)&&e.name!==DO,m=a&&(p||e.name===e.title||e.name===Ma||e.name===bx)?"":e.name,h=m&&m.toLowerCase()!==u?m:a?"":u,k=(l==="execute"||l==="other")&&n?s3(n):void 0;return{label:c?"ask":u,name:h,icon:z0.get(e.name)??z0.get(e.title??"")??k??D0[l],hint:a===h?"":a,command:n&&n!==a?n:""}}const u3=/^Async agent launched/m;function d3(e){if(!e.subagent)return!1;const t=e.input;return!!e.detached||(t==null?void 0:t.run_in_background)===!0||!!e.output&&u3.test(e.output)}const f3={read:"choosing a file",edit:"writing the change",delete:"choosing a file",move:"choosing the files",search:"writing the search",execute:"writing the command",fetch:"writing the url"};function p3(e){const t=e.toolKind;return Td(e.input)?e.subagent?"writing the brief":e.name===Mm?"writing the question":bm(t)?f3[t]:"":""}function em(e,t){const n=hE(t),r=n[0],o=Yo(e,"description");return o&&r&&!r.code&&r.text===o?n.slice(1):n}function nf(e){return pE(e)||Yo(e,"path")}function h3(e){return Yo(e,"description")}function pE(e){return Yo(e,"file_path")||Yo(e,"filepath")||Yo(e,"filePath")||m3(e)}function m3(e){const t=e.input,n=Array.isArray(t==null?void 0:t.locations)?t.locations[0]:void 0,r=n&&typeof n=="object"?n.path:void 0;return typeof r=="string"?r:""}function Rg(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 g3=/^(`{3,})([\w+#.-]*)\s*$/;function hE(e){var u;const t=[];let n=[],r="",o=!1,a=0;const l=()=>{const c=n.join(`
206
+ `).replace(/^\n+|\n+$/g,"");c.trim()&&t.push({code:o,diff:k3(c,r),lang:o?r:"",text:c}),n=[]};for(const c of e.split(`
207
+ `)){const p=g3.exec(c),m=((u=p==null?void 0:p[1])==null?void 0:u.length)??0;if(!p||o&&(m<a||p[2])){n.push(c);continue}l(),o=!o,a=o?m:0,r=o?(p[2]??"").toLowerCase():""}return l(),t}function k3(e,t){return t==="diff"||t==="patch"||/^diff --git /m.test(e)||/^@@ .*@@/m.test(e)?!0:/^--- /m.test(e)&&/^[+-]/m.test(e)}const y3=/^(diff --git |index [0-9a-f]+\.\.|new file mode |deleted file mode |similarity index |rename (from|to) |Binary files )/;function w3(e){const t=[];for(const n of e.split(`
208
+ `)){const r=b3(n);if(r==="meta"&&!n.startsWith("diff --git "))continue;const o=r==="add"||r==="del"||n.startsWith(" ");t.push({kind:r,text:o?n.slice(1):n})}return v3(t),t}function v3(e){var t,n,r,o;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 l=a;for(;((r=e[l])==null?void 0:r.kind)==="del";)l++;let u=l;for(;((o=e[u])==null?void 0:o.kind)==="add";)u++;const c=e.slice(a,l),p=e.slice(l,u),m=c.length>0&&p.length>0?zT(c.map(h=>h.text).join(`
209
+ `),p.map(h=>h.text).join(`
210
+ `)):null;m&&(U0(c,lw(m.before)),U0(p,lw(m.after)));for(const h of[...c,...p])h.spans??(h.spans=[]);a=u}}function U0(e,t){if(t.length===e.length)for(const[n,r]of e.entries())r.spans=t[n]}function b3(e){return e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")||y3.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":""}function x3(e){const t=e.tools.at(-1);return!!t.background&&!t.done&&!t.parentToolId&&t.name!==Ma}const mE=new Set(["read","edit","fetch"]);function gE(e,t){if(e.isError||!e.toolKind||!mE.has(e.toolKind)||bm(e.toolKind)&&Td(e.input))return"";const{hint:n}=oc(e,t);return n?`${e.parentToolId??""}
211
+ ${e.toolKind}
212
+ ${e.name}
213
+ ${n}`:""}function H0(e,t,n){if(!t||!("tools"in t)||e.done||e.isError||!e.toolKind||!mE.has(e.toolKind))return!1;const r=t.tools[0];return r.toolKind===e.toolKind&&r.name===e.name&&r.parentToolId===e.parentToolId&&gE(r,n)!==""}function kE(e){const t=new Set;for(const n of e)n.kind==="tool"&&(n.subagent&&t.add(n.id),n.parentToolId&&t.add(n.parentToolId));return t}function _3(e){return e.done&&!e.output&&!e.isError&&bm(e.toolKind)&&Td(e.input)}function E3(e,t){const n=kE(e),r=[],o=new Map;let a="";for(const[l,u]of e.entries()){if(u.kind!=="tool"){a="",r.push({at:l,item:u});continue}if(_3(u))continue;if(n.has(u.id)){a="";const h={at:l,spawn:u,run:[],end:l};o.set(u.id,{entry:h,key:""}),r.push(h);continue}const c=gE(u,t),p=u.parentToolId?o.get(u.parentToolId):void 0;if(p){const h=p.entry.run,k=h.at(-1);c&&c===p.key&&k?k.tools.push(u):!c&&H0(u,k,t)?k.next=u:h.push({at:l,tools:[u]}),p.key=c,p.entry.end=l;continue}const m=r.at(-1);if(c&&c===a&&m&&"tools"in m){m.tools.push(u);continue}if(!c&&H0(u,m,t)){m.next=u;continue}a=c,r.push({at:l,tools:[u]})}return r}function S3(e){return e.reduce((t,n)=>t+n.tools.length,0)}function N3(e){const t=new Set,n=new Set;let r=!0;for(let a=e.length-1;a>=0;a--){const l=e[a];if(l.kind!=="tool"||!l.parentToolId){r=!1;continue}n.add(l.parentToolId),(r||!l.done)&&t.add(l.parentToolId)}let o=!0;for(let a=e.length-1;a>=0;a--){const l=e[a];l.kind==="user"&&(o=!1),!(l.kind!=="tool"||!l.subagent)&&(l.isError?t.delete(l.id):l.done?d3(l)?o&&!n.has(l.id)&&t.add(l.id):t.delete(l.id):t.add(l.id))}return t}function T3(e,t){const n=[],r=[];let o=-1;for(const a of e)"spawn"in a?t.has(a.spawn.id)?n.push(a):(o=Math.max(o,a.end),r.push({key:o,entry:a})):"tools"in a&&x3(a)?n.push(a):r.push({key:a.at,entry:a});return r.sort((a,l)=>a.key-l.key),{flow:r.map(a=>a.entry),floating:n}}function j3(e){const t=kE(e);return e.some(n=>n.kind==="tool"&&!n.done&&!n.parentToolId&&!n.background&&(!t.has(n.id)||Td(n.input)))}function C3(e){return e.findIndex(t=>"tools"in t&&!t.tools[0].parentToolId&&!t.tools.at(-1).done&&!t.tools.at(-1).background)}function yE(e,t=!1){const n=new Set;let r=!1,o=!1;return e.forEach((a,l)=>{if(!("tools"in a)||!t&&a.tools[0].parentToolId)return;const u=a.tools.at(-1);if(u.done||u.background||u.name===Ma)return;const c=vb({name:u.name,kind:u.toolKind});(o||r&&c)&&n.add(l),r=!0,o||(o=c)}),n}function A3(e){return e.findIndex(t=>!t.tools.at(-1).done)}function wE(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function I3(e,t){return!e||!t?e===t:e.length===t.length&&e.every((n,r)=>{var o,a;return n.at===((o=t[r])==null?void 0:o.at)&&n.next===((a=t[r])==null?void 0:a.next)&&wE(n.tools,t[r].tools)})}function R3(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!("spawn"in n)){if("tools"in n){const r=n.tools[0];if((r==null?void 0:r.toolKind)==="think"&&!fE(r))return t;continue}if(n.item.kind==="thinking"){if(!n.item.text.trim())continue;return cE(n.item.text)?-1:t}if(O3(n.item))return-1}}return-1}function O3(e){return e.kind==="assistant"?!!e.text.trim():e.kind==="ask"?e.ask.kind==="question"||!!e.outcome:!0}function $3(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if("seq"in r&&r.seq!==void 0&&r.seq<=t)return n}return-1}function Og({src:e,n:t,name:n,width:r,height:o,bytes:a,uploading:l,onRemove:u,className:c=""}){return f.jsx(Cg,{className:He("image-chip",c),label:f.jsxs(f.Fragment,{children:[f.jsx("img",{className:"image-thumb",src:e,alt:n,width:40,height:40}),f.jsxs("span",{className:"pick-target",children:[f.jsx("b",{children:Eb("image",t)}),f.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",n," · ",r,"×",o," · ",Em(a),l&&" · uploading"]})]})]}),peek:f.jsx("img",{src:e,alt:n,style:{aspectRatio:`${r} / ${o}`}}),full:f.jsx("img",{src:e,alt:n}),menu:p=>rc(e,p),removeLabel:"Remove image",onRemove:u})}function M3({img:e,src:t}){return f.jsx(Og,{className:"in-chat",src:t,...e})}function vE(e,{sock:t,dispatch:n}){var h,k;const r=y=>y?"hide":"show",o=e.repos.some(y=>y.id===e.activeRepoId),a=(h=fn(e,e.activeId))==null?void 0:h.worktree.id,l=[];o&&(l.push({id:"new",label:"new worktree…",key:Et("new"),onClick:()=>n({a:"open-draft"})}),l.push({id:"refs",label:"open a branch or PR…",key:Et("refs"),onClick:()=>n({a:"open",overlay:{kind:"refs"}})})),a&&(l.push({id:"jump",label:"jump to file…",key:Et("quick-open"),onClick:()=>n({a:"open",overlay:{kind:"quick-open"}})}),l.push({id:"search",label:"search in files…",key:Et("search"),onClick:()=>n({a:"open",overlay:{kind:"search"}})})),dd(e)&&l.push({id:"routes",label:"go to page…",key:Et("routes"),onClick:()=>n({a:"open",overlay:{kind:"routes"}})}),o&&l.push({id:"chats",label:"search chats…",key:Et("chats"),onClick:()=>n({a:"open",overlay:{kind:"chats"}})});const u=Dm(e.visible,e.activeId,1);u&&l.push({id:"wt-unseen-next",label:"next that needs you",key:Et("wt-unseen-next"),onClick:()=>n({a:"activate",id:u.activate})}),l.push({id:"project",label:e.repos.length>1?"switch project…":"open project…",key:Et("project"),onClick:()=>n({a:"open",overlay:{kind:"projects",form:"center"}})});const c=[{id:"changes",label:`${r(e.layout.changes)} changes panel`,key:Et("changes"),onClick:()=>n({a:"toggle-changes"})},{id:"files",label:`${r(e.layout.changes&&Ca(e)==="files")} files`,key:Et("files"),onClick:()=>n(e.layout.changes&&Ca(e)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"})},{id:"chat",label:`${r(e.layout.chat)} chat panel`,key:Et("composer"),onClick:()=>n({a:"toggle-chat"})},{id:"terminal",label:`${r(e.layout.term)} terminal`,key:Et("terminal"),onClick:()=>n({a:"toggle-terminal"})},{id:"rail",label:`${r(e.railOpen)} worktree panel`,key:Et("rail"),onClick:()=>n({a:"toggle-rail"})},{id:"design",label:`${r(e.layout.design)} design system`,key:Et("design"),onClick:()=>n({a:"toggle-design"})},{id:"zen",label:"full-bleed preview",key:Et("zen"),onClick:()=>n({a:"toggle-zen"})}],p=[{id:"commands",label:"command palette",key:Et("commands"),onClick:()=>n({a:"open",overlay:{kind:"commands"}})},{id:"keys",label:"settings & shortcuts",key:Et("keys"),onClick:()=>n({a:"open",overlay:{kind:"keys"}})}];if((k=e.self)!=null&&k.restart&&p.push({id:"restart-daemon",label:"restart Toyon",onClick:()=>t==null?void 0:t.send({t:"restart-daemon"})}),e.remote){e.frame==="desk"&&p.push({id:"pair",label:"open on your phone",onClick:()=>n({a:"open",overlay:{kind:"pair"}})});const y=KT(`https://${e.remote.host}`);p.push({id:"toyon-cloud",label:"add to toyon.cloud",...e.managed.deploy?{}:{disabled:"managed by your organization"},onClick:()=>window.open(y,"_blank")})}const m=mo(e)?new Set(["chat","design","zen"]):null;return Dn([l,m?c.filter(y=>!m.has(y.id)):c,p])}function $g(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 bE(e,{sock:t}){return[{id:"restart:shell",label:"restart shell",onClick:()=>t==null?void 0:t.send({t:"term-restart",worktreeId:e,stream:po})}]}function L3(e,t,n,r){return Dn([[...e.flatMap(o=>$g(o,t,r)),...bE(t,r)],[{id:"terminal",label:`${n?"hide":"show"} terminal`,onClick:()=>r.dispatch({a:"toggle-terminal"})}]])}function P3(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 rf(e,t,{sock:n,dispatch:r}){const o=[];e.id!==t&&o.push({id:`repo:${e.id}`,label:`switch to ${e.name}`,onClick:()=>r({a:"activate-repo",id:e.id})});const a=[{id:`setup:${e.id}`,label:"project settings…",detail:e.configFile,onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.id}})},{id:`archived:${e.id}`,label:"archived worktrees…",onClick:()=>{r({a:"activate-repo",id:e.id}),r({a:"open",overlay:{kind:"chats",names:!0}})}},{id:`forget:${e.id}`,label:"forget project…",danger:!0,onClick:()=>{window.confirm(`Forget ${e.name}?
214
+
215
+ 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 Dn([o,a])}const vd={dark:"dark",light:"light",system:"follow system",daylight:"follow daylight"},bd={use:"while in use",always:"always",off:"off"};function D3(e){const t=document.createElement("input");t.type="file",t.accept=".json,.jsonc,application/json",t.onchange=()=>{var r;const n=(r=t.files)==null?void 0:r[0];n&&n.text().then(o=>e(n.name,o))},t.click()}function xE(e,{sock:t,dispatch:n}){var l;const r=e.themePrefs,o=u=>{var c;return((c=e.themes.find(p=>p.id===u))==null?void 0:c.name)??u},a=lM();return Dn([[{id:"theme",label:"theme…",detail:zd(r,e.themes,qx(e)).name,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"theme"}})},{id:"appearance",topic:"theme",label:"light or dark…",detail:vd[r.mode],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"appearance"}})}],[{id:"agent",label:"default agent…",detail:((l=e.agents.find(u=>u.id===e.defaultAgent))==null?void 0:l.name)??e.defaultAgent,sub:!0,onClick:()=>n({a:"open",overlay:{kind:"agent"}})}],[{id:"chat-side",label:"chat side",detail:e.chatSide,onClick:()=>n({a:"toggle-chat-side"})},...a.access==="none"?[]:[{id:"clipboard-offer",label:"offer what is copied",detail:a.access==="denied"?"blocked in site settings":a.on?"on":"off",onClick:()=>cM(!a.on)}]],...e.keepAwake===null?[]:[[{id:"keep-awake",label:"keep the Mac awake…",detail:bd[e.keepAwake],sub:!0,onClick:()=>n({a:"open",overlay:{kind:"keep-awake"}})}]],[{id:"theme-import",topic:"theme",label:"import a VS Code theme…",onClick:()=>D3((u,c)=>t==null?void 0:t.send({t:"import-theme",name:u,source:c}))},{id:"theme-rescan",topic:"theme",label:"rescan editor themes",onClick:()=>t==null?void 0:t.send({t:"rescan-themes"})}],[{id:"theme-dark",topic:"theme",label:"dark slot override…",detail:o(r.dark),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"dark"}})},{id:"theme-light",topic:"theme",label:"light slot override…",detail:o(r.light),sub:!0,onClick:()=>n({a:"open",overlay:{kind:"theme",slot:"light"}})}]])}function z3(e,t,n,r,o){const a=[],l=(h,k,y,v,x)=>a.push({id:h,label:k,hint:v,run:y,sub:x}),u=(h,k)=>{for(const y of h){if(!Ni(y)||y.disabled!==void 0||y.checked)continue;const v=y.key??(typeof y.detail=="string"?y.detail:void 0),x=k?`${k.scope}:${y.id}`:y.id,_=y.topic?`${y.topic}: ${y.label}`:y.label;l(x,k?`${_} · ${k.name}`:_,y.onClick,v,y.sub)}},c={sock:n,dispatch:t},p=r,m=p==null?void 0:p.worktree.id;if(u(vE(e,c).filter(h=>!Ni(h)||h.id!=="commands")),o&&u(rf(o,o.id,c),{scope:"project",name:o.name}),m&&!mo(e)&&(l("pick",e.picking==="chat"?"cancel element picker":"pick an element for the chat",()=>tc(m,e.picking,t,"chat"),Et("pick")),l("inspect",e.picking==="code"?"cancel element picker":"pick an element to open its code",()=>tc(m,e.picking,t,"code"),Et("inspect")),l("reload","reload preview",()=>Yt.post(m,{type:"reload"}))),u(xE(e,c)),p&&m){const h=e.repos.find(k=>k.id===p.worktree.repoId)??null;u(G1(p,h,e,c,{hostname:e.hostname}),{scope:"wt",name:Rh(p,h)});for(const k of p.procs)u($g(k,m,c))}e.visible.forEach((h,k)=>{if(h.worktree.id===m)return;const y=h.worktree.variant;l(`go:${h.worktree.id}`,`switch to ${Rh(h,o)}${y?` (v${y.index}/${y.of})`:""}`,()=>t({a:"activate",id:h.worktree.id}),gT(k,e.visible.length))});for(const h of e.repos)h.id!==(o==null?void 0:o.id)&&l(`repo:${h.id}`,`switch to project ${h.name}`,()=>t({a:"activate-repo",id:h.id}));return a}function _E(){const e=ct(),t=it(),n=L(C=>C.picking),r=L(C=>C.layout),o=L(C=>C.chatSide),a=L(C=>C.keepAwake),l=L(C=>C.railOpen),u=L(C=>C.themePrefs),c=L(C=>C.themes),p=L(C=>C.systemDark),m=L(C=>C.daylight),h=L(C=>C.rows),k=L(C=>C.visible),y=L(C=>C.activeId),v=L(C=>C.activeRepoId),x=L(C=>C.repos),_=L(C=>C.agents),N=L(C=>C.defaultAgent),j=L(C=>C.shipping),E=L(C=>C.remote),M=L(C=>C.managed),K=L(C=>C.frame),U=L(C=>C.self),R=L(C=>C.archivedPage),I=L(C=>C.archived);return S.useMemo(()=>{const C={picking:n,layout:r,chatSide:o,keepAwake:a,railOpen:l,themePrefs:u,themes:c,systemDark:p,daylight:m,rows:h,visible:k,activeId:y,activeRepoId:v,repos:x,agents:_,defaultAgent:N,shipping:j,remote:E,managed:M,frame:K,self:U,archivedPage:R,archived:I,hostname:location.hostname};return z3(C,e,t,fn(C,y),Pa(C,v))},[n,r,o,a,l,u,c,p,m,h,k,y,v,x,_,N,j,E,M,K,U,R,I,e,t])}function EE(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=[];for(const o of e){const a=tm(o.label.toLowerCase(),n);a>0&&r.push({c:o,score:a})}return r.sort((o,a)=>a.score-o.score),r.map(o=>o.c)}function tm(e,t){const n=Mg(e,t);if(!n)return 0;let r=0,o=0,a=-1;for(const l of n)o=l===a+1?o+1:1,r+=o+(SE(e,l)?3:0),a=l;return r+Math.max(0,40-e.length/4)}const SE=(e,t)=>t===0||/[\s:\-–—·/.(]/.test(e[t-1]);function Mg(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const a of t.toLowerCase()){let l=-1;if(n[o]===a)l=o;else if(a===" ")l=n.indexOf(" ",o);else for(let u=n.indexOf(a,o);u!==-1;u=n.indexOf(a,u+1))if(SE(n,u)){l=u;break}if(l===-1)return null;r.push(l),o=l+1}return r}const Oi=(e,...t)=>{const n=e.trim().toLowerCase();return!n||t.some(r=>r==null?void 0:r.toLowerCase().includes(n))},F3=/^[^\s]*$/;function W0(e,t){if(e.startsWith("!"))return null;if(e.startsWith("/")){const a=e.indexOf(" "),l=a===-1?e.length:a;if(!(e.indexOf("/",1)!==-1&&e.indexOf("/",1)<l)&&t<=l)return{kind:"command",query:e.slice(1,t),from:0,to:l}}const n=e.lastIndexOf("@",Math.max(0,t-1));if(n===-1||n>=t||n>0&&!/\s/.test(e[n-1]??""))return null;const r=e.slice(n+1,t);if(!F3.test(r))return null;let o=t;for(;o<e.length&&!/\s/.test(e[o]??"");)o++;return{kind:"file",query:r,from:n,to:o}}const B3={files:new Set,folders:new Set},K0=new WeakMap;function U3(e){if(!e)return B3;let t=K0.get(e);return t||(t={files:new Set(e),folders:new Set(Ux(e))},K0.set(e,t)),t}const H3=/(^|\s)(@\S+)/g,W3=/[.,;:!?)\]}'"]$/;function Z0(e,t){if(e==="changes")return{kind:"changes",text:"@changes"};if(t.files.has(e))return{kind:"file",text:`@${e}`,path:e};const n=e.replace(/\/+$/,"");return n&&t.folders.has(n)?{kind:"folder",text:`@${e}`,path:n}:null}function K3(e,t){const n=[];let r=0;const o=a=>{if(!a)return;const l=n.at(-1);(l==null?void 0:l.kind)==="text"?l.text+=a:n.push({kind:"text",text:a})};for(const a of e.matchAll(H3)){const l=a.index+(a[1]??"").length;let u=(a[2]??"").slice(1),c=Z0(u,t);for(;!c&&W3.test(u);)u=u.slice(0,-1),c=u?Z0(u,t):null;c&&(o(e.slice(r,l)),n.push(c),r=l+c.text.length)}return o(e.slice(r)),n}function Z3(e,t,n){return{text:e.slice(0,t.from)+n+e.slice(t.to),caret:t.from+n.length}}function q3(e,t){const n=t.trim().toLowerCase();if(!n)return e;const r=a=>e.map(l=>({c:l,score:a(l)})).filter(l=>l.score>0).sort((l,u)=>u.score-l.score||l.c.name.localeCompare(u.c.name)).map(l=>l.c),o=r(a=>tm(a.name,n));return o.length>0?o:r(a=>tm(a.description,n))}const G3=/(^|\s)@\S/;function NE({text:e,worktreeId:t,root:n,inField:r}){const o=Bn(),a=it(),l=L(m=>{var h;return t?(h=m.local[t])==null?void 0:h.files:void 0}),u=U3(l),c=S.useMemo(()=>K3(e,u),[e,u]),p=l===void 0&&t&&G3.test(e)?t:null;return S.useEffect(()=>{p&&Gd(p,o.getState(),{sock:a,dispatch:o.dispatch})},[p,o,a]),f.jsx(f.Fragment,{children:c.map((m,h)=>{if(m.kind==="text")return m.text;if(m.kind==="changes"){const x=$t("this worktree's uncommitted files",void 0,{placement:"follow"});return f.jsx("span",{className:"chat-mention","data-changes":"",...x,children:m.text},h)}if(!n||!t)return m.text;const k=m.kind==="folder",y=`${n}/${m.path}${k?"/":""}`,v=$t(k?`${m.path}/`:m.path,void 0,{placement:"follow"});return f.jsx("a",{className:"chat-mention",href:y,tabIndex:r?-1:void 0,...v,children:m.text},h)})})}function TE(e,t,n,r){if(e.target.closest("[data-changes]")){n&&r.dispatch({a:"focus-changes",tab:"changes"});return}jg(e,t,n,r)}function V3(e){return e.length<2||!e.every(t=>{var n;return t.length===1&&((n=t[0])==null?void 0:n.diff)})?null:Q3(e.map(t=>t[0].text))}const Y3=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function Q3(e,t=3){let n=[];for(const r of e){const o=X3(r);if(!o)return null;const a=J3(n,o);if(!a)return null;n=a}return n.some(r=>r.kind!=="same")?e5(n,t):null}function X3(e){const t=[];let n=null;for(const r of e.split(`
216
+ `)){const o=Y3.exec(r);if(o){n={oldStart:Number(o[1]),newStart:Number(o[2]),ops:[]},t.push(n);continue}if(!n)return null;const a=r[0];if(a===" "||a==="-"||a==="+")n.ops.push({mark:a,text:r.slice(1)});else if(r==="")n.ops.push({mark:" ",text:""});else return null}return t.length>0?t:null}function J3(e,t){const n=[];let r=0,o=0,a=0,l=0;const u=m=>{m.kind==="same"?o=m.a-m.c:m.kind==="add"?o-=1:o+=1},c=()=>{for(;r<e.length&&e[r].kind==="del";)n.push(e[r]),u(e[r]),r++},p=m=>{for(let h=m;h<e.length;h++){const k=e[h];if(k.kind!=="del")return k.c}return Number.POSITIVE_INFINITY};for(const m of t){if(m.oldStart<=l)return null;for(;r<e.length;){const y=e[r];if((y.kind==="del"?p(r):y.c)>=m.oldStart)break;n.push(y.kind==="del"?y:{...y,c:y.c+a}),u(y),r++}let h=m.oldStart,k=m.newStart;for(const y of m.ops){if(c(),y.mark==="+"){n.push({kind:"add",c:k,text:y.text}),k++;continue}const v=e[r],x=v&&v.kind!=="del"&&v.c===h?v:void 0;if(x){if(x.text!==y.text)return null;r++,u(x),y.mark===" "?n.push({...x,c:k}):x.kind==="same"&&n.push({kind:"del",a:x.a,text:x.text})}else y.mark===" "?n.push({kind:"same",a:h+o,c:k,text:y.text}):n.push({kind:"del",a:h+o,text:y.text});y.mark===" "&&k++,h++}a=k-h,l=h-1}for(;r<e.length;r++){const m=e[r];n.push(m.kind==="del"?m:{...m,c:m.c+a})}return n}function e5(e,t){const n=[];for(const r of n5(e))for(const[o,a]of r5(r.rows,t)){const l=t5(r.rows.slice(o,a)),u=l.filter(h=>h.kind!=="add").length,c=l.filter(h=>h.kind!=="del").length,p=l.find(h=>h.kind!=="add"),m=l.find(h=>h.kind!=="del");n.push(`@@ -${p?p.a:r.oldAt[o]},${u} +${m?m.c:r.newAt[o]},${c} @@`,...l.map(h=>`${h.kind==="add"?"+":h.kind==="del"?"-":" "}${h.text}`))}return n.join(`
217
+ `)}function t5(e){const t=[];for(let n=0;n<e.length;){if(e[n].kind==="same"){t.push(e[n]),n++;continue}let r=n;for(;r<e.length&&e[r].kind!=="same";)r++;const o=e.slice(n,r);t.push(...o.filter(a=>a.kind==="del"),...o.filter(a=>a.kind==="add")),n=r}return t}function n5(e){const t=[];let n=null,r=1,o=1;for(const a of e){const l=a.kind==="add"?r:a.a,u=a.kind==="del"?o:a.c;(!n||l!==r||u!==o)&&(n={rows:[],oldAt:[],newAt:[]},t.push(n)),n.rows.push(a),n.oldAt.push(l),n.newAt.push(u),r=l+(a.kind==="add"?0:1),o=u+(a.kind==="del"?0:1)}return t}function r5(e,t){const n=[];let r=0;for(;r<e.length;){if(e[r].kind==="same"){r++;continue}let o=r,a=r;for(;a<e.length;){if(e[a].kind!=="same"){o=a,a++;continue}let l=0;for(;a+l<e.length&&e[a+l].kind==="same";)l++;if(l>t*2||a+l>=e.length)break;a+=l}n.push([Math.max(0,r-t),Math.min(e.length,o+t+1)]),r=o+t+1}return n}function nm({pieces:e}){return f.jsx(f.Fragment,{children:e.map((t,n)=>{const r=`${t.changed?"ch ":""}${t.scope?`sy-${t.scope}`:""}`.trim();return r?f.jsx("span",{className:r,children:t.text},n):f.jsx(S.Fragment,{children:t.text},n)})})}function Lg({pick:e,dir:t,worktreeId:n,tipText:r,onHover:o,onOpen:a,onRemove:l,className:u=""}){const c=e.callFile,p=e.file,m=c?{path:c,line:e.callLine}:p?{path:p,line:e.line}:null,h=c&&p?{path:p,line:e.line}:null,k=(N,j)=>`${N}${j?`:${j}`:""}`,y=N=>N.split("/").pop()??N,v=(N,j,E,M)=>a?f.jsx("button",{className:"pick-open","data-tip":M,onClick:()=>a(N,j??1),children:E}):E,x=sn("chat"),_=S.useRef(null);return f.jsxs("div",{ref:_,className:He("pick-chip row row-sm",u),"data-tip":r,onMouseEnter:()=>o==null?void 0:o(!0),onMouseLeave:()=>o==null?void 0:o(!1),...x.contextMenu(()=>UP(e,{dir:t,remove:l})),children:[f.jsxs("span",{className:"pick-target",children:[f.jsx(St,{name:"pick",className:"icon-inline"})," ",Hm(e),m&&f.jsxs("span",{className:"pick-file row-dim",children:[" ","· ",v(m.path,m.line,k(y(m.path),m.line),`Open ${k(m.path,m.line)}`)]}),h&&f.jsxs("span",{className:"pick-file row-dim",children:[" ","·"," ",v(h.path,h.line,k(h.path.split("/").pop()??h.path,h.line),`Open the component: ${k(h.path,h.line)}`)]})]}),l&&f.jsx(At,{icon:"close",label:"Remove attachment",tone:"quiet",onClick:l}),n&&(m==null?void 0:m.line)&&f.jsx(nE,{chip:_,children:f.jsx(i5,{worktreeId:n,path:m.path,line:m.line})})]})}const o5=6,s5=16;function i5({worktreeId:e,path:t,line:n}){const r=s1(),o=it(),a=L(h=>{var k;return((k=ko(h))==null?void 0:k.id)===e}),l=L(h=>{var k;return a?0:(k=go(h,e).changedRanges[t])==null?void 0:k.offset}),[u,c]=S.useState(null);S.useEffect(()=>{let h=!0;return a||o==null||o.send({t:"changed-ranges",worktreeId:e,path:t}),r==null||r.look(e,t).then(k=>{h&&c(k)}),()=>{h=!1}},[r,o,e,t,a]);const p=S.useMemo(()=>{if(u===null||l===void 0)return null;const h=u.split(`
218
+ `),k=n-l,y=Math.max(1,k-o5),v=Math.min(h.length,k+s5);if(y>v)return null;const x=h.slice(y-1,v);return{from:y,at:k,slice:x,painted:Eg(x.join(`
219
+ `),_g("",t))}},[u,l,n,t]);if(!p)return null;const m=String(p.from+p.slice.length-1).length;return f.jsx("pre",{className:"pick-peek",children:p.slice.map((h,k)=>{const y=p.from+k,v=p.painted[k];return f.jsxs("span",{className:"pick-peek-line","data-state":y===p.at?"current":void 0,children:[f.jsx("span",{className:"pick-peek-n",children:String(y).padStart(m)}),v!=null&&v.length?f.jsx(nm,{pieces:v}):h||" "]},y)})})}function a5(e){return e.startsWith("!")?e.slice(1).trim():null}function of(e){if(e.kind!=="tool"||e.name!==Ma&&e.name!==bx)return null;const t=e.input;return typeof(t==null?void 0:t.command)=="string"?t.command:null}function l5(e){return e.length>0&&e.every(t=>of(t)!==null&&t.kind==="tool"&&t.done&&!t.isError)}function c5(e){const t=[],n=new Set(e.flatMap(r=>r.kind==="asked"&&r.toolId?[r.toolId]:[]));for(let r=e.length-1;r>=0;r--){const o=e[r];if(o.kind==="user")break;if(o.kind!=="tool"||!o.done||n.has(o.id))continue;const a=of(o);if(a===null)continue;const l=hE(o.output??"").map(c=>c.text).join(`
220
+ `),u=pO(l);t.unshift(`$ ${a}${u?`
221
+ ${u}`:""}`)}if(t.length!==0)return`Shell commands the user ran since their last message, and what each printed:
222
+ ${t.join(`
223
+ `)}`}function u5(e,t,n,r,o){const{sock:a}=r,l=e[0];if(!l)return[];const u=[],c=Rg(nf(l),t);if(c&&!c.startsWith("/")&&n){const v=l.toolKind==="edit"?"diff":"file";u.push({id:"open-diff",label:`open ${v}`,onClick:()=>nr(r,{worktreeId:n.id,path:c,view:v})}),u.push(...Ii(`${n.dir}/${c}`,()=>a==null?void 0:a.send({t:"reveal",worktreeId:n.id,path:c})))}else c.startsWith("/")&&u.push(...Ii(c),{id:"copy-path",label:"copy path",onClick:()=>Zt(c)});const p=[],m=oc(l,t).command,h=h3(l);h&&h!==m&&p.push({id:"copy-description",label:"copy description",onClick:()=>Zt(h)}),m&&p.push({id:"copy-command",label:"copy command",onClick:()=>Zt(m)});const k=e.map(v=>v.output??"").filter(Boolean).join(`
224
+ `);k&&p.push({id:"copy-output",label:"copy output",onClick:()=>Zt(k)});const y=o.leaf?[]:[{id:"fold",label:o.open?"collapse":"expand",onClick:o.toggle}];return Dn([u,p,y])}function q0({text:e,menu:t,marked:n,worktreeId:r,fileRoot:o,streaming:a}){const l=Sg(e,{fileRoot:o,streaming:a}),u=it(),c=ct(),p=sn("chat"),m=S.useRef(null);l1(m,l);const h=L(v=>{var x;return r?(x=v.local[r])==null?void 0:x.refusedLink:void 0});gt([l,h],()=>{var x;const v=m.current;if(v)for(const _ of v.querySelectorAll("a.file-link")){const N=h!==void 0&&_.getAttribute("href")===h.href;_.classList.toggle("file-link-refused",N),N?((x=_.dataset).tipWas??(x.tipWas=_.dataset.tip??""),_.dataset.tip=h.message,_.dataset.tipPlacement="bottom",_.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0}))):_.dataset.tipWas!==void 0&&(_.dataset.tip=_.dataset.tipWas,_.dataset.tipPlacement="follow",delete _.dataset.tipWas)}});const k=S.useRef(null),y=Ng(k);return f.jsxs("div",{ref:k,className:"msg-assistant md row-edge","data-state":rr({cursor:n}),...p.contextMenu((v,x)=>t(Tg(x,o),Xh(x))),onClick:v=>jg(v,o,r,{sock:u,dispatch:c}),children:[f.jsx("div",{ref:m}),y]})}const lh=40;function jE(e,t){return e.map(n=>{const r=_g(n.lang,t||(n.diff?wz(n.text):""));if(n.diff){const o=w3(n.text);return{...n,lines:o,painted:xz(o,r)}}return{...n,lines:[],painted:n.code?Eg(n.text,r):[]}})}function CE({blocks:e,path:t,worktreeId:n}){it();const r=ct();return f.jsx("div",{className:"tool-out",children:e.map((o,a)=>o.diff?f.jsxs("pre",{className:"tool-block diff",children:[o.lines.slice(0,lh).map((l,u)=>{var c;return l.kind==="hunk"?f.jsx("span",{className:"dl hunk",title:l.text},u):f.jsx("span",{className:`dl ${l.kind}`,children:(c=o.painted[u])!=null&&c.length?f.jsx(nm,{pieces:o.painted[u]}):l.text||" "},u)}),o.lines.length>lh&&f.jsxs("button",{type:"button",className:"dl more",disabled:!t||!n,"data-tip":t&&n?"Open this file's diff":void 0,onClick:()=>n&&nr({dispatch:r},{worktreeId:n,path:t,view:"diff"}),children:[o.lines.length-lh," more lines"]})]},a):o.code?f.jsx("pre",{className:"tool-block",children:o.painted.length?o.painted.map((l,u)=>f.jsxs(S.Fragment,{children:[u>0?`
225
+ `:null,f.jsx(nm,{pieces:l})]},u)):o.text},a):f.jsx("p",{className:"tool-note",children:o.text},a))})}function d5({image:e,worktreeId:t}){const n=Gu(t,e.file),[r,o]=S.useState(!1),a=sn("chat");return f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"tool-image","data-tip":"Open full size","data-tip-placement":"follow",onClick:()=>o(!0),...a.contextMenu(()=>rc(n,{open:()=>o(!0)})),children:f.jsx("img",{src:n,alt:e.file})}),r&&f.jsx(pg,{owner:"chat",onClose:()=>o(!1),menu:()=>rc(n),children:f.jsx("img",{src:n,alt:e.file})})]})}const f5=S.memo(function({item:t,roots:n,worktreeId:r}){const o=S.useMemo(()=>jE(em(t,t.output??""),nf(t)),[t]),a=oc(t,n).command,l=r?t.images??[]:[];return!a&&o.length===0&&l.length===0?null:f.jsxs("div",{className:"tool-part",children:[a&&f.jsx("pre",{className:"tool-block cmd",children:a}),o.length>0&&f.jsx(CE,{blocks:o,path:AE(t,n),worktreeId:r}),l.length>0&&r&&f.jsx("div",{className:"tool-out",children:l.map(u=>f.jsx(d5,{image:u,worktreeId:r},u.file))})]})});function AE(e,t){const n=Rg(nf(e),t??[]);return n.startsWith("/")?"":n}const p5=S.memo(function({text:t,item:n,roots:r,worktreeId:o}){const a=nf(n),l=S.useMemo(()=>jE([{code:!0,diff:!0,lang:"diff",text:t}],a),[t,a]);return f.jsx("div",{className:"tool-part",children:f.jsx(CE,{blocks:l,path:AE(n,r),worktreeId:o})})});function rm({className:e,state:t,auto:n,leaf:r,growing:o,label:a,summary:l,menu:u,children:c}){const[p,m]=S.useState(null),h=S.useRef(null),k=S.useRef(null),y=a1(k),v=U2(".chat-log"),x=!r&&(p??n),_=()=>{r||(x||v(h.current),m(!x))},N=sn("chat");return f.jsxs("details",{ref:h,className:He(e,r&&"leaf"),"data-state":t,open:x,onToggle:j=>{if(!j.currentTarget.open||o)return;const E=k.current;E&&(E.scrollTop=0,y.read())},...N.contextMenu((j,E)=>u({open:x,leaf:!!r,toggle:_},E)),tabIndex:-1,onPointerDown:()=>{var j;return(j=h.current)==null?void 0:j.focus({preventScroll:!0})},onKeyDown:j=>{if((j.key==="ArrowLeft"||j.key==="ArrowRight")&&!r){if(j.shiftKey||j.altKey||j.metaKey||j.ctrlKey)return;Jd([{depth:0,open:x}],0,j.key)&&_();return}j.key!=="Escape"||!x||(j.stopPropagation(),m(!1))},children:[f.jsx("summary",{"aria-label":a,tabIndex:r?-1:void 0,onClick:j=>{j.preventDefault(),_()},children:l}),f.jsx("div",{className:"tool-body",ref:k,children:c})]})}const h5=S.memo(function({item:t,open:n,streaming:r,worktreeId:o,fileRoot:a}){const l=lE(t.text),u=l.slice(0,-1),c=Sg(l.length?u.join(`
226
+
227
+ `):iE(t.text),a?{fileRoot:a}:void 0),p=it(),m=ct(),h=r?"Thinking":"Thought",k=S.useRef(null);l1(k,c);const y=S.useRef(null),v=Ng(y),x=f.jsx("div",{className:"tool-part",children:f.jsxs("div",{ref:y,className:"tool-out thought-out md",onClick:N=>jg(N,a,o,{sock:p,dispatch:m}),children:[f.jsx("div",{ref:k}),v]})}),_=l.at(-1)??(r?"":cE(t.text));if(_){const N=u.length===0;return f.jsx(rm,{className:"tool-row",auto:!1,leaf:N,growing:r,label:_,menu:(j,E)=>Dn([Zh(Xh(E)),[{id:"copy",label:"copy thought",onClick:()=>Zt(t.text)}],...N?[]:[[{id:"fold",label:j.open?"collapse":"expand",onClick:j.toggle}]]]),summary:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"bulb",className:"tool-icon"}),f.jsx("span",{className:He("tool-hint thought-line",r&&"live-text"),children:_})]}),children:N?null:x})}return f.jsx(rm,{className:"tool-row",auto:!!n,growing:r,label:h,menu:(N,j)=>Dn([Zh(Xh(j)),[{id:"copy",label:"copy thought",onClick:()=>Zt(t.text)}],[{id:"fold",label:N.open?"collapse":"expand",onClick:N.toggle}]]),summary:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"bulb",className:"tool-icon"}),f.jsx("span",{className:He("tool-name",r&&"live-text"),children:h})]}),children:x})}),$l=6,m5={land:"the land",commit:"the commit","sync-main":"the sync","pull-main":"the pull"},zu=S.memo(function e({tools:t,run:n,next:r,live:o,working:a,since:l,queued:u,roots:c,worktreeId:p,marked:m}){const h=t[0],k=S.useMemo(()=>V3(t.map(de=>em(de,de.output??""))),[t]),y=t.at(-1)??h,v=!y.done,x=v&&!!y.background,_=v||!!r,N=_&&!u||!!a,j=v&&!!u,E=Aa(v||a?l:void 0),M=n?A3(n):-1,K=S.useMemo(()=>n?yE(n,!0):void 0,[n]),U=!!o||!!n&&_,R=oc(h,c),I=v?p3(h):"",{label:C,icon:P}=R,z=fE(h),q=I?"":z?"Guardian":R.name,se=I||(z?c3(h.output??""):R.hint),pe=!(n&&n.length>0)&&!k&&t.every(de=>{var me;return!oc(de,c).command&&em(de,de.output??"").length===0&&!((me=de.images)!=null&&me.length)}),ue=n?S3(n):0,xe=l5(t),oe=[C,se].filter(Boolean).join(" ")+(x?", in the background":"")+(j?", queued":"")+(xe?", done":""),A=I?"":n?`${ue} ${ue===1?"call":"calls"}`:t.length>1?`×${t.length}`:"",X=Bn(),Z=it(),$=L(de=>{var me;return p?(me=de.shipping[p])==null?void 0:me.op:void 0}),V=v&&h.name===Ma&&p?{worktreeId:p,toolId:y.id}:null;return f.jsxs(rm,{className:He("tool-row",t.some(de=>de.isError)&&"error",h.parentToolId&&"nested",n&&"spawn",j&&"queued"),state:rr({cursor:m}),auto:U,leaf:pe,growing:N,label:n&&A?`${oe}, ${A}`:t.length>1?`${oe}, ${t.length} calls`:oe,menu:de=>{const me=fn(X.getState(),p),he=me?{id:me.worktree.id,dir:me.worktree.path}:null;return u5(t,c??[],he,{sock:Z,dispatch:X.dispatch},de)},summary:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:n?"spawn":P,className:"tool-icon"}),q&&f.jsx("span",{className:He("tool-name",N&&!se&&"live-text"),children:q}),I?f.jsx("span",{className:"tool-writing","data-tip":se,children:f.jsx(kc,{variant:"squares"})}):se&&f.jsx("span",{className:He("tool-hint",N&&"live-text"),children:se}),x&&f.jsx("span",{className:"tool-status",children:"in the background"}),j&&f.jsx("span",{className:"tool-status",children:"queued"}),xe&&f.jsx(St,{name:"check",className:"tool-done"}),E>=$l&&f.jsx("span",{className:He("tool-age",M>=0&&"tool-age-folded"),children:ba(E)}),A&&f.jsx("span",{className:"tool-count",children:A}),V&&f.jsx(At,{icon:"stop",tone:"danger",className:"tool-stop",label:$?`Stop ${m5[$]}: this step is killed, and what it printed so far stays`:x?"Kill what the command left running; what it printed so far stays":"Kill the command and everything it started; what it printed so far stays",onClick:de=>{de.preventDefault(),de.stopPropagation(),Z==null||Z.send({t:"exec-stop",...V})}})]}),children:[n&&n.length>0&&f.jsx("div",{className:"spawn-run",children:n.map((de,me)=>f.jsx(e,{tools:de.tools,next:de.next,since:me===M?l:void 0,queued:K==null?void 0:K.has(me),roots:c,worktreeId:p},de.at))}),k?f.jsx(p5,{text:k,item:h,roots:c,worktreeId:p}):t.map(de=>f.jsx(f5,{item:de,roots:c,worktreeId:p},de.id))]})},(e,t)=>e.live===t.live&&e.working===t.working&&e.since===t.since&&e.queued===t.queued&&e.next===t.next&&e.roots===t.roots&&e.worktreeId===t.worktreeId&&e.marked===t.marked&&wE(e.tools,t.tools)&&I3(e.run,t.run));function g5({item:e}){const t=it(),n=ct(),r=L(v=>v.activeId),o=L(v=>v.layout.term),a=L(v=>{var x;return((x=v.rows.find(_=>_.id===v.activeId))==null?void 0:x.login)??!1}),l=L(v=>v.managed.problem),[u,c]=S.useState(""),[p,m]=S.useState(null),h=S.useRef(!1);if(gt([a],()=>{a&&h.current&&r&&n({a:"term-stream",id:r,stream:ps,tall:!0})}),gt([e.done],()=>{e.done&&h.current&&o&&n({a:"toggle-terminal"}),h.current=!1}),!r)return null;const k=(v,x)=>{t==null||t.send({t:"agent-auth",worktreeId:r,methodId:v,...x?{apiKey:x}:{}})},y=e.methods.find(v=>v.id===p);return f.jsxs("div",{className:`auth-card ${e.done?"done":""}`,children:[f.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&&f.jsxs("div",{className:"auth-methods",children:[e.methods.map(v=>v.needsKey?f.jsx(ze,{variant:"outline",on:p===v.id,"data-tip":v.description,onClick:()=>m(p===v.id?null:v.id),children:v.name},v.id):f.jsx(ze,{variant:"outline","data-tip":v.kind==="terminal"?"opens in the terminal pane":v.description,onClick:()=>{k(v.id),v.kind==="terminal"&&(h.current=!0)},children:v.name},v.id)),f.jsx(ze,{variant:"outline","data-tip":"after logging in elsewhere (the terminal, another window)",onClick:()=>t==null?void 0:t.send({t:"agent-retry",worktreeId:r}),children:"send again"})]}),!e.done&&a&&f.jsx("div",{className:"hint auth-hint",children:"paste the code into the login tab below and press Enter; it stays hidden as you paste. Your message sends once you are in."}),!e.done&&e.withheld&&f.jsx("div",{className:"hint auth-hint",children:l?"the policy file on this machine is invalid, so signing in with a Claude plan is off until it is fixed; toyon doctor says why":"signing in with a Claude plan is managed by your organization"}),!e.done&&y&&f.jsxs("form",{className:"auth-key",onSubmit:v=>{v.preventDefault(),u.trim()&&(k(y.id,u.trim()),c(""),m(null))},children:[f.jsx(Mo,{type:"password",autoFocus:!0,placeholder:`${y.name} for ${e.agentName}`,value:u,onChange:v=>c(v.target.value)}),f.jsx(ze,{type:"submit",children:"use key"})]})]})}const k5=S.memo(function({item:t,worktreeId:n,onPickHover:r,marked:o,streaming:a}){const l=Bn(),u=it(),c=sn("chat"),p={sock:u,dispatch:l.dispatch},m=()=>{const k=fn(l.getState(),n);return k?k.worktree.path:null},h=()=>{var k;return(k=fn(l.getState(),n))==null?void 0:k.worktree.path};switch(t.kind){case"user":{const k=h();return f.jsxs("div",{className:"msg-user row-edge","data-state":rr({cursor:o}),...c.contextMenu((y,v)=>xl(t,n??null,p,{link:Tg(v,k),dir:m()})),onClick:y=>TE(y,k,n,p),children:[t.attachments&&n&&f.jsx("div",{className:"msg-attachments",children:t.attachments.map(y=>y.kind==="image"?f.jsx(M3,{img:y,src:Gu(n,y.file)},`${y.kind}-${y.n}`):y.kind==="file"?f.jsx(Ig,{className:"in-chat",name:y.name,bytes:y.bytes,href:y.text?Gu(n,y.file):void 0},`${y.kind}-${y.n}`):y.kind==="paste"?f.jsx(Ag,{className:"in-chat",n:y.n,name:y.name,source:y.source,lines:y.lines,chars:y.chars,preview:y.preview,href:Gu(n,y.file)},`${y.kind}-${y.n}`):f.jsx(Lg,{pick:y,dir:m(),className:"in-chat",tipText:"Hover to highlight on the page",onHover:v=>r==null?void 0:r(y,v),worktreeId:n,onOpen:(v,x)=>Ra(l,u,n,v,x)},`${y.kind}-${y.n}`))}),f.jsx(NE,{text:t.text,worktreeId:n,root:k})]})}case"assistant":return f.jsx(q0,{text:t.text,menu:(k,y)=>xl(t,n??null,p,{link:k,code:y,dir:m()}),marked:o,worktreeId:n,fileRoot:h(),streaming:a});case"error":return f.jsx("div",{className:"msg-assistant msg-error",...c.contextMenu(()=>xl(t,n??null,p)),children:t.text});case"auth":return f.jsx(g5,{item:t});case"ask":{const k=B$(t);if(!k)return f.jsx(Rz,{item:t});const y=Lx(k.questions,k.answers).join(`
228
+ `),v={kind:"assistant",text:y};return f.jsxs(f.Fragment,{children:[f.jsx(q0,{text:k.message,menu:(x,_)=>xl({kind:"assistant",text:k.message},n??null,p,{link:x,code:_,dir:m()}),worktreeId:n,fileRoot:h()}),f.jsx("div",{className:"msg-user",...c.contextMenu(()=>xl(v,n??null,p)),children:y})]})}case"blocked":return f.jsxs(Fs,{icon:"lock",word:"blocked",tone:"red",below:f.jsx("div",{className:"daemon-below row-dim",children:t.reason}),...c.contextMenu(()=>BP(t.path,m())),children:[f.jsx("span",{className:"tool-name",children:t.tool}),t.path&&f.jsx("span",{className:"tool-hint",children:t.path})]});case"grafted":return f.jsxs(Fs,{icon:"layers",word:"grafted",tone:"accent","data-tip":`what follows was said in ${t.title} before it was merged in here`,"data-tip-placement":"follow",children:[f.jsx("span",{className:"tool-name",children:t.title}),f.jsx("span",{className:"tool-hint",children:t.branch})]});case"asked":return f.jsx(Fs,{icon:"chat",word:"agent asked",tone:"quiet",children:f.jsx("span",{className:"daemon-text",children:t.why})});case"landed":return f.jsx(w5,{item:t});case"restored":return f.jsx(y5,{item:t});case"adopted":return f.jsx(Fs,{icon:"branch",word:"taken over",tone:"quiet",at:t.ts,children:f.jsxs("span",{className:"daemon-text",children:["on ",t.branch,", its own branch"]})})}});function y5({item:e}){return f.jsx(Fs,{icon:"reload",word:"restored",tone:"quiet",at:e.ts,children:f.jsxs("span",{className:"daemon-text",children:["after ",Hx(e.ts-e.archivedAt)," in the archive, back on ",e.branch,e.uncommitted?" with its uncommitted changes":""]})})}function w5({item:e}){const t=it(),n=ct(),r=L(a=>e.archiveIds.filter(l=>fn(a,l)!==null).length),o=d_(e.ts);return f.jsxs(Fs,{icon:"check",word:"landed",tone:"aqua",at:e.ts,children:[f.jsxs("span",{className:"daemon-text",children:[e.text,", ",o]}),r>0&&f.jsx(ze,{variant:"inline",tone:"strong",onClick:()=>Ti(t,n,e.archiveIds),children:r>1?`archive ${r} worktrees`:"archive the other worktree"})]})}const IE=e=>e===""||e==="!";function G0(e,t){const n=new Set,r=[];for(let o=e.length-1;o>=0;o--){const a=e[o],l=of(a),u=l!==null?`!${l}`:a.kind==="user"&&!t?a.text:null;u===null||!u.trim()||n.has(u)||(n.add(u),r.push({text:u,at:o}))}return r}function v5(e,t,n,r){if(!t){if(r!=="up"&&r!=="first"||!IE(n))return null;const u=G0(e,n==="!"),c=r==="up"?u[0]:u.at(-1);return c?{walk:{at:c.at,from:n},text:c.text}:null}if(r==="box")return{walk:null,text:t.from};const o=G0(e,t.from==="!"),a=r==="first"?o.length-1:o.findIndex(u=>u.at===t.at)+(r==="up"?1:-1);if(a<0)return{walk:null,text:t.from};const l=o[a];return l?{walk:{at:l.at,from:t.from},text:l.text}:{walk:t,text:n}}const b5={get current(){return Hl.el}};function V0({items:e,next:t,worktreeId:n,dir:r,onOpen:o}){return f.jsx("div",{className:"msg-attachments",children:Nb(e,t).map(([a,l])=>a.kind==="image"?f.jsx(Og,{className:"in-chat",src:fd(a.upload),n:l,name:a.name,width:a.width,height:a.height,bytes:a.bytes},`image-${l}`):a.kind==="file"?f.jsx(Ig,{className:"in-chat",name:a.name,bytes:a.bytes,href:a.text?fd(a.upload):void 0},`file-${l}`):a.kind==="paste"?f.jsx(Ag,{className:"in-chat",n:l,name:a.name,source:a.source,...$m(a.text),text:a.text},`paste-${l}`):f.jsx(Lg,{className:"in-chat",pick:a,dir:r,worktreeId:n,onOpen:o},`pick-${l}`))})}const x5=new Set,_5=240;function ch({active:e,archived:t,found:n,lead:r,tail:o}){const a=it(),l=Bn(),u=ct(),c=L(ge=>ge.frame==="phone"),p=(e==null?void 0:e.worktree.id)??(t==null?void 0:t.id)??(n==null?void 0:n.id)??null,m=Ot(p,"chat"),h=Ot(p,"queue"),k=Ot(p,"restoring"),y=Ot(p,"sending"),v=S.useMemo(()=>Sb(m.map(ge=>ge.kind==="user"?ge.attachments:void 0)),[m]),x=S.useMemo(()=>{let ge=v;return h.map(Me=>{const hn=ge;return ge=Tb(ge,Me.attachments??[]),hn})},[h,v]),_=y!=null&&y.message?h.findIndex(ge=>{var Me;return ge.text===((Me=y.message)==null?void 0:Me.text)}):-1,N=S.useRef(null);zP(N);const[j,E]=S.useState(null),M=S.useCallback(()=>{const ge=(N.current&&Kh(N.current))??"";E(Me=>({seed:ge||(Me==null?void 0:Me.seed)||"",seq:((Me==null?void 0:Me.seq)??0)+1}))},[]),K=S.useCallback(ge=>!(ge!=null&&ge.closest("[data-pane]"))&&!l.getState().overlay,[l]);k_(b5,fg,M,K);const U=ge=>{if(E(null),ge){const Me=window.getSelection();Me==null||Me.removeAllRanges(),Me==null||Me.addRange(ge)}},R=a1(N,m);gt([p],()=>R.jump());const I=R.offStart&&R.moving==="up",C=R.offEnd&&(R.moving==="down"||R.away),P=ge=>ge.preventDefault(),z=(I||C)&&f.jsxs("div",{className:He("jump",R.away&&"jump-news"),children:[I&&f.jsx("button",{className:"jump-up",onMouseDown:P,onClick:R.start,"data-tip":"Jump to start",children:f.jsx(St,{name:"caret-up",className:"icon-inline"})}),C&&f.jsxs("button",{className:"jump-down",onMouseDown:P,onClick:R.jump,"data-tip":"Jump to latest",children:[f.jsx(St,{name:"caret",className:"icon-inline"}),R.away&&" new messages"]})]});S.useEffect(()=>{const ge=N.current;if(!c||!R.offEnd||!ge){u({a:"reading",on:!1});return}const Me=()=>{ge.scrollHeight-ge.scrollTop-ge.clientHeight<=_5||(u({a:"reading",on:!0}),ge.removeEventListener("scroll",Me))};return Me(),ge.addEventListener("scroll",Me,{passive:!0}),()=>ge.removeEventListener("scroll",Me)},[c,R.offEnd,u]),S.useEffect(()=>()=>u({a:"reading",on:!1}),[u]);const q=Ot(p,"mark"),se=(q==null?void 0:q.by)==="walk"?q.at:void 0,pe=S.useRef(null),ue=()=>{const ge=N.current,Me=ge==null?void 0:ge.querySelector(':scope > [data-state~="cursor"]');if(!ge||!Me)return;const hn=parseFloat(getComputedStyle(ge).paddingTop)||0;ge.scrollTop+=Me.getBoundingClientRect().top-ge.getBoundingClientRect().top-hn,R.read()};gt([se],()=>{const ge=N.current;if(ge){if(se===void 0){const Me=pe.current;if(pe.current=null,!Me||!IE(go(l.getState(),p).draft))return;Me.bottom?R.jump():(ge.scrollTop=Me.top,R.read());return}pe.current??(pe.current={bottom:R.pinned(),top:ge.scrollTop}),ue()}});const xe=Ot(p,"sent");gt([xe],()=>{xe&&R.jump()});const oe=(q==null?void 0:q.by)==="reveal"?q:void 0,A=S.useMemo(()=>oe?$3(m,oe.seq):-1,[m,oe]),X=se??(A>=0?A:void 0);gt([oe==null?void 0:oe.n,A],()=>{A>=0&&ue()});const Z=S.useCallback((ge,Me)=>{p&&(Me?Yt.post(p,{type:"highlight-selector",selector:ge.selector,label:Hm(ge)}):Yt.post(p,{type:"highlight-clear"}))},[p]),$=!!e&&fc(e),V=Ot(p,"askParked"),de=S.useMemo(()=>{const ge=Ax(m);return!!ge&&V!==ge.id},[m,V]),me=e==null?void 0:e.worktree,he=(me==null?void 0:me.path)??(t==null?void 0:t.path)??(n==null?void 0:n.path),$e=S.useMemo(()=>he?[he]:[],[he]),ae=S.useMemo(()=>E3(m,$e),[m,$e]),ve=S.useMemo(()=>$?N3(m):x5,[$,m]),{flow:Re,floating:ee}=S.useMemo(()=>T3(ae,ve),[ae,ve]),Y=(e==null?void 0:e.agent)==="working",Pe=Y||(e==null?void 0:e.agent)==="waiting",We=S.useMemo(()=>Pe?R3(Re):-1,[Pe,Re]),Fe=Re.at(-1),pt=Y&&Fe&&"item"in Fe&&(Fe.item.kind==="thinking"||Fe.item.kind==="assistant")?Re.length-1:-1,Ge=Re.findLastIndex(ge=>{var Me;return"tools"in ge&&((Me=ge.tools[0])==null?void 0:Me.name)===Ma}),vt=Ot(p,"chatAt"),at=Aa($?vt:void 0),qt=Ot(p,"usage"),an=(qt==null?void 0:qt.heard)!==void 0&&vt!==void 0&&qt.heard>vt?qt.heard:void 0,qe=Aa($?an:void 0),J=j3(m),we=ee.length>0,Xe=pt>=0||J||we,et=S.useMemo(()=>C3(Re),[Re]),Wt=S.useMemo(()=>yE(Re),[Re]),Qt=Ot(p,"running");return f.jsxs("div",{className:"chat-wrap",children:[f.jsxs("div",{className:"chat-log",ref:N,children:[r,Re.map((ge,Me)=>"spawn"in ge?f.jsx(zu,{tools:[ge.spawn],run:ge.run,roots:$e,worktreeId:p},ge.at):"tools"in ge?f.jsx(zu,{tools:ge.tools,next:ge.next,live:Me===We||Me===Ge,since:Me===et?Qt==null?void 0:Qt.at:void 0,queued:Wt.has(Me),roots:$e,worktreeId:p,marked:ge.at===X},ge.at):ge.item.kind==="thinking"?f.jsx(h5,{item:ge.item,open:Me===We,streaming:Me===pt,worktreeId:p,fileRoot:e==null?void 0:e.worktree.path},ge.at):f.jsx(k5,{item:ge.item,worktreeId:p,onPickHover:Z,marked:ge.at===X,streaming:Y&&Me===Re.length-1},ge.at)),ee.map(ge=>"spawn"in ge?f.jsx(zu,{tools:[ge.spawn],run:ge.run,working:!0,since:vt,roots:$e,worktreeId:p},ge.at):f.jsx(zu,{tools:ge.tools,since:vt,roots:$e,worktreeId:p},ge.at)),p&&(y==null?void 0:y.message)&&f.jsxs("div",{className:"msg-user",children:[y.message.attachments&&f.jsx(V0,{items:y.message.attachments,next:v,worktreeId:p,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(ge,Me)=>Ra(l,a,p,ge,Me)}),y.message.text]}),e&&(y||$&&!(e.agent==="waiting"&&de)&&!J&&!we&&!(Xe&&at<$l))&&f.jsx("div",{className:"working-row",children:e.agent==="waiting"?"waiting for your answer…":Xe?at>=$l&&f.jsxs("span",{children:["quiet for",f.jsx("span",{className:"working-num",children:ba(at)})]}):f.jsxs("span",{className:"working-mark",children:[f.jsx(kc,{variant:"squares"}),an!==void 0?qe>=$l&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"working-word",children:"thinking"}),f.jsx("span",{className:"working-num",children:ba(qe)})]}):at>=$l&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"working-word",children:"waiting for the model"}),f.jsx("span",{className:"working-num",children:ba(at)})]})]})}),p&&h.map((ge,Me)=>Me===_?null:f.jsxs("div",{className:"msg-user queued-msg",children:[f.jsxs("span",{className:"queued-tag",children:[f.jsx(St,{name:"clock",className:"icon-inline"}),f.jsx("span",{className:"queued-word",children:"queued"})]}),f.jsxs("div",{className:"queued-text",children:[ge.attachments&&f.jsx(V0,{items:ge.attachments,next:x[Me]??v,worktreeId:p,dir:(e==null?void 0:e.worktree.path)??null,onOpen:(hn,It)=>Ra(l,a,p,hn,It)}),ge.text]}),f.jsxs("span",{className:"queued-actions",children:[f.jsx(At,{icon:"edit",label:"Edit: removes from queue, puts it back in the input",onClick:()=>j1(l,a,p,Me)}),f.jsx(At,{icon:"close",label:"Remove from queue",onClick:()=>a==null?void 0:a.send({t:"unqueue",worktreeId:p,index:Me})})]})]},`q-${Me}`)),o,k!==void 0&&f.jsxs("div",{className:"msg-user queued-msg",children:[f.jsxs("span",{className:"queued-tag",children:[f.jsx(St,{name:"clock",className:"icon-inline"}),f.jsx("span",{className:"queued-word",children:n?"taking over":"restoring"})]}),f.jsx("span",{className:"queued-text",children:k})]})]}),j&&f.jsx(m_,{root:N,body:N,seed:j.seed,seq:j.seq,onClose:U}),z]})}function RE({hints:e,className:t=""}){return f.jsx("div",{className:`key-hints ${t}`.trim(),children:e.map(([n,r])=>f.jsxs("span",{className:"key-hint",children:[f.jsx(Or,{k:n}),r]},n))})}const E5={side:"top",align:"start",offset:4,alignOffset:-10,matchWidth:-20,flip:"side",margin:8};function S5({results:e,keyOf:t,row:n,rowClass:r,nav:o,listRef:a,empty:l}){return f.jsxs(Ys,{className:"inline-picker",anchor:"parent",placement:E5,children:[f.jsxs("div",{className:"picker-list",ref:a,children:[e.map((u,c)=>f.jsx("button",{className:He("picker-item",r==null?void 0:r(u)),"data-state":rr({cursor:c===o.index}),onMouseMove:()=>c!==o.index&&o.setIndex(c),onMouseDown:p=>p.preventDefault(),onClick:()=>o.pick(u),children:n(u,c===o.index)},t(u))),e.length===0&&f.jsx("div",{className:"empty",children:l})]}),f.jsx(RE,{hints:[["↑↓","moves"],["tab","inserts"],["esc","dismisses"]]})]})}function N5({fraction:e,className:t}){const r=2*Math.PI*5.5,o=Math.max(0,Math.min(1,Number.isFinite(e)?e:0));return f.jsxs("svg",{className:He("ring",t),viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[f.jsx("circle",{className:"ring-track",cx:"7",cy:"7",r:5.5}),f.jsx("circle",{className:"ring-fill",cx:"7",cy:"7",r:5.5,strokeDasharray:`${r*o} ${r}`})]})}function T5(e,t=Vl.folder.shared){return`New project: ${e}. The repository is empty apart from a root commit. Pick the mainstream stack for what the message describes, and say which in your first sentence; if the message names a stack, that wins. Scaffold it in this directory, write its .gitignore before installing anything, make it start on $PORT, and write ${t}.`}const Qo="";function j5(e){var p;const t=A5(e.name);if(t){const m=[t.qualifier,e.description||e.name].filter(Boolean).join(" · ");return{label:t.label,version:t.version,description:m}}const n=e.name.match(/^([A-Za-z]+)-(\d+(?:\.\d+)*)(?:-([A-Z][a-z]+))?$/);if(n!=null&&n[1]&&n[2])return{label:n[3]??n[1],version:n[2],...e.description?{description:e.description}:{}};const[r="",...o]=(e.description??"").split(" · "),a=e.name.replace(/\s*\([^)]*\)$/,""),l=r.match(/^(.+?) (\d+(?:\.\d+)*)(?: with (.+))?$/);if(!(l!=null&&l[2])||l[1]!==a)return{label:e.name,...e.description?{description:e.description}:{}};const c=[l[3]??((p=e.name.match(/\(([^)]*)\)$/))==null?void 0:p[1]),...o].filter(Boolean).join(" · ");return{label:a,version:l[2],...c?{description:c}:{}}}const C5=/(?:^|[./])claude-(?:(\d{1,2}(?:-\d{1,2}(?!\d))?)-)?([a-z]+)(?:-(\d{1,2}(?:-\d{1,2}(?!\d))?))?(?:-\d{8})?(?:-v\d+(?::\d+)?)?(?:@\d{8})?(?:\[(\d+m)\])?$/;function A5(e){const t=e.match(C5),n=t==null?void 0:t[2],r=(t==null?void 0:t[3])??(t==null?void 0:t[1]);if(!(!n||!r))return{label:n.charAt(0).toUpperCase()+n.slice(1),version:r.replace("-","."),...t[4]?{qualifier:`${t[4].toUpperCase()} context`}:{}}}function OE(e,t,n,r){const o=bb(e),a=sT(e),l=v=>a&&v===(o==null?void 0:o.id)?a.id:v,u=l(t||n||(o==null?void 0:o.id)||Qo),c=l(t||(o==null?void 0:o.id)||Qo),p=a?e.filter(v=>v!==o):e,m=p.some(v=>v.id===u),h=p.map(v=>({c:v,words:j5(v)})),k=v=>[v.label,v.version].filter(Boolean).join(" "),y=[...o?[]:[{id:Qo,label:r.label,description:r.description}],...h.map(({c:v,words:x})=>{const _=h.filter(j=>k(j.words)===k(x)).length===1?x:void 0,N=_?_.description:v.description;return{id:v.id,label:_?_.label:v.name,..._!=null&&_.version?{suffix:_.version}:{},..._!=null&&_.version&&h.some(j=>j.c!==v&&j.words.label===_.label)?{chip:k(_)}:{},description:v===a?["recommended",N].filter(Boolean).join(" · "):N}}),...u&&!m?[{id:u,label:u}]:[]];if(u!==c){const v=y.find(N=>N.id===u),x=y.findIndex(N=>N.id===c),_=y[x];if(_){const N=(v==null?void 0:v.chip)??(v==null?void 0:v.label)??u;y[x]={..._,description:[`${N} now`,_.description].filter(Boolean).join(" · ")}}}return{rows:y,shown:u,picked:c}}const Tl=(e,t)=>`${e} ${t}`;function I5(e){const t=e.indexOf(" ");return t<0?{agent:e,model:Qo}:{agent:e.slice(0,t),model:e.slice(t+1)}}function R5(e,t,n){const r=e.length>1;let o=Tl(t,n);return{rows:e.flatMap(l=>{var m;const u=l.short??l.name,c=l.id===t;if(!l.available||!((m=l.models)!=null&&m.length))return c&&(o=Tl(l.id,Qo)),[{id:Tl(l.id,Qo),label:u,description:l.available?"its own default model; the rest are listed once it has run":l.reason??"not installed",disabled:!l.available}];const p=OE(l.models,c?n:Qo,void 0,{label:`${u} default`,description:`whatever ${l.name} runs when nothing is asked for`});return c&&(o=Tl(l.id,p.shown)),p.rows.map(h=>({...h,id:Tl(l.id,h.id),...r&&h.id!==Qo?{prefix:u}:{}}))}),shown:o}}function sf({anchored:e=!1,...t}){return e?f.jsx(O5,{...t,anchored:e===!0?{}:e}):f.jsx($5,{...t})}function O5({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,anchored:o,coverBy:a,id:l,children:u}){const{onKey:c,back:p}=$E(t);return f.jsx(Ys,{className:He(r?"":"overlay-box","anchored",n),id:l,anchor:"parent",placement:{side:"bottom",align:"start",cover:!0,margin:0,...o},coverBy:a,onDismiss:e?()=>e():void 0,onKey:c,onBack:()=>p()||(e==null?void 0:e()),children:u})}function $5({onClose:e,onEscape:t,boxClass:n="",bare:r=!1,id:o,children:a}){const{onKey:l,back:u}=$E(t);return f.jsx(Ys,{className:"overlay scrim",id:o,onDismiss:e?()=>e():void 0,onKey:l,onBack:()=>u()||(e==null?void 0:e()),onClick:c=>{e&&c.target===c.currentTarget&&e()},children:f.jsx("div",{className:He(r?"":"overlay-box",n),children:a})})}function $E(e){const t=Bn(),n=()=>{if(e)return e(),!0;const o=t.getState();return!o.overlay||o.choosingFolder?!1:(t.dispatch({a:"close",back:Xx(o.overlay)}),!0)};return{onKey:o=>{o.key==="Escape"&&n()&&o.stopPropagation()},back:n}}function M5({text:e,params:t}){if(t.length===0)return e;const n=[];let r=0;for(const[o,a]of t)o>r&&n.push(e.slice(r,o)),n.push(f.jsx("span",{className:"picker-ghost-param",children:e.slice(o,a)},o)),r=a;return r<e.length&&n.push(e.slice(r)),n}function $r({items:e,filter:t,keyOf:n,row:r,rowClass:o,rowTitle:a,onPick:l,onBack:u,onActive:c,onSide:p,onTab:m,onQuery:h,completionOf:k,narrowTo:y,placeholder:v,initialQuery:x="",initialIndex:_,selectOnMount:N=!1,idleWhen:j,onIdlePick:E,anchored:M=!1,onEscape:K,lead:U,trailing:R,empty:I="no matches",footer:C,keys:P,rowMenu:z,groupOf:q,groupHead:se,headAlone:pe=!1}){const ue=sn("picker"),[xe,oe]=S.useState(x),A=S.useMemo(()=>t(e,xe),[e,xe,t]),X=S.useRef(null),Z=Vs(),$=F2(N,!Z);S.useEffect(()=>{if(!h)return;const Y=setTimeout(()=>h(xe),150);return()=>clearTimeout(Y)},[xe,h]);const V=B1({results:A,keyOf:n,q:xe,onPick:l,listRef:X,onActive:c,onSide:p,completionOf:k,narrowTo:y,setQ:oe,initialIndex:_,idle:(j==null?void 0:j(x))??!1,onIdlePick:E}),{index:de,ghost:me}=V,he=typeof P=="function"?P(V.active,xe):P,$e=[];he!=null&&he.nav&&$e.push(["↑↓",he.nav]),he!=null&&he.side&&p&&$e.push(["←→",he.side]),he!=null&&he.complete&&(me!=null&&me.accept)&&$e.push(["tab",he.complete]),he!=null&&he.tab&&m&&$e.push(["tab",he.tab]),he!=null&&he.pick&&$e.push(["enter",he.pick]),he!=null&&he.back&&$e.push(["esc",he.back]);const ae=f.jsxs("div",{className:"picker-input",onMouseDown:Y=>{var Pe;Y.target.closest("input")||(Y.preventDefault(),(Pe=$.current)==null||Pe.focus())},children:[U,f.jsxs("div",{className:"picker-caret",children:[f.jsx(Mo,{font:"mono",bare:!0,ref:$,value:xe,onChange:Y=>{oe(Y.target.value),V.setIndex(j!=null&&j(Y.target.value)?-1:0)},onKeyDown:Y=>{var Pe;if(z&&V.active&&(Y.key==="ContextMenu"||Y.key==="F10"&&Y.shiftKey)){const We=(Pe=X.current)==null?void 0:Pe.querySelector('[data-state~="cursor"]');if(We){Y.preventDefault(),Y.stopPropagation(),Zr.open({items:z(V.active),owner:"picker",target:We,anchor:We.getBoundingClientRect()});return}}V.onKeyDown(Y)||!m||Y.key!=="Tab"||Y.shiftKey||(Y.preventDefault(),m())},placeholder:v}),me&&f.jsxs("div",{className:"picker-ghost","aria-hidden":"true",children:[f.jsx("span",{className:"picker-typed",children:xe}),M5(me)]})]}),R]}),ve=new Map;if(q)for(const Y of A)ve.set(q(Y),(ve.get(q(Y))??0)+1);const Re=f.jsxs("div",{className:"picker-list",ref:X,children:[A.map((Y,Pe)=>{const We=q==null?void 0:q(Y),Fe=We!==void 0&&(pe||ve.size>1)&&(Pe===0||(q==null?void 0:q(A[Pe-1]))!==We)?f.jsx("div",{className:"picker-group",children:(se==null?void 0:se(We,ve.get(We)??0))??We}):null;return f.jsxs(S.Fragment,{children:[Fe,f.jsx("button",{className:He("picker-item",o==null?void 0:o(Y)),"data-state":rr({cursor:Pe===de}),title:a==null?void 0:a(Y),onMouseMove:()=>Pe!==de&&V.setIndex(Pe),onClick:()=>{var pt;V.pick(Y),(pt=$.current)==null||pt.focus()},...ue.contextMenu(()=>(z==null?void 0:z(Y))??[]),children:r(Y,Pe===de,xe)})]},n(Y))}),A.length===0&&f.jsx("div",{className:"empty",children:typeof I=="function"?I(xe):I}),C==null?void 0:C(xe,A)]}),ee=$e.length>0&&f.jsx(RE,{hints:$e});return f.jsxs(sf,{onClose:u,onEscape:K,boxClass:"picker",anchored:M,coverBy:U?".picker-input > *:first-child":R?".picker-input > *:last-child":void 0,children:[ae,Re,ee]})}function Bs({value:e,reads:t,options:n,onChange:r,placeholder:o,hint:a,className:l,onClose:u}){const[c,p]=S.useState(!1),m=()=>{p(!1),u==null||u()},h=t??e,k=n.find(v=>v.id===h),y=(k==null?void 0:k.chip)??(k==null?void 0:k.label)??h;return f.jsxs("span",{className:"chip-picker",children:[f.jsx(ze,{variant:"ghost",tone:"chrome",mono:!0,on:c,className:He("chip-picker-btn",l),...$t(a),onClick:()=>c?m():p(!0),children:y}),c&&f.jsx($r,{anchored:{flip:"both",margin:8},onEscape:m,items:n,filter:(v,x)=>{const _=x.trim().toLowerCase().split(/\s+/).filter(Boolean);return v.filter(N=>{const j=`${N.prefix??""} ${N.label??N.id} ${N.suffix??""} ${N.id}`.toLowerCase();return _.every(E=>j.includes(E))})},keyOf:v=>v.id,initialIndex:v=>Math.max(0,v.findIndex(x=>x.id===e)),lead:f.jsx(ze,{tone:"chrome",mono:!0,on:!0,className:"chip-picker-lead",onClick:m,children:y}),placeholder:o,rowClass:()=>"picker-row",row:v=>f.jsxs(f.Fragment,{children:[v.id===e&&f.jsx("span",{className:"row-current","aria-hidden":"true"}),f.jsxs("span",{className:He("chip-option",v.disabled&&"chip-option-off"),"aria-disabled":v.disabled,children:[f.jsxs("span",{className:"chip-option-name",children:[v.prefix?`${v.prefix} `:null,v.label??v.id,v.suffix?f.jsx("span",{className:"chip-option-suffix",children:` ${v.suffix}`}):null]}),v.description&&f.jsx("span",{className:"chip-option-desc row-dim",children:v.description})]})]}),onPick:v=>{v.disabled||(r(v.id),m())},onBack:m})]})}function ME({choices:e,value:t,current:n,what:r,defaultLabel:o,defaultDescription:a,placeholder:l,className:u,onChange:c,onClose:p}){if(e.length===0)return null;const{rows:m,shown:h,picked:k}=OE(e,t,n,{label:o,description:a}),y=m.find(x=>x.id===h),v=(y==null?void 0:y.chip)??(y==null?void 0:y.label)??h;return f.jsx(Bs,{value:k,reads:h,options:m,onChange:c,onClose:p,className:u,hint:t?`asked for ${v}; click to change`:`${v}, the agent's choice; click to pick ${r}`,placeholder:l})}function LE(e){const[t,n]=ho(mt.effortPrefix+(e??""),Qo,r=>r??"");return[t,n]}function om({efforts:e,value:t,current:n,onChange:r,onClose:o}){return f.jsx(ME,{choices:e,value:t,current:n,what:"an effort level",defaultLabel:"default effort",defaultDescription:"the level the agent runs at when nothing is asked for",placeholder:"how hard the agent thinks here",className:"effort-chip",onChange:r,onClose:o})}function L5(e){const[t,n]=ho(mt.modePrefix+((e==null?void 0:e.id)??""),wh,r=>cc.some(o=>o.id===r)?r:wh);return[t,n]}const P5=e=>{var t;return((t=cc.find(n=>n.id===e))==null?void 0:t.description)??""};function Y0({value:e,onChange:t,onClose:n}){return f.jsx(Bs,{value:e,options:cc.map(r=>({id:r.id,label:r.name,description:r.description})),onChange:t,onClose:n,className:He("mode-chip",e!=="auto"&&"mode-held"),hint:`${e}: ${P5(e)}. Click to change`,placeholder:"what the agent may do without asking"})}function PE(e){const[t,n]=ho(mt.modelPrefix+(e??""),Qo,r=>r??"");return[t,n]}function DE(e,t){try{localStorage.setItem(mt.modelPrefix+e,t)}catch{}}function sm({models:e,value:t,current:n,onChange:r,onClose:o}){return f.jsx(ME,{choices:e,value:t,current:n,what:"a model",defaultLabel:"default model",defaultDescription:"whatever the agent runs when nothing is asked for",placeholder:"which model answers here",className:"model-chip",onChange:r,onClose:o})}function zE({agents:e,agent:t,model:n,onChange:r,onClose:o}){const{rows:a,shown:l}=R5(e,t,n);if(a.length===0)return null;const u=a.find(p=>p.id===l),c=u?[u.prefix,u.label,u.suffix].filter(Boolean).join(" "):n;return f.jsx(Bs,{value:l,options:a,onChange:p=>{const m=I5(p);r(m.agent,m.model)},onClose:o,className:"model-chip",hint:`${c} works on the new worktree; click to change`,placeholder:"which agent and model work on it"})}function FE(e){const t=ef(e),[n,r]=ho(mt.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,r]}function D5({repo:e,value:t,onChange:n,onClose:r}){const o=ef(e);if(o.length===0||!t)return null;const a=(e==null?void 0:e.config.profiles)??{},l=(e==null?void 0:e.configFile)??"the settings",u=c=>{var h;const p=((h=a[c])==null?void 0:h.run)??[],m=p.length>0?`runs ${p.join(", ")}`:"runs nothing";return c===(e==null?void 0:e.config.defaultProfile)?`${m}; the default in ${l}`:m};return f.jsx(Bs,{value:t,options:o.map(c=>({id:c,description:u(c)})),onChange:n,onClose:r,hint:o.length>1?`${t}: ${u(t)}. Click to change`:`the only profile in ${l}`,placeholder:"the profile the worktree runs"})}function sc(e,t,n){if(!t)return e;const r=new Set(t.map(l=>l-n)),o=[];let a="";for(let l=0;l<e.length;l++)r.has(l)?(a&&o.push(a),a="",o.push(f.jsx("b",{className:"hit",children:e[l]},l))):a+=e[l];return a&&o.push(a),o}function z5({c:e,query:t}){const n=t.trim();return f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"picker-name",children:["/",sc(e.name,n?Mg(e.name,n):null,0)]}),f.jsx("span",{className:"picker-desc row-dim",children:e.description})]})}function Jn({label:e,hint:t,current:n=!1}){return f.jsxs(f.Fragment,{children:[n&&f.jsx("span",{className:"row-current","aria-hidden":"true"}),f.jsx("span",{className:"picker-label",children:e}),t?f.jsx("span",{className:"picker-hint row-dim",children:t}):null]})}function F5(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 B5=/ \| | - | \u2013 | \u2014 | \u00b7 |: /,U5=/^(\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[0-9a-f]{12,})$/i,H5=/^[[:$*{]|\[/;function W5(e){const t=new Map,n=e.filter(a=>!!a.title);if(new Set(n.map(a=>a.path)).size<2)return t;const r=n.map(a=>({path:a.path,parts:a.title.split(B5).map(l=>l.trim()).filter(Boolean)})),o=new Map;for(const{path:a,parts:l}of r)for(const u of l)o.set(u,(o.get(u)??new Set).add(a));for(const{path:a,parts:l}of r){const u=l.filter(c=>{var p;return(((p=o.get(c))==null?void 0:p.size)??0)<2});u.length>0&&t.set(a,u.join(" "))}return t}function Pg(e){const t=e.split(/[/#]/).filter(Boolean);for(let n=t.length-1;n>=0;n--){let r=t[n];try{r=decodeURIComponent(r)}catch{}if(U5.test(r)||H5.test(r))continue;const o=r.replace(/[-_.]+/g," ").trim();if(o)return o[0].toUpperCase()+o.slice(1)}return"Home"}const uh=8,K5=3,Z5=50,q5=3;function G5(e,t,n=[]){const r=new Map,o=[],a=new Map;for(const l of(t==null?void 0:t.routes)??[]){if(l.endpoint)continue;const u=l.dynamic?WO(l.path):null;u?(o.push(u),a.set(l.path,l)):r.set(l.path,l)}return{history:e,statics:r,templates:o,templateRoutes:a,unseen:(t==null?void 0:t.unseen)??{},titles:W5(e),links:new Map(n.map(l=>[l.path,l.text]))}}function BE(e){if(!e)return"/";try{const t=new URL(e);return t.pathname+t.search+t.hash}catch{return"/"}}function V5(e){const t=e.trim();return/^[/?#]/.test(t)?t:`/${t}`}function Y5(e,t){const n=/^[/?#]/.test(t)?e:e.replace(/^\//,"");return t&&n.toLowerCase().startsWith(t.toLowerCase())?n:null}const UE=e=>/^\[\[?\.\.\.|^\*$|^\$$/.test(e),Ml=e=>UE(e)||/[[:$*{]/.test(e)&&!/^[^[{:$*]+\?$/.test(e),Q5=e=>Dd(`/${e}`).text.slice(1),Dg=e=>e.split("/").filter(Boolean);function zg(e,t){const n=t.startsWith("/"),r=t.replace(/^\//,"").split("/"),o=Dg(e);let a="";const l=[],u=h=>{const k=Q5(h);l.push([a.length,a.length+k.length]),a+=k};for(let h=0;h<r.length;h++){const k=r[h],y=o[h];if(y===void 0)return null;if(h<r.length-1){if(UE(y))return{show:t,accept:t};if(Ml(y)){if(!k)return null}else if(k.toLowerCase()!==y.toLowerCase())return null;a+=`${Ml(y)?k:y}/`;continue}if(Ml(y))k?a+=k:u(y);else{if(!y.toLowerCase().startsWith(k.toLowerCase()))return null;a+=y}}for(const h of o.slice(r.length))a+="/",Ml(h)?u(h):a+=h;const c=n?1:0,p=(n?"/":"")+a,m=l[0];return{show:p,accept:m?p.slice(0,m[0]+c):p,params:l.map(([h,k])=>[h+c,k+c])}}function X5(e,t){const n=zg(e,t);return n?n.accept.length>t.length?n.accept:t:Dd(e).literal}function HE(e,t){if(e.kind==="go")return null;if(e.template){const n=zg(e.path,t);return n&&n.show.length>t.length?n:null}return Y5(e.path,t)}const J5=e=>e.trim().replace(/^\//,"").toLowerCase();function WE(e,t){for(let n=0;n<e.length;n++)if("/-_.#".includes(e[n])&&e.startsWith(t,n+1))return!0;return!1}function e6(e,t,n){const r=e.replace(/^\//,"").toLowerCase(),o=t.toLowerCase();return r===n?100:r.startsWith(n)?80:WE(r,n)?60:o.startsWith(n)?50:o.split(/\s+/).some(a=>a.startsWith(n))?45:r.includes(n)||o.includes(n)?20:0}function t6(e,t){const{text:n,literal:r}=Dd(e);return r.replace(/^\//,"").toLowerCase().startsWith(t)?80:zg(e,t)?70:WE(n.replace(/^\//,"").toLowerCase(),t)?60:0}function n6(e,t){const n=Dg(e).findIndex(Ml);return n>=0&&t.split("/").length>n}function Kl(e,t,n){var u;const r=e.statics.get(t),o=r?null:KO(e.templates,t),a=(r==null?void 0:r.file)??(o?(u=e.templateRoutes.get(o.path))==null?void 0:u.file:void 0),l=a?e.unseen[a]:void 0;return{kind:"page",path:t,title:e.titles.get(t)||e.links.get(t)||Pg(t),template:!1,visited:n<Number.POSITIVE_INFINITY,...a?{file:a}:{},...l?{badge:l}:{},rank:n,group:(o==null?void 0:o.path)??t,score:0}}function KE(e,t){const n=e.unseen[t.file];return{kind:"page",path:t.path,title:Pg(t.path),template:!0,visited:!1,file:t.file,...n?{badge:n}:{},rank:Number.POSITIVE_INFINITY,group:t.path,score:0}}function Yu({rank:e,group:t,score:n,...r}){return r}const xd=e=>Dg(e).length,_d=e=>e.badge==="new"?0:e.badge==="changed"?1:2;function r6(e,t){const n=new Set,r=[];e.history.forEach((m,h)=>{if(m.path===t)return;const k=Kl(e,m.path,h);n.has(k.group)||(n.add(k.group),r.push(k))});const o=new Set(r.map(m=>m.path)),a=r.filter(m=>m.badge);for(const[m,h]of e.statics)e.unseen[h.file]&&m!==t&&!o.has(m)&&a.push(Kl(e,m,Number.POSITIVE_INFINITY));for(const m of e.templateRoutes.values())e.unseen[m.file]&&!n.has(m.path)&&a.push(KE(e,m));a.sort((m,h)=>_d(m)-_d(h)||m.rank-h.rank);const l=r.filter(m=>!m.badge),u=a.slice(0,uh-Math.min(K5,l.length));for(const m of l)u.length<uh&&u.push(m);const c=new Set(u.map(m=>m.path)),p=[...e.statics.keys(),...[...e.links.keys()].filter(m=>!e.statics.has(m))].filter(m=>m!==t&&!c.has(m)&&!o.has(m)).sort((m,h)=>xd(m)-xd(h)||(m<h?-1:m>h?1:0));for(const m of p){if(u.length>=uh)break;u.push(Kl(e,m,Number.POSITIVE_INFINITY))}return u.map(Yu)}function o6(e,t,n){var h;const r=J5(t),o=V5(t),a=new Map;e.history.forEach((k,y)=>{k.path!==n&&a.set(k.path,Kl(e,k.path,y))});for(const k of[...e.statics.keys(),...e.links.keys()])k!==n&&!a.has(k)&&a.set(k,Kl(e,k,Number.POSITIVE_INFINITY));const l=[];for(const k of a.values()){const y=e6(k.path,k.title,r);y>0&&l.push({...k,score:y})}let u=null;for(const k of e.templates){const y=e.templateRoutes.get(k.path);if(!u&&!e.statics.has(o)&&k.re.test(o)){u=y;continue}const v=t6(k.path,r);v>=60&&l.push({...KE(e,y),score:v})}l.sort((k,y)=>y.score-k.score||k.rank-y.rank||_d(k)-_d(y)||xd(k.path)-xd(y.path)||(k.path<y.path?-1:k.path>y.path?1:0));const c=new Map,p=[];for(const k of l){if(!k.template&&k.group!==k.path){const y=c.get(k.group)??0;if(y>=q5&&!n6(k.group,r))continue;c.set(k.group,y+1)}if(p.push(k),p.length>=Z5)break}if(p.some(k=>k.score===100))return p.map(Yu);const m={kind:"go",path:o,title:Pg((u==null?void 0:u.path)??o)};return u||(((h=p[0])==null?void 0:h.score)??0)<80?[m,...p.map(Yu)]:[...p.map(Yu),m]}function ZE(e,{query:t,current:n,here:r}){return t===n||t.trim()===""?r6(e,r):o6(e,t,r)}const s6=[],i6=[];function qE(e,t){const n=L(a=>(t?a.visits[t]:void 0)??s6),r=Ot(e,"pages"),o=Ot(e,"links");return gt([e],()=>{Wx(r)&&Yt.post(e,{type:"links"})}),S.useMemo(()=>G5(n,r,o),[n,r,o])}function a6({row:e}){if(e.kind!=="page"||!e.template)return f.jsx("span",{className:"bar-route-path row-dim",children:e.path});const{text:t,params:n}=Dd(e.path),r=[];let o=0;for(const[a,l]of n)a>o&&r.push(t.slice(o,a)),r.push(f.jsx("span",{className:"bar-route-param",children:t.slice(a,l)},a)),o=l;return o<t.length&&r.push(t.slice(o)),f.jsx("span",{className:"bar-route-path row-dim",children:r})}function GE({row:e}){return f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"picker-label",children:e.title}),f.jsx(a6,{row:e}),e.kind==="go"?f.jsx("span",{className:"picker-hint row-dim",children:"go"}):e.badge?f.jsx("span",{className:e.badge==="new"?"badge-new":"badge-changed",children:e.badge}):null]})}const VE=e=>e.kind==="page"&&e.file?e.file:e.path,YE=(e,t)=>e.kind==="page"&&e.template?X5(e.path,t):null,QE=e=>e.kind==="page"&&e.template?"fills in the parameter":"goes there";function XE(e,t,n){return e.kind!=="page"?[]:Zd([...e.file&&t.dir?fs({id:t.worktreeId,dir:t.dir},e.file,{},n):[],k1,...e.visited?F5(t.repoId,e.path,n):[]])}function l6({worktreeId:e,repoId:t,url:n}){const r=ct(),o=it(),a=L(k=>{const y=fn(k,e);return y?y.worktree.path:null}),l=qE(e,t),u=BE(n),c=n?Pd(n):null,p=S.useCallback((k,y)=>ZE(l,{query:y,current:u,here:c}),[l,u,c]),m=S.useCallback(k=>k===u||k.trim()==="",[u]),h=()=>r({a:"close"});return f.jsx($r,{anchored:{matchWidth:0},items:i6,filter:p,initialQuery:u,selectOnMount:!0,idleWhen:m,onIdlePick:()=>{Yt.post(e,{type:"reload"}),h()},keyOf:k=>`${k.kind}:${k.path}`,rowClass:()=>"picker-row",rowTitle:VE,completionOf:(k,y)=>m(y)?null:HE(k,y),narrowTo:YE,onPick:k=>{Yt.post(e,{type:"navigate",path:k.path}),h()},onBack:h,rowMenu:k=>XE(k,{worktreeId:e,repoId:t,dir:a},{sock:o,dispatch:r}),placeholder:"type a path",keys:k=>({complete:"completes the path",pick:k?QE(k):"reloads",back:"closes"}),empty:"no pages yet; type a path",row:k=>f.jsx(GE,{row:k})})}function JE(e,t){const n=t.trim();return f.jsx(Jn,{label:sc(e.label,n?Mg(e.label,n):null,0),hint:e.hint&&f.jsx(Or,{k:e.hint})})}function eS({anchored:e,trailing:t}){const n=ct(),r=_E(),o=L(a=>{var l;return((l=a.paletteReturn)==null?void 0:l.mode)==="commands"?a.paletteReturn.q:""});return f.jsx($r,{anchored:e,trailing:t,items:r,filter:EE,rowClass:()=>"picker-row",keyOf:a=>a.id,onPick:(a,l)=>{a.sub?n({a:"palette-return",v:{mode:"commands",q:l}}):n({a:"close"}),a.run()},onBack:()=>n({a:"close"}),placeholder:"run a command…",keys:{pick:"runs",back:"closes"},initialQuery:o,empty:"no matching command",row:(a,l,u)=>JE(a,u)})}function tS(e,t){const n=new Map(t.map(l=>[l.path,l])),r=t.filter(l=>l.xy==="??"&&l.path.endsWith("/")).map(l=>l.path),o=e.map(l=>{const u=n.get(l)??(r.some(c=>l.startsWith(c))?{path:l,xy:"??"}:void 0);return u?{path:l,status:u}:{path:l}}),a=new Set(e);for(const l of t)!a.has(l.path)&&!l.path.endsWith("/")&&o.push({path:l.path,status:l});return o}function Q0(e,t){const n=e.split("/"),r=t.split("/");for(let o=0;;o++){const a=n[o],l=r[o];if(a===void 0||l===void 0)return n.length-r.length;const u=o===n.length-1,c=o===r.length-1;if(u!==c)return u?-1:1;if(a!==l)return a<l?-1:1}}function nS(e,t,n,r=50){const o=tS(e,t),a=n.trim().toLowerCase();if(!a){const u=new Map(t.map((h,k)=>[h.path,k])),c=h=>{var k;return u.get(((k=h.status)==null?void 0:k.path)??"")??u.get(h.path)??Number.MAX_SAFE_INTEGER},p=o.filter(h=>h.status).sort((h,k)=>c(h)-c(k)||Q0(h.path,k.path)),m=o.filter(h=>!h.status).sort((h,k)=>Q0(h.path,k.path));return{rows:[...p,...m].slice(0,r),changed:Math.min(p.length,r)}}const l=oS(o,a);return l.sort((u,c)=>c.score-u.score||u.row.path.localeCompare(c.row.path)),{rows:l.slice(0,r).map(u=>u.row),changed:0}}function rS(e,t){const n=e.toLowerCase(),r=X0(n,t);return r<=0?0:X0(n.slice(n.lastIndexOf("/")+1),t)>0?r+10:r}function oS(e,t){const n=[];for(const r of e){const o=rS(r.path,t);o>0&&n.push({row:r,score:r.status?o+4:o})}return n}function c6(e,t,n,r,o){const a=r.trim().toLowerCase();if(!a)return nS(e,n,r,o).rows.map(c=>({kind:"file",path:c.path,status:c.status}));const l=oS(tS(e,n),a).map(({row:c,score:p})=>({row:{kind:"file",path:c.path,status:c.status},score:p}));for(const c of t){const p=rS(c,a);p>0&&l.push({row:{kind:"folder",path:c},score:p})}const u=c=>c.kind==="folder"?1:0;return l.sort((c,p)=>p.score-c.score||u(c.row)-u(p.row)||c.row.path.localeCompare(p.row.path)),l.slice(0,o).map(c=>c.row)}function u6(e,t){const n=e.toLowerCase(),r=[];let o=0;for(const a of t.toLowerCase()){const l=n.indexOf(a,o);if(l===-1)return null;r.push(l),o=l+1}return r}function X0(e,t){let n=0,r=0,o=0;for(const a of t){const l=e.indexOf(a,r);if(l===-1)return 0;o=l===r?o+1:1,n+=o+(l===0||e[l-1]==="/"||e[l-1]==="."?3:0),r=l+1}return n+Math.max(0,40-e.length/4)}function d6(e){const t=e.lastIndexOf("/");return t===-1?[e,""]:[e.slice(t+1),e.slice(0,t+1)]}const J0=[],f6=[],p6=[];function h6({worktreeId:e}){var x;const t=ct(),n=it(),r=Bn();gt([e,n],()=>Gd(e,r.getState(),{sock:n,dispatch:t}));const o=f1(e),a=o.files??f6,l=((x=o.git)==null?void 0:x.files)??p6,u=_E(),c=L(_=>{var N;return((N=_.paletteReturn)==null?void 0:N.mode)==="quick-open"?_.paletteReturn.q:""}),p=L(_=>{var j;const N=(j=fn(_,e))==null?void 0:j.worktree;return N?N.path:null}),m=L(_=>{var N;return((N=fn(_,e))==null?void 0:N.repoId)??null}),h=L(_=>{var N;return((N=dd(_))==null?void 0:N.worktreeId)===e}),k=qE(e,m),y=o.page.url?Pd(o.page.url):null,v=S.useCallback((_,N)=>N.startsWith(">")?EE(u,N.slice(1)).map(j=>({kind:"cmd",c:j})):N.startsWith("/")?h?ZE(k,{query:N,current:"/",here:y}).map(j=>({kind:"page",page:j})):J0:nS(a,l,N).rows.map(j=>({kind:"file",path:j.path,status:j.status})),[u,a,l,h,k,y]);return f.jsx($r,{items:J0,filter:v,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"?VE(_.page):void 0,completionOf:(_,N)=>_.kind==="page"?HE(_.page,N):null,narrowTo:(_,N)=>_.kind==="page"?YE(_.page,N):null,onPick:(_,N)=>{_.kind==="cmd"?(_.c.sub?t({a:"palette-return",v:{mode:"quick-open",q:N}}):t({a:"close"}),_.c.run()):_.kind==="page"?(Yt.post(e,{type:"navigate",path:_.page.path}),t({a:"close"})):(nr({dispatch:t},{worktreeId:e,path:_.path,view:Ai(_.path)}),t({a:"close"}))},onBack:()=>t({a:"close"}),rowMenu:_=>_.kind==="file"&&p?fs({id:e,dir:p},_.path,{},{sock:n,dispatch:t}):_.kind==="page"&&m?XE(_.page,{worktreeId:e,repoId:m,dir:p},{sock:n,dispatch:t}):[],placeholder:"jump to file · type > for commands, / for pages",keys:(_,N)=>N.startsWith("/")?{complete:"completes the path",pick:(_==null?void 0:_.kind)==="page"?QE(_.page):void 0,back:"closes"}:{pick:"opens",back:"closes"},initialQuery:c,empty:_=>_.startsWith(">")?"no matching command":_.startsWith("/")?h?"no pages yet; type a path":"no preview running":"no matches",row:(_,N,j)=>_.kind==="cmd"?JE(_.c,j.slice(1)):_.kind==="page"?f.jsx(GE,{row:_.page}):im(_.path,_.status,j,{gutter:l.length>0})})}function im(e,t,n,{folder:r=!1,gutter:o=!0}={}){const[a,l]=d6(e),u=n.trim()?u6(e,n.trim()):null;return f.jsxs(f.Fragment,{children:[o&&f.jsx("span",{className:`xy ${t?Bm(t.xy):""}`,children:t?Um(t.xy):""}),f.jsxs("span",{className:"name",children:[sc(a,u,l.length),r&&"/"]}),f.jsx("span",{className:"dir row-dim",children:l&&f.jsxs(f.Fragment,{children:["‎",sc(l,u,0),"‎"]})}),t&&f.jsx(a_,{f:t})]})}function dh({icon:e,verb:t,tip:n,onPress:r,onDismiss:o,children:a}){return f.jsxs("div",{className:"composer-ask",children:[f.jsx(St,{name:e,className:"icon-inline"}),f.jsxs("span",{className:"composer-ask-line",children:[f.jsx(ze,{variant:"inline",tone:"strong","data-tip":n,onClick:r,children:t})," ",a]}),o&&f.jsx(At,{icon:"close",tone:"quiet",className:"composer-ask-close",label:"Not this one",onClick:o})]})}function m6(e,t){if(t.queued>0||t.sending||t.ask)return null;const n=e.at(-1);if((n==null?void 0:n.kind)!=="tool"||!n.done||!n.fixable||t.dismissed.has(n.id)||e.some(o=>o.kind==="asked"&&o.toolId===n.id))return null;const r=of(n);return r===null?null:{verb:"fix",toolId:n.id,command:r}}let am=new Set;const lm=new Set;function g6(e){return lm.add(e),()=>{lm.delete(e)}}function k6(e){am=new Set(am).add(e);for(const t of lm)t()}function y6(){return S.useSyncExternalStore(g6,()=>am)}const w6=e=>cc.some(t=>t.id===e);function v6(e){return[...cc.map(t=>({name:t.id,description:t.description,hint:"[<description>]"})),{name:"check",description:"run the repo's check here and write the recap and the commit message",hint:"[<note for the commit message>]"},{name:"land",description:e},{name:"archive",description:"archive this worktree once its work has landed"}]}function b6(e,t){const n=new Set(e.map(r=>r.name));return[...e,...t.filter(r=>!n.has(r.name))]}function x6(e,t){const n=/^\/(\S*)([\s\S]*)$/.exec(e);if(!n)return null;const r=n[1]??"";return t.some(o=>o.name===r)?{name:r,args:(n[2]??"").trim()}:null}const eb=[],_6=[],E6=new Set(["ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),S6=e=>({kind:"cmd",c:e});function N6(e,t,n,r){return e==="command"?r?n===0?"starting the agent to see what it offers…":"no matching command":"no session has run this agent yet, so it has offered no commands":t?"no matches":"listing files…"}function T6(e){return e.kind==="cmd"?`/${e.c.name} `:e.kind==="folder"?`@${e.path}/ `:e.kind==="changes"?"@changes ":`@${e.path} `}const fh="still uploading what is attached; send again in a moment";function Qu({active:e,draft:t,archived:n,found:r,greenfield:o,placement:a="dock"}){var Wi,_c,Ec,Sc,Nc,Tc,Ga,jc;const l=a==="screen",u=ct(),c=it(),p=Bn(),m=!!t,h=(e==null?void 0:e.worktree.id)??null,k=e==null?void 0:e.worktree.repoId,y=n?n.id:r?r.id:pc(e),v=!!n||!!r,x=n?n.restorable:!!r&&!r.locked,_=Ot(y,"draft"),N=Ot(y,"attachments"),j=Ot(y,"notice"),E=((Wi=e==null?void 0:e.worktree.owns)==null?void 0:Wi.join(", "))??"",M=S.useRef({id:h,owns:E});gt([h,E],()=>{const W=M.current;M.current={id:h,owns:E},!(W.id!==h||W.owns===E||!E||!y||n)&&u({a:"notice",id:y,text:`Running its own ${E} here now: this branch changed it.`})});const K=Ot(y,"mark"),U=(K==null?void 0:K.by)==="walk"?K:void 0,R=Ot(h,"chat"),I=Ot(h,"queue"),C=S.useMemo(()=>h&&!m?Ax(R):null,[h,m,R]),P=Ot(h,"askParked"),z=Ot(h,"sending"),q=S.useMemo(()=>h&&!m&&!z?P$(R):null,[h,m,z,R]),se=Ot(h,"askRevived"),pe=!C&&q&&se===q.id?q:null,ue=C&&P!==C.id?C:pe,xe=C?P===C.id?C:null:q&&!pe?q:null,oe=S.useRef(null),A=Vs(),X=Jm(),Z=Ot(X,"page"),$=mc(),{onPaste:V,onPasteKey:de,onPasteKeyUp:me}=vL(y,h),he=dM(),$e=y6(),ae=S.useMemo(()=>h&&!m?m6(R,{queued:I.length,sending:!!z,ask:!!(ue||xe),dismissed:$e}):null,[h,m,R,I.length,z,ue,xe,$e]),ve=W=>y&&u({a:"set-draft",id:y,text:W}),Re=L(W=>W.clientId),ee=L(W=>W.repos.find(Ve=>Ve.id===(e==null?void 0:e.worktree.repoId))??null),Y=L(W=>W.defaultAgent),Pe=L(W=>W.agentChosen),We=m||!!o,Fe=!We&&!!e&&!e.worktree.agent,pt=We||Fe,Ge=(t==null?void 0:t.agent)??Y,vt=L(W=>W.agents.find(Ve=>Ve.id===(pt?Ge:e==null?void 0:e.worktree.agent))),at=!!(vt!=null&&vt.quick),qt=(vt==null?void 0:vt.models)??eb,an=(vt==null?void 0:vt.efforts)??eb,[qe,J]=PE(Ge),[we,Xe]=LE(Ge),et=L(W=>W.agents),Wt=(W,Ve)=>{if(W===Ge){J(Ve);return}DE(W,Ve),m?u({a:"draft-agent",id:W}):c==null||c.send({t:"set-default-agent",agent:W})},Qt=Ot(h,"model"),ge=Ot(h,"effort"),Me=Ot(h,"usage")??(e==null?void 0:e.usage),[hn]=FE(ee),It=(t==null?void 0:t.profile)??hn,[Rt,In]=L5(ee),Dt=(e==null?void 0:e.worktree.mode)??wh,gn=L(W=>W.picking),kt=L(W=>W.layout.term),Gt=Fx((e==null?void 0:e.procs)??[]),tn=sn("composer"),nn=Ot(h,"files"),Un=S.useMemo(()=>Ux(nn??_6),[nn]),_t=Ot(h,"git"),Kt=(_t==null?void 0:_t.files.length)??(e==null?void 0:e.dirty)??0,Rn=(_t==null?void 0:_t.unpushed)??(e==null?void 0:e.unpushed)??0,H=L(W=>{var Ve;return h?(Ve=W.shipping[h])==null?void 0:Ve.op:void 0}),fe=L(W=>{var Ve;return h?(Ve=W.shipping[h])==null?void 0:Ve.step:void 0}),Ie=L(W=>ja(W,k)),rt=L(W=>{var Ve;return Ie?(Ve=W.shipping[Ie.id])==null?void 0:Ve.op:void 0}),te=Ie&&ee&&We?Q1(ee.defaultBranch,Ie):null,Ne=L(W=>m?e2(W.rows,k,Ge,Y):h),be=Ot(Ne,"commands"),_e=be.some(W=>W.name==="compact"),Oe=(e==null?void 0:e.agent)==="working"||(e==null?void 0:e.agent)==="waiting",Mt=Oe&&!!h&&!m,Tt=e==null?void 0:e.worktree.lastTurn,ht=!_.trim()&&N.length===0,wn=!m&&!o&&ht&&!Oe?Tt:void 0,Ke=!m&&!o&&e&&bi(e.worktree)?e.worktree.landing:void 0,Kn=!!(Ke!=null&&Ke.ready)&&!Ke.stale&&!Iu(Ke,Kt,at,vt==null?void 0:vt.name),Nt=ht&&(!Oe||Kn)?Ke:void 0,Sn=Kt||(((_c=_t==null?void 0:_t.committed)==null?void 0:_c.length)??0),Nn=!m&&!o&&ht&&!Oe&&!!e,Hn=!!(e!=null&&e.worktree.landed)&&Kt===0,Lt=Nn&&Hn,Xt=Nn&&!Lt?e.worktree.pr:void 0,mn=!Hn&&((Ec=e==null?void 0:e.worktree.pr)==null?void 0:Ec.state)==="open"?e.worktree.pr:void 0,Gn=!!mn&&(Kt>0||Rn>0),On=((Sc=e==null?void 0:e.worktree.pr)==null?void 0:Sc.state)==="closed",sr=_i((ee==null?void 0:ee.config)??{}),Mr=S.useMemo(()=>v6(Ju(_i((ee==null?void 0:ee.config)??{}),ee==null?void 0:ee.defaultBranch)),[ee]),wo=()=>h&&(c==null?void 0:c.send({t:"chat",worktreeId:h,text:"/compact"})),on=_e?Oe?"wait for the turn to end":void 0:"this agent offers no compact command",Do=_e&&Me?_P(Me.used/Me.size):void 0,so=()=>[{id:"compact",label:"compact the context",detail:on||!Me?void 0:xP(Me.used/Me.size),disabled:on,onClick:wo}],[Zn,Vn]=S.useState(0),[je,Be]=S.useState(null),[yt,xt]=S.useState(null),ln=S.useRef(null),ot=y&&!v?W0(_,Zn):null,B=ot!==null&&ot.from!==je&&!U,ce=ot==null?void 0:ot.kind,De=ot==null?void 0:ot.query,lt=S.useMemo(()=>{if(De===void 0)return[];if(ce==="command")return q3(b6(Mr,be),De).slice(0,8).map(S6);const W=[],Ve=(_t==null?void 0:_t.files.length)??0;return Ve>0&&"changes".startsWith(De.toLowerCase())&&W.push({kind:"changes",n:Ve}),W.push(...c6(nn??[],Un,(_t==null?void 0:_t.files)??[],De,8)),W},[ce,De,nn,Un,_t,be,Mr]),ut=S.useRef(null),Bt=S.useRef(null),kn=()=>{var W;return(W=oe.current??ut.current)==null?void 0:W.focus()},vn=kn;gt([o?e==null?void 0:e.worktree.id:null],()=>{if(!o)return;const W=requestAnimationFrame(()=>{var Ht;const Ve=document.activeElement;(!Ve||Ve===document.body)&&((Ht=ut.current)==null||Ht.focus())});return()=>cancelAnimationFrame(W)});const Lr=L(W=>W.focusChat),Vr=S.useRef(Lr),vo=!!p1();gt([Lr],()=>{if(Lr===Vr.current||(Vr.current=Lr,vo!==!!o))return;const W=requestAnimationFrame(kn);return()=>cancelAnimationFrame(W)});const wr=ue==null?void 0:ue.id,Pr=S.useRef({id:h,askUpId:wr});gt([h,wr],()=>{const W=Pr.current;if(Pr.current={id:h,askUpId:wr},wr||!W.askUpId||W.id!==h||vo!==!!o||A&&!xe)return;const Ve=requestAnimationFrame(()=>{var xn;const Ht=document.activeElement;(!Ht||Ht===document.body)&&((xn=ut.current)==null||xn.focus())});return()=>cancelAnimationFrame(Ve)});const Yn=L(W=>W.walked),bo=S.useRef(Yn);gt([Yn],()=>{if(Yn===bo.current||(bo.current=Yn,vo!==!!o))return;const W=requestAnimationFrame(()=>{const Ve=document.activeElement;(!Ve||Ve===document.body||Ve.closest(".rail"))&&kn()});return()=>cancelAnimationFrame(W)});const Pt=B1({results:lt,keyOf:W=>W.kind==="cmd"?`c:${W.c.name}`:W.kind==="changes"?"changes":`f:${W.path}`,q:(ot==null?void 0:ot.query)??"",listRef:ln,tabPicks:!0,onPick:W=>{if(!ot)return;const{text:Ve,caret:Ht}=Z3(_,ot,T6(W));ve(Ve),Be(ot.from),xt(W.kind==="cmd"&&W.c.hint?{name:W.c.name,hint:W.c.hint}:null),requestAnimationFrame(()=>{const xn=ut.current;xn&&(xn.focus(),xn.setSelectionRange(Ht,Ht),Vn(Ht))})}}),tt=h||v?a5(_):null,es=yt&&_===`/${yt.name} `?yt.hint:null,bn=tt===""&&e?m?" a command to run in the new worktree's terminal":` a command to run in ${e.worktree.title}; the agent sees its output with your next message`:null,Ut=es??bn,vr=(e==null?void 0:e.worktree.title)??"untitled",Qn=(Nc=Tt==null?void 0:Tt.recap)==null?void 0:Nc.text,Ee=()=>{h&&Hs(c,u,{t:"land",worktreeId:h})},O=W=>{h&&(c==null||c.send({t:"judge",worktreeId:h,...W?{note:W}:{}}))},D=!!((Tc=ee==null?void 0:ee.config.check)!=null&&Tc.trim()),ne=cg(Ke,Kt,at),ke=Nn&&!H&&!We&&bi(e.worktree)&&!Hn&&!On&&Sn>0&&(!Ke||!!Ke.stale||ne==="unanswered"),Ce="Archive this worktree when you are done here; the rail's archived section brings it back with its chat.",Ue=Gn?"update":"land",wt=ee?Cd(ee):"main",cn=Gn&&mn?`Commit, take ${wt} in and push the branch; PR #${mn.number} takes the new commits.`:`${Ju(sr,ee==null?void 0:ee.defaultBranch)}.`,Vt=h?Lt?{word:"archive",line:((Ga=e==null?void 0:e.worktree.pr)==null?void 0:Ga.state)==="merged"?us(e.worktree.pr):`landed on ${(ee==null?void 0:ee.defaultBranch)??"main"}.`,tip:Ce,run:()=>Ti(c,u,[h])}:(Xt==null?void 0:Xt.state)==="open"&&!Gn?X1(Xt)?{word:"merge",line:Ru(Qn??us(Xt)),tip:`${us(Xt)} Merge the PR now, by the method the repo allows.`,run:Ee,ships:!0}:{word:"view",line:Ru(Qn??us(Xt)),tip:`${us(Xt)} Open the PR on GitHub.`,run:()=>window.open(Xt.url,"_blank")}:(Xt==null?void 0:Xt.state)==="closed"?{word:"archive",line:us(Xt),tip:`${us(Xt)} ${Ce}`,run:()=>Ti(c,u,[h])}:ke?{word:"check",line:(Ke==null?void 0:Ke.subject)??Ru(Qn??XL(Sn)),tip:e_(Ke,D,ne),run:O}:Nt!=null&&Nt.ready&&!Iu(Nt,Kt,at,vt==null?void 0:vt.name)?{word:Ue,line:Nt.subject??Ru(Qn??(qv(Nt,Sn)||"ready")),tip:[qv(Nt,Sn),QL(wt,e==null?void 0:e.behind),cn,Nt.subject?"Tab edits the message first.":""].filter(Boolean).join(" "),run:Ee,ships:!0}:null:null,Tn=((Vt==null?void 0:Vt.word)==="land"||(Vt==null?void 0:Vt.word)==="update"||(Vt==null?void 0:Vt.word)==="check")&&Nt?JL(Nt,ne):null,ts=S.useRef(null);H!=="land"&&(ts.current=h&&(Vt!=null&&Vt.ships)?{id:h,verb:Vt,under:Tn}:null);const $n=H==="land"&&ht&&((jc=ts.current)==null?void 0:jc.id)===h?ts.current:null,Mn=$n?$n.verb:Vt,Xs=!!(Mn!=null&&Mn.ships)&&H==="land",Ha=Gm(fe,Vm),zo=nc(e,"commit"),Fo=nc(e,"check"),Yr=n_(Xs?zo:Fo),Js=Aa(dg(Yr)?Yr==null?void 0:Yr.since:void 0),Wa=Nt?Nt.check==="pending"&&Fo&&Yr===Fo?Uh("Checking the work",Fo,Js):Iu(Nt,Kt,at,vt==null?void 0:vt.name):null,Ka=Mn&&Xs?Ha?`${Mn.word}: ${Ha}`:`${Mn.word} ${Mn.line}`:null,Li=Ka&&zo&&Yr===zo?Uh(Ka,zo,Js):Ka,Pi=n?n.restorable?`message agent on ${n.title}; sending restores it first`:"its commits were not kept, so it cannot come back":r?r.locked?`held by ${r.lockReason??"another tool"}; Toyon takes it over once the lock goes`:`message agent on ${r.name}; sending takes it over first`:e?Mn?"":Wa||(Xt?us(Xt):wn?ug(wn):o?`describe ${vr}…`:We?"describe a change":l?`message agent on ${vr}`:`message agent on ${vr}; / for a command, ! for a shell command`):"no worktree selected",ei=_!==""||Ut||!e?null:Xs?Ha?null:$n?$n.under:Tn:Mn?Tn:Xt||Wa?Qn??(Nt==null?void 0:Nt.subject)??null:null,xo=S.useRef(!1);S.useEffect(()=>{const W=B&&!xo.current;xo.current=B,W&&((ot==null?void 0:ot.kind)==="file"&&h?Gd(h,p.getState(),{sock:c,dispatch:u}):(ot==null?void 0:ot.kind)==="command"&&Ne&&be.length===0&&(c==null||c.send({t:"list-commands",worktreeId:Ne})))},[B,ot==null?void 0:ot.kind,be.length,h,Ne,c,p,u]);const Di=()=>{if(!e)return;const W=[],Ve=Z;if(Ve.url)try{const ar=new URL(Ve.url);W.push(`current route: ${ar.pathname}${ar.search}`)}catch{}Ve.title&&W.push(`page title: ${Ve.title}`),Ve.errors.length&&W.push(`recent console errors:
229
+ ${Ve.errors.map(ar=>`- ${ar}`).join(`
230
+ `)}`);const Ht=[];o&&Ht.push(T5(e.worktree.title,ee==null?void 0:ee.configFile)),W.length>0&&Ht.push(`What the user is looking at right now:
231
+ ${W.join(`
232
+ `)}`);const xn=c5(R);return xn&&Ht.push(xn),Ht.length>0?Ht:void 0},ti=W=>{We?In(W):h&&W!==Dt&&(c==null||c.send({t:"set-worktree-mode",worktreeId:h,mode:W}))},ir=W=>y&&u({a:"notice",id:y,text:W}),zi=(W,Ve="")=>{if(!e||!h)return;if(W==="archive"){Hn||On?Ti(c,u,[h]):ir("archive is for a landed worktree; this one has not landed");return}if(W==="check"){We||!bi(e.worktree)?ir("nothing to check from here"):Oe?ir("wait for the turn to end"):Sn===0?ir("nothing to check: no changes here"):O(Ve||void 0);return}const Ht=Ke?Iu(Ke,Kt,at,vt==null?void 0:vt.name):null;We||!bi(e.worktree)?ir("nothing to land from here"):Hn?ir(`already landed on ${(ee==null?void 0:ee.defaultBranch)??"main"}`):Ht?ir(Ht):Oe&&(!Ke||Ke.stale)?ir("wait for the turn to end"):Ke!=null&&Ke.stale?ir("the work changed since this was checked; check again first"):Ee()},ys=N.some(cd),Fi=()=>{y&&(c==null||c.send({t:"set-draft",boxId:y,text:_,clientId:Re}))},gr=()=>{if(!y||ht)return;if(n){if(!n.restorable)return;if(tt!==null){ir("nothing runs here until it is restored");return}if(ys){ir(fh);return}const Bo=N.length?N.map(Fl):void 0;Fi(),c==null||c.send({t:"restore-worktree",archiveId:n.id,clientId:Re,message:{text:_.trim(),attachments:Bo},boxId:y}),u({a:"restoring",id:y,text:_.trim()}),u({a:"sent-box",id:y});return}if(r){if(r.locked)return;if(tt!==null){ir("nothing runs here until Toyon takes it over; its menu on the rail opens a shell");return}if(ys){ir(fh);return}const Bo=N.length?N.map(Fl):void 0;Fi(),c==null||c.send({t:"adopt-worktree",worktreeId:r.id,clientId:Re,message:{text:_.trim(),attachments:Bo},boxId:y}),u({a:"restoring",id:y,text:_.trim()}),u({a:"sent-box",id:y});return}if(!e||!h)return;if(tt!==null){tt&&m?u({a:"term-run",id:h,command:tt}):tt&&(c==null||c.send({t:"exec",worktreeId:h,command:tt})),ve("");return}const W=x6(_,Mr),Ve=W&&w6(W.name)?W.name:void 0;if(W&&!Ve){zi(W.name,W.args),ve("");return}if(Ve&&!(W!=null&&W.args)){ti(Ve),ve("");return}if(t!=null&&t.batch&&N.length){ir("a batch takes no attachments; remove them or turn batch off");return}if(o&&!Pe){ir("choose an agent above first");return}if(ys){ir(fh);return}const Ht=W?W.args:_.trim(),xn=Di(),ar=N.length?N.map(Fl):void 0;if(Fi(),Ve&&ti(Ve),We){const Bo=uc(e.worktree)?{worktreeId:h}:{},ff={clientId:Re,repoId:e.worktree.repoId,context:xn,attachments:ar,agent:Ge,profile:It,mode:Ve??Rt,...qe?{model:qe}:{},...we?{effort:we}:{},...Kx(t)?{carry:!0}:{}};if(Ge!==Y&&(c==null||c.send({t:"set-default-agent",agent:Ge})),t!=null&&t.batch)c==null||c.send({t:"batch-worktrees",repoId:e.worktree.repoId,prompt:Ht,agent:Ge,...qe?{model:qe}:{},...we?{effort:we}:{},boxId:y});else{const Cc=t&&t.variants>1?{variants:t.variants}:{};c==null||c.send({t:"create-worktree",...ff,...Bo,...Cc,prompt:Ht,boxId:y}),y&&u({a:"sending",id:y,message:{text:Ht,attachments:ar}})}}else Fe&&(c==null||c.send({t:"set-worktree-model",worktreeId:h,model:qe}),c==null||c.send({t:"set-worktree-effort",worktreeId:h,effort:we})),c==null||c.send({t:"chat",worktreeId:h,clientId:Re,text:Ht,context:xn,attachments:ar,boxId:y}),Oe||u({a:"sending",id:h,message:{text:Ht,attachments:ar}});u({a:"sent-box",id:y}),o&&u({a:"show-chat"})},ws=W=>{if(!h||(pe==null?void 0:pe.ask.kind)!=="question")return;if(!W.some(va))return u({a:"ask-revive",id:h});const Ve=Lx(pe.ask.questions,W).join(`
233
+ `);c==null||c.send({t:"chat",worktreeId:h,clientId:Re,text:Ve,context:Di()}),u({a:"sending",id:h,message:{text:Ve}}),u({a:"ask-revive",id:h})},ni=L(W=>W.autoSend);gt([ni,h],()=>{!ni||ni!==h||!_.trim()||vo!==!!o||(u({a:"auto-sent"}),gr())});const ri=()=>{const W=N[N.length-1];return!y||!W?!1:(u({a:"detach",id:y,key:W.key}),!0)},bc=W=>{y&&(u({a:"walk",id:y,walk:W.walk,text:W.text}),requestAnimationFrame(()=>{var Ve;(Ve=ut.current)==null||Ve.setSelectionRange(W.text.length,W.text.length),Vn(W.text.length)}))},Bi=()=>{y&&U&&u({a:"walk",id:y,walk:null,text:_})},qa=We?[]:R.map(W=>W.kind==="user"?W.attachments:void 0),oi=We?[]:I.flatMap(W=>W.attachments??[]),Ui=e?e.worktree.path:null,Hi=e==null?void 0:e.worktree.plan,xc=Mt&&!ue,uf=L(W=>W.reading),df=l&&uf&&ht&&!ue&&!xe&&!he;return f.jsxs("div",{className:He("composer chat-input",xc&&"stopping",df&&"lean"),children:[Hi&&e&&f.jsxs("div",{className:"composer-plan",children:[f.jsx(St,{name:"text",className:"icon-inline"}),f.jsx(ze,{variant:"inline",className:"composer-plan-path","data-tip":"Read the plan in the editor pane",onClick:()=>nr({dispatch:u},{worktreeId:e.worktree.id,path:Hi,view:"preview"}),children:Hi})]}),xe&&h&&f.jsx(dh,{icon:"chat",verb:"answer",tip:"Bring the question back into the box",onPress:()=>{u(xe.outcome?{a:"ask-revive",id:h,askId:xe.id}:{a:"ask-unpark",id:h}),u({a:"focus-chat"})},children:D$(xe)}),ae&&h&&f.jsxs(dh,{icon:"run",verb:ae.verb,tip:"Send the agent what it printed and ask for a fix",onPress:()=>c==null?void 0:c.send({t:"fix",worktreeId:h,toolId:ae.toolId}),onDismiss:()=>k6(ae.toolId),children:["what failed in ",f.jsx("code",{children:ae.command})]}),he&&y&&!ue&&(e||x)&&f.jsx(dh,{icon:"copy",verb:"attach",tip:"Attach it, as a paste would",onPress:()=>{dL(p,y,he),kn()},onDismiss:h1,children:he.kind==="image"?"the image you copied":`the text you copied, ${he.text.split(`
234
+ `).length} lines`}),y&&Nb(N,Tb(Sb(qa),oi)).map(([W,Ve])=>{const Ht=()=>u({a:"detach",id:y,key:W.key});return W.kind==="image"?f.jsx(Og,{src:W.local??fd(W.upload),n:Ve,name:W.name,width:W.width,height:W.height,bytes:W.bytes,uploading:W.uploading,onRemove:Ht},W.key):W.kind==="file"?f.jsx(Ig,{name:W.name,bytes:W.bytes,href:W.text&&W.upload?fd(W.upload):void 0,uploading:W.uploading,onRemove:Ht},W.key):W.kind==="paste"?f.jsx(Ag,{n:Ve,name:W.name,source:W.source,lines:W.lines,chars:W.chars,preview:W.preview,text:W.text,onRemove:Ht},W.key):f.jsx(Lg,{pick:W,dir:Ui,tipText:W.html,onHover:xn=>X&&Yt.post(X,xn?{type:"highlight-selector",selector:W.selector,label:Hm(W)}:{type:"highlight-clear"}),worktreeId:h,onOpen:(xn,ar)=>h&&Ra(p,c,h,xn,ar),onRemove:Ht},W.key)}),B&&ot&&f.jsx(S5,{results:lt,keyOf:W=>W.kind==="cmd"?`c:${W.c.name}`:W.kind==="changes"?"changes":W.kind==="folder"?`d:${W.path}`:`f:${W.path}`,rowClass:W=>W.kind==="file"||W.kind==="folder"?"qo-file":W.kind==="changes"?"picker-row":"picker-row picker-cmd",nav:Pt,listRef:ln,empty:N6(ot.kind,nn,be.length,Ne!==null),row:W=>{const Ve=((_t==null?void 0:_t.files.length)??0)>0;return W.kind==="file"?im(W.path,W.status,ot.query,{gutter:Ve}):W.kind==="folder"?im(W.path,void 0,ot.query,{folder:!0,gutter:Ve}):W.kind==="changes"?f.jsx(Jn,{label:"@changes",hint:`${W.n} uncommitted ${W.n===1?"file":"files"}`}):f.jsx(z5,{c:W.c,query:ot.query})}}),ue&&h?f.jsx(jz,{item:ue,worktreeId:h,rootRef:oe,onAnswer:pe?ws:void 0},ue.id):f.jsxs("div",{className:He("composer-field",tt!==null&&"shell",U&&"recalled"),children:[f.jsx(Ia,{size:"lg",bare:!0,font:tt!==null?"mono":"ui",ref:ut,value:_,onChange:W=>{var Bo;const Ve=W.target.value,Ht=W.target.selectionStart??Ve.length;ve(Ve),Vn(Ht),Pt.setIndex(0);const{inputType:xn}=W.nativeEvent;Be(xn==="insertFromPaste"||xn==="insertFromDrop"?((Bo=W0(Ve,Ht))==null?void 0:Bo.from)??null:null)},onKeyUp:W=>{me(),Vn(W.currentTarget.selectionStart??0)},onClick:W=>{Vn(W.currentTarget.selectionStart??0),Bi()},onPaste:V,onScroll:W=>{Bt.current&&(Bt.current.scrollTop=W.currentTarget.scrollTop)},onKeyDown:W=>{if(de(W),!W.nativeEvent.isComposing){if(B){if(W.key==="Escape"){W.preventDefault(),W.stopPropagation(),Be((ot==null?void 0:ot.from)??null);return}if(Pt.onKeyDown(W))return}if((W.key==="ArrowUp"||W.key==="ArrowDown")&&!W.altKey&&!W.ctrlKey){const Ve=W.key==="ArrowUp",Ht=I.at(-1);if(Ve&&!W.metaKey&&!U&&_===""&&h&&!m&&Ht!==void 0){W.preventDefault(),j1(p,c,h,I.length-1);return}const xn=W.metaKey?Ve?"first":"box":Ve?"up":"down",ar=h?v5(R,U??null,_,xn):null;if(ar){W.preventDefault(),(ar.walk!==U||ar.text!==_)&&bc(ar);return}}if(U&&W.key==="Escape"){W.preventDefault(),W.stopPropagation(),bc({walk:null,text:U.from});return}if(W.key==="Escape"&&Oe&&h&&!m){W.preventDefault(),W.stopPropagation(),c==null||c.send({t:"stop-agent",worktreeId:h});return}if(U&&E6.has(W.key)&&Bi(),W.key==="Tab"&&!W.shiftKey&&_===""&&(Nt!=null&&Nt.subject)){W.preventDefault(),u({a:"edit-commit"});return}W.key==="Enter"&&(A?W.metaKey||W.ctrlKey:!W.shiftKey)?(W.preventDefault(),gr()):W.key==="Backspace"&&_===""&&ri()&&W.preventDefault()}},placeholder:ei||Mn?"":Pi,disabled:!e&&!x}),Ut&&f.jsxs("div",{className:"composer-ghost","aria-hidden":"true",children:[f.jsx("span",{className:"picker-typed",children:_}),Ut]}),h&&tt===null&&_.includes("@")&&f.jsx("div",{ref:Bt,className:"composer-ghost composer-marks","aria-hidden":"true",onClick:W=>TE(W,e==null?void 0:e.worktree.path,h,{sock:c,dispatch:u}),children:f.jsx(NE,{text:_,worktreeId:h,root:e==null?void 0:e.worktree.path,inField:!0})}),(ei||Mn)&&f.jsxs("div",{className:"composer-ghost","aria-hidden":Mn?void 0:"true",children:[f.jsx("span",{className:He("composer-placeholder",Xs&&"live-text"),children:Li||(Mn?f.jsxs(f.Fragment,{children:[f.jsx(ze,{variant:"inline",tone:"strong",className:"composer-verb",disabled:!!Mn.ships&&!!H,...$t(Mn.tip,void 0,{placement:"top"}),onClick:Mn.run,children:Mn.word})," ",f.jsx("span",{className:"composer-verb-line",children:Mn.line})]}):Pi)}),ei&&f.jsxs(f.Fragment,{children:[`
235
+ `,f.jsx("span",{className:"composer-subline",children:ei})]})]}),xc&&f.jsx(At,{icon:"stop",tone:"danger",className:"composer-stop",label:`Stop the agent (context up to here is kept${I.length?"; queued messages go next":""})`,hint:"esc",onClick:()=>h&&(c==null?void 0:c.send({t:"stop-agent",worktreeId:h}))})]}),j&&f.jsx("div",{className:"hint composer-notice",role:"status",children:j}),!ue&&f.jsxs("div",{className:"hint composer-knobs",children:[f.jsxs("span",{className:"spawn-left",children:[pt?et.length>1?f.jsx(zE,{agents:et,agent:Ge,model:qe,onChange:Wt,onClose:vn}):f.jsx(sm,{models:qt,value:qe,onChange:J,onClose:vn}):e&&f.jsx(sm,{models:qt,value:e.worktree.model??"",current:Qt,onChange:W=>c==null?void 0:c.send({t:"set-worktree-model",worktreeId:e.worktree.id,model:W}),onClose:vn}),pt?f.jsx(om,{efforts:an,value:we,onChange:Xe,onClose:vn}):e&&f.jsx(om,{efforts:an,value:e.worktree.effort??"",current:ge,onChange:W=>c==null?void 0:c.send({t:"set-worktree-effort",worktreeId:e.worktree.id,effort:W}),onClose:vn}),We?f.jsx(Y0,{value:Rt,onChange:In,onClose:vn}):e&&f.jsx(Y0,{value:Dt,onChange:W=>c==null?void 0:c.send({t:"set-worktree-mode",worktreeId:e.worktree.id,mode:W}),onClose:vn}),Me&&!We&&h&&f.jsx(At,{icon:f.jsx(N5,{fraction:Me.used/Me.size}),tone:"chrome",label:`${Math.round(100*Me.used/Me.size)}% of context`,detail:`${r0(Me.used)} of ${r0(Me.size)}${Me.cost!==void 0?` · ${yc(Me.cost)} this session`:""}${Do?` · ${Do}`:""}`,onClick:W=>tn.openUnder(W.currentTarget,so),...tn.contextMenu(so)})]}),f.jsxs("span",{className:"spawn-tools",children:[y&&(e||x)&&f.jsx(At,{icon:"attach",tone:"chrome",label:l?"Attach a picture":"Attach a picture or a file",onClick:()=>fL(p,y,{images:l})}),!o&&!v&&!l&&f.jsx(At,{icon:"terminal",tone:"chrome",on:kt,className:"composer-term",disabled:!e,label:Gt?Gt.tip:"Terminal",hint:Et("terminal"),badge:Gt&&f.jsx("span",{className:"composer-term-dot"}),onClick:()=>{u(Gt&&!kt&&h?{a:"term-stream",id:h,stream:Gt.stream}:{a:"toggle-terminal"})},...tn.contextMenu(()=>e&&h?L3(e.procs,h,kt,{sock:c,dispatch:p.dispatch}):[])}),!o&&!$&&!v&&!l&&f.jsx(At,{icon:"pick",label:"Pick an element on the page to attach",hint:Et("pick"),on:gn==="chat",disabled:!X,onClick:()=>X&&tc(X,gn,u,"chat")}),A&&y&&(e||x)&&f.jsx(At,{icon:"send",tone:"primary",label:"Send",disabled:ht,onMouseDown:W=>W.preventDefault(),onClick:gr})]})]}),te&&Ie&&f.jsx("div",{className:"composer-notes",children:f.jsxs("div",{className:"hint composer-note",children:[f.jsx("span",{children:te}),GL(Ie)&&f.jsx(ze,{variant:"outline",busy:rt==="pull-main",disabled:!!rt,"data-tip":"Fast-forward main to origin",onClick:()=>Hs(c,u,{t:"pull-main",worktreeId:Ie.id}),children:"pull"})]})})]})}function sS({children:e,className:t,tip:n,...r}){return f.jsxs("label",{className:He("check",t),"data-tip":n,children:[f.jsx("input",{type:"checkbox",className:"check-box",...r}),f.jsx("span",{children:e})]})}const j6=[1,2,3];function C6({draft:e,lead:t}){const n=ct(),r=L(u=>Pa(u,t==null?void 0:t.repoId)),[o]=FE(r),a=L(u=>{var c;return((c=ja(u,t==null?void 0:t.repoId))==null?void 0:c.dirty)??0}),l=!e.batch&&e.variants===1;return f.jsxs("div",{className:"draft-intro",children:[f.jsxs("div",{className:"draft-row hint",children:[f.jsx(ze,{variant:"ghost",tone:"chrome",on:e.batch,"data-tip":"An agent splits the prompt into a worktree per task",onClick:()=>n({a:"draft-batch",v:!e.batch}),children:"batch"}),f.jsxs("span",{className:"draft-variants",children:[j6.map(u=>f.jsx(ze,{variant:"ghost",on:e.variants===u,disabled:e.batch,onClick:()=>n({a:"draft-variants",n:u}),children:u},u)),f.jsx("span",{"data-tip":"Run the same prompt in N parallel worktrees, keep the best",children:"variants"})]}),f.jsx("span",{className:"draft-runs",children:f.jsx(D5,{repo:r,value:e.profile??o,onChange:u=>n({a:"draft-profile",profile:u})})})]}),t&&r&&a>0&&f.jsx("div",{className:"draft-notes",children:f.jsxs(sS,{className:"hint draft-note",checked:Kx(e),disabled:!l,tip:l?`Move the ${a} uncommitted ${a===1?"file":"files"} into the new worktree, leaving ${r.defaultBranch} clean`:"One set of changes can only go into one worktree",onChange:u=>n({a:"draft-carry",v:u.currentTarget.checked}),children:[f.jsxs("span",{className:"badge-dirty",children:["~",a]})," on ",r.defaultBranch," come along"]})})]})}function A6({row:e}){const t=it(),n=L(l=>l.clientId),r=L(l=>l.home),o=r&&e.path.startsWith(`${r}/`)?`~${e.path.slice(r.length)}`:e.path,a=e.locked?"Toyon would be working in a directory something else is using, so taking it over waits for the lock to go.":"A message sent below takes over this branch.";return f.jsxs(Fs,{icon:e.locked?"lock":"branch",word:e.locked?"held":"discovered",tone:"quiet",below:f.jsx("div",{className:"daemon-below row-dim",children:a}),children:[f.jsxs("span",{className:"daemon-text",children:[e.locked&&`by ${e.lockReason??"another tool"}, at `,f.jsx("span",{className:"tool-hint",children:o})]}),!e.locked&&f.jsx(ze,{variant:"inline",tone:"strong",onClick:()=>t==null?void 0:t.send({t:"adopt-worktree",worktreeId:e.id,clientId:n}),children:"take over"})]})}function Zl({placement:e,className:t,width:n,archived:r,found:o}){const a=ct(),l=gs(),u=eM(),c=Ot(l==null?void 0:l.worktree.id,"sending"),p=za(),m=e==="centre"&&!r&&(p!=null&&p.assumed)?p:null,h=L(v=>{var x;return((x=v.dragFiles)==null?void 0:x.at)==="chat"}),k=Bn(),y=S.useMemo(()=>lL(k),[k]);return f.jsxs("div",{className:He(e==="dock"?"chat-dock":e==="centre"?"chat-centre":"chat-screen",t,h&&"drop-over"),style:n===void 0?void 0:{width:n},...y,ref:v=>{var x;v?Hl.el=v:(x=Hl.el)!=null&&x.isConnected||(Hl.el=null)},children:[r?f.jsx(ch,{active:null,archived:r,tail:f.jsx(NP,{item:r})}):o?f.jsx(ch,{active:null,found:o,tail:f.jsx(A6,{row:o})}):f.jsx(ch,{active:l,lead:m&&f.jsxs("p",{className:"hint chat-centre-note",children:[m.name," has ",f.jsx("code",{children:m.assumed})," and no dev server, so it is chat only for now."," ",f.jsx(ze,{variant:"inline",onClick:()=>a({a:"open",overlay:{kind:"setup",repoId:m.id}}),children:"add a dev server"})]})}),!r&&!o&&u&&!c&&f.jsx(C6,{draft:u,lead:l}),r?f.jsx(Qu,{active:null,archived:r,placement:e}):o?f.jsx(Qu,{active:null,found:o,placement:e}):f.jsx(Qu,{active:l,draft:u,placement:e})]})}const I6="modulepreload",R6=function(e){return"/"+e},tb={},cm=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let l=function(p){return Promise.all(p.map(m=>Promise.resolve(m).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),c=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));o=l(n.map(p=>{if(p=R6(p),p in tb)return;tb[p]=!0;const m=p.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${h}`))return;const k=document.createElement("link");if(k.rel=m?"stylesheet":I6,m||(k.as="script"),k.crossOrigin="",k.href=p,c&&k.setAttribute("nonce",c),document.head.appendChild(k),m)return new Promise((y,v)=>{k.addEventListener("load",y),k.addEventListener("error",()=>v(Error(`Unable to preload CSS for ${p}`)))})}))}function a(l){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=l,window.dispatchEvent(u),!u.defaultPrevented)throw l}return o.then(l=>{for(const u of l||[])u.status==="rejected"&&a(u.reason);return t().catch(a)})},Fg=800;function O6(e,t,n,r){if(r.version===e.version)return"same";const o=t===e.text&&n===null;return r.version===null?o?"gone":"conflict":r.after===t||r.after===n?"adopt":o?"apply":"conflict"}const Co=e=>`${e.worktreeId}
236
+ ${e.ref??""}
237
+ ${e.since??""}
238
+ ${e.path}`;class $6{constructor(t){jt(this,"files",new Map);jt(this,"looks",new Map);this.d=t}start(){var a,l;let t=this.d.store.getState();const n=this.d.store.subscribe(()=>{const u=this.d.store.getState(),c=t;t=u,this.follow(c,u)}),r=()=>{const u=this.d.store.getState().editor;u&&!u.loose&&this.refresh(Co(u))};(a=this.d.win)==null||a.addEventListener("focus",r);const o=()=>{for(const[u,c]of this.files)c.timer!==void 0&&this.saveNow(u)};return(l=this.d.win)==null||l.addEventListener("pagehide",o),()=>{var u,c;n(),(u=this.d.win)==null||u.removeEventListener("focus",r),(c=this.d.win)==null||c.removeEventListener("pagehide",o)}}receive(t){const n=t.t==="file-read"?this.looks.get(t.seq):void 0;if(n&&t.t==="file-read"){this.looks.delete(t.seq),n(t.error||t.binary||t.tooLarge||t.version===null?null:t.after);return}const r=this.files.get(Co(t));if(!r)return;if(t.t==="file-blame"){this.blamed(r,t);return}const o=r.out;!o||o.seq!==t.seq||(r.out=null,t.t==="file-read"?this.read(r,t):o.write!==void 0&&this.written(r,o.write,t),this.next(r))}look(t,n){if(!this.d.store.getState().connected)return Promise.resolve(null);const r=$o();return new Promise(o=>{this.looks.set(r,o),this.d.send({t:"read-file",worktreeId:t,path:n,seq:r})})}bind(t){const n=Co(t);return{attach:r=>this.attach(n,r),edited:()=>this.edited(n),saveNow:()=>this.saveNow(n)}}reload(t){var o;const n=this.files.get(Co(t)),r=n==null?void 0:n.conflict;!n||!r||(this.cancelTimer(n),n.pending=null,n.base={text:r.after,version:r.version},this.setConflict(n,null),r.version===null?this.d.store.dispatch({a:"close-editor"}):(o=n.buffer)==null||o.replace(r.after),this.next(n))}keepMine(t){const n=this.files.get(Co(t)),r=n==null?void 0:n.conflict;!(n!=null&&n.buffer)||!r||(n.base={text:r.after,version:r.version},this.setConflict(n,null),n.pending=n.buffer.text(),this.next(n))}follow(t,n){var a,l;t.connected&&!n.connected&&this.dropped();const r=(a=n.editor)!=null&&a.loose?null:n.editor,o=(l=t.editor)!=null&&l.loose?null:t.editor;if(o&&(!r||Co(o)!==Co(r))&&this.closed(Co(o)),r&&(!o||o.seq!==r.seq)&&this.opened(r),!t.connected&&n.connected)for(const u of this.files.values())u.reread=!0,this.next(u);else r&&o&&o.seq===r.seq&&go(t,r.worktreeId).git!==go(n,r.worktreeId).git&&this.refresh(Co(r))}opened(t){const n=Co(t);let r=this.files.get(n);r||(r={file:{worktreeId:t.worktreeId,path:t.path,...t.ref?{ref:t.ref}:{},...t.since?{since:t.since}:{}},open:!0,base:null,out:null,pending:null,reread:!1,writable:!1,conflict:null,buffer:null,timer:void 0,blame:null},this.files.set(n,r)),r.open=!0,r.reread=!0,r.conflict&&this.d.store.dispatch({a:"editor-conflict",file:r.file,theirs:r.conflict}),this.next(r)}closed(t){const n=this.files.get(t);n&&(n.open=!1,this.next(n))}refresh(t){const n=this.files.get(t);!n||n.file.ref||(n.reread=!0,this.next(n))}dropped(){for(const t of this.looks.values())t(null);this.looks.clear();for(const t of this.files.values())t.out&&(t.out.write!==void 0&&(t.pending??(t.pending=t.out.write)),t.out=null,t.reread=!0)}next(t){var l;if(t.out||!this.d.store.getState().connected)return;const{worktreeId:n,path:r,ref:o,since:a}=t.file;if(t.reread){t.reread=!1;const u=$o();t.out={seq:u},this.d.send({t:"read-file",worktreeId:n,path:r,ref:o,since:a,seq:u});return}if(t.pending!==null&&t.base&&t.pending===t.base.text&&(t.pending=null),t.pending!==null&&t.writable&&!t.conflict&&!o){const u=t.pending,c=$o();t.pending=null,t.out={seq:c,write:u},this.d.send({t:"write-file",worktreeId:n,path:r,content:u,base:((l=t.base)==null?void 0:l.version)??null,seq:c});return}!t.open&&!t.buffer&&t.pending===null&&!t.conflict&&this.files.delete(Co(t.file))}read(t,n){var k,y;const{file:r}=t;if(n.error){t.open&&this.d.store.dispatch({a:"editor-read",file:r,disk:null,error:n.error});return}const{before:o,after:a,version:l,writable:u,binary:c,tooLarge:p}=n;t.writable=u,t.open&&(this.d.store.dispatch({a:"editor-read",file:r,disk:{before:o,after:a,version:l,writable:u,binary:c,tooLarge:p}}),!c&&!p&&(l!==null||r.ref)&&this.askBlame(t,l));const m={after:t.buffer?t.buffer.normalize(a):a,version:l};if(!t.base){t.base={text:m.after,version:l};return}const h=((k=t.buffer)==null?void 0:k.text())??t.pending??t.base.text;switch(O6(t.base,h,t.pending,m)){case"same":break;case"adopt":t.base={text:m.after,version:l};break;case"apply":(y=t.buffer)==null||y.replace(m.after),t.base={text:m.after,version:l};break;case"gone":t.base={text:"",version:null},t.open&&this.d.store.dispatch({a:"close-editor"});break;case"conflict":this.setConflict(t,m);return}this.setConflict(t,null)}askBlame(t,n){const r=$o();t.blame={seq:r,version:n};const{worktreeId:o,path:a,ref:l}=t.file;this.d.send({t:"blame-file",worktreeId:o,path:a,ref:l,seq:r})}blamed(t,n){const r=t.blame;if(!r||r.seq!==n.seq||(t.blame=null,!t.open))return;const{commits:o,lines:a}=n;this.d.store.dispatch({a:"editor-blame",file:t.file,blame:{commits:o,lines:a,version:r.version}})}written(t,n,r){if(r.ok){t.base={text:n,version:r.version};return}if(r.reason==="changed"){t.pending??(t.pending=n),t.reread=!0;return}t.writable=!1,t.pending=null,this.d.store.dispatch({a:"editor-refused",file:t.file,message:r.message??`not saved: ${t.file.path}`})}setConflict(t,n){t.conflict===n||t.conflict&&n&&t.conflict.version===n.version||(t.conflict=n,t.open&&this.d.store.dispatch({a:"editor-conflict",file:t.file,theirs:n}))}attach(t,n){const r=this.files.get(t);if(r){if(n){r.buffer=n,r.base&&(r.base={...r.base,text:n.normalize(r.base.text)}),r.conflict&&r.pending!==null&&n.replace(r.pending);return}r.buffer&&((r.timer!==void 0||r.conflict)&&(r.pending=r.buffer.text()),this.cancelTimer(r),r.buffer=null,this.next(r))}}edited(t){const n=this.files.get(t);!(n!=null&&n.buffer)||!n.writable||n.file.ref||(this.cancelTimer(n),n.timer=this.d.timers.set(()=>{n.timer=void 0,this.saveNow(t)},Fg))}saveNow(t){const n=this.files.get(t);if(!(n!=null&&n.buffer))return;this.cancelTimer(n);const r=n.buffer.text();r.length>id||(n.pending=r,this.next(n))}cancelTimer(t){t.timer!==void 0&&(this.d.timers.clear(t.timer),t.timer=void 0)}}const iS={attach:()=>{},edited:()=>{},saveNow:()=>{}},M6=e=>({timers:{set:(t,n)=>setTimeout(t,n),clear:t=>clearTimeout(t)},win:typeof window>"u"?null:window,send:e}),um=new Map;function L6(e){const t=um.get(e.seq);return t?(um.delete(e.seq),t(e),!0):!1}function P6(e,t,n,r){if(e.kind==="bytes")return iS;if(e.kind==="grant")return D6(e,t,n,r);const o=e.handle;let a=null,l,u=null,c=Promise.resolve(),p=!1;const m=()=>(u??(u=(async()=>await o.queryPermission({mode:"readwrite"})==="granted"?!0:await o.requestPermission({mode:"readwrite"})==="granted")().catch(()=>!1)),u),h=()=>{l!==void 0&&r.timers.clear(l),l=void 0},k=()=>{p||(p=!0,h(),n(`read-only: the browser would not save ${t}`))},y=async _=>{if(!await m())return k();const N=await o.createWritable();await N.write(_),await N.close()},v=()=>{if(!a||p)return;h();const _=a.text();c=c.then(()=>y(_)).catch(k)},x=()=>{l!==void 0&&v()};return{attach(_){var N,j;if(_){a=_,(N=r.win)==null||N.addEventListener("pagehide",x);return}l!==void 0&&v(),a=null,(j=r.win)==null||j.removeEventListener("pagehide",x)},edited(){!a||p||(m().then(_=>{_||k()}),h(),l=r.timers.set(v,Fg))},saveNow:v}}function D6(e,t,n,r){let o=null,a,l=e.version,u=!1,c=null,p=!1;const m=()=>{a!==void 0&&r.timers.clear(a),a=void 0},h=x=>{p||(p=!0,m(),c=null,n(x))},k=x=>{if(!r.send)return;const _=$o();u=!0,um.set(_,N=>{if(u=!1,N.ok?l=N.version:N.reason==="changed"?h(`read-only: ${t} changed on disk; open it again to edit`):h(N.message??`not saved: ${t}`),c!==null&&!p){const j=c;c=null,k(j)}}),r.send({t:"write-loose",id:e.id,content:x,base:l,seq:_})},y=()=>{if(!o||p)return;m();const x=o.text();x.length>id||(u?c=x:k(x))},v=()=>{a!==void 0&&y()};return{attach(x){var _,N;if(x){o=x,(_=r.win)==null||_.addEventListener("pagehide",v);return}a!==void 0&&y(),o=null,(N=r.win)==null||N.removeEventListener("pagehide",v)},edited(){!o||p||(m(),a=r.timers.set(y,Fg))},saveNow:y}}let dm=!1;function z6(){dm=!0}function Ed({title:e,body:t,action:n,pane:r,children:o}){return f.jsxs("div",{className:He("crash",r&&"in-pane"),children:[f.jsx("div",{className:"crash-title",children:e}),t&&f.jsx("div",{className:"crash-body",children:t}),o,n]})}const nb={title:"Toyon was updated",body:"This page is still running the old build. Reload to pick up the new one."};class Bg extends S.Component{constructor(){super(...arguments);jt(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("[toyon] render error",n,r.componentStack)}render(){const{error:n}=this.state;return n?f.jsx(Ed,{pane:this.props.pane,title:dm?nb.title:"Toyon hit an error",body:dm?nb.body:n.message||String(n),action:f.jsx(ze,{variant:"outline",onClick:()=>window.location.reload(),children:"reload"})}):this.props.children}}function Ug({kind:e,className:t,height:n,resizable:r=!0,onDragStart:o,title:a,tabs:l,actions:u,menu:c,full:p,onToggleFull:m,onClose:h,closeHint:k="esc",children:y}){const v=sn("pane"),x=m&&f.jsxs(ze,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:m,"data-tip":p?"Split view: show the preview above":"Full height: hide the preview",children:[f.jsx(St,{name:p?"split":"full",className:"icon-inline"})," ",p?"split":"full"]}),_=f.jsx(At,{icon:"close",label:"Close",hint:k,onClick:h});return f.jsxs("div",{className:`pane ${t}`,"data-pane":e,tabIndex:-1,style:n===void 0?void 0:{height:n},children:[r&&f.jsx("div",{className:"pane-resize",onPointerDown:o}),f.jsx("div",{className:He("pane-head",l&&"pane-head-tabs"),...v.contextMenu(()=>(c==null?void 0:c())??[]),children:l?f.jsx(Xd,{...l,end:f.jsxs(f.Fragment,{children:[u,x,_]})}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"pane-title",children:a}),u,x,_]})}),y]})}function F6({src:e,path:t,full:n,onFull:r}){const o=sn("editor");return f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",className:"editor-image",onClick:()=>r(!0),...o.contextMenu(()=>rc(e,{open:()=>r(!0)})),children:f.jsx("img",{src:e,alt:t})}),n&&f.jsx(pg,{owner:"editor",onClose:()=>r(!1),menu:()=>rc(e),children:f.jsx("img",{src:e,alt:t})})]})}const B6={image:F6};function U6({kind:e,src:t,path:n,openSeq:r,focus:o,full:a,onFull:l}){const u=S.useRef(null);gt([r],()=>{var p;o&&((p=u.current)==null||p.focus())});const c=B6[e];return f.jsx("div",{ref:u,className:"editor-viewer",tabIndex:-1,children:f.jsx(c,{src:t,path:n,full:a,onFull:l})})}const H6="img[src], source[src], video[src], audio[src], video[poster], link[href], object[data]";function W6(e,t){if(!t)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=!1;for(const o of n.querySelectorAll(H6))for(const a of["src","href","poster","data"]){const l=o.getAttribute(a),u=l===null?null:xg(t.dir,l);u&&(o.setAttribute(a,tg(t.worktreeId,u,t.version)),r=!0)}return r?`${n.doctype?`<!doctype html>
239
+ `:""}${n.documentElement.outerHTML}`:e}function K6({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:a}){const l=S.useRef(null);gt([o],()=>{var p;a&&((p=l.current)==null||p.focus())});const u=L_(t),c=S.useMemo(()=>W6(e,r===void 0?null:{worktreeId:n,dir:u,version:r}),[e,n,u,r]);return f.jsx("div",{ref:l,className:"editor-viewer",tabIndex:-1,children:f.jsx("iframe",{className:"editor-frame",title:t,sandbox:"",srcDoc:c})})}function Z6(e){const t=[];return e.map(n=>{for(;t.length&&t[t.length-1]>=n;)t.pop();if(n===1)return 0;const r=t.length;return t.push(n),r})}function q6(e){const t=new Map,n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=Z6(n.map(o=>Number(o.tagName[1])));return n.map((o,a)=>{var c;const l=((c=o.textContent)==null?void 0:c.trim())??"",u=t.get(l)??0;return t.set(l,u+1),{id:`${u}
240
+ ${l}`,level:Number(o.tagName[1]),depth:r[a],text:l,el:o}})}const G6=48,V6=16;function Y6({text:e,path:t,worktreeId:n,version:r,openSeq:o,focus:a,onChat:l}){it();const u=ct(),c=L_(t),p=Sg(e,r===void 0?void 0:{base:{worktreeId:n,dir:c,version:r}}),m=S.useRef(null),h=S.useRef(null),[k,y]=S.useState([]),[v,x]=S.useState(-1),[_,N]=S.useState(null),j=U=>{var R;if(N(null),U){const I=window.getSelection();I==null||I.removeAllRanges(),I==null||I.addRange(U)}(R=m.current)==null||R.focus()};gt([o],()=>{var U;a&&((U=m.current)==null||U.focus())}),gt([p],()=>{m.current&&y(q6(m.current))}),S.useLayoutEffect(()=>{const U=m.current;if(!U)return;let R=0;const I=()=>{if(R=0,U.scrollTop+U.clientHeight>=U.scrollHeight-1){x(k.length-1);return}const P=U.scrollTop+G6;let z=-1;for(let q=0;q<k.length;q++)k[q].el.offsetTop<=P&&(z=q);x(z)},C=()=>{R||(R=requestAnimationFrame(I))};return I(),U.addEventListener("scroll",C),()=>{U.removeEventListener("scroll",C),R&&cancelAnimationFrame(R)}},[k]);const E=U=>{var I,C;const R=(I=k[U])==null?void 0:I.el;(C=m.current)==null||C.scrollTo({top:Math.max(0,R?R.offsetTop-V6:0),behavior:"smooth"})},M=U=>{const R=U.target.closest("a"),I=R==null?void 0:R.getAttribute("href");if(!I||(R==null?void 0:R.target)==="_blank")return;U.preventDefault();const C=xg(c,I);C&&nr({dispatch:u},{worktreeId:n,path:C,view:Ai(C)})},K=U=>{var R;if(fg(U)){U.preventDefault(),U.stopPropagation();const I=(h.current&&Kh(h.current))??"";N(C=>({seed:I||(C==null?void 0:C.seed)||"",seq:((C==null?void 0:C.seq)??0)+1}));return}if(U.key==="Escape"&&_){U.stopPropagation(),j(null);return}if(g_(U)&&h.current){U.preventDefault(),y_(h.current);return}if(((R=jb(U))==null?void 0:R.id)==="composer"&&h.current){const I=Kh(h.current);if(!I)return;U.preventDefault(),U.stopPropagation(),l(I)}};return f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:m,className:"editor-viewer editor-preview",tabIndex:-1,onClick:M,onKeyDown:K,children:f.jsx("div",{ref:h,className:"md md-preview",dangerouslySetInnerHTML:{__html:p}})}),_&&f.jsx(m_,{root:m,body:h,seed:_.seed,seq:_.seq,onClose:j}),f.jsx(Q6,{heads:k,at:v,onJump:E})]})}function Q6({heads:e,at:t,onJump:n}){const[r,o]=S.useState(!1),a=S.useRef(null);return e.length<2?null:f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:a,className:"editor-outline","aria-hidden":!0,onPointerEnter:l=>{l.pointerType==="mouse"&&o(!0)},onClick:()=>o(l=>!l),children:e.map((l,u)=>f.jsx("span",{className:"editor-outline-tick","data-level":l.level,"data-state":rr({current:u===t})},l.id))}),r&&f.jsx(Ys,{className:"editor-outline-list",anchor:()=>{var l;return((l=a.current)==null?void 0:l.getBoundingClientRect())??null},placement:{side:"right",align:"center",cover:!0},trigger:a.current,onDismiss:()=>o(!1),onPointerLeave:l=>{l.pointerType==="mouse"&&o(!1)},children:e.map((l,u)=>f.jsx("button",{type:"button",className:"row editor-outline-row","data-level":l.level,"data-state":rr({current:u===t}),onClick:()=>n(u),children:f.jsx("span",{className:"editor-outline-label",style:{"--outline-depth":l.depth},children:l.text})},l.id))})]})}function X6({absPath:e,onReveal:t}){const n=sn("editor");return eg(location.hostname)?f.jsxs(ze,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",...n.dropdown(()=>Ii(e,t),"right"),children:["open in ",f.jsx(St,{name:"caret",className:"icon-inline"})]}):null}const J6=S.lazy(async()=>{const[e]=await Promise.all([cm(()=>import("./Editor-DL0q1Bu5.js").then(t=>t.E),__vite__mapDeps([0,1,2])),cm(()=>import("./grammar-CPvdB3az.js"),[]).then(t=>t.grammarsReady)]);return e});function rb({what:e}){return i1(!0,3e3)?f.jsx("div",{className:"empty",children:f.jsxs("span",{className:"live-text",children:["loading ",e]})}):null}const e8=()=>{},t8={diff:"diff",file:"text",preview:"book"};function n8(e,t){return e==="diff"?"Diff view: show what changed":e==="preview"?"Preview: read it rendered":t==="diff"?"File view: hide the diff":"File view: edit the text"}function aS({editor:e,height:t,full:n=!1,onToggleFull:r,onDragStart:o,placement:a="stack"}){const l=a==="screen",u=ct(),c=Bn(),p=it(),m=s1(),h=Hd(),{worktreeId:k,path:y,ref:v,since:x}=e,_=e.loose,N=L(oe=>{var A;return((A=ko(oe))==null?void 0:A.id)===k}),j=L(oe=>{var X,Z;const A=(X=fn(oe,k))==null?void 0:X.worktree;return A?A.path:(Z=ko(oe))==null?void 0:Z.path}),E=_?_.source.kind==="grant"?_.source.path:null:j?`${j}/${y}`:y,M=v!==void 0,K=S.useMemo(()=>_?P6(_.source,y,oe=>u({a:"editor-refused",file:{worktreeId:k,path:y},message:oe}),M6(p?oe=>p.send(oe):null)):(m==null?void 0:m.bind({worktreeId:k,path:y,...v?{ref:v}:{},...x?{since:x}:{}}))??iS,[m,k,y,v,x,_,u,p]),U=L(oe=>go(oe,k).changedRanges[y]);S.useEffect(()=>{!U&&!M&&!N&&!_&&(p==null||p.send({t:"changed-ranges",worktreeId:k,path:y}))},[k,y,U,M,N,_,p]);const R=(U==null?void 0:U.offset)??0,I=e.disk,C=e.view??"diff",P=(I==null?void 0:I.before)==="",z=x1(y,P).filter(oe=>oe!==C&&!(_&&oe==="diff")),q=(_==null?void 0:_.source.kind)==="grant"?_.source:null,se=M||N||_&&!q?null:T$(y),[pe,ue]=S.useState(!1),xe=e.line&&!e.line.fiber?e.line.n:void 0;return f.jsxs(Ug,{kind:"editor",className:He("editor-pane",n&&"full"),height:n||l?void 0:t,resizable:!n&&!l,onDragStart:o??e8,title:M?`${y} at ${v==null?void 0:v.slice(0,7)}`:x?`${y}, last turn`:y,menu:()=>j&&!_?fs({id:k,dir:j},y,{discard:!M&&!N,kept:N,ref:v,showing:e.view??void 0,added:P},{sock:p,dispatch:u}):[],onClose:()=>u({a:"close-editor"}),full:n,onToggleFull:l?void 0:r,actions:f.jsxs(f.Fragment,{children:[!se&&z.map(oe=>f.jsxs(ze,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>u({a:"editor-view",v:oe}),"data-tip":n8(oe,C),children:[f.jsx(St,{name:t8[oe],className:"icon-inline"})," ",oe]},oe)),se==="image"&&f.jsxs(ze,{variant:"outline",tone:"quiet",mono:!0,className:"deep-link",onClick:()=>ue(!0),"data-tip":"Full size: see the picture over the window",children:[f.jsx(St,{name:"zen",className:"icon-inline"})," full size"]}),!N&&E!==null&&f.jsx(X6,{absPath:E,onReveal:_?void 0:()=>p==null?void 0:p.send({t:"reveal",worktreeId:k,path:y})})]}),children:[I&&f.jsx(r8,{editor:e,disk:I,files:m}),f.jsx("div",{className:"editor-body",children:I?se?f.jsx(U6,{kind:se,src:q?AM(q.id,q.version):tg(k,y,I.version),path:y,openSeq:e.seq,focus:e.focus,full:pe,onFull:ue}):I.binary?f.jsx("div",{className:"empty",children:"not a text file: open it in another editor"}):I.tooLarge?f.jsx("div",{className:"empty",children:"too large to open here: open it in another editor"}):C==="preview"&&Fd(y)==="html"?f.jsx(K6,{text:I.after,path:y,worktreeId:k,version:M||N||_?void 0:I.version,openSeq:e.seq,focus:e.focus}):C==="preview"?f.jsx(Y6,{text:I.after,path:y,worktreeId:k,version:M||N||_?void 0:I.version,openSeq:e.seq,focus:e.focus,onChat:oe=>$v(c,{worktreeId:k,text:oe,name:y})}):f.jsx(Bg,{pane:!0,children:f.jsx(S.Suspense,{fallback:f.jsx(rb,{what:C}),children:f.jsx(J6,{file:{worktreeId:k,path:y,...v?{ref:v}:{},...x?{since:x}:{}},disk:I,blame:e.blame,view:C,openSeq:e.seq,line:xe,focus:e.focus,readOnly:M||!I.writable||l,numbers:!l,theme:h,sync:K,onCopy:_?void 0:(oe,A,X)=>fM(X,{worktreeId:k,path:oe,...A,...v?{ref:v}:{}}),onChat:(oe,A)=>$v(c,A&&(_?{worktreeId:k,text:A.text,name:oe}:{worktreeId:k,text:A.text,source:{path:oe,startLine:A.startLine,endLine:A.endLine,...v?{ref:v}:{}}})),onNew:()=>c.dispatch({a:"open-draft"}),onLineHover:M||_?void 0:oe=>{oe==null?Yt.post(k,{type:"highlight-clear"}):Yt.post(k,{type:"highlight-file",path:y,ranges:[[oe+R,oe+R]]})}},`${k}
241
+ ${_?"loose":v??x??""}
242
+ ${y}`)})}):f.jsx(rb,{what:y},y)})]})}function r8({editor:e,disk:t,files:n}){const{worktreeId:r,path:o,ref:a,since:l,conflict:u}=e,c={worktreeId:r,path:o,...a?{ref:a}:{},...l?{since:l}:{}};if(u){const p=u.version===null;return f.jsxs("div",{className:"editor-note",children:[f.jsx("span",{className:"editor-note-text",children:p?"deleted on disk; your edits are not saved":"changed on disk; your edits are not saved"}),f.jsx(ze,{variant:"outline",onClick:()=>n==null?void 0:n.reload(c),"data-tip":p?"Close the file; your edits go with it":"Take the file as it is on disk; undo brings your edits back",children:p?"close":"reload"}),f.jsx(ze,{variant:"outline",tone:"danger",onClick:()=>n==null?void 0:n.keepMine(c),"data-tip":p?"Save your edits as the file again":"Save your edits over the file on disk",children:"keep mine"})]})}return e.refused?f.jsx("div",{className:"editor-note",children:f.jsx("span",{className:"hint",children:e.refused})}):e.loose&&!t.writable&&!t.tooLarge&&!t.binary?f.jsx("div",{className:"editor-note",children:f.jsxs("span",{className:"hint",children:["read-only: ",o," is not in a project; drop it on a folder in files to add it"]})}):a===void 0&&!t.writable&&!t.binary&&!t.tooLarge?f.jsx("div",{className:"editor-note",children:f.jsx("span",{className:"hint",children:"read-only: Toyon does not run this worktree"})}):null}function Hg(e,{sock:t}){var r;const n=[];return e.canLogout&&((r=e.auth)==null?void 0:r.kind)!=="none"&&n.push({id:"logout",label:"log out",danger:!0,onClick:()=>t==null?void 0:t.send({t:"agent-logout",agent:e.id})}),!e.available&&!e.installing&&n.push({id:"install",label:e.onDemand&&e.reason==="not installed"?"install":"install again",onClick:()=>t==null?void 0:t.send({t:"install-agent",agent:e.id})}),n}function lS(e,t,n=!1){var o;const r=((o=t.find(a=>a.id===(e==null?void 0:e.repoId)))==null?void 0:o.defaultBranch)??"the default branch";return e!=null&&e.building?{text:`Rebuilding Toyon from ${r}`,busy:!0}:e!=null&&e.buildFailed?{text:"Rebuilding Toyon stopped",detail:e.buildFailed,build:"try again",busy:!1}:e!=null&&e.rebuild?{text:`Toyon's shell is behind ${r}`,build:"rebuild",busy:!1}:e!=null&&e.restart?{text:n?`Toyon itself is behind ${r}; this page reloads once it has restarted`:`Toyon itself is behind ${r}`,restart:!0,busy:!1}:n?{text:"Toyon's shell was rebuilt while this page was open",reload:!0,busy:!1}:null}const cS=e=>`Toyon restarts once ${e.join(", ")} ${e.length===1?"finishes":"finish"}`,o8=(e,t)=>[...e,...t.filter(n=>!e.includes(n))];function s8(e,t,n){const r=[...t];return[...e.map(a=>{const l=r.indexOf(a);return l===-1?{name:a,dot:"idle",note:"finished"}:(r.splice(l,1),{name:a,dot:"working",note:null})}),...n.map(a=>({name:a,dot:"waiting",note:"asking you"}))]}function i8(e,t){return`${e>=t?`Toyon restarts once ${e===1?"this chat finishes its reply":`these ${e} chats finish their replies`}`:`${t-e} of ${t} chats have finished; Toyon restarts after the ${e===1?"last one":`other ${e}`}`}, and this page reloads when it is back. Restarting now stops ${e===1?"it":"them"} mid-reply.`}function a8(e){if(!e)return null;if(e.restarting&&e.restarting.length>0){const t=e.restarting.length;return{word:t===1?"restarts after a reply":`restarts after ${t} replies`,text:cS(e.restarting),retry:!1,busy:!0}}if(e.failed){const t=e.failed.line.replace(/\.$/,"");return{word:"update failed",text:`Installing Toyon ${e.failed.version} stopped: ${t}. To update by hand, run ${e.failed.command}`,retry:!0,busy:!1}}return null}const l8=(e,t)=>{const n=Ah(t);switch(e){case"npm":case"bun":return`installed with ${e}. A newer version from ${n} installs itself when nothing is busy; press to check now and install one if it is out`;case"npx":return`run with npx, which fetches the newest version from ${n} itself. Press to check for one now`;case"none":return"run from a checkout, which does not update itself. Press to check for a newer release"}},Sd="https://github.com/toyon-dev/toyon",c8=e=>`${Sd}/releases/tag/v${e}`,u8=`${Sd}/releases/latest`,d8=4e3;function f8(e,t,n,r){if(r==="asking")return{value:`${e} checking`,text:`Asking ${Ah(n)} for the newest version`,act:"check",busy:!0};const o=Ah(r.registry),a={act:"check",busy:!1};if(r.latest===null)return{...a,value:`${e} no answer`,text:`Could not reach ${o}. Press to ask again`,settles:!0};if(S$(r.latest,e)){const l=t==="none"?"This copy runs from a checkout, so pull to get it":t==="npx"?`This copy runs with npx, so run npx toyon@${r.latest} to use it`:"It installs once no chat is replying";return{...a,value:`${r.latest} out`,text:`Toyon ${r.latest} is out. ${l}`}}return{...a,value:`${e} up to date`,text:`Toyon ${e} is the newest version ${o} lists. Press to ask again`,settles:!0}}function p8(e,t,n,r,o,a=!1,l=null,u=null){if(n){if(n.restarting){const p=n.installed??n.running,m=n.restarting.length>0?cS(n.restarting):"Toyon is restarting; this page reloads when it is back";return{value:`${p} restarting`,text:m,act:"restart",busy:!0}}if(n.installing){const p=n.latest??n.installed??n.running;return{value:`${p} installing`,text:`Installing Toyon ${p}`,act:"update",busy:!0}}if(n.failed){const p=n.failed.line.replace(/\.$/,"");return{value:`${n.running} update failed`,text:`Installing Toyon ${n.failed.version} stopped: ${p}. Press to try again, or run ${n.failed.command}`,act:"update",busy:!1}}if(n.installed)return{value:`${n.installed} ready`,text:`Toyon ${n.installed} is installed and ${n.running} is still running. It restarts onto the new one when nothing is busy; press to restart now`,act:"restart",busy:!1};if(n.latest)return{value:`${n.latest} out`,text:n.method==="npx"?`Toyon ${n.latest} is out. This copy runs with npx, so run npx toyon@${n.latest} to use it`:`Toyon ${n.latest} is out and installs when nothing is busy; press to install now`,act:"update",busy:!1}}const c=lS(r,o,a);return c?c.busy?{value:`${e} rebuilding`,text:c.text,act:"rebuild",busy:!0}:c.reload?{value:`${e} rebuilt`,text:c.text,act:"reload",busy:!1}:c.build==="try again"?{value:`${e} rebuild stopped`,text:c.text,detail:c.detail,act:"rebuild",busy:!1}:{value:`${e} behind`,text:c.text,act:c.build?"rebuild":"restart",busy:!1}:u?f8(e,t,l,u):{value:e,text:`Toyon ${e}, ${l8(t,l)}`,act:"check",busy:!1}}function h8(e,t){const n=r=>()=>window.open(r,"_blank");return Dn([t?[{id:"check-update",label:"check for updates",...t.off?{disabled:t.off}:{},onClick:t.run}]:[],[{id:"release-notes",label:`release notes for ${e}`,onClick:n(c8(e))},{id:"latest-release",label:"latest release",onClick:n(u8)},{id:"repo",label:"Toyon on GitHub",onClick:n(Sd)},{id:"report",label:"report a problem",onClick:n(`${Sd}/issues/new`)}],[{id:"copy-version",label:"copy version",onClick:()=>Zt(e)}]])}const m8=bT.map(e=>({title:e,rows:ET(e).map(t=>[Et(t),Pl[t].label])}));function g8(){const e=ct(),t=it(),n=sn("keys"),r=L(h=>h.themePrefs),o=L(h=>h.themes),a=L(h=>h.chatSide),l=L(h=>h.keepAwake),u=qm(),c=L(h=>h.agents),p=za(),m=h=>{e({a:"palette-return",v:{mode:"keys",q:""}}),e(h)};return f.jsxs(sf,{bare:!0,boxClass:"keys-stack",id:"keys-help",onClose:()=>e({a:"close"}),children:[f.jsxs("div",{className:"keys-card",children:[f.jsxs("div",{children:[p&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"section-title keys-h",children:p.name}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"processes"}),f.jsx(ze,{variant:"field",mono:!0,className:"keys-chip","data-tip":`edit the install + start commands in ${p.configFile}`,onClick:()=>e({a:"open",overlay:{kind:"setup",repoId:p.id}}),...n.contextMenu(()=>rf(p,p.id,{sock:t,dispatch:e})),children:f.jsx("span",{className:"keys-v",children:Object.keys(p.config.run).join(" + ")||"not set up"})})]})]}),f.jsx("div",{className:"section-title keys-h",children:"Agents"}),c.map(h=>f.jsx(w8,{agent:h},h.id))]}),f.jsxs("div",{children:[f.jsx("div",{className:"section-title keys-h",children:"Appearance"}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"mode"}),f.jsx(ze,{variant:"field",mono:!0,onClick:()=>m({a:"open",overlay:{kind:"appearance"}}),children:vd[r.mode]})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"theme"}),f.jsx(ze,{variant:"field",mono:!0,onClick:()=>m({a:"open",overlay:{kind:"theme",slot:"theme"}}),children:zd(r,o,u).name})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"chat side"}),f.jsx(ze,{variant:"field",mono:!0,onClick:()=>e({a:"toggle-chat-side"}),children:a})]}),f.jsx("div",{className:"section-title keys-h",children:"Toyon"}),l!==null&&f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"keep the Mac awake"}),f.jsx(ze,{variant:"field",mono:!0,onClick:()=>m({a:"open",overlay:{kind:"keep-awake"}}),children:bd[l]})]}),f.jsx(k8,{}),f.jsx(y8,{})]})]}),f.jsx("div",{className:"keys-card",children:m8.map(h=>f.jsxs("div",{children:[f.jsx("div",{className:"section-title keys-h",children:h.title}),h.rows.map(([k,y])=>f.jsxs("div",{className:"keys-row",children:[f.jsx(Or,{k}),f.jsx("span",{className:"keys-d",children:y})]},k))]},h.title))})]})}function k8(){const e=it(),t=ct(),n=sn("keys"),r=L(N=>N.version),o=L(N=>N.install),a=L(N=>N.registry),l=L(N=>N.update),u=L(N=>N.self),c=L(N=>N.rebuilt),p=L(N=>N.repos),m=L(N=>N.managed.updates),h=L(N=>N.updateCheck),k=p8(r,o,l,u,p,c,a,h),y=!m&&(k.act==="update"||k.act==="check"),v=k.settles&&h&&h!=="asking"?h:null;S.useEffect(()=>{if(!v)return;const N=()=>t({a:"update-check-settle",check:v}),j=setTimeout(N,d8);return()=>{clearTimeout(j),N()}},[v,t]);const x=()=>{k.act==="restart"?e==null||e.send({t:"restart-daemon"}):k.act==="reload"?window.location.reload():k.act==="rebuild"&&u?e==null||e.send({t:"run-after-land",repoId:u.repoId}):k.act==="update"?e==null||e.send({t:"update-now"}):k.act==="check"&&e&&(t({a:"update-check"}),e.send({t:"check-update"}))},_=()=>h8(r,k.act==="check"&&!k.busy?{run:x,...y?{off:"managed by your organization"}:{}}:null);return f.jsxs("div",{className:"keys-setting",...n.contextMenu(_),children:[f.jsx("span",{className:"keys-d",children:"version"}),f.jsx(ze,{variant:"field",mono:!0,busy:k.busy,disabled:y,onClick:x,...$t(y?"updates are managed by your organization":k.text,void 0,{detail:k.detail}),children:k.value})]})}function y8(){const e=L(n=>n.managed);if(e.source===null)return null;const t=e.problem?"the policy file on this machine is invalid, so everything it governs is off; toyon doctor says why":`managed by your organization: ${fO(e).join(", ")||"nothing turned off"}`;return f.jsx("div",{className:"hint",children:t})}function uS(e){return e.available?e.auth?e.auth.kind==="none"?"not logged in":e.auth.label:"ready":e.installing?"installing":"not installed"}function dS(e){var n,r;return e.available?e.auth?[e.auth.detail,(n=e.auth.account)==null?void 0:n.email,(r=e.auth.account)==null?void 0:r.organization].filter(Boolean).join(" · ")||e.auth.label:"installed; it names the account it runs on the first time it runs":e.reason??"not installed"}function w8({agent:e}){const t=ct(),n=it(),r=sn("keys");return f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:e.name}),f.jsx(ze,{variant:"field",mono:!0,"data-tip":dS(e),...r.contextMenu(()=>Hg(e,{sock:n})),onClick:()=>{t({a:"palette-return",v:{mode:"keys",q:""}}),t({a:"open",overlay:{kind:"agent-page",agent:e.id}})},children:uS(e)})]})}function v8({agentId:e}){const t=ct(),n=it(),r=za(),o=L(k=>k.home),a=L(k=>k.agents.find(y=>y.id===e)??null),l=L(k=>k.agentConfigs[e]??null),u=sn("keys");if(S.useEffect(()=>{n==null||n.send({t:"agent-config",agent:e,...r?{repoId:r.id}:{}})},[n,e,r]),!a)return null;const c=Hg(a,{sock:n}),p=()=>t({a:"close",back:!0}),m=k=>o&&k.startsWith(`${o}/`)?`~${k.slice(o.length)}`:k,h=k=>n==null?void 0:n.send({t:"reveal-agent-file",agent:e,file:k.id,...r?{repoId:r.id}:{}});return f.jsx(sf,{bare:!0,boxClass:"keys-stack",onClose:p,children:f.jsxs("div",{className:"keys-card keys-settings",children:[f.jsx("div",{className:"agent-page-back",children:f.jsx(At,{icon:"back",label:"back to settings",hint:"esc",onClick:p})}),f.jsx("div",{className:"section-title keys-h",children:a.name}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"signed in"}),f.jsx(ze,{variant:"field",mono:!0,"data-tip":dS(a),disabled:c.length===0,...u.dropdown(()=>c,"right"),children:uS(a)})]}),f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"commit messages"}),f.jsx("span",{className:"keys-d",children:a.quick?"its quick model writes one after each turn":"none: it has no quick model, so you write them in the changes panel; quickModel in agents.json names one"})]}),f.jsx("div",{className:"section-title keys-h",children:"MCP servers it will load"}),l===null?f.jsx("div",{className:"keys-setting",children:f.jsx("span",{className:"keys-d",children:"reading…"})}):l.servers.length===0?f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:"none configured"}),f.jsx("span",{className:"keys-d",children:"add one with the agent's own CLI, or a .mcp.json in the repo"})]}):l.servers.map(k=>f.jsx(b8,{s:k},`${k.scope}:${k.name}`)),l&&l.files.length>0&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"section-title keys-h",children:"the files it reads"}),l.files.map(k=>f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{className:"keys-d",children:k.label}),k.exists?f.jsx(ze,{variant:"field",mono:!0,"data-tip":`reveal ${m(k.path)} in Finder`,onClick:()=>h(k),children:m(k.path)}):f.jsxs("span",{className:"keys-d",children:["not present: ",m(k.path)]})]},k.id))]})]})})}function b8({s:e}){return f.jsxs("div",{className:"keys-setting",children:[f.jsx("span",{children:e.name}),f.jsx("span",{className:"keys-d",children:e.detail?`${e.scope} · ${e.detail}`:e.scope})]})}function x8(){const e=ct(),t=it(),n=L(o=>o.agents),r=L(o=>o.defaultAgent);return f.jsx($r,{items:n,filter:(o,a)=>o.filter(l=>Oi(a,l.name,l.id)),rowClass:o=>o.available?"picker-row":"picker-row dim",keyOf:o=>o.id,initialIndex:o=>Math.max(0,o.findIndex(a=>a.id===r)),onPick:o=>{o.available&&(t==null||t.send({t:"set-default-agent",agent:o.id}),e({a:"close"}))},onBack:()=>e({a:"close",back:!0}),rowMenu:o=>Hg(o,{sock:t}),placeholder:"default agent for new worktrees",keys:{pick:"sets",back:"closes"},row:o=>f.jsx(Jn,{label:o.name,current:o.id===r,hint:o.available?o.sandboxed?void 0:"unsandboxed":o.reason??"not installed"})})}const _8=["dark","light","system","daylight"],E8=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});function S8(){const e=ct(),t=it(),n=L(c=>c.themePrefs),r=L(c=>c.themes),o=qm(),a=L(c=>c.daylight),l=c=>{var p;return((p=r.find(m=>m.id===n[Pm({...n,mode:c},o)]))==null?void 0:p.name)??""},u=c=>{if(c==="system")return`${o.system?"dark":"light"} now · ${l(c)}`;if(c!=="daylight")return l(c);const p=a&&a.until>Date.now()?` · ${o.daylight?"light":"dark"} at ${E8.format(a.until)}`:"";return`${o.daylight?"dark":"light"} now${p} · ${l(c)}`};return f.jsx($r,{items:_8,filter:(c,p)=>c.filter(m=>Oi(p,vd[m])),rowClass:()=>"picker-row",keyOf:c=>c,initialIndex:c=>c.indexOf(n.mode),onActive:c=>e({a:"preview-theme",theme:c?zd({...n,mode:c},r,o):null}),onPick:c=>{t==null||t.send({t:"set-theme",prefs:{...n,mode:c}}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"light/dark mode",keys:{nav:"preview",pick:"keeps",back:"reverts"},row:c=>f.jsx(Jn,{label:vd[c],current:c===n.mode,hint:u(c)})})}const N8=2,fm=e=>xx(e).join(" ").length<N8,T8=e=>({kind:"chat",id:e.id,name:e.name,hint:e.branch??"",fields:[e.name,e.branch??""]}),j8=e=>({kind:"chat",id:e.id,name:e.title,hint:c_(e),fields:[e.title,e.branch],prompt:e.prompt,archived:e});function C8(e,t,n){const r=xx(t),o=n==="all"&&!fm(t);return e.filter(a=>{if(a.kind==="hit")return o;const l=n==="names"&&a.prompt?[...a.fields,a.prompt]:a.fields;return r.every(u=>l.some(c=>c.toLowerCase().includes(u)))})}const A8=e=>e.flatMap(([t,n])=>Array.from({length:n},(r,o)=>t+o));function I8({repoId:e,scope:t}){const n=ct(),r=it(),o=L(E=>E.clientId),a=L(E=>E.frame),l=L(E=>E.chats[e]),u=Qm(),c=L(E=>E.archived[e]),[p,m]=S.useState(t),h=S.useCallback(()=>m(E=>E==="all"?"names":"all"),[]);S.useEffect(()=>{r==null||r.send({t:"list-archived",repoId:e})},[r,e]);const k=S.useMemo(()=>[...u.filter(E=>!Cr(E.worktree)).map(T8),...(c??[]).map(j8)],[u,c]),y=S.useMemo(()=>new Map(k.map(E=>[E.id,E])),[k]),v=S.useMemo(()=>[...k,...((l==null?void 0:l.hits)??[]).map(E=>({kind:"hit",hit:E}))],[k,l]),x=S.useCallback((E,M)=>C8(E,M,p),[p]),_=S.useCallback(E=>{p==="all"&&!fm(E)&&(r==null||r.send({t:"search-chats",repoId:e,query:E.trim()}))},[r,e,p]),N=E=>!l||l.query!==E.trim(),j=E=>p==="all"&&!fm(E);return f.jsx($r,{items:v,filter:x,onQuery:_,onTab:h,trailing:f.jsx(ze,{tone:"chrome",on:p==="names","aria-pressed":p==="names",onClick:h,children:"names only"}),keyOf:E=>E.kind==="hit"?`h:${E.hit.worktreeId}:${E.hit.seq}`:`w:${E.id}`,rowClass:E=>E.kind==="hit"?"chats-hit":He("picker-row",E.archived&&!E.archived.restorable&&"dim"),rowTitle:E=>{var M;return E.kind==="hit"?E.hit.text:((M=E.archived)==null?void 0:M.prompt)??E.name},groupOf:E=>E.kind==="hit"?`h:${E.hit.worktreeId}`:E.archived?"archived":"open",groupHead:(E,M)=>{if(!E.startsWith("h:"))return`${E} · ${M}`;const K=y.get(E.slice(2));return f.jsxs("span",{children:[(K==null?void 0:K.name)??"a worktree",(K==null?void 0:K.archived)&&f.jsxs(f.Fragment,{children:[" ",f.jsx("span",{className:"row-dim",children:"archived"})]}),` · ${M}`]})},headAlone:!0,onPick:E=>{const M=E.kind==="hit"?E.hit.worktreeId:E.id,K=E.kind==="hit"?E.hit.archived:!!E.archived;n(K?{a:"open-archived",id:M}:{a:"activate",id:M}),E.kind==="hit"&&n({a:"reveal",id:M,seq:E.hit.seq}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:E=>E.kind==="chat"&&E.archived?Vu(E.archived,{clientId:o,frame:a},{sock:r,dispatch:n}):[],placeholder:p==="names"?"find a chat by name…":"search in chats…",keys:E=>({nav:"moves",tab:p==="names"?"searches messages too":"searches names only",pick:E?E.kind==="hit"?"opens the chat there":"opens its chat":void 0,back:"closes"}),empty:E=>E.trim()?j(E)?N(E)?"searching…":"no chat says that":"no chat is named that":c?"no chats yet":"looking…",footer:(E,M)=>{const K=M.filter(U=>U.kind==="hit").length;return l!=null&&l.truncated&&!N(E)&&K>0?f.jsxs("div",{className:"empty",children:["showing the first ",K,"; narrow the search"]}):null},row:E=>E.kind==="chat"?f.jsx(Jn,{label:E.name,hint:E.hint}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"chats-text",children:sc(E.hit.text,A8(E.hit.match),0)}),f.jsxs("span",{className:"chats-said row-dim",children:[E.hit.role==="user"?"you":"the agent",E.hit.ts>0?` · ${ro(E.hit.ts)}`:""]})]})})}function R8({worktreeId:e,hits:t}){const n=ct(),r=it(),o=L(u=>u.layout.changes),a=L(u=>{var p;const c=(p=fn(u,e))==null?void 0:p.worktree;return c?c.path:null}),l=S.useCallback((u,c)=>{const p=c.trim().toLowerCase();return p?u.filter(m=>`${m.path}:${m.line} ${m.text}`.toLowerCase().includes(p)):u},[]);return f.jsx($r,{items:t,filter:l,keyOf:u=>`${u.path}:${u.line}`,rowClass:()=>"search-hit",rowTitle:u=>`${u.path}:${u.line}`,onPick:u=>{nr({dispatch:n},{worktreeId:e,path:u.path,view:"file",line:{n:u.line}}),o||n({a:"toggle-changes"}),n({a:"close"})},onBack:()=>n({a:"close"}),rowMenu:u=>a?fs({id:e,dir:a},u.path,{},{sock:r,dispatch:n}):[],placeholder:"lines that could write this element",keys:{pick:"opens the file",back:"closes"},row:u=>f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"search-loc",children:[u.path,":",u.line]}),f.jsx("span",{className:"search-text",children:u.text})]})})}const af=e=>/^(~|\/|\.\.?\/)/.test(e.trim());function fS(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 O8(e,t,n){const r=e.map(p=>p.path.slice(0,p.path.lastIndexOf("/"))).filter(Boolean),o=e.find(p=>p.id===t),a=o==null?void 0:o.path.slice(0,o.path.lastIndexOf("/")),l=new Map;for(const p of r)l.set(p,(l.get(p)??0)+1);let u="",c=0;for(const[p,m]of[...l].sort(([h],[k])=>h.localeCompare(k)))(m>c||m===c&&p===a)&&(u=p,c=m);return u?pS(u,n):`~/${wx}`}function pS(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function hS(e,t){return`${e.replace(/\/+$/,"")}/${t.trim()}`}function $8(e){const t=e.query.trim(),n=()=>e.entries.map(l=>({kind:"dir",entry:l}));if(!af(t)){const l=e.repos.filter(h=>Oi(t,h.name,h.path)).map(h=>({kind:"repo",repo:h})),u=e.pending.filter(h=>Oi(t,h.name,h.url)).map(h=>({kind:"pending",pending:h})),c=[...l,...u];if(!t)return[...c,{kind:"new"},{kind:"disk"}];const p=AO(t);if(p)return c.length>0?c:[{kind:"clone",url:p.url,name:p.name}];const m=h=>h.toLowerCase()===t.toLowerCase();return e.repos.some(h=>m(h.name))||e.pending.some(h=>m(h.name))||Jl(t)?c:[...c,{kind:"create",name:t,parent:null}]}if(e.answered.trim()!==t||!e.target)return n();const{target:r}=e;if(t.endsWith("/"))return n();if(r.exists)return r.isRepo?[...n(),{kind:"open",path:t}]:n();if(!r.parentExists)return[];const{parent:o,name:a}=fS(t);return Jl(a)?n():[...n(),{kind:"create",name:a,parent:o}]}function ic(e,t){return t&&(e==="~"||e.startsWith("~/"))?`${t}${e.slice(1)}`:e}function mS(e,t){const n=ic(e,t).replace(/\/+$/,"");return n.startsWith("/")?pS(n.slice(0,n.lastIndexOf("/"))||"/",t):null}function pm(e,t){const n=ic(e,t).replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||"/"}function M8(e){const t=e.query.trim(),n=t.lastIndexOf("/"),r=n<0?"":t.slice(0,n)||"/",o=ic(r,e.home);if(!af(t)||!o.startsWith("/"))return[];const a=t.slice(n+1).toLowerCase(),l=e.answered.trim()===t?e.target:null,u=!l||(a?l.parentExists:l.exists&&l.isDir&&!l.isRepo),c=e.entries.filter(m=>{if(m.isRepo)return!1;const h=ic(m.path,e.home);return(h.slice(0,h.lastIndexOf("/"))||"/")===o&&m.name.toLowerCase().startsWith(a)}),p=mS(r,e.home);return[...u?[{kind:"here",path:r}]:[],...p?[{kind:"up",path:p}]:[],...c.map(m=>({kind:"dir",entry:m}))]}function L8({project:e}){const t=ct(),n=it(),r=L(p=>p.paths),o=L(p=>p.home),a=S.useCallback(p=>{af(p)&&(n==null||n.send({t:"browse-path",path:p}))},[n]),l=S.useCallback((p,m)=>M8({query:m,entries:r.entries,target:r.target,answered:r.query,home:o}),[r,o]),u=Jl(e.name)?null:e.name.trim(),c=p=>`${p.replace(/\/+$/,"")}/`;return f.jsx($r,{initialQuery:c(e.parent),lead:f.jsx("span",{className:"picker-chip",children:u??"new project"}),items:[],filter:l,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"?c(p.entry.path):null,narrowTo:p=>p.kind==="dir"?c(p.entry.path):p.kind==="up"?c(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"?f.jsx(Jn,{label:`put ${u??"it"} in ${pm(p.path,o)}`,hint:f.jsx("bdi",{children:u?hS(p.path,u):p.path})}):p.kind==="up"?f.jsx(Jn,{label:`up to ${pm(p.path,o)}`,hint:f.jsx("bdi",{children:p.path})}):f.jsx(Jn,{label:p.entry.name})})}const P8={use:"an agent working, a question waiting, a phone connected",always:"whenever Toyon runs, on battery too",off:"the Mac sleeps when it would anyway"};function D8(){const e=ct(),t=it(),n=L(r=>r.keepAwake);return f.jsx($r,{items:[...oT],filter:(r,o)=>r.filter(a=>Oi(o,bd[a])),rowClass:()=>"picker-row",keyOf:r=>r,initialIndex:r=>Math.max(0,n?r.indexOf(n):0),onPick:r=>{t==null||t.send({t:"set-keep-awake",mode:r}),e({a:"close"})},onBack:()=>e({a:"close",back:!0}),placeholder:"keep the Mac awake",keys:{pick:"sets",back:"closes"},row:r=>f.jsx(Jn,{label:bd[r],current:r===n,hint:P8[r]})})}const Ua=function(e,t){let o=e;const a=Ll[t];let l=null,u=0,c=null;const p=[],m={},h=function(R,I){u=o*4+17,l=(function(C){const P=new Array(C);for(let z=0;z<C;z+=1){P[z]=new Array(C);for(let q=0;q<C;q+=1)P[z][q]=null}return P})(u),k(0,0),k(u-7,0),k(0,u-7),x(),v(),N(R,I),o>=7&&_(R),c==null&&(c=M(o,a,p)),j(c,I)},k=function(R,I){for(let C=-1;C<=7;C+=1)if(!(R+C<=-1||u<=R+C))for(let P=-1;P<=7;P+=1)I+P<=-1||u<=I+P||(0<=C&&C<=6&&(P==0||P==6)||0<=P&&P<=6&&(C==0||C==6)||2<=C&&C<=4&&2<=P&&P<=4?l[R+C][I+P]=!0:l[R+C][I+P]=!1)},y=function(){let R=0,I=0;for(let C=0;C<8;C+=1){h(!0,C);const P=Ps.getLostPoint(m);(C==0||R>P)&&(R=P,I=C)}return I},v=function(){for(let R=8;R<u-8;R+=1)l[R][6]==null&&(l[R][6]=R%2==0);for(let R=8;R<u-8;R+=1)l[6][R]==null&&(l[6][R]=R%2==0)},x=function(){const R=Ps.getPatternPosition(o);for(let I=0;I<R.length;I+=1)for(let C=0;C<R.length;C+=1){const P=R[I],z=R[C];if(l[P][z]==null)for(let q=-2;q<=2;q+=1)for(let se=-2;se<=2;se+=1)q==-2||q==2||se==-2||se==2||q==0&&se==0?l[P+q][z+se]=!0:l[P+q][z+se]=!1}},_=function(R){const I=Ps.getBCHTypeNumber(o);for(let C=0;C<18;C+=1){const P=!R&&(I>>C&1)==1;l[Math.floor(C/3)][C%3+u-8-3]=P}for(let C=0;C<18;C+=1){const P=!R&&(I>>C&1)==1;l[C%3+u-8-3][Math.floor(C/3)]=P}},N=function(R,I){const C=a<<3|I,P=Ps.getBCHTypeInfo(C);for(let z=0;z<15;z+=1){const q=!R&&(P>>z&1)==1;z<6?l[z][8]=q:z<8?l[z+1][8]=q:l[u-15+z][8]=q}for(let z=0;z<15;z+=1){const q=!R&&(P>>z&1)==1;z<8?l[8][u-z-1]=q:z<9?l[8][15-z-1+1]=q:l[8][15-z-1]=q}l[u-8][8]=!R},j=function(R,I){let C=-1,P=u-1,z=7,q=0;const se=Ps.getMaskFunction(I);for(let pe=u-1;pe>0;pe-=2)for(pe==6&&(pe-=1);;){for(let ue=0;ue<2;ue+=1)if(l[P][pe-ue]==null){let xe=!1;q<R.length&&(xe=(R[q]>>>z&1)==1),se(P,pe-ue)&&(xe=!xe),l[P][pe-ue]=xe,z-=1,z==-1&&(q+=1,z=7)}if(P+=C,P<0||u<=P){P-=C,C=-C;break}}},E=function(R,I){let C=0,P=0,z=0;const q=new Array(I.length),se=new Array(I.length);for(let oe=0;oe<I.length;oe+=1){const A=I[oe].dataCount,X=I[oe].totalCount-A;P=Math.max(P,A),z=Math.max(z,X),q[oe]=new Array(A);for(let de=0;de<q[oe].length;de+=1)q[oe][de]=255&R.getBuffer()[de+C];C+=A;const Z=Ps.getErrorCorrectPolynomial(X),V=ac(q[oe],Z.getLength()-1).mod(Z);se[oe]=new Array(Z.getLength()-1);for(let de=0;de<se[oe].length;de+=1){const me=de+V.getLength()-se[oe].length;se[oe][de]=me>=0?V.getAt(me):0}}let pe=0;for(let oe=0;oe<I.length;oe+=1)pe+=I[oe].totalCount;const ue=new Array(pe);let xe=0;for(let oe=0;oe<P;oe+=1)for(let A=0;A<I.length;A+=1)oe<q[A].length&&(ue[xe]=q[A][oe],xe+=1);for(let oe=0;oe<z;oe+=1)for(let A=0;A<I.length;A+=1)oe<se[A].length&&(ue[xe]=se[A][oe],xe+=1);return ue},M=function(R,I,C){const P=ob.getRSBlocks(R,I),z=sb();for(let se=0;se<C.length;se+=1){const pe=C[se];z.put(pe.getMode(),4),z.put(pe.getLength(),Ps.getLengthInBits(pe.getMode(),R)),pe.write(z)}let q=0;for(let se=0;se<P.length;se+=1)q+=P[se].dataCount;if(z.getLengthInBits()>q*8)throw"code length overflow. ("+z.getLengthInBits()+">"+q*8+")";for(z.getLengthInBits()+4<=q*8&&z.put(0,4);z.getLengthInBits()%8!=0;)z.putBit(!1);for(;!(z.getLengthInBits()>=q*8||(z.put(236,8),z.getLengthInBits()>=q*8));)z.put(17,8);return E(z,P)};m.addData=function(R,I){I=I||"Byte";let C=null;switch(I){case"Numeric":C=z8(R);break;case"Alphanumeric":C=F8(R);break;case"Byte":C=B8(R);break;case"Kanji":C=U8(R);break;default:throw"mode:"+I}p.push(C),c=null},m.isDark=function(R,I){if(R<0||u<=R||I<0||u<=I)throw R+","+I;return l[R][I]},m.getModuleCount=function(){return u},m.make=function(){if(o<1){let R=1;for(;R<40;R++){const I=ob.getRSBlocks(R,a),C=sb();for(let z=0;z<p.length;z++){const q=p[z];C.put(q.getMode(),4),C.put(q.getLength(),Ps.getLengthInBits(q.getMode(),R)),q.write(C)}let P=0;for(let z=0;z<I.length;z++)P+=I[z].dataCount;if(C.getLengthInBits()<=P*8)break}o=R}h(!1,y())},m.createTableTag=function(R,I){R=R||2,I=typeof I>"u"?R*4:I;let C="";C+='<table style="',C+=" border-width: 0px; border-style: none;",C+=" border-collapse: collapse;",C+=" padding: 0px; margin: "+I+"px;",C+='">',C+="<tbody>";for(let P=0;P<m.getModuleCount();P+=1){C+="<tr>";for(let z=0;z<m.getModuleCount();z+=1)C+='<td style="',C+=" border-width: 0px; border-style: none;",C+=" border-collapse: collapse;",C+=" padding: 0px; margin: 0px;",C+=" width: "+R+"px;",C+=" height: "+R+"px;",C+=" background-color: ",C+=m.isDark(P,z)?"#000000":"#ffffff",C+=";",C+='"/>';C+="</tr>"}return C+="</tbody>",C+="</table>",C},m.createSvgTag=function(R,I,C,P){let z={};typeof arguments[0]=="object"&&(z=arguments[0],R=z.cellSize,I=z.margin,C=z.alt,P=z.title),R=R||2,I=typeof I>"u"?R*4:I,C=typeof C=="string"?{text:C}:C||{},C.text=C.text||null,C.id=C.text?C.id||"qrcode-description":null,P=typeof P=="string"?{text:P}:P||{},P.text=P.text||null,P.id=P.text?P.id||"qrcode-title":null;const q=m.getModuleCount()*R+I*2;let se,pe,ue,xe,oe="",A;for(A="l"+R+",0 0,"+R+" -"+R+",0 0,-"+R+"z ",oe+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',oe+=z.scalable?"":' width="'+q+'px" height="'+q+'px"',oe+=' viewBox="0 0 '+q+" "+q+'" ',oe+=' preserveAspectRatio="xMinYMin meet"',oe+=P.text||C.text?' role="img" aria-labelledby="'+K([P.id,C.id].join(" ").trim())+'"':"",oe+=">",oe+=P.text?'<title id="'+K(P.id)+'">'+K(P.text)+"</title>":"",oe+=C.text?'<description id="'+K(C.id)+'">'+K(C.text)+"</description>":"",oe+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',oe+='<path d="',ue=0;ue<m.getModuleCount();ue+=1)for(xe=ue*R+I,se=0;se<m.getModuleCount();se+=1)m.isDark(ue,se)&&(pe=se*R+I,oe+="M"+pe+","+xe+A);return oe+='" stroke="transparent" fill="black"/>',oe+="</svg>",oe},m.createDataURL=function(R,I){R=R||2,I=typeof I>"u"?R*4:I;const C=m.getModuleCount()*R+I*2,P=I,z=C-I;return Z8(C,C,function(q,se){if(P<=q&&q<z&&P<=se&&se<z){const pe=Math.floor((q-P)/R),ue=Math.floor((se-P)/R);return m.isDark(ue,pe)?0:1}else return 1})},m.createImgTag=function(R,I,C){R=R||2,I=typeof I>"u"?R*4:I;const P=m.getModuleCount()*R+I*2;let z="";return z+="<img",z+=' src="',z+=m.createDataURL(R,I),z+='"',z+=' width="',z+=P,z+='"',z+=' height="',z+=P,z+='"',C&&(z+=' alt="',z+=K(C),z+='"'),z+="/>",z};const K=function(R){let I="";for(let C=0;C<R.length;C+=1){const P=R.charAt(C);switch(P){case"<":I+="&lt;";break;case">":I+="&gt;";break;case"&":I+="&amp;";break;case'"':I+="&quot;";break;default:I+=P;break}}return I},U=function(R){R=typeof R>"u"?2:R;const C=m.getModuleCount()*1+R*2,P=R,z=C-R;let q,se,pe,ue,xe;const oe={"██":"█","█ ":"▀"," █":"▄"," ":" "},A={"██":"▀","█ ":"▀"," █":" "," ":" "};let X="";for(q=0;q<C;q+=2){for(pe=Math.floor((q-P)/1),ue=Math.floor((q+1-P)/1),se=0;se<C;se+=1)xe="█",P<=se&&se<z&&P<=q&&q<z&&m.isDark(pe,Math.floor((se-P)/1))&&(xe=" "),P<=se&&se<z&&P<=q+1&&q+1<z&&m.isDark(ue,Math.floor((se-P)/1))?xe+=" ":xe+="█",X+=R<1&&q+1>=z?A[xe]:oe[xe];X+=`
243
+ `}return C%2&&R>0?X.substring(0,X.length-C-1)+Array(C+1).join("▀"):X.substring(0,X.length-1)};return m.createASCII=function(R,I){if(R=R||1,R<2)return U(I);R-=1,I=typeof I>"u"?R*2:I;const C=m.getModuleCount()*R+I*2,P=I,z=C-I;let q,se,pe,ue;const xe=Array(R+1).join("██"),oe=Array(R+1).join(" ");let A="",X="";for(q=0;q<C;q+=1){for(pe=Math.floor((q-P)/R),X="",se=0;se<C;se+=1)ue=1,P<=se&&se<z&&P<=q&&q<z&&m.isDark(pe,Math.floor((se-P)/R))&&(ue=0),X+=ue?xe:oe;for(pe=0;pe<R;pe+=1)A+=X+`
244
+ `}return A.substring(0,A.length-1)},m.renderTo2dContext=function(R,I){I=I||2;const C=m.getModuleCount();for(let P=0;P<C;P++)for(let z=0;z<C;z++)R.fillStyle=m.isDark(P,z)?"black":"white",R.fillRect(z*I,P*I,I,I)},m};Ua.stringToBytes=function(e){const t=[];for(let n=0;n<e.length;n+=1){const r=e.charCodeAt(n);t.push(r&255)}return t};Ua.createStringToBytes=function(e,t){const n=(function(){const o=W8(e),a=function(){const c=o.read();if(c==-1)throw"eof";return c};let l=0;const u={};for(;;){const c=o.read();if(c==-1)break;const p=a(),m=a(),h=a(),k=String.fromCharCode(c<<8|p),y=m<<8|h;u[k]=y,l+=1}if(l!=t)throw l+" != "+t;return u})(),r=63;return function(o){const a=[];for(let l=0;l<o.length;l+=1){const u=o.charCodeAt(l);if(u<128)a.push(u);else{const c=n[o.charAt(l)];typeof c=="number"?(c&255)==c?a.push(c):(a.push(c>>>8),a.push(c&255)):a.push(r)}}return a}};const Tr={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Ll={L:1,M:0,Q:3,H:2},Ls={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Ps=(function(){const e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,n=7973,r=21522,o={},a=function(l){let u=0;for(;l!=0;)u+=1,l>>>=1;return u};return o.getBCHTypeInfo=function(l){let u=l<<10;for(;a(u)-a(t)>=0;)u^=t<<a(u)-a(t);return(l<<10|u)^r},o.getBCHTypeNumber=function(l){let u=l<<12;for(;a(u)-a(n)>=0;)u^=n<<a(u)-a(n);return l<<12|u},o.getPatternPosition=function(l){return e[l-1]},o.getMaskFunction=function(l){switch(l){case Ls.PATTERN000:return function(u,c){return(u+c)%2==0};case Ls.PATTERN001:return function(u,c){return u%2==0};case Ls.PATTERN010:return function(u,c){return c%3==0};case Ls.PATTERN011:return function(u,c){return(u+c)%3==0};case Ls.PATTERN100:return function(u,c){return(Math.floor(u/2)+Math.floor(c/3))%2==0};case Ls.PATTERN101:return function(u,c){return u*c%2+u*c%3==0};case Ls.PATTERN110:return function(u,c){return(u*c%2+u*c%3)%2==0};case Ls.PATTERN111:return function(u,c){return(u*c%3+(u+c)%2)%2==0};default:throw"bad maskPattern:"+l}},o.getErrorCorrectPolynomial=function(l){let u=ac([1],0);for(let c=0;c<l;c+=1)u=u.multiply(ac([1,zs.gexp(c)],0));return u},o.getLengthInBits=function(l,u){if(1<=u&&u<10)switch(l){case Tr.MODE_NUMBER:return 10;case Tr.MODE_ALPHA_NUM:return 9;case Tr.MODE_8BIT_BYTE:return 8;case Tr.MODE_KANJI:return 8;default:throw"mode:"+l}else if(u<27)switch(l){case Tr.MODE_NUMBER:return 12;case Tr.MODE_ALPHA_NUM:return 11;case Tr.MODE_8BIT_BYTE:return 16;case Tr.MODE_KANJI:return 10;default:throw"mode:"+l}else if(u<41)switch(l){case Tr.MODE_NUMBER:return 14;case Tr.MODE_ALPHA_NUM:return 13;case Tr.MODE_8BIT_BYTE:return 16;case Tr.MODE_KANJI:return 12;default:throw"mode:"+l}else throw"type:"+u},o.getLostPoint=function(l){const u=l.getModuleCount();let c=0;for(let h=0;h<u;h+=1)for(let k=0;k<u;k+=1){let y=0;const v=l.isDark(h,k);for(let x=-1;x<=1;x+=1)if(!(h+x<0||u<=h+x))for(let _=-1;_<=1;_+=1)k+_<0||u<=k+_||x==0&&_==0||v==l.isDark(h+x,k+_)&&(y+=1);y>5&&(c+=3+y-5)}for(let h=0;h<u-1;h+=1)for(let k=0;k<u-1;k+=1){let y=0;l.isDark(h,k)&&(y+=1),l.isDark(h+1,k)&&(y+=1),l.isDark(h,k+1)&&(y+=1),l.isDark(h+1,k+1)&&(y+=1),(y==0||y==4)&&(c+=3)}for(let h=0;h<u;h+=1)for(let k=0;k<u-6;k+=1)l.isDark(h,k)&&!l.isDark(h,k+1)&&l.isDark(h,k+2)&&l.isDark(h,k+3)&&l.isDark(h,k+4)&&!l.isDark(h,k+5)&&l.isDark(h,k+6)&&(c+=40);for(let h=0;h<u;h+=1)for(let k=0;k<u-6;k+=1)l.isDark(k,h)&&!l.isDark(k+1,h)&&l.isDark(k+2,h)&&l.isDark(k+3,h)&&l.isDark(k+4,h)&&!l.isDark(k+5,h)&&l.isDark(k+6,h)&&(c+=40);let p=0;for(let h=0;h<u;h+=1)for(let k=0;k<u;k+=1)l.isDark(k,h)&&(p+=1);const m=Math.abs(100*p/u/u-50)/5;return c+=m*10,c},o})(),zs=(function(){const e=new Array(256),t=new Array(256);for(let r=0;r<8;r+=1)e[r]=1<<r;for(let r=8;r<256;r+=1)e[r]=e[r-4]^e[r-5]^e[r-6]^e[r-8];for(let r=0;r<255;r+=1)t[e[r]]=r;const n={};return n.glog=function(r){if(r<1)throw"glog("+r+")";return t[r]},n.gexp=function(r){for(;r<0;)r+=255;for(;r>=256;)r-=255;return e[r]},n})(),ac=function(e,t){if(typeof e.length>"u")throw e.length+"/"+t;const n=(function(){let o=0;for(;o<e.length&&e[o]==0;)o+=1;const a=new Array(e.length-o+t);for(let l=0;l<e.length-o;l+=1)a[l]=e[l+o];return a})(),r={};return r.getAt=function(o){return n[o]},r.getLength=function(){return n.length},r.multiply=function(o){const a=new Array(r.getLength()+o.getLength()-1);for(let l=0;l<r.getLength();l+=1)for(let u=0;u<o.getLength();u+=1)a[l+u]^=zs.gexp(zs.glog(r.getAt(l))+zs.glog(o.getAt(u)));return ac(a,0)},r.mod=function(o){if(r.getLength()-o.getLength()<0)return r;const a=zs.glog(r.getAt(0))-zs.glog(o.getAt(0)),l=new Array(r.getLength());for(let u=0;u<r.getLength();u+=1)l[u]=r.getAt(u);for(let u=0;u<o.getLength();u+=1)l[u]^=zs.gexp(zs.glog(o.getAt(u))+a);return ac(l,0).mod(o)},r},ob=(function(){const e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(o,a){const l={};return l.totalCount=o,l.dataCount=a,l},n={},r=function(o,a){switch(a){case Ll.L:return e[(o-1)*4+0];case Ll.M:return e[(o-1)*4+1];case Ll.Q:return e[(o-1)*4+2];case Ll.H:return e[(o-1)*4+3];default:return}};return n.getRSBlocks=function(o,a){const l=r(o,a);if(typeof l>"u")throw"bad rs block @ typeNumber:"+o+"/errorCorrectionLevel:"+a;const u=l.length/3,c=[];for(let p=0;p<u;p+=1){const m=l[p*3+0],h=l[p*3+1],k=l[p*3+2];for(let y=0;y<m;y+=1)c.push(t(h,k))}return c},n})(),sb=function(){const e=[];let t=0;const n={};return n.getBuffer=function(){return e},n.getAt=function(r){const o=Math.floor(r/8);return(e[o]>>>7-r%8&1)==1},n.put=function(r,o){for(let a=0;a<o;a+=1)n.putBit((r>>>o-a-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(r){const o=Math.floor(t/8);e.length<=o&&e.push(0),r&&(e[o]|=128>>>t%8),t+=1},n},z8=function(e){const t=Tr.MODE_NUMBER,n=e,r={};r.getMode=function(){return t},r.getLength=function(l){return n.length},r.write=function(l){const u=n;let c=0;for(;c+2<u.length;)l.put(o(u.substring(c,c+3)),10),c+=3;c<u.length&&(u.length-c==1?l.put(o(u.substring(c,c+1)),4):u.length-c==2&&l.put(o(u.substring(c,c+2)),7))};const o=function(l){let u=0;for(let c=0;c<l.length;c+=1)u=u*10+a(l.charAt(c));return u},a=function(l){if("0"<=l&&l<="9")return l.charCodeAt(0)-48;throw"illegal char :"+l};return r},F8=function(e){const t=Tr.MODE_ALPHA_NUM,n=e,r={};r.getMode=function(){return t},r.getLength=function(a){return n.length},r.write=function(a){const l=n;let u=0;for(;u+1<l.length;)a.put(o(l.charAt(u))*45+o(l.charAt(u+1)),11),u+=2;u<l.length&&a.put(o(l.charAt(u)),6)};const o=function(a){if("0"<=a&&a<="9")return a.charCodeAt(0)-48;if("A"<=a&&a<="Z")return a.charCodeAt(0)-65+10;switch(a){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+a}};return r},B8=function(e){const t=Tr.MODE_8BIT_BYTE,n=Ua.stringToBytes(e),r={};return r.getMode=function(){return t},r.getLength=function(o){return n.length},r.write=function(o){for(let a=0;a<n.length;a+=1)o.put(n[a],8)},r},U8=function(e){const t=Tr.MODE_KANJI,n=Ua.stringToBytes;(function(a,l){const u=n(a);if(u.length!=2||(u[0]<<8|u[1])!=l)throw"sjis not supported."})("友",38726);const r=n(e),o={};return o.getMode=function(){return t},o.getLength=function(a){return~~(r.length/2)},o.write=function(a){const l=r;let u=0;for(;u+1<l.length;){let c=(255&l[u])<<8|255&l[u+1];if(33088<=c&&c<=40956)c-=33088;else if(57408<=c&&c<=60351)c-=49472;else throw"illegal char at "+(u+1)+"/"+c;c=(c>>>8&255)*192+(c&255),a.put(c,13),u+=2}if(u<l.length)throw"illegal char at "+(u+1)},o},gS=function(){const e=[],t={};return t.writeByte=function(n){e.push(n&255)},t.writeShort=function(n){t.writeByte(n),t.writeByte(n>>>8)},t.writeBytes=function(n,r,o){r=r||0,o=o||n.length;for(let a=0;a<o;a+=1)t.writeByte(n[a+r])},t.writeString=function(n){for(let r=0;r<n.length;r+=1)t.writeByte(n.charCodeAt(r))},t.toByteArray=function(){return e},t.toString=function(){let n="";n+="[";for(let r=0;r<e.length;r+=1)r>0&&(n+=","),n+=e[r];return n+="]",n},t},H8=function(){let e=0,t=0,n=0,r="";const o={},a=function(u){r+=String.fromCharCode(l(u&63))},l=function(u){if(u<0)throw"n:"+u;if(u<26)return 65+u;if(u<52)return 97+(u-26);if(u<62)return 48+(u-52);if(u==62)return 43;if(u==63)return 47;throw"n:"+u};return o.writeByte=function(u){for(e=e<<8|u&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},o.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0){const u=3-n%3;for(let c=0;c<u;c+=1)r+="="}},o.toString=function(){return r},o},W8=function(e){const t=e;let n=0,r=0,o=0;const a={};a.read=function(){for(;o<8;){if(n>=t.length){if(o==0)return-1;throw"unexpected end of file./"+o}const c=t.charAt(n);if(n+=1,c=="=")return o=0,-1;if(c.match(/^\s$/))continue;r=r<<6|l(c.charCodeAt(0)),o+=6}const u=r>>>o-8&255;return o-=8,u};const l=function(u){if(65<=u&&u<=90)return u-65;if(97<=u&&u<=122)return u-97+26;if(48<=u&&u<=57)return u-48+52;if(u==43)return 62;if(u==47)return 63;throw"c:"+u};return a},K8=function(e,t){const n=e,r=t,o=new Array(e*t),a={};a.setPixel=function(p,m,h){o[m*n+p]=h},a.write=function(p){p.writeString("GIF87a"),p.writeShort(n),p.writeShort(r),p.writeByte(128),p.writeByte(0),p.writeByte(0),p.writeByte(0),p.writeByte(0),p.writeByte(0),p.writeByte(255),p.writeByte(255),p.writeByte(255),p.writeString(","),p.writeShort(0),p.writeShort(0),p.writeShort(n),p.writeShort(r),p.writeByte(0);const m=2,h=u(m);p.writeByte(m);let k=0;for(;h.length-k>255;)p.writeByte(255),p.writeBytes(h,k,255),k+=255;p.writeByte(h.length-k),p.writeBytes(h,k,h.length-k),p.writeByte(0),p.writeString(";")};const l=function(p){const m=p;let h=0,k=0;const y={};return y.write=function(v,x){if(v>>>x)throw"length over";for(;h+x>=8;)m.writeByte(255&(v<<h|k)),x-=8-h,v>>>=8-h,k=0,h=0;k=v<<h|k,h=h+x},y.flush=function(){h>0&&m.writeByte(k)},y},u=function(p){const m=1<<p,h=(1<<p)+1;let k=p+1;const y=c();for(let j=0;j<m;j+=1)y.add(String.fromCharCode(j));y.add(String.fromCharCode(m)),y.add(String.fromCharCode(h));const v=gS(),x=l(v);x.write(m,k);let _=0,N=String.fromCharCode(o[_]);for(_+=1;_<o.length;){const j=String.fromCharCode(o[_]);_+=1,y.contains(N+j)?N=N+j:(x.write(y.indexOf(N),k),y.size()<4095&&(y.size()==1<<k&&(k+=1),y.add(N+j)),N=j)}return x.write(y.indexOf(N),k),x.write(h,k),x.flush(),v.toByteArray()},c=function(){const p={};let m=0;const h={};return h.add=function(k){if(h.contains(k))throw"dup key:"+k;p[k]=m,m+=1},h.size=function(){return m},h.indexOf=function(k){return p[k]},h.contains=function(k){return typeof p[k]<"u"},h};return a},Z8=function(e,t,n){const r=K8(e,t);for(let u=0;u<t;u+=1)for(let c=0;c<e;c+=1)r.setPixel(c,u,n(c,u));const o=gS();r.write(o);const a=H8(),l=o.toByteArray();for(let u=0;u<l.length;u+=1)a.writeByte(l[u]);return a.flush(),"data:image/gif;base64,"+a};Ua.stringToBytes;function q8(e){const t=Ua(0,"M");t.addData(e,"Byte"),t.make();const n=t.getModuleCount();return Array.from({length:n},(r,o)=>Array.from({length:n},(a,l)=>t.isDark(o,l)))}const ph=4;function G8({text:e,spent:t}){const{size:n,d:r}=S.useMemo(()=>{const o=q8(e);let a="";return o.forEach((l,u)=>{l.forEach((c,p)=>{c&&(a+=`M${p+ph} ${u+ph}h1v1h-1z`)})}),{size:o.length+ph*2,d:a}},[e]);return f.jsx("svg",{className:He("pair-qr",t&&"pair-qr-spent"),viewBox:`0 0 ${n} ${n}`,shapeRendering:"crispEdges",role:"img","aria-label":"Pairing code",children:f.jsx("path",{d:r})})}function V8(e){const[t,n]=S.useState(0);return S.useEffect(()=>{if(!e)return;const r=performance.now()+e.ms,o=()=>n(Math.max(0,Math.ceil((r-performance.now())/1e3)));o();const a=setInterval(o,250);return()=>clearInterval(a)},[e]),t}const Y8=3e3;function Q8(e,t){const[n,r]=S.useState(),o=e!==null&&hO(e);return S.useEffect(()=>{if(!o||!t)return;let a=!0,l;const u=()=>void RM().then(c=>{a&&(r(c),l=setTimeout(u,Y8))});return u(),()=>{a=!1,clearTimeout(l)}},[o,t]),o?n:void 0}function X8(){const e=ct(),t=L(_=>{var N;return((N=_.remote)==null?void 0:N.host)??null}),n=L(_=>_.pairings),[r,o]=S.useState(null),[a,l]=S.useState(null),[u,c]=S.useState(0),p=S.useRef(n),m=V8(r);gt([u],()=>{let _=!0;return o(null),l(null),OM().then(N=>{_&&(p.current=n,typeof N=="string"?l(N):o(N))}),()=>{_=!1}});const h=r!==null&&n>p.current,k=r!==null&&m===0,y=()=>e({a:"close"}),v=Q8(t,!h&&!a),x=v===void 0?null:mO(v);return f.jsx(sf,{bare:!0,boxClass:"pair-stack",onClose:y,children:f.jsxs("div",{className:"pair-card",children:[f.jsx("div",{className:"pair-title",children:"Open on your phone"}),h?f.jsx("p",{className:"pair-line",children:"Paired. Your phone lists this machine on toyon.cloud now."}):a?f.jsx("p",{className:"pair-line",children:a}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"pair-frame",children:r&&f.jsx(G8,{text:r.url,spent:k})}),t&&f.jsx("div",{className:"hint pair-host",children:t}),f.jsx("p",{className:"pair-line",children:r?k?"This code has expired.":f.jsxs(f.Fragment,{children:["Scan with your phone's camera. The code works once; ",f.jsx("span",{className:"pair-left",children:m})," seconds left."]}):"Making a code."}),x&&f.jsx("p",{className:He("pair-note",x.ok&&"hint"),children:x.text})]}),f.jsxs("div",{className:"pair-actions",children:[(k||a)&&!h&&f.jsx(ze,{variant:"outline",onClick:()=>c(_=>_+1),children:"new code"}),f.jsx(ze,{tone:"quiet",onClick:y,children:"done"})]})]})})}function Wg({form:e}){var j;const t=ct(),n=it(),r=L(E=>E.repos),o=L(E=>E.newProject?null:E.activeRepoId),a=L(E=>E.rows),l=L(E=>E.paths),u=L(E=>E.home),c=L(E=>E.pending),p=S.useCallback(E=>{af(E)&&(n==null||n.send({t:"browse-path",path:E}))},[n]),m=S.useCallback((E,M)=>$8({query:M,repos:r,pending:c,entries:[...l.entries].sort((K,U)=>Number(U.isRepo)-Number(K.isRepo)),target:l.target,answered:l.query}),[r,l,c]),h=E=>{const M=a.filter(P=>P.repoId===E.id),K=M.filter(tr).filter(P=>P.worktree.kind!=="spare"),U=K.filter(fc).length,R=K.length-1,I=M.length-M.filter(tr).length;return[R>0?`${R} worktree${R===1?"":"s"}`:null,U>0?`${U} working`:null,I>0?`${I} discovered`:null].filter(Boolean).join(" · ")||void 0},k=()=>t({a:"close"}),y=()=>t({a:"close",back:!0}),v=E=>{t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:E})},x=(E,M)=>{t({a:"open-repo"}),n==null||n.send({t:"create-repo",mode:"create",parent:E,name:M})},_=(E,M,K)=>t({a:"new-project",v:Wm({mode:E,name:M,parent:O8(r,o,u),...K?{url:K}:{}})}),N=()=>t({a:"open",overlay:{kind:"projects",form:"disk"}});return f.jsx($r,{anchored:e==="pill",initialQuery:e==="disk"?"~/":"",lead:e==="disk"?void 0:f.jsx("span",{className:"picker-chip",children:((j=r.find(E=>E.id===o))==null?void 0:j.name)??"no project"}),trailing:e==="disk"?void 0:f.jsx(At,{icon:"folder",label:"Find a project on disk",onClick:N}),items:[],filter:m,initialIndex:E=>E.findIndex(M=>M.kind==="repo"&&M.repo.id===o),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":E.kind==="disk"?"open-folder":`new:${E.parent??""}/${E.name}`,rowClass:E=>He("picker-row",(E.kind==="new"||E.kind==="disk")&&"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 _("clone",E.name,E.url);if(E.kind==="create"&&!E.parent)return _("create",E.name);if(E.kind==="new")return _("create","");if(E.kind==="disk")return N();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"?v(E.path):E.kind==="dir"?v(E.entry.path):E.parent&&x(E.parent,E.name),k()},onBack:y,rowMenu:E=>E.kind==="repo"?rf(E.repo,o,{sock:n,dispatch:t}):E.kind==="pending"?P3(E.pending,{sock:n,dispatch:t}):[],placeholder:r.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":(E==null?void 0:E.kind)==="disk"?"browses":"opens",back:"closes"}),empty:"nothing here; keep typing a path (~/… or /…)",row:E=>E.kind==="repo"?f.jsx(Jn,{label:E.repo.name,current:E.repo.id===o,hint:h(E.repo)}):E.kind==="pending"?f.jsx(Jn,{label:E.pending.name,hint:E.pending.error?"import failed":"importing…"}):E.kind==="dir"?f.jsx(Jn,{label:E.entry.name,hint:E.entry.isRepo?"git repo":void 0}):E.kind==="open"?f.jsx(Jn,{label:`open ${E.path}`,hint:"register with this daemon"}):E.kind==="clone"?f.jsx(Jn,{label:`clone ${E.name}`,hint:J8(E.url)}):E.kind==="new"?f.jsx(Jn,{label:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"plus",className:"icon-inline"}),"new project"]})}):E.kind==="disk"?f.jsx(Jn,{label:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:"folder",className:"icon-inline"}),"open folder"]})}):f.jsx(Jn,{label:`create ${E.name}`,hint:E.parent?`in ${E.parent}`:"new project"})})}function J8(e){const t=e.match(/^[a-z+]+:\/\/(?:[^@/]*@)?([^/:]+)/i)??e.match(/^[^@]+@([^:]+):/);return(t==null?void 0:t[1])??"git remote"}function eF(e){const t=[];if(e.pr){const r=e.pr.url;t.push({id:"open-pr",label:"open on GitHub",onClick:()=>window.open(r,"_blank")}),t.push({id:"copy-link",label:"copy link",onClick:()=>Zt(r)})}const n=[{id:"copy-ref",label:e.kind==="pr"?"copy PR number":"copy branch name",onClick:()=>Zt(e.ref)}];return Dn([t,n])}const tF=[],nF={branch:"branch",remote:"globe",pr:"pr"},ib={pr:0,branch:1,remote:2},rF={pr:"pull requests",branch:"branches",remote:"remote branches"};function oF({repoId:e}){const t=ct(),n=it(),r=L(h=>h.clientId),o=L(h=>h.refs[e]),a=L(h=>h.rows),l=h=>{var k;return((k=a.find(y=>y.id===h))==null?void 0:k.name)??"a worktree"},u=S.useCallback(h=>[...h].sort((k,y)=>ib[k.kind]-ib[y.kind]),[]),c=S.useCallback(h=>n==null?void 0:n.send({t:"search-refs",repoId:e,query:h.trim()}),[n,e]),p=h=>!o||o.query!==h.trim(),m=h=>h.openIn?`open in ${l(h.openIn)}`:h.merged?"merged":h.pr?`${h.pr.author}${h.pr.draft?" · draft":""}${h.pr.fork?" · fork":""}`:h.subject??"";return f.jsx($r,{items:(o==null?void 0:o.refs)??tF,filter:u,onQuery:c,keyOf:h=>`${h.kind}:${h.ref}`,rowClass:()=>"picker-row ref-row",onPick:h=>{h.openIn?t({a:"activate",id:h.openIn}):n==null||n.send({t:"open-ref",repoId:e,kind:h.kind,ref:h.ref,clientId:r,...h.pr?{pr:{title:h.pr.title,url:h.pr.url}}:{}}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:eF,groupOf:h=>h.kind,groupHead:(h,k)=>`${rF[h]} · ${k}`,placeholder:"open a branch or PR…",keys:h=>({nav:"moves",pick:h!=null&&h.openIn?"switches to it":"opens it as a worktree",back:"closes"}),empty:h=>p(h)?"looking…":h.trim()?"no branch or PR matches":"no unmerged branches or open PRs",row:h=>f.jsx(Jn,{label:f.jsxs(f.Fragment,{children:[f.jsx(St,{name:nF[h.kind],className:"icon-inline"}),f.jsx("span",{className:"ref-name",children:h.name})]}),hint:m(h)})})}const ab=[],hh=2;function sF({worktreeId:e}){const t=ct(),n=it(),r=f1(e).search,o=L(p=>p.layout.changes),a=L(p=>{var h;const m=(h=fn(p,e))==null?void 0:h.worktree;return m?m.path:null}),l=S.useCallback((p,m)=>m.trim().length>=hh?p:ab,[]),u=S.useCallback(p=>{const m=p.trim();m.length>=hh&&(n==null||n.send({t:"search",worktreeId:e,query:m}))},[n,e]),c=p=>!r||r.query.trim()!==p.trim();return f.jsx($r,{items:(r==null?void 0:r.hits)??ab,filter:l,onQuery:u,keyOf:p=>`${p.path}:${p.line}`,rowClass:()=>"search-hit",rowTitle:p=>`${p.path}:${p.line}`,onPick:p=>{nr({dispatch:t},{worktreeId:e,path:p.path,view:"file",line:{n:p.line}}),o||t({a:"toggle-changes"}),t({a:"close"})},onBack:()=>t({a:"close"}),rowMenu:p=>a?fs({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<hh?"type at least two characters":c(p)?"searching…":"no matches",footer:(p,m)=>r!=null&&r.truncated&&!c(p)&&m.length>0?f.jsxs("div",{className:"empty",children:["showing the first ",m.length,"; narrow the search"]}):null,row:p=>f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"search-loc",children:[p.path,":",p.line]}),f.jsx("span",{className:"search-text",children:p.text})]})})}const lb=e=>e.source==="file"?"~/.toyon/themes":e.source==="vscode"?"VS Code":"";function iF({slot:e}){const t=ct(),n=it(),r=L(j=>j.themePrefs),o=L(j=>j.themes),a=qm(),l=Pm(r,a),u=r[e==="theme"?l:e],c=()=>t({a:"close"}),p=()=>t({a:"close",back:!0}),m=j=>t({a:"preview-theme",theme:j}),[h,k]=S.useState(null),[y,v]=S.useState(null),x=(j,E)=>j[E??l]??j.dark??j.light??null,_=S.useMemo(()=>v$(o),[o]),N=S.useMemo(()=>o.filter(j=>j.kind===e),[o,e]);return gt([h,y],()=>{e==="theme"&&m(h?x(h,y):null)}),e!=="theme"?f.jsx($r,{items:N,filter:(j,E)=>j.filter(M=>Oi(E,M.name,M.id)),rowClass:()=>"picker-row",keyOf:j=>j.id,initialIndex:j=>j.findIndex(E=>E.id===u),onActive:m,onPick:j=>{n==null||n.send({t:"set-theme",prefs:{...r,[e]:j.id}}),c()},onBack:p,placeholder:`${e} slot override`,keys:{nav:"preview",pick:"keeps",back:"reverts"},empty:"no matching theme",row:j=>f.jsx(Jn,{label:j.name,current:j.id===u,hint:lb(j)})}):f.jsx($r,{items:_,filter:(j,E)=>j.filter(M=>{var K,U;return Oi(E,M.name,(K=M.dark)==null?void 0:K.name,(U=M.light)==null?void 0:U.name)}),rowClass:()=>"picker-row",keyOf:j=>{var E,M;return j.name+(((E=j.dark)==null?void 0:E.id)??((M=j.light)==null?void 0:M.id))},initialIndex:j=>j.findIndex(E=>{var M,K;return((M=E.dark)==null?void 0:M.id)===u||((K=E.light)==null?void 0:K.id)===u}),onActive:k,onSide:j=>{var E;j.dark&&j.light&&v((((E=x(j,y))==null?void 0:E.kind)??l)==="dark"?"light":"dark")},onPick:j=>{n==null||n.send({t:"set-theme",prefs:b$(r,j)}),c()},onBack:p,placeholder:"theme",keys:{nav:"preview",side:"dark/light",pick:"keeps",back:"reverts"},empty:"no matching theme",row:(j,E)=>{var R,I;const M=x(j,E?y:null),K=lb(j.dark??j.light),U=((R=j.dark)==null?void 0:R.id)===u||((I=j.light)==null?void 0:I.id)===u;return f.jsx(Jn,{label:j.name,current:U,hint:f.jsxs("span",{className:"theme-kinds",children:[K&&f.jsx("span",{children:K}),f.jsx("span",{className:"kind","data-state":rr({current:E&&(M==null?void 0:M.kind)==="dark"}),children:j.dark?"dark":""}),f.jsx("span",{className:"kind","data-state":rr({current:E&&(M==null?void 0:M.kind)==="light"}),children:j.light?"light":""})]})})}})}function kS(){const e=X2(),t=L(a=>a.frame==="phone"),n=Da(),r=L(a=>a.activeRepoId),o=L(a=>a.newProject);return f.jsxs(f.Fragment,{children:[(e==null?void 0:e.kind)==="quick-open"&&n&&f.jsx(h6,{worktreeId:n}),(e==null?void 0:e.kind)==="search"&&n&&f.jsx(sF,{worktreeId:n}),(e==null?void 0:e.kind)==="element-sources"&&f.jsx(R8,{worktreeId:e.worktreeId,hits:e.hits}),(e==null?void 0:e.kind)==="refs"&&r&&f.jsx(oF,{repoId:r}),(e==null?void 0:e.kind)==="chats"&&r&&f.jsx(I8,{repoId:r,scope:e.names?"names":"all"}),(e==null?void 0:e.kind)==="keys"&&f.jsx(g8,{}),(e==null?void 0:e.kind)==="pair"&&f.jsx(X8,{}),(e==null?void 0:e.kind)==="theme"&&f.jsx(iF,{slot:e.slot}),(e==null?void 0:e.kind)==="appearance"&&f.jsx(S8,{}),(e==null?void 0:e.kind)==="keep-awake"&&f.jsx(D8,{}),(e==null?void 0:e.kind)==="agent"&&f.jsx(x8,{}),(e==null?void 0:e.kind)==="agent-page"&&f.jsx(v8,{agentId:e.agent}),(e==null?void 0:e.kind)==="commands"&&!t&&f.jsx(eS,{}),(e==null?void 0:e.kind)==="projects"&&e.form!=="pill"&&f.jsx(Wg,{form:e.form},e.form),(e==null?void 0:e.kind)==="choose-folder"&&o&&f.jsx(L8,{project:o})]})}const ql="Lost the daemon; retrying",aF="Not run by Toyon",yS="new worktree",lF=new Set(["waiting","working","starting","failed","crashed"]);function hm(e,t){if(t.offline)return ql;if(!tr(e))return e.locked?`Held by ${e.lockReason??"another tool"}`:t.path;if(t.op)return Fm(t.op);if(Cr(e.worktree))return yS;const n=zm(e,t.needsSetup),r=e.worktree.lastTurn;return!lF.has(Ks(e))&&r?ug(r):t.at&&t.at!=="now"?`${n} · ${t.at}`:n}function cF(e,t){if(!tr(e)||t)return!1;const n=Ks(e);return(n==="idle"||n==="asleep")&&!e.unseen}function uF(e){const t=e.worktree.lastTurn,n=t?(fc(e)?tP:ug)(t):void 0,r=e.worktree.pr&&!e.worktree.landed?us(e.worktree.pr):void 0;return[n,r].filter(o=>!!o)}function dF(e,t,n,r){var p,m;let o;const a=(h,k)=>{k&&(!o||k>o.at)&&(o={title:h,at:k})};for(const h of e){const k=(p=h.worktree)==null?void 0:p.lands;h.worktree&&(k!=null&&k.length)&&a(h.worktree.title,(m=k[k.length-1])==null?void 0:m.at)}for(const h of t)a(h.title,h.landedAt);const l=o?`Landed ${o.title} ${qo(ro(o.at))}.`:void 0,u=n?Q1(r,n):null,c=u?Jo(`${u.charAt(0).toUpperCase()}${u.slice(1)}`):n!=null&&n.fetchedAt?`Level with origin, fetched ${qo(ro(n.fetchedAt))}.`:void 0;return[l,c].filter(h=>!!h)}const cb=160;function fF(e){var r;const t=(r=e.prompt)==null?void 0:r.replace(/\s+/g," ").trim();if(!t)return[];if(t.length<=cb)return[t];const n=t.slice(0,cb);return[`${n.slice(0,Math.max(n.lastIndexOf(" "),1)).trimEnd()}…`]}function pF(e){const n=[e.auto&&hF(e.auto,!!e.landed),e.cost!==void 0?yc(e.cost):void 0].filter(r=>!!r);return n.length?n:void 0}function hF(e,t){const{what:n,idle:r}=cT(e);return r?`${t?"":`${n}, `}${r} idle`:n}const ub=25;function mF(e,t){if(e.length<=ub+1)return{shown:e,rest:0};const n=e.slice(0,ub),r=t?e.find(o=>o.id===t):void 0;return r&&!n.includes(r)&&n.push(r),{shown:n,rest:e.length-n.length}}const gF=.5;function kF(e){const t=e.usage,n=t&&t.size>0?t.used/t.size:0,r=[n>=gF?`${Math.round(100*n)}% of context`:void 0,e.queued?`${e.queued} queued`:void 0,(t==null?void 0:t.cost)!==void 0?yc(t.cost):void 0].filter(o=>!!o);return r.length?r:void 0}const Fu=e=>e>999?"1k+":String(e);function wS({width:e,placement:t="strip"}){const n=t==="screen",r=Vs(),o=L(J=>J.chatSide)==="left"?"right":"left",a=ct(),l=it(),u=Qm(),c=u[0]&&Cr(u[0].worktree)?u[0]:null,p=c?u.slice(1):u,m=L(J=>ja(J,J.activeRepoId)),h=J=>c&&J.id===c.id&&m?{behind:m.behind,dirty:m.dirty}:J,[,k]=S.useState(0);S.useEffect(()=>{const J=setInterval(()=>k(we=>we+1),6e4);return()=>clearInterval(J)},[]);const y=Z2(),v=q2(),x=G2(),_=V2(),N=(J,we,Xe)=>{J.key!=="ArrowLeft"&&J.key!=="ArrowRight"||J.shiftKey||J.altKey||J.metaKey||J.ctrlKey||(J.preventDefault(),Jd([{depth:0,open:we}],0,J.key)&&a({a:Xe}))},j=$i(),E=L(J=>J.clientId),M=L(J=>J.frame),K=L(J=>J.activeRepoId),U=L(J=>J.connected);S.useEffect(()=>{l&&U&&K&&l.send({t:"list-archived",repoId:K})},[l,U,K]);const R=Da(),I=u1(),C=L(J=>J.layout),P=L(J=>J.railOpen),z=L(J=>J.railPeek),q=S.useRef(null),[se,pe]=S.useState(!1);gt([z],()=>{var J;z&&!n&&!r&&!((J=q.current)!=null&&J.matches(":hover"))&&pe(!0)}),S.useEffect(()=>{if(!se)return;let J=null;const we=Xe=>{if(!J){J={x:Xe.clientX,y:Xe.clientY};return}Math.abs(Xe.clientX-J.x)+Math.abs(Xe.clientY-J.y)<3||pe(!1)};return window.addEventListener("pointermove",we),()=>window.removeEventListener("pointermove",we)},[se]);const ue=L(J=>J.focusRail),xe=S.useRef(ue),oe=S.useRef(null);gt([ue],()=>{if(ue===xe.current)return;xe.current=ue;const J=requestAnimationFrame(()=>{var we,Xe;return(Xe=(we=oe.current)==null?void 0:we.querySelector('[data-state~="current"]'))==null?void 0:Xe.focus()});return()=>cancelAnimationFrame(J)});const A=L(J=>J.repos),X=L(J=>J.shipping),Z=J=>A.find(we=>we.id===J.repoId)??null,$=sn("rail"),V=y1(),de=L(J=>J.home),me=J=>{const we=J.worktree?J.worktree.path:J.path;return de&&we.startsWith(`${de}/`)?`~${we.slice(de.length)}`:we},[he,$e]=S.useState(!1),[ae,ve]=S.useState([]),Re=J=>{Wu(J.worktree)&&($e(!0),ve(we=>we.includes(J.worktree.id)?we.filter(Xe=>Xe!==J.worktree.id):[...we,J.worktree.id]))},ee=()=>{$e(!1),ve([])};gt([he],()=>{const J=we=>we.key==="Escape"&&ee();return he&&window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)});const Y=lg(l,a),Pe={sock:l,dispatch:a},We=J=>{$e(!0),ve(we=>J===R||we.includes(J)?we:[...we,J])},Fe=J=>tr(J)?G1(J,Z(J),{layout:C,shipping:X,frame:M},Pe,{graft:We,hostname:location.hostname}):KL(J,{clientId:E,frame:M},Pe,location.hostname),pt=mF(x,(j==null?void 0:j.id)??null),Ge=pt.shown.some(J=>(J.dirty??0)>0),vt=J=>f.jsxs("button",{type:"button",className:He("row row-edge row-quiet rail-disc-item rail-arch-item",(V==null?void 0:V.owner)==="rail"&&V.key===J.id&&"menu-open"),"data-state":rr({current:!n&&(j==null?void 0:j.id)===J.id}),...$t(EP(J),void 0,{placement:o,card:!0,detail:fF(J),aside:pF(J)}),onClick:()=>a({a:"open-archived",id:J.id}),...$.contextMenu(()=>Vu(J,{clientId:E,frame:M},Pe),J.id),children:[f.jsxs("span",{className:"rail-gut",onClick:r?we=>{we.stopPropagation(),$.openUnder(we.currentTarget,()=>Vu(J,{clientId:E,frame:M},Pe),J.id)}:void 0,children:[f.jsx("span",{className:"rail-at row-dim",children:ro(J.archivedAt)}),f.jsx("span",{className:"rail-more",...$t("Actions"),onClick:we=>{we.stopPropagation(),$.openUnder(we.currentTarget,()=>Vu(J,{clientId:E,frame:M},Pe),J.id)},children:f.jsx(St,{name:"more"})})]}),f.jsx("span",{className:"branch",children:J.title}),Ge&&f.jsx("span",{className:"rail-counts",children:f.jsx("span",{className:"rail-count row-dim","data-tip":J.dirty?`${J.dirty} uncommitted, kept`:void 0,children:J.dirty?`~${Fu(J.dirty)}`:""})}),J.auto?f.jsx("span",{className:"rail-glyph rail-auto row-dim",children:f.jsx(St,{name:"clock",className:"icon-inline"})}):f.jsx("span",{className:"dot"}),n&&f.jsx("span",{className:"rail-at rail-at-end row-dim",children:ro(J.archivedAt)})]},J.id),at=[...u,...y].map(h),qt=["ahead","dirty","behind"].filter(J=>at.some(we=>(we[J]??0)>0)),an=J=>{const we=qt.findIndex(Xe=>(J[Xe]??0)>0);return new Set(we<0?[]:qt.slice(we))},qe=J=>{var gn;const we=tr(J)?J:null,Xe=!!we&&Cr(we.worktree),et=h(J),Wt=A.find(kt=>kt.id===J.repoId)??null,Qt=Wt?Cd(Wt):"main",ge=Wt&&HT(Wt)&&(m!=null&&m.fetchedAt)?` as of ${Y1(m.fetchedAt)}`:"",Me=an(et),hn=!!et.ahead&&!et.dirty,It=J.id,Rt=(V==null?void 0:V.owner)==="rail"&&V.key===It,In=we&&he&&Wu(we.worktree)&&It!==R,Dt=zx(J,(gn=X[It])==null?void 0:gn.op);return f.jsxs("button",{type:"button",className:He("row row-edge",we?"rail-item":"row-quiet rail-disc-item",n&&cF(J,Dt)&&"row-quiet",Rt&&"menu-open"),"data-state":rr({current:!n&&It===R&&!j,checked:ae.includes(It)}),...we?$t(I?ql:Dt?Fm(Dt):zm(J,ud(Z(we))),void 0,{placement:o,card:!0,aside:kF(J),detail:Cr(we.worktree)?dF(u,x,m,Qt):uF(we),dot:I?void 0:Dt?"spinner":Ks(J)}):$t(I?ql:J.locked?`Held by ${J.lockReason??"another tool"}`:aF,void 0,{placement:o,card:!0,detail:me(J),dot:I||J.locked?void 0:"discovered"}),"data-wt":It,onKeyDown:kt=>{var Un,_t;if(!we||he||kt.key!=="ArrowUp"&&kt.key!=="ArrowDown"||kt.altKey||kt.ctrlKey||kt.metaKey)return;kt.preventDefault();const Gt=kt.key==="ArrowDown",tn=u.findIndex(Kt=>Kt.id===It),nn=u[tn+(Gt?1:-1)];nn&&(a({a:"activate",id:nn.id}),(_t=(Un=kt.currentTarget.parentElement)==null?void 0:Un.querySelector(`[data-wt="${nn.id}"]`))==null||_t.focus())},onClick:kt=>{we&&(he||kt.shiftKey)?It===R?$e(!0):Re(we):Xe&&!n?a({a:"open-draft"}):(a({a:"activate",id:It}),we&&!r&&a({a:"walked"}))},...$.contextMenu(()=>Fe(J),It),children:[f.jsx("span",{className:"rail-gut",onClick:r&&!he?kt=>{kt.stopPropagation(),$.openUnder(kt.currentTarget,()=>Fe(J),It)}:void 0,children:In?f.jsx("input",{type:"checkbox",className:"rail-graft-check",checked:ae.includes(It),readOnly:!0,tabIndex:-1}):!he&&f.jsxs(f.Fragment,{children:[we&&!Xe&&f.jsx("span",{className:"rail-at row-dim",children:ro(Gl(we.worktree))}),f.jsx("span",{className:"rail-more",...$t("Actions"),onClick:kt=>{kt.stopPropagation(),$.openUnder(kt.currentTarget,()=>Fe(J),It)},children:f.jsx(St,{name:"more"})})]})}),Xe?f.jsxs("span",{className:"branch rail-main-label",children:[f.jsx(St,{name:"plus",className:"icon-inline"}),"new worktree"]}):f.jsx("span",{className:He("branch",(we==null?void 0:we.worktree.unnamed)&&"row-dim"),children:Rh(J,we?Z(we):null)}),(we==null?void 0:we.worktree.mode)&&we.worktree.mode!=="auto"&&f.jsx("span",{className:"rail-badge badge-mode","data-tip":`${we.worktree.mode} mode: the agent waits for you`,children:we.worktree.mode}),we&&(()=>{const kt=Z(we),Gt=K1(we.worktree,kt);return Gt&&Gt!==(kt==null?void 0:kt.config.defaultProfile)?f.jsx("span",{className:"rail-badge badge-profile","data-tip":`runs the ${Gt} profile`,children:Gt}):null})(),(we==null?void 0:we.worktree.variant)&&f.jsxs("span",{className:"rail-badge badge-variant clickable","data-tip":"Keep this variant, archive the others",onClick:kt=>{kt.stopPropagation(),Y.pickVariant(we)},children:[f.jsxs("span",{className:"num",children:["v",we.worktree.variant.index,"/",we.worktree.variant.of]}),f.jsx("span",{className:"act",children:"pick"})]}),f.jsxs("span",{className:"rail-counts",children:[Me.has("ahead")&&f.jsx("span",{className:"rail-count badge-ahead","data-tip":et.ahead?`${et.ahead} ahead of ${Qt}`:void 0,children:et.ahead?`+${Fu(et.ahead)}`:""}),Me.has("dirty")&&!hn&&f.jsx("span",{className:"rail-count badge-dirty","data-tip":et.dirty?`${et.dirty} uncommitted${Xe?" on main":""}`:void 0,children:et.dirty?`~${Fu(et.dirty)}`:""}),Me.has("behind")&&f.jsx("span",{className:"rail-count rail-behind row-dim","data-tip":et.behind?`${et.behind} behind ${Xe?"origin":Qt}${Xe?"":ge}`:void 0,children:et.behind?Fu(et.behind):""}),n&&we&&f.jsx("span",{className:"rail-at row-dim",children:Xe?"":ro(Gl(we.worktree))})]}),(()=>{if(Dt)return f.jsx(kc,{size:"dot"});if(J.locked)return f.jsx("span",{className:"rail-glyph rail-lock row-dim",children:f.jsx(St,{name:"lock",className:"icon-inline"})});if(!we)return f.jsx("span",{className:"dot discovered"});const kt=he||I?null:Fx(J.procs),Gt=J.unseen?" unseen":"",tn=Ks(J);return Xe&&!kt&&tn!=="crashed"&&!I?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:`dot ${tn} rail-main-dot`}),f.jsx("span",{className:"rail-glyph rail-main-strip",children:f.jsx(St,{name:"plus"})})]}):!kt||tn!=="crashed"?f.jsx("span",{className:`dot ${tn}${Gt}`}):f.jsx("span",{className:`dot crashed clickable${Gt}`,...$t(kt.tip),onClick:nn=>{nn.stopPropagation(),a({a:"activate",id:It}),a({a:"term-stream",id:It,stream:kt.stream})}})})(),n&&f.jsx("span",{className:"rail-say row-dim",children:hm(J,{offline:I,needsSetup:ud(we?Z(we):null),path:me(J),op:Dt})})]},It)};return f.jsx("div",{ref:q,className:He("rail",n&&"rail-screen",!n&&(he||(V==null?void 0:V.owner)==="rail"||z)&&"hold",se&&"quiet",(n||P)&&"pinned",I&&"offline"),style:e!==void 0&&!n?{"--rail-width":`${e}px`}:void 0,onClick:r&&!n&&!P?J=>{J.target instanceof Element&&J.target.closest("button, .rail-gut")||a({a:"toggle-rail"})}:void 0,children:f.jsxs("div",{className:"rail-panel","data-tip":I?ql:void 0,"data-tip-placement":"follow",children:[f.jsxs("div",{className:"rail-list",ref:oe,children:[c&&!n&&qe(c),p.map(qe),he&&f.jsxs("div",{className:"rail-graft",children:[(()=>{const J=u.find(et=>et.worktree.id===R&&Wu(et.worktree)),we=ae.filter(et=>et!==(J==null?void 0:J.worktree.id)),Xe=we.map(et=>{var Wt;return((Wt=u.find(Qt=>Qt.worktree.id===et))==null?void 0:Wt.worktree.title)??et}).join(", ");return f.jsxs(ze,{size:"md",tone:"primary",disabled:!J||we.length===0,"data-tip":J?`Merge the checked worktrees into ${J.worktree.title} and remove them`:"Select a worktree to graft onto",onClick:()=>{J&&window.confirm(`Graft ${Xe} onto ${J.worktree.title}?
245
+
246
+ Their branches are merged in, then their directories and branches are removed.`)&&(l==null||l.send({t:"graft",targetId:J.worktree.id,sourceIds:we}),ee())},children:["graft ",we.length]})})(),f.jsxs(ze,{size:"md",disabled:!ae.some(J=>{var we;return(((we=u.find(Xe=>Xe.worktree.id===J))==null?void 0:we.behind)??0)>0}),"data-tip":"Pull main into every selected worktree that's behind",onClick:()=>{for(const J of ae){const we=u.find(Xe=>Xe.worktree.id===J);((we==null?void 0:we.behind)??0)>0&&Hs(l,a,{t:"sync-main",worktreeId:J})}ee()},children:[f.jsx(St,{name:"pull",className:"icon-inline"})," sync"]}),f.jsx(ze,{size:"md",tone:"danger",disabled:ae.length===0,"data-tip":"Archive all selected worktrees; their chats and work are kept",onClick:()=>{window.confirm(`Archive ${ae.length} worktree(s)?
247
+
248
+ Their directories and branches go. The chats, commits and any uncommitted changes are kept, and each can be restored.`)&&(Ti(l,a,ae),ee())},children:"archive…"}),f.jsx(At,{icon:"close",label:"Cancel",hint:"esc",onClick:ee})]}),!he&&y.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{className:"section-title section-row section-fold rail-disc-head","aria-expanded":v,...$t(`${y.length} worktree${y.length===1?"":"s"} here that Toyon did not make`,void 0,{placement:o}),onClick:()=>a({a:"toggle-discovered"}),onKeyDown:J=>N(J,v,"toggle-discovered"),children:[f.jsx("span",{className:"rail-gut",children:f.jsx(St,{name:"caret",className:He("icon-inline disc-caret",!v&&"shut")})}),f.jsx("span",{className:"rail-label",children:"discovered"})]}),v&&y.map(qe)]}),!he&&x.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{type:"button",className:"section-title section-row section-fold rail-disc-head","aria-expanded":_,...$t(`${x.length} archived worktree${x.length===1?"":"s"}, kept with ${x.length===1?"its chat":"their chats"}`,void 0,{placement:o}),onClick:()=>a({a:"toggle-archived"}),onKeyDown:J=>N(J,_,"toggle-archived"),children:[f.jsx("span",{className:"rail-gut",children:f.jsx(St,{name:"caret",className:He("icon-inline disc-caret",!_&&"shut")})}),f.jsx("span",{className:"rail-label",children:"archived"})]}),_&&pt.shown.map(vt),_&&pt.rest>0&&K&&f.jsxs("button",{type:"button",className:"row row-quiet rail-disc-item rail-arch-item",...$t("Find an older one by its name, branch or first message",void 0,{placement:o}),onClick:()=>a({a:"open",overlay:{kind:"chats",names:!0}}),children:[f.jsx("span",{className:"rail-gut"}),f.jsxs("span",{className:"branch row-dim",children:[pt.rest," more"]}),f.jsx("span",{className:"dot"})]})]})]}),!n&&f.jsx("div",{className:"rail-foot",children:f.jsx(At,{icon:"worktrees",label:"Worktree panel",hint:Et("rail"),tone:"chrome",on:P,onClick:()=>a({a:"toggle-rail"})})})]})})}function yF({screen:e,tabs:t,fold:n}){const r=ct(),o=L(P=>P.reading),a=za(),l=L(P=>P.repos),u=gs(),c=Da(),p=$i(),m=Xm(),h=Qm(),k=u1(),y=L$(h,c),v=h.find(P=>Cr(P.worktree)),x=e==="home",_=!x&&!p&&!!u&&Cr(u.worktree),N=L(P=>{var z;return _&&u?zx(u,(z=P.shipping[u.id])==null?void 0:z.op):null}),j=x?(a==null?void 0:a.name)??null:_?yS:(p==null?void 0:p.title)??(u==null?void 0:u.worktree.title)??(m==null?void 0:m.name)??null,E=h.filter(P=>!Cr(P.worktree)).length,M=x?E===0?"no worktrees yet":`${E} ${E===1?"worktree":"worktrees"}`:p?c_(p):_?k?ql:N?Fm(N):(a==null?void 0:a.name)??null:u?hm(u,{offline:k,needsSetup:ud(a),path:u.worktree.path,at:ro(Gl(u.worktree))}):m?hm(m,{offline:k,needsSetup:!1,path:m.path}):null,K=!x&&!p&&!!u&&Ks(u)==="waiting",U=L(P=>{var z;return((z=P.overlay)==null?void 0:z.kind)==="projects"&&P.overlay.form==="pill"}),R=L(P=>{var z;return((z=P.overlay)==null?void 0:z.kind)==="commands"}),I=f.jsxs("div",{className:"phone-title",children:[x&&l.length>1?f.jsxs("span",{className:"phone-drop phone-switch",children:[f.jsxs(ze,{tone:"chrome",on:U,onClick:()=>r({a:"toggle",overlay:{kind:"projects",form:"pill"}}),children:[f.jsx("span",{className:"phone-name",children:j}),f.jsx(St,{name:"caret",className:"icon-inline"})]}),U&&f.jsx(Wg,{form:"pill"})]}):f.jsx("span",{className:"phone-name",children:j}),M&&f.jsx("span",{className:He("phone-sub",K&&"phone-sub-asks"),children:M})]}),C=y&&f.jsxs(ze,{size:"md",tone:"primary",onClick:()=>{const P=Dm(h,c,1);P&&r({a:"activate",id:P.activate})},children:[y.n," ",y.tier]});return f.jsxs("div",{className:"phone-bar",children:[f.jsxs("div",{className:"phone-bar-row",children:[!x&&f.jsx(At,{icon:"back",label:"Worktrees",tone:"chrome",onClick:()=>r({a:"screen",to:"home"})}),t?f.jsx("div",{className:"phone-tabs",children:t}):I,!t&&C,x&&v&&f.jsx(At,{icon:"plus",label:"New worktree",tone:"chrome",onClick:()=>r({a:"activate",id:v.id})}),f.jsxs("span",{className:"phone-drop",children:[f.jsx(At,{icon:"more",label:"Menu",tone:"chrome",on:R,onClick:()=>r({a:"toggle",overlay:{kind:"commands"}})}),R&&f.jsx(eS,{anchored:{flip:"align",margin:6},trailing:f.jsx(At,{icon:"close",label:"Close",tone:"chrome",onClick:()=>r({a:"close"})})})]})]}),t&&!n&&f.jsx("div",{className:"phone-title-seat","data-away":o||void 0,children:f.jsxs("div",{className:"phone-title-strip",children:[I,C]})})]})}function wF({active:e,url:t,hidden:n}){return f.jsx("div",{className:"phone-preview",hidden:n,children:Zm(e)?f.jsx("iframe",{className:"phone-preview-frame",src:t,title:e.worktree.title}):f.jsx(Qs,{wide:!0,children:f.jsx("p",{className:"status-line",children:zm(e)})})})}const vF=S1();function bF(){const e=S.useRef(null);W2(e);const t=ct(),n=L(E=>E.screen),r=gs(),o=$i(),a=Xm(),l=L(E=>E.editor),u=L(E=>E.remote),c=mc(),p=L(E=>E.connected),m=L(E=>E.heard),h=L(E=>E.connectFailure),k=Vs(),y=H1({connected:p,heard:m,connectFailure:h,hasToken:vF,projectChord:Et("project"),title:(r==null?void 0:r.worktree.title)??null}),v=n!=="home"&&(r!==null||o!==null||a!==null),x=v&&!c&&!o?r:null,_=x?Ih(x.worktree.id,x.worktree.proxyPort,u):null,N=n==="preview"&&!x?"chat":n,j=[{id:"chat",label:"chat"},...x&&_?[{id:"preview",label:"preview",trail:f.jsx(At,{icon:"external",label:"Open in browser",tone:"chrome",onClick:()=>window.open(_,"_blank")})}]:[],{id:"changes",label:"code"}];return f.jsxs("div",{ref:e,className:"app phone","data-chat-side":"left","data-touch":k||void 0,"data-hover":!k||void 0,children:[f.jsx(D1,{}),f.jsx(U1,{}),f.jsx(yF,{screen:v?"chat":"home",fold:N!=="chat"||l!==null,tabs:v&&y===null&&f.jsx(Xd,{fill:!0,segmented:!0,owner:"phone-tabs",label:"worktree",items:j,current:N,onPick:E=>t({a:"screen",to:E})})}),f.jsx("div",{className:"phone-screen",children:f.jsxs("div",{className:"center-root",children:[y!==null?f.jsx(Qs,{wide:!0,children:f.jsx("p",{className:"status-line",children:y})}):v?l?f.jsx(aS,{editor:l,placement:"screen"}):N==="chat"?f.jsx(Zl,{placement:"screen",archived:o,found:a}):N==="changes"?f.jsx(l_,{placement:"screen"}):null:f.jsx(wS,{placement:"screen"}),x&&_&&f.jsx(wF,{active:x,url:_,hidden:N!=="preview"||l!==null},x.worktree.id),f.jsx(kS,{})]})})]})}const xF=640,_F=1e3,vS=`(max-width: ${xF}px), ((hover: none) and (max-width: ${_F}px))`,bS="(hover: none)",xS=()=>{var e;return(e=window.matchMedia)!=null&&e.call(window,vS).matches?"phone":"desk"},EF=()=>{var e;return((e=window.matchMedia)==null?void 0:e.call(window,bS).matches)??!1};function SF(e){const t=(o,a)=>{var c;const l=(c=window.matchMedia)==null?void 0:c.call(window,o);if(!l)return()=>{};const u=p=>a(p.matches);return l.addEventListener("change",u),()=>l.removeEventListener("change",u)},n=t(vS,o=>e.dispatch({a:"frame",v:o?"phone":"desk"})),r=t(bS,o=>e.dispatch({a:"touch",v:o}));return()=>{n(),r()}}function NF(){try{const e=localStorage.getItem(mt.theme);if(e){const t=JSON.parse(e);if(t!=null&&t.colors&&typeof t.colors.surface0=="string")return t}}catch{}return dc}function _S(e,t={}){var o;const n=document.documentElement;for(const[a,l]of Object.entries(g$(e)))n.style.setProperty(a,l);n.style.colorScheme=e.kind,n.dataset.theme=e.kind;const r=xS()==="phone"?e.colors.surface0:e.colors.surface1;if((o=document.querySelector('meta[name="theme-color"]'))==null||o.setAttribute("content",r),t.remember!==!1)try{localStorage.setItem(mt.theme,JSON.stringify(e))}catch{}}function ES(e){const t=Lm(e);return{type:"theme",accent:t,accentFg:E$(t)}}function TF(){var e;return((e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)??!0}const jF=12*36e5;function CF(){try{const e=localStorage.getItem(mt.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<jF?{dark:!t.dark,until:0}:null}catch{return null}}function AF(e){try{localStorage.setItem(mt.daylight,JSON.stringify(e))}catch{}}function IF(e){var r;const t=(r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)");if(!t)return()=>{};const n=o=>e(o.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}function mm(e,t){return[{id:"copy-name",label:"copy name",detail:e,onClick:()=>Zt(e)},{id:"copy-value",label:"copy value",detail:t,onClick:()=>Zt(t)}]}function gm(e){return[{id:"copy-value",label:"copy value",detail:e,onClick:()=>Zt(e)}]}function RF(e,t,{sock:n},r){return t?Dn([[{id:"source",label:"open source",onClick:r}],Ii(`${e.dir}/${t}`,()=>n==null?void 0:n.send({t:"reveal",worktreeId:e.id,path:t})),[{id:"copy-path",label:"copy path",onClick:()=>Zt(t)}]]):[]}function lc(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());if(!t)return null;const n=t[1],r=n.length===3||n.length===4?[...n].map(a=>a+a).join(""):n;if(r.length!==6&&r.length!==8)return null;const o=Number.parseInt(r.slice(0,6),16);return[o>>16&255,o>>8&255,o&255]}function OF(e){const t=/^#([0-9a-f]{3,8})$/i.exec(e.trim());return t?t[1].length===4||t[1].length===8:!1}function db([e,t,n]){const r=o=>{const a=o/255;return a<=.03928?a/12.92:((a+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function SS(e,t){if(OF(e))return null;const n=lc(e);if(!n)return null;const r=lc(t);if(!r)return null;const[o,a]=[db(n),db(r)];return`${((Math.max(o,a)+.05)/(Math.min(o,a)+.05)).toFixed(2)}:1`}function $F({worktreeId:e,height:t,full:n,onToggleFull:r,onDragStart:o}){const a=ct(),l=it(),u=L(p=>go(p,e).design);S.useEffect(()=>{u||l==null||l.send({t:"design-scan",worktreeId:e})},[u,e,l]),S.useEffect(()=>()=>Yt.post(e,{type:"highlight-clear"}),[e]);const c={outline:p=>Yt.post(e,p),clear:()=>Yt.post(e,{type:"highlight-clear"}),open:p=>nr({dispatch:a},{worktreeId:e,path:p})};return f.jsx(Ug,{kind:"design",className:He("design-pane",n&&"full"),height:n?void 0:t,resizable:!n,onDragStart:o,title:u?f.jsx("span",{children:DF(u)}):void 0,onClose:()=>a({a:"toggle-design"}),closeHint:Et("design"),full:n,onToggleFull:r,actions:f.jsxs(ze,{variant:"outline",onClick:()=>l==null?void 0:l.send({t:"design-scan",worktreeId:e}),"data-tip":"Scan this worktree again",children:[f.jsx(St,{name:"reload",className:"icon-inline"})," rescan"]}),children:u?f.jsxs("div",{className:"design-body",style:PF,onMouseLeave:c.clear,children:[u.tokens.length===0&&u.literals.length>0?f.jsx(WF,{literals:u.literals,outline:c.outline,clear:c.clear}):f.jsx(UF,{tokens:u.tokens,coverage:u.coverage,outline:c.outline,clear:c.clear}),f.jsx(JF,{index:u,outline:c.outline,clear:c.clear,onOpen:c.open}),f.jsx(e9,{index:u,outline:c.outline,clear:c.clear,onOpen:c.open})]}):f.jsx("div",{className:"empty",children:"reading the design system…"})})}const MF=720,LF=132,PF={"--design-column":`${MF}px`,"--design-cell":`${LF}px`};function DF(e){const t=Object.values(e.coverage.files).reduce((r,o)=>r+o,0),n=e.coverage.stylesheets;return`${t} file${t===1?"":"s"} read, ${n} stylesheet${n===1?"":"s"}`}const ya=e=>`${e} use${e===1?"":"s"}`;function lf({title:e,note:t,children:n}){return f.jsxs("section",{className:"design-section",children:[f.jsxs("h2",{className:"design-h",children:[e,t&&f.jsx("span",{className:"design-note",children:t})]}),n]})}function Nd({children:e}){return f.jsx("p",{className:"design-gap",children:e})}const zF=[{kind:"font",label:"type"},{kind:"color",label:"color"},{kind:"length",label:"size & radius"},{kind:"shadow",label:"shadow"},{kind:"other",label:"computed"}];function FF(e){return e.find(t=>t.kind==="color"&&lc(t.resolved??t.value)!==null)}function BF(e){if(e.stylesheets===0)return"No stylesheet was read, so there is no palette or type scale to show.";const t=e.files,n=(t.scss??0)+(t.sass??0)+(t.less??0)+(t.styl??0),r="No custom properties, and no colors or sizes written out in the stylesheets.";return n>0?`${r} Sass, Less and Stylus variables are not read yet.`:r}function UF({tokens:e,coverage:t,outline:n,clear:r}){const o=FF(e),a=o&&(o.resolved??o.value),l=new Map;for(const c of e){const p=(c.resolved??c.value).trim().toLowerCase();l.set(p,[...l.get(p)??[],c.name])}const u=c=>(l.get((c.resolved??c.value).trim().toLowerCase())??[]).filter(p=>p!==c.name);return f.jsx(lf,{title:"Tokens",children:e.length===0?f.jsx(Nd,{children:BF(t)}):zF.map(({kind:c,label:p})=>{const m=e.filter(k=>k.kind===c);if(m.length===0)return null;const h=TS(m.map(k=>k.value));return f.jsxs("div",{className:"design-group",children:[c!=="font"&&f.jsx("span",{className:"design-group-name",children:p}),c==="font"?f.jsx(jS,{groups:VF(m),outline:n,clear:r}):f.jsx("div",{className:"design-breakout",style:NS(m.length),children:f.jsx("div",{className:"design-grid",children:m.map(k=>{const y=k.resolved??k.value,v=k.kind==="color"&&a?SS(y,a):null;return f.jsx(CS,{kind:k.kind,name:k.name,lines:k.resolved?[k.value,k.resolved]:[k.value],actual:y,ratio:v,largest:h,tipText:QF(k,v,o,u(k)),menu:()=>mm(k.name,y),outline:n,clear:r},k.name)})})})]},c)})})}const HF=[{role:"color",kind:"color",label:"color"},{role:"radius",kind:"length",label:"radius"},{role:"shadow",kind:"shadow",label:"shadow"}];function WF({literals:e,outline:t,clear:n}){const r=e.find(a=>a.ground&&lc(a.value)!==null),o=YF(e);return f.jsxs(lf,{title:"Values",note:"written out in the rules; no custom properties",children:[o.length>0&&f.jsx("div",{className:"design-group",children:f.jsx(jS,{groups:o,outline:t,clear:n})}),HF.map(({role:a,kind:l,label:u})=>{const c=e.filter(m=>m.role===a);if(c.length===0)return null;const p=TS(c.map(m=>m.value));return f.jsxs("div",{className:"design-group",children:[f.jsx("span",{className:"design-group-name",children:u}),f.jsx("div",{className:"design-breakout",style:NS(c.length),children:f.jsx("div",{className:"design-grid",children:c.map(m=>{const h=l==="color"&&r?SS(m.value,r.value):null;return f.jsx(CS,{kind:l,name:m.value,lines:[ya(m.uses)],actual:m.value,ratio:h,largest:p,tipText:XF(m,h,r),menu:()=>gm(m.value),outline:t,clear:n},m.value)})})})]},a)})]})}function NS(e){const t="var(--design-cell)",n=`min(round(down, 100%, ${t}), calc(${e} * ${t}))`,r=`round(down, var(--design-column), ${t})`,o=`round(down, max(0px, calc((${n} - ${r}) / 2)), ${t})`;return{width:n,marginLeft:`max(0px, calc((100% - var(--design-column)) / 2 - ${o}))`}}function TS(e){return e.reduce((t,n)=>Math.max(t,Math.abs(Number.parseFloat(n))||0),0)}const KF=["color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline-color"];function ZF(e,t){if(!e)return[];const n=getComputedStyle(e);return t.map(r=>[r,n.getPropertyValue(r)])}const km=e=>(e.split(",")[0]??e).replace(/["']/g,"").trim();function qF(e){const t=/^[1-9]00\s+([\d.]+)px(?:\s*\/\s*([\d.]+)(px)?)?\s+(.+)$/.exec(e.trim());if(!t)return{family:km(e),size:null,lead:null};const n=Number(t[1]),r=t[2]?Number(t[2]):null,o=r===null?null:Math.round((t[3]?r:n*r)*100)/100;return{family:km(t[4]??""),size:n,lead:o}}function mh(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 GF(e,t){if(!e)return null;const n=Number.parseFloat(e),r=/^[\d.]+$/.test(e)?t*n:e.endsWith("px")?n:null;return r===null?null:Math.round(r*100)/100}function VF(e){const t=e.map(n=>({token:n,actual:n.resolved??n.value,...qF(n.resolved??n.value)}));return[...new Set(t.map(n=>n.family))].map(n=>{const r=t.filter(a=>a.family===n),o=r.find(a=>a.size===null);return{family:n,stack:o?o.actual:n,name:o==null?void 0:o.token.name,label:o?o.token.name:n,tipText:o?`${o.token.name}
249
+ ${o.actual}`:void 0,menu:()=>o?mm(o.token.name,o.actual):[],rows:r.filter(a=>a.size!==null).sort((a,l)=>(l.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}
250
+ ${a.actual}`,menu:()=>mm(a.token.name,a.actual)}))}})}function YF(e){const t=e.filter(o=>o.role==="family"),n=e.filter(o=>o.role==="size");return[...new Set([...t.map(o=>o.value),...n.map(o=>o.family??"initial")])].map(o=>{const a=t.find(u=>u.value===o),l=o==="initial"?"default face":km(o);return{family:l,stack:o,name:a?ya(a.uses):void 0,label:l,tipText:a?`${a.value}
251
+ ${ya(a.uses)}: ${a.selectors.join(", ")}`:void 0,menu:()=>a?gm(a.value):[],rows:n.filter(u=>(u.family??"initial")===o).sort((u,c)=>mh(c.value)-mh(u.value)).map(u=>{const c=mh(u.value),p=GF(u.lead,c),m=u.value.endsWith("px")?`${c}`:u.value;return{key:`${u.value}/${u.lead??""}`,sample:`${l} ${m}${p===null?"":`/${p}`}`,style:{fontFamily:o,fontSize:u.value,lineHeight:u.lead},name:ya(u.uses),label:u.value,tipText:`${u.value}${u.lead?` / ${u.lead}`:""}
252
+ ${ya(u.uses)}: ${u.selectors.join(", ")}`,menu:()=>gm(u.value)}})}})}function jS({groups:e,outline:t,clear:n}){const r=(a,l,u)=>t({type:"highlight-computed",props:ZF(a.currentTarget.querySelector(".design-face-sample"),l?["font-family","font-size","line-height"]:["font-family"]),match:"all",label:u}),o=sn("design");return f.jsx("div",{className:"design-faces",children:e.map(a=>f.jsxs("div",{className:"design-face-group",children:[f.jsxs("div",{className:"design-face-head row-edge",onMouseEnter:l=>r(l,!1,a.label),onMouseLeave:n,...o.contextMenu(a.menu),...a.tipText?$t(a.tipText,void 0,{placement:"follow"}):{},children:[f.jsx("span",{className:"design-face-sample design-face-family",style:{fontFamily:a.stack},children:a.family}),a.name&&f.jsx("span",{className:"design-face-name row-dim",children:a.name})]}),a.rows.map(l=>f.jsxs("div",{className:"design-face row-edge",onMouseEnter:u=>r(u,!0,l.label),onMouseLeave:n,...o.contextMenu(l.menu),...$t(l.tipText,void 0,{placement:"follow"}),children:[f.jsx("span",{className:"design-face-sample",style:l.style,children:l.sample}),f.jsx("span",{className:"design-face-name row-dim",children:l.name})]},l.key))]},a.stack))})}function CS({kind:e,name:t,lines:n,actual:r,ratio:o,largest:a,tipText:l,menu:u,outline:c,clear:p}){const m=e==="color"&&lc(r)!==null,h=e==="length"?Number.parseFloat(r):Number.NaN,k=sn("design");return f.jsxs("div",{className:"design-cell","data-kind":e,...k.contextMenu(u),onMouseEnter:m?y=>{const v=y.currentTarget.querySelector(".design-fill"),x=v?getComputedStyle(v).backgroundColor:"";c({type:"highlight-computed",props:KF.map(_=>[_,x]),match:"any",label:t})}:void 0,onMouseLeave:m?p:void 0,...$t(l),children:[e==="color"&&f.jsx("div",{className:"design-sample",children:m&&f.jsx("span",{className:"design-fill",style:{background:r}})}),f.jsxs("div",{className:"design-plate",children:[f.jsx("span",{className:"design-cell-name",children:t}),n.map((y,v)=>f.jsxs("span",{className:"design-cell-line",children:[f.jsx("span",{className:"design-cell-value",children:y}),v===0&&o&&f.jsx("span",{className:"design-cell-note",children:o})]},y)),Number.isFinite(h)&&a>0&&f.jsx("span",{className:"design-scale",style:{width:`${Math.max(2,Math.abs(h)/a*100)}%`}})]})]})}function QF(e,t,n,r=[]){const o=[e.name,e.resolved?`${e.value} resolves to ${e.resolved}`:e.value];if(r.length>0&&o.push(`same value as ${r.join(", ")}`),t&&n){const a=e.name===n.name;o.push(a?"the ground these ratios are measured against":`${t} against ${n.name}`)}return o.join(`
253
+ `)}function XF(e,t,n){const r=[e.value,`${ya(e.uses)}: ${e.selectors.join(", ")}`];return t&&n&&r.push(e===n?"the page background these ratios are measured against":`${t} against the page background`),r.join(`
254
+ `)}function AS({shared:e,rest:t}){return e.length===0?f.jsx("ul",{className:"design-rows",children:t}):f.jsxs(f.Fragment,{children:[f.jsx("ul",{className:"design-rows",children:e}),t.length>0&&f.jsxs("details",{className:"design-tail",children:[f.jsxs("summary",{className:"row-edge",children:[f.jsx("span",{className:"design-count row-dim",children:t.length}),"used once or never"]}),f.jsx("ul",{className:"design-rows",children:t})]})]})}function JF({index:e,outline:t,clear:n,onOpen:r}){const{components:o,typed:a}=e;if(o.length===0)return null;const l=o.filter(p=>p.imports>=2),u=o.filter(p=>p.imports<2),c=p=>f.jsx(IS,{count:p.imports,name:p.name,path:p.path,onEnter:()=>t({type:"highlight-file",path:p.path,ranges:null}),onLeave:n,onOpen:()=>r(p.path),children:p.variants.length>0&&f.jsx("span",{className:"design-variants",children:p.variants.map(m=>f.jsxs("span",{className:"design-variant",children:[m.prop,": ",m.values.join(" · ")]},m.prop))})},`${p.path}:${p.name}`);return f.jsxs(lf,{title:"Components",note:`${l.length} reused of ${o.length}`,children:[!a&&f.jsx(Nd,{children:"No TypeScript in this project, so the values each prop allows are not listed."}),f.jsx(AS,{shared:l.map(c),rest:u.map(c)})]})}function e9({index:e,outline:t,clear:n,onOpen:r}){const{classes:o,coverage:a}=e,l=o.filter(k=>k.uses>0),u=o.filter(k=>k.uses>=2),c=o.filter(k=>k.uses<2),p=u.filter(k=>k.unwrapped).length,m=o.length?`${u.length} reused of ${o.length}`+(p?`, ${p} with no component of their name`:""):void 0,h=k=>f.jsx(t9,{cls:k,outline:t,clear:n,onOpen:r},k.name);return f.jsx(lf,{title:"Classes",note:m,children:o.length===0?f.jsx(Nd,{children:"No stylesheet in this project defines a class. Utility-first CSS generates its own."}):l.length===0?f.jsx(Nd,{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."}):f.jsx(AS,{shared:u.map(h),rest:c.map(h)})})}function t9({cls:e,outline:t,clear:n,onOpen:r}){return f.jsx(IS,{count:e.uses,name:`.${e.name}`,path:e.path,onEnter:()=>t({type:"highlight-selector",selector:`.${e.name}`,label:`.${e.name}`}),onLeave:n,onOpen:()=>e.path&&r(e.path),children:e.unwrapped&&f.jsx("span",{className:"design-tag",children:"no component"})})}function IS({count:e,name:t,path:n,onEnter:r,onLeave:o,onOpen:a,children:l}){const u=gs(),c=it();ct();const p=sn("design");return f.jsx("li",{children:f.jsxs("button",{type:"button",className:"design-row row-edge",onMouseEnter:r,onFocus:r,onMouseLeave:o,onBlur:o,onClick:a,disabled:!n,...p.contextMenu(()=>u?RF({id:u.worktree.id,dir:u.worktree.path},n,{sock:c},a):[]),children:[f.jsx("span",{className:"design-count row-dim",children:e}),f.jsx("span",{className:"design-name",children:t}),f.jsx("span",{className:"design-path row-dim",children:n}),l]})})}function n9({worktreeId:e,procs:t,borrowed:n,login:r,current:o,onRestart:a}){const l=it();ct();const u={sock:l},c=(m,h)=>f.jsx(At,{icon:"reload",label:h,onClick:()=>a(m)}),p={id:ps,label:"login",tip:$t("The agent's login; it closes once you are in",void 0,{placement:"top"}),trail:c(ps,"Run the login again")};return r&&o===ps?[p]:[{id:po,label:"shell",tip:$t("A shell in this worktree",void 0,{placement:"top"}),menu:()=>bE(e,u),trail:c(po,"Restart the shell")},...r?[p]:[],...t.map(m=>({id:m.name,label:m.name,lead:f.jsx("span",{className:`dot ${m.status}`}),tip:$t(V$(m.status),void 0,{placement:"top",dot:m.status,name:m.name,detail:m.command,aside:[`:${m.port}`]}),menu:()=>$g(m,e,u),trail:c(m.name,`Restart ${m.name}`)})),...n.map(m=>({id:m,label:m,lead:f.jsx("span",{className:"dot borrowed"}),tip:$t(`${m} runs on main for every worktree; this one reaches it at its usual address`,void 0,{placement:"top"})}))]}const r9=S.lazy(()=>cm(()=>import("./XTerm-C9YH4Lh2.js"),__vite__mapDeps([3,4]))),o9=[];function s9({worktreeId:e,opened:t,height:n,onDragStart:r}){const o=ct(),a=it(),l=Hd(),u=L(z=>z.connected),c=L(z=>z.focusTerm),p=gs(),m=(p==null?void 0:p.procs)??[],h=(p==null?void 0:p.borrowed)??o9,k=(p==null?void 0:p.login)??!1,y=Ot(e,"termStream"),v=L(z=>{var q;return((q=z.termRun)==null?void 0:q.id)===e&&y===po?z.termRun.command:null}),[x,_]=S.useState(null),N=h.includes(y);S.useEffect(()=>{y===po||(y===ps?k:m.some(q=>q.name===y)||h.includes(y))||o({a:"term-stream",id:e,stream:po})},[m,h,k,y,e,o]);const j=z=>{z!==y&&(_(null),o({a:"term-stream",id:e,stream:z}))},E=S.useRef(!1),[M,K]=S.useState(0),U=z=>{z===po&&z===y&&(E.current=!0),a==null||a.send({t:"term-restart",worktreeId:e,stream:z}),z===ps&&z===y&&(_(null),K(q=>q+1))},R=(z,q)=>{if(z)return _(null);if(E.current){E.current=!1,K(se=>se+1);return}_({code:q})},I=n9({worktreeId:e,procs:m,borrowed:h,login:k,current:y,onRestart:U}),C=S.useRef(!t),P=!C.current;return S.useEffect(()=>{C.current=!1},[]),f.jsxs(Ug,{kind:"terminal",className:"term-pane",height:n,onDragStart:r,tabs:{items:I,current:y,onPick:j,font:"mono",owner:"terminal",label:"terminal streams"},onClose:()=>o({a:"toggle-terminal"}),closeHint:Et("terminal"),children:[f.jsxs("div",{className:"term-body",children:[N&&f.jsx(Ed,{pane:!0,title:`${y} runs on main`,body:"Every worktree reaches main's copy until its own changes touch it, or until asked.",action:f.jsx(ze,{variant:"outline",onClick:()=>a==null?void 0:a.send({t:"own-procs",worktreeId:e,names:[y]}),children:"run it here"})}),f.jsx(Bg,{pane:!0,children:f.jsx(S.Suspense,{fallback:f.jsx("div",{className:"empty",children:"loading terminal…"}),children:f.jsx(r9,{worktreeId:e,stream:y,theme:l,sock:a,connected:u,focusOnMount:P,focusReq:c,onAlive:R,run:v,onRan:()=>o({a:"term-ran"}),onEscape:()=>o({a:"toggle-terminal"})},`${y}:${M}`)})})]}),x!==null&&!N&&f.jsx(Ed,{pane:!0,title:y===po?"the shell exited":y===ps?"the login did not finish":`${y} exited`,body:x.code===void 0?void 0:`exit code ${x.code}`,action:f.jsx(ze,{variant:"outline",onClick:()=>U(y),children:"restart"})})]})}function i9(e){return e==="reserved"?"checking out a fresh worktree…":e==="warming"?"copying dependencies and running setup…":"starting dev servers…"}const a9="preview off; it starts when the agent writes a file";function l9({worktree:e,log:t}){const n=it(),r=ct(),o=e.procs,a=x=>n==null?void 0:n.send({t:"term-restart",worktreeId:e.id,stream:x.name}),l=o.some(x=>x.status==="crashed"||x.status==="unreachable"),u=L(x=>x.clientId),c=nc(e,"setup"),p=c&&c.status!=="terminated"?c:null,m=Aa(dg(p??void 0)?p==null?void 0:p.since:void 0),h=!!e.worktree.parked&&o.length===0,k=()=>n==null?void 0:n.send({t:"preview-start",worktreeId:e.id}),y=p&&(p.status==="running"||p.status==="detached"),v=()=>n==null?void 0:n.send({t:"fix-preview",worktreeId:e.id,clientId:u});return f.jsxs(Qs,{wide:!0,children:[o.length===0?f.jsx("div",{className:"status-line",children:p?f.jsx("span",{className:"live-text","data-tip":o_[p.status],children:Uh("setup",p,m)}):h?a9:i9(e.worktree.phase)}):f.jsx("ul",{className:"boot-procs",children:o.map(x=>f.jsxs("li",{className:He("boot-proc",(x.status==="crashed"||x.status==="unreachable")&&"boot-bad"),children:[f.jsx("span",{className:"boot-name",children:x.name}),f.jsx("span",{className:"boot-status",children:c9(x)}),(x.status==="crashed"||x.status==="unreachable")&&f.jsx(ze,{variant:"outline",onClick:()=>a(x),children:"restart"}),x.detail&&x.status!=="asleep"&&f.jsx("div",{className:"boot-detail",children:x.detail})]},x.name))}),h&&f.jsx("div",{className:"status-actions",children:f.jsx(ze,{variant:"outline",size:"lg",onClick:k,children:"start preview"})}),y&&f.jsx("div",{className:"status-actions",children:f.jsx(ze,{variant:"outline","data-tip":s_("setup"),onClick:()=>n==null?void 0:n.send({t:"run-stop",worktreeId:e.id,kind:"setup"}),children:"stop setup"})}),l&&f.jsxs("div",{className:"status-actions",children:[e.agent==="idle"&&f.jsx(ze,{variant:"outline",size:"lg",onClick:v,children:"ask the agent to fix it"}),f.jsx(ze,{onClick:()=>r({a:"open",overlay:{kind:"setup",repoId:e.repoId}}),children:"edit setup"})]}),t.length>0&&f.jsx("pre",{className:"status-tail",children:t.slice(-30).map(x=>`[${x.proc}] ${x.line}`).join(`
255
+ `)})]})}function c9(e){switch(e.status){case"starting":return`starting on :${e.port}`;case"running":return`running on :${e.boundPort??e.port}`;case"unreachable":return"never answered";case"crashed":return e.exitCode!=null?`crashed (exit ${e.exitCode})`:"crashed";case"stopped":return"stopped";case"asleep":return`asleep${e.detail?`: ${e.detail}`:""}; opens when you look`}}function u9(e,t,n){return!e||!t||e===t?null:n(e)===n(t)?e:null}function d9(e){return e.previewId===null?null:e.painted?e.previewId:e.ready?e.carry&&e.mounted.includes(e.carry)?e.carry:e.previewId:null}function f9(e){return e.available?e.sandboxed?`${e.name} works on it`:`${e.name} works on it, with no sandbox around its commands`:e.installing?`${e.name} is installing; it works on it once that lands`:e.onDemand&&e.reason==="not installed"?`${e.name} is a large download; press to fetch it`:`${e.reason??"not installed"}; press to install again`}function RS(){const e=it(),t=L(c=>c.agents),n=L(c=>c.agentChosen),[r,o]=S.useState(null),a=r?t.find(c=>c.id===r):void 0,l=c=>e==null?void 0:e.send({t:"set-default-agent",agent:c});if(gt([a==null?void 0:a.available,r],()=>{!r||!(a!=null&&a.available)||(l(r),o(null))}),n)return null;const u=c=>{if(c.available){l(c.id);return}o(c.id),c.installing||e==null||e.send({t:"install-agent",agent:c.id})};return f.jsxs("div",{className:"hint agent-ask",children:[f.jsx("span",{children:"which agent works on it?"}),t.map(c=>f.jsx(ze,{variant:"outline",size:"md",busy:c.installing||r===c.id,onClick:()=>u(c),...$t(f9(c)),children:c.name},c.id))]})}function p9({active:e}){const t=ct(),n=it(),r=Bn(),o=za(),a=L(c=>c.home),l=e.worktree.title,u=()=>{o!=null&&o.made&&(t({a:"new-project",v:{...Wm({mode:o.made==="git"?"init":"create",name:o.name,parent:mS(o.path,a)??o.path}),phase:"unmaking",repoId:o.id,prompt:go(r.getState(),e.worktree.id).draft}}),n==null||n.send({t:"unmake-repo",repoId:o.id}))};return f.jsxs(Qs,{anchor:"line",children:[f.jsx("p",{className:"form-title",children:o!=null&&o.made?f.jsx(ze,{variant:"inline",onClick:u,...$t("Rename or move this project"),children:l}):l}),f.jsx(RS,{}),f.jsx("div",{className:"form-body form-body-lg",children:f.jsx(Qu,{active:e,greenfield:!0})})]})}function h9({pending:e}){const t=ct(),n=it(),r=!!e.error,o=()=>{n==null||n.send({t:"cancel-import",id:e.id}),t({a:"watch-import",id:null})},a=S.useRef(null);return S.useEffect(()=>{var l;return(l=a.current)==null?void 0:l.scrollTo({top:a.current.scrollHeight})},[e.lines.length]),f.jsxs(Qs,{wide:!0,children:[f.jsxs("p",{className:"status-line",children:[r?"could not import":"importing"," ",e.name]}),f.jsxs("p",{children:["from ",f.jsx("code",{children:e.url})," into ",f.jsx("code",{children:e.parent})]}),r?f.jsx("p",{className:"import-error",children:e.error}):f.jsx("p",{className:"hint",children:"the whole history is cloned, so worktrees, land and graft all work on it straight away."}),f.jsx("div",{className:"status-tail",ref:a,children:e.lines.length===0&&!r?f.jsx("span",{className:"import-idle",children:"starting git…"}):e.lines.map((l,u)=>f.jsx("div",{children:l},u))}),f.jsx("div",{className:"status-actions",children:f.jsx(ze,{variant:"outline",size:"lg",onClick:o,children:r?"dismiss":"stop"})})]})}const m9=150,g9=/^[^\s@]+@[^\s@]+$/,k9=14,fb=[];function y9({project:e}){var ee;const t=ct(),n=it(),r=L(Y=>Y.repos),o=L(Y=>Y.home),a=L(Y=>Y.folderDialog),l=L(Y=>Y.gitIdentity),u=L(Y=>Y.choosingFolder),c=L(Y=>Y.chosenFolder),p=L(Y=>Y.paths),m=L(Y=>Y.agents),h=L(Y=>Y.defaultAgent),k=L(Y=>Y.agentChosen),[y,v]=S.useState({name:"",email:""}),[x,_]=S.useState(null),[N,j]=S.useState(null),E=S.useRef(null),M=S.useRef(null),{mode:K,name:U,parent:R,prompt:I}=e,C=K==="clone",P=K==="init",z=e.phase==="editing",q=U.trim(),se=P||!q?null:Jl(U),pe=!P&&q&&!se?hS(R,q):null,ue=pm(R,o),xe=pe!==null&&p.query===pe&&((ee=p.target)==null?void 0:ee.exists)===!0,oe=!l&&!C,A=!oe||y.name.trim()!==""&&g9.test(y.email.trim()),X=z&&!x&&(P||q!==""&&!se&&!xe)&&A&&k,Z=m.find(Y=>Y.id===h),[$,V]=PE(h),[de,me]=LE(h),he=(Y,Pe)=>{if(Y===h){V(Pe);return}DE(Y,Pe),n==null||n.send({t:"set-default-agent",agent:Y})};S.useEffect(()=>{if(!pe)return;const Y=setTimeout(()=>n==null?void 0:n.send({t:"browse-path",path:pe}),m9);return()=>clearTimeout(Y)},[pe,n]),gt([e.phase],()=>{var Y;e.phase==="editing"&&((Y=E.current)==null||Y.focus())}),gt([K,U,R],()=>j(null));const $e=()=>{X&&(t({a:"open-repo"}),t({a:"new-project-set",v:{phase:"creating"}}),n==null||n.send({t:"create-repo",mode:K,parent:R.trim(),name:q,...C&&e.url?{url:e.url}:{},...oe?{identity:{name:y.name.trim(),email:y.email.trim()}}:{}}))},ae=Y=>{const Pe=r.find(We=>We.path===ic(Y,o));if(Pe){t({a:"activate-repo",id:Pe.id});return}t({a:"open-repo"}),n==null||n.send({t:"register-repo",path:Y})},ve=Y=>{j(null),a?(t({a:"choosing-folder",v:Y}),n==null||n.send({t:"choose-folder",start:R,purpose:Y})):t(Y==="location"?{a:"open",overlay:{kind:"choose-folder"}}:{a:"open",overlay:{kind:"projects",form:"disk"}})};gt([c==null?void 0:c.seq],()=>{var Pe,We;if(!u||!c)return;t({a:"choosing-folder",v:!1});const Y=c.folder;if(!Y){(Pe=E.current)==null||Pe.focus();return}if(u==="open"&&Y.kind==="project"){ae(Y.path);return}if(u==="open"&&Y.kind==="folder"){j("that folder has files but is not a project yet; choose a project, or an empty folder to start one");return}if(_(Y.kind==="project"?Y.path:null),Y.kind!=="project"){if(Y.kind==="empty"&&!C){const Fe=fS(Y.path);t({a:"new-project-set",v:{mode:"init",parent:Fe.parent,name:Fe.name}});return}t({a:"new-project-set",v:{mode:C?"clone":"create",parent:Y.path}}),(We=E.current)==null||We.focus()}});const Re=N??(P?"the empty folder you chose becomes the project":x?"the folder you chose is already a project: open it, or choose another":xe?`${ue} already has a folder called ${q}`:se);return f.jsxs(Qs,{anchor:"line",children:[C&&f.jsx("p",{className:"new-project-url",children:e.url}),f.jsxs("div",{className:"form-head",children:[P?f.jsx("p",{className:"form-title",children:U}):f.jsx(Mo,{ref:E,bare:!0,font:"lead",className:"new-project-field",autoFocus:!0,spellCheck:!1,autoComplete:"off",value:U,placeholder:"Project name",disabled:!z,style:{width:`${Math.max(U.length+1,k9)}ch`},onChange:Y=>t({a:"new-project-set",v:{name:Y.target.value}}),onKeyDown:Y=>{var Pe;Y.key==="Enter"&&(Y.preventDefault(),(Pe=M.current)==null||Pe.focus())}}),f.jsxs("span",{className:"new-project-where",children:[f.jsx("span",{className:"hint",children:"in"}),f.jsx("span",{className:"new-project-parent",...$t(R),children:ue}),f.jsx(At,{icon:"folder",label:a?"Choose in Finder":"Choose a folder",className:"new-project-folder",on:u==="location",disabled:!z,onClick:()=>ve("location")})]})]}),Re&&f.jsx("p",{className:"hint",children:Re}),f.jsx(RS,{}),f.jsx("div",{className:"form-body",children:f.jsx(Ia,{ref:M,bare:!0,font:"ui",value:I,placeholder:`describe ${q||"the app"}…`,disabled:!z,onChange:Y=>t({a:"new-project-set",v:{prompt:Y.target.value}}),onKeyDown:Y=>{Y.key!=="Enter"||Y.shiftKey||(Y.preventDefault(),$e())}})}),f.jsxs("div",{className:"hint form-knobs",children:[m.length>1?f.jsx(zE,{agents:m,agent:h,model:$,onChange:he}):f.jsx(sm,{models:(Z==null?void 0:Z.models)??fb,value:$,onChange:V}),f.jsx(om,{efforts:(Z==null?void 0:Z.efforts)??fb,value:de,onChange:me}),x?f.jsx(ze,{variant:"outline",size:"lg",className:"form-go",autoFocus:!0,onClick:()=>ae(x),children:"open it"}):f.jsx(ze,{variant:"outline",size:"lg",className:"form-go",busy:e.phase==="creating",disabled:!X,onClick:$e,...$t(k?C?"Clone the project":I.trim()?"Make it and start on this":"Make the project":"Choose an agent first","⏎"),children:C?"clone":"create"})]}),e.error&&f.jsx("p",{className:"hint",role:"status",children:e.error}),oe&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"new-project-identity",children:[f.jsx(Mo,{size:"md",font:"ui",rule:!0,value:y.name,placeholder:"Your name",autoComplete:"name",disabled:!z,onChange:Y=>v({...y,name:Y.target.value})}),f.jsx(Mo,{size:"md",font:"ui",rule:!0,type:"email",value:y.email,placeholder:"Email",autoComplete:"email",disabled:!z,onChange:Y=>v({...y,email:Y.target.value})})]}),f.jsx("p",{className:"hint",children:"git labels the work you save with these, and asks only once"})]}),!C&&z&&f.jsx(ze,{tone:"quiet",className:"new-project-open",onClick:()=>ve("open"),children:"or open a folder you already have"})]})}function pa({label:e,hint:t,children:n}){return f.jsxs("label",{className:"form-row",children:[f.jsx("span",{className:"form-label",children:e}),f.jsxs("div",{className:"form-control",children:[n,t&&f.jsx("span",{className:"hint",children:t})]})]})}function w9(e,t,n){const r=[n.envUrl?`\`${n.envUrl.name}\` in \`${n.envUrl.file}\``:null,n.compose?`the compose stack in \`${n.compose}\``:null].filter(Boolean).join(" and ");return[`Toyon runs several worktrees of this repo (${e.name}) at once, each with its own copy of the code, and right now they would all share ${r}: a migration run in one worktree changes the database every other worktree is using.`,"",`Give each worktree its own. Every command Toyon runs gets \`TOYON_WORKTREE\` (the worktree's id, empty in the main checkout, which never runs setup) and \`TOYON_ROOT\` (the main checkout). Edit \`${t}\` so that:`,'- `setup` makes the worktree\'s own database with the same schema and seed data. Postgres refuses to copy a database with connections open, so copy from a template nothing serves: `createdb -T <db>_template "<db>_$TOYON_WORKTREE"`, making `<db>_template` once from the seed if it does not exist. Keep it seed-sized, since every worktree copies it. A hosted database that branches (the repo already uses one, or its README says so) gets a branch named for the worktree instead. A compose stack: bring it up under `-p "<name>_$TOYON_WORKTREE"` and seed it the way the README does.',"- `teardown` drops it again (`dropdb --if-exists ...`, the branch deleted, or `docker compose -p ... down -v`).","- the running commands point at it, with the base database in the main checkout: put the URL in front of the command in `run`, or in a profile's `env`, named `<db>${TOYON_WORKTREE:+_$TOYON_WORKTREE}`. `setup` does not see what `run` sets, so a migration step in `setup` needs the URL in front of it too.",'- a database container the worktrees share (each with its own database inside it) is marked `{ "cmd": ..., "from": "trunk", "paths": [] }` in `run`, so the main checkout runs it once for everyone.',"","Read the README and the existing env files for the database's name and credentials. Do not run any migration yourself, and do not start any server; Toyon picks the file up as soon as it is written."].join(`
256
+ `)}function v9(e,t){return[`This repo (${e.name}) has no Toyon settings yet, so Toyon does not know how to install its dependencies or start its dev server.`,"",`Work it out from the repo itself (package manager, scripts, framework, a README) and write \`${t}\` in this shape:`,"```json",'{ "setup": ["<install command>"], "run": { "web": "<start command>" } }',"```",'`setup` runs once in each new worktree. A worktree starts with the branch\'s files only: `node_modules` and the `.env` files are copied in for it, but any other gitignored file the project needs (a local database, a test cache such as `.testmondata`) is not, so add a `cp` from `$TOYON_ROOT`, the main checkout, when you find one in `.gitignore`. Never copy a virtualenv or another dependency tree that holds absolute paths; reinstall it instead. Every command in `run` must run in the foreground and listen on the port in the PORT environment variable, which Toyon sets per worktree; a tool that takes its port from a flag needs the flag (Vite: `--port $PORT --strictPort`, and with npm the `--` before it). Name one entry per server if there are several. If the project has nothing to run (a library, a CLI), write `"run": {}` and say so. Do not start any server yourself; toyon picks the file up as soon as it is written.'].join(`
257
+ `)}let b9=1;const gh=(e,t,n=!1)=>({id:b9++,name:e,cmd:t,shared:n}),x9=[{id:"shared",label:"committed",description:"in the repo; everyone who opens it gets these settings"},{id:"local",label:"kept local",description:"in a file git never sees; for when only you use Toyon here"}];function _9({repo:e,onClose:t}){const n=it(),r=Bn(),o=L(ae=>ae.clientId),a=L(ae=>ae.rows.find(ve=>{var Re;return tr(ve)&&ve.id===((Re=ja(ae,e.id))==null?void 0:Re.id)})??null),l=L(ae=>{var ve;return((ve=ja(ae,e.id))==null?void 0:ve.id)??null});S.useEffect(()=>{if(!t)return;const ae=ve=>ve.key==="Escape"&&t();return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[t]);const[u]=S.useState(()=>Object.keys(e.config.run).length>0),[c,p]=S.useState(()=>{const ae=Object.entries(e.config.run).map(([ve,Re])=>gh(ve,Ab(Re),TT(Re)));return ae.length>0?ae:[gh("web","")]}),[m,h]=S.useState(()=>(e.config.setup??[]).join(`
258
+ `)),[k,y]=S.useState(()=>(e.config.teardown??[]).join(`
259
+ `)),[v,x]=S.useState(()=>e.config.check??""),[_,N]=S.useState(()=>_i(e.config).land),[j,E]=S.useState(()=>_i(e.config).automerge),[M,K]=S.useState(()=>_i(e.config).merge??"default"),[U,R]=S.useState(()=>AT(e.configFile)),I=IT(e.configFile,U),C=!!e.remote&&_==="pr",P=c.length>1,z=c.some(ae=>ae.name.trim()&&ae.cmd.trim()),se=!!a&&!t&&!u&&!z,pe=(ae,ve)=>p(c.map((Re,ee)=>ee===ae?{...Re,...ve}:Re)),ue=ae=>ae.split(`
260
+ `).map(ve=>ve.trim()).filter(Boolean),xe=()=>ue(m),oe=()=>ue(k),A=()=>{const{check:ae,land:ve,teardown:Re,...ee}=e.config,Y=e.remote?_:vh,Pe=M==="default"||Y!=="pr"&&M===bh?void 0:M,We={...Y!==vh?{route:Y}:{},...Y==="pr"&&j?{automerge:!0}:{},...Pe?{method:Pe}:{}};return{...ee,setup:xe(),...oe().length>0?{teardown:oe()}:{},...v.trim()?{check:v.trim()}:{},...Object.keys(We).length>0?{land:We}:{}}},X=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...A(),run:Object.fromEntries(c.filter(ae=>ae.name.trim()&&ae.cmd.trim()).map((ae,ve)=>[ae.name.trim(),ae.shared&&ve>0?{cmd:ae.cmd.trim(),from:"trunk"}:ae.cmd.trim()]))},kind:U}),t==null||t()},Z=()=>{n==null||n.send({t:"confirm-config",repoId:e.id,config:{...A(),run:{}},kind:U}),t==null||t()},$=()=>n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:v9(e,I)}),V=e.services,de=[m,k,...c.map(ae=>ae.cmd)].some(ae=>ae.includes("TOYON_WORKTREE"))||jT(e.config),me=V?[V.envUrl?`the database at ${V.envUrl.name} in ${V.envUrl.file}`:null,V.compose?`the stack in ${V.compose}`:null].filter(Boolean).join(" and "):"",he=()=>V&&(n==null?void 0:n.send({t:"create-worktree",clientId:o,repoId:e.id,prompt:w9(e,I,V)})),$e=(ae,ve)=>f.jsxs("div",{className:"setup-proc",children:[P&&f.jsx(Mo,{size:"md",rule:!0,className:"setup-name",value:ae.name,placeholder:"name",...$t("Process name, shown in the status bar"),onChange:Re=>pe(ve,{name:Re.target.value})}),f.jsx(Mo,{size:"md",rule:!0,className:"setup-cmd",value:ae.cmd,placeholder:"npm run dev",onChange:Re=>pe(ve,{cmd:Re.target.value})}),P&&f.jsx(At,{icon:"close",label:"Remove",onClick:()=>p(c.filter((Re,ee)=>ee!==ve))}),P&&ve>0&&f.jsx(sS,{className:"setup-shared",checked:ae.shared,onChange:Re=>pe(ve,{shared:Re.target.checked}),tip:"Main runs it once for every worktree; a worktree whose changes touch it runs its own",children:"shared from main"})]},ae.id);return f.jsxs(Qs,{children:[f.jsxs("p",{className:"form-title",children:["how does ",e.name," start?"]}),V&&!de&&f.jsxs("p",{className:"hint setup-shared-note",children:["Worktrees will share ",me,", migrations included."," ",f.jsx(ze,{tone:"quiet",disabled:!a,onClick:he,children:"ask the agent to keep them apart"})]}),f.jsx(pa,{label:"install",hint:"once per new worktree; one command per line",children:f.jsx(Ia,{size:"md",rule:!0,rows:Math.max(1,m.split(`
261
+ `).length),value:m,placeholder:"bun install",onChange:ae=>h(ae.target.value)})}),f.jsx(pa,{label:"remove",hint:"once when a worktree goes, before its directory does; one command per line",children:f.jsx(Ia,{size:"md",rule:!0,rows:Math.max(1,k.split(`
262
+ `).length),value:k,placeholder:'dropdb --if-exists "app_$TOYON_WORKTREE"',onChange:ae=>y(ae.target.value)})}),f.jsx(pa,{label:"check",hint:"runs after each of the agent's turns; the work lands only when it passes",children:f.jsx(Mo,{size:"md",rule:!0,value:v,placeholder:"bun run check",onChange:ae=>x(ae.target.value)})}),e.remote&&f.jsx(pa,{label:"land",hint:"where a worktree's finished work goes; one way per repo",children:f.jsxs("div",{className:"setup-land",children:[f.jsx(Bs,{value:_,options:FT.map(ae=>({id:ae.id,label:ae.name,description:ae.description})),onChange:N,hint:"where the work goes",placeholder:"where work lands"}),C&&f.jsx(Bs,{value:j?"github":"you",options:UT.map(ae=>({id:ae.id,label:ae.name,description:ae.description})),onChange:ae=>E(ae==="github"),hint:"who merges the pull request",placeholder:"who merges it"})]})}),f.jsx(pa,{label:"merge",hint:C?"how GitHub merges the pull request; only what the repo allows":"how the commits arrive on main",children:f.jsx(Bs,{value:M==="default"&&!C?bh:M,options:[...C?[{id:"default",label:"what the repo allows",description:"the repo's allowed methods on GitHub: squash, else a merge commit, else rebase"}]:[],...BT.map(ae=>({id:ae.id,label:ae.name,description:ae.description}))],onChange:K,hint:"how the commits arrive on main",placeholder:"how the commits arrive"})}),f.jsx(pa,{label:"start",hint:f.jsxs(f.Fragment,{children:["must listen on ",f.jsx("code",{...$t("Toyon sets a different port for each worktree"),children:"$PORT"}),e.guess&&l&&f.jsxs(f.Fragment,{children:[" · from ",f.jsx(ze,{mono:!0,tone:"quiet",...$t(`open ${e.guess} in the editor pane`),onClick:()=>Ra(r,n,l,e.guess??"",1),children:e.guess})]})]}),children:c[0]&&$e(c[0],0)}),c.slice(1).map((ae,ve)=>f.jsxs("div",{className:"form-row",children:[f.jsx("span",{className:"form-label"}),f.jsx("div",{className:"form-control",children:$e(ae,ve+1)})]},ae.id)),f.jsxs("div",{className:"form-row",children:[f.jsx("span",{className:"form-label"}),f.jsxs(ze,{tone:"quiet",onClick:()=>p([...c,gh("","")]),children:[f.jsx(St,{name:"plus",className:"icon-inline"})," another process"]})]}),f.jsxs("div",{className:"form-knobs",children:[f.jsx(Bs,{value:U,options:x9,onChange:R,hint:"whether the settings file is committed with the repo or kept out of git",placeholder:"committed or kept local"}),f.jsx("span",{className:"form-sign",children:I}),t&&f.jsx(ze,{onClick:t,children:"cancel"}),(!u||t)&&f.jsx(ze,{...$t("This project has no dev server: chat, changes and the terminal work, the preview stays empty"),onClick:Z,children:"no dev server"}),se&&a?f.jsx(ze,{variant:"outline",size:"lg",disabled:a.agent!=="idle",...$t("The agent reads the repo and writes the settings file; the daemon picks it up as soon as it lands"),onClick:$,children:"let the agent work it out"}):f.jsxs(ze,{variant:"outline",size:"lg",disabled:!z,...t?$t("Restarts every worktree of this repo. Profiles and other keys in the file are kept."):{},onClick:X,children:[t?"save + restart":"start"," ",f.jsx(St,{name:"forward",className:"icon-inline"})]})]})]})}const pb={title:"Toyon was updated",waiting:"Restarting Toyon. This page reloads when it is back."},E9=1e3,hb={held:[],asking:[],seen:[]};async function mb(e,t){for(;;){await new Promise(o=>setTimeout(o,E9));const[n,r]=await Promise.all([zh(),N1()]);if(n!==null&&n!==e)break;t(r??{waiting:[],asking:[]})}window.location.reload()}function S9(){const[e,t]=S.useState(!0),[n,r]=S.useState(null),[o,a]=S.useState(hb),l=S.useRef(null),u=S.useCallback(h=>a(k=>({held:h.waiting,asking:h.asking,seen:o8(k.seen,h.waiting)})),[]),c=S.useCallback(async h=>{t(!0),r(null);const k=l.current??{pid:await zh()},y=await IM(h);if(y){t(l.current!==null),r(y);return}h&&a(hb),!l.current&&(l.current=k,mb(k.pid,u))},[u]);S.useEffect(()=>{let h=!0;return(async()=>{const[k,y]=await Promise.all([zh(),N1()]);if(!(!h||l.current)){if(y===null){c(!1);return}l.current={pid:k},u(y),mb(k,u)}})(),()=>{h=!1}},[u,c]);const p=e&&o.held.length>0,m=p?s8(o.seen,o.held,o.asking):[];return f.jsx(Ed,{title:pb.title,body:n??(p?i8(o.held.length,o.seen.length):pb.waiting),action:p?f.jsx(ze,{variant:"outline",onClick:()=>void c(!0),children:"restart now"}):f.jsx(ze,{variant:"outline",busy:e,onClick:()=>void c(!1),children:"restart"}),children:m.length>0&&f.jsx("ul",{className:"crash-list",children:m.map((h,k)=>f.jsxs("li",{className:He("crash-row",h.dot!=="working"&&"row-dim"),children:[f.jsx("span",{className:He("dot",h.dot)}),f.jsx("span",{className:"crash-row-name",children:h.name}),h.note&&f.jsx("span",{className:"crash-row-note",children:h.note})]},k))})})}const N9=1500,T9={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};class j9{constructor(t,n,r=T9){jt(this,"frames",new Map);this.send=t,this.sendTitle=n,this.timers=r}note(t,n,r){const o=this.frame(t);o.timer!==null&&(this.timers.clear(o.timer),o.timer=null),o.pending=null,r!==void 0&&(o.title=Gw(r));const a=Pd(n);if(!a){o.sent=null;return}if(a===o.sent){this.renamed(t,o);return}o.pending=a,o.timer=this.timers.set(()=>{o.timer=null,o.pending=null,o.sent=a,o.sentTitle=o.title,this.send(t,a,o.title)},N9)}title(t,n){const r=this.frame(t);r.title=Gw(n),r.pending===null&&this.renamed(t,r)}dispose(){for(const t of this.frames.values())t.timer!==null&&this.timers.clear(t.timer);this.frames.clear()}frame(t){let n=this.frames.get(t);return n||(n={sent:null,pending:null,timer:null},this.frames.set(t,n)),n}renamed(t,n){!n.sent||!n.title||n.title===n.sentTitle||(n.sentTitle=n.title,this.sendTitle(t,n.sent,n.title))}}const C9=S1(),A9=2*6e4;function gb(e){e==null||e.setAttribute("src",e.src)}const I9=8e3;function R9({onRoot:e}){const t=S.useRef(null),n=S.useCallback(te=>{t.current=te,e(te)},[e]),r=ct(),o=Bn(),a=it(),l=S.useRef(a);l.current=a;const[u]=S.useState(()=>new j9((te,Ne,be)=>{var _e,Oe;(_e=l.current)==null||_e.send({t:"visit",worktreeId:te,path:Ne,title:be}),Wx((Oe=o.getState().local[te])==null?void 0:Oe.pages)&&Yt.post(te,{type:"links"})},(te,Ne,be)=>{var _e;return(_e=l.current)==null?void 0:_e.send({t:"page-title",worktreeId:te,path:Ne,title:be})}));S.useEffect(()=>()=>u.dispose(),[u]);const c=d1(),p=Da(),m=gs(),h=L(te=>te.connected),k=L(te=>te.heard),y=L(te=>te.connectFailure),v=L(te=>te.remote),x=L(te=>te.editor),_=p1(),N=J2(),j=hc(),E=L(te=>te.layout.term)&&!j,M=L(te=>te.focusTerm),K=S.useRef(!1),U=S.useRef(M),R=!K.current||M!==U.current;S.useEffect(()=>{K.current=E&&!!p,U.current=M});const I=mc(),C=L(te=>te.layout.design)&&!j&&!I,P=L(te=>te.reloadReq),z=Hd(),q=S.useRef(z);q.current=z;const se=L(te=>te.zen),pe=L(te=>{var Ne;return((Ne=te.dragFiles)==null?void 0:Ne.at)==="centre"}),ue=S.useRef(se);ue.current=se;const xe=Ot(p,"log"),oe=L(te=>te.incompatible),A=tM(),X=L(te=>{var Ne;return((Ne=te.overlay)==null?void 0:Ne.kind)==="setup"?te.repos.find(be=>be.id===te.overlay.repoId)??null:null}),Z=(m==null?void 0:m.worktree.empty)===!0,$=!!m&&fc(m),V=A&&!Z&&!$?A:null,de=V??X,me=L(te=>te.pending.find(Ne=>Ne.id===te.activeImportId)??null),[he,$e]=S.useState([]),ae=S.useRef(new Map),ve=S.useRef(new Map),[Re,ee]=S.useState([]),Y=S.useRef(new Set),Pe=S.useRef(new Set);S.useEffect(()=>{Yt.post=(te,Ne)=>{var be,_e;if(Ne.type==="reload"&&Y.current.has(te))return gb(ae.current.get(te));(_e=(be=ae.current.get(te))==null?void 0:be.contentWindow)==null||_e.postMessage({__toyon:!0,...Ne},ve.current.get(te)??"*")},Yt.broadcast=te=>{var Ne;for(const[be,_e]of ae.current)(Ne=_e.contentWindow)==null||Ne.postMessage({__toyon:!0,...te},ve.current.get(be)??"*")}},[]),S.useEffect(()=>{let te=null;const Ne=Oe=>{Oe.target instanceof HTMLElement&&Oe.target.tagName!=="IFRAME"&&(te=Oe.target)},be=Oe=>{Oe.relatedTarget===null&&setTimeout(()=>{document.activeElement===document.body&&(te=null)},0)},_e=Oe=>{var Mt,Tt;if((Mt=Oe.data)!=null&&Mt.__toyon)for(const[ht,wn]of ae.current){if(wn.contentWindow!==Oe.source)continue;if(Oe.origin!==ve.current.get(ht))return;const Ke=PO(Oe.data);if(!Ke)return;switch(Ke.type){case"key":window.dispatchEvent(new KeyboardEvent(Ke.up?"keyup":"keydown",{key:Ke.key,code:Ke.code,metaKey:Ke.meta,ctrlKey:!!Ke.ctrl,shiftKey:!!Ke.shift,altKey:!!Ke.alt}));break;case"hmr":r({a:"hmr",id:ht});break;case"loaded":Y.current.delete(ht),Pe.current.add(ht),ee(Kn=>Kn.includes(ht)?Kn:[...Kn,ht]),Yt.post(ht,ES(q.current)),Yt.post(ht,{type:"zen",on:ue.current}),r({a:"hmr",id:ht}),r({a:"page",id:ht,url:Ke.url,title:Ke.title,fresh:!0}),u.note(ht,Ke.url,Ke.title);break;case"navigated":r({a:"page",id:ht,url:Ke.url,...Ke.title!==void 0?{title:Ke.title}:{}}),u.note(ht,Ke.url,Ke.title);break;case"title":r({a:"page",id:ht,title:Ke.title}),u.title(ht,Ke.title);break;case"links":r({a:"links",id:ht,links:Ke.links});break;case"page-error":{const Kn=Ke.source?` (${cv(Ke.source)}:${Ke.line??"?"})`:"";r({a:"page",id:ht,error:`${Ke.message}${Kn}`});break}case"picked":{const{type:Kn,verb:Nt,site:Sn,...Nn}=Ke,Hn=Sn==="call"?{file:Nn.callFile,line:Nn.callLine}:{file:Nn.file,line:Nn.line};if(Nt==="code"){r({a:"set-picking",v:!1});const Lt=(Tt=fn(o.getState(),ht))==null?void 0:Tt.worktree;Hn.file?Ra(o,a,ht,cv(Hn.file,Lt==null?void 0:Lt.path),Hn.line??1):a==null||a.send({t:"find-element",worktreeId:ht,seq:$o(),element:Nn.element})}else WM(o,ht,Nn);break}case"pick-cancel":r({a:"set-picking",v:!1});break;case"drag-files":ig(o,o.getState().activeId?{at:"centre"}:null);break;case"drop-files":P1(o,a,o.getState().activeId?{at:"centre"}:null,mL(Ke.files));break;case"focus":Ke.gesture?te=null:document.activeElement===wn&&(te!=null&&te.isConnected)&&te!==document.body&&te.focus();break;case"highlight-miss":console.warn(`[toyon] highlight miss on ${Ke.path}: ${Ke.fileMatched} elements from this file, ${Ke.withSource} elements with source info on page, ranges=${JSON.stringify(Ke.ranges)}`);break}return}};return window.addEventListener("message",_e),document.addEventListener("focusin",Ne),document.addEventListener("focusout",be),()=>{window.removeEventListener("message",_e),document.removeEventListener("focusin",Ne),document.removeEventListener("focusout",be)}},[r,o,a,u]),S.useEffect(()=>{Yt.broadcast({type:"zen",on:se})},[se]);const We=S.useRef(new Map);gt([P==null?void 0:P.id,P==null?void 0:P.n],()=>{if(!P)return;const{id:te}=P;clearTimeout(We.current.get(te)),We.current.set(te,setTimeout(()=>{We.current.delete(te),Yt.post(te,{type:"reload"})},1200))});const Fe=Ym(),pt=Fe&&!tr(Fe)?Fe:null,Ge=$i(),vt=!!m&&m.procs.some(te=>te.status==="running"),at=Jm(),qt=at!==null&&at===p&&vt;S.useEffect(()=>{at&&qt&&!he.includes(at)&&$e(te=>[...te,at])},[at,qt,he]);const an=c.filter(te=>tr(te)&&te.procs.some(Ne=>Ne.status==="asleep")).map(te=>te.id).join(" ");S.useEffect(()=>{const te=new Set(an.split(" ").filter(Boolean));he.some(Ne=>te.has(Ne))&&$e(Ne=>Ne.filter(be=>!te.has(be)))},[an,he]),S.useEffect(()=>{const te=he.filter(Ne=>Ne!==at).map(Ne=>setTimeout(()=>$e(be=>be.filter(_e=>_e!==Ne)),A9));return()=>{for(const Ne of te)clearTimeout(Ne)}},[he,at]),S.useEffect(()=>{ee(te=>te.every(Ne=>he.includes(Ne))?te:te.filter(Ne=>he.includes(Ne)))},[he]);const qe=c.filter(tr).filter(te=>he.includes(te.id)).map(te=>({id:te.worktree.id,port:te.worktree.proxyPort,title:te.worktree.title})),J=qe.filter(te=>{var Ne;return(Ne=c.find(be=>be.id===te.id))==null?void 0:Ne.procs.some(be=>be.status==="running")}).map(te=>te.id).join(" ");gt([J],()=>{for(const te of J.split(" "))Y.current.has(te)&&gb(ae.current.get(te))});const[we,Xe]=S.useState(null),[et,Wt]=S.useState(at),Qt=S.useRef(null);et!==at&&(Wt(at),Xe(u9(Qt.current,at,te=>{var Ne;return((Ne=c.find(be=>be.id===te))==null?void 0:Ne.repoId)??null}))),S.useEffect(()=>{if(!we)return;const te=setTimeout(()=>Xe(null),I9);return()=>clearTimeout(te)},[we]);const ge=at!==null&&Re.includes(at),Me=d9({previewId:at,painted:ge,ready:qt,carry:we,mounted:he}),hn=Me!==null&&Me!==at;S.useEffect(()=>{Qt.current=Me});const[It,Rt]=ho(mt.editorHeight,0,te=>{const Ne=Number(te);return Number.isFinite(Ne)&&Ne>=120?Ne:0}),[In,Dt]=ho(mt.designHeight,0,te=>{const Ne=Number(te);return Number.isFinite(Ne)&&Ne>0?Ne:0}),[gn,kt]=ho(mt.designFull,!1,te=>te===null?void 0:te==="1"),[Gt,tn]=ho(mt.editorFull,!1,te=>te===null?void 0:te==="1"),[nn,Un]=ho(mt.termHeight,240,te=>{const Ne=Number(te);return Number.isFinite(Ne)&&Ne>=140?Ne:void 0}),_t=L(te=>te.termTall);gt([_t],()=>{const te=t.current;_t&&te&&Un(Math.max(nn,Math.round(te.clientHeight/2)))});const Kt=te=>(Ne,be)=>{const _e=be.parentElement,Oe=t.current;if(!_e||!Oe)return null;let Mt=0;for(const ht of Array.from(Oe.querySelectorAll(":scope > .pane")))ht!==_e&&!ht.classList.contains("full")&&(Mt+=ht.offsetHeight);const Tt=Math.max(Oe.clientHeight-Mt-80,te);return Math.min(Math.max(_e.getBoundingClientRect().bottom-Ne.clientY,te),Tt)},Rn=_a(Kt(120),te=>Rt(Math.round(te))),H=_a(Kt(160),te=>Dt(Math.round(te))),fe=_a(Kt(140),te=>Un(Math.round(te))),Ie=L(te=>{var Ne,be;return m&&Cr(m.worktree)?((be=(Ne=te.rows.find(_e=>{var Oe;return _e.repoId===m.worktree.repoId&&((Oe=_e.worktree)==null?void 0:Oe.kind)==="worktree"}))==null?void 0:Ne.worktree)==null?void 0:be.title)??null:null}),rt=HL({connected:h,heard:k,connectFailure:y,hasToken:C9,projectChord:Et("project"),title:(m==null?void 0:m.worktree.title)??null,needsSetup:!!A,busy:$,treeEmpty:Z,landsFrom:Ie});return f.jsxs("div",{className:"center-root",ref:n,children:[f.jsx("div",{className:He("center-area",pe&&"drop-over"),style:{display:!(se&&!I)&&(x&&Gt||C&&gn)?"none":void 0},children:f.jsxs("div",{className:"frames-wrap",children:[qe.map(te=>f.jsx("iframe",{ref:Ne=>{Ne?(ae.current.set(te.id,Ne),ve.current.set(te.id,new URL(Ih(te.id,te.port,v)).origin)):(ae.current.delete(te.id),ve.current.delete(te.id),Y.current.delete(te.id),Pe.current.delete(te.id))},onLoad:()=>{Pe.current.delete(te.id)?Y.current.delete(te.id):Y.current.add(te.id)},src:Ih(te.id,te.port,v),title:te.title,style:{display:te.id===Me&&!de&&!me&&!j&&!I?"block":"none"}},te.id)),N?f.jsx(y9,{project:N}):f.jsxs(f.Fragment,{children:[me&&f.jsx(h9,{pending:me},me.id),_&&m&&!me&&f.jsx(p9,{active:m},m.worktree.id),de&&!me&&!_&&f.jsx(_9,{repo:de,onClose:V?void 0:()=>r({a:"close"})},`${de.id}:${JSON.stringify(de.config)}`),pt&&!de&&!me&&!Ge&&f.jsx(Zl,{placement:"centre",found:pt},pt.id),Ge&&!de&&!me&&f.jsx(Zl,{placement:"centre",archived:Ge},Ge.id),!vt&&!pt&&!Ge&&!de&&!me&&!_&&oe&&f.jsx(S9,{}),!vt&&!pt&&!Ge&&!de&&!me&&!_&&!oe&&(rt!==null?f.jsx(Qs,{wide:!0,children:f.jsx("p",{className:"status-line",children:rt})}):I?f.jsx(Zl,{placement:"centre"}):hn?null:m&&f.jsx(l9,{worktree:m,log:xe}))]})]})}),x&&f.jsx(aS,{editor:x,height:Gt?"100%":It>0?It:"45%",full:Gt,onToggleFull:()=>tn(!Gt),onDragStart:Rn}),C&&p&&!Ge&&f.jsx($F,{worktreeId:p,height:gn?"100%":In>0?In:"55%",full:gn,onToggleFull:()=>kt(!gn),onDragStart:H},`design:${p}`),E&&p&&!Ge&&f.jsx(s9,{worktreeId:p,opened:R,height:nn,onDragStart:fe},`term:${p}`),f.jsx(kS,{})]})}function O9({width:e}){const t=L(r=>r.layout.chat),n=hc();return f.jsx(Zl,{placement:"dock",className:!t||n?"collapsed":void 0,width:e})}function $9(e,t){const n=[];return e&&(n.push(v1(e)),n.push({id:"copy-url",label:"copy URL",onClick:()=>Zt(e)})),Dn([n,[{id:"reload",label:"reload preview",key:Et("reload"),onClick:t.reload}]])}const M9=520,kh=8;function L9({winW:e,centre:t,leadRight:n,toolsLeft:r}){const o=t.right-t.left,a=Math.max(0,Math.min(M9,Math.floor(e*.4),o-2*kh)),l=t.left+(o-a)/2,u=n+kh,c=r-kh-a,p=Math.max(Math.min(l,c),u);return{left:Math.round(p),width:a}}function P9({center:e}){const t=B2(),n=c1(e),r=S.useRef(null);K2(r);const[o,a]=_v(),[l,u]=_v(),c=L9({winW:t,centre:n,leadRight:a.right,toolsLeft:u.left}),p=ct(),m=it(),h=Bn(),k=sn("bar"),y=gs(),v=mc(),x=L(q=>q.zen)&&!v,_=L(q=>q.layout.changes),N=L(q=>q.layout.chat),j=hc(),E=L(q=>q.layout.design),M=L(q=>{var se;return((se=q.overlay)==null?void 0:se.kind)==="keys"}),K=H9(),U=(y==null?void 0:y.worktree.id)??null,R=L(q=>q.archivedPage!==null),I=!!y&&Zm(y)&&!R,C=L(q=>q.chatSide)==="left",P=!j&&f.jsx(At,{icon:"branch",label:"Changes panel",hint:Et("changes"),tone:"chrome",on:_,onClick:()=>p({a:"toggle-changes"})}),z=!j&&!v&&f.jsx(At,{icon:"chat",label:"Chat panel",hint:Et("composer"),tone:"chrome",on:N,onClick:()=>p({a:"toggle-chat"})});return f.jsxs("div",{className:"top-bar",ref:r,children:[x&&f.jsx("span",{className:"bar-zen-title",children:(y==null?void 0:y.worktree.title)??"Toyon"}),f.jsxs("span",{className:"bar-lead",ref:o,children:[C?z:P,f.jsx(D9,{}),K&&f.jsx(cf,{icon:"download","data-tip":"Install Toyon as an app (own window, dock icon)",onClick:()=>void K.prompt(),children:"install app"}),f.jsx(F9,{}),f.jsx(B9,{})]}),!v&&f.jsx(z9,{worktreeId:U,repoId:(y==null?void 0:y.repoId)??null,ready:I,left:c.left,width:c.width}),f.jsx("span",{className:"bar-grow"}),f.jsxs("span",{className:"bar-tools",ref:l,children:[f.jsx(U9,{}),f.jsx(At,{icon:"settings",label:"Settings & shortcuts",hint:Et("keys"),tone:"chrome",on:M,"aria-controls":"keys-help","aria-expanded":M,onClick:()=>p({a:"toggle",overlay:{kind:"keys"}}),...k.contextMenu(()=>xE(h.getState(),{sock:m,dispatch:p}))}),!j&&!v&&f.jsx(At,{icon:"palette",label:"Design system",hint:Et("design"),tone:"chrome",on:E,onClick:()=>p({a:"toggle-design"})}),C?P:z,!v&&f.jsx(At,{icon:"zen",className:"bar-zen",label:"Full-bleed preview",hint:Et("zen"),tone:"chrome",on:x,onClick:()=>p({a:"toggle-zen"})})]})]})}function D9(){const e=ct(),t=it(),n=za(),r=L(p=>p.repos),o=sn("bar"),a=()=>Dn([[{id:"project",label:r.length>1?"switch project…":"open project…",key:Et("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?rf(n,n.id,{sock:t,dispatch:e}):[]]),l=L(p=>{var m;return((m=p.overlay)==null?void 0:m.kind)==="projects"&&p.overlay.form==="pill"}),u=L(p=>p.heard),c=L(p=>p.newProject!==null);return f.jsxs("span",{className:"bar-project",children:[f.jsx(ze,{tone:"chrome",className:"bar-pill",on:l,...$t(r.length>1?"Switch project":"Open a project",Et("project")),onClick:()=>e({a:"toggle",overlay:{kind:"projects",form:"pill"}}),...o.contextMenu(a),children:f.jsx("span",{className:"bar-project-name",children:c?"new project":(n==null?void 0:n.name)??(u?"open project":"")})}),l&&f.jsx(Wg,{form:"pill"})]})}function z9({worktreeId:e,repoId:t,ready:n,left:r,width:o}){const a=Ot(e,"page").url,l=BE(a),u=ct(),c=L(v=>{var x;return((x=v.overlay)==null?void 0:x.kind)==="routes"}),p=()=>{n&&e&&t&&!c&&u({a:"open",overlay:{kind:"routes"}})};gt([e,n],()=>{c&&u({a:"close"})});const h=sn("bar").contextMenu(()=>n?$9(a,{reload:()=>e&&Yt.post(e,{type:"reload"})}):[]),k=L(v=>v.picking),y=Jm();return f.jsxs("div",{className:"bar-center",style:{left:r,width:o},children:[f.jsx(At,{icon:"back",label:"Back",hint:Et("back"),disabled:!n,onClick:()=>e&&Yt.post(e,{type:"back"}),...h}),f.jsx(At,{icon:"forward",label:"Forward",hint:Et("forward"),disabled:!n,onClick:()=>e&&Yt.post(e,{type:"forward"}),...h}),f.jsx(At,{icon:"reload",label:"Reload preview",hint:Et("reload"),disabled:!n,onClick:()=>e&&Yt.post(e,{type:"reload"}),...h}),f.jsxs("span",{className:"bar-route",children:[f.jsx(Mo,{className:"bar-path",value:n?l:"",readOnly:!0,disabled:!n,placeholder:n?"/":"",onMouseDown:v=>{v.button===0&&v.preventDefault()},onClick:p,onFocus:p,spellCheck:!1,...$t("Go to a page",Et("routes"))}),c&&n&&e&&t&&f.jsx(l6,{worktreeId:e,repoId:t,url:a},e)]}),f.jsx(At,{icon:"inspect",label:"Pick an element to open its code",hint:Et("inspect"),also:{text:"Add an element to chat",key:Et("pick")},on:k==="code",disabled:!n||!y,onClick:()=>y&&tc(y,k,u,"code")})]})}function cf({icon:e,busy:t,children:n,...r}){return f.jsxs(ze,{disabled:t,...r,children:[!t&&f.jsx(St,{name:e,className:"icon-inline"}),f.jsx("span",{className:He(t&&"live-text"),children:n})]})}function F9(){const e=L(c=>c.self),t=L(c=>c.rebuilt),n=L(c=>c.repos),r=it(),o=L(c=>{var p;return((p=c.update)==null?void 0:p.restarting)!=null}),a=lS(e,n,t);if(!a||o)return null;const l=a.busy?"rebuilding":a.reload?"reload Toyon":a.build==="rebuild"?"rebuild Toyon":a.build??"restart Toyon",u=()=>{a.reload?window.location.reload():e&&(r==null||r.send(a.build?{t:"run-after-land",repoId:e.repoId}:{t:"restart-daemon"}))};return f.jsx(cf,{icon:"reload",busy:a.busy,onClick:u,...$t(a.text,void 0,{detail:a.detail}),children:l})}function B9(){const e=L(o=>o.update),t=L(o=>o.managed.updates),n=it(),r=a8(e);return!r||!t?null:f.jsx(cf,{icon:"reload",busy:r.busy,onClick:()=>{r.retry&&(n==null||n.send({t:"update-now"}))},...$t(r.text),children:r.word})}function U9(){const e=ct(),t=L(a=>a.remote!==null&&a.frame==="desk"),n=L(a=>a.paired),r=L(a=>{var l;return((l=a.overlay)==null?void 0:l.kind)==="pair"});if(!t)return null;const o=()=>e({a:"toggle",overlay:{kind:"pair"}});return n?f.jsx(At,{icon:"phone",label:"Open on your phone",tone:"chrome",on:r,"aria-expanded":r,onClick:o}):f.jsx(cf,{icon:"phone","aria-expanded":r,onClick:o,...$t("Scan a code with your phone to open this machine there, signed in"),children:"open on phone"})}function H9(){const[e,t]=S.useState(null);return S.useEffect(()=>{if(Bd())return;const n=o=>{o.preventDefault(),t(o)},r=()=>t(null);return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",r),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",r)}},[]),e}function W9(e,t,n){return t==="left"?n-e.left:e.right-n}const K9="input, textarea, [contenteditable], .monaco-editor, .xterm, iframe";function Z9(){const e=Bn(),t=ct(),n=it(),r=hc(),o=Vs(),a=mc(),l=L(A=>A.zen)&&!a,u=$i(),c=!!Xm()||!!u,p=L(A=>A.layout.changes)&&!r,m=L(A=>A.layout.chat)&&!r&&!a&&!c,h=L(A=>A.chatSide),k=L(A=>A.railOpen),[y,v]=ho(mt.changesWidth,220,A=>A?Cu(Number(A),220):void 0),[x,_]=ho(mt.chatWidth,380,A=>A?Cu(Number(A),380):void 0),[N,j]=ho(mt.railWidth,280,A=>A?Cu(Number(A),280):void 0),E=(A,X,Z)=>{const $=X.classList.contains("left")?"left":"right",V=$==="left"?X.previousElementSibling:X.nextElementSibling;return V?Cu(W9(V.getBoundingClientRect(),$,A.clientX),Z):null},M=_a((A,X)=>E(A,X,220),v),K=_a((A,X)=>E(A,X,380),_),U=_a((A,X)=>E(A,X,280),j),[R,I]=S.useState(null),P=sn("app").contextMenu(()=>vE(e.getState(),{sock:n,dispatch:t})),z=f.jsx(l_,{width:y}),q=!a&&!c&&f.jsx(O9,{width:x}),se=!r&&f.jsx(wS,{width:N}),pe=A=>!r&&k&&f.jsx("div",{className:`dock-resize ${A}`,onPointerDown:U}),ue=h==="left",xe=ue?{dock:q,open:m,drag:K}:{dock:z,open:p,drag:M},oe=ue?{dock:z,open:p,drag:M}:{dock:q,open:m,drag:K};return f.jsxs("div",{className:He("app",l&&"zen"),"data-chat-side":h,"data-touch":o||void 0,"data-hover":!o||void 0,onContextMenu:A=>{A.defaultPrevented||A.target instanceof Element&&A.target.closest(K9)||P.onContextMenu(A)},children:[f.jsx(D1,{}),f.jsx(U1,{}),f.jsx(P9,{center:R}),f.jsxs("div",{className:"docks",children:[ue&&se,ue&&pe("left"),xe.dock,xe.open&&f.jsx("div",{className:"dock-resize left",onPointerDown:xe.drag}),f.jsx(R9,{onRoot:I}),oe.open&&f.jsx("div",{className:"dock-resize right",onPointerDown:oe.drag}),oe.dock,!ue&&pe("right"),!ue&&se]})]})}function q9(e){return e.altKey?"Alt":e.ctrlKey?"Control":e.metaKey?"Meta":null}function G9(e,t){return t==="Alt"?e.altKey:t==="Control"?e.ctrlKey:e.metaKey}const V9=200,Y9={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function Q9(e,t=Y9){let n=null,r=!1,o=null;const a=()=>{r||(r=!0,e(!0))},l=()=>{o!==null&&(t.clear(o),o=null)},u=()=>{l(),n=null,r&&(r=!1,e(!1))};return{press(c){const p=n!==null;n=q9(c),l(),n&&(p?a():o=t.set(()=>{o=null,a()},V9))},keyup(c){n&&c===n&&u()},mods(c){n&&!G9(c,n)&&u()},end:u}}function X9(e,t,n,r){if(!n)return null;const o=e.findIndex(c=>c.id===n);if(o>=0){const c=e[(o+r+e.length)%e.length];return c&&c.id!==n?{activate:c.id}:null}const a=t.findIndex(c=>c.id===n);if(a<0)return null;const l=t[a+r];if(l)return{activate:l.id};const u=e[e.length-1];return r<0&&u?{activate:u.id}:null}const J9=new Set(["design","chats"]),eB=new Set(["reload","back","forward"]),tB=new Set(["project","commands","keys","zen"]);function nB(){const e=Bn(),t=it();S.useEffect(()=>{const n=Q9(m=>e.dispatch({a:"rail-peek",on:m})),r=n.end,o=m=>{e.getState().railOpen||n.press(m)},a=m=>n.keyup(m.key),l=m=>n.mods(m),u=()=>{var y,v;const m=e.getState(),k=((v=(y=document.activeElement)==null?void 0:y.closest("[data-pane]"))==null?void 0:v.dataset.pane)??(m.layout.term?"terminal":m.editor?"editor":m.layout.design?"design":null);k==="terminal"?e.dispatch({a:"toggle-terminal"}):k==="editor"?e.dispatch({a:"close-editor"}):k==="design"&&e.dispatch({a:"toggle-design"})},c=m=>{m.key!=="Escape"||!e.getState().choosingFolder||(m.stopImmediatePropagation(),t==null||t.send({t:"cancel-folder"}),e.dispatch({a:"choosing-folder",v:!1}))},p=m=>{var _,N,j,E;l(m),mT(m)&&!m.defaultPrevented&&m.preventDefault();const h=e.getState(),{dispatch:k}=e,y=M=>{const K=document.activeElement,U=!K||K===document.body||!!K.closest(".rail, .chat-input");k({a:"activate",id:M}),U&&k({a:"walked"})},v=jb(m,{guest:!!((_=document.activeElement)!=null&&_.closest(".xterm"))});if(!(h.zen&&!mo(h)&&!h.overlay&&!h.picking&&!(v&&hT.has(v.id))||(v==null?void 0:v.id)==="close"&&!Bd()||(N=document.activeElement)!=null&&N.closest(".monaco-editor")&&v&&J9.has(v.id))&&!(v&&vT(v.id,document.activeElement))&&!(v&&eB.has(v.id)&&!(Cl(h)&&dd(h)))){if(v){const M=m.defaultPrevented;if(m.preventDefault(),h.newProject&&!tB.has(v.id))return;switch(v.id){case"worktree":{const K=kT(v.digit,h.visible.length),U=K===null?void 0:h.visible[K];U&&y(U.id);break}case"wt-prev":case"wt-next":{const K=X9(h.visible,h.visibleDiscovered,h.activeId,v.id==="wt-next"?1:-1);K&&y(K.activate),o(m);break}case"wt-unseen-prev":case"wt-unseen-next":{const K=Dm(h.visible,h.activeId,v.id==="wt-unseen-next"?1:-1);K&&y(K.activate),o(m);break}case"mark-unread":h.activeId&&!h.draft&&h.visible.some(K=>K.id===h.activeId)&&q1(t,k,h.activeId);break;case"wt-archive":{if(m.repeat||M)break;const K=h.draft||h.archivedPage?void 0:h.visible.find(U=>U.id===h.activeId);K&&lg(t,k).archive(K);break}case"new":k({a:"open-draft"});break;case"project":k({a:"toggle",overlay:{kind:"projects",form:"center"}});break;case"quick-open":((j=h.overlay)==null?void 0:j.kind)==="quick-open"?k({a:"close"}):h.activeId&&k({a:"open",overlay:{kind:"quick-open"}});break;case"routes":((E=h.overlay)==null?void 0:E.kind)==="routes"?k({a:"close"}):dd(h)&&k({a:"open",overlay:{kind:"routes"}});break;case"reload":case"back":case"forward":{const K=Cl(h);K&&Yt.post(K,{type:v.id});break}case"pick":case"inspect":{const K=Cl(h);K&&tc(K,h.picking,k,v.id==="pick"?"chat":"code");break}case"search":h.activeId&&k({a:"toggle",overlay:{kind:"search"}});break;case"refs":h.activeRepoId&&k({a:"toggle",overlay:{kind:"refs"}});break;case"chats":h.activeRepoId&&k({a:"toggle",overlay:{kind:"chats"}});break;case"commands":k({a:"toggle",overlay:{kind:"commands"}});break;case"zen":k({a:"toggle-zen"});break;case"close":!(h.zen&&!mo(h))&&!h.overlay&&u();break;case"changes":k(h.layout.changes&&(Ca(h)==="changes"||ko(h)!==null)?{a:"toggle-changes"}:{a:"focus-changes",tab:"changes"});break;case"files":k(h.layout.changes&&Ca(h)==="files"?{a:"toggle-changes"}:{a:"focus-changes",tab:"files"});break;case"panel-tab-prev":case"panel-tab-next":if(Ud(h))break;k(h.layout.changes?{a:"focus-changes",tab:g2(h,v.id==="panel-tab-next"?1:-1)}:{a:"focus-changes"});break;case"composer":k(Vx(h));break;case"rail":k(h.railOpen?{a:"toggle-rail"}:{a:"focus-rail"});break;case"keys":k({a:"toggle",overlay:{kind:"keys"}});break;case"terminal":k(h.layout.term?{a:"toggle-terminal"}:{a:"focus-terminal"});break;case"design":k({a:"toggle-design"});break;case"term-tab":{const K=h.rows.find(C=>C.id===h.activeId);if(!K)break;const U=go(h,h.activeId).termStream;if(K.login&&U===ps)break;const R=[po,...K.login?[ps]:[],...K.procs.map(C=>C.name)],I=R.indexOf(U);k({a:"term-stream",id:K.id,stream:R[(I+1)%R.length]??po});break}}}else if(m.key==="Escape")if(h.newProject)h.newProject.phase==="editing"&&k({a:"close-new-project"});else if(h.picking){const M=Cl(h);M&&Yt.post(M,{type:"pick-cancel"}),k({a:"set-picking",v:!1})}else h.archivedPage?k({a:"close-archived"}):h.activeImportId?k({a:"watch-import",id:null}):u()}};return window.addEventListener("keydown",c,!0),window.addEventListener("keydown",p),window.addEventListener("keyup",a),window.addEventListener("pointermove",l),window.addEventListener("pointerdown",l),window.addEventListener("blur",r),()=>{window.removeEventListener("keydown",c,!0),window.removeEventListener("keydown",p),window.removeEventListener("keyup",a),window.removeEventListener("pointermove",l),window.removeEventListener("pointerdown",l),window.removeEventListener("blur",r),r()}},[e,t]),S.useEffect(()=>{const n=r=>{if(r.key!=="Alt"&&r.key!=="Shift")return;const o=e.getState();o.picking&&o.activeId&&Yt.post(o.activeId,{type:"pick-mods",alt:r.altKey,shift:r.shiftKey})};return window.addEventListener("keydown",n),window.addEventListener("keyup",n),()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",n)}},[e])}const rB=3,oB=2e3,sB=200,iB=5e3;function aB(){const e=Bn(),t=ct(),n=it(),r=Da(),o=L(Z=>Z.activeRepoId),a=gs(),l=Ym(),u=L(Z=>Z.connected),c=L(Z=>Z.daylight),p=L(Z=>{var $;return(($=Z.daylight)==null?void 0:$.until)??0}),m=$i(),h=L(Z=>Z.railOpen),k=L(Z=>Z.chatSide),y=L(Z=>Z.layouts),v=L(Z=>Z.lastActive),x=L(Z=>Z.discoveredOpen),_=L(Z=>Z.archivedOpen),N=L(Z=>Z.committedShut),j=L(Z=>Z.turnOpen),E=L(Z=>Z.treeOpen),M=Hd(),K=L(Z=>Z.previewTheme!==null),U=L(Z=>Z.openUrl),R=d1();S.useEffect(()=>pd.install(window),[]);const I=S.useRef([]);S.useEffect(()=>{if(!n||!u||!r)return;const Z=[r,...I.current.filter($=>$!==r)];for(const $ of Z.splice(rB))n.send({t:"unsubscribe",worktreeId:$});I.current.includes(r)||n.send({t:"subscribe",worktreeId:r}),I.current=Z},[r,u,n]),S.useEffect(()=>{if(!(!n||!u))for(const Z of I.current)n.send({t:"subscribe",worktreeId:Z})},[u,n]);const C=S.useRef(void 0);S.useEffect(()=>{if(!n||!u)return;let Z;const $=()=>{const me=document.visibilityState==="visible"?r:null;n.send({t:"view",worktreeId:me}),C.current=me},V=()=>{clearTimeout(Z),Z=setTimeout($,sB)};C.current===void 0||C.current===r||document.visibilityState!=="visible"?$():V();const de=()=>document.visibilityState==="visible"?V():$();return document.addEventListener("visibilitychange",de),()=>{clearTimeout(Z),document.removeEventListener("visibilitychange",de)}},[r,u,n]);const P=(m==null?void 0:m.id)??null;S.useEffect(()=>{if(!(!n||!u||!P))return n.send({t:"subscribe",worktreeId:P}),()=>n.send({t:"unsubscribe",worktreeId:P})},[P,u,n]),S.useEffect(()=>{const Z=new Set(R.map(V=>V.id)),$=I.current.filter(V=>!Z.has(V));if($.length!==0&&(I.current=I.current.filter(V=>Z.has(V)),!(!n||!u)))for(const V of $)n.send({t:"unsubscribe",worktreeId:V})},[R,u,n]);const z=(m==null?void 0:m.title)??(l==null?void 0:l.name)??null;S.useEffect(()=>{document.title=z?`${z} · Toyon`:"Toyon"},[z]);const q=!!(a!=null&&a.unseen),se=L(Z=>Z.unreadHold!==null&&Z.unreadHold===Z.activeId);S.useEffect(()=>{if(!n||!r||!q||se)return;let Z;const $=()=>document.visibilityState==="visible"&&document.hasFocus(),V=()=>{clearTimeout(Z),$()&&(Z=setTimeout(()=>{$()&&n.send({t:"seen",worktreeId:r})},oB))},de=()=>clearTimeout(Z);return V(),window.addEventListener("focus",V),window.addEventListener("blur",de),()=>{de(),window.removeEventListener("focus",V),window.removeEventListener("blur",de)}},[n,r,q,se]);const pe=S.useRef(0);S.useEffect(()=>{if(!n||!u||!o)return;const Z=()=>{Date.now()-pe.current<iB||(pe.current=Date.now(),n.send({t:"refresh-git",repoId:o}))};return window.addEventListener("focus",Z),()=>window.removeEventListener("focus",Z)},[n,u,o]),S.useEffect(()=>{_S(M,{remember:!K}),Yt.broadcast(ES(M))},[M,K]),S.useEffect(()=>IF(Z=>t({a:"system-dark",v:Z})),[t]);const ue=S.useCallback(()=>{n==null||n.send({t:"zone",tz:Intl.DateTimeFormat().resolvedOptions().timeZone})},[n]);S.useEffect(()=>{if(!u)return;ue();const Z=()=>{document.visibilityState==="visible"&&ue()};return document.addEventListener("visibilitychange",Z),()=>document.removeEventListener("visibilitychange",Z)},[u,ue]),S.useEffect(()=>{if(!u||p<=Date.now())return;const Z=setTimeout(ue,p-Date.now()+1e3);return()=>clearTimeout(Z)},[u,p,ue]),S.useEffect(()=>{c&&c.until>0&&AF(c)},[c]),S.useEffect(()=>{if(r)try{localStorage.setItem(mt.active,r)}catch{}},[r]);const xe=L(Z=>Z.frame==="phone"?Z.screen!=="home":null);S.useEffect(()=>{if(xe!==null)try{sessionStorage.setItem(mt.phoneRow,xe?"1":"0")}catch{}},[xe]),S.useEffect(()=>{if(o)try{localStorage.setItem(mt.repo,o)}catch{}},[o]),S.useEffect(()=>{try{localStorage.setItem(mt.rail,h?"1":"0")}catch{}},[h]),S.useEffect(()=>{try{localStorage.setItem(mt.chatSide,k)}catch{}},[k]),S.useEffect(()=>{try{localStorage.setItem(mt.layouts,JSON.stringify(y))}catch{}},[y]),S.useEffect(()=>{try{localStorage.setItem(mt.lastActive,JSON.stringify(v))}catch{}},[v]),S.useEffect(()=>{try{localStorage.setItem(mt.discoveredOpen,JSON.stringify(x))}catch{}},[x]),S.useEffect(()=>{try{localStorage.setItem(mt.archivedOpen,JSON.stringify(_))}catch{}},[_]),S.useEffect(()=>{try{localStorage.setItem(mt.committedShut,JSON.stringify(N))}catch{}},[N]),S.useEffect(()=>{try{localStorage.setItem(mt.turnOpen,JSON.stringify(j))}catch{}},[j]),S.useEffect(()=>{try{localStorage.setItem(mt.treeOpen,JSON.stringify(E))}catch{}},[E]),nB(),wL();const oe=S.useRef(null);S.useEffect(()=>{!U||oe.current===U||(oe.current=U,window.open(U,"_blank"),t({a:"opened-url"}))},[U,t]);const A=S.useRef(null);return gt([r],()=>{var ae,ve,Re,ee;const Z=A.current;if(A.current=r,!Z||!r||Z===r)return;const $=e.getState(),V=R.find(Y=>Y.id===Z),de=R.find(Y=>Y.id===r),me=(ve=(ae=V==null?void 0:V.worktree)==null?void 0:ae.variant)==null?void 0:ve.group;if(!me||((ee=(Re=de==null?void 0:de.worktree)==null?void 0:Re.variant)==null?void 0:ee.group)!==me)return;const he=Y=>{var Pe;try{const We=(Pe=$.local[Y])==null?void 0:Pe.page.url;return We?new URL(We).pathname+new URL(We).search:"/"}catch{return"/"}},$e=he(Z);$e!==he(r)&&Yt.post(r,{type:"navigate",path:$e})}),L(Z=>Z.frame)==="phone"?f.jsx(bF,{}):f.jsx(Z9,{})}const ym="toyonDepth",OS="toyonOver";function kb(e){if(e.frame!=="phone"||!e.heard)return null;if(!(e.screen!=="home"&&(fn(e,e.activeId)!==null||ko(e)!==null)))return 0;const n=fn(e,e.activeId)!==null&&!mo(e)&&ko(e)===null;return 1+(e.screen==="changes"||e.screen==="preview"&&n?1:0)+(e.editor?1:0)}const yh=e=>{const t=e&&typeof e=="object"?e[ym]:void 0;return typeof t=="number"?t:null},lB=e=>!!e&&typeof e=="object"&&e[OS]===!0;function cB(e,t=window,n=pd){const r=t.history;let o=yh(r.state)??0;yh(r.state)===null&&r.replaceState({[ym]:0},"");let a=null;const l=()=>{const v=n.open();a&&!v.includes(a)&&(a=null);for(let x=v.length-1;x>=0;x--){const _=v[x];if(_!=null&&_.dismiss&&_!==a)return _}return null};let u=0;const c=()=>{const v=kb(e.getState());if(v===null)return;const x=v+(l()?1:0);if(x!==o){if(x>o)for(let _=o+1;_<=x;_++)r.pushState({[ym]:_,[OS]:_>v},"");else r.go(x-o),u++;o=x}};let p=!1;const m=()=>{p||(p=!0,queueMicrotask(()=>{p=!1,c()}))},h=v=>{const x=u>0;x&&u--,o=yh(v.state)??0;const _=e.getState(),N=kb(_);if(N===null)return;const j=l(),E=N+(j?1:0);if(E!==o){if(E>o&&j){a=j,n.shut(j);return}if(E>o){const M=o===0?"home":_.editor&&o===N-1?_.screen:"chat";e.dispatch({a:"screen",to:M})}else{if(x&&u>0)return;!x&&E===0&&_.activeId&&!lB(v.state)&&e.dispatch({a:"screen",to:"chat"})}c()}};t.addEventListener("popstate",h);const k=e.subscribe(c),y=n.watch(m);return c(),()=>{t.removeEventListener("popstate",h),k(),y()}}const Bu=new Map,uB={on(e,t){let n=Bu.get(e);return n||(n=new Set,Bu.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Bu.delete(e)}},deliver(e){for(const t of Bu.get(nT(e.worktreeId,e.stream))??[])t(e)}};window.__toyonShell=!0;window.top!==window&&(document.documentElement.dataset.framed="");z2();const $S=NF();_S($S);function Vo(e,t){try{return e.getItem(t)}catch{return null}}function dB(){const e={};try{const t=JSON.parse(Vo(localStorage,mt.layouts)??"{}");if(!t||typeof t!="object")return e;for(const[n,r]of Object.entries(t))a2(r)&&(e[n]=r)}catch{}return e}function fB(){const e={};try{const t=JSON.parse(Vo(localStorage,mt.lastActive)??"{}");if(!t||typeof t!="object")return e;for(const[n,r]of Object.entries(t))typeof r=="string"&&r&&(e[n]=r)}catch{}return e}function Uu(e){const t={};try{const n=JSON.parse(Vo(localStorage,e)??"{}");if(!n||typeof n!="object")return t;for(const[r,o]of Object.entries(n))typeof o=="boolean"&&(t[r]=o)}catch{}return t}function pB(){const e={};try{const t=JSON.parse(Vo(localStorage,mt.treeOpen)??"{}");if(!t||typeof t!="object")return e;for(const[n,r]of Object.entries(t))Array.isArray(r)&&r.every(o=>typeof o=="string")&&r.length>0&&(e[n]=r)}catch{}return e}const hB=400,mB=2e3;function gB(){const e=new Map,t=new Map,n=MS(),r=a=>{var u,c;clearTimeout((u=t.get(a))==null?void 0:u.timer),t.delete(a);const l=er.getState().local[a];!l||((c=l.mark)==null?void 0:c.by)==="walk"||(e.get(a)??"")!==l.draft&&(e.set(a,l.draft),Us.send({t:"set-draft",boxId:a,text:l.draft,clientId:er.getState().clientId}))},o=()=>{for(const a of[...t.keys()])r(a)};return er.subscribe(()=>{var a,l;for(const[u,c]of Object.entries(er.getState().local)){if(n.another(u,c.sent)&&(clearTimeout((a=t.get(u))==null?void 0:a.timer),t.delete(u),e.set(u,"")),((l=c.mark)==null?void 0:l.by)==="walk"||(e.get(u)??"")===c.draft)continue;if(!c.draft){r(u);continue}const p=t.get(u);if((p==null?void 0:p.text)===c.draft)continue;clearTimeout(p==null?void 0:p.timer);const m=(p==null?void 0:p.since)??Date.now(),h=Math.max(0,Math.min(hB,m+mB-Date.now()));t.set(u,{text:c.draft,timer:setTimeout(r,h,u),since:m})}}),window.addEventListener("focusout",o),window.addEventListener("pagehide",o),{hello(a){e.clear();for(const[l,u]of Object.entries(a))e.set(l,u)},heard(a,l){return t.has(a)?!1:(e.set(a,l),!0)}}}function MS(){const e=new Map;return{another(t,n=0){return(e.get(t)??0)===n?!1:(e.set(t,n),!0)}}}function kB(){const e=new Map,t=new Map,n=MS();return er.subscribe(()=>{for(const[r,o]of Object.entries(er.getState().local)){if(n.another(r,o.sent)&&t.set(r,"[]"),e.get(r)===o.attachments)continue;e.set(r,o.attachments);const a=r2(o.attachments),l=JSON.stringify(a);(t.get(r)??"[]")!==l&&(t.set(r,l),Us.send({t:"set-attachments",boxId:r,items:a,clientId:er.getState().clientId}))}}),{hello(r){t.clear(),e.clear();for(const[o,a]of Object.entries(r))t.set(o,JSON.stringify(a))},heard(r,o){t.set(r,JSON.stringify(o))}}}function yB(){const e=Vo(sessionStorage,mt.client);if(e)return e;const t=Math.random().toString(36).slice(2,10);try{sessionStorage.setItem(mt.client,t)}catch{}return t}const er=L2(c2({cached:$S,systemDark:TF(),daylight:CF(),storedActive:Vo(localStorage,mt.active),storedPhoneRow:Vo(sessionStorage,mt.phoneRow)==="1",storedRepo:Vo(localStorage,mt.repo),storedRailOpen:Vo(localStorage,mt.rail)==="1",storedChatSide:Vo(localStorage,mt.chatSide)==="right"?"right":"left",storedLayouts:dB(),storedLastActive:fB(),storedDiscoveredOpen:Uu(mt.discoveredOpen),storedArchivedOpen:Uu(mt.archivedOpen),storedCommittedShut:Uu(mt.committedShut),storedTurnOpen:Uu(mt.turnOpen),storedTreeOpen:pB(),clientId:yB(),frame:xS(),touch:EF()}));SF(er);cB(er);let Xu=null;const Us=new DM(e=>{if(e.t==="hello"){const{rebuilt:t,update:n}=er.getState(),r=t&&(n==null?void 0:n.restarting)!=null;if(Xu!==null&&(r||e.version!==Xu||e.protocol!==Ch)){Us.dispose(),window.location.reload();return}if(e.protocol!==Ch){er.dispatch({a:"incompatible"}),Us.dispose();return}Xu=e.version;const o=new Set(Us.sentWhileDown());if(o.size){const a=l=>Object.fromEntries(Object.entries(l).filter(([u])=>!o.has(u)));e.drafts=a(e.drafts),e.attachments=a(e.attachments)}yb.hello(e.drafts),wm.hello(e.attachments)}if(e.t==="attachments"&&e.clientId!==er.getState().clientId&&wm.heard(e.boxId,e.items),!(e.t==="draft"&&e.clientId!==er.getState().clientId&&!yb.heard(e.boxId,e.text))){if(bO(e)){uB.deliver(e);return}if(xO(e)){if(e.t==="file-written"&&jM(e))return;Kg.receive(e);return}if(e.t==="loose-written"){L6(e);return}if(Oz(e)){Pz(er,Us,e);return}if(e.t==="open-refused"){Lz(er,e);return}er.dispatch({a:"server",msg:e})}},(e,t)=>er.dispatch({a:"connected",v:e,failure:t})),Kg=new $6({store:er,send:e=>Us.send(e),timers:{set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)},win:window});Kg.start();window.addEventListener("vite:preloadError",z6);const yb=gB(),wm=kB(),wB=(window.toyonBoot??Promise.resolve(null)).then(e=>{const t=e;t&&typeof t=="object"&&t.t==="hello"&&t.protocol===Ch&&(Xu??(Xu=t.version),wm.hello(t.attachments),er.dispatch({a:"server",msg:t}))});wB.then(()=>M$.createRoot(document.getElementById("root")).render(f.jsx(C$.StrictMode,{children:f.jsx(Bg,{children:f.jsx(P2,{store:er,sock:Us,files:Kg,children:f.jsx(aB,{})})})})));"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});export{Ys as F,cm as _,ro as a,Lm as b,_B as c,Cb as d,uB as e,nT as f,IP as g,x$ as h,fg as i,f as j,bB as k,jb as m,xB as p,S as r,m$ as s,dc as t,gt as u,Qw as w};