@promptctl/cc-candybar 1.217.0 → 1.218.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 (2) hide show
  1. package/dist/index.mjs +44 -44
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -1,23 +1,23 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"node:module";import t from"node:process";import{URL as n,URLSearchParams as r,fileURLToPath as i}from"node:url";import{json as a}from"node:stream/consumers";import o from"node:os";import s,{closeSync as c,constants as l,existsSync as u,fstatSync as d,linkSync as f,mkdtempSync as p,openSync as m,readFileSync as h,readSync as g,rmSync as _,statSync as v,writeFileSync as y}from"node:fs";import{StringDecoder as b}from"node:string_decoder";import{inspect as x,parseArgs as S,types as C}from"node:util";import{clearImmediate as w,setImmediate as T}from"node:timers";import{spawn as ee,spawnSync as te}from"node:child_process";import E,{basename as ne,dirname as D,isAbsolute as re,join as ie,sep as O}from"node:path";import ae,{createHash as oe,createHmac as se,randomBytes as ce,randomUUID as le,timingSafeEqual as ue}from"node:crypto";import de from"node:net";import fe from"node:v8";import{open as pe,readFile as me,readdir as he,stat as ge}from"node:fs/promises";import{get as _e}from"node:https";import{WriteStream as ve}from"node:tty";import{createInterface as ye}from"node:readline";var be=Object.create,xe=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,Ce=Object.getOwnPropertyNames,we=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty,Ee=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),De=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Ce(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Te.call(e,s)&&s!==n&&xe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Se(t,s))||r.enumerable});return e},Oe=(e,t,n)=>(n=e==null?{}:be(we(e)),De(t||!e||!e.__esModule?xe(n,`default`,{value:e,enumerable:!0}):n,e));let ke=!1;const Ae=()=>ke;function je(e){ke=e}function Me(e){return Ae()?`[DEBUG] ${e()}\n`:``}function k(e,...t){Ae()&&console.error(`[DEBUG] ${e}`,...t)}function Ne(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const Pe=(e,t)=>k(t);function Fe(e,t){return Math.round(t-e)}function A(e,t){return Fe(t,e.monotonic())}const Ie={now:()=>Date.now(),monotonic:()=>performance.now(),after:(e,t,n)=>{let r=setTimeout(t,e);return n?.unref&&r.unref(),()=>clearTimeout(r)},every:(e,t,n)=>{let r=setInterval(t,e);return n?.unref&&r.unref(),()=>clearInterval(r)},defer:e=>{let t=T(e);return()=>w(t)}};function Le(e,t,n){return new Promise((r,i)=>{let a=()=>Object.assign(Error(`The operation was aborted`),{name:`AbortError`,code:`ABORT_ERR`,cause:n?.reason});if(n?.aborted){i(a());return}let o=()=>{s(),i(a())},s=e.after(t,()=>{n?.removeEventListener(`abort`,o),r()});n?.addEventListener(`abort`,o,{once:!0})})}function Re(e,t){let n=new AbortController;return e.after(t,()=>n.abort(new DOMException(`The operation was aborted due to timeout`,`TimeoutError`)),{unref:!0}),n.signal}function ze(e,t,n,r){return n<e.at+t?`held`:r===`request`&&!e.answered?`owed`:`over`}function Be(e,t){return!e.answered&&e.at===t.at&&e.text===t.text}const Ve=e=>e.getTime()/1e3,He=e=>new Date(e*1e3),Ue=e=>Ve(new Date(e.now()));function We(e,t){return C.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!u(t)?`working directory does not exist: ${t}`:e.message:String(e)}const Ge={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3};function Ke(e,t,n){let r=Ge[t];if(r===void 0)return{allowed:!0};let i=e.get(t);if(i===void 0)return{allowed:!0};let a=n-i;return a>=r?{allowed:!0}:{allowed:!1,minIntervalMs:r,sinceLastMs:a}}function qe(e,t){return{...e.inherited,...t.envOverlay}}function Je(e){switch(e.reason){case`non-zero`:return`exited with code ${e.exitCode}`;case`signal`:return`killed by ${e.signal??`a signal`}`;case`timeout`:case`output-limit`:case`rate-limited`:case`pipe-error`:case`spawn-error`:return e.error??e.reason;default:return e.error===void 0?e.reason:`${e.reason}: ${e.error}`}}const Ye=e=>{let t=[];for(let n of e){if(t.length===200)return`${t.join(``)}…`;t.push(n)}return e};function Xe(e,t){if(e.reason===`output-limit`||e.reason===`pipe-error`)return``;let n=t.trim(),r=n.search(/[\r\n]/);if(r===-1)return Ye(n);let i=Math.max(n.lastIndexOf(`
3
- `),n.lastIndexOf(`\r`))+1;return`${Ye(n.slice(0,r).trim())} … ${Ye(n.slice(i).trim())}`}function Ze(e,t=``){let n=Xe(e,e.stderr);return`${Je(e)}${t}${n===``?``:`: ${n}`}`}const Qe=({reason:e})=>({ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)});function $e(e,t,n){return{ok:!1,reason:`rate-limited`,stdout:``,stderr:``,exitCode:null,signal:null,error:`rate-limited: ${e} min interval ${t}ms, last start ${Math.round(n)}ms ago`}}function et(e,t){let n=t.finally(()=>e.ending.delete(n));return e.ending.add(n),n}function tt(e,t,n){let r=nt(e,t,n);return r===null?(e.lastStartAt.set(t,e.scope.clock.monotonic()),null):(e.scope.stats?.onRefused(t),r)}function nt(e,t,n){if(e.scope.signal.aborted)return Qe(e.scope.signal);if(n?.aborted)return Qe(n);let r=Ke(e.lastStartAt,t,e.scope.clock.monotonic());return r.allowed?null:$e(t,r.minIntervalMs,r.sinceLastMs)}const rt=`\$1 == "+" { live[\$2] = 1; next } \$1 == "-" { delete live[\$2]; next } END { for (g in live) groups = groups " -" g; if (groups != "") system("kill -TERM" groups " 2>/dev/null; sleep ${250/1e3}; kill -KILL" groups " 2>/dev/null") }`;function it(e,t){t!==e.fault&&(e.fault=t,e.scope.observeWarnings({kind:`lifeline`,fault:t}))}function at(e,t,n){e.lifeline?.process===t&&(e.lifeline=null,t.ref(),it(e,n))}const ot=e=>`programs launched now would outlive their launcher if it died: its launch lifeline ${e}, and the next launch starts another`,st=e=>e===`cut`?`output cut at the ${gt}-byte bound, so the program holding it now fails its writes`:`output failed to read`,ct=`a launched program's pipe outlived its launch: `;function lt(e,t,n){let r=e.pipeEvent,i=new Map(r===null||r.answered?[]:r.counts),a=`${t}\0${n}`;i.set(a,(i.get(a)??0)+1),e.pipeEvent={text:`${ct}${[...i].map(([e,t])=>{let[n,r]=e.split(`\0`);return`${t}× ${r} ${st(n)}`}).join(`; `)}`,at:e.scope.now(),answered:!1,counts:i},e.scope.observeWarnings({kind:`launch-pipes`,text:`${ct}${n} ${st(t)}`})}function ut(e,t){let n=e.pipeEvent;n===null||!Be(n,t)||(e.pipeEvent={...n,answered:!0})}function dt(e,t,n){let r=e.pipeEvent,i=r===null?`over`:ze(r,60,t,n);return[...e.fault===null?[]:[{kind:`lifeline`,message:ot(e.fault)}],...r===null||i===`over`?[]:[{kind:`launch-pipes`,message:r.text,event:r,hold:i}]]}function ft(e){let{stats:t,clock:n}=e.scope;t?.onStart(`lifeline`);let r=n.monotonic(),i;try{i=e.spawner.spawn(`awk`,[rt],{stdio:[`pipe`,`ignore`,`ignore`],detached:!0})}catch(i){return t?.onEnd(`lifeline`,A(n,r)),it(e,`did not start: ${We(i,void 0)}`),null}t?.onEnd(`lifeline`,A(n,r));let a=i.stdin;if(a==null)return i.once(`error`,t=>it(e,`did not start: ${t.message}`)),null;i.once(`spawn`,()=>{e.lifeline?.process===i&&it(e,null)}),i.once(`error`,t=>at(e,i,`failed: ${t.message}`)),i.once(`exit`,(t,n)=>at(e,i,`exited ${n??t}`)),a.on(`error`,t=>at(e,i,`pipe failed: ${t.message}`)),et(e,new Promise(e=>i.once(`close`,e))),i.unref(),a.unref();for(let t of e.liveGroups)a.write(`+ ${t}\n`);return{process:i,pipe:a}}function pt(e,t){e.liveGroups.add(t),e.lifeline??=ft(e),e.lifeline?.pipe.write(`+ ${t}\n`)}function mt(e,t){e.liveGroups.delete(t),e.lifeline?.pipe.write(`- ${t}\n`)}function ht(e){let t=e.lifeline;e.lifeline=null,t?.process.ref(),t?.pipe.end()}const gt=16*1024*1024,_t=`output exceeded ${gt} bytes`,vt=e=>`timed out after ${e/1e3} s`;function yt(e,t,n,r){let{stats:i}=e.scope,a=new b(`utf8`),o=``,s=0,c=0,l=r,u=`closed`;return n?.on(`error`,n=>{i?.onPipeError(t),l===null?lt(e,`read-error`,t):l.failed(n)}),n?.on(`data`,r=>{if(l===null){if(c+=r.length,i?.onDrainRead(t,r.length),c<=16777216)return;u=`cut`,n.destroy(),lt(e,`cut`,t);return}let d=Math.max(0,gt-s);o+=a.write(r.subarray(0,d)),s+=r.length,s>16777216&&l.full()}),{take:()=>{if(l===null)return``;l=null;let e=o+a.end();return o=``,e},drain:()=>{n===null||n.destroyed||n.readableEnded||bt(e,t,n,()=>u)}}}function bt(e,t,n,r){let{stats:i}=e.scope;if(e.scope.signal.aborted){n.destroy();return}n.once(`close`,()=>{e.drains.delete(n),i?.onDrainClose(t,r())}),n.unref(),e.drains.add(n),i?.onDrainOpen(t)}const xt=()=>`closed`;function St(e,t){e.on(`error`,()=>{}),e.end(t)}async function Ct(e,t){let{stats:n,clock:r}=e.scope,i=tt(e,t.category,t.signal);if(i!==null)return i;let a=r.monotonic();return n?.onStart(t.category),new Promise(i=>{let{spawner:o}=e,s;try{s=o.spawn(t.bin,t.args??[],{cwd:t.cwd,env:qe(e.scope,t),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(e){n?.onEnd(t.category,A(r,a)),i({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:We(e,t.cwd)});return}let c=s.pid;c!==void 0&&pt(e,c);let l=new Promise(e=>s.once(`exit`,e)),u=s.stdin;s.stdin=null;let d=null,f={full:()=>te(`output-limit`),failed:e=>{d??=e.message,te(`pipe-error`)}},p=yt(e,t.category,s.stdout,f),m=yt(e,t.category,s.stderr,f),h=()=>({stdout:p.take(),stderr:m.take()}),g=!1,_=null,v=null,y=null,b=null,x=()=>te(`aborted`),S=()=>{t.signal?.removeEventListener(`abort`,x),e.inFlight.delete(x)},C=i=>{g||(g=!0,_?.(),v?.(),y?.(),S(),c!==void 0&&mt(e,c),n?.onEnd(t.category,A(r,a)),s.off(`close`,ne),s.off(`error`,E),p.drain(),m.drain(),u!==null&&!u.destroyed&&!u.writableFinished&&bt(e,t.category,u,xt),i())},w=e=>C(()=>i(e)),T=(n,r)=>{try{o.signalGroup(n,r)}catch(n){e.unreaped.set(s,t.category),l.then(()=>e.unreaped.delete(s)),w({ok:!1,reason:`signal-refused`,...h(),exitCode:null,signal:null,error:n instanceof Error?n.message:String(n)})}},ee=()=>ne(s.exitCode,s.signalCode);if(c!==void 0){let e=t=>{if(!g){if(o.groupGone(c)){r.defer(ee);return}y=r.after(t,()=>e(Math.min(t*2,1e3)))}};l.then(()=>r.defer(()=>e(25)))}let te=e=>{if(b!==null)return;if((s.exitCode!==null||s.signalCode!==null)&&c!==void 0&&o.groupGone(c)){b=e===`timeout`?null:e,r.defer(ee);return}b=e,_?.(),S();let t=s.pid;t!==void 0&&(v=r.after(250,()=>{T(t,`SIGKILL`),l.then(()=>r.defer(ee))}),T(t,`SIGTERM`))},E=e=>{w({ok:!1,reason:`spawn-error`,...h(),exitCode:null,signal:null,error:We(e,t.cwd)})};s.on(`error`,E);let ne=(e,n)=>{if(b!==null){w({ok:!1,reason:b,...h(),exitCode:e,signal:n,...b===`timeout`?{error:vt(t.timeoutMs??0)}:b===`output-limit`?{error:_t}:b===`pipe-error`?{error:`a pipe failed to read: ${d}`}:{}});return}if(e===0){w({ok:!0,...h(),exitCode:e});return}w({ok:!1,reason:n?`signal`:`non-zero`,...h(),exitCode:e,signal:n})};s.on(`close`,ne),t.timeoutMs&&t.timeoutMs>0&&(_=r.after(t.timeoutMs,()=>te(`timeout`))),t.signal?.addEventListener(`abort`,x,{once:!0}),e.inFlight.add(x),u!==null&&St(u,t.stdinInput)})}function wt(e,t){let{stats:n,clock:r}=e.scope,i=tt(e,t.category);if(i!==null)return i;let a=r.monotonic();n?.onStart(t.category);try{let i=e.spawner.spawnSync(t.bin,t.args??[],{cwd:t.cwd,env:qe(e.scope,t),input:t.stdinInput,timeout:t.timeoutMs&&t.timeoutMs>0?t.timeoutMs:void 0,stdio:[`pipe`,`pipe`,`pipe`],encoding:`utf8`});n?.onEnd(t.category,A(r,a));let o=typeof i.stdout==`string`?i.stdout:``,s=typeof i.stderr==`string`?i.stderr:``,c=i.error?.code;if(i.error&&c!==`EPIPE`&&c!==`ECONNRESET`){let e=c===`ETIMEDOUT`?`timeout`:`spawn-error`;return{ok:!1,reason:e,stdout:o,stderr:s,exitCode:null,signal:i.signal??null,error:e===`timeout`?vt(t.timeoutMs??0):We(i.error,t.cwd)}}return i.status===0?{ok:!0,stdout:o,stderr:s,exitCode:i.status}:{ok:!1,reason:i.signal?`signal`:`non-zero`,stdout:o,stderr:s,exitCode:i.status,signal:i.signal??null}}catch(e){return n?.onEnd(t.category,A(r,a)),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:We(e,t.cwd)}}}function Tt(e,t){let{stats:n,clock:r}=e.scope,i=tt(e,t.category);if(i!==null)return i;let a=r.monotonic();n?.onStart(t.category);let o=Et(e,t);return n?.onEnd(t.category,A(r,a)),o}function Et(e,t){let n;try{n=e.spawner.spawn(t.bin,t.args??[],{cwd:t.cwd,env:qe(e.scope,t),detached:!0,stdio:`ignore`})}catch(e){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:We(e,t.cwd)}}return n.once(`error`,()=>{}),n.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${t.bin}): no pid (binary not found or unexecutable)`}:(n.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}const Dt=e=>e.kind===`exit`?`exit ${e.code}`:`timeout`;function Ot(e,t,n){let{stats:r,clock:i}=e.scope,a=tt(e,t.category);if(a!==null)return{ok:!1,reason:a.reason,error:a.error};let o=i.monotonic();r?.onStart(t.category);let s;try{s=e.spawner.spawn(`/bin/sh`,[`-c`,`out=$1 err=$2 status=$3; shift 3; read go || exit 0; "$@" >"$out" 2>"$err" </dev/null; echo "exit $?" >"$status.$$" && ln "$status.$$" "$status"; rm -f "$status.$$"`,`sh`,n.stdout,n.stderr,n.status,t.bin,...t.args??[]],{cwd:t.cwd,env:qe(e.scope,t),detached:!0,stdio:[`pipe`,`ignore`,`ignore`]})}catch(e){return r?.onEnd(t.category,A(i,o)),{ok:!1,reason:`spawn-error`,error:We(e,t.cwd)}}r?.onEnd(t.category,A(i,o)),s.once(`error`,()=>{});let c=s.pid,l=s.stdin;return l.on(`error`,()=>{}),c===void 0?(l.destroy(),{ok:!1,reason:`spawn-error`,error:`spawn(/bin/sh): no pid (shell not found or unexecutable)`}):(s.unref(),l.unref(),{ok:!0,pid:c,release:()=>l.end(`go
4
- `),withdraw:()=>l.end()})}function kt(e){let t;try{t=h(e,`utf8`).trim()}catch(e){if(e.code===`ENOENT`)return null;throw e}let n=/^exit (\d+)$/.exec(t);if(n)return{kind:`exit`,code:Number(n[1])};if(t===`timeout`)return{kind:`timeout`};throw Error(`${e}: not a job verdict: ${JSON.stringify(t)}`)}function At(e,t,n,r,i){let a=`${r}.${process.pid}`;try{y(a,`${Dt(i)}\n`)}catch(e){if(e.code===`ENOENT`)return{stands:!1,signalled:!1};throw e}let o=!0;try{f(a,r)}catch(e){if(e.code!==`EEXIST`)throw e;o=!1}finally{_(a,{force:!0})}let s=e.signalJob(n,`SIGTERM`);return s&&t.after(250,()=>e.signalJob(n,`SIGKILL`),{unref:!0}),{stands:o,signalled:s}}function jt(e,t,n){return Nt(e,t,n).launcher}function Mt(e,t,n){let{launcher:r,state:i}=Nt(e,t,n);return{...r,launchSync:e=>wt(i,e)}}function Nt(e,t,n){let r={clock:t,launch:e=>et(i,Ct(i,e)),launchDetachedSync:e=>Tt(i,e),launchJobSync:(e,t)=>Ot(i,e,t),jobGroupAlive:e=>n.signalJob(e,0),endJob:(e,r,i)=>At(n,t,e,r,i),launcherWarnings:(e,t)=>dt(i,e,t),answeredPipeEvent:e=>ut(i,e),settled:async()=>(await Promise.all(i.ending),{unreaped:[...i.unreaped.values()]}),__lifelineForTest:()=>{let e=i.lifeline;return{pid:e?.process.pid,cut:()=>{e?.pipe.end(),e&&at(i,e.process,`cut by a test`)}}}},i={spawner:n,scope:{stats:null,observeWarnings:e=>{let t=e.kind===`launch-pipes`?e.text:e.fault===null?null:ot(e.fault);t!==null&&process.emitWarning(t)},signal:new AbortController().signal,now:()=>Ve(new Date(t.now())),...e,clock:t},lastStartAt:new Map,inFlight:new Set,liveGroups:new Set,lifeline:null,fault:null,pipeEvent:null,ending:new Set,unreaped:new Map,drains:new Set};return i.scope.signal.addEventListener(`abort`,()=>{i.inFlight.forEach(e=>e()),i.drains.forEach(e=>e.destroy()),ht(i)},{once:!0}),{launcher:r,state:i}}function Pt(e){try{return process.kill(e,0),!1}catch(e){return e.code===`EPERM`}}const Ft={spawn:(e,t,n)=>ee(e,t,n),spawnSync:(e,t,n)=>te(e,t,n),signalGroup:(e,t)=>{try{process.kill(-e,t)}catch(t){let n=t.code;if(n!==`ESRCH`&&!(n===`EPERM`&&!Pt(e)))throw t}},groupGone:e=>{try{return process.kill(-e,0),!1}catch(e){return e.code===`ESRCH`}},signalJob:(e,t)=>{try{return process.kill(-e,t),!0}catch(e){let t=e.code;if(t===`ESRCH`||t===`EPERM`)return!1;throw e}}},It=(e,t)=>jt(e,t,Ft),Lt=(e,t)=>Mt(e,t,Ft);function Rt(){let e={env:process.env,home:o.homedir(),tmp:o.tmpdir()},t=Ie;return{host:e,launcher:Lt({inherited:process.env},t),clock:t}}const zt=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function Bt(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Vt(e){return zt.test(e)?e:Bt(e)}function Ht(e){return`${e.dir===void 0?``:`cd ${Vt(e.dir)} && `}${e.env.map(([e,t])=>`${e}=${Vt(t)} `).join(``)}${[e.program,...e.args].map(Vt).join(` `)}`}const Ut=`cc-extra`;function j(e){return E.join(E.dirname(e),Ut,`src`,`bun-attach.js`)}function Wt(e){return E.join(E.dirname(e),`bun-graph.js`)}const Gt=`attach-preload.cjs`;function Kt(e){return E.join(E.dirname(e),Gt)}function qt(e,t){return Ht({...t,env:[...t.env,[`BUN_OPTIONS`,`--preload ${e.replace(/[\\\s]/g,`\\$&`)}`]]})}const Jt=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Yt(e,t){return t.isSymbolicLink()?Buffer.from(s.readlinkSync(e)):s.readFileSync(e)}function M(e,t,n=Jt){return s.readdirSync(t).filter(n).sort().flatMap(n=>{let r=E.join(t,n),i=s.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?M(e,r):[[E.relative(e,r).split(E.sep).join(`/`),Yt(r,i)]]})}function Xt(e){let t=ae.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Zt(e){return Xt(M(e,e))}const Qt=[`Cargo.toml`,`Cargo.lock`,`src`];function $t(e){return Xt(M(e,e,e=>Qt.includes(e)))}const en=e=>e.slice(0,7),tn=`1.217.0`;function nn(e){let t=E.dirname(E.dirname(e));return s.existsSync(E.join(t,`src`))?t:null}function rn(e){if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:tn,digest:e}}function an(){return`9f44e7634ceaecf210c81e20af2c6c0aacbf54f643ed46281f55902548bff7c8`}function on(e){let t=JSON.parse(s.readFileSync(E.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${E.join(e,`package.json`)} has no version string`);return n}function sn(e,t){try{let n=nn(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Zt(E.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:on(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}function cn(e,t){let n=e[t];return n&&n.length>0?n:void 0}function ln(e){let t=cn(e.env,`XDG_STATE_HOME`)??E.join(e.home,`.local`,`state`);return E.join(t,`cc-candybar`)}function un(e){let t=cn(e.env,`XDG_CACHE_HOME`)??E.join(e.home,`.cache`);return E.join(t,`cc-candybar`)}function dn(e){return ln(e)}function fn(e){return e.env.CC_CANDYBAR_SOCKET||pn()}function pn(){let e=o.userInfo().uid;return E.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function mn(e){s.mkdirSync(e,{recursive:!0,mode:448});let t=s.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=o.userInfo().uid;if(typeof n==`number`&&t.uid!==n)throw Error(`directory is not owned by uid ${n}: ${e} (owner uid=${t.uid})`);if(t.mode&63)throw Error(`directory has unsafe permissions: ${e} (mode=${(t.mode&511).toString(8)}, expected 0700)`)}function hn(e){mn(E.dirname(e));for(let t of[e,gn(e)])try{if(s.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function gn(e){return`${e}.lease`}function _n(e){return gn(fn(e))}function vn(e){return E.join(ln(e),`session-state.json`)}function yn(e){return E.join(ln(e),`settings-history.json`)}function bn(e){let t=e.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(t)return t;let n=o.userInfo().uid;return E.join(`/tmp`,`cc-candybar-${n}`,`daemons`)}function xn(e){return E.join(ln(e),`spawn.lock`)}function Sn(e){return E.join(ln(e),`spawn.cooldown`)}function Cn(e){return E.join(ln(e),`spawn.backoff`)}function wn(e){return E.join(ln(e),`watch-probe`)}function Tn(e){return E.join(ln(e),`daemon.log`)}function N(e){return{socket:fn(e),lease:_n(e),state:ln(e),registry:bn(e),log:Tn(e),sessionState:vn(e),settingsHistory:yn(e),watchProbe:wn(e),spawnBackoff:Cn(e)}}function En(e){let{env:t}=e,n=`/usr/local/share:/usr/share`,r=process.platform===`darwin`?`${E.join(cn(t,`HOMEBREW_PREFIX`)??`/opt/homebrew`,`share`)}:${n}`:n;return{home:e.home,configHome:cn(t,`XDG_CONFIG_HOME`)??E.join(e.home,`.config`),dataHome:cn(t,`XDG_DATA_HOME`)??E.join(e.home,`.local`,`share`),dataDirs:(cn(t,`XDG_DATA_DIRS`)??r).split(`:`).filter(e=>e!==``)}}function Dn(e,t,n){let r=On(e);s.mkdirSync(E.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??s.statSync(r,{throwIfNoEntry:!1})?.mode;try{s.writeFileSync(i,t,a===void 0?{}:{mode:a}),s.renameSync(i,r)}catch(e){throw s.rmSync(i,{force:!0}),e}}function On(e){return kn(e).at(-1)}function kn(e){let{hops:t,stopped:n}=An(e);if(n!==null)throw n;return t}function An(e){let t=[e];try{for(let e=0;e<Mn;e++){let e=jn(t[t.length-1]);if(e===null)return{hops:t,stopped:null};t.push(e)}return{hops:t,stopped:Error(`${e}: more than ${Mn} symbolic links`)}}catch(e){return{hops:t,stopped:e}}}function jn(e){try{return s.lstatSync(e).isSymbolicLink()?E.resolve(s.realpathSync(E.dirname(e)),s.readlinkSync(e)):null}catch(e){let{code:t}=e;if(t===`ENOENT`||t===`ENOTDIR`)return null;throw e}}const Mn=40,Nn=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function Pn(e){return Object.fromEntries(Nn.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const Fn=[`native`,`node`,`frames`];function In(e,t){return{kind:e,bundle:t,source:null}}const Ln=[`ansi`,`frame`],Rn=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,terminalEnv:!0,client:!0});function zn(e){let t=Jn(e.termCols),n=Jn(e.termRows),r=Yn(e.ssh),i=Kn(e.tmux),a=Gn(e.configEnv),o=Gn(e.claudeConfigDir),s=Wn(e.terminalEnv),c=ir(e.client);return{...t!==void 0&&{termCols:t},...n!==void 0&&{termRows:n},...r!==void 0&&{ssh:r},...i!==void 0&&{tmux:i},...a!==void 0&&{configEnv:a},...o!==void 0&&{claudeConfigDir:o},...s!==void 0&&{terminalEnv:s},...c!==void 0&&{client:c}}}function Bn(e,t){return Rn.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function Vn(e){return e.length===0?null:`Client hints refused: ${e.map(({hint:e,sent:t})=>`${e}=${JSON.stringify(t)}`).join(`, `)} — is the statusline client older than the daemon? Reinstall it (\`cc-candybar install\`, or \`just install-rust\` in a checkout).`}const Hn={unknown:e=>`Unknown flags: ${e}`,"no-value":e=>`${e} names no file — the bar renders with no ${e}`,positional:e=>`Unexpected arguments: ${e}`};function Un(e){let t=Object.keys(Hn).flatMap(t=>{let n=e.filter(e=>e.why===t).map(e=>e.arg);return n.length===0?[]:[Hn[t](n.join(`, `))]});return t.length===0?null:t.join(`
5
- `)}function Wn(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=Nn.filter(e=>t[e]!==void 0);return n.every(e=>typeof t[e]==`string`&&t[e]!==``)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function Gn(e){return typeof e==`string`&&E.isAbsolute(e)?e:void 0}function Kn(e){if(e===null)return null;if(typeof e!=`object`)return;let{socket:t,pane:n,truecolor:r}=e;if(!(typeof t!=`string`||t===``)&&!(typeof n!=`string`||n===``)&&!(r!==null&&(typeof r!=`string`||r===``)))return{socket:t,pane:n,truecolor:r}}const qn=1e4;function Jn(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>qn?qn:t}function Yn(e){return typeof e==`boolean`?e:void 0}const Xn=new Set([...[],1]);function Zn(e){return typeof e==`object`&&e&&e.kind===`url`?{kind:`url`,frame:e}:{kind:`request`,req:e}}var Qn=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}},$n=class extends Error{constructor(e){super(e===`connect`?`CONNECT_TIMEOUT`:`TIMEOUT`),this.phase=e,this.name=`ClientTimeoutError`}};function er(e){return tr(JSON.stringify(e))}function tr(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function nr(e,t){let n=Buffer.alloc(0);return function(r){for(n=Buffer.concat([n,r]);n.length>=4;){let r=n.readUInt32BE(0);if(r>16777216){t(new Qn(`frame too large: ${r}`));return}if(n.length<4+r)return;let i=n.subarray(4,4+r);n=n.subarray(4+r);try{e(JSON.parse(i.toString(`utf8`)))}catch(e){let n=new Qn(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function rr(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=t=>{if(!o){o=!0,c(),e.off(`data`,l),e.off(`error`,u),e.off(`close`,d);try{t()}catch{}}},c=r.after(n-r.now(),()=>{s(()=>{e.destroy(),a(new $n(`deadline`))})}),l=nr(e=>s(()=>i(e)),e=>s(()=>a(e))),u=e=>s(()=>a(e)),d=()=>s(()=>a(Error(`socket closed before response`)));e.on(`data`,l),e.on(`error`,u),e.on(`close`,d),e.write(er(t))})}function ir(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=Gn(n);return Fn.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function ar(e,t,n,r){let i;try{i=await dr(fn(e.host),n.connectMs,e.clock)}catch(e){return ur(e)}return or(i,e.clock,t,n,r)}async function or(e,t,n,r,i){try{let a=t.now()+r.budgetMs,o=n(a),s=await rr(e,{v:3,...o},a,t);return lr(o.kind,s,i)}catch(e){return ur(e)}finally{e.destroy()}}function sr(e,t){return typeof e==`string`?e:t}function cr(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function lr(e,t,n){let r=t;if(r.ok===!0){let r=n(t);return r===void 0?{kind:`permanent`,cause:`malformed_response`,message:`ok response without payload for "${e}" request`}:{kind:`ok`,value:r}}let i=sr(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:cr(r.daemonV)};case`TIMEOUT`:return{kind:`busy`,phase:`deadline`,message:i};case`BAD_REQUEST`:return{kind:`permanent`,cause:`bad_request`,message:i};case`RENDER_FAILED`:return{kind:`permanent`,cause:`render_failed`,message:i};case`SWITCHED_OFF`:return{kind:`permanent`,cause:`switched_off`,message:i};default:return{kind:`permanent`,cause:`malformed_response`,message:`unknown error code: ${String(r.code)}`}}}function ur(e){if(e instanceof Qn||e instanceof SyntaxError)return{kind:`permanent`,cause:`malformed_response`,message:e instanceof Error?e.message:String(e)};let t=e instanceof Error?e.message:String(e);return e instanceof $n?{kind:`busy`,phase:e.phase,message:t}:t.includes(`ECONNREFUSED`)||t.includes(`ENOENT`)||t.includes(`ENOTSOCK`)?{kind:`transient`,cause:`unreachable`,message:t}:{kind:`transient`,cause:`io_error`,message:t}}function dr(e,t,n){return new Promise((r,i)=>{let a=de.createConnection({path:e}),o=n.after(t,()=>{a.destroy(),i(new $n(`connect`))});a.once(`connect`,()=>{o(),r(a)}),a.once(`error`,e=>{o(),i(e)})})}function fr(e){if(e.kind===`busy`)return`daemon busy (${e.message})`;if(e.kind===`transient`)return`daemon unavailable (${e.cause}: ${e.message})\nHint: daemon may not be running. Run \`cc-candybar\` once to spawn it.`;switch(e.cause){case`version_mismatch`:{let t=e.daemonV===0?`unknown`:`v${e.daemonV}`;return`daemon protocol mismatch (client v${e.clientV} ≠ daemon ${t})`}case`bad_request`:case`render_failed`:case`switched_off`:case`malformed_response`:return`daemon error (${e.cause}): ${e.message}`}}function pr(e){return e===void 0?{kind:`unstated`}:typeof e==`number`&&Number.isSafeInteger(e)&&e>0?{kind:`stated`,at:e}:{kind:`refused`,problem:`request 'deadline' is not epoch milliseconds: ${JSON.stringify(e)}`}}function mr(e,t,n){let r=e.kind===`stated`?n.monoMs+(e.at-n.epochMs):t+150-50,i=Math.min(r,t+200);return Math.round(i-60-n.monoMs)}const hr={connectMs:50,budgetMs:150},gr={connectMs:50,budgetMs:350};function _r(e){let t=e.output;return typeof t==`string`?t:void 0}function vr(e){return lr(`render`,e,_r)}function yr(e,t,n,r,i,a=hr){return ar(e,e=>({kind:`render`,hookData:t,args:n,cwd:r,deadline:e,...i}),a,_r)}function br(e,t,n){return ar(e,()=>({kind:`pane-session`,socket:t,pane:n}),gr,e=>`paneSession`in e?e.paneSession:void 0)}function xr(e,t,n){return ar(e,()=>({kind:`click`,verb:t,value:n}),gr,_r)}const Sr=5e3;async function Cr(e){let t=[];for(let n of e){let e=await n.read();if(e.kind===`text`)return`# memory report from: ${n.name}\n${e.text}`;t.push(`# ${n.name}: unavailable — ${e.reason}`)}return[`# memory report: no probe answered`,...t.length>0?t:[`# no probe is known for this platform`]].join(`
6
- `)}const wr=`/usr/bin/footprint`;function Tr(e,t,n){return t===`darwin`?[kr(e,wr,[`-p`,String(n)]),kr(e,`/usr/bin/vmmap`,[`--summary`,String(n)])]:t===`linux`?[Ar(`/proc/self/smaps_rollup`),Ar(`/proc/self/status`)]:[]}function Er(e,t,n){return t===`darwin`?Dr(n,t=>e.launch({bin:wr,args:t,timeoutMs:Sr,category:`limits.charge`})):async e=>({kind:`charged`,measure:`rss`,bytes:e})}function Dr(e,t){return async n=>{let r=await t([`-p`,String(e),`--noCategories`,`-f`,`bytes`]);if(!r.ok)return{kind:`stand-in`,bytes:n,unread:`footprint ${Ze(r)}`};let i=Or(r.stdout);return i===null?{kind:`stand-in`,bytes:n,unread:`footprint printed no phys_footprint line`}:{kind:`charged`,measure:`phys_footprint`,bytes:i}}}function Or(e){let t=/^\s*phys_footprint:\s+(\d+) B\s*$/m.exec(e);return t===null?null:Number(t[1])}function kr(e,t,n){return{name:`${t} ${n.join(` `)}`,read:async()=>{let r=await e.launch({bin:t,args:[...n],timeoutMs:Sr,category:`limits.memory-report`});return r.ok?r.stdout.trim().length>0?{kind:`text`,text:r.stdout}:{kind:`unavailable`,reason:`exited 0 but printed nothing`}:{kind:`unavailable`,reason:Ze(r)}}}}function Ar(e){return{name:e,read:async()=>{try{let t=s.readFileSync(e,`utf8`);return t.trim().length>0?{kind:`text`,text:t}:{kind:`unavailable`,reason:`empty file`}}catch(e){return{kind:`unavailable`,reason:e.message}}}}}const jr=`CC_CANDYBAR_RSS_LIMIT_MB`;function Mr(e){let t=e[jr];if(t===void 0)return 1024;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${jr} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function Nr(e){return Mr(e)*2}const Pr=1024*1024,Fr=e=>Math.round(e/Pr);function Ir(e){return Mr(e)*Pr}const Lr={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function Rr(e,t){return e>t}function zr(e,t){if(e.kind===`charged`)return e;let n=t.kind===`unmeasured`?0:t.charge.kind===`charged`?t.rss-t.charge.bytes:t.charge.gap;return{...e,bytes:e.bytes-n,gap:n}}const Br=.75;function Vr(e,t){return e>t*Br}function Hr(e,t,n){let{prefix:r,suffix:i}=Lr[t];return E.join(e,`${r}${n}${i}`)}function Ur(e){for(let t of Object.keys(Lr)){let{prefix:n,suffix:r}=Lr[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function Wr(e){let t=e.limitBytes??1024*Pr,n=e.snapshotsKeep??3,r=!1,i={kind:`unmeasured`},a=null,o=!1,s;function c(){return a??=l().finally(()=>{a=null}),a}async function l(){if(r)return!0;let{rss:a,heapTotal:s}=e.memoryBytes(),c=zr(await e.memoryCharge(a),i),l={kind:`measured`,charge:c,rss:a,heapTotal:s};if(i=l,e.log(`info`,`memory ${qr(l,t)}`),o||c.bytes<=t)return!1;r=!0,e.log(`warn`,`${Gr(c)} > limit ${Fr(t)} MB (rss ${Fr(a)} MB, v8 heap ${Fr(s)} MB); recording memory then shutting down`);let u=`${new Date(e.clock.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return await Jr(e.log,`memory report`,async()=>{let t=Hr(e.snapshotDir,`memoryReport`,u),n=await e.captureMemoryReport();o||(e.writeMemoryReport(t,n),e.log(`info`,`memory report written: ${t}`))}),o?(e.log(`info`,`daemon closed during the breach: no snapshot, no exit`),!1):(await Jr(e.log,`heap snapshot`,()=>{e.writeLogNow();let t=Hr(e.snapshotDir,`heapSnapshot`,u);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),await Jr(e.log,`artifact rotation`,async()=>{for(let{artifacts:t}of Yr(e.listArtifacts()).slice(n))for(let n of Object.values(t))await Jr(e.log,`evicting ${n}`,()=>e.removeFile(n))}),e.shutdown(0),!0)}function u(){return i.kind===`measured`&&Vr(i.charge.bytes,t)?`${Gr(i.charge)} approaching limit ${Fr(t)} MB (v8 heap ${Fr(i.heapTotal)} MB)`:null}function d(){let n;try{n={kind:`ok`,value:Yr(e.listArtifacts())}}catch(e){n={kind:`failed`,reason:e.message}}return{pid:e.pid,memory:i,limit:t,postMortems:n}}function f(t=6e4){let n=async()=>{try{if(await c())return}catch(t){e.log(`warn`,`memory check failed: ${t.message}`)}o||(s=e.clock.after(t,()=>void n(),{unref:!0}))};n()}function p(){o=!0,s?.()}return{check:c,describeNextRestart:u,serving:d,arm:f,disarm:p}}function Gr(e){return e.kind===`charged`?`${e.measure} ${Fr(e.bytes)} MB`:`rss ${Fr(e.bytes+e.gap)} MB${e.gap===0?``:` less its last ${Fr(e.gap)} MB gap`} (standing in: ${e.unread})`}function Kr(e){return e.kind===`charged`?e.measure:`rss-stand-in`}function qr({charge:e,rss:t,heapTotal:n},r){let i=e.kind===`stand-in`?` unread=${JSON.stringify(e.unread)} gap=${Fr(e.gap)}MB`:``;return`measure=${Kr(e)} charge=${Fr(e.bytes)}MB rss=${Fr(t)}MB heap=${Fr(n)}MB limit=${Fr(r)}MB${i}`}async function Jr(e,t,n){try{await n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function Yr(e){let t=new Map;for(let n of e){let e=E.basename(n),r=Ur(e);if(r===null)continue;let{prefix:i,suffix:a}=Lr[r],o=e.slice(i.length,e.length-a.length);t.set(o,{...t.get(o),[r]:n})}let n=Object.keys(Lr);return[...t].sort(([e],[t])=>Rr(e,t)?-1:1).map(([e,t])=>({identity:e,artifacts:Object.fromEntries(n.flatMap(e=>t[e]===void 0?[]:[[e,t[e]]]))}))}function Xr(e,t,n,r={}){let i=n.snapshotDir;return{clock:n.clock,pid:process.pid,snapshotDir:i,log:n.log,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},memoryCharge:Er(n.launcher,process.platform,process.pid),captureMemoryReport:()=>Cr(Tr(n.launcher,process.platform,process.pid)),writeMemoryReport:(e,t)=>s.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>fe.writeHeapSnapshot(e),writeLogNow:n.writeLogNow,listArtifacts:()=>{let e;try{e=s.readdirSync(i)}catch(e){if(e.code===`ENOENT`)return[];throw e}return e.filter(e=>Ur(e)!==null).map(e=>E.join(i,e))},removeFile:e=>s.unlinkSync(e),shutdown:t,startedAtMs:e,...r}}function Zr(e,n={}){let{host:r,clock:i}=e;if(pi(r)!==null)return;let a=n.spawn??(()=>hi(e)),o=ui(r,i);if(o.kind===`contended`){let e=$r(r,i);e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),Qr(r,i,a));return}if(o.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${o.reason}) — spawning unlocked\n`),Qr(r,i,a);return}try{Qr(r,i,a)}finally{fi()}}function Qr(e,t,n){oi(e,t)&&ei(n)}function $r(e,t){try{let n=s.statSync(xn(e));return t.now()-n.mtimeMs}catch{return null}}function ei(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
7
- `)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function ti(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function ni(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function ri(e){try{let t=s.readFileSync(e,`utf8`).trim(),n=Number(t);return!Number.isInteger(n)||n<0?0:Math.min(n,5)}catch{return 0}}function ii(e,n){try{s.mkdirSync(E.dirname(e),{recursive:!0}),s.writeFileSync(e,String(n),{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.backoff: ${e.message}\n`)}}function ai(e){try{s.unlinkSync(e)}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function oi(e,n){let r=Sn(e),i=Cn(e),a=ri(i),o=ti(si(r,n),ni(a));return o.kind===`deny`?!1:(o.kind===`allow-future-garbage`&&t.stderr.write(`cc-candybar: spawn.cooldown mtime is ${o.futureMs}ms in the future — ignoring and spawning\n`),ci(r,n),ii(i,Math.min(a+1,5)),!0)}function si(e,t){try{return t.now()-s.statSync(e).mtimeMs}catch{return null}}function ci(e,n){try{s.mkdirSync(E.dirname(e),{recursive:!0}),s.writeFileSync(e,`${t.pid} ${n.now()}\n`,{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.cooldown: ${e.message}\n`)}}let li=null;function ui(e,n){let r=xn(e);for(let e=0;e<2;e++){try{let e=s.openSync(r,`wx`,384);try{s.writeSync(e,JSON.stringify({pid:t.pid,ts:n.now()}))}catch{}return li={fd:e,path:r},{kind:`held`}}catch(e){let t=e.code;if(t!==`EEXIST`)return{kind:`error`,reason:`openSync(${r}): ${t??e.message}`}}if(!di(r,n))return{kind:`contended`};try{s.unlinkSync(r)}catch(e){if(e.code!==`ENOENT`)return{kind:`error`,reason:`unlink stale spawn.lock: ${e.message}`}}}return{kind:`contended`}}function di(e,t){try{let n=s.statSync(e);return t.now()-n.mtimeMs>1e4}catch{return!0}}function fi(){if(!li)return;let{fd:e,path:t}=li;li=null;try{s.closeSync(e)}catch{}try{s.unlinkSync(t)}catch{}}function pi(e){try{return s.mkdirSync(dn(e),{recursive:!0}),null}catch(t){return`mkdir ${dn(e)}: ${t.message}`}}function mi(e,t){return[`--max-old-space-size=${Nr(t)}`,e,`daemon`]}function hi({host:e,launcher:n}){let r=t.execPath,i=t.argv[1];return i?n.launchDetachedSync({bin:r,args:mi(i,e.env),category:`daemon-spawn`}).ok:!1}const gi=`closed`,_i=`open`,vi=`🍫`;function yi(e,t,n){if(t===0)return`${e} needs a display (the clickable text)`;if(t!==1&&t!==n)return`${e} cycles ${n} members; bind one display per member (${n}) or one static display, got ${t}`}function bi(e,t,n,r){let i=yi(e,t.length,n);if(i!==void 0)throw Error(i);return t.length===1?t[0]:t[r]}function xi(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function Si(e,t,n,r,i){return{kind:`segment`,name:e,opens:{ref:t,body:n,placement:r},...i!==void 0&&{when:i}}}function Ci(e,...t){return`{{ and ${[e,...t].map(wi).join(` `)} }}`}function wi(e){return`(eq .${e.variable} "${xi(e.member)}")`}function Ti(e,t,n){return`{{ ${Ei(e,Di(t),Di(n))} }}`}function Ei(e,t,n){return`action "${e}" ${t} ${n}`}function Di(e){return`"${xi(e)}"`}function Oi(e,t){return{kind:`state`,key:e,default:t}}function ki(e,t){return{set:e,cycle:[gi,t]}}function Ai(e){if(!(`set`in e&&`cycle`in e))return;let[t,n,...r]=e.cycle;return t===`closed`&&n!==void 0&&r.length===0?{key:e.set,member:n}:void 0}const ji=`groups.`,Mi=`menus.`,Ni=`menupages.`,Pi=`edit.`,P=`candybar.`,Fi=[ji,Mi,Ni,Pi,P];function Ii(e){return Fi.some(t=>e.startsWith(t))}const Li=`${P}menu`,Ri=_i,zi={variable:Li,key:Li,member:Ri},Bi=`${P}diagnostics`,Vi=`cc-candybar`,Hi=`CCCandybarURLHandler`,Ui=`dispatch`,Wi=`set-state`,Gi=`step-state`,Ki=`copy`,qi=`open-vscode`,Ji=`toolbar-toggle`,Yi=`load-config`,Xi=`set-config`,Zi=`step-config`,Qi=`save`,$i=`save-preset`,ea=`save-theme-default`,ta=`delete-preset`,na=`reset-config`,ra=`apply-layout-op`,ia=`undo`,aa=`redo`,oa=`back`,sa=`rewind`,ca=`apply-update`,la=`doctor-run`,ua=`doctor-fix`,da=`doctor-mark`,fa=`doctor-probe`,pa=`slash`,ma=`repo-config`,ha=`copy-diagnostic`,ga=(e,t)=>`step ${e} ${t.startsWith(`-`)?`down`:`up`} by ${t.replace(`-`,``)}`,_a=(e,t)=>e.startsWith(t)?e.slice(t.length):e;function va(e,t){if(e===Bi)return`${t===`0`?`close`:`open`} diagnostics`;let n=`set ${e} to ${t}`;if(!Ii(e))return n;let r=_a(_a(e,Ni),Mi);return e.startsWith(`menupages.`)?`turn ${r} to page ${Number(t)+1}`:t===`closed`?`close ${r}`:t===`open`?`open ${r}`:e.startsWith(`menus.`)?`open ${t}`:n}function ya(e){let t=[...e];return t.length<=60?e:`${t.slice(0,28).join(``)}...${t.slice(-28).join(``)}`}const ba={[Wi]:([,...e])=>e.flatMap((t,n)=>n%2==0?[va(t,e[n+1])]:[]),[Gi]:([,e,t])=>[ga(e,t)],[Ki]:([e])=>[`copy ${ya(e)}`],[qi]:([e])=>[`open ${e} in vs code`],[Ji]:()=>[`toggle the toolbar`],[Yi]:([,e])=>[`load config ${e}`],[Xi]:([,e,t])=>[`save ${e} as ${t}`],[Zi]:([,e,t])=>[`save ${ga(e,t)}`],[Qi]:()=>[`save settings`],[$i]:()=>[`save as a new preset`],[ea]:()=>[`save this look for the theme`],[ta]:([,e])=>[`delete preset ${e}`],[na]:([,...e])=>e.map(e=>`reset ${e}`),[ra]:([,e,t])=>[`edit ${t} in ${e}`],[ia]:()=>[`undo`],[aa]:()=>[`redo`],[oa]:()=>[`go back`],[sa]:()=>[`cancel edits`],[ca]:()=>[`update cc-candybar`],[la]:()=>[`run doctor`],[ua]:([,e])=>[`fix ${e}`],[da]:([,e,t])=>[`mark ${e} ${t}`],[pa]:([,e])=>[`type ${e}`],run:([,e])=>[`run ${e}`],[ma]:([,e,t])=>[`mark config in ${e} ${t}`],[ha]:()=>[`copy diagnostic`]},xa=e=>encodeURIComponent(e).replaceAll(`%20`,`+`).replaceAll(`%2F`,`/`).replaceAll(`%3A`,`:`);function Sa(e){let t=e=>e.verb===`set-state`||e.verb===`step-state`,[n=`nothing`,...r]=[...e.filter(e=>!t(e)),...e.filter(t)].flatMap(e=>ba[e.verb](e.args));return r.length>0?`${n} and ${r.length} more`:n}function Ca(e){return e.map(encodeURIComponent).join(`/`)}function wa(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function Ta(e){return decodeURIComponent(e.split(`/`,1)[0])}function Ea(e,t=Sa(e)){let n=e.map(e=>`e=${encodeURIComponent(`${e.verb}/${Ca(e.args)}`)}`);return`${Vi}://${Ui}/${[`does=${xa(t)}`,...n].join(`&`)}`}function Da(e){return new r(e).getAll(`e`).map(ja)}const Oa=new Set([Wi,na]);function ka(e){return e.reduce((e,t)=>{let n=e.at(-1),r=n&&Aa(n,t);return r?[...e.slice(0,-1),r]:[...e,t]},[])}function Aa(e,t){if(e.verb!==t.verb||!Oa.has(e.verb))return;let[n,r]=[ja(e.value),ja(t.value)];return n.verb===r.verb?{verb:e.verb,value:`${n.verb}/${n.value}/${r.value}`}:void 0}function ja(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}function Ma(e){let t=`${Vi}://`;if(!e.startsWith(t))return{ok:!1,problem:`expected a ${t} link, got: ${e}`};let n=e.slice(t.length),r=n.indexOf(`/`);if(r===-1)return{ok:!0,verb:Ki,value:n};let i=n.slice(0,r);try{return{ok:!0,verb:decodeURIComponent(i),value:n.slice(r+1)}}catch{return{ok:!1,problem:`the link's verb is malformed: ${i}`}}}var Na=Ee(((e,t)=>{t.exports.Space_Separator=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,t.exports.ID_Start=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,t.exports.ID_Continue=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/})),Pa=Ee(((e,t)=>{let n=Na();t.exports={isSpaceSeparator(e){return typeof e==`string`&&n.Space_Separator.test(e)},isIdStartChar(e){return typeof e==`string`&&(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`$`||e===`_`||n.ID_Start.test(e))},isIdContinueChar(e){return typeof e==`string`&&(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`$`||e===`_`||e===`‌`||e===`‍`||n.ID_Continue.test(e))},isDigit(e){return typeof e==`string`&&/[0-9]/.test(e)},isHexDigit(e){return typeof e==`string`&&/[0-9A-Fa-f]/.test(e)}}})),Fa=Ee(((e,t)=>{let n=Pa(),r,i,a,o,s,c,l,u,d;t.exports=function(e,t){r=String(e),i=`start`,a=[],o=0,s=1,c=0,l=void 0,u=void 0,d=void 0;do l=v(),te[i]();while(l.type!==`eof`);return typeof t==`function`?f({"":d},``,t):d};function f(e,t,n){let r=e[t];if(typeof r==`object`&&r)if(Array.isArray(r))for(let e=0;e<r.length;e++){let t=String(e),i=f(r,t,n);i===void 0?delete r[t]:Object.defineProperty(r,t,{value:i,writable:!0,enumerable:!0,configurable:!0})}else for(let e in r){let t=f(r,e,n);t===void 0?delete r[e]:Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}return n.call(e,t,r)}let p,m,h,g,_;function v(){for(p=`default`,m=``,h=!1,g=1;;){_=y();let e=x[p]();if(e)return e}}function y(){if(r[o])return String.fromCodePoint(r.codePointAt(o))}function b(){let e=y();return e===`
2
+ import{createRequire as e}from"node:module";import t from"node:process";import{URL as n,URLSearchParams as r,fileURLToPath as i}from"node:url";import{json as a}from"node:stream/consumers";import o from"node:os";import s,{closeSync as c,constants as l,existsSync as u,fstatSync as d,linkSync as f,mkdtempSync as p,openSync as m,readFileSync as h,readSync as g,rmSync as _,statSync as v,writeFileSync as y}from"node:fs";import{StringDecoder as b}from"node:string_decoder";import{inspect as x,parseArgs as S,types as C}from"node:util";import{clearImmediate as w,setImmediate as T}from"node:timers";import{spawn as ee,spawnSync as te}from"node:child_process";import E,{basename as ne,dirname as D,isAbsolute as O,join as re,sep as k}from"node:path";import ie,{createHash as ae,createHmac as oe,randomBytes as se,randomUUID as ce,timingSafeEqual as le}from"node:crypto";import ue from"node:net";import de from"node:v8";import{open as fe,readFile as pe,readdir as me,stat as he}from"node:fs/promises";import{get as ge}from"node:https";import{WriteStream as _e}from"node:tty";import{createInterface as ve}from"node:readline";var ye=Object.create,be=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyNames,Ce=Object.getPrototypeOf,we=Object.prototype.hasOwnProperty,Te=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Se(t),a=0,o=i.length,s;a<o;a++)s=i[a],!we.call(e,s)&&s!==n&&be(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=xe(t,s))||r.enumerable});return e},De=(e,t,n)=>(n=e==null?{}:ye(Ce(e)),Ee(t||!e||!e.__esModule?be(n,`default`,{value:e,enumerable:!0}):n,e));let Oe=!1;const ke=()=>Oe;function Ae(e){Oe=e}function je(e){return ke()?`[DEBUG] ${e()}\n`:``}function A(e,...t){ke()&&console.error(`[DEBUG] ${e}`,...t)}function Me(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const Ne=(e,t)=>A(t);function Pe(e,t){return Math.round(t-e)}function Fe(e,t){return Pe(t,e.monotonic())}const Ie={now:()=>Date.now(),monotonic:()=>performance.now(),after:(e,t,n)=>{let r=setTimeout(t,e);return n?.unref&&r.unref(),()=>clearTimeout(r)},every:(e,t,n)=>{let r=setInterval(t,e);return n?.unref&&r.unref(),()=>clearInterval(r)},defer:e=>{let t=T(e);return()=>w(t)}};function Le(e,t,n){return new Promise((r,i)=>{let a=()=>Object.assign(Error(`The operation was aborted`),{name:`AbortError`,code:`ABORT_ERR`,cause:n?.reason});if(n?.aborted){i(a());return}let o=()=>{s(),i(a())},s=e.after(t,()=>{n?.removeEventListener(`abort`,o),r()});n?.addEventListener(`abort`,o,{once:!0})})}function Re(e,t){let n=new AbortController;return e.after(t,()=>n.abort(new DOMException(`The operation was aborted due to timeout`,`TimeoutError`)),{unref:!0}),n.signal}function ze(e,t,n,r){return n<e.at+t?`held`:r===`request`&&!e.answered?`owed`:`over`}function Be(e,t){return!e.answered&&e.at===t.at&&e.text===t.text}const Ve=e=>e.getTime()/1e3,He=e=>new Date(e*1e3),Ue=e=>Ve(new Date(e.now()));function We(e,t){return C.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!u(t)?`working directory does not exist: ${t}`:e.message:String(e)}const Ge={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3};function Ke(e,t,n){let r=Ge[t];if(r===void 0)return{allowed:!0};let i=e.get(t);if(i===void 0)return{allowed:!0};let a=n-i;return a>=r?{allowed:!0}:{allowed:!1,minIntervalMs:r,sinceLastMs:a}}function qe(e,t){return{...e.inherited,...t.envOverlay}}function Je(e){switch(e.reason){case`non-zero`:return`exited with code ${e.exitCode}`;case`signal`:return`killed by ${e.signal??`a signal`}`;case`timeout`:case`output-limit`:case`rate-limited`:case`pipe-error`:case`spawn-error`:return e.error??e.reason;default:return e.error===void 0?e.reason:`${e.reason}: ${e.error}`}}const Ye=e=>{let t=[];for(let n of e){if(t.length===200)return`${t.join(``)}…`;t.push(n)}return e};function Xe(e,t){if(e.reason===`output-limit`||e.reason===`pipe-error`)return``;let n=t.trim(),r=n.search(/[\r\n]/);if(r===-1)return Ye(n);let i=Math.max(n.lastIndexOf(`
3
+ `),n.lastIndexOf(`\r`))+1;return`${Ye(n.slice(0,r).trim())} … ${Ye(n.slice(i).trim())}`}function Ze(e,t=``){let n=Xe(e,e.stderr);return`${Je(e)}${t}${n===``?``:`: ${n}`}`}const Qe=({reason:e})=>({ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)});function $e(e,t,n){return{ok:!1,reason:`rate-limited`,stdout:``,stderr:``,exitCode:null,signal:null,error:`rate-limited: ${e} min interval ${t}ms, last start ${Math.round(n)}ms ago`}}function et(e,t){let n=t.finally(()=>e.ending.delete(n));return e.ending.add(n),n}function tt(e,t,n){let r=nt(e,t,n);return r===null?(e.lastStartAt.set(t,e.scope.clock.monotonic()),null):(e.scope.stats?.onRefused(t),r)}function nt(e,t,n){if(e.scope.signal.aborted)return Qe(e.scope.signal);if(n?.aborted)return Qe(n);let r=Ke(e.lastStartAt,t,e.scope.clock.monotonic());return r.allowed?null:$e(t,r.minIntervalMs,r.sinceLastMs)}const rt=`\$1 == "+" { live[\$2] = 1; next } \$1 == "-" { delete live[\$2]; next } END { for (g in live) groups = groups " -" g; if (groups != "") system("kill -TERM" groups " 2>/dev/null; sleep ${250/1e3}; kill -KILL" groups " 2>/dev/null") }`;function it(e,t){t!==e.fault&&(e.fault=t,e.scope.observeWarnings({kind:`lifeline`,fault:t}))}function at(e,t,n){e.lifeline?.process===t&&(e.lifeline=null,t.ref(),it(e,n))}const ot=e=>`programs launched now would outlive their launcher if it died: its launch lifeline ${e}, and the next launch starts another`,st=e=>e===`cut`?`output cut at the ${gt}-byte bound, so the program holding it now fails its writes`:`output failed to read`,ct=`a launched program's pipe outlived its launch: `;function lt(e,t,n){let r=e.pipeEvent,i=new Map(r===null||r.answered?[]:r.counts),a=`${t}\0${n}`;i.set(a,(i.get(a)??0)+1),e.pipeEvent={text:`${ct}${[...i].map(([e,t])=>{let[n,r]=e.split(`\0`);return`${t}× ${r} ${st(n)}`}).join(`; `)}`,at:e.scope.now(),answered:!1,counts:i},e.scope.observeWarnings({kind:`launch-pipes`,text:`${ct}${n} ${st(t)}`})}function ut(e,t){let n=e.pipeEvent;n===null||!Be(n,t)||(e.pipeEvent={...n,answered:!0})}function dt(e,t,n){let r=e.pipeEvent,i=r===null?`over`:ze(r,60,t,n);return[...e.fault===null?[]:[{kind:`lifeline`,message:ot(e.fault)}],...r===null||i===`over`?[]:[{kind:`launch-pipes`,message:r.text,event:r,hold:i}]]}function ft(e){let{stats:t,clock:n}=e.scope;t?.onStart(`lifeline`);let r=n.monotonic(),i;try{i=e.spawner.spawn(`awk`,[rt],{stdio:[`pipe`,`ignore`,`ignore`],detached:!0})}catch(i){return t?.onEnd(`lifeline`,Fe(n,r)),it(e,`did not start: ${We(i,void 0)}`),null}t?.onEnd(`lifeline`,Fe(n,r));let a=i.stdin;if(a==null)return i.once(`error`,t=>it(e,`did not start: ${t.message}`)),null;i.once(`spawn`,()=>{e.lifeline?.process===i&&it(e,null)}),i.once(`error`,t=>at(e,i,`failed: ${t.message}`)),i.once(`exit`,(t,n)=>at(e,i,`exited ${n??t}`)),a.on(`error`,t=>at(e,i,`pipe failed: ${t.message}`)),et(e,new Promise(e=>i.once(`close`,e))),i.unref(),a.unref();for(let t of e.liveGroups)a.write(`+ ${t}\n`);return{process:i,pipe:a}}function pt(e,t){e.liveGroups.add(t),e.lifeline??=ft(e),e.lifeline?.pipe.write(`+ ${t}\n`)}function mt(e,t){e.liveGroups.delete(t),e.lifeline?.pipe.write(`- ${t}\n`)}function ht(e){let t=e.lifeline;e.lifeline=null,t?.process.ref(),t?.pipe.end()}const gt=16*1024*1024,_t=`output exceeded ${gt} bytes`,vt=e=>`timed out after ${e/1e3} s`;function yt(e,t,n,r){let{stats:i}=e.scope,a=new b(`utf8`),o=``,s=0,c=0,l=r,u=`closed`;return n?.on(`error`,n=>{i?.onPipeError(t),l===null?lt(e,`read-error`,t):l.failed(n)}),n?.on(`data`,r=>{if(l===null){if(c+=r.length,i?.onDrainRead(t,r.length),c<=16777216)return;u=`cut`,n.destroy(),lt(e,`cut`,t);return}let d=Math.max(0,gt-s);o+=a.write(r.subarray(0,d)),s+=r.length,s>16777216&&l.full()}),{take:()=>{if(l===null)return``;l=null;let e=o+a.end();return o=``,e},drain:()=>{n===null||n.destroyed||n.readableEnded||bt(e,t,n,()=>u)}}}function bt(e,t,n,r){let{stats:i}=e.scope;if(e.scope.signal.aborted){n.destroy();return}n.once(`close`,()=>{e.drains.delete(n),i?.onDrainClose(t,r())}),n.unref(),e.drains.add(n),i?.onDrainOpen(t)}const xt=()=>`closed`;function St(e,t){e.on(`error`,()=>{}),e.end(t)}async function Ct(e,t){let{stats:n,clock:r}=e.scope,i=tt(e,t.category,t.signal);if(i!==null)return i;let a=r.monotonic();return n?.onStart(t.category),new Promise(i=>{let{spawner:o}=e,s;try{s=o.spawn(t.bin,t.args??[],{cwd:t.cwd,env:qe(e.scope,t),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(e){n?.onEnd(t.category,Fe(r,a)),i({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:We(e,t.cwd)});return}let c=s.pid;c!==void 0&&pt(e,c);let l=new Promise(e=>s.once(`exit`,e)),u=s.stdin;s.stdin=null;let d=null,f={full:()=>te(`output-limit`),failed:e=>{d??=e.message,te(`pipe-error`)}},p=yt(e,t.category,s.stdout,f),m=yt(e,t.category,s.stderr,f),h=()=>({stdout:p.take(),stderr:m.take()}),g=!1,_=null,v=null,y=null,b=null,x=()=>te(`aborted`),S=()=>{t.signal?.removeEventListener(`abort`,x),e.inFlight.delete(x)},C=i=>{g||(g=!0,_?.(),v?.(),y?.(),S(),c!==void 0&&mt(e,c),n?.onEnd(t.category,Fe(r,a)),s.off(`close`,ne),s.off(`error`,E),p.drain(),m.drain(),u!==null&&!u.destroyed&&!u.writableFinished&&bt(e,t.category,u,xt),i())},w=e=>C(()=>i(e)),T=(n,r)=>{try{o.signalGroup(n,r)}catch(n){e.unreaped.set(s,t.category),l.then(()=>e.unreaped.delete(s)),w({ok:!1,reason:`signal-refused`,...h(),exitCode:null,signal:null,error:n instanceof Error?n.message:String(n)})}},ee=()=>ne(s.exitCode,s.signalCode);if(c!==void 0){let e=t=>{if(!g){if(o.groupGone(c)){r.defer(ee);return}y=r.after(t,()=>e(Math.min(t*2,1e3)))}};l.then(()=>r.defer(()=>e(25)))}let te=e=>{if(b!==null)return;if((s.exitCode!==null||s.signalCode!==null)&&c!==void 0&&o.groupGone(c)){b=e===`timeout`?null:e,r.defer(ee);return}b=e,_?.(),S();let t=s.pid;t!==void 0&&(v=r.after(250,()=>{T(t,`SIGKILL`),l.then(()=>r.defer(ee))}),T(t,`SIGTERM`))},E=e=>{w({ok:!1,reason:`spawn-error`,...h(),exitCode:null,signal:null,error:We(e,t.cwd)})};s.on(`error`,E);let ne=(e,n)=>{if(b!==null){w({ok:!1,reason:b,...h(),exitCode:e,signal:n,...b===`timeout`?{error:vt(t.timeoutMs??0)}:b===`output-limit`?{error:_t}:b===`pipe-error`?{error:`a pipe failed to read: ${d}`}:{}});return}if(e===0){w({ok:!0,...h(),exitCode:e});return}w({ok:!1,reason:n?`signal`:`non-zero`,...h(),exitCode:e,signal:n})};s.on(`close`,ne),t.timeoutMs&&t.timeoutMs>0&&(_=r.after(t.timeoutMs,()=>te(`timeout`))),t.signal?.addEventListener(`abort`,x,{once:!0}),e.inFlight.add(x),u!==null&&St(u,t.stdinInput)})}function wt(e,t){let{stats:n,clock:r}=e.scope,i=tt(e,t.category);if(i!==null)return i;let a=r.monotonic();n?.onStart(t.category);try{let i=e.spawner.spawnSync(t.bin,t.args??[],{cwd:t.cwd,env:qe(e.scope,t),input:t.stdinInput,timeout:t.timeoutMs&&t.timeoutMs>0?t.timeoutMs:void 0,stdio:[`pipe`,`pipe`,`pipe`],encoding:`utf8`});n?.onEnd(t.category,Fe(r,a));let o=typeof i.stdout==`string`?i.stdout:``,s=typeof i.stderr==`string`?i.stderr:``,c=i.error?.code;if(i.error&&c!==`EPIPE`&&c!==`ECONNRESET`){let e=c===`ETIMEDOUT`?`timeout`:`spawn-error`;return{ok:!1,reason:e,stdout:o,stderr:s,exitCode:null,signal:i.signal??null,error:e===`timeout`?vt(t.timeoutMs??0):We(i.error,t.cwd)}}return i.status===0?{ok:!0,stdout:o,stderr:s,exitCode:i.status}:{ok:!1,reason:i.signal?`signal`:`non-zero`,stdout:o,stderr:s,exitCode:i.status,signal:i.signal??null}}catch(e){return n?.onEnd(t.category,Fe(r,a)),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:We(e,t.cwd)}}}function Tt(e,t){let{stats:n,clock:r}=e.scope,i=tt(e,t.category);if(i!==null)return i;let a=r.monotonic();n?.onStart(t.category);let o=Et(e,t);return n?.onEnd(t.category,Fe(r,a)),o}function Et(e,t){let n;try{n=e.spawner.spawn(t.bin,t.args??[],{cwd:t.cwd,env:qe(e.scope,t),detached:!0,stdio:`ignore`})}catch(e){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:We(e,t.cwd)}}return n.once(`error`,()=>{}),n.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${t.bin}): no pid (binary not found or unexecutable)`}:(n.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}const Dt=e=>e.kind===`exit`?`exit ${e.code}`:`timeout`;function Ot(e,t,n){let{stats:r,clock:i}=e.scope,a=tt(e,t.category);if(a!==null)return{ok:!1,reason:a.reason,error:a.error};let o=i.monotonic();r?.onStart(t.category);let s;try{s=e.spawner.spawn(`/bin/sh`,[`-c`,`out=$1 err=$2 status=$3; shift 3; read go || exit 0; "$@" >"$out" 2>"$err" </dev/null; echo "exit $?" >"$status.$$" && ln "$status.$$" "$status"; rm -f "$status.$$"`,`sh`,n.stdout,n.stderr,n.status,t.bin,...t.args??[]],{cwd:t.cwd,env:qe(e.scope,t),detached:!0,stdio:[`pipe`,`ignore`,`ignore`]})}catch(e){return r?.onEnd(t.category,Fe(i,o)),{ok:!1,reason:`spawn-error`,error:We(e,t.cwd)}}r?.onEnd(t.category,Fe(i,o)),s.once(`error`,()=>{});let c=s.pid,l=s.stdin;return l.on(`error`,()=>{}),c===void 0?(l.destroy(),{ok:!1,reason:`spawn-error`,error:`spawn(/bin/sh): no pid (shell not found or unexecutable)`}):(s.unref(),l.unref(),{ok:!0,pid:c,release:()=>l.end(`go
4
+ `),withdraw:()=>l.end()})}function kt(e){let t;try{t=h(e,`utf8`).trim()}catch(e){if(e.code===`ENOENT`)return null;throw e}let n=/^exit (\d+)$/.exec(t);if(n)return{kind:`exit`,code:Number(n[1])};if(t===`timeout`)return{kind:`timeout`};throw Error(`${e}: not a job verdict: ${JSON.stringify(t)}`)}function At(e,t,n,r,i){let a=`${r}.${process.pid}`;try{y(a,`${Dt(i)}\n`)}catch(e){if(e.code===`ENOENT`)return{stands:!1,signalled:!1};throw e}let o=!0;try{f(a,r)}catch(e){if(e.code!==`EEXIST`)throw e;o=!1}finally{_(a,{force:!0})}let s=e.signalJob(n,`SIGTERM`);return s&&t.after(250,()=>e.signalJob(n,`SIGKILL`),{unref:!0}),{stands:o,signalled:s}}function jt(e,t,n){return Nt(e,t,n).launcher}function Mt(e,t,n){let{launcher:r,state:i}=Nt(e,t,n);return{...r,launchSync:e=>wt(i,e)}}function Nt(e,t,n){let r={clock:t,launch:e=>et(i,Ct(i,e)),launchDetachedSync:e=>Tt(i,e),launchJobSync:(e,t)=>Ot(i,e,t),jobGroupAlive:e=>n.signalJob(e,0),endJob:(e,r,i)=>At(n,t,e,r,i),launcherWarnings:(e,t)=>dt(i,e,t),answeredPipeEvent:e=>ut(i,e),settled:async()=>(await Promise.all(i.ending),{unreaped:[...i.unreaped.values()]}),__lifelineForTest:()=>{let e=i.lifeline;return{pid:e?.process.pid,cut:()=>{e?.pipe.end(),e&&at(i,e.process,`cut by a test`)}}}},i={spawner:n,scope:{stats:null,observeWarnings:e=>{let t=e.kind===`launch-pipes`?e.text:e.fault===null?null:ot(e.fault);t!==null&&process.emitWarning(t)},signal:new AbortController().signal,now:()=>Ve(new Date(t.now())),...e,clock:t},lastStartAt:new Map,inFlight:new Set,liveGroups:new Set,lifeline:null,fault:null,pipeEvent:null,ending:new Set,unreaped:new Map,drains:new Set};return i.scope.signal.addEventListener(`abort`,()=>{i.inFlight.forEach(e=>e()),i.drains.forEach(e=>e.destroy()),ht(i)},{once:!0}),{launcher:r,state:i}}function Pt(e){try{return process.kill(e,0),!1}catch(e){return e.code===`EPERM`}}const Ft={spawn:(e,t,n)=>ee(e,t,n),spawnSync:(e,t,n)=>te(e,t,n),signalGroup:(e,t)=>{try{process.kill(-e,t)}catch(t){let n=t.code;if(n!==`ESRCH`&&!(n===`EPERM`&&!Pt(e)))throw t}},groupGone:e=>{try{return process.kill(-e,0),!1}catch(e){return e.code===`ESRCH`}},signalJob:(e,t)=>{try{return process.kill(-e,t),!0}catch(e){let t=e.code;if(t===`ESRCH`||t===`EPERM`)return!1;throw e}}},It=(e,t)=>jt(e,t,Ft),Lt=(e,t)=>Mt(e,t,Ft);function Rt(){let e={env:process.env,home:o.homedir(),tmp:o.tmpdir()},t=Ie;return{host:e,launcher:Lt({inherited:process.env},t),clock:t}}const zt=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function Bt(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Vt(e){return zt.test(e)?e:Bt(e)}function Ht(e){return`${e.dir===void 0?``:`cd ${Vt(e.dir)} && `}${e.env.map(([e,t])=>`${e}=${Vt(t)} `).join(``)}${[e.program,...e.args].map(Vt).join(` `)}`}const Ut=`cc-extra`;function j(e){return E.join(E.dirname(e),Ut,`src`,`bun-attach.js`)}function Wt(e){return E.join(E.dirname(e),`bun-graph.js`)}const Gt=`attach-preload.cjs`;function Kt(e){return E.join(E.dirname(e),Gt)}function qt(e,t){return Ht({...t,env:[...t.env,[`BUN_OPTIONS`,`--preload ${e.replace(/[\\\s]/g,`\\$&`)}`]]})}const Jt=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Yt(e,t){return t.isSymbolicLink()?Buffer.from(s.readlinkSync(e)):s.readFileSync(e)}function M(e,t,n=Jt){return s.readdirSync(t).filter(n).sort().flatMap(n=>{let r=E.join(t,n),i=s.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?M(e,r):[[E.relative(e,r).split(E.sep).join(`/`),Yt(r,i)]]})}function Xt(e){let t=ie.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Zt(e){return Xt(M(e,e))}const Qt=[`Cargo.toml`,`Cargo.lock`,`src`];function $t(e){return Xt(M(e,e,e=>Qt.includes(e)))}const en=e=>e.slice(0,7),tn=`1.218.0`;function nn(e){let t=E.dirname(E.dirname(e));return s.existsSync(E.join(t,`src`))?t:null}function rn(e){if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:tn,digest:e}}function an(){return`54de85c325edb8d930b155e59f068fc66cdc12d9cd7238423be52631d97596d4`}function on(e){let t=JSON.parse(s.readFileSync(E.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${E.join(e,`package.json`)} has no version string`);return n}function sn(e,t){try{let n=nn(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Zt(E.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:on(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}function cn(e,t){let n=e[t];return n&&n.length>0?n:void 0}function ln(e){let t=cn(e.env,`XDG_STATE_HOME`)??E.join(e.home,`.local`,`state`);return E.join(t,`cc-candybar`)}function un(e){let t=cn(e.env,`XDG_CACHE_HOME`)??E.join(e.home,`.cache`);return E.join(t,`cc-candybar`)}function dn(e){return ln(e)}function fn(e){return e.env.CC_CANDYBAR_SOCKET||pn()}function pn(){let e=o.userInfo().uid;return E.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function mn(e){s.mkdirSync(e,{recursive:!0,mode:448});let t=s.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=o.userInfo().uid;if(typeof n==`number`&&t.uid!==n)throw Error(`directory is not owned by uid ${n}: ${e} (owner uid=${t.uid})`);if(t.mode&63)throw Error(`directory has unsafe permissions: ${e} (mode=${(t.mode&511).toString(8)}, expected 0700)`)}function hn(e){mn(E.dirname(e));for(let t of[e,gn(e)])try{if(s.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function gn(e){return`${e}.lease`}function _n(e){return gn(fn(e))}function vn(e){return E.join(ln(e),`session-state.json`)}function yn(e){return E.join(ln(e),`settings-history.json`)}function bn(e){let t=e.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(t)return t;let n=o.userInfo().uid;return E.join(`/tmp`,`cc-candybar-${n}`,`daemons`)}function xn(e){return E.join(ln(e),`spawn.lock`)}function Sn(e){return E.join(ln(e),`spawn.cooldown`)}function Cn(e){return E.join(ln(e),`spawn.backoff`)}function wn(e){return E.join(ln(e),`watch-probe`)}function Tn(e){return E.join(ln(e),`daemon.log`)}function N(e){return{socket:fn(e),lease:_n(e),state:ln(e),registry:bn(e),log:Tn(e),sessionState:vn(e),settingsHistory:yn(e),watchProbe:wn(e),spawnBackoff:Cn(e)}}function En(e){let{env:t}=e,n=`/usr/local/share:/usr/share`,r=process.platform===`darwin`?`${E.join(cn(t,`HOMEBREW_PREFIX`)??`/opt/homebrew`,`share`)}:${n}`:n;return{home:e.home,configHome:cn(t,`XDG_CONFIG_HOME`)??E.join(e.home,`.config`),dataHome:cn(t,`XDG_DATA_HOME`)??E.join(e.home,`.local`,`share`),dataDirs:(cn(t,`XDG_DATA_DIRS`)??r).split(`:`).filter(e=>e!==``)}}function Dn(e,t,n){let r=On(e);s.mkdirSync(E.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??s.statSync(r,{throwIfNoEntry:!1})?.mode;try{s.writeFileSync(i,t,a===void 0?{}:{mode:a}),s.renameSync(i,r)}catch(e){throw s.rmSync(i,{force:!0}),e}}function On(e){return kn(e).at(-1)}function kn(e){let{hops:t,stopped:n}=An(e);if(n!==null)throw n;return t}function An(e){let t=[e];try{for(let e=0;e<Mn;e++){let e=jn(t[t.length-1]);if(e===null)return{hops:t,stopped:null};t.push(e)}return{hops:t,stopped:Error(`${e}: more than ${Mn} symbolic links`)}}catch(e){return{hops:t,stopped:e}}}function jn(e){try{return s.lstatSync(e).isSymbolicLink()?E.resolve(s.realpathSync(E.dirname(e)),s.readlinkSync(e)):null}catch(e){let{code:t}=e;if(t===`ENOENT`||t===`ENOTDIR`)return null;throw e}}const Mn=40,Nn=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function Pn(e){return Object.fromEntries(Nn.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const Fn=[`native`,`node`,`frames`];function In(e,t){return{kind:e,bundle:t,source:null}}const Ln=[`ansi`,`frame`],Rn=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,terminalEnv:!0,client:!0});function zn(e){let t=Jn(e.termCols),n=Jn(e.termRows),r=Yn(e.ssh),i=Kn(e.tmux),a=Gn(e.configEnv),o=Gn(e.claudeConfigDir),s=Wn(e.terminalEnv),c=ir(e.client);return{...t!==void 0&&{termCols:t},...n!==void 0&&{termRows:n},...r!==void 0&&{ssh:r},...i!==void 0&&{tmux:i},...a!==void 0&&{configEnv:a},...o!==void 0&&{claudeConfigDir:o},...s!==void 0&&{terminalEnv:s},...c!==void 0&&{client:c}}}function Bn(e,t){return Rn.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function Vn(e){return e.length===0?null:`Client hints refused: ${e.map(({hint:e,sent:t})=>`${e}=${JSON.stringify(t)}`).join(`, `)} — is the statusline client older than the daemon? Reinstall it (\`cc-candybar install\`, or \`just install-rust\` in a checkout).`}const Hn={unknown:e=>`Unknown flags: ${e}`,"no-value":e=>`${e} names no file — the bar renders with no ${e}`,positional:e=>`Unexpected arguments: ${e}`};function Un(e){let t=Object.keys(Hn).flatMap(t=>{let n=e.filter(e=>e.why===t).map(e=>e.arg);return n.length===0?[]:[Hn[t](n.join(`, `))]});return t.length===0?null:t.join(`
5
+ `)}function Wn(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=Nn.filter(e=>t[e]!==void 0);return n.every(e=>typeof t[e]==`string`&&t[e]!==``)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function Gn(e){return typeof e==`string`&&E.isAbsolute(e)?e:void 0}function Kn(e){if(e===null)return null;if(typeof e!=`object`)return;let{socket:t,pane:n,truecolor:r}=e;if(!(typeof t!=`string`||t===``)&&!(typeof n!=`string`||n===``)&&!(r!==null&&(typeof r!=`string`||r===``)))return{socket:t,pane:n,truecolor:r}}const qn=1e4;function Jn(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>qn?qn:t}function Yn(e){return typeof e==`boolean`?e:void 0}const Xn=new Set([...[],1]);function Zn(e){return typeof e==`object`&&e&&e.kind===`url`?{kind:`url`,frame:e}:{kind:`request`,req:e}}var Qn=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}},$n=class extends Error{constructor(e){super(e===`connect`?`CONNECT_TIMEOUT`:`TIMEOUT`),this.phase=e,this.name=`ClientTimeoutError`}};function er(e){return tr(JSON.stringify(e))}function tr(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function nr(e,t){let n=Buffer.alloc(0);return function(r){for(n=Buffer.concat([n,r]);n.length>=4;){let r=n.readUInt32BE(0);if(r>16777216){t(new Qn(`frame too large: ${r}`));return}if(n.length<4+r)return;let i=n.subarray(4,4+r);n=n.subarray(4+r);try{e(JSON.parse(i.toString(`utf8`)))}catch(e){let n=new Qn(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function rr(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=t=>{if(!o){o=!0,c(),e.off(`data`,l),e.off(`error`,u),e.off(`close`,d);try{t()}catch{}}},c=r.after(n-r.now(),()=>{s(()=>{e.destroy(),a(new $n(`deadline`))})}),l=nr(e=>s(()=>i(e)),e=>s(()=>a(e))),u=e=>s(()=>a(e)),d=()=>s(()=>a(Error(`socket closed before response`)));e.on(`data`,l),e.on(`error`,u),e.on(`close`,d),e.write(er(t))})}function ir(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=Gn(n);return Fn.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function ar(e,t,n,r){let i;try{i=await dr(fn(e.host),n.connectMs,e.clock)}catch(e){return ur(e)}return or(i,e.clock,t,n,r)}async function or(e,t,n,r,i){try{let a=t.now()+r.budgetMs,o=n(a),s=await rr(e,{v:3,...o},a,t);return lr(o.kind,s,i)}catch(e){return ur(e)}finally{e.destroy()}}function sr(e,t){return typeof e==`string`?e:t}function cr(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function lr(e,t,n){let r=t;if(r.ok===!0){let r=n(t);return r===void 0?{kind:`permanent`,cause:`malformed_response`,message:`ok response without payload for "${e}" request`}:{kind:`ok`,value:r}}let i=sr(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:cr(r.daemonV)};case`TIMEOUT`:return{kind:`busy`,phase:`deadline`,message:i};case`BAD_REQUEST`:return{kind:`permanent`,cause:`bad_request`,message:i};case`RENDER_FAILED`:return{kind:`permanent`,cause:`render_failed`,message:i};case`SWITCHED_OFF`:return{kind:`permanent`,cause:`switched_off`,message:i};default:return{kind:`permanent`,cause:`malformed_response`,message:`unknown error code: ${String(r.code)}`}}}function ur(e){if(e instanceof Qn||e instanceof SyntaxError)return{kind:`permanent`,cause:`malformed_response`,message:e instanceof Error?e.message:String(e)};let t=e instanceof Error?e.message:String(e);return e instanceof $n?{kind:`busy`,phase:e.phase,message:t}:t.includes(`ECONNREFUSED`)||t.includes(`ENOENT`)||t.includes(`ENOTSOCK`)?{kind:`transient`,cause:`unreachable`,message:t}:{kind:`transient`,cause:`io_error`,message:t}}function dr(e,t,n){return new Promise((r,i)=>{let a=ue.createConnection({path:e}),o=n.after(t,()=>{a.destroy(),i(new $n(`connect`))});a.once(`connect`,()=>{o(),r(a)}),a.once(`error`,e=>{o(),i(e)})})}function fr(e){if(e.kind===`busy`)return`daemon busy (${e.message})`;if(e.kind===`transient`)return`daemon unavailable (${e.cause}: ${e.message})\nHint: daemon may not be running. Run \`cc-candybar\` once to spawn it.`;switch(e.cause){case`version_mismatch`:{let t=e.daemonV===0?`unknown`:`v${e.daemonV}`;return`daemon protocol mismatch (client v${e.clientV} ≠ daemon ${t})`}case`bad_request`:case`render_failed`:case`switched_off`:case`malformed_response`:return`daemon error (${e.cause}): ${e.message}`}}function pr(e){return e===void 0?{kind:`unstated`}:typeof e==`number`&&Number.isSafeInteger(e)&&e>0?{kind:`stated`,at:e}:{kind:`refused`,problem:`request 'deadline' is not epoch milliseconds: ${JSON.stringify(e)}`}}function mr(e,t,n){let r=e.kind===`stated`?n.monoMs+(e.at-n.epochMs):t+150-50,i=Math.min(r,t+200);return Math.round(i-60-n.monoMs)}const hr={connectMs:50,budgetMs:150},gr={connectMs:50,budgetMs:350};function _r(e){let t=e.output;return typeof t==`string`?t:void 0}function vr(e){return lr(`render`,e,_r)}function yr(e,t,n,r,i,a=hr){return ar(e,e=>({kind:`render`,hookData:t,args:n,cwd:r,deadline:e,...i}),a,_r)}function br(e,t,n){return ar(e,()=>({kind:`pane-session`,socket:t,pane:n}),gr,e=>`paneSession`in e?e.paneSession:void 0)}function xr(e,t,n){return ar(e,()=>({kind:`click`,verb:t,value:n}),gr,_r)}const Sr=5e3;async function Cr(e){let t=[];for(let n of e){let e=await n.read();if(e.kind===`text`)return`# memory report from: ${n.name}\n${e.text}`;t.push(`# ${n.name}: unavailable — ${e.reason}`)}return[`# memory report: no probe answered`,...t.length>0?t:[`# no probe is known for this platform`]].join(`
6
+ `)}const wr=`/usr/bin/footprint`;function Tr(e,t,n){return t===`darwin`?[kr(e,wr,[`-p`,String(n)]),kr(e,`/usr/bin/vmmap`,[`--summary`,String(n)])]:t===`linux`?[Ar(`/proc/self/smaps_rollup`),Ar(`/proc/self/status`)]:[]}function Er(e,t,n){return t===`darwin`?Dr(n,t=>e.launch({bin:wr,args:t,timeoutMs:Sr,category:`limits.charge`})):async e=>({kind:`charged`,measure:`rss`,bytes:e})}function Dr(e,t){return async n=>{let r=await t([`-p`,String(e),`--noCategories`,`-f`,`bytes`]);if(!r.ok)return{kind:`stand-in`,bytes:n,unread:`footprint ${Ze(r)}`};let i=Or(r.stdout);return i===null?{kind:`stand-in`,bytes:n,unread:`footprint printed no phys_footprint line`}:{kind:`charged`,measure:`phys_footprint`,bytes:i}}}function Or(e){let t=/^\s*phys_footprint:\s+(\d+) B\s*$/m.exec(e);return t===null?null:Number(t[1])}function kr(e,t,n){return{name:`${t} ${n.join(` `)}`,read:async()=>{let r=await e.launch({bin:t,args:[...n],timeoutMs:Sr,category:`limits.memory-report`});return r.ok?r.stdout.trim().length>0?{kind:`text`,text:r.stdout}:{kind:`unavailable`,reason:`exited 0 but printed nothing`}:{kind:`unavailable`,reason:Ze(r)}}}}function Ar(e){return{name:e,read:async()=>{try{let t=s.readFileSync(e,`utf8`);return t.trim().length>0?{kind:`text`,text:t}:{kind:`unavailable`,reason:`empty file`}}catch(e){return{kind:`unavailable`,reason:e.message}}}}}const jr=`CC_CANDYBAR_RSS_LIMIT_MB`;function Mr(e){let t=e[jr];if(t===void 0)return 1024;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${jr} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function Nr(e){return Mr(e)*2}const Pr=1024*1024,Fr=e=>Math.round(e/Pr);function Ir(e){return Mr(e)*Pr}const Lr={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function Rr(e,t){return e>t}function zr(e,t){if(e.kind===`charged`)return e;let n=t.kind===`unmeasured`?0:t.charge.kind===`charged`?t.rss-t.charge.bytes:t.charge.gap;return{...e,bytes:e.bytes-n,gap:n}}const Br=.75;function Vr(e,t){return e>t*Br}function Hr(e,t,n){let{prefix:r,suffix:i}=Lr[t];return E.join(e,`${r}${n}${i}`)}function Ur(e){for(let t of Object.keys(Lr)){let{prefix:n,suffix:r}=Lr[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function Wr(e){let t=e.limitBytes??1024*Pr,n=e.snapshotsKeep??3,r=!1,i={kind:`unmeasured`},a=null,o=!1,s;function c(){return a??=l().finally(()=>{a=null}),a}async function l(){if(r)return!0;let{rss:a,heapTotal:s}=e.memoryBytes(),c=zr(await e.memoryCharge(a),i),l={kind:`measured`,charge:c,rss:a,heapTotal:s};if(i=l,e.log(`info`,`memory ${qr(l,t)}`),o||c.bytes<=t)return!1;r=!0,e.log(`warn`,`${Gr(c)} > limit ${Fr(t)} MB (rss ${Fr(a)} MB, v8 heap ${Fr(s)} MB); recording memory then shutting down`);let u=`${new Date(e.clock.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return await Jr(e.log,`memory report`,async()=>{let t=Hr(e.snapshotDir,`memoryReport`,u),n=await e.captureMemoryReport();o||(e.writeMemoryReport(t,n),e.log(`info`,`memory report written: ${t}`))}),o?(e.log(`info`,`daemon closed during the breach: no snapshot, no exit`),!1):(await Jr(e.log,`heap snapshot`,()=>{e.writeLogNow();let t=Hr(e.snapshotDir,`heapSnapshot`,u);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),await Jr(e.log,`artifact rotation`,async()=>{for(let{artifacts:t}of Yr(e.listArtifacts()).slice(n))for(let n of Object.values(t))await Jr(e.log,`evicting ${n}`,()=>e.removeFile(n))}),e.shutdown(0),!0)}function u(){return i.kind===`measured`&&Vr(i.charge.bytes,t)?`${Gr(i.charge)} approaching limit ${Fr(t)} MB (v8 heap ${Fr(i.heapTotal)} MB)`:null}function d(){let n;try{n={kind:`ok`,value:Yr(e.listArtifacts())}}catch(e){n={kind:`failed`,reason:e.message}}return{pid:e.pid,memory:i,limit:t,postMortems:n}}function f(t=6e4){let n=async()=>{try{if(await c())return}catch(t){e.log(`warn`,`memory check failed: ${t.message}`)}o||(s=e.clock.after(t,()=>void n(),{unref:!0}))};n()}function p(){o=!0,s?.()}return{check:c,describeNextRestart:u,serving:d,arm:f,disarm:p}}function Gr(e){return e.kind===`charged`?`${e.measure} ${Fr(e.bytes)} MB`:`rss ${Fr(e.bytes+e.gap)} MB${e.gap===0?``:` less its last ${Fr(e.gap)} MB gap`} (standing in: ${e.unread})`}function Kr(e){return e.kind===`charged`?e.measure:`rss-stand-in`}function qr({charge:e,rss:t,heapTotal:n},r){let i=e.kind===`stand-in`?` unread=${JSON.stringify(e.unread)} gap=${Fr(e.gap)}MB`:``;return`measure=${Kr(e)} charge=${Fr(e.bytes)}MB rss=${Fr(t)}MB heap=${Fr(n)}MB limit=${Fr(r)}MB${i}`}async function Jr(e,t,n){try{await n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function Yr(e){let t=new Map;for(let n of e){let e=E.basename(n),r=Ur(e);if(r===null)continue;let{prefix:i,suffix:a}=Lr[r],o=e.slice(i.length,e.length-a.length);t.set(o,{...t.get(o),[r]:n})}let n=Object.keys(Lr);return[...t].sort(([e],[t])=>Rr(e,t)?-1:1).map(([e,t])=>({identity:e,artifacts:Object.fromEntries(n.flatMap(e=>t[e]===void 0?[]:[[e,t[e]]]))}))}function Xr(e,t,n,r={}){let i=n.snapshotDir;return{clock:n.clock,pid:process.pid,snapshotDir:i,log:n.log,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},memoryCharge:Er(n.launcher,process.platform,process.pid),captureMemoryReport:()=>Cr(Tr(n.launcher,process.platform,process.pid)),writeMemoryReport:(e,t)=>s.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>de.writeHeapSnapshot(e),writeLogNow:n.writeLogNow,listArtifacts:()=>{let e;try{e=s.readdirSync(i)}catch(e){if(e.code===`ENOENT`)return[];throw e}return e.filter(e=>Ur(e)!==null).map(e=>E.join(i,e))},removeFile:e=>s.unlinkSync(e),shutdown:t,startedAtMs:e,...r}}function Zr(e,n={}){let{host:r,clock:i}=e;if(pi(r)!==null)return;let a=n.spawn??(()=>hi(e)),o=ui(r,i);if(o.kind===`contended`){let e=$r(r,i);e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),Qr(r,i,a));return}if(o.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${o.reason}) — spawning unlocked\n`),Qr(r,i,a);return}try{Qr(r,i,a)}finally{fi()}}function Qr(e,t,n){oi(e,t)&&ei(n)}function $r(e,t){try{let n=s.statSync(xn(e));return t.now()-n.mtimeMs}catch{return null}}function ei(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
7
+ `)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function ti(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function ni(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function ri(e){try{let t=s.readFileSync(e,`utf8`).trim(),n=Number(t);return!Number.isInteger(n)||n<0?0:Math.min(n,5)}catch{return 0}}function ii(e,n){try{s.mkdirSync(E.dirname(e),{recursive:!0}),s.writeFileSync(e,String(n),{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.backoff: ${e.message}\n`)}}function ai(e){try{s.unlinkSync(e)}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function oi(e,n){let r=Sn(e),i=Cn(e),a=ri(i),o=ti(si(r,n),ni(a));return o.kind===`deny`?!1:(o.kind===`allow-future-garbage`&&t.stderr.write(`cc-candybar: spawn.cooldown mtime is ${o.futureMs}ms in the future — ignoring and spawning\n`),ci(r,n),ii(i,Math.min(a+1,5)),!0)}function si(e,t){try{return t.now()-s.statSync(e).mtimeMs}catch{return null}}function ci(e,n){try{s.mkdirSync(E.dirname(e),{recursive:!0}),s.writeFileSync(e,`${t.pid} ${n.now()}\n`,{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.cooldown: ${e.message}\n`)}}let li=null;function ui(e,n){let r=xn(e);for(let e=0;e<2;e++){try{let e=s.openSync(r,`wx`,384);try{s.writeSync(e,JSON.stringify({pid:t.pid,ts:n.now()}))}catch{}return li={fd:e,path:r},{kind:`held`}}catch(e){let t=e.code;if(t!==`EEXIST`)return{kind:`error`,reason:`openSync(${r}): ${t??e.message}`}}if(!di(r,n))return{kind:`contended`};try{s.unlinkSync(r)}catch(e){if(e.code!==`ENOENT`)return{kind:`error`,reason:`unlink stale spawn.lock: ${e.message}`}}}return{kind:`contended`}}function di(e,t){try{let n=s.statSync(e);return t.now()-n.mtimeMs>1e4}catch{return!0}}function fi(){if(!li)return;let{fd:e,path:t}=li;li=null;try{s.closeSync(e)}catch{}try{s.unlinkSync(t)}catch{}}function pi(e){try{return s.mkdirSync(dn(e),{recursive:!0}),null}catch(t){return`mkdir ${dn(e)}: ${t.message}`}}function mi(e,t){return[`--max-old-space-size=${Nr(t)}`,e,`daemon`]}function hi({host:e,launcher:n}){let r=t.execPath,i=t.argv[1];return i?n.launchDetachedSync({bin:r,args:mi(i,e.env),category:`daemon-spawn`}).ok:!1}const gi=`closed`,_i=`open`,vi=`🍫`;function yi(e,t,n){if(t===0)return`${e} needs a display (the clickable text)`;if(t!==1&&t!==n)return`${e} cycles ${n} members; bind one display per member (${n}) or one static display, got ${t}`}function bi(e,t,n,r){let i=yi(e,t.length,n);if(i!==void 0)throw Error(i);return t.length===1?t[0]:t[r]}function xi(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function Si(e,t,n,r,i){return{kind:`segment`,name:e,opens:{ref:t,body:n,placement:r},...i!==void 0&&{when:i}}}function Ci(e,...t){return`{{ and ${[e,...t].map(wi).join(` `)} }}`}function wi(e){return`(eq .${e.variable} "${xi(e.member)}")`}function Ti(e,t,n){return`{{ ${Ei(e,Di(t),Di(n))} }}`}function Ei(e,t,n){return`action "${e}" ${t} ${n}`}function Di(e){return`"${xi(e)}"`}function Oi(e,t){return{kind:`state`,key:e,default:t}}function ki(e,t){return{set:e,cycle:[gi,t]}}function Ai(e){if(!(`set`in e&&`cycle`in e))return;let[t,n,...r]=e.cycle;return t===`closed`&&n!==void 0&&r.length===0?{key:e.set,member:n}:void 0}const ji=`groups.`,Mi=`menus.`,Ni=`menupages.`,Pi=`edit.`,P=`candybar.`,Fi=[ji,Mi,Ni,Pi,P];function Ii(e){return Fi.some(t=>e.startsWith(t))}const Li=`${P}menu`,Ri=_i,zi={variable:Li,key:Li,member:Ri},Bi=`${P}diagnostics`,Vi=`cc-candybar`,Hi=`CCCandybarURLHandler`,Ui=`dispatch`,Wi=`set-state`,Gi=`step-state`,Ki=`copy`,qi=`open-vscode`,Ji=`toolbar-toggle`,Yi=`load-config`,Xi=`set-config`,Zi=`step-config`,Qi=`save`,$i=`save-preset`,ea=`save-theme-default`,ta=`delete-preset`,na=`reset-config`,ra=`apply-layout-op`,ia=`undo`,aa=`redo`,oa=`back`,sa=`rewind`,ca=`apply-update`,la=`doctor-run`,ua=`doctor-fix`,da=`doctor-mark`,fa=`doctor-probe`,pa=`slash`,ma=`repo-config`,ha=`copy-diagnostic`,ga=(e,t)=>`step ${e} ${t.startsWith(`-`)?`down`:`up`} by ${t.replace(`-`,``)}`,_a=(e,t)=>e.startsWith(t)?e.slice(t.length):e;function va(e,t){if(e===Bi)return`${t===`0`?`close`:`open`} diagnostics`;let n=`set ${e} to ${t}`;if(!Ii(e))return n;let r=_a(_a(e,Ni),Mi);return e.startsWith(`menupages.`)?`turn ${r} to page ${Number(t)+1}`:t===`closed`?`close ${r}`:t===`open`?`open ${r}`:e.startsWith(`menus.`)?`open ${t}`:n}function ya(e){let t=[...e];return t.length<=60?e:`${t.slice(0,28).join(``)}...${t.slice(-28).join(``)}`}const ba={[Wi]:([,...e])=>e.flatMap((t,n)=>n%2==0?[va(t,e[n+1])]:[]),[Gi]:([,e,t])=>[ga(e,t)],[Ki]:([e])=>[`copy ${ya(e)}`],[qi]:([e])=>[`open ${e} in vs code`],[Ji]:()=>[`toggle the toolbar`],[Yi]:([,e])=>[`load config ${e}`],[Xi]:([,e,t])=>[`save ${e} as ${t}`],[Zi]:([,e,t])=>[`save ${ga(e,t)}`],[Qi]:()=>[`save settings`],[$i]:()=>[`save as a new preset`],[ea]:()=>[`save this look for the theme`],[ta]:([,e])=>[`delete preset ${e}`],[na]:([,...e])=>e.map(e=>`reset ${e}`),[ra]:([,e,t])=>[`edit ${t} in ${e}`],[ia]:()=>[`undo`],[aa]:()=>[`redo`],[oa]:()=>[`go back`],[sa]:()=>[`cancel edits`],[ca]:()=>[`update cc-candybar`],[la]:()=>[`run doctor`],[ua]:([,e])=>[`fix ${e}`],[da]:([,e,t])=>[`mark ${e} ${t}`],[pa]:([,e])=>[`type ${e}`],run:([,e])=>[`run ${e}`],[ma]:([,e,t])=>[`mark config in ${e} ${t}`],[ha]:()=>[`copy diagnostic`]},xa=e=>encodeURIComponent(e).replaceAll(`%20`,`+`).replaceAll(`%2F`,`/`).replaceAll(`%3A`,`:`);function Sa(e){let t=e=>e.verb===`set-state`||e.verb===`step-state`,[n=`nothing`,...r]=[...e.filter(e=>!t(e)),...e.filter(t)].flatMap(e=>ba[e.verb](e.args));return r.length>0?`${n} and ${r.length} more`:n}function Ca(e){return e.map(encodeURIComponent).join(`/`)}function wa(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function Ta(e){return decodeURIComponent(e.split(`/`,1)[0])}function Ea(e,t=Sa(e)){let n=e.map(e=>`e=${encodeURIComponent(`${e.verb}/${Ca(e.args)}`)}`);return`${Vi}://${Ui}/${[`does=${xa(t)}`,...n].join(`&`)}`}function Da(e){return new r(e).getAll(`e`).map(ja)}const Oa=new Set([Wi,na]);function ka(e){return e.reduce((e,t)=>{let n=e.at(-1),r=n&&Aa(n,t);return r?[...e.slice(0,-1),r]:[...e,t]},[])}function Aa(e,t){if(e.verb!==t.verb||!Oa.has(e.verb))return;let[n,r]=[ja(e.value),ja(t.value)];return n.verb===r.verb?{verb:e.verb,value:`${n.verb}/${n.value}/${r.value}`}:void 0}function ja(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}function Ma(e){let t=`${Vi}://`;if(!e.startsWith(t))return{ok:!1,problem:`expected a ${t} link, got: ${e}`};let n=e.slice(t.length),r=n.indexOf(`/`);if(r===-1)return{ok:!0,verb:Ki,value:n};let i=n.slice(0,r);try{return{ok:!0,verb:decodeURIComponent(i),value:n.slice(r+1)}}catch{return{ok:!1,problem:`the link's verb is malformed: ${i}`}}}var Na=Te(((e,t)=>{t.exports.Space_Separator=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,t.exports.ID_Start=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,t.exports.ID_Continue=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/})),Pa=Te(((e,t)=>{let n=Na();t.exports={isSpaceSeparator(e){return typeof e==`string`&&n.Space_Separator.test(e)},isIdStartChar(e){return typeof e==`string`&&(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`$`||e===`_`||n.ID_Start.test(e))},isIdContinueChar(e){return typeof e==`string`&&(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`$`||e===`_`||e===`‌`||e===`‍`||n.ID_Continue.test(e))},isDigit(e){return typeof e==`string`&&/[0-9]/.test(e)},isHexDigit(e){return typeof e==`string`&&/[0-9A-Fa-f]/.test(e)}}})),Fa=Te(((e,t)=>{let n=Pa(),r,i,a,o,s,c,l,u,d;t.exports=function(e,t){r=String(e),i=`start`,a=[],o=0,s=1,c=0,l=void 0,u=void 0,d=void 0;do l=v(),te[i]();while(l.type!==`eof`);return typeof t==`function`?f({"":d},``,t):d};function f(e,t,n){let r=e[t];if(typeof r==`object`&&r)if(Array.isArray(r))for(let e=0;e<r.length;e++){let t=String(e),i=f(r,t,n);i===void 0?delete r[t]:Object.defineProperty(r,t,{value:i,writable:!0,enumerable:!0,configurable:!0})}else for(let e in r){let t=f(r,e,n);t===void 0?delete r[e]:Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}return n.call(e,t,r)}let p,m,h,g,_;function v(){for(p=`default`,m=``,h=!1,g=1;;){_=y();let e=x[p]();if(e)return e}}function y(){if(r[o])return String.fromCodePoint(r.codePointAt(o))}function b(){let e=y();return e===`
8
8
  `?(s++,c=0):e?c+=e.length:c++,e&&(o+=e.length),e}let x={default(){switch(_){case` `:case`\v`:case`\f`:case` `:case`\xA0`:case``:case`
9
9
  `:case`\r`:case`\u2028`:case`\u2029`:b();return;case`/`:b(),p=`comment`;return;case void 0:return b(),S(`eof`)}if(n.isSpaceSeparator(_)){b();return}return x[i]()},comment(){switch(_){case`*`:b(),p=`multiLineComment`;return;case`/`:b(),p=`singleLineComment`;return}throw D(b())},multiLineComment(){switch(_){case`*`:b(),p=`multiLineCommentAsterisk`;return;case void 0:throw D(b())}b()},multiLineCommentAsterisk(){switch(_){case`*`:b();return;case`/`:b(),p=`default`;return;case void 0:throw D(b())}b(),p=`multiLineComment`},singleLineComment(){switch(_){case`
10
- `:case`\r`:case`\u2028`:case`\u2029`:b(),p=`default`;return;case void 0:return b(),S(`eof`)}b()},value(){switch(_){case`{`:case`[`:return S(`punctuator`,b());case`n`:return b(),C(`ull`),S(`null`,null);case`t`:return b(),C(`rue`),S(`boolean`,!0);case`f`:return b(),C(`alse`),S(`boolean`,!1);case`-`:case`+`:b()===`-`&&(g=-1),p=`sign`;return;case`.`:m=b(),p=`decimalPointLeading`;return;case`0`:m=b(),p=`zero`;return;case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:m=b(),p=`decimalInteger`;return;case`I`:return b(),C(`nfinity`),S(`numeric`,1/0);case`N`:return b(),C(`aN`),S(`numeric`,NaN);case`"`:case`'`:h=b()===`"`,m=``,p=`string`;return}throw D(b())},identifierNameStartEscape(){if(_!==`u`)throw D(b());b();let e=ee();switch(e){case`$`:case`_`:break;default:if(!n.isIdStartChar(e))throw ie();break}m+=e,p=`identifierName`},identifierName(){switch(_){case`$`:case`_`:case`‌`:case`‍`:m+=b();return;case`\\`:b(),p=`identifierNameEscape`;return}if(n.isIdContinueChar(_)){m+=b();return}return S(`identifier`,m)},identifierNameEscape(){if(_!==`u`)throw D(b());b();let e=ee();switch(e){case`$`:case`_`:case`‌`:case`‍`:break;default:if(!n.isIdContinueChar(e))throw ie();break}m+=e,p=`identifierName`},sign(){switch(_){case`.`:m=b(),p=`decimalPointLeading`;return;case`0`:m=b(),p=`zero`;return;case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:m=b(),p=`decimalInteger`;return;case`I`:return b(),C(`nfinity`),S(`numeric`,g*(1/0));case`N`:return b(),C(`aN`),S(`numeric`,NaN)}throw D(b())},zero(){switch(_){case`.`:m+=b(),p=`decimalPoint`;return;case`e`:case`E`:m+=b(),p=`decimalExponent`;return;case`x`:case`X`:m+=b(),p=`hexadecimal`;return}return S(`numeric`,g*0)},decimalInteger(){switch(_){case`.`:m+=b(),p=`decimalPoint`;return;case`e`:case`E`:m+=b(),p=`decimalExponent`;return}if(n.isDigit(_)){m+=b();return}return S(`numeric`,g*Number(m))},decimalPointLeading(){if(n.isDigit(_)){m+=b(),p=`decimalFraction`;return}throw D(b())},decimalPoint(){switch(_){case`e`:case`E`:m+=b(),p=`decimalExponent`;return}if(n.isDigit(_)){m+=b(),p=`decimalFraction`;return}return S(`numeric`,g*Number(m))},decimalFraction(){switch(_){case`e`:case`E`:m+=b(),p=`decimalExponent`;return}if(n.isDigit(_)){m+=b();return}return S(`numeric`,g*Number(m))},decimalExponent(){switch(_){case`+`:case`-`:m+=b(),p=`decimalExponentSign`;return}if(n.isDigit(_)){m+=b(),p=`decimalExponentInteger`;return}throw D(b())},decimalExponentSign(){if(n.isDigit(_)){m+=b(),p=`decimalExponentInteger`;return}throw D(b())},decimalExponentInteger(){if(n.isDigit(_)){m+=b();return}return S(`numeric`,g*Number(m))},hexadecimal(){if(n.isHexDigit(_)){m+=b(),p=`hexadecimalInteger`;return}throw D(b())},hexadecimalInteger(){if(n.isHexDigit(_)){m+=b();return}return S(`numeric`,g*Number(m))},string(){switch(_){case`\\`:b(),m+=w();return;case`"`:if(h)return b(),S(`string`,m);m+=b();return;case`'`:if(!h)return b(),S(`string`,m);m+=b();return;case`
11
- `:case`\r`:throw D(b());case`\u2028`:case`\u2029`:O(_);break;case void 0:throw D(b())}m+=b()},start(){switch(_){case`{`:case`[`:return S(`punctuator`,b())}p=`value`},beforePropertyName(){switch(_){case`$`:case`_`:m=b(),p=`identifierName`;return;case`\\`:b(),p=`identifierNameStartEscape`;return;case`}`:return S(`punctuator`,b());case`"`:case`'`:h=b()===`"`,p=`string`;return}if(n.isIdStartChar(_)){m+=b(),p=`identifierName`;return}throw D(b())},afterPropertyName(){if(_===`:`)return S(`punctuator`,b());throw D(b())},beforePropertyValue(){p=`value`},afterPropertyValue(){switch(_){case`,`:case`}`:return S(`punctuator`,b())}throw D(b())},beforeArrayValue(){if(_===`]`)return S(`punctuator`,b());p=`value`},afterArrayValue(){switch(_){case`,`:case`]`:return S(`punctuator`,b())}throw D(b())},end(){throw D(b())}};function S(e,t){return{type:e,value:t,line:s,column:c}}function C(e){for(let t of e){if(y()!==t)throw D(b());b()}}function w(){switch(y()){case`b`:return b(),`\b`;case`f`:return b(),`\f`;case`n`:return b(),`
10
+ `:case`\r`:case`\u2028`:case`\u2029`:b(),p=`default`;return;case void 0:return b(),S(`eof`)}b()},value(){switch(_){case`{`:case`[`:return S(`punctuator`,b());case`n`:return b(),C(`ull`),S(`null`,null);case`t`:return b(),C(`rue`),S(`boolean`,!0);case`f`:return b(),C(`alse`),S(`boolean`,!1);case`-`:case`+`:b()===`-`&&(g=-1),p=`sign`;return;case`.`:m=b(),p=`decimalPointLeading`;return;case`0`:m=b(),p=`zero`;return;case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:m=b(),p=`decimalInteger`;return;case`I`:return b(),C(`nfinity`),S(`numeric`,1/0);case`N`:return b(),C(`aN`),S(`numeric`,NaN);case`"`:case`'`:h=b()===`"`,m=``,p=`string`;return}throw D(b())},identifierNameStartEscape(){if(_!==`u`)throw D(b());b();let e=ee();switch(e){case`$`:case`_`:break;default:if(!n.isIdStartChar(e))throw re();break}m+=e,p=`identifierName`},identifierName(){switch(_){case`$`:case`_`:case`‌`:case`‍`:m+=b();return;case`\\`:b(),p=`identifierNameEscape`;return}if(n.isIdContinueChar(_)){m+=b();return}return S(`identifier`,m)},identifierNameEscape(){if(_!==`u`)throw D(b());b();let e=ee();switch(e){case`$`:case`_`:case`‌`:case`‍`:break;default:if(!n.isIdContinueChar(e))throw re();break}m+=e,p=`identifierName`},sign(){switch(_){case`.`:m=b(),p=`decimalPointLeading`;return;case`0`:m=b(),p=`zero`;return;case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:m=b(),p=`decimalInteger`;return;case`I`:return b(),C(`nfinity`),S(`numeric`,g*(1/0));case`N`:return b(),C(`aN`),S(`numeric`,NaN)}throw D(b())},zero(){switch(_){case`.`:m+=b(),p=`decimalPoint`;return;case`e`:case`E`:m+=b(),p=`decimalExponent`;return;case`x`:case`X`:m+=b(),p=`hexadecimal`;return}return S(`numeric`,g*0)},decimalInteger(){switch(_){case`.`:m+=b(),p=`decimalPoint`;return;case`e`:case`E`:m+=b(),p=`decimalExponent`;return}if(n.isDigit(_)){m+=b();return}return S(`numeric`,g*Number(m))},decimalPointLeading(){if(n.isDigit(_)){m+=b(),p=`decimalFraction`;return}throw D(b())},decimalPoint(){switch(_){case`e`:case`E`:m+=b(),p=`decimalExponent`;return}if(n.isDigit(_)){m+=b(),p=`decimalFraction`;return}return S(`numeric`,g*Number(m))},decimalFraction(){switch(_){case`e`:case`E`:m+=b(),p=`decimalExponent`;return}if(n.isDigit(_)){m+=b();return}return S(`numeric`,g*Number(m))},decimalExponent(){switch(_){case`+`:case`-`:m+=b(),p=`decimalExponentSign`;return}if(n.isDigit(_)){m+=b(),p=`decimalExponentInteger`;return}throw D(b())},decimalExponentSign(){if(n.isDigit(_)){m+=b(),p=`decimalExponentInteger`;return}throw D(b())},decimalExponentInteger(){if(n.isDigit(_)){m+=b();return}return S(`numeric`,g*Number(m))},hexadecimal(){if(n.isHexDigit(_)){m+=b(),p=`hexadecimalInteger`;return}throw D(b())},hexadecimalInteger(){if(n.isHexDigit(_)){m+=b();return}return S(`numeric`,g*Number(m))},string(){switch(_){case`\\`:b(),m+=w();return;case`"`:if(h)return b(),S(`string`,m);m+=b();return;case`'`:if(!h)return b(),S(`string`,m);m+=b();return;case`
11
+ `:case`\r`:throw D(b());case`\u2028`:case`\u2029`:k(_);break;case void 0:throw D(b())}m+=b()},start(){switch(_){case`{`:case`[`:return S(`punctuator`,b())}p=`value`},beforePropertyName(){switch(_){case`$`:case`_`:m=b(),p=`identifierName`;return;case`\\`:b(),p=`identifierNameStartEscape`;return;case`}`:return S(`punctuator`,b());case`"`:case`'`:h=b()===`"`,p=`string`;return}if(n.isIdStartChar(_)){m+=b(),p=`identifierName`;return}throw D(b())},afterPropertyName(){if(_===`:`)return S(`punctuator`,b());throw D(b())},beforePropertyValue(){p=`value`},afterPropertyValue(){switch(_){case`,`:case`}`:return S(`punctuator`,b())}throw D(b())},beforeArrayValue(){if(_===`]`)return S(`punctuator`,b());p=`value`},afterArrayValue(){switch(_){case`,`:case`]`:return S(`punctuator`,b())}throw D(b())},end(){throw D(b())}};function S(e,t){return{type:e,value:t,line:s,column:c}}function C(e){for(let t of e){if(y()!==t)throw D(b());b()}}function w(){switch(y()){case`b`:return b(),`\b`;case`f`:return b(),`\f`;case`n`:return b(),`
12
12
  `;case`r`:return b(),`\r`;case`t`:return b(),` `;case`v`:return b(),`\v`;case`0`:if(b(),n.isDigit(y()))throw D(b());return`\0`;case`x`:return b(),T();case`u`:return b(),ee();case`
13
13
  `:case`\u2028`:case`\u2029`:return b(),``;case`\r`:return b(),y()===`
14
- `&&b(),``;case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:throw D(b());case void 0:throw D(b())}return b()}function T(){let e=``,t=y();if(!n.isHexDigit(t)||(e+=b(),t=y(),!n.isHexDigit(t)))throw D(b());return e+=b(),String.fromCodePoint(parseInt(e,16))}function ee(){let e=``,t=4;for(;t-- >0;){let t=y();if(!n.isHexDigit(t))throw D(b());e+=b()}return String.fromCodePoint(parseInt(e,16))}let te={start(){if(l.type===`eof`)throw re();E()},beforePropertyName(){switch(l.type){case`identifier`:case`string`:u=l.value,i=`afterPropertyName`;return;case`punctuator`:ne();return;case`eof`:throw re()}},afterPropertyName(){if(l.type===`eof`)throw re();i=`beforePropertyValue`},beforePropertyValue(){if(l.type===`eof`)throw re();E()},beforeArrayValue(){if(l.type===`eof`)throw re();if(l.type===`punctuator`&&l.value===`]`){ne();return}E()},afterPropertyValue(){if(l.type===`eof`)throw re();switch(l.value){case`,`:i=`beforePropertyName`;return;case`}`:ne()}},afterArrayValue(){if(l.type===`eof`)throw re();switch(l.value){case`,`:i=`beforeArrayValue`;return;case`]`:ne()}},end(){}};function E(){let e;switch(l.type){case`punctuator`:switch(l.value){case`{`:e={};break;case`[`:e=[];break}break;case`null`:case`boolean`:case`numeric`:case`string`:e=l.value;break}if(d===void 0)d=e;else{let t=a[a.length-1];Array.isArray(t)?t.push(e):Object.defineProperty(t,u,{value:e,writable:!0,enumerable:!0,configurable:!0})}if(typeof e==`object`&&e)a.push(e),i=Array.isArray(e)?`beforeArrayValue`:`beforePropertyName`;else{let e=a[a.length-1];i=e==null?`end`:Array.isArray(e)?`afterArrayValue`:`afterPropertyValue`}}function ne(){a.pop();let e=a[a.length-1];i=e==null?`end`:Array.isArray(e)?`afterArrayValue`:`afterPropertyValue`}function D(e){return oe(e===void 0?`JSON5: invalid end of input at ${s}:${c}`:`JSON5: invalid character '${ae(e)}' at ${s}:${c}`)}function re(){return oe(`JSON5: invalid end of input at ${s}:${c}`)}function ie(){return c-=5,oe(`JSON5: invalid identifier character at ${s}:${c}`)}function O(e){console.warn(`JSON5: '${ae(e)}' in strings is not valid ECMAScript; consider escaping`)}function ae(e){let t={"'":`\\'`,'"':`\\"`,"\\":`\\\\`,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`,"\v":`\\v`,"\0":`\\0`,"\u2028":`\\u2028`,"\u2029":`\\u2029`};if(t[e])return t[e];if(e<` `){let t=e.charCodeAt(0).toString(16);return`\\x`+(`00`+t).substring(t.length)}return e}function oe(e){let t=SyntaxError(e);return t.lineNumber=s,t.columnNumber=c,t}})),eee=Ee(((e,t)=>{let n=Pa();t.exports=function(e,t,r){let i=[],a=``,o,s,c=``,l;if(typeof t==`object`&&t&&!Array.isArray(t)&&(r=t.space,l=t.quote,t=t.replacer),typeof t==`function`)s=t;else if(Array.isArray(t)){o=[];for(let e of t){let t;typeof e==`string`?t=e:(typeof e==`number`||e instanceof String||e instanceof Number)&&(t=String(e)),t!==void 0&&o.indexOf(t)<0&&o.push(t)}}return r instanceof Number?r=Number(r):r instanceof String&&(r=String(r)),typeof r==`number`?r>0&&(r=Math.min(10,Math.floor(r)),c=` `.substr(0,r)):typeof r==`string`&&(c=r.substr(0,10)),u(``,{"":e});function u(e,t){let n=t[e];switch(n!=null&&(typeof n.toJSON5==`function`?n=n.toJSON5(e):typeof n.toJSON==`function`&&(n=n.toJSON(e))),s&&(n=s.call(t,e,n)),n instanceof Number?n=Number(n):n instanceof String?n=String(n):n instanceof Boolean&&(n=n.valueOf()),n){case null:return`null`;case!0:return`true`;case!1:return`false`}if(typeof n==`string`)return d(n,!1);if(typeof n==`number`)return String(n);if(typeof n==`object`)return Array.isArray(n)?m(n):f(n)}function d(e){let t={"'":.1,'"':.2},r={"'":`\\'`,'"':`\\"`,"\\":`\\\\`,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`,"\v":`\\v`,"\0":`\\0`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},i=``;for(let a=0;a<e.length;a++){let o=e[a];switch(o){case`'`:case`"`:t[o]++,i+=o;continue;case`\0`:if(n.isDigit(e[a+1])){i+=`\\x00`;continue}}if(r[o]){i+=r[o];continue}if(o<` `){let e=o.charCodeAt(0).toString(16);i+=`\\x`+(`00`+e).substring(e.length);continue}i+=o}let a=l||Object.keys(t).reduce((e,n)=>t[e]<t[n]?e:n);return i=i.replace(new RegExp(a,`g`),r[a]),a+i+a}function f(e){if(i.indexOf(e)>=0)throw TypeError(`Converting circular structure to JSON5`);i.push(e);let t=a;a+=c;let n=o||Object.keys(e),r=[];for(let t of n){let n=u(t,e);if(n!==void 0){let e=p(t)+`:`;c!==``&&(e+=` `),e+=n,r.push(e)}}let s;if(r.length===0)s=`{}`;else{let e;if(c===``)e=r.join(`,`),s=`{`+e+`}`;else{let n=`,
14
+ `&&b(),``;case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:throw D(b());case void 0:throw D(b())}return b()}function T(){let e=``,t=y();if(!n.isHexDigit(t)||(e+=b(),t=y(),!n.isHexDigit(t)))throw D(b());return e+=b(),String.fromCodePoint(parseInt(e,16))}function ee(){let e=``,t=4;for(;t-- >0;){let t=y();if(!n.isHexDigit(t))throw D(b());e+=b()}return String.fromCodePoint(parseInt(e,16))}let te={start(){if(l.type===`eof`)throw O();E()},beforePropertyName(){switch(l.type){case`identifier`:case`string`:u=l.value,i=`afterPropertyName`;return;case`punctuator`:ne();return;case`eof`:throw O()}},afterPropertyName(){if(l.type===`eof`)throw O();i=`beforePropertyValue`},beforePropertyValue(){if(l.type===`eof`)throw O();E()},beforeArrayValue(){if(l.type===`eof`)throw O();if(l.type===`punctuator`&&l.value===`]`){ne();return}E()},afterPropertyValue(){if(l.type===`eof`)throw O();switch(l.value){case`,`:i=`beforePropertyName`;return;case`}`:ne()}},afterArrayValue(){if(l.type===`eof`)throw O();switch(l.value){case`,`:i=`beforeArrayValue`;return;case`]`:ne()}},end(){}};function E(){let e;switch(l.type){case`punctuator`:switch(l.value){case`{`:e={};break;case`[`:e=[];break}break;case`null`:case`boolean`:case`numeric`:case`string`:e=l.value;break}if(d===void 0)d=e;else{let t=a[a.length-1];Array.isArray(t)?t.push(e):Object.defineProperty(t,u,{value:e,writable:!0,enumerable:!0,configurable:!0})}if(typeof e==`object`&&e)a.push(e),i=Array.isArray(e)?`beforeArrayValue`:`beforePropertyName`;else{let e=a[a.length-1];i=e==null?`end`:Array.isArray(e)?`afterArrayValue`:`afterPropertyValue`}}function ne(){a.pop();let e=a[a.length-1];i=e==null?`end`:Array.isArray(e)?`afterArrayValue`:`afterPropertyValue`}function D(e){return ae(e===void 0?`JSON5: invalid end of input at ${s}:${c}`:`JSON5: invalid character '${ie(e)}' at ${s}:${c}`)}function O(){return ae(`JSON5: invalid end of input at ${s}:${c}`)}function re(){return c-=5,ae(`JSON5: invalid identifier character at ${s}:${c}`)}function k(e){console.warn(`JSON5: '${ie(e)}' in strings is not valid ECMAScript; consider escaping`)}function ie(e){let t={"'":`\\'`,'"':`\\"`,"\\":`\\\\`,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`,"\v":`\\v`,"\0":`\\0`,"\u2028":`\\u2028`,"\u2029":`\\u2029`};if(t[e])return t[e];if(e<` `){let t=e.charCodeAt(0).toString(16);return`\\x`+(`00`+t).substring(t.length)}return e}function ae(e){let t=SyntaxError(e);return t.lineNumber=s,t.columnNumber=c,t}})),eee=Te(((e,t)=>{let n=Pa();t.exports=function(e,t,r){let i=[],a=``,o,s,c=``,l;if(typeof t==`object`&&t&&!Array.isArray(t)&&(r=t.space,l=t.quote,t=t.replacer),typeof t==`function`)s=t;else if(Array.isArray(t)){o=[];for(let e of t){let t;typeof e==`string`?t=e:(typeof e==`number`||e instanceof String||e instanceof Number)&&(t=String(e)),t!==void 0&&o.indexOf(t)<0&&o.push(t)}}return r instanceof Number?r=Number(r):r instanceof String&&(r=String(r)),typeof r==`number`?r>0&&(r=Math.min(10,Math.floor(r)),c=` `.substr(0,r)):typeof r==`string`&&(c=r.substr(0,10)),u(``,{"":e});function u(e,t){let n=t[e];switch(n!=null&&(typeof n.toJSON5==`function`?n=n.toJSON5(e):typeof n.toJSON==`function`&&(n=n.toJSON(e))),s&&(n=s.call(t,e,n)),n instanceof Number?n=Number(n):n instanceof String?n=String(n):n instanceof Boolean&&(n=n.valueOf()),n){case null:return`null`;case!0:return`true`;case!1:return`false`}if(typeof n==`string`)return d(n,!1);if(typeof n==`number`)return String(n);if(typeof n==`object`)return Array.isArray(n)?m(n):f(n)}function d(e){let t={"'":.1,'"':.2},r={"'":`\\'`,'"':`\\"`,"\\":`\\\\`,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`,"\v":`\\v`,"\0":`\\0`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},i=``;for(let a=0;a<e.length;a++){let o=e[a];switch(o){case`'`:case`"`:t[o]++,i+=o;continue;case`\0`:if(n.isDigit(e[a+1])){i+=`\\x00`;continue}}if(r[o]){i+=r[o];continue}if(o<` `){let e=o.charCodeAt(0).toString(16);i+=`\\x`+(`00`+e).substring(e.length);continue}i+=o}let a=l||Object.keys(t).reduce((e,n)=>t[e]<t[n]?e:n);return i=i.replace(new RegExp(a,`g`),r[a]),a+i+a}function f(e){if(i.indexOf(e)>=0)throw TypeError(`Converting circular structure to JSON5`);i.push(e);let t=a;a+=c;let n=o||Object.keys(e),r=[];for(let t of n){let n=u(t,e);if(n!==void 0){let e=p(t)+`:`;c!==``&&(e+=` `),e+=n,r.push(e)}}let s;if(r.length===0)s=`{}`;else{let e;if(c===``)e=r.join(`,`),s=`{`+e+`}`;else{let n=`,
15
15
  `+a;e=r.join(n),s=`{
16
16
  `+a+e+`,
17
17
  `+t+`}`}}return i.pop(),a=t,s}function p(e){if(e.length===0)return d(e,!0);let t=String.fromCodePoint(e.codePointAt(0));if(!n.isIdStartChar(t))return d(e,!0);for(let r=t.length;r<e.length;r++)if(!n.isIdContinueChar(String.fromCodePoint(e.codePointAt(r))))return d(e,!0);return e}function m(e){if(i.indexOf(e)>=0)throw TypeError(`Converting circular structure to JSON5`);i.push(e);let t=a;a+=c;let n=[];for(let t=0;t<e.length;t++){let r=u(String(t),e);n.push(r===void 0?`null`:r)}let r;if(n.length===0)r=`[]`;else if(c===``)r=`[`+n.join(`,`)+`]`;else{let e=`,
18
18
  `+a,i=n.join(e);r=`[
19
19
  `+a+i+`,
20
- `+t+`]`}return i.pop(),a=t,r}}})),Ia=Oe(Ee(((e,t)=>{t.exports={parse:Fa(),stringify:eee()}}))(),1),La=class extends Error{constructor(e,t){super(`${e} (at offset ${t})`),this.reason=e,this.offset=t,this.name=`Json5EditError`}};const Ra=/[A-Za-z_$\p{L}]/u,za=/[A-Za-z0-9_$\u200C\u200D\p{L}\p{N}]/u,Ba=/[A-Za-z0-9_$.+\-\p{L}\p{N}]/u,Va=/[\t\n\v\f\r \u00A0\uFEFF\u2028\u2029\p{Zs}]/u;var Ha=class{pos=0;constructor(e){this.text=e}peek(){return this.text[this.pos]??``}fail(e){throw new La(e,this.pos)}skipTrivia(){for(;;){let e=this.peek();if(e===``)return;if(Va.test(e))this.pos++;else if(e===`/`&&this.text[this.pos+1]===`/`){let e=this.text.indexOf(`
20
+ `+t+`]`}return i.pop(),a=t,r}}})),Ia=De(Te(((e,t)=>{t.exports={parse:Fa(),stringify:eee()}}))(),1),La=class extends Error{constructor(e,t){super(`${e} (at offset ${t})`),this.reason=e,this.offset=t,this.name=`Json5EditError`}};const Ra=/[A-Za-z_$\p{L}]/u,za=/[A-Za-z0-9_$\u200C\u200D\p{L}\p{N}]/u,Ba=/[A-Za-z0-9_$.+\-\p{L}\p{N}]/u,Va=/[\t\n\v\f\r \u00A0\uFEFF\u2028\u2029\p{Zs}]/u;var Ha=class{pos=0;constructor(e){this.text=e}peek(){return this.text[this.pos]??``}fail(e){throw new La(e,this.pos)}skipTrivia(){for(;;){let e=this.peek();if(e===``)return;if(Va.test(e))this.pos++;else if(e===`/`&&this.text[this.pos+1]===`/`){let e=this.text.indexOf(`
21
21
  `,this.pos);this.pos=e===-1?this.text.length:e}else if(e===`/`&&this.text[this.pos+1]===`*`){let e=this.text.indexOf(`*/`,this.pos+2);e===-1&&this.fail(`unterminated block comment`),this.pos=e+2}else return}}expect(e){this.peek()!==e&&this.fail(`expected "${e}"`),this.pos++}value(){this.skipTrivia();let e=this.peek();if(e===`{`)return this.object();if(e===`[`)return this.array();if(e===`"`||e===`'`){let e=this.stringSpan();return{kind:`string`,span:e,value:this.decode(e)}}e===``&&this.fail(`unexpected end of input`);let t=this.pos;for(;this.pos<this.text.length&&Ba.test(this.peek());)this.pos++;this.pos===t&&this.fail(`unexpected character "${e}"`);let n={start:t,end:this.pos},r=this.decode(n);return r===null?{kind:`null`,span:n}:typeof r==`boolean`?{kind:`boolean`,span:n,value:r}:typeof r==`number`?{kind:`number`,span:n,value:r}:this.fail(`unexpected word "${this.text.slice(t,this.pos)}"`)}decode(e){try{return Ia.default.parse(this.text.slice(e.start,e.end))}catch(t){throw new La(t.message,e.start)}}stringSpan(){let e=this.pos,t=this.peek();for(this.pos++;;){let n=this.peek();if(n===``&&this.fail(`unterminated string`),n===`\\`){let e=this.text.startsWith(`\r
22
22
  `,this.pos+1);this.pos+=e?3:2;continue}if(this.pos++,n===t)return{start:e,end:this.pos};n===`
23
23
  `&&this.fail(`unterminated string`)}}key(){let e=this.peek();if(e===`"`||e===`'`){let e=this.stringSpan();return{key:this.decode(e),span:e}}let t=this.pos;for(Ra.test(e)||this.fail(`expected an object key`);this.pos<this.text.length&&za.test(this.peek());)this.pos++;return{key:this.text.slice(t,this.pos),span:{start:t,end:this.pos}}}object(){let e=this.pos;this.expect(`{`);let t=[];for(;this.skipTrivia(),this.peek()!==`}`;){let{key:e,span:n}=this.key();if(t.some(t=>t.key===e))throw new La(`duplicate key "${e}"`,n.start);this.skipTrivia(),this.expect(`:`);let r=this.value();if(t.push({key:e,keySpan:n,value:r,span:{start:n.start,end:r.span.end}}),this.skipTrivia(),this.peek()===`,`){this.pos++;continue}this.peek()!==`}`&&this.fail(`expected "," or "}"`)}return this.expect(`}`),{kind:`object`,span:{start:e,end:this.pos},entries:t}}array(){let e=this.pos;this.expect(`[`);let t=[];for(;this.skipTrivia(),this.peek()!==`]`;){if(t.push(this.value()),this.skipTrivia(),this.peek()===`,`){this.pos++;continue}this.peek()!==`]`&&this.fail(`expected "," or "]"`)}return this.expect(`]`),{kind:`array`,span:{start:e,end:this.pos},elements:t}}};function Ua(e){let t=new Ha(e),n=t.value();return t.skipTrivia(),t.pos!==e.length&&t.fail(`trailing content after the document`),n}function Wa(e,t){return e.kind===`object`?e.entries.find(e=>e.key===t):void 0}function Ga(e,t){let n=e;for(let e of t)n=n===void 0?void 0:Wa(n,e)?.value;return n}function Ka(e,t){return e.slice(t.span.start,t.span.end)}function qa(e,t){let n=oo(e,t.span.start),r=Ja(t),i=e=>r.some(t=>t.start<e&&e<t.end),a=t.span.start;return Ka(e,t).split(`
@@ -32,13 +32,13 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
32
32
  `}function to(e,t,n){return e.split(`
33
33
  `).join(`${n}${t}`)}function no(e,t,n){let[r,...i]=e,a=i.length===0?t:`{\n ${to(no(i,t,n),` `,`
34
34
  `)}${n.trailingComma}\n}`;return`${n.key(r)}: ${a}`}function ro(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}function io(e,t){return e.lastIndexOf(`
35
- `,t-1)+1}function ao(e){return/^[ \t]*$/.test(e)}function oo(e,t){let n=io(e,t);return/^[ \t]*/.exec(e.slice(n))[0]}function so(e,t){return ao(e.slice(io(e,t),t))}const co=/(?:\/\/[^\n]*?)?(\r\n|\n|$)/y;function lo(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;let r=e[n]===`,`?n+1:-1;for(r!==-1&&(n=r);n<e.length&&(e[n]===` `||e[n]===` `);)n++;co.lastIndex=n;let i=co.exec(e);if(i===null)return{commaEnd:r,line:null};let a=n+i[0].length;return{commaEnd:r,line:{at:a-i[1].length,next:a}}}function uo(e,t){let{commaEnd:n,line:r}=lo(e,t.end);if(so(e,t.start)&&r!==null)return ro(e,io(e,t.start),r.next,``);if(n!==-1){let r=n;for(;r<e.length&&e[r]===` `;)r++;return ro(e,t.start,r,``)}let i=t.start;for(;i>0&&(e[i-1]===` `||e[i-1]===` `);)i--;return e[i-1]===`,`?ro(e,i-1,t.end,``):ro(e,t.start,t.end,``)}function fo(e,t,n,r,i){let a=n.commaEnd!==-1,o=a?e:ro(e,t.end,t.end,`,`),s=n.line.at+ +!a,c=eo(e);return ro(o,s,s,`${c}${i}${to(r,i,c)}${a?`,`:``}`)}function po(e,t,n,r){let i=t.kind===`object`?t.entries:t.elements,a=i[i.length-1],o=oo(e,t.span.start);if(a===void 0){let i=o+` `,a=eo(e);return ro(e,t.span.start+1,t.span.end-1,`${a}${i}${to(n,i,a)}${r.trailingComma}${a}${o}`)}let{commaEnd:s,line:c}=lo(e,a.span.end);if(so(e,a.span.start)&&c!==null){let t=e.slice(io(e,a.span.start),a.span.start);return fo(e,a.span,{commaEnd:s,line:c},n,t)}let l=s===-1?a.span.end:s;return ro(e,l,l,`${s===-1?`, `:` `}${n}${s===-1?``:`,`}`)}function mo(e,t,n,r){if(t.length===0)throw new La(`setValue needs a non-empty path`,0);if(/^\s*$/.test(e)){let i=eo(e);return`{${i} ${to(no(t,n,r),` `,i)}${r.trailingComma}${i}}${i}`}return ho(e,Ua(e),t,n,r)}function ho(e,t,n,r,i){let a=t;for(let t=0;t<n.length;t++){if(a.kind!==`object`)throw new La(`cannot set ${n.join(`.`)}: ${n.slice(0,t).join(`.`)||`the document`} is not an object`,a.span.start);let o=Wa(a,n[t]);if(o===void 0)return po(e,a,no(n.slice(t),r,i),i);if(t===n.length-1){let t=oo(e,o.keySpan.start);return ro(e,o.value.span.start,o.value.span.end,to(r,t,eo(e)))}a=o.value}throw new La(`unreachable: path exhausted`,0)}function go(e,t,n=0){if(t.length===0)throw new La(`deleteValue needs a non-empty path`,0);if(/^\s*$/.test(e))return e;let r=t.slice(0,-1),i=Ga(Ua(e),r),a=i===void 0?void 0:Wa(i,t[t.length-1]);if(a===void 0||i?.kind!==`object`)return e;let o=uo(e,a.span);return r.length>n&&i.entries.length===1?go(o,r,n):o}const _o=[`h`,`v`,`children`];function vo(e){if(e.kind===`string`)return e.value;if(e.kind!==`object`)return;let t=Wa(e,`seg`)?.value,n=Wa(e,`kind`)?.value,r=Wa(e,`name`)?.value,i=t?.kind===`string`?t.value:n?.kind===`string`&&n.value===`segment`&&r?.kind===`string`?r.value:void 0;if(i===void 0)return;let a=Wa(e,`id`)?.value;return a?.kind===`string`?a.value:i}function yo(e){return e.kind===`object`?_o.map(t=>Wa(e,t)?.value).filter(e=>e?.kind===`array`):[]}function bo(e){let t=Wa(e,`rows`)?.value;return t?.kind===`object`?t.entries:null}function xo(e){if(e.kind!==`object`)return!0;let t=bo(e);return t===null||t.length>0||e.entries.some(e=>e.key!==`rows`)}function*So(e,t){yield{node:e,bareAt:t};for(let t of yo(e))for(let e of t.elements)yield*So(e,null);for(let n of bo(e)??[])yield*So(n.value,t===null?null:[...t,`rows`,n.key])}function Co(e,t){for(let{node:n}of So(e,null))if(vo(n)===t)return!0;return!1}function wo(e,t,n){let r=Ga(Ua(e),t);if(r===void 0)return null;for(let{node:i,bareAt:a}of So(r,t))if(vo(i)===n)return a===null?{text:e,ref:i}:wo(mo(e,a,`{ h: [${Ka(e,i)}] }`,Za),t,n);return null}function To(e,t,n){let r=wo(e,t,n);return r===null?null:uo(r.text,r.ref.span)}function Eo(e,t,n,r,i){let a=wo(e,t,r);if(a===null)return null;let{text:o,ref:s}=a,c=n.id===void 0?JSON.stringify(n.seg):`{ seg: ${JSON.stringify(n.seg)}, id: ${JSON.stringify(n.id)} }`,{commaEnd:l,line:u}=lo(o,s.span.end);if(so(o,s.span.start)&&u!==null){let e=o.slice(io(o,s.span.start),s.span.start);return i===`after`?fo(o,s.span,{commaEnd:l,line:u},c,e):ro(o,s.span.start,s.span.start,`${c},${eo(o)}${e}`)}let d=Ka(o,s),f=i===`before`?`${c}, ${d}`:`${d}, ${c}`;return ro(o,s.span.start,s.span.end,f)}function Do(e,t,n,r,i){let a=wo(e,t,n);if(a===null)return null;let{text:o,ref:s}=a,c=`{ ${Xa(r)}: ${i} }`;return s.kind===`string`?ro(o,s.span.start,s.span.end,`{ seg: ${JSON.stringify(s.value)}, settings: ${c} }`):Wa(s,`settings`)===void 0?ho(o,s,[`settings`],c,Za):ho(o,s,[`settings`,r],i,Za)}function F(e){return{kind:`ok`,value:e}}const I={kind:`absent`};function L(e,t){return{kind:`failed`,reason:e,failedAt:t}}function Oo(e,t){return e?.kind===`ok`?e.value:t}const ko={unread:Object.freeze({kind:`pending`,why:`unread`}),superseded:Object.freeze({kind:`pending`,why:`superseded`})};function Ao(e){return ko[e]}function jo(e){return typeof e==`object`&&!!e&&e.kind===`pending`}var Mo=class{slots;head=null;tail=null;constructor(e){this.slots=e}async run(e){await this.acquire();try{return await e()}finally{this.release()}}async acquire(){if(this.slots>0){this.slots--;return}await new Promise(e=>{let t={wake:e,next:null};this.tail?this.tail.next=t:this.head=t,this.tail=t})}release(){let e=this.head;if(!e){this.slots++;return}this.head=e.next,this.head||(this.tail=null),e.wake()}};function No(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}function Po(e){if(!e)return``;try{return Fo(v(e))}catch{return``}}function Fo(e){return`${e.mtimeMs}:${e.size}`}const Io=new Mo(8);function Lo(e){return((...t)=>Io.run(()=>e(...t)))}const Ro=Lo(he),zo=Lo(ge),Bo={reads:0,bytes:0,longLines:0,largestLine:0};function Vo(){return{...Bo}}const Ho=[];function Uo(e){Ho.length<8&&Ho.push(e)}async function Wo(e,t,n){return Io.run(async()=>{let r=Ho.pop()??Buffer.allocUnsafe(524288),i=await tee(e,t,n,r);if(i.kind!==`ok`)return Uo(r),i;let a=r;return F({...i.value,[Symbol.dispose]:()=>{a!==void 0&&Uo(a),a=void 0}})})}function Go(e,t){try{var n=No();return t(n.u(e).lines)}catch(e){n.e=e}finally{n.d()}}async function tee(e,t,n,r){let i=null;try{i=await pe(e,`r`);let a=await i.stat(),{size:o,ino:s}=a,c=Fo(a),l=t!==void 0&&(s!==t.ino||o<t.offset),u=l||t===void 0?0:t.offset,d=l||n===void 0?o:Math.min(o,n),f=0,p=await Ko(i,r.subarray(0,d-u),u);f+=p.length;let m=p.lastIndexOf(10),h=u+p.length,g=p.length<Math.min(r.length,d-u);for(;m<0&&h<d&&!g;){let e=await Ko(i,r.subarray(0,d-h),h);f+=e.length;let t=e.indexOf(10);t>=0&&(m=h-u+t),g=e.length<Math.min(r.length,d-h),h+=e.length}let _=m+1,v=_>r.length?_:0,y=v>0?await Ko(i,Buffer.allocUnsafe(_),u):p.subarray(0,_);f+=v>0?y.length:0;let b=y.length===_;return Bo.reads++,Bo.bytes+=f,Bo.longLines+=+(v>0),Bo.largestLine=Math.max(Bo.largestLine,v),F({lines:b?y:y.subarray(0,0),start:u,atEnd:!b||(v>0?u+_>=d:h>=d||g),size:o,stamp:c,ino:s,reset:l,longLine:v})}catch(t){return t.code===`ENOENT`?I:L(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`,`read`)}finally{await i?.close().catch(e=>{k(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}}async function Ko(e,t,n){let r=0;for(;r<t.length;){let{bytesRead:i}=await e.read(t,r,t.length-r,n+r);if(i===0)break;r+=i}return t.subarray(0,r)}async function qo(e,t){return Io.run(async()=>{let n=null;try{n=await pe(e,`r`);let{size:r}=await n.stat(),i=Math.max(0,r-t);return F({buf:await Ko(n,Buffer.alloc(r-i),i),fromStart:i===0})}catch(t){return t.code===`ENOENT`?I:L(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`,`read`)}finally{await n?.close().catch(e=>{k(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}function Jo(e,t){let n;try{n=m(e,l.O_RDONLY|l.O_NONBLOCK)}catch(e){let{code:t}=e;return t===`ENOENT`||t===`ENOTDIR`?I:L(e instanceof Error?e.message:String(e),`read`)}try{let e=d(n,{bigint:!0});if(!e.isFile())return L(`not a regular file`,`read`);let r=Number(e.size),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let e=g(n,a,o,a.length-o,i+o);if(e===0)break;o+=e}return F({buf:a.subarray(0,o),fromStart:i===0,file:`${e.dev}:${e.ino}`})}catch(e){return L(e instanceof Error?e.message:String(e),`read`)}finally{try{c(n)}catch(e){k(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)}}}const Yo=`CLAUDE_CONFIG_DIR`;function Xo(e,t){let n=(e.CLAUDE_CONFIG_DIR??``).split(`,`)[0].trim();return n===``?void 0:E.resolve(t,n)}function Zo(e,t){return e??E.join(t,`.claude`)}function Qo(e){return E.join(e,`settings.json`)}function $o(e){let t=Jo(e,2**53-1);switch(t.kind){case`absent`:return null;case`failed`:throw Error(`cannot read ${e}: ${t.reason}`);case`ok`:return{text:t.value.buf.toString(`utf8`),file:t.value.file}}}const es=(e,t)=>Error(`cannot read ${e}: ${us(t)}`,{cause:t});function ts(e){return $o(e)?.text??``}function ns(e){let t=rs(e);if(t.kind===`failed`)throw Error(t.reason);return t.value}function rs(e){let t=e=>e instanceof Error?e.message:String(e),n;try{n=ts(e)}catch(e){return L(t(e),`read`)}try{return F(is(e,n))}catch(e){return L(t(e),`parse`)}}function is(e,t){let n;try{if(/^\s*$/.test(t))return{};n=Qa.parse(t)}catch(t){throw es(e,t)}if(!ls(n))throw Error(`cannot read ${e}: not a JSON object`);return n}function as(e){switch(e){case`darwin`:return`/Library/Application Support/ClaudeCode`;case`win32`:return`C:\\Program Files\\ClaudeCode`;default:return`/etc/claude-code`}}const os=e=>E.join(e,`.claude`,`settings.local.json`);function ss(e){let t=E.join(e.managedDir,`managed-settings.d`),n=[...cs(t).reverse().map(e=>({scope:`managed`,path:E.join(t,e)})),{scope:`managed`,path:E.join(e.managedDir,`managed-settings.json`)},{scope:`project-local`,path:os(e.projectDir)},{scope:`project`,path:E.join(e.projectDir,`.claude`,`settings.json`)},{scope:`user`,path:e.userFile}].flatMap(e=>{let t=$o(e.path);if(t===null)return[];let n=is(e.path,t.text),{env:r={}}=n;if(!ls(r))throw Error(`cannot read ${e.path}: \`env\` is not an object`);return[{source:{...e,settings:n,env:r},file:t.file}]}),r=n.find(e=>e.source.scope===`user`);return n.filter(e=>e.source.scope!==`project`||e.file!==r?.file).map(e=>e.source)}function cs(e){try{return s.readdirSync(e).filter(e=>!e.startsWith(`.`)&&e.endsWith(`.json`)).sort()}catch(t){if(t.code===`ENOENT`)return[];throw es(e,t)}}const ls=e=>typeof e==`object`&&!!e&&!Array.isArray(e),us=e=>e instanceof Error?e.message:String(e),ds=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function fs(e){let t=ds.exec(e);return t?{kind:`ok`,value:[Number(t[1]),Number(t[2]),Number(t[3])]}:{kind:`failed`,reason:`"${e}" is not a release version (expected MAJOR.MINOR.PATCH)`,failedAt:`parse`}}function ps(e){return e.join(`.`)}function ms([e,t,n],[r,i,a]){return e-r||t-i||n-a}const hs=`@promptctl/cc-candybar`;async function gs(e,t,n,r){let i=`${n}/-/package/${encodeURIComponent(e)}/dist-tags`;try{let e=await t(i,{signal:Re(r,5e3)});if(!e.ok)return L(`registry responded ${e.status} for ${i}`,`read`);let n=await e.json();return typeof n.latest==`string`?fs(n.latest):I}catch(e){return L(e instanceof Error?e.message:String(e),`read`)}}function _s(e,t){let n=fs(e);if(n.kind===`failed`)return{kind:`unchecked`,installed:e,reason:n.reason};switch(t.kind){case`failed`:return{kind:`unchecked`,installed:e,reason:t.reason};case`absent`:return{kind:`unchecked`,installed:e,reason:"the registry lists no `latest` dist-tag"};case`ok`:{let e=ms(n.value,t.value);return e<0?{kind:`stale`,installed:n.value,latest:t.value}:e>0?{kind:`ahead`,installed:n.value,latest:t.value}:{kind:`current`,installed:n.value}}}}function vs(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${ps(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${ps(t.installed)} is newer than the registry's latest release (${ps(t.latest)}): an unpublished build.\n`};case`stale`:{let n=ps(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${ps(t.installed)} was staged, but the latest release is ${n}.\n pnpm's release-age gate (minimumReleaseAge) and its dlx cache can both\n resolve \`@latest\` to an older release without saying so.\n To install ${n} now, name it explicitly:\n pnpm dlx ${e}@${n} install\n`}}case`unchecked`:return{stream:`stderr`,text:`⚠ Could not check for a cc-candybar release newer than ${t.installed} (${t.reason}); the registry check was skipped.\n`}}}const ys={"darwin-arm64":`@promptctl/cc-candybar-darwin-arm64`,"darwin-x64":`@promptctl/cc-candybar-darwin-x64`,"linux-x64":`@promptctl/cc-candybar-linux-x64`,"linux-arm64":`@promptctl/cc-candybar-linux-arm64`};function bs(e,t){return`${e}-${t}`in ys}const xs=`cc-candybar-url-handler`,Ss=[];function Cs(e,t){return[e,...t].map(Vt).join(` `)}function ws(e){return E.join(e.home,`Applications`,`${Hi}.app`)}function Ts(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function Es(e){return process.platform===`darwin`?E.join(e.home,`Library`,`Application Support`,`CCCandybar`):E.join(En(e).dataHome,`cc-candybar`)}function Ds(e){return E.join(e,`bin`,`cc-candybar`)}function Os(e){return E.join(e,`dist`,`index.mjs`)}function ks(e,t){let n=nn(e);return Kt(n===null?Os(Es(t)):E.join(n,`dist`,`index.mjs`))}function As(e){return E.join(e,`Contents`,`MacOS`,Hi)}function js(e){let t=nn(e);if(t!==null){let e=E.join(t,`bin`,`cc-candybar-url-handler-native`);if(!s.existsSync(e))throw Error(`install: the URL handler app is not built at ${e}. Run \`just install-url-handler\` in the checkout.`);return e}let n=Ms(e,`bin/${xs}`);switch(n.kind){case`found`:return n.path;case`no-package`:throw Error(`install: no URL handler app ships for ${n.platform}; the scheme is macOS-only.`);case`missing`:throw Error(`install: the URL handler app was not found in ${n.pkgName} (bin/${xs}). The optional platform package is missing or older than this release: reinstall the package.`)}}function Ms(t,n){let r=`${process.platform}-${process.arch}`,i=ys[r];if(i===void 0)return{kind:`no-package`,platform:r};try{return{kind:`found`,path:e(t).resolve(`${i}/${n}`)}}catch{return{kind:`missing`,pkgName:i}}}function Ns(e){let t=Ms(e,`bin/cc-candybar`);return t.kind===`found`?{kind:`native`,sourcePath:t.path}:{kind:`node-shim`,sourcePath:E.resolve(E.dirname(e),`..`,`bin`,`cc-candybar`)}}function Ps(e,t){E.resolve(e)!==E.resolve(t)&&s.copyFileSync(e,t)}function nee(e,t){E.resolve(e)!==E.resolve(t)&&(s.rmSync(t,{recursive:!0,force:!0}),s.cpSync(e,t,{recursive:!0}))}function ree(e){let t=s.openSync(e,`r`);try{let n=Buffer.alloc(2),r=s.readSync(t,n,0,2,0);if(r<2)throw Error(`install: staged render entry at ${e} is truncated (${r} byte(s)). Re-run: pnpm dlx ${hs}@latest install`);return n.toString(`latin1`)===`#!`?`node-shim`:`native`}finally{s.closeSync(t)}}function Fs(e,t){if(!s.existsSync(e))throw Error(`install: bundled dist not found at ${e}. Reinstall the package.`);let n=Ns(e);if(!s.existsSync(n.sourcePath))throw Error(`install: render entry not found at ${n.sourcePath}. Reinstall the package.`);let r=E.join(E.dirname(e),Ut);if(!s.existsSync(r))throw Error(`install: the attach launcher was not found at ${r}. Reinstall the package.`);let i=E.join(E.dirname(e),Gt);if(!s.existsSync(i))throw Error(`install: the attach preload was not found at ${i}. Reinstall the package.`);let a=Os(t),o=Ds(t);s.mkdirSync(E.dirname(a),{recursive:!0}),s.mkdirSync(E.dirname(o),{recursive:!0}),Ps(e,a),nee(r,E.join(E.dirname(a),Ut)),Ps(i,E.join(E.dirname(a),Gt)),Ps(n.sourcePath,o),s.chmodSync(o,493),s.rmSync(E.join(t,`url-handler.mjs`),{force:!0});let c=ree(o);return process.stdout.write(`Staged cc-candybar v${tn} runtime at ${t}\n`+(c===`native`?` render entry: native binary (${process.platform}-${process.arch})\n`:` render entry: node shim (no native binary for ${process.platform}-${process.arch}; renders are correct but pay node startup)\n`)),{binPath:o,distPath:a,entryKind:c}}function iee(){return[`<?xml version="1.0" encoding="UTF-8"?>`,`<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">`,`<plist version="1.0">`,`<dict>`,` <key>CFBundleIdentifier</key>`,` <string>com.cccandybar.url-handler</string>`,` <key>CFBundleName</key>`,` <string>${Hi}</string>`,` <key>CFBundleDisplayName</key>`,` <string>cc-candybar</string>`,` <key>CFBundleExecutable</key>`,` <string>${Hi}</string>`,` <key>CFBundlePackageType</key>`,` <string>APPL</string>`,` <key>CFBundleVersion</key>`,` <string>${tn}</string>`,` <key>CFBundleShortVersionString</key>`,` <string>${tn}</string>`,` <key>LSMinimumSystemVersion</key>`,` <string>12.0</string>`,` <key>LSBackgroundOnly</key>`,` <true/>`,` <key>CFBundleURLTypes</key>`,` <array>`,` <dict>`,` <key>CFBundleURLName</key>`,` <string>cc-candybar click</string>`,` <key>CFBundleURLSchemes</key>`,` <array>`,` <string>${Vi}</string>`,` </array>`,` </dict>`,` </array>`,`</dict>`,`</plist>`,``].join(`
35
+ `,t-1)+1}function ao(e){return/^[ \t]*$/.test(e)}function oo(e,t){let n=io(e,t);return/^[ \t]*/.exec(e.slice(n))[0]}function so(e,t){return ao(e.slice(io(e,t),t))}const co=/(?:\/\/[^\n]*?)?(\r\n|\n|$)/y;function lo(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;let r=e[n]===`,`?n+1:-1;for(r!==-1&&(n=r);n<e.length&&(e[n]===` `||e[n]===` `);)n++;co.lastIndex=n;let i=co.exec(e);if(i===null)return{commaEnd:r,line:null};let a=n+i[0].length;return{commaEnd:r,line:{at:a-i[1].length,next:a}}}function uo(e,t){let{commaEnd:n,line:r}=lo(e,t.end);if(so(e,t.start)&&r!==null)return ro(e,io(e,t.start),r.next,``);if(n!==-1){let r=n;for(;r<e.length&&e[r]===` `;)r++;return ro(e,t.start,r,``)}let i=t.start;for(;i>0&&(e[i-1]===` `||e[i-1]===` `);)i--;return e[i-1]===`,`?ro(e,i-1,t.end,``):ro(e,t.start,t.end,``)}function fo(e,t,n,r,i){let a=n.commaEnd!==-1,o=a?e:ro(e,t.end,t.end,`,`),s=n.line.at+ +!a,c=eo(e);return ro(o,s,s,`${c}${i}${to(r,i,c)}${a?`,`:``}`)}function po(e,t,n,r){let i=t.kind===`object`?t.entries:t.elements,a=i[i.length-1],o=oo(e,t.span.start);if(a===void 0){let i=o+` `,a=eo(e);return ro(e,t.span.start+1,t.span.end-1,`${a}${i}${to(n,i,a)}${r.trailingComma}${a}${o}`)}let{commaEnd:s,line:c}=lo(e,a.span.end);if(so(e,a.span.start)&&c!==null){let t=e.slice(io(e,a.span.start),a.span.start);return fo(e,a.span,{commaEnd:s,line:c},n,t)}let l=s===-1?a.span.end:s;return ro(e,l,l,`${s===-1?`, `:` `}${n}${s===-1?``:`,`}`)}function mo(e,t,n,r){if(t.length===0)throw new La(`setValue needs a non-empty path`,0);if(/^\s*$/.test(e)){let i=eo(e);return`{${i} ${to(no(t,n,r),` `,i)}${r.trailingComma}${i}}${i}`}return ho(e,Ua(e),t,n,r)}function ho(e,t,n,r,i){let a=t;for(let t=0;t<n.length;t++){if(a.kind!==`object`)throw new La(`cannot set ${n.join(`.`)}: ${n.slice(0,t).join(`.`)||`the document`} is not an object`,a.span.start);let o=Wa(a,n[t]);if(o===void 0)return po(e,a,no(n.slice(t),r,i),i);if(t===n.length-1){let t=oo(e,o.keySpan.start);return ro(e,o.value.span.start,o.value.span.end,to(r,t,eo(e)))}a=o.value}throw new La(`unreachable: path exhausted`,0)}function go(e,t,n=0){if(t.length===0)throw new La(`deleteValue needs a non-empty path`,0);if(/^\s*$/.test(e))return e;let r=t.slice(0,-1),i=Ga(Ua(e),r),a=i===void 0?void 0:Wa(i,t[t.length-1]);if(a===void 0||i?.kind!==`object`)return e;let o=uo(e,a.span);return r.length>n&&i.entries.length===1?go(o,r,n):o}const _o=[`h`,`v`,`children`];function vo(e){if(e.kind===`string`)return e.value;if(e.kind!==`object`)return;let t=Wa(e,`seg`)?.value,n=Wa(e,`kind`)?.value,r=Wa(e,`name`)?.value,i=t?.kind===`string`?t.value:n?.kind===`string`&&n.value===`segment`&&r?.kind===`string`?r.value:void 0;if(i===void 0)return;let a=Wa(e,`id`)?.value;return a?.kind===`string`?a.value:i}function yo(e){return e.kind===`object`?_o.map(t=>Wa(e,t)?.value).filter(e=>e?.kind===`array`):[]}function bo(e){let t=Wa(e,`rows`)?.value;return t?.kind===`object`?t.entries:null}function xo(e){if(e.kind!==`object`)return!0;let t=bo(e);return t===null||t.length>0||e.entries.some(e=>e.key!==`rows`)}function*So(e,t){yield{node:e,bareAt:t};for(let t of yo(e))for(let e of t.elements)yield*So(e,null);for(let n of bo(e)??[])yield*So(n.value,t===null?null:[...t,`rows`,n.key])}function Co(e,t){for(let{node:n}of So(e,null))if(vo(n)===t)return!0;return!1}function wo(e,t,n){let r=Ga(Ua(e),t);if(r===void 0)return null;for(let{node:i,bareAt:a}of So(r,t))if(vo(i)===n)return a===null?{text:e,ref:i}:wo(mo(e,a,`{ h: [${Ka(e,i)}] }`,Za),t,n);return null}function To(e,t,n){let r=wo(e,t,n);return r===null?null:uo(r.text,r.ref.span)}function Eo(e,t,n,r,i){let a=wo(e,t,r);if(a===null)return null;let{text:o,ref:s}=a,c=n.id===void 0?JSON.stringify(n.seg):`{ seg: ${JSON.stringify(n.seg)}, id: ${JSON.stringify(n.id)} }`,{commaEnd:l,line:u}=lo(o,s.span.end);if(so(o,s.span.start)&&u!==null){let e=o.slice(io(o,s.span.start),s.span.start);return i===`after`?fo(o,s.span,{commaEnd:l,line:u},c,e):ro(o,s.span.start,s.span.start,`${c},${eo(o)}${e}`)}let d=Ka(o,s),f=i===`before`?`${c}, ${d}`:`${d}, ${c}`;return ro(o,s.span.start,s.span.end,f)}function Do(e,t,n,r,i){let a=wo(e,t,n);if(a===null)return null;let{text:o,ref:s}=a,c=`{ ${Xa(r)}: ${i} }`;return s.kind===`string`?ro(o,s.span.start,s.span.end,`{ seg: ${JSON.stringify(s.value)}, settings: ${c} }`):Wa(s,`settings`)===void 0?ho(o,s,[`settings`],c,Za):ho(o,s,[`settings`,r],i,Za)}function F(e){return{kind:`ok`,value:e}}const I={kind:`absent`};function L(e,t){return{kind:`failed`,reason:e,failedAt:t}}function Oo(e,t){return e?.kind===`ok`?e.value:t}const ko={unread:Object.freeze({kind:`pending`,why:`unread`}),superseded:Object.freeze({kind:`pending`,why:`superseded`})};function Ao(e){return ko[e]}function jo(e){return typeof e==`object`&&!!e&&e.kind===`pending`}var Mo=class{slots;head=null;tail=null;constructor(e){this.slots=e}async run(e){await this.acquire();try{return await e()}finally{this.release()}}async acquire(){if(this.slots>0){this.slots--;return}await new Promise(e=>{let t={wake:e,next:null};this.tail?this.tail.next=t:this.head=t,this.tail=t})}release(){let e=this.head;if(!e){this.slots++;return}this.head=e.next,this.head||(this.tail=null),e.wake()}};function No(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}function Po(e){if(!e)return``;try{return Fo(v(e))}catch{return``}}function Fo(e){return`${e.mtimeMs}:${e.size}`}const Io=new Mo(8);function Lo(e){return((...t)=>Io.run(()=>e(...t)))}const Ro=Lo(me),zo=Lo(he),Bo={reads:0,bytes:0,longLines:0,largestLine:0};function Vo(){return{...Bo}}const Ho=[];function Uo(e){Ho.length<8&&Ho.push(e)}async function Wo(e,t,n){return Io.run(async()=>{let r=Ho.pop()??Buffer.allocUnsafe(524288),i=await tee(e,t,n,r);if(i.kind!==`ok`)return Uo(r),i;let a=r;return F({...i.value,[Symbol.dispose]:()=>{a!==void 0&&Uo(a),a=void 0}})})}function Go(e,t){try{var n=No();return t(n.u(e).lines)}catch(e){n.e=e}finally{n.d()}}async function tee(e,t,n,r){let i=null;try{i=await fe(e,`r`);let a=await i.stat(),{size:o,ino:s}=a,c=Fo(a),l=t!==void 0&&(s!==t.ino||o<t.offset),u=l||t===void 0?0:t.offset,d=l||n===void 0?o:Math.min(o,n),f=0,p=await Ko(i,r.subarray(0,d-u),u);f+=p.length;let m=p.lastIndexOf(10),h=u+p.length,g=p.length<Math.min(r.length,d-u);for(;m<0&&h<d&&!g;){let e=await Ko(i,r.subarray(0,d-h),h);f+=e.length;let t=e.indexOf(10);t>=0&&(m=h-u+t),g=e.length<Math.min(r.length,d-h),h+=e.length}let _=m+1,v=_>r.length?_:0,y=v>0?await Ko(i,Buffer.allocUnsafe(_),u):p.subarray(0,_);f+=v>0?y.length:0;let b=y.length===_;return Bo.reads++,Bo.bytes+=f,Bo.longLines+=+(v>0),Bo.largestLine=Math.max(Bo.largestLine,v),F({lines:b?y:y.subarray(0,0),start:u,atEnd:!b||(v>0?u+_>=d:h>=d||g),size:o,stamp:c,ino:s,reset:l,longLine:v})}catch(t){return t.code===`ENOENT`?I:L(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`,`read`)}finally{await i?.close().catch(e=>{A(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}}async function Ko(e,t,n){let r=0;for(;r<t.length;){let{bytesRead:i}=await e.read(t,r,t.length-r,n+r);if(i===0)break;r+=i}return t.subarray(0,r)}async function qo(e,t){return Io.run(async()=>{let n=null;try{n=await fe(e,`r`);let{size:r}=await n.stat(),i=Math.max(0,r-t);return F({buf:await Ko(n,Buffer.alloc(r-i),i),fromStart:i===0})}catch(t){return t.code===`ENOENT`?I:L(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`,`read`)}finally{await n?.close().catch(e=>{A(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}function Jo(e,t){let n;try{n=m(e,l.O_RDONLY|l.O_NONBLOCK)}catch(e){let{code:t}=e;return t===`ENOENT`||t===`ENOTDIR`?I:L(e instanceof Error?e.message:String(e),`read`)}try{let e=d(n,{bigint:!0});if(!e.isFile())return L(`not a regular file`,`read`);let r=Number(e.size),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let e=g(n,a,o,a.length-o,i+o);if(e===0)break;o+=e}return F({buf:a.subarray(0,o),fromStart:i===0,file:`${e.dev}:${e.ino}`})}catch(e){return L(e instanceof Error?e.message:String(e),`read`)}finally{try{c(n)}catch(e){A(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)}}}const Yo=`CLAUDE_CONFIG_DIR`;function Xo(e,t){let n=(e.CLAUDE_CONFIG_DIR??``).split(`,`)[0].trim();return n===``?void 0:E.resolve(t,n)}function Zo(e,t){return e??E.join(t,`.claude`)}function Qo(e){return E.join(e,`settings.json`)}function $o(e){let t=Jo(e,2**53-1);switch(t.kind){case`absent`:return null;case`failed`:throw Error(`cannot read ${e}: ${t.reason}`);case`ok`:return{text:t.value.buf.toString(`utf8`),file:t.value.file}}}const es=(e,t)=>Error(`cannot read ${e}: ${us(t)}`,{cause:t});function ts(e){return $o(e)?.text??``}function ns(e){let t=rs(e);if(t.kind===`failed`)throw Error(t.reason);return t.value}function rs(e){let t=e=>e instanceof Error?e.message:String(e),n;try{n=ts(e)}catch(e){return L(t(e),`read`)}try{return F(is(e,n))}catch(e){return L(t(e),`parse`)}}function is(e,t){let n;try{if(/^\s*$/.test(t))return{};n=Qa.parse(t)}catch(t){throw es(e,t)}if(!ls(n))throw Error(`cannot read ${e}: not a JSON object`);return n}function as(e){switch(e){case`darwin`:return`/Library/Application Support/ClaudeCode`;case`win32`:return`C:\\Program Files\\ClaudeCode`;default:return`/etc/claude-code`}}const os=e=>E.join(e,`.claude`,`settings.local.json`);function ss(e){let t=E.join(e.managedDir,`managed-settings.d`),n=[...cs(t).reverse().map(e=>({scope:`managed`,path:E.join(t,e)})),{scope:`managed`,path:E.join(e.managedDir,`managed-settings.json`)},{scope:`project-local`,path:os(e.projectDir)},{scope:`project`,path:E.join(e.projectDir,`.claude`,`settings.json`)},{scope:`user`,path:e.userFile}].flatMap(e=>{let t=$o(e.path);if(t===null)return[];let n=is(e.path,t.text),{env:r={}}=n;if(!ls(r))throw Error(`cannot read ${e.path}: \`env\` is not an object`);return[{source:{...e,settings:n,env:r},file:t.file}]}),r=n.find(e=>e.source.scope===`user`);return n.filter(e=>e.source.scope!==`project`||e.file!==r?.file).map(e=>e.source)}function cs(e){try{return s.readdirSync(e).filter(e=>!e.startsWith(`.`)&&e.endsWith(`.json`)).sort()}catch(t){if(t.code===`ENOENT`)return[];throw es(e,t)}}const ls=e=>typeof e==`object`&&!!e&&!Array.isArray(e),us=e=>e instanceof Error?e.message:String(e),ds=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function fs(e){let t=ds.exec(e);return t?{kind:`ok`,value:[Number(t[1]),Number(t[2]),Number(t[3])]}:{kind:`failed`,reason:`"${e}" is not a release version (expected MAJOR.MINOR.PATCH)`,failedAt:`parse`}}function ps(e){return e.join(`.`)}function ms([e,t,n],[r,i,a]){return e-r||t-i||n-a}const hs=`@promptctl/cc-candybar`;async function gs(e,t,n,r){let i=`${n}/-/package/${encodeURIComponent(e)}/dist-tags`;try{let e=await t(i,{signal:Re(r,5e3)});if(!e.ok)return L(`registry responded ${e.status} for ${i}`,`read`);let n=await e.json();return typeof n.latest==`string`?fs(n.latest):I}catch(e){return L(e instanceof Error?e.message:String(e),`read`)}}function _s(e,t){let n=fs(e);if(n.kind===`failed`)return{kind:`unchecked`,installed:e,reason:n.reason};switch(t.kind){case`failed`:return{kind:`unchecked`,installed:e,reason:t.reason};case`absent`:return{kind:`unchecked`,installed:e,reason:"the registry lists no `latest` dist-tag"};case`ok`:{let e=ms(n.value,t.value);return e<0?{kind:`stale`,installed:n.value,latest:t.value}:e>0?{kind:`ahead`,installed:n.value,latest:t.value}:{kind:`current`,installed:n.value}}}}function vs(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${ps(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${ps(t.installed)} is newer than the registry's latest release (${ps(t.latest)}): an unpublished build.\n`};case`stale`:{let n=ps(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${ps(t.installed)} was staged, but the latest release is ${n}.\n pnpm's release-age gate (minimumReleaseAge) and its dlx cache can both\n resolve \`@latest\` to an older release without saying so.\n To install ${n} now, name it explicitly:\n pnpm dlx ${e}@${n} install\n`}}case`unchecked`:return{stream:`stderr`,text:`⚠ Could not check for a cc-candybar release newer than ${t.installed} (${t.reason}); the registry check was skipped.\n`}}}const ys={"darwin-arm64":`@promptctl/cc-candybar-darwin-arm64`,"darwin-x64":`@promptctl/cc-candybar-darwin-x64`,"linux-x64":`@promptctl/cc-candybar-linux-x64`,"linux-arm64":`@promptctl/cc-candybar-linux-arm64`};function bs(e,t){return`${e}-${t}`in ys}const xs=`cc-candybar-url-handler`,Ss=[];function Cs(e,t){return[e,...t].map(Vt).join(` `)}function ws(e){return E.join(e.home,`Applications`,`${Hi}.app`)}function Ts(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function Es(e){return process.platform===`darwin`?E.join(e.home,`Library`,`Application Support`,`CCCandybar`):E.join(En(e).dataHome,`cc-candybar`)}function Ds(e){return E.join(e,`bin`,`cc-candybar`)}function Os(e){return E.join(e,`dist`,`index.mjs`)}function ks(e,t){let n=nn(e);return Kt(n===null?Os(Es(t)):E.join(n,`dist`,`index.mjs`))}function As(e){return E.join(e,`Contents`,`MacOS`,Hi)}function js(e){let t=nn(e);if(t!==null){let e=E.join(t,`bin`,`cc-candybar-url-handler-native`);if(!s.existsSync(e))throw Error(`install: the URL handler app is not built at ${e}. Run \`just install-url-handler\` in the checkout.`);return e}let n=Ms(e,`bin/${xs}`);switch(n.kind){case`found`:return n.path;case`no-package`:throw Error(`install: no URL handler app ships for ${n.platform}; the scheme is macOS-only.`);case`missing`:throw Error(`install: the URL handler app was not found in ${n.pkgName} (bin/${xs}). The optional platform package is missing or older than this release: reinstall the package.`)}}function Ms(t,n){let r=`${process.platform}-${process.arch}`,i=ys[r];if(i===void 0)return{kind:`no-package`,platform:r};try{return{kind:`found`,path:e(t).resolve(`${i}/${n}`)}}catch{return{kind:`missing`,pkgName:i}}}function Ns(e){let t=Ms(e,`bin/cc-candybar`);return t.kind===`found`?{kind:`native`,sourcePath:t.path}:{kind:`node-shim`,sourcePath:E.resolve(E.dirname(e),`..`,`bin`,`cc-candybar`)}}function Ps(e,t){E.resolve(e)!==E.resolve(t)&&s.copyFileSync(e,t)}function nee(e,t){E.resolve(e)!==E.resolve(t)&&(s.rmSync(t,{recursive:!0,force:!0}),s.cpSync(e,t,{recursive:!0}))}function ree(e){let t=s.openSync(e,`r`);try{let n=Buffer.alloc(2),r=s.readSync(t,n,0,2,0);if(r<2)throw Error(`install: staged render entry at ${e} is truncated (${r} byte(s)). Re-run: pnpm dlx ${hs}@latest install`);return n.toString(`latin1`)===`#!`?`node-shim`:`native`}finally{s.closeSync(t)}}function Fs(e,t){if(!s.existsSync(e))throw Error(`install: bundled dist not found at ${e}. Reinstall the package.`);let n=Ns(e);if(!s.existsSync(n.sourcePath))throw Error(`install: render entry not found at ${n.sourcePath}. Reinstall the package.`);let r=E.join(E.dirname(e),Ut);if(!s.existsSync(r))throw Error(`install: the attach launcher was not found at ${r}. Reinstall the package.`);let i=E.join(E.dirname(e),Gt);if(!s.existsSync(i))throw Error(`install: the attach preload was not found at ${i}. Reinstall the package.`);let a=Os(t),o=Ds(t);s.mkdirSync(E.dirname(a),{recursive:!0}),s.mkdirSync(E.dirname(o),{recursive:!0}),Ps(e,a),nee(r,E.join(E.dirname(a),Ut)),Ps(i,E.join(E.dirname(a),Gt)),Ps(n.sourcePath,o),s.chmodSync(o,493),s.rmSync(E.join(t,`url-handler.mjs`),{force:!0});let c=ree(o);return process.stdout.write(`Staged cc-candybar v${tn} runtime at ${t}\n`+(c===`native`?` render entry: native binary (${process.platform}-${process.arch})\n`:` render entry: node shim (no native binary for ${process.platform}-${process.arch}; renders are correct but pay node startup)\n`)),{binPath:o,distPath:a,entryKind:c}}function iee(){return[`<?xml version="1.0" encoding="UTF-8"?>`,`<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">`,`<plist version="1.0">`,`<dict>`,` <key>CFBundleIdentifier</key>`,` <string>com.cccandybar.url-handler</string>`,` <key>CFBundleName</key>`,` <string>${Hi}</string>`,` <key>CFBundleDisplayName</key>`,` <string>cc-candybar</string>`,` <key>CFBundleExecutable</key>`,` <string>${Hi}</string>`,` <key>CFBundlePackageType</key>`,` <string>APPL</string>`,` <key>CFBundleVersion</key>`,` <string>${tn}</string>`,` <key>CFBundleShortVersionString</key>`,` <string>${tn}</string>`,` <key>LSMinimumSystemVersion</key>`,` <string>12.0</string>`,` <key>LSBackgroundOnly</key>`,` <true/>`,` <key>CFBundleURLTypes</key>`,` <array>`,` <dict>`,` <key>CFBundleURLName</key>`,` <string>cc-candybar click</string>`,` <key>CFBundleURLSchemes</key>`,` <array>`,` <string>${Vi}</string>`,` </array>`,` </dict>`,` </array>`,`</dict>`,`</plist>`,``].join(`
36
36
  `)}function Is(e,{host:t,launcher:n}){let r=ws(t),i=`${r}.installing`,a=As(i);process.stdout.write(`Building ${r}\n`),s.rmSync(i,{recursive:!0,force:!0});try{s.mkdirSync(E.dirname(a),{recursive:!0}),s.copyFileSync(e,a),s.chmodSync(a,493),s.writeFileSync(E.join(i,`Contents`,`Info.plist`),iee());let t=n.launchSync({bin:`/usr/bin/codesign`,args:[`--force`,`--sign`,`-`,i],category:`install.codesign`});if(!t.ok)throw process.stderr.write(t.stderr),Error(`codesign failed (${Je(t)})`);s.rmSync(r,{recursive:!0,force:!0}),s.renameSync(i,r)}catch(e){throw s.rmSync(i,{recursive:!0,force:!0}),e}let o=n.launchSync({bin:`/usr/bin/killall`,args:[Hi],category:`install.killall`});if(!o.ok&&o.exitCode!==1)throw process.stderr.write(o.stderr),Error(`killall ${Hi} failed (${Je(o)})`);process.stdout.write(o.ok?`Quit the running ${Hi}; the next click starts the new one\n`:`${Hi} was not running\n`),process.stdout.write(`Registering ${Vi}:// with Launch Services\n`);let c=n.launchSync({bin:`/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister`,args:[`-f`,r],category:`install.lsregister`});if(!c.ok)throw process.stderr.write(c.stderr),Error(`lsregister failed (${Je(c)})`);process.stdout.write(`✓ ${Hi}.app installed and registered.\n`),process.stdout.write(` Test: open '${Vi}://hello-world' && pbpaste\n`)}function aee(e,t){Ts();let n=js(e);Fs(e,Es(t.host)),Is(n,t)}async function Ls(e,t){e||(process.stderr.write(`url-handle: missing URL argument.
37
37
  `),process.exit(1));let n=Ma(e);n.ok||(process.stderr.write(`url-handle: ${n.problem}\n`),process.exit(1));let r=await xr(t,n.verb,n.value);r.kind===`ok`&&process.exit(0);let i=Rs(r);i.kick&&Zr(t),process.stderr.write(i.stderr),process.exit(i.code)}function Rs(e){switch(e.kind){case`busy`:return{stderr:`url-handle: daemon busy (${e.message})\n`,code:+(e.phase===`connect`),kick:!1};case`transient`:return{stderr:`url-handle: daemon unavailable (${e.cause}: ${e.message})\n`,code:1,kick:!0};case`permanent`:return{stderr:zs(e)+`
38
38
  `,code:1,kick:!1}}}function zs(e){switch(e.cause){case`version_mismatch`:return`url-handle: daemon rejected click (version mismatch: client v${e.clientV} ≠ daemon v${e.daemonV})`;case`bad_request`:return`url-handle: daemon rejected click (bad request: ${e.message})`;case`render_failed`:return`url-handle: daemon rejected click (handler failed: ${e.message})`;case`switched_off`:return`url-handle: daemon rejected click (switched off: ${e.message})`;case`malformed_response`:return`url-handle: daemon rejected click (malformed response: ${e.message})`}}function Bs(){return`✓ install complete.
39
39
  Restart Claude Code to pick up the new statusline.
40
40
  Tip: every bar carries a settings menu — click it (${vi} by\n default) for quick actions, preset switching, edit mode, and clickable\n theme/style/variation/shade/endcaps/wrap/padding controls.\n`}async function Vs(e,t,n){let r=e.includes(`--force`),i=e.filter(e=>e!==`--force`),a=i.length>0?i:[...Ss],o=process.platform===`darwin`?js(t):null,s=Fs(t,Es(n.host));o===null?process.stdout.write(`Skipping URL handler (cmd-click verbs are macOS-only).
41
- `):Is(o,n),Hs(s.binPath,a,r,n.host),process.stdout.write(Bs());let c=vs(hs,_s(tn,await gs(hs,fetch,`https://registry.npmjs.org`,n.clock)));process[c.stream].write(c.text)}function Hs(e,t,n,r,i){let a=i??Qo(Zo(Xo(r.env,process.cwd()),r.home));s.mkdirSync(E.dirname(a),{recursive:!0});let o=ns(a).statusLine,c=ls(o)?o.command:void 0,l=[e,Vt(e),Bt(e)],u=typeof c==`string`&&(c.startsWith(`pnpm dlx @promptctl/cc-candybar@`)||l.some(e=>c===e||c.startsWith(`${e} `)));if(c&&!u&&!n){process.stderr.write(`Skipping settings.json update: existing statusLine.command appears customized.\n Current: ${c}\n To overwrite, re-run with --force.\n`);return}let d=Cs(e,t);Dn(a,(ls(o)?[[[`statusLine`,`type`],`command`],[[`statusLine`,`command`],d]]:[[[`statusLine`],{type:`command`,command:d}]]).reduce((e,[t,n])=>mo(e,t,JSON.stringify(n,null,2),Qa),ts(a))),process.stdout.write(`Updated ${a}\n`)}async function Us(e,t){return e.kind===`owned`?await t(e.pid,e.startTime)?{kind:`attach-and-exit`,reason:`live owner pid=${e.pid} holds the socket`}:{kind:`reclaim`,reason:`owner pid=${e.pid} is gone or recycled`}:e.kind===`absent`?{kind:`reclaim`,reason:`no lease — stale socket, no live owner`}:{kind:`reclaim`,reason:`unreadable lease (${e.detail}) — cannot prove a live owner`}}function Ws(e){let t;try{t=s.readFileSync(e,`utf8`)}catch(e){return e.code===`ENOENT`?{kind:`absent`}:{kind:`unreadable`,detail:`read failed: ${e.message}`}}let n;try{n=JSON.parse(t)}catch(e){return{kind:`unreadable`,detail:`bad JSON: ${e.message}`}}let r=n,i=r?.pid;if(typeof i!=`number`||!Number.isInteger(i)||i<=0)return{kind:`unreadable`,detail:`no valid pid (got ${JSON.stringify(i)})`};let a=r?.startTime;return a!=null&&typeof a!=`string`?{kind:`unreadable`,detail:`invalid startTime (got ${JSON.stringify(a)})`}:{kind:`owned`,pid:i,startTime:a??null}}function Gs(e,n){let r=`${e}.${t.pid}.tmp`;try{return s.writeFileSync(r,JSON.stringify(n),{mode:384}),s.renameSync(r,e),null}catch(e){let t=e.message;try{s.unlinkSync(r)}catch(e){if(e.code!==`ENOENT`)return`${t}; also failed to remove temp ${r}: ${e.message}`}return t}}function Ks(e,t){let n=Ws(e);if(n.kind===`owned`&&n.pid===t)try{s.unlinkSync(e)}catch{}}function qs(e){try{let t=s.statSync(e);return{kind:`present`,identity:{dev:t.dev,ino:t.ino}}}catch(e){return e.code===`ENOENT`?{kind:`absent`}:{kind:`unreadable`,detail:e.message}}}function Js(e,t,n,r){let i=Ys(e,t);return i===null?r.kind===`owned`?r.pid===n?{kind:`owned`}:{kind:`displaced`,reason:`lease reassigned (names pid=${r.pid}, we are pid=${n}) — a reclaimer overwrote it`}:{kind:`displaced`,reason:`lease not held (${r.kind}) — no longer the socket owner`}:{kind:`displaced`,reason:i}}function Ys(e,t){return t.kind===`present`?t.identity.dev===e.dev&&t.identity.ino===e.ino?null:`socket replaced (bound dev=${e.dev} ino=${e.ino}, now dev=${t.identity.dev} ino=${t.identity.ino})`:t.kind===`absent`?`socket path gone (ENOENT) — unlinked by a reclaimer`:`socket path unreadable (${t.detail}) — cannot prove ownership`}function Xs(e){let t=!1;function n(){let n=Js(e.bound,e.readIdentity(),e.myPid,e.readLease());return n.kind===`displaced`&&!t&&(t=!0,e.log(`warn`,`ownership self-check: ${n.reason}; shutting down`),e.shutdown(0)),n}function r(t=e.intervalMs??5e3){let r=e.clock.every(t,()=>{n().kind===`displaced`&&r()},{unref:!0});return{disarm:r}}return{check:n,arm:r}}async function Zs(e,t){let n=await t({bin:`ps`,args:[`-o`,`lstart=`,`-p`,String(e)],category:`process-fingerprint`,timeoutMs:2e3,envOverlay:{LC_ALL:`C`,TZ:`UTC`}});if(n.ok){let e=n.stdout.trim();return e.length>0?{kind:`start`,token:e}:{kind:`unavailable`,detail:`ps produced no start-time`}}return{kind:`unavailable`,detail:n.reason===`spawn-error`?n.error??`ps spawn failed`:`ps ${n.reason} (exit ${n.exitCode})`}}function Qs(e){return{alive:e=>{try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}},startTime:t=>Zs(t,e.launch)}}async function $s(e,t,n){if(t===null)return n.alive(e);let r=await n.startTime(e);switch(r.kind){case`start`:return r.token===t;case`unavailable`:return n.alive(e)}}async function ec(e,t){let n=await t(e);return n.kind===`start`?n.token:null}function tc(e){let t=Number(e.CC_CANDYBAR_DAEMON_CEILING??``);return Number.isInteger(t)&&t>0?t:16}function nc(e,t,n){return e?t>=n?{allow:!1,reason:`${t} live isolated daemons registered >= ceiling ${n}`}:{allow:!0,reason:`${t} live isolated daemons registered < ceiling ${n}`}:{allow:!0,reason:`canonical production socket — exempt (bind() already caps it to one)`}}function rc(e){try{return s.readdirSync(e).filter(e=>e.endsWith(`.json`)).map(t=>E.join(e,t))}catch{return[]}}function ic(e){let t;try{t=s.readFileSync(e,`utf8`)}catch{return null}try{let e=JSON.parse(t),n=e?.pid;return typeof n!=`number`||!Number.isInteger(n)||n<=0?null:{pid:n,startTime:typeof e?.startTime==`string`?e.startTime:null}}catch{return null}}async function ac(e,t,n){let r=0;for(let i of e)await t(i.identity.pid,i.identity.startTime)?r++:n(i.path);return r}async function oc(e){if(!e.isolated)return{decision:nc(!1,0,e.ceiling),registryPath:null};e.ensureDirSafe(e.registryDir);let t=[];for(let n of e.listFiles(e.registryDir)){let r=e.readEntry(n);r!==null&&r.pid!==e.pid&&t.push({path:n,identity:r})}let n=nc(!0,await ac(t,e.isSameLiveProcess,e.removeFile),e.ceiling);if(!n.allow)return{decision:n,registryPath:null};let r=E.join(e.registryDir,`pid-${e.pid}.json`);return e.writeEntry(r,{pid:e.pid,startTime:e.startTime}),{decision:n,registryPath:r}}function sc(e,t,n,r){let i=n(e);if(i!==null&&i.pid===t)try{r(e)}catch{}}function cc({host:e,launcher:t},n,r,i={}){return{isolated:!!e.env.CC_CANDYBAR_SOCKET,registryDir:r,ceiling:tc(e.env),pid:process.pid,startTime:n,isSameLiveProcess:(e,n)=>$s(e,n,Qs(t)),listFiles:rc,readEntry:ic,removeFile:e=>{try{s.unlinkSync(e)}catch{}},writeEntry:(e,t)=>{let n=`${e}.${t.pid}.tmp`;try{s.writeFileSync(n,JSON.stringify(t),{mode:384}),s.renameSync(n,e)}catch(e){try{s.unlinkSync(n)}catch(e){e.code}throw e}},ensureDirSafe:e.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR?mn:e=>{mn(E.dirname(e)),mn(e)},...i}}const lc=1e3;function uc(e){return`${e.dev}:${e.ino}`}function dc(e,t){return new Promise((n,r)=>s.write(e,t,(e,t)=>e===null?n(t):r(e)))}async function fc(e){for(let t=2;t>=1;t--)await s.promises.rename(`${e}.${t}`,`${e}.${t+1}`).catch(()=>{});await s.promises.rename(e,`${e}.1`).catch(()=>{})}function pc(e,t,n){return`${new Date(n).toISOString()} [${e}] ${t}\n`}function mc(e,t,n,r){let i=e.monotonic()+r,a=new Int32Array(new SharedArrayBuffer(4));for(;;){let{size:r}=s.fstatSync(t);if(r>=n||e.monotonic()>=i)return r;Atomics.wait(a,0,0,1)}}function hc(e,t){try{process.stderr.write(`${e}cc-candybar: daemon.log unwritable: ${t.message}\n`)}catch{}}var gc=class{sink=null;waiting=[];waitingBytes=0;dropped=0;droppedBytes=0;onItsWay=null;flushing=!1;drainedWaiters=[];exiting=!1;exitListener=null;disposed=!1;constructor(e,t){this.filePath=e,this.clock=t}log=(e,t)=>{let n=pc(e,t,this.clock.now());if(this.exitListener===null&&!this.disposed&&(this.exitListener=()=>{this.exiting=!0,this.writeWaitingSync(!0,lc)},process.on(`exit`,this.exitListener)),this.waiting.push(n),this.waitingBytes+=Buffer.byteLength(n),this.waitingBytes>4194304){let e=0;for(;this.waitingBytes>4194304/2&&e<this.waiting.length-1;){let t=Buffer.byteLength(this.waiting[e]);this.waitingBytes-=t,this.droppedBytes+=t,e++}this.waiting.splice(0,e),this.dropped+=e}this.exiting?this.writeWaitingSync(!0,lc):this.flushing||this.flush()};drained(){return this.flushing?new Promise(e=>this.drainedWaiters.push(e)):Promise.resolve()}writeNow(){this.writeWaitingSync(!1,2e3)}dispose(){this.disposed=!0,this.exitListener!==null&&(process.off(`exit`,this.exitListener),this.exitListener=null),this.flushing||this.closeSink()}closeSink(){if(this.sink!==null){try{s.closeSync(this.sink.fd)}catch{}this.sink=null}}async sinkAt(){let e=await s.promises.stat(this.filePath).catch(()=>null);if(this.sink!==null&&e!==null&&this.sink.id===uc(e))return{held:this.sink,size:e.size};this.closeSink(),await s.promises.mkdir(E.dirname(this.filePath),{recursive:!0});let t=await new Promise((e,t)=>s.open(this.filePath,`a`,(n,r)=>n===null?e(r):t(n))),n=await new Promise((e,n)=>s.fstat(t,(t,r)=>t===null?e(r):n(t)));return this.sink={path:this.filePath,fd:t,id:uc(n)},{held:this.sink,size:n.size}}async flush(){this.flushing=!0;try{for(;this.waiting.length>0;){let e=this.take(),t={bytes:Buffer.from(e),state:{kind:`taken`}};this.onItsWay=t;try{await this.append(t)}catch(n){this.closeSink(),t.state.kind!==`landed`&&hc(e,n)}finally{this.onItsWay=null}}}finally{this.flushing=!1,this.disposed&&this.closeSink();for(let e of this.drainedWaiters.splice(0))e()}}take(){let e=(this.dropped===0?``:pc(`warn`,`log: ${this.dropped} earlier line(s) dropped (${this.droppedBytes} bytes): more than 4194304 bytes were waiting for the disk`,this.clock.now()))+this.waiting.join(``);return this.waiting=[],this.waitingBytes=0,this.dropped=0,this.droppedBytes=0,e}async append(e){let{held:t,size:n}=await this.sinkAt();if(e.state.kind===`landed`)return;let{bytes:r}=e,i=n+r.length;e.state={kind:`issued`,fd:t.fd,endsAt:i};for(let e=0;e<r.length;){let n=await dc(t.fd,r.subarray(e));if(n===0)throw Error(`the disk took 0 bytes of a write`);e+=n}if(e.state={kind:`landed`},i>=5242880){this.closeSink();let e=await s.promises.stat(t.path).catch(()=>null);e!==null&&uc(e)===t.id&&await fc(t.path)}}writeWaitingSync(e,t){let n=this.onItsWay,r=Buffer.alloc(0);n!==null&&n.state.kind===`taken`&&(r=n.bytes,n.state={kind:`landed`});let i=null;if(n!==null&&n.state.kind===`issued`){let{fd:a,endsAt:o}=n.state;try{let s=mc(this.clock,a,o,t);s<o&&e?(r=n.bytes.subarray(Math.max(0,s-(o-n.bytes.length))),n.state={kind:`landed`}):s<o&&(i={fd:a,endsAt:o})}catch(t){e&&(r=n.bytes,n.state={kind:`landed`}),hc(n.bytes.toString(),t)}}if(r.length===0&&this.waiting.length===0)return;let a=Buffer.concat([r,Buffer.from(this.take())]);try{s.mkdirSync(E.dirname(this.filePath),{recursive:!0}),s.appendFileSync(this.filePath,a),i!==null&&n!==null&&uc(s.fstatSync(i.fd))===uc(s.statSync(this.filePath))&&(n.state={kind:`issued`,fd:i.fd,endsAt:i.endsAt+a.length})}catch(e){hc(a.toString(),e)}}};function _c(e,t,n,r){return{bin:`tmux`,args:[`-S`,e.socket,...n],timeoutMs:2e3,category:t,stdinInput:r}}function vc(e,t){return e.ok?{kind:`ok`,stdout:e.stdout}:e.reason===`rate-limited`?{kind:`rate-limited`,reason:Ze(e)}:{kind:`failed`,reason:`tmux ${t[0]} failed (${Ze(e)})`}}function yc(e,t,n,r,i){return vc(e.launchSync(_c(t,n,r,i)),r)}async function bc(e,t,n,r,i){return vc(await e.launch(_c(t,n,r,i)),r)}const xc=`click.error`;function Sc(e,t,n,r){let i={text:n,at:r,answered:!1};e.set(t,xc,JSON.stringify(i))}function Cc(e,t,n){let r=wc(e,t);r===null||!Be(r,n)||e.set(t,xc,JSON.stringify({...r,answered:!0}))}function wc(e,t){let n=e.get(t,xc);return n===null?null:Ec(n)}function Tc(e,t,n,r){let i=wc(e,t);if(i===null)return{kind:`none`};let a=ze(i,5,n,r);return a===`over`?{kind:a}:{kind:a,error:i}}function Ec(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let{text:n,at:r,answered:i}=t;return typeof n==`string`&&typeof r==`number`&&(i===void 0||typeof i==`boolean`)?{text:n,at:r,answered:i===!0}:null}const Dc=/^[^\s"=\\]+$/,R=e=>Dc.test(e)?e:JSON.stringify(e),Oc=(e,t)=>`${e}${t.map(([e,t])=>` ${e}=${R(t)}`).join(``)}`;function kc(e){if(e.ok)return`ok`;switch(e.reason){case`non-zero`:case`signal`:return`exit`;case`timeout`:return`timeout`;case`aborted`:return`aborted`;case`spawn-error`:case`rate-limited`:case`signal-refused`:return`launch`;case`output-limit`:return`output-limit`;case`pipe-error`:return`pipe`}}function Ac(e){return!e.ok&&e.signal!==null?e.signal:e.exitCode===null?`-`:String(e.exitCode)}var jc=class{deps;timeoutMs;inFlight=new Set;started=0;failed=0;timedOut=0;refusals=0;closed=!1;constructor(e){this.deps=e,this.timeoutMs=e.timeoutMs??1e4}start(e){if(this.closed)throw Error(`run owner used after close`);let t=e.refreshes.map(t=>this.deps.supersede(t.storage,e.sessionId)),n=new AbortController;this.inFlight.add(n),this.started++;let[r,...i]=e.argv,a=this.deps.clock.monotonic();this.deps.launch({bin:r.includes(`/`)?E.resolve(e.cwd,r):r,args:i,envOverlay:e.envOverlay,cwd:e.cwd,timeoutMs:this.timeoutMs,signal:n.signal,category:`click.run`}).then(t=>this.ended(e,t,A(this.deps.clock,a))).finally(()=>{this.inFlight.delete(n);for(let e of t)e()})}refused(e,t,n){this.refusals++,this.deps.log(`warn`,`run refused sid=${R(e)} action=${R(t)} reason=${R(n)}`)}stats(){return{started:this.started,failed:this.failed,timedOut:this.timedOut,refused:this.refusals,running:this.inFlight.size}}close(){this.closed=!0;for(let e of this.inFlight)e.abort()}ended(e,t,n){let r=kc(t);this.deps.log(r===`ok`||r===`aborted`?`info`:`warn`,`run sid=${R(e.sessionId)} action=${R(e.action)} program=${R(e.argv[0])} outcome=${r} exit=${Ac(t)} took=${n} refreshed=${e.refreshes.map(e=>e.name).join(`,`)||`-`}`),r===`timeout`&&this.timedOut++,!(t.ok||r===`aborted`)&&(r!==`timeout`&&this.failed++,Sc(this.deps.state,e.sessionId,`run ${e.action}: ${Ze(t)}`,this.deps.now()))}};const Mc={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`},Nc=e=>e!=null;function Pc(e){let t=e[Mc.socket]??``,n=e[Mc.pane]??``;if(t===``||n===``)return null;let r=e[Mc.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const Fc=e=>{try{let t=s.statSync(e,{bigint:!0});return{dev:t.dev,ino:t.ino,birthtimeNs:t.birthtimeNs}}catch(e){let t=e.code;if(t===`ENOENT`||t===`ENOTDIR`)return`gone`;throw e}},Ic=(e,t)=>e.dev===t.dev&&e.ino===t.ino&&e.birthtimeNs===t.birthtimeNs,Lc=e=>e===`gone`?`gone`:`${e.dev}:${e.ino}:${e.birthtimeNs}`,Rc=e=>{try{return Fc(e)}catch(e){return{unreadable:e.code??String(e)}}},zc=e=>typeof e==`string`||`ino`in e?Lc(e):`unreadable:${e.unreadable}`,Bc=e=>typeof e!=`string`&&`ino`in e,Vc=`probe`,Hc={delivery:()=>({kind:`unmeasured`,since:0,reason:`outside the daemon`,missedSince:null}),subscribe:()=>()=>{}},Uc=e=>new Date(e).toISOString(),Wc=e=>e.kind===`unmeasured`?`unmeasured:${e.reason}`:e.kind;var Gc=class{current;instrument={kind:`idle`};listeners=new Set;stalls=0;catchUps=0;probes=0;probeFailures=0;watchers;logger;identityOf;clock;constructor(e){this.watchers=e.watchers,this.logger=e.logger,this.clock=e.clock,this.identityOf=e.identityOf??Fc,this.current={kind:`unmeasured`,since:this.clock.now(),reason:`not started`,missedSince:null}}delivery(){return this.current}subscribe(e){return this.listeners.add(e),()=>void this.listeners.delete(e)}start(e){if(this.instrument.kind!==`idle`)throw Error(`file events: the owner was started twice`);let t=this.clock.every(3e4,()=>void this.tick(),{unref:!0}),n;try{s.mkdirSync(e,{recursive:!0}),n=this.identityOf(e)}catch(e){this.end(t,`the probe folder could not be made: ${e.message}`);return}if(n===`gone`){this.end(t,`the probe folder was removed as it was made`);return}let r={kind:`probing`,folder:e,identity:n,stopPeriod:t,handle:this.watchers.acquire(`file-events:${e}`,{dirs:[{path:e,filenames:[Vc]}]},e=>this.heard(r,e))};this.instrument=r,this.logger(`info`,`file events probing folder=${R(e)}`);let[i]=r.handle.deaf;if(i!==void 0){this.end(t,`the OS refused the probe folder's watch: ${i.reason}`);return}this.move({kind:`delivering`,unreported:[],missedSince:null}),this.tick()}stats(){return{delivery:this.current,stalls:this.stalls,catchUps:this.catchUps,probes:this.probes,probeFailures:this.probeFailures}}close(){let e=this.instrument;switch(this.instrument={kind:`idle`},this.listeners.clear(),e.kind){case`probing`:e.handle.release(),e.stopPeriod();return;case`ended`:e.stopPeriod();return;case`idle`:return}}async tick(){this.notify({kind:`period`});let e=this.instrument;if(e.kind!==`probing`)return;let t;try{t=this.identityOf(e.folder)}catch(t){this.end(e.stopPeriod,`the probe folder cannot be read: ${t.message}`);return}if(t===`gone`){this.end(e.stopPeriod,`the probe folder was removed`);return}if(!Ic(t,e.identity)){this.end(e.stopPeriod,`the probe folder was replaced`);return}let n=this.current;n.kind===`delivering`&&n.unreported.length>=2&&(this.stalls++,this.move({kind:`stalled`,missedSince:n.missedSince??n.unreported[0]})),await this.probe(e)}async probe(e){let t=this.clock.now(),n=this.current;n.kind===`delivering`&&(this.current={...n,unreported:[...n.unreported,t]});try{await s.promises.writeFile(E.join(e.folder,Vc),String(t))}catch(n){this.probeFailures++;let r=this.current;if(this.instrument!==e||r.kind===`unmeasured`)return;this.move({kind:`unmeasured`,since:t,reason:`the probe could not be written: ${n.message}`,missedSince:r.missedSince??t});return}this.probes++;let r=this.current;this.instrument!==e||r.kind!==`unmeasured`||this.move({kind:`delivering`,unreported:[t],missedSince:r.missedSince})}heard(e,t){if(this.instrument!==e)return;if(t.kind===`failed`){this.end(e.stopPeriod,`the probe folder's watch failed: ${t.reason}`);return}let n=this.current,r={kind:`delivering`,unreported:[],missedSince:null};if(n.missedSince===null){this.move(r);return}this.current=r,this.catchUps++,this.logger(`info`,`file events resumed since=${Uc(n.missedSince)} missed=${this.clock.now()-n.missedSince}ms from=${n.kind}`),this.notify({kind:`caught-up`,since:n.missedSince})}end(e,t){let n=this.instrument;n.kind===`probing`&&n.handle.release(),this.instrument={kind:`ended`,stopPeriod:e};let r=this.clock.now();this.move({kind:`unmeasured`,since:r,reason:`${t}; restart the daemon`,missedSince:this.current.missedSince??r})}move(e){let t=Wc(this.current);if(this.current=e,Wc(e)!==t){switch(e.kind){case`delivering`:this.logger(`info`,`file events delivering`);break;case`stalled`:this.logger(`warn`,`file events stalled since=${Uc(e.missedSince)}`);break;case`unmeasured`:this.logger(`warn`,`file events unmeasured since=${Uc(e.since)} reason=${JSON.stringify(e.reason)}`);break}this.notify({kind:`moved`})}}notify(e){for(let t of[...this.listeners])t(e)}};const Kc=e=>`file events stopped at ${Uc(e)}; the OS has delivered none since, not even for a file the daemon wrote to test it`,qc=e=>e.kind===`stalled`?Kc(e.missedSince):null;function Jc(e){if(e.missedSince===null)return[];let t=Uc(e.missedSince);return[{kind:`file-events`,state:e.kind,message:(()=>{switch(e.kind){case`delivering`:return`file events unconfirmed since ${t}: the probe written to test them has not been heard yet, so an edit to the config made since may not have reloaded`;case`stalled`:return`${Kc(e.missedSince)}, so an edit to the config will not reload until they resume`;case`unmeasured`:return`since ${t}, the daemon cannot check whether file events are arriving: ${e.reason}`}})()}]}function Yc(e){let{delivery:t}=e;return`${t.kind===`unmeasured`?`unmeasured since ${Uc(t.since)} reason=${JSON.stringify(t.reason)}`:t.kind}${t.missedSince===null?``:` unvouched since ${Uc(t.missedSince)}`} stalls=${e.stalls} catchUps=${e.catchUps} probes=${e.probes} probeFailures=${e.probeFailures}`}const Xc=[[0,0,0],[768,879,0],[1155,1161,0],[1425,1469,0],[1471,1471,0],[1473,1474,0],[1476,1477,0],[1479,1479,0],[1552,1562,0],[1564,1564,0],[1611,1631,0],[1648,1648,0],[1750,1756,0],[1759,1764,0],[1767,1768,0],[1770,1773,0],[1809,1809,0],[1840,1866,0],[1958,1968,0],[2027,2035,0],[2045,2045,0],[2070,2073,0],[2075,2083,0],[2085,2087,0],[2089,2093,0],[2137,2139,0],[2199,2207,0],[2250,2273,0],[2275,2307,0],[2362,2364,0],[2366,2383,0],[2385,2391,0],[2402,2403,0],[2433,2435,0],[2492,2492,0],[2494,2500,0],[2503,2504,0],[2507,2509,0],[2519,2519,0],[2530,2531,0],[2558,2558,0],[2561,2563,0],[2620,2620,0],[2622,2626,0],[2631,2632,0],[2635,2637,0],[2641,2641,0],[2672,2673,0],[2677,2677,0],[2689,2691,0],[2748,2748,0],[2750,2757,0],[2759,2761,0],[2763,2765,0],[2786,2787,0],[2810,2815,0],[2817,2819,0],[2876,2876,0],[2878,2884,0],[2887,2888,0],[2891,2893,0],[2901,2903,0],[2914,2915,0],[2946,2946,0],[3006,3010,0],[3014,3016,0],[3018,3021,0],[3031,3031,0],[3072,3076,0],[3132,3132,0],[3134,3140,0],[3142,3144,0],[3146,3149,0],[3157,3158,0],[3170,3171,0],[3201,3203,0],[3260,3260,0],[3262,3268,0],[3270,3272,0],[3274,3277,0],[3285,3286,0],[3298,3299,0],[3315,3315,0],[3328,3331,0],[3387,3388,0],[3390,3396,0],[3398,3400,0],[3402,3405,0],[3415,3415,0],[3426,3427,0],[3457,3459,0],[3530,3530,0],[3535,3540,0],[3542,3542,0],[3544,3551,0],[3570,3571,0],[3633,3633,0],[3636,3642,0],[3655,3662,0],[3761,3761,0],[3764,3772,0],[3784,3790,0],[3864,3865,0],[3893,3893,0],[3895,3895,0],[3897,3897,0],[3902,3903,0],[3953,3972,0],[3974,3975,0],[3981,3991,0],[3993,4028,0],[4038,4038,0],[4139,4158,0],[4182,4185,0],[4190,4192,0],[4194,4196,0],[4199,4205,0],[4209,4212,0],[4226,4237,0],[4239,4239,0],[4250,4253,0],[4352,4447,2],[4448,4607,0],[4957,4959,0],[5906,5909,0],[5938,5940,0],[5970,5971,0],[6002,6003,0],[6068,6099,0],[6109,6109,0],[6155,6159,0],[6277,6278,0],[6313,6313,0],[6432,6443,0],[6448,6459,0],[6679,6683,0],[6741,6750,0],[6752,6780,0],[6783,6783,0],[6832,6877,0],[6880,6891,0],[6912,6916,0],[6964,6980,0],[7019,7027,0],[7040,7042,0],[7073,7085,0],[7142,7155,0],[7204,7223,0],[7376,7378,0],[7380,7400,0],[7405,7405,0],[7412,7412,0],[7415,7417,0],[7616,7679,0],[8203,8207,0],[8232,8238,0],[8288,8303,0],[8400,8432,0],[8986,8987,2],[9001,9002,2],[9193,9196,2],[9200,9200,2],[9203,9203,2],[9725,9726,2],[9748,9749,2],[9776,9783,2],[9800,9811,2],[9855,9855,2],[9866,9871,2],[9875,9875,2],[9889,9889,2],[9898,9899,2],[9917,9918,2],[9924,9925,2],[9934,9934,2],[9940,9940,2],[9962,9962,2],[9970,9971,2],[9973,9973,2],[9978,9978,2],[9981,9981,2],[9989,9989,2],[9994,9995,2],[10024,10024,2],[10060,10060,2],[10062,10062,2],[10067,10069,2],[10071,10071,2],[10133,10135,2],[10160,10160,2],[10175,10175,2],[11035,11036,2],[11088,11088,2],[11093,11093,2],[11503,11505,0],[11647,11647,0],[11744,11775,0],[11904,11929,2],[11931,12019,2],[12032,12245,2],[12272,12329,2],[12330,12335,0],[12336,12350,2],[12353,12438,2],[12441,12442,0],[12443,12543,2],[12549,12591,2],[12593,12643,2],[12644,12644,0],[12645,12686,2],[12688,12773,2],[12783,12830,2],[12832,12871,2],[12880,42124,2],[42128,42182,2],[42607,42610,0],[42612,42621,0],[42654,42655,0],[42736,42737,0],[43010,43010,0],[43014,43014,0],[43019,43019,0],[43043,43047,0],[43052,43052,0],[43136,43137,0],[43188,43205,0],[43232,43249,0],[43263,43263,0],[43302,43309,0],[43335,43347,0],[43360,43388,2],[43392,43395,0],[43443,43456,0],[43493,43493,0],[43561,43574,0],[43587,43587,0],[43596,43597,0],[43643,43645,0],[43696,43696,0],[43698,43700,0],[43703,43704,0],[43710,43711,0],[43713,43713,0],[43755,43759,0],[43765,43766,0],[44003,44010,0],[44012,44013,0],[44032,55203,2],[55216,55295,0],[63744,64255,2],[64286,64286,0],[65024,65039,0],[65040,65049,2],[65056,65071,0],[65072,65106,2],[65108,65126,2],[65128,65131,2],[65279,65279,0],[65281,65376,2],[65440,65440,0],[65504,65510,2],[65520,65531,0],[66045,66045,0],[66272,66272,0],[66422,66426,0],[68097,68099,0],[68101,68102,0],[68108,68111,0],[68152,68154,0],[68159,68159,0],[68325,68326,0],[68900,68903,0],[68969,68973,0],[69291,69292,0],[69370,69375,0],[69446,69456,0],[69506,69509,0],[69632,69634,0],[69688,69702,0],[69744,69744,0],[69747,69748,0],[69759,69762,0],[69808,69818,0],[69826,69826,0],[69888,69890,0],[69927,69940,0],[69957,69958,0],[70003,70003,0],[70016,70018,0],[70067,70080,0],[70089,70092,0],[70094,70095,0],[70188,70199,0],[70206,70206,0],[70209,70209,0],[70367,70378,0],[70400,70403,0],[70459,70460,0],[70462,70468,0],[70471,70472,0],[70475,70477,0],[70487,70487,0],[70498,70499,0],[70502,70508,0],[70512,70516,0],[70584,70592,0],[70594,70594,0],[70597,70597,0],[70599,70602,0],[70604,70608,0],[70610,70610,0],[70625,70626,0],[70709,70726,0],[70750,70750,0],[70832,70851,0],[71087,71093,0],[71096,71104,0],[71132,71133,0],[71216,71232,0],[71339,71351,0],[71453,71467,0],[71724,71738,0],[71984,71989,0],[71991,71992,0],[71995,71998,0],[72e3,72e3,0],[72002,72003,0],[72145,72151,0],[72154,72160,0],[72164,72164,0],[72193,72202,0],[72243,72249,0],[72251,72254,0],[72263,72263,0],[72273,72283,0],[72330,72345,0],[72544,72551,0],[72751,72758,0],[72760,72767,0],[72850,72871,0],[72873,72886,0],[73009,73014,0],[73018,73018,0],[73020,73021,0],[73023,73029,0],[73031,73031,0],[73098,73102,0],[73104,73105,0],[73107,73111,0],[73459,73462,0],[73472,73473,0],[73475,73475,0],[73524,73530,0],[73534,73538,0],[73562,73562,0],[78896,78912,0],[78919,78933,0],[90398,90415,0],[92912,92916,0],[92976,92982,0],[94031,94031,0],[94033,94087,0],[94095,94098,0],[94176,94179,2],[94180,94180,0],[94192,94193,0],[94194,94198,2],[94208,101589,2],[101631,101662,2],[101760,101874,2],[110576,110579,2],[110581,110587,2],[110589,110590,2],[110592,110882,2],[110898,110898,2],[110928,110930,2],[110933,110933,2],[110948,110951,2],[110960,111355,2],[113821,113822,0],[113824,113827,0],[118528,118573,0],[118576,118598,0],[119141,119145,0],[119149,119170,0],[119173,119179,0],[119210,119213,0],[119362,119364,0],[119552,119638,2],[119648,119670,2],[121344,121398,0],[121403,121452,0],[121461,121461,0],[121476,121476,0],[121499,121503,0],[121505,121519,0],[122880,122886,0],[122888,122904,0],[122907,122913,0],[122915,122916,0],[122918,122922,0],[123023,123023,0],[123184,123190,0],[123566,123566,0],[123628,123631,0],[124140,124143,0],[124398,124399,0],[124643,124643,0],[124646,124646,0],[124654,124655,0],[124661,124661,0],[125136,125142,0],[125252,125258,0],[126980,126980,2],[127183,127183,2],[127374,127374,2],[127377,127386,2],[127488,127490,2],[127504,127547,2],[127552,127560,2],[127568,127569,2],[127584,127589,2],[127744,127776,2],[127789,127797,2],[127799,127868,2],[127870,127891,2],[127904,127946,2],[127951,127955,2],[127968,127984,2],[127988,127988,2],[127992,127994,2],[127995,127999,0],[128e3,128062,2],[128064,128064,2],[128066,128252,2],[128255,128317,2],[128331,128334,2],[128336,128359,2],[128378,128378,2],[128405,128406,2],[128420,128420,2],[128507,128591,2],[128640,128709,2],[128716,128716,2],[128720,128722,2],[128725,128728,2],[128732,128735,2],[128747,128748,2],[128756,128764,2],[128992,129003,2],[129008,129008,2],[129292,129338,2],[129340,129349,2],[129351,129535,2],[129648,129660,2],[129664,129674,2],[129678,129734,2],[129736,129736,2],[129741,129756,2],[129759,129770,2],[129775,129784,2],[131072,196605,2],[196608,262141,2],[917504,921599,0]],Zc=new Set([35,42,48,49,50,51,52,53,54,55,56,57,169,174,8252,8265,8482,8505,8596,8597,8598,8599,8600,8601,8617,8618,9e3,9167,9197,9198,9199,9201,9202,9208,9209,9210,9410,9642,9643,9654,9664,9723,9724,9728,9729,9730,9731,9732,9742,9745,9752,9757,9760,9762,9763,9766,9770,9774,9775,9784,9785,9786,9792,9794,9823,9824,9827,9829,9830,9832,9851,9854,9874,9876,9877,9878,9879,9881,9883,9884,9888,9895,9904,9905,9928,9935,9937,9939,9961,9968,9969,9972,9975,9976,9977,9986,9992,9993,9996,9997,9999,10002,10004,10006,10013,10017,10035,10036,10052,10055,10083,10084,10145,10548,10549,11013,11014,11015,127344,127345,127358,127359,127777,127780,127781,127782,127783,127784,127785,127786,127787,127788,127798,127869,127894,127895,127897,127898,127899,127902,127903,127947,127948,127949,127950,127956,127957,127958,127959,127960,127961,127962,127963,127964,127965,127966,127967,127987,127989,127991,128063,128065,128253,128329,128330,128367,128368,128371,128372,128373,128374,128375,128376,128377,128391,128394,128395,128396,128397,128400,128421,128424,128433,128434,128444,128450,128451,128452,128465,128466,128467,128476,128477,128478,128481,128483,128488,128495,128499,128506,128715,128717,128718,128719,128736,128737,128738,128739,128740,128741,128745,128752,128755]);function Qc(e){if(e<32||e>=127&&e<160)return 0;let t=0,n=Xc.length-1;for(;t<=n;){let r=t+n>>1,[i,a,o]=Xc[r];if(e<i)n=r-1;else if(e>a)t=r+1;else return o}return 1}function $c(e){return Zc.has(e)}var el=class{entries=new Map;get size(){return this.entries.size}get(e,t){let n=this.entries.get(e);if(n!==void 0)return n;let r=t(e);return this.entries.size>=4096&&this.entries.clear(),this.entries.set(e,r),r}},tl=class{entries=new WeakMap;get(e,t){let n=this.entries.get(e);if(n!==void 0)return n;let r=t(e);return this.entries.set(e,r),r}};function nl(e){if(e.global||e.sticky)throw TypeError(`/${e.source}/${e.flags} keeps a cursor in lastIndex; make it in the function that runs it`);return e}const rl=new el,il=nl(/[\u200d\ufe0f]/),al=nl(/^[ -~]*$/),ol=new Intl.Segmenter(void 0,{granularity:`grapheme`});function sl(e){let t=0,n=!1,r=!1;for(let i of e){let e=i.codePointAt(0);if(r)r=!1;else if(e===8205)r=!0;else if(e===65039)t+=+!!n,n=!1;else{let r=Qc(e);t+=r,n=r>0?$c(e):n}}return t}function cl(e){if(al.test(e))return e.length;if(!il.test(e))return sl(e);let t=0;for(let{segment:n}of ol.segment(e))t+=sl(n);return t}function z(e){return e.length===0?0:e.length<=64?rl.get(e,cl):cl(e)}function ll(e){return e}function ul(e){return e}function dl(e){return e>0?Math.floor(e):0}function fl(e,t){if(t<=0)return[``,e];if(t>=z(e))return[e,``];let n=_l(e,t);return[n+` `.repeat(t-z(n)),e.slice(n.length)]}function pl(e,t){let n=[],r=0,i=0,a=0,o=0,s=0;for(let c of gl(e,ul(0))){if(s===t.length)break;let l=o+z(c),u=o;for(;s<t.length&&t[s]<l;s++){let l=t[s];n.push(` `.repeat(i)+e.slice(r,a)+` `.repeat(l-u)),i=0,r=l===o?a:a+c.length,u=l}u>o&&(i=l-u),a+=c.length,o=l}return n.push(` `.repeat(i)+e.slice(r)),n}function ml(e,t){return t<=0||e.length===0?[e]:Array.from(oee(e,()=>t),({start:t,end:n})=>e.slice(t,n))}function*oee(e,t){let n=0,r=0,i=0,a=0;for(let o of gl(e,ul(0))){let e=z(o);i>r&&a+e>t(n)&&(yield{start:ul(r),end:ul(i)},n+=1,r=i,a=0),a+=e,i+=o.length}i>r&&(yield{start:ul(r),end:ul(i)})}function hl(e){return al.test(e)?e.split(``):Array.from(gl(e,ul(0)))}function*gl(e,t){let n=ol.segment(e);for(let r=t,i=n.containing(r);i;i=n.containing(r)){let t=i.index+i.segment.length;yield e.slice(r,t),r=ul(t)}}function*see(e,t){let n=ol.segment(e);for(let r=t;r>0;){let{index:t}=n.containing(r-1);yield e.slice(t,r),r=ul(t)}}function _l(e,t){return e.slice(0,yl(gl(e,ul(0)),t))}function vl(e,t){return e.slice(e.length-yl(see(e,ul(e.length)),t))}function yl(e,t){let n=0,r=0;for(let i of e){let e=z(i);if(n+e>t)break;n+=e,r+=i.length}return r}function cee(e){if(!Number.isInteger(e)||e<1)throw RangeError(`tabSize must be a positive integer, got ${e}`);return e}function bl(e,t){let[n,...r]=e.split(` `),i=[],a=[],o=(e,t)=>{let n=e.lastIndexOf(`
41
+ `):Is(o,n),Hs(s.binPath,a,r,n.host),process.stdout.write(Bs());let c=vs(hs,_s(tn,await gs(hs,fetch,`https://registry.npmjs.org`,n.clock)));process[c.stream].write(c.text)}function Hs(e,t,n,r,i){let a=i??Qo(Zo(Xo(r.env,process.cwd()),r.home));s.mkdirSync(E.dirname(a),{recursive:!0});let o=ns(a).statusLine,c=ls(o)?o.command:void 0,l=[e,Vt(e),Bt(e)],u=typeof c==`string`&&(c.startsWith(`pnpm dlx @promptctl/cc-candybar@`)||l.some(e=>c===e||c.startsWith(`${e} `)));if(c&&!u&&!n){process.stderr.write(`Skipping settings.json update: existing statusLine.command appears customized.\n Current: ${c}\n To overwrite, re-run with --force.\n`);return}let d=Cs(e,t);Dn(a,(ls(o)?[[[`statusLine`,`type`],`command`],[[`statusLine`,`command`],d]]:[[[`statusLine`],{type:`command`,command:d}]]).reduce((e,[t,n])=>mo(e,t,JSON.stringify(n,null,2),Qa),ts(a))),process.stdout.write(`Updated ${a}\n`)}async function Us(e,t){return e.kind===`owned`?await t(e.pid,e.startTime)?{kind:`attach-and-exit`,reason:`live owner pid=${e.pid} holds the socket`}:{kind:`reclaim`,reason:`owner pid=${e.pid} is gone or recycled`}:e.kind===`absent`?{kind:`reclaim`,reason:`no lease — stale socket, no live owner`}:{kind:`reclaim`,reason:`unreadable lease (${e.detail}) — cannot prove a live owner`}}function Ws(e){let t;try{t=s.readFileSync(e,`utf8`)}catch(e){return e.code===`ENOENT`?{kind:`absent`}:{kind:`unreadable`,detail:`read failed: ${e.message}`}}let n;try{n=JSON.parse(t)}catch(e){return{kind:`unreadable`,detail:`bad JSON: ${e.message}`}}let r=n,i=r?.pid;if(typeof i!=`number`||!Number.isInteger(i)||i<=0)return{kind:`unreadable`,detail:`no valid pid (got ${JSON.stringify(i)})`};let a=r?.startTime;return a!=null&&typeof a!=`string`?{kind:`unreadable`,detail:`invalid startTime (got ${JSON.stringify(a)})`}:{kind:`owned`,pid:i,startTime:a??null}}function Gs(e,n){let r=`${e}.${t.pid}.tmp`;try{return s.writeFileSync(r,JSON.stringify(n),{mode:384}),s.renameSync(r,e),null}catch(e){let t=e.message;try{s.unlinkSync(r)}catch(e){if(e.code!==`ENOENT`)return`${t}; also failed to remove temp ${r}: ${e.message}`}return t}}function Ks(e,t){let n=Ws(e);if(n.kind===`owned`&&n.pid===t)try{s.unlinkSync(e)}catch{}}function qs(e){try{let t=s.statSync(e);return{kind:`present`,identity:{dev:t.dev,ino:t.ino}}}catch(e){return e.code===`ENOENT`?{kind:`absent`}:{kind:`unreadable`,detail:e.message}}}function Js(e,t,n,r){let i=Ys(e,t);return i===null?r.kind===`owned`?r.pid===n?{kind:`owned`}:{kind:`displaced`,reason:`lease reassigned (names pid=${r.pid}, we are pid=${n}) — a reclaimer overwrote it`}:{kind:`displaced`,reason:`lease not held (${r.kind}) — no longer the socket owner`}:{kind:`displaced`,reason:i}}function Ys(e,t){return t.kind===`present`?t.identity.dev===e.dev&&t.identity.ino===e.ino?null:`socket replaced (bound dev=${e.dev} ino=${e.ino}, now dev=${t.identity.dev} ino=${t.identity.ino})`:t.kind===`absent`?`socket path gone (ENOENT) — unlinked by a reclaimer`:`socket path unreadable (${t.detail}) — cannot prove ownership`}function Xs(e){let t=!1;function n(){let n=Js(e.bound,e.readIdentity(),e.myPid,e.readLease());return n.kind===`displaced`&&!t&&(t=!0,e.log(`warn`,`ownership self-check: ${n.reason}; shutting down`),e.shutdown(0)),n}function r(t=e.intervalMs??5e3){let r=e.clock.every(t,()=>{n().kind===`displaced`&&r()},{unref:!0});return{disarm:r}}return{check:n,arm:r}}async function Zs(e,t){let n=await t({bin:`ps`,args:[`-o`,`lstart=`,`-p`,String(e)],category:`process-fingerprint`,timeoutMs:2e3,envOverlay:{LC_ALL:`C`,TZ:`UTC`}});if(n.ok){let e=n.stdout.trim();return e.length>0?{kind:`start`,token:e}:{kind:`unavailable`,detail:`ps produced no start-time`}}return{kind:`unavailable`,detail:n.reason===`spawn-error`?n.error??`ps spawn failed`:`ps ${n.reason} (exit ${n.exitCode})`}}function Qs(e){return{alive:e=>{try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}},startTime:t=>Zs(t,e.launch)}}async function $s(e,t,n){if(t===null)return n.alive(e);let r=await n.startTime(e);switch(r.kind){case`start`:return r.token===t;case`unavailable`:return n.alive(e)}}async function ec(e,t){let n=await t(e);return n.kind===`start`?n.token:null}function tc(e){let t=Number(e.CC_CANDYBAR_DAEMON_CEILING??``);return Number.isInteger(t)&&t>0?t:16}function nc(e,t,n){return e?t>=n?{allow:!1,reason:`${t} live isolated daemons registered >= ceiling ${n}`}:{allow:!0,reason:`${t} live isolated daemons registered < ceiling ${n}`}:{allow:!0,reason:`canonical production socket — exempt (bind() already caps it to one)`}}function rc(e){try{return s.readdirSync(e).filter(e=>e.endsWith(`.json`)).map(t=>E.join(e,t))}catch{return[]}}function ic(e){let t;try{t=s.readFileSync(e,`utf8`)}catch{return null}try{let e=JSON.parse(t),n=e?.pid;return typeof n!=`number`||!Number.isInteger(n)||n<=0?null:{pid:n,startTime:typeof e?.startTime==`string`?e.startTime:null}}catch{return null}}async function ac(e,t,n){let r=0;for(let i of e)await t(i.identity.pid,i.identity.startTime)?r++:n(i.path);return r}async function oc(e){if(!e.isolated)return{decision:nc(!1,0,e.ceiling),registryPath:null};e.ensureDirSafe(e.registryDir);let t=[];for(let n of e.listFiles(e.registryDir)){let r=e.readEntry(n);r!==null&&r.pid!==e.pid&&t.push({path:n,identity:r})}let n=nc(!0,await ac(t,e.isSameLiveProcess,e.removeFile),e.ceiling);if(!n.allow)return{decision:n,registryPath:null};let r=E.join(e.registryDir,`pid-${e.pid}.json`);return e.writeEntry(r,{pid:e.pid,startTime:e.startTime}),{decision:n,registryPath:r}}function sc(e,t,n,r){let i=n(e);if(i!==null&&i.pid===t)try{r(e)}catch{}}function cc({host:e,launcher:t},n,r,i={}){return{isolated:!!e.env.CC_CANDYBAR_SOCKET,registryDir:r,ceiling:tc(e.env),pid:process.pid,startTime:n,isSameLiveProcess:(e,n)=>$s(e,n,Qs(t)),listFiles:rc,readEntry:ic,removeFile:e=>{try{s.unlinkSync(e)}catch{}},writeEntry:(e,t)=>{let n=`${e}.${t.pid}.tmp`;try{s.writeFileSync(n,JSON.stringify(t),{mode:384}),s.renameSync(n,e)}catch(e){try{s.unlinkSync(n)}catch(e){e.code}throw e}},ensureDirSafe:e.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR?mn:e=>{mn(E.dirname(e)),mn(e)},...i}}const lc=1e3;function uc(e){return`${e.dev}:${e.ino}`}function dc(e,t){return new Promise((n,r)=>s.write(e,t,(e,t)=>e===null?n(t):r(e)))}async function fc(e){for(let t=2;t>=1;t--)await s.promises.rename(`${e}.${t}`,`${e}.${t+1}`).catch(()=>{});await s.promises.rename(e,`${e}.1`).catch(()=>{})}function pc(e,t,n){return`${new Date(n).toISOString()} [${e}] ${t}\n`}function mc(e,t,n,r){let i=e.monotonic()+r,a=new Int32Array(new SharedArrayBuffer(4));for(;;){let{size:r}=s.fstatSync(t);if(r>=n||e.monotonic()>=i)return r;Atomics.wait(a,0,0,1)}}function hc(e,t){try{process.stderr.write(`${e}cc-candybar: daemon.log unwritable: ${t.message}\n`)}catch{}}var gc=class{sink=null;waiting=[];waitingBytes=0;dropped=0;droppedBytes=0;onItsWay=null;flushing=!1;drainedWaiters=[];exiting=!1;exitListener=null;disposed=!1;constructor(e,t){this.filePath=e,this.clock=t}log=(e,t)=>{let n=pc(e,t,this.clock.now());if(this.exitListener===null&&!this.disposed&&(this.exitListener=()=>{this.exiting=!0,this.writeWaitingSync(!0,lc)},process.on(`exit`,this.exitListener)),this.waiting.push(n),this.waitingBytes+=Buffer.byteLength(n),this.waitingBytes>4194304){let e=0;for(;this.waitingBytes>4194304/2&&e<this.waiting.length-1;){let t=Buffer.byteLength(this.waiting[e]);this.waitingBytes-=t,this.droppedBytes+=t,e++}this.waiting.splice(0,e),this.dropped+=e}this.exiting?this.writeWaitingSync(!0,lc):this.flushing||this.flush()};drained(){return this.flushing?new Promise(e=>this.drainedWaiters.push(e)):Promise.resolve()}writeNow(){this.writeWaitingSync(!1,2e3)}dispose(){this.disposed=!0,this.exitListener!==null&&(process.off(`exit`,this.exitListener),this.exitListener=null),this.flushing||this.closeSink()}closeSink(){if(this.sink!==null){try{s.closeSync(this.sink.fd)}catch{}this.sink=null}}async sinkAt(){let e=await s.promises.stat(this.filePath).catch(()=>null);if(this.sink!==null&&e!==null&&this.sink.id===uc(e))return{held:this.sink,size:e.size};this.closeSink(),await s.promises.mkdir(E.dirname(this.filePath),{recursive:!0});let t=await new Promise((e,t)=>s.open(this.filePath,`a`,(n,r)=>n===null?e(r):t(n))),n=await new Promise((e,n)=>s.fstat(t,(t,r)=>t===null?e(r):n(t)));return this.sink={path:this.filePath,fd:t,id:uc(n)},{held:this.sink,size:n.size}}async flush(){this.flushing=!0;try{for(;this.waiting.length>0;){let e=this.take(),t={bytes:Buffer.from(e),state:{kind:`taken`}};this.onItsWay=t;try{await this.append(t)}catch(n){this.closeSink(),t.state.kind!==`landed`&&hc(e,n)}finally{this.onItsWay=null}}}finally{this.flushing=!1,this.disposed&&this.closeSink();for(let e of this.drainedWaiters.splice(0))e()}}take(){let e=(this.dropped===0?``:pc(`warn`,`log: ${this.dropped} earlier line(s) dropped (${this.droppedBytes} bytes): more than 4194304 bytes were waiting for the disk`,this.clock.now()))+this.waiting.join(``);return this.waiting=[],this.waitingBytes=0,this.dropped=0,this.droppedBytes=0,e}async append(e){let{held:t,size:n}=await this.sinkAt();if(e.state.kind===`landed`)return;let{bytes:r}=e,i=n+r.length;e.state={kind:`issued`,fd:t.fd,endsAt:i};for(let e=0;e<r.length;){let n=await dc(t.fd,r.subarray(e));if(n===0)throw Error(`the disk took 0 bytes of a write`);e+=n}if(e.state={kind:`landed`},i>=5242880){this.closeSink();let e=await s.promises.stat(t.path).catch(()=>null);e!==null&&uc(e)===t.id&&await fc(t.path)}}writeWaitingSync(e,t){let n=this.onItsWay,r=Buffer.alloc(0);n!==null&&n.state.kind===`taken`&&(r=n.bytes,n.state={kind:`landed`});let i=null;if(n!==null&&n.state.kind===`issued`){let{fd:a,endsAt:o}=n.state;try{let s=mc(this.clock,a,o,t);s<o&&e?(r=n.bytes.subarray(Math.max(0,s-(o-n.bytes.length))),n.state={kind:`landed`}):s<o&&(i={fd:a,endsAt:o})}catch(t){e&&(r=n.bytes,n.state={kind:`landed`}),hc(n.bytes.toString(),t)}}if(r.length===0&&this.waiting.length===0)return;let a=Buffer.concat([r,Buffer.from(this.take())]);try{s.mkdirSync(E.dirname(this.filePath),{recursive:!0}),s.appendFileSync(this.filePath,a),i!==null&&n!==null&&uc(s.fstatSync(i.fd))===uc(s.statSync(this.filePath))&&(n.state={kind:`issued`,fd:i.fd,endsAt:i.endsAt+a.length})}catch(e){hc(a.toString(),e)}}};function _c(e,t,n,r){return{bin:`tmux`,args:[`-S`,e.socket,...n],timeoutMs:2e3,category:t,stdinInput:r}}function vc(e,t){return e.ok?{kind:`ok`,stdout:e.stdout}:e.reason===`rate-limited`?{kind:`rate-limited`,reason:Ze(e)}:{kind:`failed`,reason:`tmux ${t[0]} failed (${Ze(e)})`}}function yc(e,t,n,r,i){return vc(e.launchSync(_c(t,n,r,i)),r)}async function bc(e,t,n,r,i){return vc(await e.launch(_c(t,n,r,i)),r)}const xc=`click.error`;function Sc(e,t,n,r){let i={text:n,at:r,answered:!1};e.set(t,xc,JSON.stringify(i))}function Cc(e,t,n){let r=wc(e,t);r===null||!Be(r,n)||e.set(t,xc,JSON.stringify({...r,answered:!0}))}function wc(e,t){let n=e.get(t,xc);return n===null?null:Ec(n)}function Tc(e,t,n,r){let i=wc(e,t);if(i===null)return{kind:`none`};let a=ze(i,5,n,r);return a===`over`?{kind:a}:{kind:a,error:i}}function Ec(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let{text:n,at:r,answered:i}=t;return typeof n==`string`&&typeof r==`number`&&(i===void 0||typeof i==`boolean`)?{text:n,at:r,answered:i===!0}:null}const Dc=/^[^\s"=\\]+$/,R=e=>Dc.test(e)?e:JSON.stringify(e),Oc=(e,t)=>`${e}${t.map(([e,t])=>` ${e}=${R(t)}`).join(``)}`;function kc(e){if(e.ok)return`ok`;switch(e.reason){case`non-zero`:case`signal`:return`exit`;case`timeout`:return`timeout`;case`aborted`:return`aborted`;case`spawn-error`:case`rate-limited`:case`signal-refused`:return`launch`;case`output-limit`:return`output-limit`;case`pipe-error`:return`pipe`}}function Ac(e){return!e.ok&&e.signal!==null?e.signal:e.exitCode===null?`-`:String(e.exitCode)}var jc=class{deps;timeoutMs;inFlight=new Set;started=0;failed=0;timedOut=0;refusals=0;closed=!1;constructor(e){this.deps=e,this.timeoutMs=e.timeoutMs??1e4}start(e){if(this.closed)throw Error(`run owner used after close`);let t=e.refreshes.map(t=>this.deps.supersede(t.storage,e.sessionId)),n=new AbortController;this.inFlight.add(n),this.started++;let[r,...i]=e.argv,a=this.deps.clock.monotonic();this.deps.launch({bin:r.includes(`/`)?E.resolve(e.cwd,r):r,args:i,envOverlay:e.envOverlay,cwd:e.cwd,timeoutMs:this.timeoutMs,signal:n.signal,category:`click.run`}).then(t=>this.ended(e,t,Fe(this.deps.clock,a))).finally(()=>{this.inFlight.delete(n);for(let e of t)e()})}refused(e,t,n){this.refusals++,this.deps.log(`warn`,`run refused sid=${R(e)} action=${R(t)} reason=${R(n)}`)}stats(){return{started:this.started,failed:this.failed,timedOut:this.timedOut,refused:this.refusals,running:this.inFlight.size}}close(){this.closed=!0;for(let e of this.inFlight)e.abort()}ended(e,t,n){let r=kc(t);this.deps.log(r===`ok`||r===`aborted`?`info`:`warn`,`run sid=${R(e.sessionId)} action=${R(e.action)} program=${R(e.argv[0])} outcome=${r} exit=${Ac(t)} took=${n} refreshed=${e.refreshes.map(e=>e.name).join(`,`)||`-`}`),r===`timeout`&&this.timedOut++,!(t.ok||r===`aborted`)&&(r!==`timeout`&&this.failed++,Sc(this.deps.state,e.sessionId,`run ${e.action}: ${Ze(t)}`,this.deps.now()))}};const Mc={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`},Nc=e=>e!=null;function Pc(e){let t=e[Mc.socket]??``,n=e[Mc.pane]??``;if(t===``||n===``)return null;let r=e[Mc.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const Fc=e=>{try{let t=s.statSync(e,{bigint:!0});return{dev:t.dev,ino:t.ino,birthtimeNs:t.birthtimeNs}}catch(e){let t=e.code;if(t===`ENOENT`||t===`ENOTDIR`)return`gone`;throw e}},Ic=(e,t)=>e.dev===t.dev&&e.ino===t.ino&&e.birthtimeNs===t.birthtimeNs,Lc=e=>e===`gone`?`gone`:`${e.dev}:${e.ino}:${e.birthtimeNs}`,Rc=e=>{try{return Fc(e)}catch(e){return{unreadable:e.code??String(e)}}},zc=e=>typeof e==`string`||`ino`in e?Lc(e):`unreadable:${e.unreadable}`,Bc=e=>typeof e!=`string`&&`ino`in e,Vc=`probe`,Hc={delivery:()=>({kind:`unmeasured`,since:0,reason:`outside the daemon`,missedSince:null}),subscribe:()=>()=>{}},Uc=e=>new Date(e).toISOString(),Wc=e=>e.kind===`unmeasured`?`unmeasured:${e.reason}`:e.kind;var Gc=class{current;instrument={kind:`idle`};listeners=new Set;stalls=0;catchUps=0;probes=0;probeFailures=0;watchers;logger;identityOf;clock;constructor(e){this.watchers=e.watchers,this.logger=e.logger,this.clock=e.clock,this.identityOf=e.identityOf??Fc,this.current={kind:`unmeasured`,since:this.clock.now(),reason:`not started`,missedSince:null}}delivery(){return this.current}subscribe(e){return this.listeners.add(e),()=>void this.listeners.delete(e)}start(e){if(this.instrument.kind!==`idle`)throw Error(`file events: the owner was started twice`);let t=this.clock.every(3e4,()=>void this.tick(),{unref:!0}),n;try{s.mkdirSync(e,{recursive:!0}),n=this.identityOf(e)}catch(e){this.end(t,`the probe folder could not be made: ${e.message}`);return}if(n===`gone`){this.end(t,`the probe folder was removed as it was made`);return}let r={kind:`probing`,folder:e,identity:n,stopPeriod:t,handle:this.watchers.acquire(`file-events:${e}`,{dirs:[{path:e,filenames:[Vc]}]},e=>this.heard(r,e))};this.instrument=r,this.logger(`info`,`file events probing folder=${R(e)}`);let[i]=r.handle.deaf;if(i!==void 0){this.end(t,`the OS refused the probe folder's watch: ${i.reason}`);return}this.move({kind:`delivering`,unreported:[],missedSince:null}),this.tick()}stats(){return{delivery:this.current,stalls:this.stalls,catchUps:this.catchUps,probes:this.probes,probeFailures:this.probeFailures}}close(){let e=this.instrument;switch(this.instrument={kind:`idle`},this.listeners.clear(),e.kind){case`probing`:e.handle.release(),e.stopPeriod();return;case`ended`:e.stopPeriod();return;case`idle`:return}}async tick(){this.notify({kind:`period`});let e=this.instrument;if(e.kind!==`probing`)return;let t;try{t=this.identityOf(e.folder)}catch(t){this.end(e.stopPeriod,`the probe folder cannot be read: ${t.message}`);return}if(t===`gone`){this.end(e.stopPeriod,`the probe folder was removed`);return}if(!Ic(t,e.identity)){this.end(e.stopPeriod,`the probe folder was replaced`);return}let n=this.current;n.kind===`delivering`&&n.unreported.length>=2&&(this.stalls++,this.move({kind:`stalled`,missedSince:n.missedSince??n.unreported[0]})),await this.probe(e)}async probe(e){let t=this.clock.now(),n=this.current;n.kind===`delivering`&&(this.current={...n,unreported:[...n.unreported,t]});try{await s.promises.writeFile(E.join(e.folder,Vc),String(t))}catch(n){this.probeFailures++;let r=this.current;if(this.instrument!==e||r.kind===`unmeasured`)return;this.move({kind:`unmeasured`,since:t,reason:`the probe could not be written: ${n.message}`,missedSince:r.missedSince??t});return}this.probes++;let r=this.current;this.instrument!==e||r.kind!==`unmeasured`||this.move({kind:`delivering`,unreported:[t],missedSince:r.missedSince})}heard(e,t){if(this.instrument!==e)return;if(t.kind===`failed`){this.end(e.stopPeriod,`the probe folder's watch failed: ${t.reason}`);return}let n=this.current,r={kind:`delivering`,unreported:[],missedSince:null};if(n.missedSince===null){this.move(r);return}this.current=r,this.catchUps++,this.logger(`info`,`file events resumed since=${Uc(n.missedSince)} missed=${this.clock.now()-n.missedSince}ms from=${n.kind}`),this.notify({kind:`caught-up`,since:n.missedSince})}end(e,t){let n=this.instrument;n.kind===`probing`&&n.handle.release(),this.instrument={kind:`ended`,stopPeriod:e};let r=this.clock.now();this.move({kind:`unmeasured`,since:r,reason:`${t}; restart the daemon`,missedSince:this.current.missedSince??r})}move(e){let t=Wc(this.current);if(this.current=e,Wc(e)!==t){switch(e.kind){case`delivering`:this.logger(`info`,`file events delivering`);break;case`stalled`:this.logger(`warn`,`file events stalled since=${Uc(e.missedSince)}`);break;case`unmeasured`:this.logger(`warn`,`file events unmeasured since=${Uc(e.since)} reason=${JSON.stringify(e.reason)}`);break}this.notify({kind:`moved`})}}notify(e){for(let t of[...this.listeners])t(e)}};const Kc=e=>`file events stopped at ${Uc(e)}; the OS has delivered none since, not even for a file the daemon wrote to test it`,qc=e=>e.kind===`stalled`?Kc(e.missedSince):null;function Jc(e){if(e.missedSince===null)return[];let t=Uc(e.missedSince);return[{kind:`file-events`,state:e.kind,message:(()=>{switch(e.kind){case`delivering`:return`file events unconfirmed since ${t}: the probe written to test them has not been heard yet, so an edit to the config made since may not have reloaded`;case`stalled`:return`${Kc(e.missedSince)}, so an edit to the config will not reload until they resume`;case`unmeasured`:return`since ${t}, the daemon cannot check whether file events are arriving: ${e.reason}`}})()}]}function Yc(e){let{delivery:t}=e;return`${t.kind===`unmeasured`?`unmeasured since ${Uc(t.since)} reason=${JSON.stringify(t.reason)}`:t.kind}${t.missedSince===null?``:` unvouched since ${Uc(t.missedSince)}`} stalls=${e.stalls} catchUps=${e.catchUps} probes=${e.probes} probeFailures=${e.probeFailures}`}const Xc=[[0,0,0],[768,879,0],[1155,1161,0],[1425,1469,0],[1471,1471,0],[1473,1474,0],[1476,1477,0],[1479,1479,0],[1552,1562,0],[1564,1564,0],[1611,1631,0],[1648,1648,0],[1750,1756,0],[1759,1764,0],[1767,1768,0],[1770,1773,0],[1809,1809,0],[1840,1866,0],[1958,1968,0],[2027,2035,0],[2045,2045,0],[2070,2073,0],[2075,2083,0],[2085,2087,0],[2089,2093,0],[2137,2139,0],[2199,2207,0],[2250,2273,0],[2275,2307,0],[2362,2364,0],[2366,2383,0],[2385,2391,0],[2402,2403,0],[2433,2435,0],[2492,2492,0],[2494,2500,0],[2503,2504,0],[2507,2509,0],[2519,2519,0],[2530,2531,0],[2558,2558,0],[2561,2563,0],[2620,2620,0],[2622,2626,0],[2631,2632,0],[2635,2637,0],[2641,2641,0],[2672,2673,0],[2677,2677,0],[2689,2691,0],[2748,2748,0],[2750,2757,0],[2759,2761,0],[2763,2765,0],[2786,2787,0],[2810,2815,0],[2817,2819,0],[2876,2876,0],[2878,2884,0],[2887,2888,0],[2891,2893,0],[2901,2903,0],[2914,2915,0],[2946,2946,0],[3006,3010,0],[3014,3016,0],[3018,3021,0],[3031,3031,0],[3072,3076,0],[3132,3132,0],[3134,3140,0],[3142,3144,0],[3146,3149,0],[3157,3158,0],[3170,3171,0],[3201,3203,0],[3260,3260,0],[3262,3268,0],[3270,3272,0],[3274,3277,0],[3285,3286,0],[3298,3299,0],[3315,3315,0],[3328,3331,0],[3387,3388,0],[3390,3396,0],[3398,3400,0],[3402,3405,0],[3415,3415,0],[3426,3427,0],[3457,3459,0],[3530,3530,0],[3535,3540,0],[3542,3542,0],[3544,3551,0],[3570,3571,0],[3633,3633,0],[3636,3642,0],[3655,3662,0],[3761,3761,0],[3764,3772,0],[3784,3790,0],[3864,3865,0],[3893,3893,0],[3895,3895,0],[3897,3897,0],[3902,3903,0],[3953,3972,0],[3974,3975,0],[3981,3991,0],[3993,4028,0],[4038,4038,0],[4139,4158,0],[4182,4185,0],[4190,4192,0],[4194,4196,0],[4199,4205,0],[4209,4212,0],[4226,4237,0],[4239,4239,0],[4250,4253,0],[4352,4447,2],[4448,4607,0],[4957,4959,0],[5906,5909,0],[5938,5940,0],[5970,5971,0],[6002,6003,0],[6068,6099,0],[6109,6109,0],[6155,6159,0],[6277,6278,0],[6313,6313,0],[6432,6443,0],[6448,6459,0],[6679,6683,0],[6741,6750,0],[6752,6780,0],[6783,6783,0],[6832,6877,0],[6880,6891,0],[6912,6916,0],[6964,6980,0],[7019,7027,0],[7040,7042,0],[7073,7085,0],[7142,7155,0],[7204,7223,0],[7376,7378,0],[7380,7400,0],[7405,7405,0],[7412,7412,0],[7415,7417,0],[7616,7679,0],[8203,8207,0],[8232,8238,0],[8288,8303,0],[8400,8432,0],[8986,8987,2],[9001,9002,2],[9193,9196,2],[9200,9200,2],[9203,9203,2],[9725,9726,2],[9748,9749,2],[9776,9783,2],[9800,9811,2],[9855,9855,2],[9866,9871,2],[9875,9875,2],[9889,9889,2],[9898,9899,2],[9917,9918,2],[9924,9925,2],[9934,9934,2],[9940,9940,2],[9962,9962,2],[9970,9971,2],[9973,9973,2],[9978,9978,2],[9981,9981,2],[9989,9989,2],[9994,9995,2],[10024,10024,2],[10060,10060,2],[10062,10062,2],[10067,10069,2],[10071,10071,2],[10133,10135,2],[10160,10160,2],[10175,10175,2],[11035,11036,2],[11088,11088,2],[11093,11093,2],[11503,11505,0],[11647,11647,0],[11744,11775,0],[11904,11929,2],[11931,12019,2],[12032,12245,2],[12272,12329,2],[12330,12335,0],[12336,12350,2],[12353,12438,2],[12441,12442,0],[12443,12543,2],[12549,12591,2],[12593,12643,2],[12644,12644,0],[12645,12686,2],[12688,12773,2],[12783,12830,2],[12832,12871,2],[12880,42124,2],[42128,42182,2],[42607,42610,0],[42612,42621,0],[42654,42655,0],[42736,42737,0],[43010,43010,0],[43014,43014,0],[43019,43019,0],[43043,43047,0],[43052,43052,0],[43136,43137,0],[43188,43205,0],[43232,43249,0],[43263,43263,0],[43302,43309,0],[43335,43347,0],[43360,43388,2],[43392,43395,0],[43443,43456,0],[43493,43493,0],[43561,43574,0],[43587,43587,0],[43596,43597,0],[43643,43645,0],[43696,43696,0],[43698,43700,0],[43703,43704,0],[43710,43711,0],[43713,43713,0],[43755,43759,0],[43765,43766,0],[44003,44010,0],[44012,44013,0],[44032,55203,2],[55216,55295,0],[63744,64255,2],[64286,64286,0],[65024,65039,0],[65040,65049,2],[65056,65071,0],[65072,65106,2],[65108,65126,2],[65128,65131,2],[65279,65279,0],[65281,65376,2],[65440,65440,0],[65504,65510,2],[65520,65531,0],[66045,66045,0],[66272,66272,0],[66422,66426,0],[68097,68099,0],[68101,68102,0],[68108,68111,0],[68152,68154,0],[68159,68159,0],[68325,68326,0],[68900,68903,0],[68969,68973,0],[69291,69292,0],[69370,69375,0],[69446,69456,0],[69506,69509,0],[69632,69634,0],[69688,69702,0],[69744,69744,0],[69747,69748,0],[69759,69762,0],[69808,69818,0],[69826,69826,0],[69888,69890,0],[69927,69940,0],[69957,69958,0],[70003,70003,0],[70016,70018,0],[70067,70080,0],[70089,70092,0],[70094,70095,0],[70188,70199,0],[70206,70206,0],[70209,70209,0],[70367,70378,0],[70400,70403,0],[70459,70460,0],[70462,70468,0],[70471,70472,0],[70475,70477,0],[70487,70487,0],[70498,70499,0],[70502,70508,0],[70512,70516,0],[70584,70592,0],[70594,70594,0],[70597,70597,0],[70599,70602,0],[70604,70608,0],[70610,70610,0],[70625,70626,0],[70709,70726,0],[70750,70750,0],[70832,70851,0],[71087,71093,0],[71096,71104,0],[71132,71133,0],[71216,71232,0],[71339,71351,0],[71453,71467,0],[71724,71738,0],[71984,71989,0],[71991,71992,0],[71995,71998,0],[72e3,72e3,0],[72002,72003,0],[72145,72151,0],[72154,72160,0],[72164,72164,0],[72193,72202,0],[72243,72249,0],[72251,72254,0],[72263,72263,0],[72273,72283,0],[72330,72345,0],[72544,72551,0],[72751,72758,0],[72760,72767,0],[72850,72871,0],[72873,72886,0],[73009,73014,0],[73018,73018,0],[73020,73021,0],[73023,73029,0],[73031,73031,0],[73098,73102,0],[73104,73105,0],[73107,73111,0],[73459,73462,0],[73472,73473,0],[73475,73475,0],[73524,73530,0],[73534,73538,0],[73562,73562,0],[78896,78912,0],[78919,78933,0],[90398,90415,0],[92912,92916,0],[92976,92982,0],[94031,94031,0],[94033,94087,0],[94095,94098,0],[94176,94179,2],[94180,94180,0],[94192,94193,0],[94194,94198,2],[94208,101589,2],[101631,101662,2],[101760,101874,2],[110576,110579,2],[110581,110587,2],[110589,110590,2],[110592,110882,2],[110898,110898,2],[110928,110930,2],[110933,110933,2],[110948,110951,2],[110960,111355,2],[113821,113822,0],[113824,113827,0],[118528,118573,0],[118576,118598,0],[119141,119145,0],[119149,119170,0],[119173,119179,0],[119210,119213,0],[119362,119364,0],[119552,119638,2],[119648,119670,2],[121344,121398,0],[121403,121452,0],[121461,121461,0],[121476,121476,0],[121499,121503,0],[121505,121519,0],[122880,122886,0],[122888,122904,0],[122907,122913,0],[122915,122916,0],[122918,122922,0],[123023,123023,0],[123184,123190,0],[123566,123566,0],[123628,123631,0],[124140,124143,0],[124398,124399,0],[124643,124643,0],[124646,124646,0],[124654,124655,0],[124661,124661,0],[125136,125142,0],[125252,125258,0],[126980,126980,2],[127183,127183,2],[127374,127374,2],[127377,127386,2],[127488,127490,2],[127504,127547,2],[127552,127560,2],[127568,127569,2],[127584,127589,2],[127744,127776,2],[127789,127797,2],[127799,127868,2],[127870,127891,2],[127904,127946,2],[127951,127955,2],[127968,127984,2],[127988,127988,2],[127992,127994,2],[127995,127999,0],[128e3,128062,2],[128064,128064,2],[128066,128252,2],[128255,128317,2],[128331,128334,2],[128336,128359,2],[128378,128378,2],[128405,128406,2],[128420,128420,2],[128507,128591,2],[128640,128709,2],[128716,128716,2],[128720,128722,2],[128725,128728,2],[128732,128735,2],[128747,128748,2],[128756,128764,2],[128992,129003,2],[129008,129008,2],[129292,129338,2],[129340,129349,2],[129351,129535,2],[129648,129660,2],[129664,129674,2],[129678,129734,2],[129736,129736,2],[129741,129756,2],[129759,129770,2],[129775,129784,2],[131072,196605,2],[196608,262141,2],[917504,921599,0]],Zc=new Set([35,42,48,49,50,51,52,53,54,55,56,57,169,174,8252,8265,8482,8505,8596,8597,8598,8599,8600,8601,8617,8618,9e3,9167,9197,9198,9199,9201,9202,9208,9209,9210,9410,9642,9643,9654,9664,9723,9724,9728,9729,9730,9731,9732,9742,9745,9752,9757,9760,9762,9763,9766,9770,9774,9775,9784,9785,9786,9792,9794,9823,9824,9827,9829,9830,9832,9851,9854,9874,9876,9877,9878,9879,9881,9883,9884,9888,9895,9904,9905,9928,9935,9937,9939,9961,9968,9969,9972,9975,9976,9977,9986,9992,9993,9996,9997,9999,10002,10004,10006,10013,10017,10035,10036,10052,10055,10083,10084,10145,10548,10549,11013,11014,11015,127344,127345,127358,127359,127777,127780,127781,127782,127783,127784,127785,127786,127787,127788,127798,127869,127894,127895,127897,127898,127899,127902,127903,127947,127948,127949,127950,127956,127957,127958,127959,127960,127961,127962,127963,127964,127965,127966,127967,127987,127989,127991,128063,128065,128253,128329,128330,128367,128368,128371,128372,128373,128374,128375,128376,128377,128391,128394,128395,128396,128397,128400,128421,128424,128433,128434,128444,128450,128451,128452,128465,128466,128467,128476,128477,128478,128481,128483,128488,128495,128499,128506,128715,128717,128718,128719,128736,128737,128738,128739,128740,128741,128745,128752,128755]);function Qc(e){if(e<32||e>=127&&e<160)return 0;let t=0,n=Xc.length-1;for(;t<=n;){let r=t+n>>1,[i,a,o]=Xc[r];if(e<i)n=r-1;else if(e>a)t=r+1;else return o}return 1}function $c(e){return Zc.has(e)}var el=class{entries=new Map;get size(){return this.entries.size}get(e,t){let n=this.entries.get(e);if(n!==void 0)return n;let r=t(e);return this.entries.size>=4096&&this.entries.clear(),this.entries.set(e,r),r}},tl=class{entries=new WeakMap;get(e,t){let n=this.entries.get(e);if(n!==void 0)return n;let r=t(e);return this.entries.set(e,r),r}};function nl(e){if(e.global||e.sticky)throw TypeError(`/${e.source}/${e.flags} keeps a cursor in lastIndex; make it in the function that runs it`);return e}const rl=new el,il=nl(/[\u200d\ufe0f]/),al=nl(/^[ -~]*$/),ol=new Intl.Segmenter(void 0,{granularity:`grapheme`});function sl(e){let t=0,n=!1,r=!1;for(let i of e){let e=i.codePointAt(0);if(r)r=!1;else if(e===8205)r=!0;else if(e===65039)t+=+!!n,n=!1;else{let r=Qc(e);t+=r,n=r>0?$c(e):n}}return t}function cl(e){if(al.test(e))return e.length;if(!il.test(e))return sl(e);let t=0;for(let{segment:n}of ol.segment(e))t+=sl(n);return t}function z(e){return e.length===0?0:e.length<=64?rl.get(e,cl):cl(e)}function ll(e){return e}function ul(e){return e}function dl(e){return e>0?Math.floor(e):0}function fl(e,t){if(t<=0)return[``,e];if(t>=z(e))return[e,``];let n=_l(e,t);return[n+` `.repeat(t-z(n)),e.slice(n.length)]}function pl(e,t){let n=[],r=0,i=0,a=0,o=0,s=0;for(let c of gl(e,ul(0))){if(s===t.length)break;let l=o+z(c),u=o;for(;s<t.length&&t[s]<l;s++){let l=t[s];n.push(` `.repeat(i)+e.slice(r,a)+` `.repeat(l-u)),i=0,r=l===o?a:a+c.length,u=l}u>o&&(i=l-u),a+=c.length,o=l}return n.push(` `.repeat(i)+e.slice(r)),n}function ml(e,t){return t<=0||e.length===0?[e]:Array.from(oee(e,()=>t),({start:t,end:n})=>e.slice(t,n))}function*oee(e,t){let n=0,r=0,i=0,a=0;for(let o of gl(e,ul(0))){let e=z(o);i>r&&a+e>t(n)&&(yield{start:ul(r),end:ul(i)},n+=1,r=i,a=0),a+=e,i+=o.length}i>r&&(yield{start:ul(r),end:ul(i)})}function hl(e){return al.test(e)?e.split(``):Array.from(gl(e,ul(0)))}function*gl(e,t){let n=ol.segment(e);for(let r=t,i=n.containing(r);i;i=n.containing(r)){let t=i.index+i.segment.length;yield e.slice(r,t),r=ul(t)}}function*see(e,t){let n=ol.segment(e);for(let r=t;r>0;){let{index:t}=n.containing(r-1);yield e.slice(t,r),r=ul(t)}}function _l(e,t){return e.slice(0,yl(gl(e,ul(0)),t))}function vl(e,t){return e.slice(e.length-yl(see(e,ul(e.length)),t))}function yl(e,t){let n=0,r=0;for(let i of e){let e=z(i);if(n+e>t)break;n+=e,r+=i.length}return r}function cee(e){if(!Number.isInteger(e)||e<1)throw RangeError(`tabSize must be a positive integer, got ${e}`);return e}function bl(e,t){let[n,...r]=e.split(` `),i=[],a=[],o=(e,t)=>{let n=e.lastIndexOf(`
42
42
  `);return(n<0?t:0)+z(e.slice(n+1))},s=n,c=n,l=0,u=n.length,d=0;for(let e of r){l=o(c,l);let n=t-l%t;d+=n-1,i.push(u),a.push(d),s+=` `.repeat(n)+e,l+=n,c=e,u+=1+e.length}return{text:s,offsetOf:e=>{let t=0,n=i.length;for(;t<n;){let r=t+n>>1;i[r]<e?t=r+1:n=r}return e+(t===0?0:a[t-1])}}}function xl(e){return e.toString(16).padStart(2,`0`)}function Sl(e){return Number.isInteger(e)&&e>=0&&e<=255}function Cl(e,t){if(!Sl(t))throw RangeError(`ColorRgba.${e} must be an integer in [0, 255]; got ${t}`)}var B=class e{red;green;blue;alpha;constructor(e,t,n,r=1){if(this.red=e,this.green=t,this.blue=n,this.alpha=r,Cl(`red`,e),Cl(`green`,t),Cl(`blue`,n),!Number.isFinite(r)||r<0||r>1)throw RangeError(`ColorRgba.alpha must be a finite number in [0, 1]; got ${r}`)}get hex(){let e=`#`+xl(this.red)+xl(this.green)+xl(this.blue);return this.alpha===1?e:e+xl(Math.round(this.alpha*255))}get rgb(){return this.alpha===1?`rgb(${this.red},${this.green},${this.blue})`:`rgba(${this.red},${this.green},${this.blue},${this.alpha})`}get normalized(){return[this.red/255,this.green/255,this.blue/255,this.alpha]}compositeOver(t){if(this.alpha===1)return this;let n=this.alpha;return new e(Math.round(t.red+(this.red-t.red)*n),Math.round(t.green+(this.green-t.green)*n),Math.round(t.blue+(this.blue-t.blue)*n),1)}};const wl=new B(0,0,0);function Tl(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.red)+.7152*t(e.green)+.0722*t(e.blue)}function El(e,t){return Dl(Tl(e),Tl(t))}function Dl(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function Ol(e,t){let n=e.red-t.red,r=e.green-t.green,i=e.blue-t.blue;return n*n+r*r+i*i}var kl=class{colors;luminances;firstIndex;matchMemo=new el;readableMemo=new el;constructor(e,t=0){this.colors=e,this.luminances=e.map(Tl),this.firstIndex=t}get(e){return this.colors[e-this.firstIndex]}get size(){return this.colors.length}match(e){let t=`${e.red},${e.green},${e.blue},${e.alpha}`;return this.matchMemo.get(t,()=>this.nearest(e))}nearest(e){let t=0,n=1/0;for(let r=0;r<this.colors.length;r++){let i=this.colors[r],a=Ol(i,e);a<n&&(n=a,t=r)}return this.firstIndex+t}matchReadable(e,t,n){let r=`${e.red},${e.green},${e.blue}|${t.red},${t.green},${t.blue}|${n}`;return this.readableMemo.get(r,()=>this.nearestReadable(e,t,n))}nearestReadable(e,t,n){let r=Tl(t),i=0,a=!1,o=-1/0;for(let t=0;t<this.colors.length;t++){let s=this.colors[t],c=this.luminances[t],l=Dl(c,r),u=l>=n,d=u?-Ol(s,e):l;(u&&!a||u===a&&d>o)&&(i=t,a=u,o=d)}return this.firstIndex+i}matchWhere(e,t){let n=this.colors.map(t=>Ol(t,e)),r=[...n.keys()].sort((e,t)=>n[e]-n[t]).find(e=>t(this.colors[e],this.firstIndex+e));return r===void 0?void 0:this.firstIndex+r}},V;(function(e){e[e.DEFAULT=0]=`DEFAULT`,e[e.STANDARD=1]=`STANDARD`,e[e.EIGHT_BIT=2]=`EIGHT_BIT`,e[e.TRUECOLOR=3]=`TRUECOLOR`,e[e.WINDOWS=4]=`WINDOWS`})(V||={});function Al(e){switch(e){case V.DEFAULT:return 0;case V.STANDARD:case V.WINDOWS:return 1;case V.EIGHT_BIT:return 2;case V.TRUECOLOR:return 3}}const jl={truecolor:V.TRUECOLOR,256:V.EIGHT_BIT,ansi:V.STANDARD,none:null},Ml=new Map([[`0`,null],[`false`,null],[`1`,V.STANDARD],[`true`,V.STANDARD],[`2`,V.EIGHT_BIT],[`3`,V.TRUECOLOR],[`iTerm.app`,V.TRUECOLOR],[`Apple_Terminal`,V.EIGHT_BIT],[`vscode`,V.TRUECOLOR],[`Tabby`,V.TRUECOLOR],[`xterm-kitty`,V.TRUECOLOR],[`xterm-ghostty`,V.TRUECOLOR],[`wezterm`,V.TRUECOLOR],[`alacritty`,V.TRUECOLOR],[`foot`,V.TRUECOLOR],[`contour`,V.TRUECOLOR]]);function Nl(e={}){let t=Fl(e).NO_COLOR;if(t!==void 0&&t!==``)return null;let n=Pl(Fl(e));return n===void 0?Ll(e):n}function Pl(e){let t=e.FORCE_COLOR;if(t===void 0||t===``)return;let n=Ml.get(t);return n===void 0?V.STANDARD:n}function Fl(e){return e.env??(typeof process<`u`?process.env:{})}function Il(e){let t=e.TERM;return t===`dumb`||t===`unknown`}function Ll(e){let t=Fl(e);if(!(e.isTTY??(typeof process<`u`?process.stdout?.isTTY??!1:!1))||Il(t))return null;let n=t.TERM??``,r=t.COLORTERM;if(r===`truecolor`||r===`24bit`)return V.TRUECOLOR;let i=Ml.get(n);if(i!==void 0)return i;let a=t.TERM_PROGRAM;if(a!==void 0){let e=Ml.get(a);if(e!==void 0)return e}return/-256(color)?$/i.test(n)?V.EIGHT_BIT:/-truecolor$/i.test(n)?V.TRUECOLOR:(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n),V.STANDARD)}function Rl(e,t={}){let n=t.reducedMotion??!1;return e===`auto`?{colorSystem:Nl(t),hyperlinks:(Pl(Fl(t))??null)!==null||Ll(t)!==null,reducedMotion:n}:{colorSystem:typeof e==`string`?zl(e):e,hyperlinks:!0,reducedMotion:n}}function zl(e,t){if(e===`auto`)return Nl(t);if(Object.hasOwn(jl,e))return jl[e];throw new Bl(`Unknown color system name: ${JSON.stringify(e)} (expected "auto", "truecolor", "256", "ansi", or "none")`)}var Bl=class extends Error{constructor(e){super(e),this.name=`ColorParseError`}};const Vl=new el;var H=class e{name;type;number;value;downgrades=new el;constructor(e,t,n,r){this.name=e,this.type=t,this.number=n,this.value=r}get isDefault(){return this.type===V.DEFAULT}get fixedValue(){switch(this.type){case V.TRUECOLOR:return this.value;case V.EIGHT_BIT:return this.number<16?void 0:fu.get(this.number);case V.DEFAULT:case V.STANDARD:case V.WINDOWS:return}}get isSystemDefined(){return this.type===V.STANDARD||this.type===V.WINDOWS}getAnsiCodes(e=!0){switch(this.type){case V.DEFAULT:return[e?`39`:`49`];case V.STANDARD:{let t=this.number;return e?t<8?[`${30+t}`]:[`${90+t-8}`]:t<8?[`${40+t}`]:[`${100+t-8}`]}case V.EIGHT_BIT:return[e?`38`:`48`,`5`,`${this.number}`];case V.TRUECOLOR:{let t=this.value;return[e?`38`:`48`,`2`,`${t.red}`,`${t.green}`,`${t.blue}`]}case V.WINDOWS:{let t=this.number;return e?t<8?[`${30+t}`]:[`${90+t-8}`]:t<8?[`${40+t}`]:[`${100+t-8}`]}}}flattenAlpha(t){if(this.type!==V.TRUECOLOR||!this.value)return this;let n=this.value.compositeOver(t);return n===this.value?this:e.fromRgba(n)}downgrade(e){return this.type===V.DEFAULT||this.type===e||Al(this.type)<Al(e)?this:this.downgrades.get(`${e}`,()=>this.performDowngrade(e))}getTruecolor(e,t=!0){switch(this.type){case V.TRUECOLOR:return this.value;case V.EIGHT_BIT:return this.number<16?_u(e,this.type).ansiColors.get(this.number):fu.get(this.number);case V.STANDARD:case V.WINDOWS:return _u(e,this.type).ansiColors.get(this.number);case V.DEFAULT:{let n=_u(e,this.type);return t?n.foregroundColor:n.backgroundColor}}}static default(){return new e(`default`,V.DEFAULT)}static fromAnsi(t){let n=t<16?V.STANDARD:V.EIGHT_BIT;return new e(`color(${t})`,n,t)}static fromRgba(t){return new e(t.hex,V.TRUECOLOR,void 0,t)}static fromRgb(t,n,r){return e.fromRgba(new B(t,n,r))}static blend(t,n,r){for(let e of[t,n]){if(e.isDefault)throw new Bl(`A blend cannot mix "default", which is no colour`);if(e.value!==void 0&&e.value.alpha<1)throw new Bl(`A blend's ends are opaque; "${e.name}" is translucent`)}if(!(r>=0&&r<=1))throw new Bl(`A blend's fraction is in [0, 1]; got ${r}`);let i=t.fixedValue,a=n.fixedValue;return i!==void 0&&a!==void 0?e.fromRgba(au(i,a,r)):r===0?t:r===1?n:t.type===n.type&&(t.number===void 0?t.name===n.name:t.number===n.number)?t:new ql(t,n,r)}static matchOn(t,n,r,i){if(t.alpha<1)throw RangeError(`matchOn rounds an opaque colour; got alpha ${t.alpha}`);if(n===V.TRUECOLOR)return e.fromRgba(t);if(n===V.DEFAULT)return e.default();let a=r.ansiColors.match(t);return[[e.default(),i?r.foregroundColor:r.backgroundColor],[new e(`color(${a})`,n===V.WINDOWS?n:V.STANDARD,a),r.ansiColors.get(a)],...n===V.EIGHT_BIT?[Hl(t)]:[]].reduce((e,n)=>Ol(n[1],t)<Ol(e[1],t)?n:e)[0]}static indexed(e,t){return Ul.get(t,()=>new el).get(`${e}`,()=>Wl(e,t))}static matchMove(t,n,r,i,a){let o=e.matchOn(n,r,i,a);return Ol(t,n)<=Ol(o.getTruecolor(i,a),n)?void 0:o}static parse(e){return Vl.get(e.toLowerCase().trim(),Ql)}performDowngrade(t){let n=this.getTruecolor(_u(void 0,t));switch(t){case V.EIGHT_BIT:return e.fromAnsi(vu(t).match(n));case V.STANDARD:case V.WINDOWS:{let r=this.number!==void 0&&this.number<16?this.number:vu(t).match(n);return new e(`color(${r})`,t,r)}case V.TRUECOLOR:return this;case V.DEFAULT:return e.default()}}};function Hl(e){let t=pu.match(e);return[H.fromAnsi(t),pu.get(t)]}const Ul=new tl;function Wl(e,t){let n=()=>Array.from({length:16},(n,r)=>[new H(`color(${r})`,e===V.WINDOWS?e:V.STANDARD,r),t.ansiColors.get(r)]);switch(e){case V.TRUECOLOR:case V.DEFAULT:return[];case V.STANDARD:case V.WINDOWS:return n();case V.EIGHT_BIT:{let{firstIndex:e,size:t}=pu;return[...n(),...Array.from({length:t},(t,n)=>[H.fromAnsi(e+n),pu.get(e+n)])]}}}function Gl(e,t,n,r){return au(e.getTruecolor(r),t.getTruecolor(r),n)}function Kl(e){return e.fixedValue?.hex??(e.number===void 0?e.name:`color(${e.number})`)}var ql=class extends H{from;to;t;constructor(e,t,n){super(`blend(${Kl(e)},${Kl(t)},${n})`,V.TRUECOLOR,void 0,Gl(e,t,n)),this.from=e,this.to=t,this.t=n}get fixedValue(){}getTruecolor(e){return Gl(this.from,this.to,this.t,e)}};const Jl=nl(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/),Yl=nl(/^color\((\d+)\)$/),Xl=nl(/^blend\((.*)\)$/),Zl=nl(/^\s*(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?\s*$/);function Ql(e){if(e===`default`||e===``)return H.default();let t=bu[e];if(t!==void 0)return new H(e,t<16?V.STANDARD:V.EIGHT_BIT,t);if(e.startsWith(`#`))return new H(e,V.TRUECOLOR,void 0,iu(e));let n=Jl.exec(e);if(n){let t=eu(e,n[1],`red`),r=eu(e,n[2],`green`),i=eu(e,n[3],`blue`);return new H(e,V.TRUECOLOR,void 0,new B(t,r,i))}let r=Yl.exec(e);if(r){let t=eu(e,r[1],`number`);return new H(e,t<16?V.STANDARD:V.EIGHT_BIT,t)}let i=Xl.exec(e);if(i){let t=$l(i[1]),n=t[2]??``;if(t.length!==3||!Zl.test(n))throw new Bl(`ColorSpec "${e}": a blend is blend(<color>,<color>,<fraction>)`);return H.blend(H.parse(t[0]),H.parse(t[1]),Number(n))}throw new Bl(`Failed to parse color: "${e}"`)}function $l(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`(`?n++:a===`)`?n--:a===`,`&&n===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function eu(e,t,n){let r=parseInt(t,10);if(!Sl(r))throw new Bl(`ColorSpec "${e}": ${n} ${t} is out of range (0-255)`);return r}const tu=nl(/^[0-9a-fA-F]+$/),nu={6:`RRGGBB`,8:`RRGGBBAA`};function ru(e,t,n,r){if(!r.includes(n.length)||!tu.test(n)){let n=r.map(e=>t+nu[e]).join(` or `);throw new Bl(`Invalid hex colour ${JSON.stringify(e)} (expected ${n})`)}let i=e=>parseInt(n.slice(e,e+2),16);return new B(i(0),i(2),i(4),n.length===8?i(6)/255:1)}function iu(e){return ru(e,`#`,e.startsWith(`#`)?e.slice(1):``,[6,8])}function au(e,t,n=.5){return new B(Math.round(e.red+(t.red-e.red)*n),Math.round(e.green+(t.green-e.green)*n),Math.round(e.blue+(t.blue-e.blue)*n),e.alpha+(t.alpha-e.alpha)*n)}var ou=class{backgroundColor;foregroundColor;ansiColors;constructor(e,t,n){if(this.backgroundColor=e,this.foregroundColor=t,this.ansiColors=n,n.firstIndex!==0||n.size!==16)throw RangeError(`a TerminalTheme's ansiColors are the sixteen ANSI colours, indices 0–15; got ${n.size} from index ${n.firstIndex}`)}},su=class extends ou{palette;constructor(e,t,n,r){super(e,t,n),this.palette=r}};function cu(){return[new B(0,0,0),new B(128,0,0),new B(0,128,0),new B(128,128,0),new B(0,0,128),new B(128,0,128),new B(0,128,128),new B(192,192,192),new B(128,128,128),new B(255,0,0),new B(0,255,0),new B(255,255,0),new B(0,0,255),new B(255,0,255),new B(0,255,255),new B(255,255,255)]}function lu(){let e=cu(),t=[0,95,135,175,215,255];for(let n=0;n<6;n++)for(let r=0;r<6;r++)for(let i=0;i<6;i++)e.push(new B(t[n],t[r],t[i]));for(let t=0;t<24;t++){let n=8+10*t;e.push(new B(n,n,n))}return e}function uu(){return[new B(12,12,12),new B(197,15,31),new B(19,161,14),new B(193,156,0),new B(0,55,218),new B(136,23,152),new B(58,150,221),new B(204,204,204),new B(118,118,118),new B(231,72,86),new B(22,198,12),new B(249,241,165),new B(59,120,255),new B(180,0,158),new B(97,214,214),new B(242,242,242)]}const du=new kl(cu()),fu=new kl(lu()),pu=new kl(lu().slice(16),16),mu=new kl(uu()),hu=new ou(new B(0,0,0),new B(255,255,255),du),gu=new ou(mu.get(0),mu.get(7),mu);function _u(e,t){return e??(t===V.WINDOWS?gu:hu)}function vu(e){switch(e){case V.EIGHT_BIT:return pu;case V.STANDARD:return du;case V.WINDOWS:return mu}}function yu(e){let t=Object.entries(e).filter(([e])=>e.includes(`grey`)).map(([e,t])=>[e.replace(`grey`,`gray`),t]);return{...e,...Object.fromEntries(t)}}const bu=yu({black:0,red:1,green:2,yellow:3,blue:4,magenta:5,cyan:6,white:7,bright_black:8,bright_red:9,bright_green:10,bright_yellow:11,bright_blue:12,bright_magenta:13,bright_cyan:14,bright_white:15,grey0:16,navy_blue:17,dark_blue:18,blue3:19,blue2:20,blue1:21,dark_green:22,deep_sky_blue4:23,deep_sky_blue5:24,deep_sky_blue6:25,dodger_blue3:26,dodger_blue2:27,green4:28,spring_green4:29,turquoise4:30,deep_sky_blue3:31,deep_sky_blue7:32,dodger_blue1:33,green3:34,spring_green3:35,dark_cyan:36,light_sea_green:37,deep_sky_blue2:38,deep_sky_blue1:39,green5:40,spring_green5:41,spring_green2:42,cyan3:43,dark_turquoise:44,turquoise2:45,green1:46,spring_green6:47,spring_green1:48,medium_spring_green:49,cyan2:50,cyan1:51,dark_red:52,deep_pink4:53,purple4:54,purple5:55,purple3:56,blue_violet:57,orange4:58,grey37:59,medium_purple4:60,slate_blue3:61,slate_blue4:62,royal_blue1:63,chartreuse4:64,dark_sea_green4:65,pale_turquoise4:66,steel_blue:67,steel_blue3:68,cornflower_blue:69,chartreuse3:70,dark_sea_green5:71,cadet_blue:72,cadet_blue2:73,sky_blue3:74,steel_blue1:75,chartreuse5:76,pale_green3:77,sea_green3:78,aquamarine3:79,medium_turquoise:80,steel_blue2:81,chartreuse2:82,sea_green2:83,sea_green1:84,sea_green4:85,aquamarine1:86,dark_slate_gray2:87,dark_red2:88,deep_pink5:89,dark_magenta:90,dark_magenta2:91,dark_violet:92,purple2:93,orange5:94,light_pink4:95,plum4:96,medium_purple3:97,medium_purple5:98,slate_blue1:99,yellow4:100,wheat4:101,grey53:102,light_slate_grey:103,medium_purple:104,light_slate_blue:105,yellow5:106,dark_olive_green3:107,dark_sea_green:108,light_sky_blue3:109,light_sky_blue4:110,sky_blue2:111,chartreuse6:112,dark_olive_green4:113,pale_green4:114,dark_sea_green3:115,dark_slate_gray3:116,sky_blue1:117,chartreuse1:118,light_green:119,light_green2:120,pale_green1:121,aquamarine2:122,dark_slate_gray1:123,red3:124,deep_pink6:125,medium_violet_red:126,magenta3:127,dark_violet2:128,purple:129,dark_orange3:130,indian_red:131,hot_pink3:132,medium_orchid3:133,medium_orchid:134,medium_purple2:135,dark_goldenrod:136,light_salmon3:137,rosy_brown:138,grey63:139,medium_purple6:140,medium_purple1:141,gold3:142,dark_khaki:143,navajo_white3:144,grey69:145,light_steel_blue3:146,light_steel_blue:147,yellow3:148,dark_olive_green5:149,dark_sea_green6:150,dark_sea_green2:151,light_cyan3:152,light_sky_blue1:153,green_yellow:154,dark_olive_green2:155,pale_green2:156,dark_sea_green7:157,dark_sea_green1:158,pale_turquoise1:159,red4:160,deep_pink3:161,deep_pink8:162,magenta4:163,magenta5:164,magenta2:165,dark_orange4:166,indian_red2:167,hot_pink4:168,hot_pink2:169,orchid:170,medium_orchid1:171,orange3:172,light_salmon4:173,light_pink3:174,pink3:175,plum3:176,violet:177,gold4:178,light_goldenrod3:179,tan:180,misty_rose3:181,thistle3:182,plum2:183,yellow6:184,khaki3:185,light_goldenrod2:186,light_yellow3:187,grey84:188,light_steel_blue1:189,yellow2:190,dark_olive_green1:191,dark_olive_green6:192,dark_sea_green8:193,honeydew2:194,light_cyan1:195,red1:196,deep_pink2:197,deep_pink1:198,deep_pink9:199,magenta6:200,magenta1:201,orange_red1:202,indian_red1:203,indian_red3:204,hot_pink5:205,hot_pink:206,medium_orchid2:207,dark_orange:208,salmon1:209,light_coral:210,pale_violet_red1:211,orchid2:212,orchid1:213,orange1:214,sandy_brown:215,light_salmon1:216,light_pink1:217,pink1:218,plum1:219,gold1:220,light_goldenrod4:221,light_goldenrod5:222,navajo_white1:223,misty_rose1:224,thistle1:225,yellow1:226,light_goldenrod1:227,khaki1:228,wheat1:229,cornsilk1:230,grey100:231,grey3:232,grey7:233,grey11:234,grey15:235,grey19:236,grey23:237,grey27:238,grey30:239,grey35:240,grey39:241,grey42:242,grey46:243,grey50:244,grey54:245,grey58:246,grey62:247,grey66:248,grey70:249,grey74:250,grey78:251,grey82:252,grey85:253,grey89:254,grey93:255}),xu=[`default`,...Object.keys(bu)];var Su;const Cu=[`l`,`c`,`h`,`alpha`],wu=Object.freeze({hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:0});Object.freeze({hueShift:0,chromaScale:1,lightnessScale:-1,lightnessShift:1});function Tu(e){return e.hueShift%360==0&&e.chromaScale===1&&e.lightnessScale===1&&e.lightnessShift===0}function Eu(e){return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Du(e){return e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055}function Ou(e){return e<0?0:e>1?1:e}const ku=1e-4,Au=1e-7,ju=(e,t)=>e<Au?0:t,Mu=(e,t,n)=>e*(1-n)+t*n,Nu=e=>{let t=e%360;return t<0?t+360:t};function Pu(e,t,n){return e>=-ku&&e<=1+ku&&t>=-ku&&t<=1+ku&&n>=-ku&&n<=1+ku}function Fu(e,t){let n=Math.PI/180*t;return[e*Math.cos(n),e*Math.sin(n)]}var Iu=class{l;c;h;alpha;constructor(e,t,n,r=1){if(this.l=e,this.c=t,this.h=n,this.alpha=r,!Number.isFinite(e))throw RangeError(`Oklch.l must be finite; got ${e}`);if(!Number.isFinite(t))throw RangeError(`Oklch.c must be finite; got ${t}`);if(!Number.isFinite(n))throw RangeError(`Oklch.h must be finite; got ${n}`);if(!Number.isFinite(r)||r<0||r>1)throw RangeError(`Oklch.alpha must be a finite number in [0,1]; got ${r}`);this.#t=Fu(t,n)}static fromRgba(e){let[t,n,r,i]=e.normalized,a=Eu(t),o=Eu(n),s=Eu(r),c=.4122214708*a+.5363325363*o+.0514459929*s,l=.2119034982*a+.6806995451*o+.1073969566*s,u=.0883024619*a+.2817188376*o+.6299787005*s,d=Math.cbrt(c),f=Math.cbrt(l),p=Math.cbrt(u),m=.2104542553*d+.793617785*f-.0040720468*p,h=1.9779984951*d-2.428592205*f+.4505937099*p,g=.0259040371*d+.7827717662*f-.808675766*p,_=Math.sqrt(h*h+g*g),v=Nu(180/Math.PI*Math.atan2(g,h));return new Su(m,_,ju(_,v),i)}toRgba(){let e=Ou(this.l),t=Math.max(0,this.c),n=this.findInGamutChroma(e,t,this.h),{r,g:i,b:a}=this.toLinearRgb(e,n,this.h);return new B(Math.round(Ou(Du(r))*255),Math.round(Ou(Du(i))*255),Math.round(Ou(Du(a))*255),this.alpha)}applyKey(e){if(Tu(e))return this;let t=Ou(this.l*e.lightnessScale+e.lightnessShift),n=Math.max(0,this.c*e.chromaScale),r=Nu(this.h+e.hueShift);return new Su(t,n,ju(n,r),this.alpha)}mix(e,t){if(!(t>=0&&t<=1))throw RangeError(`Oklch.mix: t must be in [0, 1]; got ${t}`);return this.#e(e,t,t,t,t)}mixAxes(e,t){for(let e of Cu){let n=t[e];if(!(n>=0&&n<=1))throw RangeError(`Oklch.mixAxes: ${e} weight must be in [0, 1]; got ${n}`)}return this.#e(e,t.l,t.c,t.h,t.alpha)}#e(e,t,n,r,i){let a=this.c>=Au,o=e.c>=Au,s=Nu(a?this.h:o?e.h:0),c=Nu(o?e.h:s),l=c-s,u=l<-180?s-360:s,d=l>180?c-360:c,f=Mu(this.c,e.c,n);return new Su(Mu(this.l,e.l,t),f,ju(f,Nu(Mu(u,d,r))),Mu(this.alpha,e.alpha,i))}deltaE(e){let[t,n]=this.#t,[r,i]=e.#t;return Math.hypot(this.l-e.l,t-r,n-i)}#t;toLinearRgb(e,t,n){let[r,i]=Fu(t,n),a=e+.3963377774*r+.2158037573*i,o=e-.1055613458*r-.0638541728*i,s=e-.0894841775*r-1.291485548*i,c=a*a*a,l=o*o*o,u=s*s*s;return{r:4.0767416621*c-3.3077115913*l+.2309699292*u,g:-1.2684380046*c+2.6097574011*l-.3413193965*u,b:-.0041960863*c-.7034186147*l+1.707614701*u}}findInGamutChroma(e,t,n){let r=this.toLinearRgb(e,t,n);if(Pu(r.r,r.g,r.b))return t;let i=0,a=t;for(let t=0;t<24;t++){let t=(i+a)/2,r=this.toLinearRgb(e,t,n);Pu(r.r,r.g,r.b)?i=t:a=t}return i}};Su=Iu;var Lu=class{name;dark;vars;constructor(e,t,n){this.name=e,this.dark=t;let r=Ru(e,n.background);this.vars=new Map(Object.entries(n).map(([e,t])=>[e,r(t)]))}get(e){return this.vars.get(e)}mapRoles(e){return Object.fromEntries([...this.vars].map(([t,n])=>[t,e(n,t)]))}};function Ru(e,t){if(t.alpha!==1)throw RangeError(`palette ${JSON.stringify(e)}: background is the surface its translucent colours are drawn on, so it must be opaque; got ${t.hex}`);return e=>e.alpha===0?e:e.compositeOver(t)}var zu=class extends Error{ref;constructor(e,t,n){super(`color reference ${JSON.stringify(e)} did not resolve — ${t}`,n),this.ref=e,this.name=`ColorRefError`}};function Bu(e,t){let n=t.trim();if(n.startsWith(`#`))try{return iu(n)}catch(e){throw e instanceof Bl?new zu(t,e.message,{cause:e}):e}let r=e.get(n);if(r===void 0)throw new zu(t,`no such variable in palette ${JSON.stringify(e.name)}`+Vu(e,n));return r}function Vu(e,t){let n=t.split(`-`),r=[...e.vars.keys()].filter(e=>n.some(t=>t!==``&&e.includes(t))).slice(0,8);return r.length===0?``:`; did you mean: ${r.join(`, `)}`}function Hu(e){let t=e.red/255,n=e.green/255,r=e.blue/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s=i-a;if(s===0)return{h:0,s:0,l:o};let c=s/(o>.5?2-i-a:i+a),l;return l=i===t?(n-r)/s%6:i===n?(r-t)/s+2:(t-n)/s+4,l=(l*60+360)%360,{h:l,s:c,l:o}}function Uu(e){let t=Math.round(e);return t<0?0:t>255?255:t}function Wu(e){let{h:t,s:n,l:r}=e;if(n===0){let e=Uu(r*255);return new B(e,e,e)}let i=(1-Math.abs(2*r-1))*n,a=t/60,o=i*(1-Math.abs(a%2-1)),s=0,c=0,l=0;a<1?[s,c,l]=[i,o,0]:a<2?[s,c,l]=[o,i,0]:a<3?[s,c,l]=[0,i,o]:a<4?[s,c,l]=[0,o,i]:a<5?[s,c,l]=[o,0,i]:[s,c,l]=[i,0,o];let u=r-i/2;return new B(Uu((s+u)*255),Uu((c+u)*255),Uu((l+u)*255))}function Gu(e){return e<0?0:e>1?1:e}function Ku(e,t){let n=Hu(e);return n.l=Gu(n.l-.1*t),Wu(n)}function qu(e){let[t,n,r]=[e.red,e.green,e.blue].map(e=>Eu(e/255)),[i,a,o]=[(t*41.24+n*35.76+r*18.05)/95.047,(t*21.26+n*71.52+r*7.22)/100,(t*1.93+n*11.92+r*95.05)/108.883].map(e=>e>.008856?Math.cbrt(e):7.787*e+16/116);return[116*a-16,500*(i-a),200*(a-o)]}function Ju(e,t,n,r){let i=e=>e>.2068930344?e**3:(e-16/116)/7.787,a=(e+16)/116,o=i(a),s=.95047*i(t/500+a),c=1.08883*i(a-n/200),[l,u,d]=[s*3.2406+o*-1.5372+c*-.4986,s*-.9689+o*1.8758+c*.0415,s*.0557+o*-.204+c*1.057].map(e=>Uu(255*Du(e)));return new B(l,u,d,r)}function Yu(e,t){let[n,r,i]=qu(e);return Ju(n+t*100,r,i,e.alpha)}function Xu(e,t,n){return au(t,e,Gu(n))}function Zu(e,t=wl){return Tl(nd(e,t))>.179?new B(0,0,0):new B(255,255,255)}function Qu(e,t,n=4.5,r=V.TRUECOLOR,i=wl,a){let o=nd(t,i),s=id(e,o,n,Zu(o)),c=rd(r,a);if(c===void 0)return s;let l=td(c,o);return El(td(c,s),l)>=n?s:c.written.get(c.shown.matchReadable(e.compositeOver(o),l,n))}function $u(e,t,n,r=wl,i){let a=nd(e,r),o=rd(t,i),s=e=>td(o,nd(e,r));if(n(s(a),s))return a;let c=o?.shown.matchWhere(a,e=>n(e,s));return c===void 0?void 0:o.written.get(c)}function ed(e,t,n=wl,r){return td(rd(t,r),nd(e,n))}function td(e,t){return e===void 0?t:H.fromRgba(t).downgrade(e.depth).getTruecolor(e.terminal)}function nd(e,t){if(t.alpha!==1)throw RangeError(`a contrast substrate is the opaque surface under a translucent background; got ${t.hex}`);return e.compositeOver(t)}function rd(e,t){let n=_u(t,e);switch(e){case V.EIGHT_BIT:return{depth:e,terminal:n,written:vu(e),shown:vu(e)};case V.STANDARD:case V.WINDOWS:return{depth:e,terminal:n,written:vu(e),shown:n.ansiColors};case V.TRUECOLOR:case V.DEFAULT:return}}function id(e,t,n,r){let i=e.compositeOver(t);if(El(i,t)>=n)return i;let a=Iu.fromRgba(i),o=+(Tl(r)>.179);if(El(new Iu(o,a.c,a.h,a.alpha).toRgba(),t)<n)return Zu(t);let s=a.l,c=o;for(let e=0;e<20;e++){let e=(s+c)/2;El(new Iu(e,a.c,a.h,a.alpha).toRgba(),t)>=n?c=e:s=e}return new Iu(c,a.c,a.h,a.alpha).toRgba()}const ad=.7,od=.38,sd=[`primary`,`secondary`,`accent`,`success`,`warning`,`error`],cd=new B(0,0,0,0),ld=new B(255,255,255),ud=(e,t)=>new B(e.red,e.green,e.blue,t),dd=e=>t=>ud(Zu(t(`background`)),e),fd=e=>t=>t(e),pd=()=>cd;function md(e,t){let n=[`darken`,`lighten`].flatMap(n=>[1,2,3].map(r=>[`${e}-${n}-${r}`,t((n===`darken`?-r:r)*.075)]));return Object.fromEntries(n)}const hd=e=>md(e,t=>n=>Yu(n(e),t)),gd=(e,t)=>(n,r)=>r?au(au(n(`background`),n(e),.15),ld,Math.max(0,.15+t)):Yu(n(e),t);function _d(e){return{...hd(e),[`${e}-muted`]:(t=>au(t(e),t(`background`),ad)),[`on-${e}`]:(t=>Zu(t(e))),[`text-${e}`]:(t=>Xu(t(e),Zu(t(`background`)),.66))}}const vd={..._d(`primary`),..._d(`secondary`),..._d(`accent`),..._d(`success`),..._d(`warning`),..._d(`error`),...hd(`background`),...hd(`foreground`),...hd(`panel`),...hd(`boost`),...hd(`surface`),...md(`primary-background`,e=>gd(`primary`,e)),...md(`secondary-background`,e=>gd(`secondary`,e)),"background-muted":e=>au(e(`background`),e(`foreground`),ad),"foreground-muted":e=>au(e(`foreground`),e(`background`),ad),"foreground-disabled":e=>ud(e(`foreground`),od),surface:e=>au(e(`background`),e(`foreground`),.05),"surface-active":e=>Yu(e(`surface`),.06),boost:dd(.04),panel:(e,t)=>{let n=au(e(`surface`),e(`primary`),.1);return t?e(`boost`).compositeOver(n):n},"primary-background":gd(`primary`,0),"secondary-background":gd(`secondary`,0),text:dd(.87),"text-muted":dd(.6),"text-disabled":dd(od),border:fd(`primary`),"border-blurred":e=>Yu(e(`surface`),-.025),"block-cursor-background":fd(`primary`),"block-cursor-foreground":fd(`on-primary`),"block-cursor-blurred-background":e=>ud(e(`primary`),.3),"block-cursor-blurred-foreground":fd(`foreground`),"block-hover-background":e=>ud(e(`boost`),.1),"button-foreground":fd(`foreground`),"button-color-foreground":fd(`on-primary`),"footer-background":fd(`panel`),"footer-foreground":fd(`foreground`),"footer-description-background":pd,"footer-description-foreground":fd(`foreground`),"footer-item-background":pd,"footer-key-background":pd,"footer-key-foreground":fd(`accent`),"input-cursor-background":fd(`foreground`),"input-cursor-foreground":fd(`background`),"input-selection-background":e=>ud(e(`primary-lighten-1`),.4),"link-background":pd,"link-background-hover":fd(`primary`),"link-color":fd(`text`),"link-color-hover":fd(`on-primary`),"markdown-h1-background":pd,"markdown-h1-color":fd(`primary`),"markdown-h2-background":pd,"markdown-h2-color":fd(`primary`),"markdown-h3-background":pd,"markdown-h3-color":fd(`primary`),"markdown-h4-background":pd,"markdown-h4-color":fd(`foreground`),"markdown-h5-background":pd,"markdown-h5-color":fd(`foreground`),"markdown-h6-background":pd,"markdown-h6-color":fd(`text-muted`),scrollbar:e=>Xu(e(`primary`),e(`background-darken-1`),.4),"scrollbar-active":fd(`primary`),"scrollbar-hover":e=>Xu(e(`primary`),e(`background-darken-1`),.5),"scrollbar-background":fd(`background-darken-1`),"scrollbar-background-active":fd(`scrollbar-background`),"scrollbar-background-hover":fd(`scrollbar-background`),"scrollbar-corner-color":fd(`scrollbar-background`)},yd=[...sd,`background`,`foreground`],bd=[...yd,...Object.keys(vd)],xd=new Set(bd);function Sd(e,t,n){let r=Cd(e,n),i=e=>{let n=r.get(e)??vd[e](i,t);return r.set(e,n),n};for(let e of sd){let t=i(`${e}-muted`).compositeOver(i(`background`));r.set(`text-${e}`,wd(n[`text-${e}`]??i(`text-${e}`),t,i(`background`)))}return new Lu(e,t,Object.fromEntries(bd.map(e=>[e,i(e)])))}function Cd(e,t){let n=Ru(e,t.background),r=Object.entries(t).flatMap(([t,r])=>{if(!xd.has(t))throw RangeError(`palette ${JSON.stringify(e)}: ${JSON.stringify(t)} is not a role`);return r===void 0?[]:[[t,t===`boost`?r:n(r)]]}),i=new Map(r);for(let r of yd){let a=t[r];if(a.alpha===0)throw RangeError(`palette ${JSON.stringify(e)}: ${r} is fully transparent (${a.hex}), so there is no colour to derive the palette from`);i.set(r,n(a))}return i}function wd(e,t,n){return id(e,t,4.5,Zu(n))}const Td={name:`atom-one-dark`,dark:!0,ansi:{black:`#282C34`,red:`#E06C75`,green:`#98C379`,yellow:`#E5C07B`,blue:`#61AFEF`,magenta:`#C678DD`,cyan:`#56B6C2`,white:`#DCDFE4`,brightBlack:`#5D677A`,brightRed:`#E06C75`,brightGreen:`#98C379`,brightYellow:`#E5C07B`,brightBlue:`#61AFEF`,brightMagenta:`#C678DD`,brightCyan:`#56B6C2`,brightWhite:`#DCDFE4`},vars:{accent:`#A378C2`,"accent-darken-1":`#8E65AD`,"accent-darken-2":`#7A5299`,"accent-darken-3":`#674085`,"accent-lighten-1":`#B78BD6`,"accent-lighten-2":`#CC9FEC`,"accent-lighten-3":`#E2B3FF`,"accent-muted":`#4C425E`,background:`#282C34`,"background-darken-1":`#181C23`,"background-darken-2":`#050A14`,"background-darken-3":`#000000`,"background-lighten-1":`#383C44`,"background-lighten-2":`#494D56`,"background-lighten-3":`#5B5F68`,"block-cursor-background":`#61AFEF`,"block-cursor-blurred-background":`#61AFEF4C`,"block-cursor-blurred-foreground":`#ABB2BF`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#61AFEF`,"border-blurred":`#353B47`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#ABB2BF`,error:`#EF6262`,"error-darken-1":`#D84D50`,"error-darken-2":`#C1373E`,"error-darken-3":`#AA1F2E`,"error-lighten-1":`#FF7674`,"error-lighten-2":`#FF8B87`,"error-lighten-3":`#FFA09B`,"error-muted":`#643C41`,"footer-background":`#4F5666`,"footer-description-background":`#00000000`,"footer-description-foreground":`#ABB2BF`,"footer-foreground":`#ABB2BF`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#A378C2`,foreground:`#ABB2BF`,"foreground-darken-1":`#979DAA`,"foreground-darken-2":`#838A96`,"foreground-darken-3":`#707783`,"foreground-disabled":`#ABB2BF60`,"foreground-lighten-1":`#BFC6D3`,"foreground-lighten-2":`#D4DBE8`,"foreground-lighten-3":`#E9F0FE`,"foreground-muted":`#ABB2BF99`,"input-cursor-background":`#ABB2BF`,"input-cursor-foreground":`#282C34`,"input-selection-background":`#77C3FF66`,"link-background":`#00000000`,"link-background-hover":`#61AFEF`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#61AFEF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#61AFEF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#61AFEF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#ABB2BF`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#ABB2BF`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#ABB2BF99`,panel:`#4F5666`,"panel-darken-1":`#3D4453`,"panel-darken-2":`#2C3342`,"panel-darken-3":`#1C2331`,"panel-lighten-1":`#616878`,"panel-lighten-2":`#737A8B`,"panel-lighten-3":`#868E9F`,primary:`#61AFEF`,"primary-background":`#4F5B6A`,"primary-background-darken-1":`#3F4D5D`,"primary-background-darken-2":`#303F50`,"primary-background-darken-3":`#303F50`,"primary-background-lighten-1":`#5E6A77`,"primary-background-lighten-2":`#6E7884`,"primary-background-lighten-3":`#7D8791`,"primary-darken-1":`#489BD9`,"primary-darken-2":`#2C87C4`,"primary-darken-3":`#0074AF`,"primary-lighten-1":`#77C3FF`,"primary-lighten-2":`#8ED8FF`,"primary-lighten-3":`#A4EDFF`,"primary-muted":`#39536C`,scrollbar:`#355674`,"scrollbar-active":`#61AFEF`,"scrollbar-background":`#181C23`,"scrollbar-background-active":`#181C23`,"scrollbar-background-hover":`#181C23`,"scrollbar-corner-color":`#181C23`,"scrollbar-hover":`#3C6589`,secondary:`#C678DD`,"secondary-background":`#5B5567`,"secondary-background-darken-1":`#4D465A`,"secondary-background-darken-2":`#3F374D`,"secondary-background-darken-3":`#3F374D`,"secondary-background-lighten-1":`#6A6475`,"secondary-background-lighten-2":`#787382`,"secondary-background-lighten-3":`#87828F`,"secondary-darken-1":`#B064C7`,"secondary-darken-2":`#9B50B3`,"secondary-darken-3":`#873D9E`,"secondary-lighten-1":`#DB8CF2`,"secondary-lighten-2":`#F1A0FF`,"secondary-lighten-3":`#FFB5FF`,"secondary-muted":`#574266`,success:`#62F062`,"success-darken-1":`#48DA4D`,"success-darken-2":`#29C438`,"success-darken-3":`#00AF22`,"success-lighten-1":`#7AFF76`,"success-lighten-2":`#91FF8A`,"success-lighten-3":`#A8FF9F`,"success-muted":`#396641`,surface:`#3B414D`,"surface-active":`#484E5B`,"surface-darken-1":`#2A303B`,"surface-darken-2":`#1A202B`,"surface-darken-3":`#09101B`,"surface-lighten-1":`#4C525E`,"surface-lighten-2":`#5E6471`,"surface-lighten-3":`#707684`,text:`#FFFFFFDD`,"text-accent":`#C2A5D6`,"text-disabled":`#FFFFFF60`,"text-error":`#F59797`,"text-muted":`#FFFFFF99`,"text-primary":`#96CAF4`,"text-secondary":`#D9A5E8`,"text-success":`#97F597`,"text-warning":`#E9CC92`,warning:`#DDB25B`,"warning-darken-1":`#C79D47`,"warning-darken-2":`#B28A34`,"warning-darken-3":`#9C7721`,"warning-lighten-1":`#F4C66E`,"warning-lighten-2":`#FFDB82`,"warning-lighten-3":`#FFF096`,"warning-muted":`#5E543F`}},Ed={name:`atom-one-light`,dark:!1,ansi:{black:`#383A42`,red:`#E45649`,green:`#50A14F`,yellow:`#C18401`,blue:`#0184BC`,magenta:`#A626A4`,cyan:`#0997B3`,white:`#BABABA`,brightBlack:`#4F525E`,brightRed:`#E06C75`,brightGreen:`#98C379`,brightYellow:`#D8B36E`,brightBlue:`#61AFEF`,brightMagenta:`#C678DD`,brightCyan:`#56B6C2`,brightWhite:`#FFFFFF`},vars:{accent:`#BE9232`,"accent-darken-1":`#A97E1D`,"accent-darken-2":`#936B01`,"accent-darken-3":`#7E5900`,"accent-lighten-1":`#D5A545`,"accent-lighten-2":`#EBB959`,"accent-lighten-3":`#FFCE6C`,"accent-muted":`#E8DABE`,background:`#FAFAFA`,"background-darken-1":`#E4E4E4`,"background-darken-2":`#CFCFCF`,"background-darken-3":`#BABABA`,"background-lighten-1":`#FFFFFF`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#4078F2`,"block-cursor-blurred-background":`#4078F24C`,"block-cursor-blurred-foreground":`#383A42`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#4078F2`,"border-blurred":`#D8D8D8`,"button-color-foreground":`#000000DD`,"button-foreground":`#383A42`,error:`#F13F3F`,"error-darken-1":`#D9232D`,"error-darken-2":`#C1001D`,"error-darken-3":`#A9000D`,"error-lighten-1":`#FF5650`,"error-lighten-2":`#FF6C62`,"error-lighten-3":`#FF8275`,"error-muted":`#F7C1C1`,"footer-background":`#CCCCCC`,"footer-description-background":`#00000000`,"footer-description-foreground":`#383A42`,"footer-foreground":`#383A42`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#BF9232`,foreground:`#383A42`,"foreground-darken-1":`#272931`,"foreground-darken-2":`#181A21`,"foreground-darken-3":`#040612`,"foreground-disabled":`#383A4260`,"foreground-lighten-1":`#494B53`,"foreground-lighten-2":`#5A5C65`,"foreground-lighten-3":`#6D6F78`,"foreground-muted":`#383A4299`,"input-cursor-background":`#383A42`,"input-cursor-foreground":`#FAFAFA`,"input-selection-background":`#5C8AFF66`,"link-background":`#00000000`,"link-background-hover":`#4078F2`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#4078F2`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#4078F2`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#4078F2`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#383A42`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#383A42`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#383A4299`,panel:`#CCCCCC`,"panel-darken-1":`#B7B7B7`,"panel-darken-2":`#A3A3A3`,"panel-darken-3":`#8F8F8F`,"panel-lighten-1":`#E1E1E1`,"panel-lighten-2":`#F6F6F6`,"panel-lighten-3":`#FFFFFF`,primary:`#4078F2`,"primary-background":`#4078F2`,"primary-background-darken-1":`#1865DC`,"primary-background-darken-2":`#0053C6`,"primary-background-darken-3":`#0043B1`,"primary-background-lighten-1":`#5C8AFF`,"primary-background-lighten-2":`#759EFF`,"primary-background-lighten-3":`#8DB2FF`,"primary-darken-1":`#1865DC`,"primary-darken-2":`#0053C6`,"primary-darken-3":`#0043B1`,"primary-lighten-1":`#5C8AFF`,"primary-lighten-2":`#759EFF`,"primary-lighten-3":`#8DB2FF`,"primary-muted":`#C2D3F7`,scrollbar:`#A2B8E9`,"scrollbar-active":`#4078F2`,"scrollbar-background":`#E4E4E4`,"scrollbar-background-active":`#E4E4E4`,"scrollbar-background-hover":`#E4E4E4`,"scrollbar-corner-color":`#E4E4E4`,"scrollbar-hover":`#92AEEB`,secondary:`#A626A4`,"secondary-background":`#A626A4`,"secondary-background-darken-1":`#90008F`,"secondary-background-darken-2":`#7B007C`,"secondary-background-darken-3":`#670069`,"secondary-background-lighten-1":`#BB3EB8`,"secondary-background-lighten-2":`#D154CD`,"secondary-background-lighten-3":`#E769E2`,"secondary-darken-1":`#90008F`,"secondary-darken-2":`#7B007C`,"secondary-darken-3":`#670069`,"secondary-lighten-1":`#BB3EB8`,"secondary-lighten-2":`#D154CD`,"secondary-lighten-3":`#E769E2`,"secondary-muted":`#E0BAE0`,success:`#6BF23F`,"success-darken-1":`#52DC25`,"success-darken-2":`#36C600`,"success-darken-3":`#05B100`,"success-lighten-1":`#83FF55`,"success-lighten-2":`#9BFF6B`,"success-lighten-3":`#B2FF80`,"success-muted":`#CFF7C1`,surface:`#E0E0E0`,"surface-active":`#F1F1F1`,"surface-darken-1":`#CACACA`,"surface-darken-2":`#B6B6B6`,"surface-darken-3":`#A2A2A2`,"surface-lighten-1":`#F5F5F5`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#7E6021`,"text-disabled":`#00000060`,"text-error":`#9F2929`,"text-muted":`#00000099`,"text-primary":`#2A4F9F`,"text-secondary":`#6D196C`,"text-success":`#479F29`,"text-warning":`#8E8F24`,warning:`#D7D938`,"warning-darken-1":`#C1C41C`,"warning-darken-2":`#ABAF00`,"warning-darken-3":`#969B00`,"warning-lighten-1":`#EEEE4E`,"warning-lighten-2":`#FFFF64`,"warning-lighten-3":`#FFFF79`,"warning-muted":`#EFF0BF`}},Dd={name:`catppuccin-frappe`,dark:!0,ansi:{black:`#51576D`,red:`#E78284`,green:`#A6D189`,yellow:`#E5C890`,blue:`#8CAAEE`,magenta:`#F4B8E4`,cyan:`#81C8BE`,white:`#B5BFE2`,brightBlack:`#626880`,brightRed:`#EDA0A2`,brightGreen:`#B9DBA2`,brightYellow:`#ECD7AE`,brightBlue:`#ADC2F3`,brightMagenta:`#F38ED8`,brightCyan:`#98D2CA`,brightWhite:`#A5ADCE`},vars:{accent:`#F4B8E4`,"accent-darken-1":`#DEA3CE`,"accent-darken-2":`#C98FBA`,"accent-darken-3":`#B47BA5`,"accent-lighten-1":`#FFCCF9`,"accent-lighten-2":`#FFE2FF`,"accent-lighten-3":`#FFF7FF`,"accent-muted":`#6A5B75`,background:`#303446`,"background-darken-1":`#1F2435`,"background-darken-2":`#101424`,"background-darken-3":`#000016`,"background-lighten-1":`#404457`,"background-lighten-2":`#525669`,"background-lighten-3":`#64687C`,"block-cursor-background":`#CA9EE6`,"block-cursor-blurred-background":`#CA9EE64C`,"block-cursor-blurred-foreground":`#C6D0F5`,"block-cursor-foreground":`#292C3C`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#BABBF1`,"border-blurred":`#838BA7`,"button-color-foreground":`#303446`,"button-foreground":`#C6D0F5`,error:`#E68284`,"error-darken-1":`#D06E71`,"error-darken-2":`#BA5A5E`,"error-darken-3":`#A4474C`,"error-lighten-1":`#FD9697`,"error-lighten-2":`#FFAAAB`,"error-lighten-3":`#FFBFBF`,"error-muted":`#664B58`,"footer-background":`#51576D`,"footer-description-background":`#00000000`,"footer-description-foreground":`#C6D0F5`,"footer-foreground":`#C6D0F5`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#F4B8E4`,foreground:`#C6D0F5`,"foreground-darken-1":`#B1BBDF`,"foreground-darken-2":`#9CA7CA`,"foreground-darken-3":`#8993B5`,"foreground-disabled":`#C6D0F560`,"foreground-lighten-1":`#DBE5FF`,"foreground-lighten-2":`#F0FAFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#C6D0F599`,"input-cursor-background":`#F2D5CF`,"input-cursor-foreground":`#232634`,"input-selection-background":`#949CBB4C`,"link-background":`#00000000`,"link-background-hover":`#CA9EE6`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#CA9EE6`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#CA9EE6`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#CA9EE6`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#C6D0F5`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#C6D0F5`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#C6D0F599`,panel:`#51576D`,"panel-darken-1":`#3F455A`,"panel-darken-2":`#2E3448`,"panel-darken-3":`#1D2437`,"panel-lighten-1":`#63697F`,"panel-lighten-2":`#767B93`,"panel-lighten-3":`#898FA7`,primary:`#CA9EE6`,"primary-background":`#625F76`,"primary-background-darken-1":`#54516A`,"primary-background-darken-2":`#47435E`,"primary-background-darken-3":`#47435E`,"primary-background-lighten-1":`#706D82`,"primary-background-lighten-2":`#7E7B8E`,"primary-background-lighten-3":`#8C899A`,"primary-darken-1":`#B58AD0`,"primary-darken-2":`#A076BB`,"primary-darken-3":`#8C63A7`,"primary-lighten-1":`#DFB2FB`,"primary-lighten-2":`#F4C7FF`,"primary-lighten-3":`#FFDCFF`,"primary-muted":`#5E5376`,scrollbar:`#63547B`,"scrollbar-active":`#CA9EE6`,"scrollbar-background":`#1F2435`,"scrollbar-background-active":`#1F2435`,"scrollbar-background-hover":`#1F2435`,"scrollbar-corner-color":`#1F2435`,"scrollbar-hover":`#74618D`,secondary:`#EE9F76`,"secondary-background":`#666067`,"secondary-background-darken-1":`#59525A`,"secondary-background-darken-2":`#4C444D`,"secondary-background-darken-3":`#4C444D`,"secondary-background-lighten-1":`#746E75`,"secondary-background-lighten-2":`#817C82`,"secondary-background-lighten-3":`#8F8A8F`,"secondary-darken-1":`#D88B63`,"secondary-darken-2":`#C27750`,"secondary-darken-3":`#AC643E`,"secondary-lighten-1":`#FFB389`,"secondary-lighten-2":`#FFC89D`,"secondary-lighten-3":`#FFDDB1`,"secondary-muted":`#695454`,success:`#A6D189`,"success-darken-1":`#91BC75`,"success-darken-2":`#7DA762`,"success-darken-3":`#6A9350`,"success-lighten-1":`#BAE69C`,"success-lighten-2":`#CFFBB1`,"success-lighten-3":`#E5FFC5`,"success-muted":`#53635A`,surface:`#414559`,"surface-active":`#4F5267`,"surface-darken-1":`#303447`,"surface-darken-2":`#1F2436`,"surface-darken-3":`#101526`,"surface-lighten-1":`#52566B`,"surface-lighten-2":`#64687E`,"surface-lighten-3":`#777B91`,text:`#FFFFFFDD`,"text-accent":`#F7D0ED`,"text-disabled":`#FFFFFF60`,"text-error":`#EFACAD`,"text-muted":`#FFFFFF99`,"text-primary":`#DCBEEE`,"text-secondary":`#F4BFA4`,"text-success":`#C4E0B1`,"text-warning":`#EDDAB5`,warning:`#E4C890`,"warning-darken-1":`#CFB37C`,"warning-darken-2":`#BA9F69`,"warning-darken-3":`#A58B56`,"warning-lighten-1":`#FADCA4`,"warning-lighten-2":`#FFF2B8`,"warning-lighten-3":`#FFFFCD`,"warning-muted":`#66605C`}},Od={name:`catppuccin-latte`,dark:!1,ansi:{black:`#BCC0CC`,red:`#D20F39`,green:`#40A02B`,yellow:`#DF8E1D`,blue:`#1E66F5`,magenta:`#EA76CB`,cyan:`#179299`,white:`#5C5F77`,brightBlack:`#ACB0BE`,brightRed:`#E7103F`,brightGreen:`#46B02F`,brightYellow:`#E49931`,brightBlue:`#3878F6`,brightMagenta:`#EF95D7`,brightCyan:`#19A1A8`,brightWhite:`#6C6F85`},vars:{accent:`#FD640B`,"accent-darken-1":`#E54F00`,"accent-darken-2":`#CC3900`,"accent-darken-3":`#B42200`,"accent-lighten-1":`#FF7825`,"accent-lighten-2":`#FF8D3A`,"accent-lighten-3":`#FFA24F`,"accent-muted":`#F3C6AE`,background:`#EFF1F5`,"background-darken-1":`#D9DBDF`,"background-darken-2":`#C4C6CA`,"background-darken-3":`#B0B2B5`,"background-lighten-1":`#FFFFFF`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#8839EF`,"block-cursor-blurred-background":`#8839EF4C`,"block-cursor-blurred-foreground":`#4C4F69`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#8839EF`,"border-blurred":`#DEE1E7`,"button-color-foreground":`#EFF1F5`,"button-foreground":`#4C4F69`,error:`#D10F39`,"error-darken-1":`#BA0028`,"error-darken-2":`#A20019`,"error-darken-3":`#8A0008`,"error-lighten-1":`#EA324A`,"error-lighten-2":`#FF4B5B`,"error-lighten-3":`#FF626E`,"error-muted":`#E6ADBC`,"footer-background":`#CCD0DA`,"footer-description-background":`#00000000`,"footer-description-foreground":`#4C4F69`,"footer-foreground":`#4C4F69`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FE640B`,foreground:`#4C4F69`,"foreground-darken-1":`#3A3D56`,"foreground-darken-2":`#292D45`,"foreground-darken-3":`#191D34`,"foreground-disabled":`#4C4F6960`,"foreground-lighten-1":`#5E607B`,"foreground-lighten-2":`#70738F`,"foreground-lighten-3":`#8386A2`,"foreground-muted":`#4C4F6999`,"input-cursor-background":`#4C4F69`,"input-cursor-foreground":`#EFF1F5`,"input-selection-background":`#9E4DFF66`,"link-background":`#00000000`,"link-background-hover":`#8839EF`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#8839EF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#8839EF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#8839EF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#4C4F69`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#4C4F69`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#4C4F6999`,panel:`#CCD0DA`,"panel-darken-1":`#B7BBC5`,"panel-darken-2":`#A3A6B0`,"panel-darken-3":`#8F939C`,"panel-lighten-1":`#E1E5EF`,"panel-lighten-2":`#F6FAFF`,"panel-lighten-3":`#FFFFFF`,primary:`#8839EF`,"primary-background":`#8839EF`,"primary-background-darken-1":`#7122D9`,"primary-background-darken-2":`#5901C3`,"primary-background-darken-3":`#4000AE`,"primary-background-lighten-1":`#9E4DFF`,"primary-background-lighten-2":`#B562FF`,"primary-background-lighten-3":`#CC76FF`,"primary-darken-1":`#7122D9`,"primary-darken-2":`#5901C3`,"primary-darken-3":`#4000AE`,"primary-lighten-1":`#9E4DFF`,"primary-lighten-2":`#B562FF`,"primary-lighten-3":`#CC76FF`,"primary-muted":`#D0B9F3`,scrollbar:`#B89AE5`,"scrollbar-active":`#8839EF`,"scrollbar-background":`#D9DBDF`,"scrollbar-background-active":`#D9DBDF`,"scrollbar-background-hover":`#D9DBDF`,"scrollbar-corner-color":`#D9DBDF`,"scrollbar-hover":`#B08AE7`,secondary:`#DB8A78`,"secondary-background":`#DB8A78`,"secondary-background-darken-1":`#C57665`,"secondary-background-darken-2":`#B06353`,"secondary-background-darken-3":`#9A5041`,"secondary-background-lighten-1":`#F29D8B`,"secondary-background-lighten-2":`#FFB29E`,"secondary-background-lighten-3":`#FFC7B3`,"secondary-darken-1":`#C57665`,"secondary-darken-2":`#B06353`,"secondary-darken-3":`#9A5041`,"secondary-lighten-1":`#F29D8B`,"secondary-lighten-2":`#FFB29E`,"secondary-lighten-3":`#FFC7B3`,"secondary-muted":`#E9D2CF`,success:`#40A02B`,"success-darken-1":`#278B14`,"success-darken-2":`#007800`,"success-darken-3":`#006400`,"success-lighten-1":`#56B43F`,"success-lighten-2":`#6BC952`,"success-lighten-3":`#81DE66`,"success-muted":`#BAD8B8`,surface:`#E6E9EF`,"surface-active":`#F7FAFF`,"surface-darken-1":`#D0D3D9`,"surface-darken-2":`#BCBFC4`,"surface-darken-3":`#A7AAB0`,"surface-lighten-1":`#FBFEFF`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#A74207`,"text-disabled":`#00000060`,"text-error":`#8A0925`,"text-muted":`#00000099`,"text-primary":`#59259D`,"text-secondary":`#915B4F`,"text-success":`#2A691C`,"text-warning":`#935D13`,warning:`#DE8E1D`,"warning-darken-1":`#C77A00`,"warning-darken-2":`#B06700`,"warning-darken-3":`#9A5500`,"warning-lighten-1":`#F6A134`,"warning-lighten-2":`#FFB648`,"warning-lighten-3":`#FFCA5D`,"warning-muted":`#EAD3B4`}},kd={name:`catppuccin-macchiato`,dark:!0,ansi:{black:`#494D64`,red:`#ED8796`,green:`#A6DA95`,yellow:`#EED49F`,blue:`#8AADF4`,magenta:`#F5BDE6`,cyan:`#8BD5CA`,white:`#B8C0E0`,brightBlack:`#5B6078`,brightRed:`#F2A7B2`,brightGreen:`#BDE3B0`,brightYellow:`#F4E3C1`,brightBlue:`#ADC5F7`,brightMagenta:`#F493DA`,brightCyan:`#A5DED6`,brightWhite:`#A5ADCB`},vars:{accent:`#F5BDE6`,"accent-darken-1":`#DFA8D0`,"accent-darken-2":`#CA94BC`,"accent-darken-3":`#B580A7`,"accent-lighten-1":`#FFD1FB`,"accent-lighten-2":`#FFE7FF`,"accent-lighten-3":`#FFFCFF`,"accent-muted":`#62546D`,background:`#24273A`,"background-darken-1":`#141729`,"background-darken-2":`#00021A`,"background-darken-3":`#000007`,"background-lighten-1":`#34374B`,"background-lighten-2":`#45485C`,"background-lighten-3":`#57596F`,"block-cursor-background":`#C6A0F6`,"block-cursor-blurred-background":`#C6A0F64C`,"block-cursor-blurred-foreground":`#CAD3F5`,"block-cursor-foreground":`#1E2030`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#B7BDF8`,"border-blurred":`#737994`,"button-color-foreground":`#24273A`,"button-foreground":`#CAD3F5`,error:`#ED8796`,"error-darken-1":`#D67382`,"error-darken-2":`#C05F6F`,"error-darken-3":`#AB4C5D`,"error-lighten-1":`#FF9BA9`,"error-lighten-2":`#FFAFBE`,"error-lighten-3":`#FFC4D3`,"error-muted":`#604355`,"footer-background":`#494D64`,"footer-description-background":`#00000000`,"footer-description-foreground":`#CAD3F5`,"footer-foreground":`#CAD3F5`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#F5BDE6`,foreground:`#CAD3F5`,"foreground-darken-1":`#B5BEDF`,"foreground-darken-2":`#A0A9CA`,"foreground-darken-3":`#8C95B5`,"foreground-disabled":`#CAD3F560`,"foreground-lighten-1":`#DFE8FF`,"foreground-lighten-2":`#F4FDFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#CAD3F599`,"input-cursor-background":`#F4DBD6`,"input-cursor-foreground":`#181926`,"input-selection-background":`#838BA74C`,"link-background":`#00000000`,"link-background-hover":`#C6A0F6`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#C6A0F6`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#C6A0F6`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#C6A0F6`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#CAD3F5`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#CAD3F5`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#CAD3F599`,panel:`#494D64`,"panel-darken-1":`#373B51`,"panel-darken-2":`#262B40`,"panel-darken-3":`#161C2F`,"panel-lighten-1":`#5A5E76`,"panel-lighten-2":`#6D7189`,"panel-lighten-3":`#80849D`,primary:`#C6A0F6`,"primary-background":`#59566F`,"primary-background-darken-1":`#4A4762`,"primary-background-darken-2":`#3C3956`,"primary-background-darken-3":`#3C3956`,"primary-background-lighten-1":`#67657C`,"primary-background-lighten-2":`#767488`,"primary-background-lighten-3":`#858395`,"primary-darken-1":`#B08CE0`,"primary-darken-2":`#9C78CB`,"primary-darken-3":`#8865B6`,"primary-lighten-1":`#DBB4FF`,"primary-lighten-2":`#F1C9FF`,"primary-lighten-3":`#FFDEFF`,"primary-muted":`#544B72`,scrollbar:`#5B4D7B`,"scrollbar-active":`#C6A0F6`,"scrollbar-background":`#141729`,"scrollbar-background-active":`#141729`,"scrollbar-background-hover":`#141729`,"scrollbar-corner-color":`#141729`,"scrollbar-hover":`#6D5B8F`,secondary:`#F4A97F`,"secondary-background":`#5F5760`,"secondary-background-darken-1":`#514852`,"secondary-background-darken-2":`#433A44`,"secondary-background-darken-3":`#433A44`,"secondary-background-lighten-1":`#6D666E`,"secondary-background-lighten-2":`#7B757C`,"secondary-background-lighten-3":`#89838A`,"secondary-darken-1":`#DE946B`,"secondary-darken-2":`#C88159`,"secondary-darken-3":`#B26E47`,"secondary-lighten-1":`#FFBD92`,"secondary-lighten-2":`#FFD2A6`,"secondary-lighten-3":`#FFE7BB`,"secondary-muted":`#624E4E`,success:`#A6DA95`,"success-darken-1":`#91C481`,"success-darken-2":`#7DB06E`,"success-darken-3":`#6A9C5B`,"success-lighten-1":`#BAEFA9`,"success-lighten-2":`#CFFFBD`,"success-lighten-3":`#E5FFD2`,"success-muted":`#4B5C55`,surface:`#363A4F`,"surface-active":`#43475D`,"surface-darken-1":`#25293D`,"surface-darken-2":`#151A2D`,"surface-darken-3":`#03061D`,"surface-lighten-1":`#474B60`,"surface-lighten-2":`#595C73`,"surface-lighten-3":`#6B6F86`,text:`#FFFFFFDD`,"text-accent":`#F8D3EE`,"text-disabled":`#FFFFFF60`,"text-error":`#F3AFB9`,"text-muted":`#FFFFFF99`,"text-primary":`#D9C0F9`,"text-secondary":`#F8C6AA`,"text-success":`#C4E6B9`,"text-warning":`#F3E2BF`,warning:`#EED49F`,"warning-darken-1":`#D8BF8B`,"warning-darken-2":`#C3AA77`,"warning-darken-3":`#AE9664`,"warning-lighten-1":`#FFE9B3`,"warning-lighten-2":`#FFFEC7`,"warning-lighten-3":`#FFFFDD`,"warning-muted":`#605A58`}},Ad={name:`catppuccin-mocha`,dark:!0,ansi:{black:`#45475A`,red:`#F38BA8`,green:`#A6E3A1`,yellow:`#F9E2AF`,blue:`#89B4FA`,magenta:`#F5C2E7`,cyan:`#94E2D5`,white:`#BAC2DE`,brightBlack:`#585B70`,brightRed:`#F7AEC2`,brightGreen:`#C2ECBF`,brightYellow:`#FCD682`,brightBlue:`#AECCFC`,brightMagenta:`#F398DA`,brightCyan:`#B1EAE1`,brightWhite:`#A6ADC8`},vars:{accent:`#F9B387`,"accent-darken-1":`#E39E73`,"accent-darken-2":`#CD8A60`,"accent-darken-3":`#B7774E`,"accent-lighten-1":`#FFC79A`,"accent-lighten-2":`#FFDCAE`,"accent-lighten-3":`#FFF2C3`,"accent-muted":`#5B4642`,background:`#181825`,"background-darken-1":`#040216`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#272735`,"background-lighten-2":`#373746`,"background-lighten-3":`#484857`,"block-cursor-background":`#F5C2E7`,"block-cursor-blurred-background":`#F5C2E74C`,"block-cursor-blurred-foreground":`#CDD6F4`,"block-cursor-foreground":`#1E1E2E`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#B4BEFE`,"border-blurred":`#585B70`,"button-color-foreground":`#181825`,"button-foreground":`#CDD6F4`,error:`#F28FAD`,"error-darken-1":`#DB7A99`,"error-darken-2":`#C66785`,"error-darken-3":`#B05372`,"error-lighten-1":`#FFA3C1`,"error-lighten-2":`#FFB8D6`,"error-lighten-3":`#FFCDEB`,"error-muted":`#593B4D`,"footer-background":`#45475A`,"footer-description-background":`#00000000`,"footer-description-foreground":`#CDD6F4`,"footer-foreground":`#CDD6F4`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FAB387`,foreground:`#CDD6F4`,"foreground-darken-1":`#B8C1DE`,"foreground-darken-2":`#A3ACC9`,"foreground-darken-3":`#8F98B4`,"foreground-disabled":`#CDD6F460`,"foreground-lighten-1":`#E2EBFF`,"foreground-lighten-2":`#F7FFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#CDD6F499`,"input-cursor-background":`#F5E0DC`,"input-cursor-foreground":`#11111B`,"input-selection-background":`#9399B24C`,"link-background":`#00000000`,"link-background-hover":`#F5C2E7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#F5C2E7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#F5C2E7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#F5C2E7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#CDD6F4`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#CDD6F4`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#CDD6F499`,panel:`#45475A`,"panel-darken-1":`#333648`,"panel-darken-2":`#232637`,"panel-darken-3":`#131627`,"panel-lighten-1":`#56586C`,"panel-lighten-2":`#696A7F`,"panel-lighten-3":`#7B7D92`,primary:`#F5C2E7`,"primary-background":`#564F5E`,"primary-background-darken-1":`#474050`,"primary-background-darken-2":`#393142`,"primary-background-darken-3":`#393142`,"primary-background-lighten-1":`#655F6C`,"primary-background-lighten-2":`#746E7A`,"primary-background-lighten-3":`#837E88`,"primary-darken-1":`#DFADD1`,"primary-darken-2":`#CA99BD`,"primary-darken-3":`#B585A8`,"primary-lighten-1":`#FFD6FC`,"primary-lighten-2":`#FFECFF`,"primary-lighten-3":`#FFFFFF`,"primary-muted":`#5A4B5F`,scrollbar:`#644E69`,"scrollbar-active":`#F5C2E7`,"scrollbar-background":`#040216`,"scrollbar-background-active":`#040216`,"scrollbar-background-hover":`#040216`,"scrollbar-corner-color":`#040216`,"scrollbar-hover":`#7C627E`,secondary:`#CBA6F7`,"secondary-background":`#504C60`,"secondary-background-darken-1":`#413C52`,"secondary-background-darken-2":`#322D44`,"secondary-background-darken-3":`#322D44`,"secondary-background-lighten-1":`#605C6E`,"secondary-background-lighten-2":`#6F6C7C`,"secondary-background-lighten-3":`#7E7B8A`,"secondary-darken-1":`#B592E1`,"secondary-darken-2":`#A17ECC`,"secondary-darken-3":`#8C6BB7`,"secondary-lighten-1":`#E0BAFF`,"secondary-lighten-2":`#F6CFFF`,"secondary-lighten-3":`#FFE4FF`,"secondary-muted":`#4D4264`,success:`#ABE9B3`,"success-darken-1":`#96D39E`,"success-darken-2":`#82BE8B`,"success-darken-3":`#6EAA77`,"success-lighten-1":`#BFFEC7`,"success-lighten-2":`#D5FFDC`,"success-lighten-3":`#EAFFF2`,"success-muted":`#44564F`,surface:`#313244`,"surface-active":`#3E3F51`,"surface-darken-1":`#202233`,"surface-darken-2":`#111223`,"surface-darken-3":`#000014`,"surface-lighten-1":`#414255`,"surface-lighten-2":`#535467`,"surface-lighten-3":`#65667A`,text:`#FFFFFFDD`,"text-accent":`#FBCCAF`,"text-disabled":`#FFFFFF60`,"text-error":`#F6B5C8`,"text-muted":`#FFFFFF99`,"text-primary":`#F8D6EF`,"text-secondary":`#DCC4F9`,"text-success":`#C7F0CC`,"text-warning":`#FBECCA`,warning:`#FAE3B0`,"warning-darken-1":`#E4CD9B`,"warning-darken-2":`#CEB988`,"warning-darken-3":`#B9A574`,"warning-lighten-1":`#FFF8C4`,"warning-lighten-2":`#FFFFD9`,"warning-lighten-3":`#FFFFEF`,"warning-muted":`#5B544E`}},jd=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],Md=Object.fromEntries(jd.map((e,t)=>[e,du.get(t).hex])),Nd={black:`#1A1A1A`,red:`#F4005F`,green:`#98E024`,yellow:`#FD971F`,blue:`#9D65FF`,magenta:`#F4005F`,cyan:`#58D1EB`,white:`#C4C5B5`,brightBlack:`#625E4C`,brightRed:`#F4005F`,brightGreen:`#98E024`,brightYellow:`#E0D561`,brightBlue:`#9D65FF`,brightMagenta:`#F4005F`,brightCyan:`#58D1EB`,brightWhite:`#F6F6EF`},Pd={"atom-one-dark":Td,"atom-one-light":Ed,"catppuccin-frappe":Dd,"catppuccin-latte":Od,"catppuccin-macchiato":kd,"catppuccin-mocha":Ad,cyberpunk:{name:`cyberpunk`,dark:!0,ansi:Nd,vars:{background:`#070714`,"background-darken-1":`#03030A`,"background-darken-2":`#000003`,"background-darken-3":`#000000`,"background-lighten-1":`#11111E`,"background-lighten-2":`#1A1A2B`,"background-lighten-3":`#25253A`,foreground:`#E2E2FF`,"foreground-darken-1":`#CACAE4`,"foreground-darken-2":`#B3B3CC`,"foreground-darken-3":`#9C9CB5`,"foreground-disabled":`#E2E2FF60`,"foreground-lighten-1":`#EEEEFF`,"foreground-lighten-2":`#F6F6FF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E2E2FF99`,primary:`#00E5FFD9`,"primary-darken-1":`#00CCE6D9`,"primary-darken-2":`#00B2CCD9`,"primary-darken-3":`#0099B3D9`,"primary-lighten-1":`#1AF0FFD9`,"primary-lighten-2":`#33F5FFD9`,"primary-lighten-3":`#4DFAFFD9`,"primary-muted":`#054A5BF4`,"primary-background":`#0A3340`,"primary-background-darken-1":`#072833`,"primary-background-darken-2":`#051E27`,"primary-background-darken-3":`#051E27`,"primary-background-lighten-1":`#0F404F`,"primary-background-lighten-2":`#154E5F`,"primary-background-lighten-3":`#1A5C6F`,secondary:`#FF1E8ECC`,"secondary-darken-1":`#E60A76CC`,"secondary-darken-2":`#CC005FCC`,"secondary-darken-3":`#B20048CC`,"secondary-lighten-1":`#FF3CA2CC`,"secondary-lighten-2":`#FF5AB6CC`,"secondary-lighten-3":`#FF78CACC`,"secondary-muted":`#510E39EF`,"secondary-background":`#3A0A28`,"secondary-background-darken-1":`#2E071F`,"secondary-background-darken-2":`#220517`,"secondary-background-darken-3":`#220517`,"secondary-background-lighten-1":`#470D33`,"secondary-background-lighten-2":`#54103F`,"secondary-background-lighten-3":`#61134B`,accent:`#EEFF00CC`,"accent-darken-1":`#D6E600CC`,"accent-darken-2":`#BECC00CC`,"accent-darken-3":`#A5B200CC`,"accent-lighten-1":`#FFFF26CC`,"accent-lighten-2":`#FFFF4DCC`,"accent-lighten-3":`#FFFF73CC`,"accent-muted":`#4C510EEF`,success:`#39FF14BF`,"success-darken-1":`#23E60ABF`,"success-darken-2":`#0FCC00BF`,"success-darken-3":`#00B200BF`,"success-lighten-1":`#4DFF32BF`,"success-lighten-2":`#69FF5ABF`,"success-lighten-3":`#87FF82BF`,"success-muted":`#164D14F0`,warning:`#FF6E00CC`,"warning-darken-1":`#E65800CC`,"warning-darken-2":`#CC4300CC`,"warning-darken-3":`#B23000CC`,"warning-lighten-1":`#FF8C26CC`,"warning-lighten-2":`#FFA54DCC`,"warning-lighten-3":`#FFBE73CC`,"warning-muted":`#51260EEF`,error:`#FF1133BF`,"error-darken-1":`#E6051EBF`,"error-darken-2":`#CC000CBF`,"error-darken-3":`#B20000BF`,"error-lighten-1":`#FF3758BF`,"error-lighten-2":`#FF5A78BF`,"error-lighten-3":`#FF7D96BF`,"error-muted":`#510A1DF0`,surface:`#0F0F22`,"surface-active":`#161630`,"surface-darken-1":`#08081A`,"surface-darken-2":`#040411`,"surface-darken-3":`#020209`,"surface-lighten-1":`#17172E`,"surface-lighten-2":`#1F1F3C`,"surface-lighten-3":`#28284A`,panel:`#0C0C1E`,"panel-darken-1":`#060614`,"panel-darken-2":`#03030C`,"panel-darken-3":`#010108`,"panel-lighten-1":`#14142C`,"panel-lighten-2":`#1C1C3A`,"panel-lighten-3":`#242448`,scrollbar:`#151535`,"scrollbar-active":`#00E5FFD9`,"scrollbar-background":`#040412`,"scrollbar-background-active":`#040412`,"scrollbar-background-hover":`#040412`,"scrollbar-corner-color":`#040412`,"scrollbar-hover":`#1F1F48`,"block-cursor-background":`#00E5FF`,"block-cursor-blurred-background":`#00E5FF4C`,"block-cursor-blurred-foreground":`#E2E2FF`,"block-cursor-foreground":`#070714`,"block-hover-background":`#00E5FF19`,boost:`#00E5FF0A`,"boost-darken-1":`#00CCE60A`,"boost-darken-2":`#00B2CC0A`,"boost-darken-3":`#0099B30A`,"boost-lighten-1":`#00E5FF0A`,"boost-lighten-2":`#00E5FF0A`,"boost-lighten-3":`#00E5FF0A`,border:`#00E5FFD9`,"border-blurred":`#1A1A35`,"button-color-foreground":`#070714`,"button-foreground":`#E2E2FF`,"footer-background":`#0C0C1E`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E2E2FF`,"footer-foreground":`#E2E2FF`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#00E5FFD9`,"input-cursor-background":`#E2E2FF`,"input-cursor-foreground":`#070714`,"input-selection-background":`#00E5FF40`,"link-background":`#00000000`,"link-background-hover":`#00E5FFD9`,"link-color":`#E2E2FFDD`,"link-color-hover":`#070714`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#00E5FFD9`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#00E5FFD9`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#FF1E8ECC`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E2E2FF`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E2E2FF`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E2E2FF99`,text:`#E2E2FFDD`,"text-accent":`#F4FF66CC`,"text-disabled":`#E2E2FF60`,"text-error":`#FF6677BF`,"text-muted":`#E2E2FF99`,"text-primary":`#66F0FFD9`,"text-secondary":`#FF80B0CC`,"text-success":`#80FF55BF`,"text-warning":`#FFB055CC`}},default:{name:`default`,dark:!0,ansi:Md,vars:{accent:`#006FB8`,"accent-darken-1":`#005CA3`,"accent-darken-2":`#004B8F`,"accent-darken-3":`#003A7B`,"accent-lighten-1":`#3081CC`,"accent-lighten-2":`#4C95E2`,"accent-lighten-3":`#64A8F7`,"accent-muted":`#002137`,background:`#000000`,"background-darken-1":`#000000`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#161616`,"background-lighten-2":`#252525`,"background-lighten-3":`#353535`,"block-cursor-background":`#006FB8`,"block-cursor-blurred-background":`#006FB84C`,"block-cursor-blurred-foreground":`#FFFFFF`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#006FB8`,"border-blurred":`#191919`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#FFFFFF`,error:`#7F0000`,"error-darken-1":`#6A0000`,"error-darken-2":`#560000`,"error-darken-3":`#450000`,"error-lighten-1":`#961E12`,"error-lighten-2":`#AD3423`,"error-lighten-3":`#C44934`,"error-muted":`#260000`,"footer-background":`#242E35`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FFFFFF`,"footer-foreground":`#FFFFFF`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#006FB8`,foreground:`#FFFFFF`,"foreground-darken-1":`#E9E9E9`,"foreground-darken-2":`#D4D4D4`,"foreground-darken-3":`#BFBFBF`,"foreground-disabled":`#FFFFFF60`,"foreground-lighten-1":`#FFFFFF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#FFFFFF99`,"input-cursor-background":`#FFFFFF`,"input-cursor-foreground":`#000000`,"input-selection-background":`#3081CC66`,"link-background":`#00000000`,"link-background-hover":`#006FB8`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#006FB8`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#006FB8`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#006FB8`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#FFFFFF`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#FFFFFF`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#FFFFFF99`,panel:`#242E35`,"panel-darken-1":`#141E24`,"panel-darken-2":`#000D15`,"panel-darken-3":`#000000`,"panel-lighten-1":`#343E45`,"panel-lighten-2":`#454F57`,"panel-lighten-3":`#566169`,primary:`#006FB8`,"primary-background":`#26333D`,"primary-background-darken-1":`#13212C`,"primary-background-darken-2":`#00101B`,"primary-background-darken-3":`#00101B`,"primary-background-lighten-1":`#39454E`,"primary-background-lighten-2":`#4C575F`,"primary-background-lighten-3":`#5F6970`,"primary-darken-1":`#005CA3`,"primary-darken-2":`#004B8F`,"primary-darken-3":`#003A7B`,"primary-lighten-1":`#3081CC`,"primary-lighten-2":`#4C95E2`,"primary-lighten-3":`#64A8F7`,"primary-muted":`#002137`,scrollbar:`#002C49`,"scrollbar-active":`#006FB8`,"scrollbar-background":`#000000`,"scrollbar-background-active":`#000000`,"scrollbar-background-hover":`#000000`,"scrollbar-corner-color":`#000000`,"scrollbar-hover":`#00375C`,secondary:`#762671`,"secondary-background":`#342A33`,"secondary-background-darken-1":`#221721`,"secondary-background-darken-2":`#110510`,"secondary-background-darken-3":`#110510`,"secondary-background-lighten-1":`#463D45`,"secondary-background-lighten-2":`#585057`,"secondary-background-lighten-3":`#6A6269`,"secondary-darken-1":`#620F5E`,"secondary-darken-2":`#4E004C`,"secondary-darken-3":`#3B003A`,"secondary-lighten-1":`#8A3984`,"secondary-lighten-2":`#9E4C97`,"secondary-lighten-3":`#B360AB`,"secondary-muted":`#230B21`,success:`#008000`,"success-darken-1":`#006C00`,"success-darken-2":`#005900`,"success-darken-3":`#004600`,"success-lighten-1":`#29931C`,"success-lighten-2":`#42A832`,"success-lighten-3":`#58BD46`,"success-muted":`#002600`,surface:`#1E1E1E`,"surface-active":`#2A2A2A`,"surface-darken-1":`#0D0D0D`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2D2D2D`,"surface-lighten-2":`#3E3E3E`,"surface-lighten-3":`#4F4F4F`,text:`#FFFFFFDD`,"text-accent":`#569FD0`,"text-disabled":`#FFFFFF60`,"text-error":`#AB5656`,"text-muted":`#FFFFFF99`,"text-primary":`#569FD0`,"text-secondary":`#A46FA1`,"text-success":`#56AB56`,"text-warning":`#ABAB56`,warning:`#7F8000`,"warning-darken-1":`#6B6D00`,"warning-darken-2":`#575A00`,"warning-darken-3":`#454900`,"warning-lighten-1":`#94931E`,"warning-lighten-2":`#A9A734`,"warning-lighten-3":`#BFBB48`,"warning-muted":`#262600`}},dracula:{name:`dracula`,dark:!0,ansi:{black:`#21222C`,red:`#FF5555`,green:`#50FA7B`,yellow:`#F1FA8C`,blue:`#BD93F9`,magenta:`#FF79C6`,cyan:`#8BE9FD`,white:`#F8F8F2`,brightBlack:`#6272A4`,brightRed:`#FF6E6E`,brightGreen:`#69FF94`,brightYellow:`#FFFFA5`,brightBlue:`#D6ACFF`,brightMagenta:`#FF92DF`,brightCyan:`#A4FFFF`,brightWhite:`#FFFFFF`},vars:{accent:`#FF79C6`,"accent-darken-1":`#E864B1`,"accent-darken-2":`#D24F9D`,"accent-darken-3":`#BC3989`,"accent-lighten-1":`#FF8DDA`,"accent-lighten-2":`#FFA3F0`,"accent-lighten-3":`#FFB8FF`,"accent-muted":`#684161`,background:`#282A36`,"background-darken-1":`#181A25`,"background-darken-2":`#050716`,"background-darken-3":`#000000`,"background-lighten-1":`#383A46`,"background-lighten-2":`#494B58`,"background-lighten-3":`#5B5D6A`,"block-cursor-background":`#BD93F9`,"block-cursor-blurred-background":`#BD93F94C`,"block-cursor-blurred-foreground":`#F8F8F2`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#BD93F9`,"border-blurred":`#252835`,"button-color-foreground":`#282A36`,"button-foreground":`#F8F8F2`,error:`#FE5555`,"error-darken-1":`#E63E43`,"error-darken-2":`#CE2332`,"error-darken-3":`#B70022`,"error-lighten-1":`#FF6A67`,"error-lighten-2":`#FF807A`,"error-lighten-3":`#FF958D`,"error-muted":`#68363F`,"footer-background":`#313442`,"footer-description-background":`#00000000`,"footer-description-foreground":`#F8F8F2`,"footer-foreground":`#F8F8F2`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FF79C6`,foreground:`#F8F8F2`,"foreground-darken-1":`#E2E2DC`,"foreground-darken-2":`#CDCDC7`,"foreground-darken-3":`#B8B8B3`,"foreground-disabled":`#F8F8F260`,"foreground-lighten-1":`#FFFFFF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#F8F8F299`,"input-cursor-background":`#F8F8F2`,"input-cursor-foreground":`#282A36`,"input-selection-background":`#D2A7FF66`,"link-background":`#00000000`,"link-background-hover":`#BD93F9`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#BD93F9`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#BD93F9`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#BD93F9`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#F8F8F2`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#F8F8F2`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#F8F8F299`,panel:`#313442`,"panel-darken-1":`#202431`,"panel-darken-2":`#111421`,"panel-darken-3":`#000012`,"panel-lighten-1":`#414453`,"panel-lighten-2":`#535665`,"panel-lighten-3":`#656878`,primary:`#BD93F9`,"primary-background":`#5A566C`,"primary-background-darken-1":`#4C475F`,"primary-background-darken-2":`#3E3953`,"primary-background-darken-3":`#3E3953`,"primary-background-lighten-1":`#696579`,"primary-background-lighten-2":`#777486`,"primary-background-lighten-3":`#868393`,"primary-darken-1":`#A77FE3`,"primary-darken-2":`#936CCE`,"primary-darken-3":`#7E59B9`,"primary-lighten-1":`#D2A7FF`,"primary-lighten-2":`#E8BBFF`,"primary-lighten-3":`#FED0FF`,"primary-muted":`#544970`,scrollbar:`#5A4A79`,"scrollbar-active":`#BD93F9`,"scrollbar-background":`#181A25`,"scrollbar-background-active":`#181A25`,"scrollbar-background-hover":`#181A25`,"scrollbar-corner-color":`#181A25`,"scrollbar-hover":`#6A568F`,secondary:`#6272A4`,"secondary-background":`#4F5261`,"secondary-background-darken-1":`#3F4353`,"secondary-background-darken-2":`#303446`,"secondary-background-darken-3":`#303446`,"secondary-background-lighten-1":`#5E616F`,"secondary-background-lighten-2":`#6E707D`,"secondary-background-lighten-3":`#7D808B`,"secondary-darken-1":`#4E5F90`,"secondary-darken-2":`#3B4D7C`,"secondary-darken-3":`#283C69`,"secondary-lighten-1":`#7584B8`,"secondary-lighten-2":`#8998CD`,"secondary-lighten-3":`#9DACE2`,"secondary-muted":`#393F57`,success:`#50FA7B`,"success-darken-1":`#2FE467`,"success-darken-2":`#00CE53`,"success-darken-3":`#00B83F`,"success-lighten-1":`#6AFF8F`,"success-lighten-2":`#83FFA3`,"success-lighten-3":`#9BFFB8`,"success-muted":`#34684A`,surface:`#2B2E3B`,"surface-active":`#383B48`,"surface-darken-1":`#1B1E2A`,"surface-darken-2":`#0A0D1B`,"surface-darken-3":`#000009`,"surface-lighten-1":`#3B3E4C`,"surface-lighten-2":`#4C4F5D`,"surface-lighten-3":`#5E6170`,text:`#FFFFFFDD`,"text-accent":`#FFA6D9`,"text-disabled":`#FFFFFF60`,"text-error":`#FF8E8E`,"text-muted":`#FFFFFF99`,"text-primary":`#D3B7FB`,"text-secondary":`#97A1C2`,"text-success":`#8BFBA7`,"text-warning":`#FFD09D`,warning:`#FEB86C`,"warning-darken-1":`#E8A358`,"warning-darken-2":`#D18F45`,"warning-darken-3":`#BB7C33`,"warning-lighten-1":`#FFCC7F`,"warning-lighten-2":`#FFE193`,"warning-lighten-3":`#FFF7A7`,"warning-muted":`#685446`}},flexoki:{name:`flexoki`,dark:!0,ansi:{black:`#100F0F`,red:`#D14D41`,green:`#879A39`,yellow:`#D0A215`,blue:`#4385BE`,magenta:`#CE5D97`,cyan:`#3AA99F`,white:`#878580`,brightBlack:`#575653`,brightRed:`#AF3029`,brightGreen:`#66800B`,brightYellow:`#AD8301`,brightBlue:`#205EA6`,brightMagenta:`#A02F6F`,brightCyan:`#24837B`,brightWhite:`#CECDC3`},vars:{accent:`#9B76C8`,"accent-darken-1":`#8663B3`,"accent-darken-2":`#72509E`,"accent-darken-3":`#5F3E8B`,"accent-lighten-1":`#AF89DD`,"accent-lighten-2":`#C49DF2`,"accent-lighten-3":`#D9B1FF`,"accent-muted":`#392D46`,background:`#100F0F`,"background-darken-1":`#000000`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#1F1F1F`,"background-lighten-2":`#2F2E2E`,"background-lighten-3":`#403F3F`,"block-cursor-background":`#205EA6`,"block-cursor-blurred-background":`#205EA64C`,"block-cursor-blurred-foreground":`#FFFCF0`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#205EA6`,"border-blurred":`#171614`,"button-color-foreground":`#FFFCF0`,"button-foreground":`#FFFCF0`,error:`#AE3029`,"error-darken-1":`#981818`,"error-darken-2":`#810007`,"error-darken-3":`#6B0000`,"error-lighten-1":`#C64539`,"error-lighten-2":`#DD594B`,"error-lighten-3":`#F46D5D`,"error-muted":`#3F1816`,"footer-background":`#282726`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FFFCF0`,"footer-foreground":`#FFFCF0`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#9B76C8`,foreground:`#FFFCF0`,"foreground-darken-1":`#E9E6DA`,"foreground-darken-2":`#D4D1C5`,"foreground-darken-3":`#BFBCB1`,"foreground-disabled":`#FFFCF060`,"foreground-lighten-1":`#FFFFFF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#FFFCF099`,"input-cursor-background":`#FFFCF0`,"input-cursor-foreground":`#5E409D`,"input-selection-background":`#6F6E6959`,"link-background":`#00000000`,"link-background-hover":`#205EA6`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#205EA6`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#205EA6`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#205EA6`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#FFFCF0`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#FFFCF0`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#FFFCF099`,panel:`#282726`,"panel-darken-1":`#181716`,"panel-darken-2":`#040200`,"panel-darken-3":`#000000`,"panel-lighten-1":`#383736`,"panel-lighten-2":`#494846`,"panel-lighten-3":`#5A5958`,primary:`#205EA6`,"primary-background":`#353C45`,"primary-background-darken-1":`#232B35`,"primary-background-darken-2":`#121A25`,"primary-background-darken-3":`#121A25`,"primary-background-lighten-1":`#474D56`,"primary-background-lighten-2":`#595E66`,"primary-background-lighten-3":`#6A6F76`,"primary-darken-1":`#004C91`,"primary-darken-2":`#003B7E`,"primary-darken-3":`#002B6B`,"primary-lighten-1":`#3C70BA`,"primary-lighten-2":`#5383CF`,"primary-lighten-3":`#6996E4`,"primary-muted":`#14263C`,scrollbar:`#0C2542`,"scrollbar-active":`#205EA6`,"scrollbar-background":`#000000`,"scrollbar-background-active":`#000000`,"scrollbar-background-hover":`#000000`,"scrollbar-corner-color":`#000000`,"scrollbar-hover":`#102F53`,secondary:`#24837B`,"secondary-background":`#364140`,"secondary-background-darken-1":`#24302F`,"secondary-background-darken-2":`#13201F`,"secondary-background-darken-3":`#13201F`,"secondary-background-lighten-1":`#485251`,"secondary-background-lighten-2":`#596262`,"secondary-background-lighten-3":`#6B7373`,"secondary-darken-1":`#006F68`,"secondary-darken-2":`#005D56`,"secondary-darken-3":`#004A44`,"secondary-lighten-1":`#3C968E`,"secondary-lighten-2":`#52AAA1`,"secondary-lighten-3":`#67BFB6`,"secondary-muted":`#16312F`,success:`#65800B`,"success-darken-1":`#526D00`,"success-darken-2":`#3E5A00`,"success-darken-3":`#2D4800`,"success-lighten-1":`#7A9324`,"success-lighten-2":`#8EA738`,"success-lighten-3":`#A3BB4C`,"success-muted":`#29300D`,surface:`#1C1B1A`,"surface-active":`#282726`,"surface-darken-1":`#0A0806`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2B2A29`,"surface-lighten-2":`#3B3A39`,"surface-lighten-3":`#4D4B4A`,text:`#FFFFFFDD`,"text-accent":`#BDA4DA`,"text-disabled":`#FFFFFF60`,"text-error":`#CA7671`,"text-muted":`#FFFFFF99`,"text-primary":`#6B94C4`,"text-secondary":`#6EADA7`,"text-success":`#9AAB5D`,"text-warning":`#C8AD57`,warning:`#AC8301`,"warning-darken-1":`#977000`,"warning-darken-2":`#815D00`,"warning-darken-3":`#6C4C00`,"warning-lighten-1":`#C39621`,"warning-lighten-2":`#D9AA37`,"warning-lighten-3":`#F0BE4B`,"warning-muted":`#3F310A`}},gruvbox:{name:`gruvbox`,dark:!0,ansi:{black:`#282828`,red:`#CC241D`,green:`#98971A`,yellow:`#D79921`,blue:`#458588`,magenta:`#B16286`,cyan:`#689D6A`,white:`#A89984`,brightBlack:`#928374`,brightRed:`#FB4934`,brightGreen:`#B8BB26`,brightYellow:`#FABD2F`,brightBlue:`#83A598`,brightMagenta:`#D3869B`,brightCyan:`#8EC07C`,brightWhite:`#EBDBB2`},vars:{accent:`#F9BD2F`,"accent-darken-1":`#E2A811`,"accent-darken-2":`#CB9400`,"accent-darken-3":`#B48100`,"accent-lighten-1":`#FFD146`,"accent-lighten-2":`#FFE65B`,"accent-lighten-3":`#FFFC70`,"accent-muted":`#67542A`,background:`#282828`,"background-darken-1":`#181818`,"background-darken-2":`#040404`,"background-darken-3":`#000000`,"background-lighten-1":`#383838`,"background-lighten-2":`#494949`,"background-lighten-3":`#5A5A5A`,"block-cursor-background":`#85A598`,"block-cursor-blurred-background":`#85A5984C`,"block-cursor-blurred-foreground":`#FBF1C7`,"block-cursor-foreground":`#FBF1C7`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#85A598`,"border-blurred":`#363230`,"button-color-foreground":`#282828`,"button-foreground":`#FBF1C7`,error:`#FA4934`,"error-darken-1":`#E23022`,"error-darken-2":`#C90D10`,"error-darken-3":`#B10000`,"error-lighten-1":`#FF5F45`,"error-lighten-2":`#FF7558`,"error-lighten-3":`#FF8B6B`,"error-muted":`#67312B`,"footer-background":`#504945`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FBF1C7`,"footer-foreground":`#FBF1C7`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FABD2F`,foreground:`#FBF1C7`,"foreground-darken-1":`#E5DBB2`,"foreground-darken-2":`#D0C69E`,"foreground-darken-3":`#BBB28A`,"foreground-disabled":`#FBF1C760`,"foreground-lighten-1":`#FFFFDC`,"foreground-lighten-2":`#FFFFF1`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#FBF1C799`,"input-cursor-background":`#FBF1C7`,"input-cursor-foreground":`#282828`,"input-selection-background":`#689D6A40`,"link-background":`#00000000`,"link-background-hover":`#85A598`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#85A598`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#85A598`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#85A598`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#FBF1C7`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#FBF1C7`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#FBF1C799`,panel:`#504945`,"panel-darken-1":`#3E3834`,"panel-darken-2":`#2E2724`,"panel-darken-3":`#1E1815`,"panel-lighten-1":`#615A56`,"panel-lighten-2":`#746C68`,"panel-lighten-3":`#877F7B`,primary:`#85A598`,"primary-background":`#535755`,"primary-background-darken-1":`#444846`,"primary-background-darken-2":`#353A38`,"primary-background-darken-3":`#353A38`,"primary-background-lighten-1":`#626664`,"primary-background-lighten-2":`#717573`,"primary-background-lighten-3":`#808382`,"primary-darken-1":`#719184`,"primary-darken-2":`#5F7D71`,"primary-darken-3":`#4C6A5F`,"primary-lighten-1":`#98B9AB`,"primary-lighten-2":`#ACCEC0`,"primary-lighten-3":`#C1E3D5`,"primary-muted":`#434D49`,scrollbar:`#43504B`,"scrollbar-active":`#85A598`,"scrollbar-background":`#181818`,"scrollbar-background-active":`#181818`,"scrollbar-background-hover":`#181818`,"scrollbar-corner-color":`#181818`,"scrollbar-hover":`#4E5E58`,secondary:`#A89A85`,"secondary-background":`#585653`,"secondary-background-darken-1":`#494744`,"secondary-background-darken-2":`#3B3935`,"secondary-background-darken-3":`#3B3935`,"secondary-background-lighten-1":`#676562`,"secondary-background-lighten-2":`#757471`,"secondary-background-lighten-3":`#848380`,"secondary-darken-1":`#938671`,"secondary-darken-2":`#80735F`,"secondary-darken-3":`#6D604D`,"secondary-lighten-1":`#BCAE98`,"secondary-lighten-2":`#D1C2AC`,"secondary-lighten-3":`#E6D7C1`,"secondary-muted":`#4E4A43`,success:`#B7BB26`,"success-darken-1":`#A2A601`,"success-darken-2":`#8C9300`,"success-darken-3":`#777F00`,"success-lighten-1":`#CDCF3D`,"success-lighten-2":`#E4E453`,"success-lighten-3":`#FAFA68`,"success-muted":`#535427`,surface:`#3C3836`,"surface-active":`#494543`,"surface-darken-1":`#2B2725`,"surface-darken-2":`#1C1816`,"surface-darken-3":`#0A0300`,"surface-lighten-1":`#4D4846`,"surface-lighten-2":`#5F5A58`,"surface-lighten-3":`#716C6A`,text:`#FFFFFFDD`,"text-accent":`#FBD375`,"text-disabled":`#FFFFFF60`,"text-error":`#FC8679`,"text-muted":`#FFFFFF99`,"text-primary":`#AEC3BB`,"text-secondary":`#C5BCAE`,"text-success":`#D0D26F`,"text-warning":`#FEAB67`,warning:`#FD8019`,"warning-darken-1":`#E56C00`,"warning-darken-2":`#CD5800`,"warning-darken-3":`#B54500`,"warning-lighten-1":`#FF9430`,"warning-lighten-2":`#FFA845`,"warning-lighten-3":`#FFBD5A`,"warning-muted":`#684223`}},monokai:{name:`monokai`,dark:!0,ansi:{black:`#333333`,red:`#C4265E`,green:`#86B42B`,yellow:`#B3B42B`,blue:`#6A7EC8`,magenta:`#8C6BC8`,cyan:`#56ADBC`,white:`#E3E3DD`,brightBlack:`#666666`,brightRed:`#F92672`,brightGreen:`#A6E22E`,brightYellow:`#E2E22E`,brightBlue:`#819AFF`,brightMagenta:`#AE81FF`,brightCyan:`#66D9EF`,brightWhite:`#F8F8F2`},vars:{accent:`#66D9EF`,"accent-darken-1":`#4DC3D9`,"accent-darken-2":`#31AFC4`,"accent-darken-3":`#009BB0`,"accent-lighten-1":`#7DEEFF`,"accent-lighten-2":`#94FFFF`,"accent-lighten-3":`#AAFFFF`,"accent-muted":`#395D5F`,background:`#272822`,"background-darken-1":`#171812`,"background-darken-2":`#020400`,"background-darken-3":`#000000`,"background-lighten-1":`#373831`,"background-lighten-2":`#484942`,"background-lighten-3":`#595A54`,"block-cursor-background":`#AE81FF`,"block-cursor-blurred-background":`#AE81FF4C`,"block-cursor-blurred-foreground":`#D6D6D6`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#AE81FF`,"border-blurred":`#282828`,"button-color-foreground":`#272822`,"button-foreground":`#D6D6D6`,error:`#F82672`,"error-darken-1":`#E1005F`,"error-darken-2":`#C9004E`,"error-darken-3":`#B1003D`,"error-lighten-1":`#FF4484`,"error-lighten-2":`#FF5D98`,"error-lighten-3":`#FF75AC`,"error-muted":`#66273A`,"footer-background":`#3E3D32`,"footer-description-background":`#00000000`,"footer-description-foreground":`#D6D6D6`,"footer-foreground":`#D6D6D6`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#66D9EF`,foreground:`#D6D6D6`,"foreground-darken-1":`#C1C1C1`,"foreground-darken-2":`#ACACAC`,"foreground-darken-3":`#989898`,"foreground-disabled":`#D6D6D660`,"foreground-lighten-1":`#EBEBEB`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#797979`,"input-cursor-background":`#D6D6D6`,"input-cursor-foreground":`#272822`,"input-selection-background":`#575B6190`,"link-background":`#00000000`,"link-background-hover":`#AE81FF`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#AE81FF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#AE81FF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#AE81FF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#D6D6D6`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#D6D6D6`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#797979`,panel:`#3E3D32`,"panel-darken-1":`#2D2C22`,"panel-darken-2":`#1D1C12`,"panel-darken-3":`#0D0B00`,"panel-lighten-1":`#4F4E42`,"panel-lighten-2":`#616054`,"panel-lighten-3":`#737266`,primary:`#AE81FF`,"primary-background":`#58535F`,"primary-background-darken-1":`#494451`,"primary-background-darken-2":`#3B3543`,"primary-background-darken-3":`#3B3543`,"primary-background-lighten-1":`#67626D`,"primary-background-lighten-2":`#75717B`,"primary-background-lighten-3":`#848089`,"primary-darken-1":`#986DE9`,"primary-darken-2":`#835AD3`,"primary-darken-3":`#6E48BE`,"primary-lighten-1":`#C394FF`,"primary-lighten-2":`#D9A9FF`,"primary-lighten-3":`#EFBDFF`,"primary-muted":`#4F4264`,scrollbar:`#534270`,"scrollbar-active":`#AE81FF`,"scrollbar-background":`#171812`,"scrollbar-background-active":`#171812`,"scrollbar-background-hover":`#171812`,"scrollbar-corner-color":`#171812`,"scrollbar-hover":`#624C88`,secondary:`#F82672`,"secondary-background":`#61474D`,"secondary-background-darken-1":`#53373D`,"secondary-background-darken-2":`#46272E`,"secondary-background-darken-3":`#46272E`,"secondary-background-lighten-1":`#6F575D`,"secondary-background-lighten-2":`#7D676C`,"secondary-background-lighten-3":`#8B787C`,"secondary-darken-1":`#E1005F`,"secondary-darken-2":`#C9004E`,"secondary-darken-3":`#B1003D`,"secondary-lighten-1":`#FF4484`,"secondary-lighten-2":`#FF5D98`,"secondary-lighten-3":`#FF75AC`,"secondary-muted":`#66273A`,success:`#A5E22E`,"success-darken-1":`#90CC09`,"success-darken-2":`#7AB700`,"success-darken-3":`#64A300`,"success-lighten-1":`#BBF746`,"success-lighten-2":`#D2FF5D`,"success-lighten-3":`#E8FF72`,"success-muted":`#4D5F25`,surface:`#2E2E2E`,"surface-active":`#3B3B3B`,"surface-darken-1":`#1E1E1E`,"surface-darken-2":`#0D0D0D`,"surface-darken-3":`#000000`,"surface-lighten-1":`#3E3E3E`,"surface-lighten-2":`#4F4F4F`,"surface-lighten-3":`#616161`,text:`#FFFFFFDD`,"text-accent":`#9AE5F4`,"text-disabled":`#FFFFFF60`,"text-error":`#FB6FA1`,"text-muted":`#FFFFFF99`,"text-primary":`#C9ABFF`,"text-secondary":`#FB6FA1`,"text-success":`#C4EB75`,"text-warning":`#FDBA6B`,warning:`#FC971F`,"warning-darken-1":`#E58300`,"warning-darken-2":`#CD6F00`,"warning-darken-3":`#B65D00`,"warning-lighten-1":`#FFAB36`,"warning-lighten-2":`#FFBF4C`,"warning-lighten-3":`#FFD460`,"warning-muted":`#674921`}},nord:{name:`nord`,dark:!0,ansi:{black:`#3B4252`,red:`#BF616A`,green:`#A3BE8C`,yellow:`#EBCB8B`,blue:`#81A1C1`,magenta:`#B48EAD`,cyan:`#88C0D0`,white:`#E5E9F0`,brightBlack:`#596377`,brightRed:`#BF616A`,brightGreen:`#A3BE8C`,brightYellow:`#EBCB8B`,brightBlue:`#81A1C1`,brightMagenta:`#B48EAD`,brightCyan:`#8FBCBB`,brightWhite:`#ECEFF4`},vars:{accent:`#B48EAD`,"accent-darken-1":`#9F7A98`,"accent-darken-2":`#8B6785`,"accent-darken-3":`#785572`,"accent-lighten-1":`#C8A1C1`,"accent-lighten-2":`#DDB6D6`,"accent-lighten-3":`#F3CAEB`,"accent-muted":`#564F60`,background:`#2E3440`,"background-darken-1":`#1E242F`,"background-darken-2":`#0E141F`,"background-darken-3":`#000010`,"background-lighten-1":`#3E4451`,"background-lighten-2":`#505663`,"background-lighten-3":`#626875`,"block-cursor-background":`#88C0D0`,"block-cursor-blurred-background":`#88C0D04C`,"block-cursor-blurred-foreground":`#D8DEE9`,"block-cursor-foreground":`#2E3440`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#88C0D0`,"border-blurred":`#353C4C`,"button-color-foreground":`#2E3440`,"button-foreground":`#D8DEE9`,error:`#BE616A`,"error-darken-1":`#A94D57`,"error-darken-2":`#933A46`,"error-darken-3":`#7E2735`,"error-lighten-1":`#D4747C`,"error-lighten-2":`#EB8890`,"error-lighten-3":`#FF9CA3`,"error-muted":`#59414C`,"footer-background":`#434C5E`,"footer-description-background":`#00000000`,"footer-description-foreground":`#D8DEE9`,"footer-foreground":`#D8DEE9`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#88C0D0`,foreground:`#D8DEE9`,"foreground-darken-1":`#C3C9D3`,"foreground-darken-2":`#AEB4BF`,"foreground-darken-3":`#9AA0AA`,"foreground-disabled":`#D8DEE960`,"foreground-lighten-1":`#EDF3FE`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#D8DEE999`,"input-cursor-background":`#D8DEE9`,"input-cursor-foreground":`#2E3440`,"input-selection-background":`#81A1C159`,"link-background":`#00000000`,"link-background-hover":`#88C0D0`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#88C0D0`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#88C0D0`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#88C0D0`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#D8DEE9`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#D8DEE9`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#D8DEE999`,panel:`#434C5E`,"panel-darken-1":`#313A4C`,"panel-darken-2":`#212A3A`,"panel-darken-3":`#111B2A`,"panel-lighten-1":`#545D70`,"panel-lighten-2":`#677083`,"panel-lighten-3":`#798396`,primary:`#88C0D0`,"primary-background":`#58646E`,"primary-background-darken-1":`#495661`,"primary-background-darken-2":`#3B4955`,"primary-background-darken-3":`#3B4955`,"primary-background-lighten-1":`#67717B`,"primary-background-lighten-2":`#757F88`,"primary-background-lighten-3":`#848D94`,"primary-darken-1":`#73ABBB`,"primary-darken-2":`#5F97A6`,"primary-darken-3":`#4B8393`,"primary-lighten-1":`#9CD4E5`,"primary-lighten-2":`#B1EAFA`,"primary-lighten-3":`#C6FFFF`,"primary-muted":`#495E6B`,scrollbar:`#48626F`,"scrollbar-active":`#88C0D0`,"scrollbar-background":`#1E242F`,"scrollbar-background-active":`#1E242F`,"scrollbar-background-hover":`#1E242F`,"scrollbar-corner-color":`#1E242F`,"scrollbar-hover":`#53727F`,secondary:`#81A1C1`,"secondary-background":`#57606C`,"secondary-background-darken-1":`#48525F`,"secondary-background-darken-2":`#3A4453`,"secondary-background-darken-3":`#3A4453`,"secondary-background-lighten-1":`#666E79`,"secondary-background-lighten-2":`#757C86`,"secondary-background-lighten-3":`#838A93`,"secondary-darken-1":`#6D8DAC`,"secondary-darken-2":`#597A98`,"secondary-darken-3":`#466784`,"secondary-lighten-1":`#95B5D5`,"secondary-lighten-2":`#A9C9EB`,"secondary-lighten-3":`#BEDEFF`,"secondary-muted":`#465466`,success:`#A3BE8C`,"success-darken-1":`#8FA978`,"success-darken-2":`#7B9565`,"success-darken-3":`#688253`,"success-lighten-1":`#B7D29F`,"success-lighten-2":`#CCE8B4`,"success-lighten-3":`#E1FDC8`,"success-muted":`#515D56`,surface:`#3B4252`,"surface-active":`#484F60`,"surface-darken-1":`#2A3140`,"surface-darken-2":`#1A212F`,"surface-darken-3":`#0A1120`,"surface-lighten-1":`#4C5364`,"surface-lighten-2":`#5E6576`,"surface-lighten-3":`#707889`,text:`#FFFFFFDD`,"text-accent":`#CDB4C8`,"text-disabled":`#FFFFFF60`,"text-error":`#D4969C`,"text-muted":`#FFFFFF99`,"text-primary":`#B0D5DF`,"text-secondary":`#ABC0D6`,"text-success":`#C2D4B3`,"text-warning":`#F1DCB2`,warning:`#EACB8B`,"warning-darken-1":`#D5B677`,"warning-darken-2":`#BFA264`,"warning-darken-3":`#AA8E51`,"warning-lighten-1":`#FFE09E`,"warning-lighten-2":`#FFF5B3`,"warning-lighten-3":`#FFFFC8`,"warning-muted":`#666156`}},"rose-pine":{name:`rose-pine`,dark:!0,ansi:{black:`#26233A`,red:`#EB6F92`,green:`#31748F`,yellow:`#F6C177`,blue:`#9CCFD8`,magenta:`#C4A7E7`,cyan:`#EBBCBA`,white:`#E0DEF4`,brightBlack:`#6E6A86`,brightRed:`#EB6F92`,brightGreen:`#31748F`,brightYellow:`#F6C177`,brightBlue:`#9CCFD8`,brightMagenta:`#C4A7E7`,brightCyan:`#EBBCBA`,brightWhite:`#E0DEF4`},vars:{accent:`#EBBCBA`,"accent-darken-1":`#D5A7A5`,"accent-darken-2":`#C09391`,"accent-darken-3":`#AB807E`,"accent-lighten-1":`#FFD0CE`,"accent-lighten-2":`#FFE5E3`,"accent-lighten-3":`#FFFBF9`,"accent-muted":`#584851`,background:`#191724`,"background-darken-1":`#060015`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#282634`,"background-lighten-2":`#383644`,"background-lighten-3":`#4A4756`,"block-cursor-background":`#C4A7E7`,"block-cursor-blurred-background":`#C4A7E74C`,"block-cursor-blurred-foreground":`#E0DEF4`,"block-cursor-foreground":`#191724`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#524F67`,"border-blurred":`#6E6A86`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#E0DEF4`,error:`#EA6F92`,"error-darken-1":`#D45A7E`,"error-darken-2":`#BE466B`,"error-darken-3":`#A83159`,"error-lighten-1":`#FF83A5`,"error-lighten-2":`#FF98BA`,"error-lighten-3":`#FFADCE`,"error-muted":`#583145`,"footer-background":`#26233A`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0DEF4`,"footer-foreground":`#E0DEF4`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#EBBCBA`,foreground:`#E0DEF4`,"foreground-darken-1":`#CAC9DE`,"foreground-darken-2":`#B6B4C9`,"foreground-darken-3":`#A2A0B4`,"foreground-disabled":`#E0DEF460`,"foreground-lighten-1":`#F5F3FF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E0DEF499`,"input-cursor-background":`#F4EDE8`,"input-cursor-foreground":`#191724`,"input-selection-background":`#403D52`,"link-background":`#00000000`,"link-background-hover":`#C4A7E7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#C4A7E7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#C4A7E7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#C4A7E7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0DEF4`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0DEF4`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E0DEF499`,panel:`#26233A`,"panel-darken-1":`#161329`,"panel-darken-2":`#04001A`,"panel-darken-3":`#000008`,"panel-lighten-1":`#36324B`,"panel-lighten-2":`#47435D`,"panel-lighten-3":`#59556F`,primary:`#C4A7E7`,"primary-background":`#504B5D`,"primary-background-darken-1":`#413B4F`,"primary-background-darken-2":`#322C41`,"primary-background-darken-3":`#322C41`,"primary-background-lighten-1":`#605B6B`,"primary-background-lighten-2":`#6F6B7A`,"primary-background-lighten-3":`#7E7B88`,"primary-darken-1":`#AF93D1`,"primary-darken-2":`#9A7FBC`,"primary-darken-3":`#866CA8`,"primary-lighten-1":`#D9BBFC`,"primary-lighten-2":`#EED0FF`,"primary-lighten-3":`#FFE5FF`,"primary-muted":`#4C425E`,scrollbar:`#524269`,"scrollbar-active":`#C4A7E7`,"scrollbar-background":`#060015`,"scrollbar-background-active":`#060015`,"scrollbar-background-hover":`#060015`,"scrollbar-corner-color":`#060015`,"scrollbar-hover":`#65537E`,secondary:`#31748F`,"secondary-background":`#3E4452`,"secondary-background-darken-1":`#2D3443`,"secondary-background-darken-2":`#1C2434`,"secondary-background-darken-3":`#1C2434`,"secondary-background-lighten-1":`#4F5561`,"secondary-background-lighten-2":`#606570`,"secondary-background-lighten-3":`#717680`,"secondary-darken-1":`#17617B`,"secondary-darken-2":`#004F68`,"secondary-darken-3":`#003E56`,"secondary-lighten-1":`#4687A2`,"secondary-lighten-2":`#5B9AB7`,"secondary-lighten-3":`#70AECB`,"secondary-muted":`#203244`,success:`#9CCFD8`,"success-darken-1":`#87BAC3`,"success-darken-2":`#73A5AE`,"success-darken-3":`#60929A`,"success-lighten-1":`#B0E4ED`,"success-lighten-2":`#C5F9FF`,"success-lighten-3":`#DAFFFF`,"success-muted":`#404E5A`,surface:`#1F1D2E`,"surface-active":`#2B293B`,"surface-darken-1":`#100B1E`,"surface-darken-2":`#00000E`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2F2C3E`,"surface-lighten-2":`#3F3D4F`,"surface-lighten-3":`#514E61`,text:`#FFFFFFDD`,"text-accent":`#F1D2D1`,"text-disabled":`#FFFFFF60`,"text-error":`#F19FB7`,"text-muted":`#FFFFFF99`,"text-primary":`#D8C4EF`,"text-secondary":`#77A3B5`,"text-success":`#BDDFE5`,"text-warning":`#F9D6A5`,warning:`#F5C177`,"warning-darken-1":`#DFAC63`,"warning-darken-2":`#C99850`,"warning-darken-3":`#B3853E`,"warning-lighten-1":`#FFD58A`,"warning-lighten-2":`#FFEB9E`,"warning-lighten-3":`#FFFFB3`,"warning-muted":`#5B4A3C`}},"rose-pine-dawn":{name:`rose-pine-dawn`,dark:!1,ansi:{black:`#F2E9E1`,red:`#B4637A`,green:`#286983`,yellow:`#EA9D34`,blue:`#56949F`,magenta:`#907AA9`,cyan:`#D7827E`,white:`#575279`,brightBlack:`#9893A5`,brightRed:`#B4637A`,brightGreen:`#286983`,brightYellow:`#EA9D34`,brightBlue:`#56949F`,brightMagenta:`#907AA9`,brightCyan:`#D7827E`,brightWhite:`#575279`},vars:{accent:`#D6827E`,"accent-darken-1":`#C16E6B`,"accent-darken-2":`#AB5B58`,"accent-darken-3":`#964847`,"accent-lighten-1":`#ED9591`,"accent-lighten-2":`#FFAAA5`,"accent-lighten-3":`#FFBEB9`,"accent-muted":`#EFD1CB`,background:`#FAF4ED`,"background-darken-1":`#E4DED7`,"background-darken-2":`#CFC9C2`,"background-darken-3":`#BAB5AE`,"background-lighten-1":`#FFFFFF`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#575279`,"block-cursor-blurred-background":`#907AA94C`,"block-cursor-blurred-foreground":`#575279`,"block-cursor-foreground":`#FAF4ED`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#CECACD`,"border-blurred":`#9893A5`,"button-color-foreground":`#000000DD`,"button-foreground":`#575279`,error:`#B4637A`,"error-darken-1":`#9E5067`,"error-darken-2":`#8A3D55`,"error-darken-3":`#752A43`,"error-lighten-1":`#C9768D`,"error-lighten-2":`#DF8AA0`,"error-lighten-3":`#F59EB5`,"error-muted":`#E5C8CA`,"footer-background":`#F2E9E1`,"footer-description-background":`#00000000`,"footer-description-foreground":`#575279`,"footer-foreground":`#575279`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#D7827E`,foreground:`#575279`,"foreground-darken-1":`#444066`,"foreground-darken-2":`#332F53`,"foreground-darken-3":`#222042`,"foreground-disabled":`#57527960`,"foreground-lighten-1":`#69648C`,"foreground-lighten-2":`#7C76A0`,"foreground-lighten-3":`#9089B4`,"foreground-muted":`#57527999`,"input-cursor-background":`#575279`,"input-cursor-foreground":`#FAF4ED`,"input-selection-background":`#DFDAD9`,"link-background":`#00000000`,"link-background-hover":`#907AA9`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#907AA9`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#907AA9`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#907AA9`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#575279`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#575279`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#57527999`,panel:`#F2E9E1`,"panel-darken-1":`#DCD3CB`,"panel-darken-2":`#C7BFB7`,"panel-darken-3":`#B3AAA3`,"panel-lighten-1":`#FFFEF6`,"panel-lighten-2":`#FFFFFF`,"panel-lighten-3":`#FFFFFF`,primary:`#907AA9`,"primary-background":`#907AA9`,"primary-background-darken-1":`#7C6795`,"primary-background-darken-2":`#695481`,"primary-background-darken-3":`#56436E`,"primary-background-lighten-1":`#A48DBD`,"primary-background-lighten-2":`#B8A1D2`,"primary-background-lighten-3":`#CDB5E7`,"primary-darken-1":`#7C6795`,"primary-darken-2":`#695481`,"primary-darken-3":`#56436E`,"primary-lighten-1":`#A48DBD`,"primary-lighten-2":`#B8A1D2`,"primary-lighten-3":`#CDB5E7`,"primary-muted":`#DACFD8`,scrollbar:`#C2B6C4`,"scrollbar-active":`#907AA9`,"scrollbar-background":`#E4DED7`,"scrollbar-background-active":`#E4DED7`,"scrollbar-background-hover":`#E4DED7`,"scrollbar-corner-color":`#E4DED7`,"scrollbar-hover":`#BAACC0`,secondary:`#286983`,"secondary-background":`#286983`,"secondary-background-darken-1":`#0A566F`,"secondary-background-darken-2":`#00455D`,"secondary-background-darken-3":`#00344B`,"secondary-background-lighten-1":`#3E7B96`,"secondary-background-lighten-2":`#538FAA`,"secondary-background-lighten-3":`#67A2BE`,"secondary-darken-1":`#0A566F`,"secondary-darken-2":`#00455D`,"secondary-darken-3":`#00344B`,"secondary-lighten-1":`#3E7B96`,"secondary-lighten-2":`#538FAA`,"secondary-lighten-3":`#67A2BE`,"secondary-muted":`#BBCACD`,success:`#56949F`,"success-darken-1":`#41808B`,"success-darken-2":`#2D6D78`,"success-darken-3":`#155B65`,"success-lighten-1":`#6AA7B3`,"success-lighten-2":`#7EBCC7`,"success-lighten-3":`#92D1DC`,"success-muted":`#C8D7D5`,surface:`#FFFAF3`,"surface-active":`#FFFFFF`,"surface-darken-1":`#E9E4DD`,"surface-darken-2":`#D4CFC8`,"surface-darken-3":`#BFBAB4`,"surface-lighten-1":`#FFFFFF`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#8D5553`,"text-disabled":`#00000060`,"text-error":`#764150`,"text-muted":`#00000099`,"text-primary":`#5F506F`,"text-secondary":`#1A4556`,"text-success":`#386168`,"text-warning":`#9A6722`,warning:`#E99D34`,"warning-darken-1":`#D2891D`,"warning-darken-2":`#BC7600`,"warning-darken-3":`#A56300`,"warning-lighten-1":`#FFB148`,"warning-lighten-2":`#FFC55C`,"warning-lighten-3":`#FFDA70`,"warning-muted":`#F5D9B5`}},"rose-pine-moon":{name:`rose-pine-moon`,dark:!0,ansi:{black:`#393552`,red:`#EB6F92`,green:`#3E8FB0`,yellow:`#F6C177`,blue:`#9CCFD8`,magenta:`#C4A7E7`,cyan:`#EA9A97`,white:`#E0DEF4`,brightBlack:`#6E6A86`,brightRed:`#EB6F92`,brightGreen:`#3E8FB0`,brightYellow:`#F6C177`,brightBlue:`#9CCFD8`,brightMagenta:`#C4A7E7`,brightCyan:`#EA9A97`,brightWhite:`#E0DEF4`},vars:{accent:`#EA9A97`,"accent-darken-1":`#D48683`,"accent-darken-2":`#BE7270`,"accent-darken-3":`#A95F5E`,"accent-lighten-1":`#FFAEAA`,"accent-lighten-2":`#FFC3BF`,"accent-lighten-3":`#FFD8D4`,"accent-muted":`#5E4553`,background:`#232136`,"background-darken-1":`#131125`,"background-darken-2":`#000017`,"background-darken-3":`#000001`,"background-lighten-1":`#333046`,"background-lighten-2":`#444158`,"background-lighten-3":`#56526A`,"block-cursor-background":`#C4A7E7`,"block-cursor-blurred-background":`#C4A7E74C`,"block-cursor-blurred-foreground":`#E0DEF4`,"block-cursor-foreground":`#232136`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#56526E`,"border-blurred":`#6E6A86`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#E0DEF4`,error:`#EA6F92`,"error-darken-1":`#D45A7E`,"error-darken-2":`#BE466B`,"error-darken-3":`#A83159`,"error-lighten-1":`#FF83A5`,"error-lighten-2":`#FF98BA`,"error-lighten-3":`#FFADCE`,"error-muted":`#5F3851`,"footer-background":`#393552`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0DEF4`,"footer-foreground":`#E0DEF4`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#EA9A97`,foreground:`#E0DEF4`,"foreground-darken-1":`#CAC9DE`,"foreground-darken-2":`#B6B4C9`,"foreground-darken-3":`#A2A0B4`,"foreground-disabled":`#E0DEF460`,"foreground-lighten-1":`#F5F3FF`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E0DEF499`,"input-cursor-background":`#F4EDE8`,"input-cursor-foreground":`#232136`,"input-selection-background":`#44415A`,"link-background":`#00000000`,"link-background-hover":`#C4A7E7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#C4A7E7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#C4A7E7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#C4A7E7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0DEF4`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0DEF4`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E0DEF499`,panel:`#393552`,"panel-darken-1":`#282440`,"panel-darken-2":`#17152F`,"panel-darken-3":`#080020`,"panel-lighten-1":`#4A4564`,"panel-lighten-2":`#5C5776`,"panel-lighten-3":`#6F6989`,primary:`#C4A7E7`,"primary-background":`#58536A`,"primary-background-darken-1":`#49445D`,"primary-background-darken-2":`#3B3550`,"primary-background-darken-3":`#3B3550`,"primary-background-lighten-1":`#676277`,"primary-background-lighten-2":`#757184`,"primary-background-lighten-3":`#848091`,"primary-darken-1":`#AF93D1`,"primary-darken-2":`#9A7FBC`,"primary-darken-3":`#866CA8`,"primary-lighten-1":`#D9BBFC`,"primary-lighten-2":`#EED0FF`,"primary-lighten-3":`#FFE5FF`,"primary-muted":`#53496B`,scrollbar:`#594D72`,"scrollbar-active":`#C4A7E7`,"scrollbar-background":`#131125`,"scrollbar-background-active":`#131125`,"scrollbar-background-hover":`#131125`,"scrollbar-corner-color":`#131125`,"scrollbar-hover":`#6B5C86`,secondary:`#3E8FB0`,"secondary-background":`#474F63`,"secondary-background-darken-1":`#374055`,"secondary-background-darken-2":`#273148`,"secondary-background-darken-3":`#273148`,"secondary-background-lighten-1":`#575F71`,"secondary-background-lighten-2":`#676E7E`,"secondary-background-lighten-3":`#787E8C`,"secondary-darken-1":`#237B9B`,"secondary-darken-2":`#006888`,"secondary-darken-3":`#005674`,"secondary-lighten-1":`#54A2C4`,"secondary-lighten-2":`#6AB7D9`,"secondary-lighten-3":`#80CBEE`,"secondary-muted":`#2B425A`,success:`#9CCFD8`,"success-darken-1":`#87BAC3`,"success-darken-2":`#73A5AE`,"success-darken-3":`#60929A`,"success-lighten-1":`#B0E4ED`,"success-lighten-2":`#C5F9FF`,"success-lighten-3":`#DAFFFF`,"success-muted":`#475566`,surface:`#2A273F`,"surface-active":`#37334C`,"surface-darken-1":`#19172E`,"surface-darken-2":`#0A021E`,"surface-darken-3":`#00000F`,"surface-lighten-1":`#3A3750`,"surface-lighten-2":`#4C4862`,"surface-lighten-3":`#5E5975`,text:`#FFFFFFDD`,"text-accent":`#F1BCBA`,"text-disabled":`#FFFFFF60`,"text-error":`#F19FB7`,"text-muted":`#FFFFFF99`,"text-primary":`#D8C4EF`,"text-secondary":`#7FB5CA`,"text-success":`#BDDFE5`,"text-warning":`#F9D6A5`,warning:`#F5C177`,"warning-darken-1":`#DFAC63`,"warning-darken-2":`#C99850`,"warning-darken-3":`#B3853E`,"warning-lighten-1":`#FFD58A`,"warning-lighten-2":`#FFEB9E`,"warning-lighten-3":`#FFFFB3`,"warning-muted":`#625149`}},"solarized-dark":{name:`solarized-dark`,dark:!0,ansi:{black:`#073642`,red:`#DC322F`,green:`#859900`,yellow:`#B58900`,blue:`#268BD2`,magenta:`#D33682`,cyan:`#2AA198`,white:`#EEE8D5`,brightBlack:`#335E69`,brightRed:`#CB4B16`,brightGreen:`#586E75`,brightYellow:`#657B83`,brightBlue:`#839496`,brightMagenta:`#6C71C4`,brightCyan:`#93A1A1`,brightWhite:`#FDF6E3`},vars:{accent:`#6C71C4`,"accent-darken-1":`#575EAF`,"accent-darken-2":`#424C9A`,"accent-darken-3":`#2D3B87`,"accent-lighten-1":`#8083D9`,"accent-lighten-2":`#9597EE`,"accent-lighten-3":`#AAABFF`,"accent-muted":`#204060`,background:`#002B36`,"background-darken-1":`#001B25`,"background-darken-2":`#000A17`,"background-darken-3":`#000000`,"background-lighten-1":`#143B46`,"background-lighten-2":`#274C58`,"background-lighten-3":`#3A5E6A`,"block-cursor-background":`#268BD2`,"block-cursor-blurred-background":`#268BD24C`,"block-cursor-blurred-foreground":`#839496`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#268BD2`,"border-blurred":`#00303C`,"button-color-foreground":`#FDF6E3`,"button-foreground":`#839496`,error:`#DB322F`,"error-darken-1":`#C3121E`,"error-darken-2":`#AB000D`,"error-darken-3":`#940000`,"error-lighten-1":`#F44940`,"error-lighten-2":`#FF6052`,"error-lighten-3":`#FF7564`,"error-muted":`#422D33`,"footer-background":`#268BD2`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FDF6E3`,"footer-foreground":`#839496`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FDF6E3`,foreground:`#839496`,"foreground-darken-1":`#6F8082`,"foreground-darken-2":`#5D6D6F`,"foreground-darken-3":`#4B5B5D`,"foreground-disabled":`#83949660`,"foreground-lighten-1":`#96A7A9`,"foreground-lighten-2":`#AABCBE`,"foreground-lighten-3":`#BED0D3`,"foreground-muted":`#83949699`,"input-cursor-background":`#839496`,"input-cursor-foreground":`#002B36`,"input-selection-background":`#073642`,"link-background":`#00000000`,"link-background-hover":`#268BD2`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#268BD2`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#268BD2`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#268BD2`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#839496`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#839496`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#83949699`,panel:`#073642`,"panel-darken-1":`#002531`,"panel-darken-2":`#001721`,"panel-darken-3":`#000112`,"panel-lighten-1":`#1D4653`,"panel-lighten-2":`#305865`,"panel-lighten-3":`#436A78`,primary:`#268BD2`,"primary-background":`#2A5667`,"primary-background-darken-1":`#17475A`,"primary-background-darken-2":`#05394D`,"primary-background-darken-3":`#05394D`,"primary-background-lighten-1":`#3D6575`,"primary-background-lighten-2":`#507482`,"primary-background-lighten-3":`#62838F`,"primary-darken-1":`#0077BD`,"primary-darken-2":`#0065A8`,"primary-darken-3":`#005394`,"primary-lighten-1":`#459EE7`,"primary-lighten-2":`#5FB2FD`,"primary-lighten-3":`#77C7FF`,"primary-muted":`#0B4764`,scrollbar:`#0F476A`,"scrollbar-active":`#268BD2`,"scrollbar-background":`#001B25`,"scrollbar-background-active":`#001B25`,"scrollbar-background-hover":`#001B25`,"scrollbar-corner-color":`#001B25`,"scrollbar-hover":`#13537B`,secondary:`#2AA198`,"secondary-background":`#2B5960`,"secondary-background-darken-1":`#184A52`,"secondary-background-darken-2":`#063C44`,"secondary-background-darken-3":`#063C44`,"secondary-background-lighten-1":`#3E676E`,"secondary-background-lighten-2":`#50767C`,"secondary-background-lighten-3":`#63858A`,"secondary-darken-1":`#008C84`,"secondary-darken-2":`#007971`,"secondary-darken-3":`#00665F`,"secondary-lighten-1":`#44B5AB`,"secondary-lighten-2":`#5BCAC0`,"secondary-lighten-3":`#72DFD5`,"secondary-muted":`#0C4E53`,success:`#849900`,"success-darken-1":`#708500`,"success-darken-2":`#5B7200`,"success-darken-3":`#485F00`,"success-lighten-1":`#99AC22`,"success-lighten-2":`#AFC139`,"success-lighten-3":`#C4D64E`,"success-muted":`#274C25`,surface:`#073642`,"surface-active":`#19434F`,"surface-darken-1":`#002531`,"surface-darken-2":`#001721`,"surface-darken-3":`#000112`,"surface-lighten-1":`#1D4653`,"surface-lighten-2":`#305865`,"surface-lighten-3":`#436A78`,text:`#FFFFFFDD`,"text-accent":`#9DA1D8`,"text-disabled":`#FFFFFF60`,"text-error":`#E77775`,"text-muted":`#FFFFFF99`,"text-primary":`#6FB2E1`,"text-secondary":`#72C0BB`,"text-success":`#AEBB56`,"text-warning":`#DC8865`,warning:`#CA4B16`,"warning-darken-1":`#B33600`,"warning-darken-2":`#9C2000`,"warning-darken-3":`#850100`,"warning-lighten-1":`#E25F29`,"warning-lighten-2":`#FA733C`,"warning-lighten-3":`#FF874E`,"warning-muted":`#3C342C`}},"solarized-light":{name:`solarized-light`,dark:!1,ansi:{black:`#073642`,red:`#DC322F`,green:`#859900`,yellow:`#B58900`,blue:`#268BD2`,magenta:`#D33682`,cyan:`#2AA198`,white:`#BBB5A2`,brightBlack:`#002B36`,brightRed:`#CB4B16`,brightGreen:`#586E75`,brightYellow:`#657B83`,brightBlue:`#839496`,brightMagenta:`#6C71C4`,brightCyan:`#93A1A1`,brightWhite:`#FDF6E3`},vars:{accent:`#6C71C4`,"accent-darken-1":`#575EAF`,"accent-darken-2":`#424C9A`,"accent-darken-3":`#2D3B87`,"accent-lighten-1":`#8083D9`,"accent-lighten-2":`#9597EE`,"accent-lighten-3":`#AAABFF`,"accent-muted":`#D1CED9`,background:`#FDF6E3`,"background-darken-1":`#E7E0CD`,"background-darken-2":`#D2CBB9`,"background-darken-3":`#BDB6A4`,"background-lighten-1":`#FFFFF8`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#268BD2`,"block-cursor-blurred-background":`#268BD24C`,"block-cursor-blurred-foreground":`#586E75`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#268BD2`,"border-blurred":`#E6E0CE`,"button-color-foreground":`#FDF6E3`,"button-foreground":`#586E75`,error:`#DB322F`,"error-darken-1":`#C3121E`,"error-darken-2":`#AB000D`,"error-darken-3":`#940000`,"error-lighten-1":`#F44940`,"error-lighten-2":`#FF6052`,"error-lighten-3":`#FF7564`,"error-muted":`#F3BBAD`,"footer-background":`#268BD2`,"footer-description-background":`#00000000`,"footer-description-foreground":`#FDF6E3`,"footer-foreground":`#586E75`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FDF6E3`,foreground:`#586E75`,"foreground-darken-1":`#465B62`,"foreground-darken-2":`#344950`,"foreground-darken-3":`#23383F`,"foreground-disabled":`#586E7560`,"foreground-lighten-1":`#6A8088`,"foreground-lighten-2":`#7D949B`,"foreground-lighten-3":`#91A8AF`,"foreground-muted":`#586E7599`,"input-cursor-background":`#586E75`,"input-cursor-foreground":`#FDF6E3`,"input-selection-background":`#459EE766`,"link-background":`#00000000`,"link-background-hover":`#268BD2`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#268BD2`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#268BD2`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#268BD2`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#586E75`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#586E75`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#586E7599`,panel:`#EEE8D5`,"panel-darken-1":`#D8D2C0`,"panel-darken-2":`#C3BEAB`,"panel-darken-3":`#AFA997`,"panel-lighten-1":`#FFFDEA`,"panel-lighten-2":`#FFFFFF`,"panel-lighten-3":`#FFFFFF`,primary:`#268BD2`,"primary-background":`#268BD2`,"primary-background-darken-1":`#0077BD`,"primary-background-darken-2":`#0065A8`,"primary-background-darken-3":`#005394`,"primary-background-lighten-1":`#459EE7`,"primary-background-lighten-2":`#5FB2FD`,"primary-background-lighten-3":`#77C7FF`,"primary-darken-1":`#0077BD`,"primary-darken-2":`#0065A8`,"primary-darken-3":`#005394`,"primary-lighten-1":`#459EE7`,"primary-lighten-2":`#5FB2FD`,"primary-lighten-3":`#77C7FF`,"primary-muted":`#BCD5DD`,scrollbar:`#99BECF`,"scrollbar-active":`#268BD2`,"scrollbar-background":`#E7E0CD`,"scrollbar-background-active":`#E7E0CD`,"scrollbar-background-hover":`#E7E0CD`,"scrollbar-corner-color":`#E7E0CD`,"scrollbar-hover":`#86B5CF`,secondary:`#2AA198`,"secondary-background":`#2AA198`,"secondary-background-darken-1":`#008C84`,"secondary-background-darken-2":`#007971`,"secondary-background-darken-3":`#00665F`,"secondary-background-lighten-1":`#44B5AB`,"secondary-background-lighten-2":`#5BCAC0`,"secondary-background-lighten-3":`#72DFD5`,"secondary-darken-1":`#008C84`,"secondary-darken-2":`#007971`,"secondary-darken-3":`#00665F`,"secondary-lighten-1":`#44B5AB`,"secondary-lighten-2":`#5BCAC0`,"secondary-lighten-3":`#72DFD5`,"secondary-muted":`#BDDCCC`,success:`#849900`,"success-darken-1":`#708500`,"success-darken-2":`#5B7200`,"success-darken-3":`#485F00`,"success-lighten-1":`#99AC22`,"success-lighten-2":`#AFC139`,"success-lighten-3":`#C4D64E`,"success-muted":`#D9DA9E`,surface:`#EEE8D5`,"surface-active":`#FFF9E5`,"surface-darken-1":`#D8D2C0`,"surface-darken-2":`#C3BEAB`,"surface-darken-3":`#AFA997`,"surface-lighten-1":`#FFFDEA`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#474A81`,"text-disabled":`#00000060`,"text-error":`#91211F`,"text-muted":`#00000099`,"text-primary":`#195B8A`,"text-secondary":`#1B6A64`,"text-success":`#576400`,"text-warning":`#85310E`,warning:`#CA4B16`,"warning-darken-1":`#B33600`,"warning-darken-2":`#9C2000`,"warning-darken-3":`#850100`,"warning-lighten-1":`#E25F29`,"warning-lighten-2":`#FA733C`,"warning-lighten-3":`#FF874E`,"warning-muted":`#EEC2A5`}},"svg-export":{name:`svg-export`,dark:!0,ansi:{black:`#4B4E55`,red:`#CC555A`,green:`#98A84B`,yellow:`#D0B344`,blue:`#608AB1`,magenta:`#98729F`,cyan:`#68A0B3`,white:`#C5C8C6`,brightBlack:`#9A9B99`,brightRed:`#FF2627`,brightGreen:`#00823D`,brightYellow:`#D08442`,brightBlue:`#1984E9`,brightMagenta:`#FF2C7A`,brightCyan:`#398280`,brightWhite:`#FDFDC5`},vars:{accent:`#56B6C2`,"accent-darken-1":`#3EA1AD`,"accent-darken-2":`#238D99`,"accent-darken-3":`#007A85`,"accent-lighten-1":`#6CCAD6`,"accent-lighten-2":`#81DFEC`,"accent-lighten-3":`#97F5FF`,"accent-muted":`#365356`,background:`#292929`,"background-darken-1":`#191919`,"background-darken-2":`#050505`,"background-darken-3":`#000000`,"background-lighten-1":`#393939`,"background-lighten-2":`#4A4A4A`,"background-lighten-3":`#5C5C5C`,"block-cursor-background":`#61AFEF`,"block-cursor-blurred-background":`#61AFEF4C`,"block-cursor-blurred-foreground":`#C5C8C6`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#61AFEF`,"border-blurred":`#191919`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#C5C8C6`,error:`#CB555A`,"error-darken-1":`#B54048`,"error-darken-2":`#9F2C37`,"error-darken-3":`#891427`,"error-lighten-1":`#E2686C`,"error-lighten-2":`#F97D7F`,"error-lighten-3":`#FF9192`,"error-muted":`#593637`,"footer-background":`#2C343A`,"footer-description-background":`#00000000`,"footer-description-foreground":`#C5C8C6`,"footer-foreground":`#C5C8C6`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#56B6C2`,foreground:`#C5C8C6`,"foreground-darken-1":`#B0B3B1`,"foreground-darken-2":`#9C9F9D`,"foreground-darken-3":`#888B89`,"foreground-disabled":`#C5C8C660`,"foreground-lighten-1":`#D9DCDA`,"foreground-lighten-2":`#EFF2F0`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#C5C8C699`,"input-cursor-background":`#C5C8C6`,"input-cursor-foreground":`#292929`,"input-selection-background":`#77C3FF66`,"link-background":`#00000000`,"link-background-hover":`#61AFEF`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#61AFEF`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#61AFEF`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#61AFEF`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#C5C8C6`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#C5C8C6`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#C5C8C699`,panel:`#2C343A`,"panel-darken-1":`#1C2429`,"panel-darken-2":`#0C141A`,"panel-darken-3":`#000007`,"panel-lighten-1":`#3C444B`,"panel-lighten-2":`#4D565C`,"panel-lighten-3":`#5F686F`,primary:`#61AFEF`,"primary-background":`#4F5A61`,"primary-background-darken-1":`#404B53`,"primary-background-darken-2":`#313D46`,"primary-background-darken-3":`#313D46`,"primary-background-lighten-1":`#5F686F`,"primary-background-lighten-2":`#6E777D`,"primary-background-lighten-3":`#7E858B`,"primary-darken-1":`#489BD9`,"primary-darken-2":`#2C87C4`,"primary-darken-3":`#0074AF`,"primary-lighten-1":`#77C3FF`,"primary-lighten-2":`#8ED8FF`,"primary-lighten-3":`#A4EDFF`,"primary-muted":`#395164`,scrollbar:`#35556E`,"scrollbar-active":`#61AFEF`,"scrollbar-background":`#191919`,"scrollbar-background-active":`#191919`,"scrollbar-background-hover":`#191919`,"scrollbar-corner-color":`#191919`,"scrollbar-hover":`#3D6484`,secondary:`#C678DD`,"secondary-background":`#5C5260`,"secondary-background-darken-1":`#4E4352`,"secondary-background-darken-2":`#403444`,"secondary-background-darken-3":`#403444`,"secondary-background-lighten-1":`#6A616E`,"secondary-background-lighten-2":`#79707C`,"secondary-background-lighten-3":`#87808A`,"secondary-darken-1":`#B064C7`,"secondary-darken-2":`#9B50B3`,"secondary-darken-3":`#873D9E`,"secondary-lighten-1":`#DB8CF2`,"secondary-lighten-2":`#F1A0FF`,"secondary-lighten-3":`#FFB5FF`,"secondary-muted":`#58405F`,success:`#98C379`,"success-darken-1":`#83AE65`,"success-darken-2":`#709A53`,"success-darken-3":`#5C8641`,"success-lighten-1":`#ACD78C`,"success-lighten-2":`#C1EDA0`,"success-lighten-3":`#D6FFB4`,"success-muted":`#4A5741`,surface:`#1E1E1E`,"surface-active":`#2A2A2A`,"surface-darken-1":`#0D0D0D`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2D2D2D`,"surface-lighten-2":`#3E3E3E`,"surface-lighten-3":`#4F4F4F`,text:`#FFFFFFDD`,"text-accent":`#8FCED6`,"text-disabled":`#FFFFFF60`,"text-error":`#DD8E92`,"text-muted":`#FFFFFF99`,"text-primary":`#96CAF4`,"text-secondary":`#D9A5E8`,"text-success":`#BBD7A6`,"text-warning":`#EDD5A7`,warning:`#E4C07B`,"warning-darken-1":`#CFAB67`,"warning-darken-2":`#B99754`,"warning-darken-3":`#A48442`,"warning-lighten-1":`#FBD48E`,"warning-lighten-2":`#FFE9A2`,"warning-lighten-3":`#FFFFB7`,"warning-muted":`#615641`}},"textual-ansi":{name:`textual-ansi`,dark:!0,ansi:Md,vars:{accent:`#0000FF`,"accent-darken-1":`#0000FF`,"accent-darken-2":`#0000FF`,"accent-darken-3":`#0000FF`,"accent-lighten-1":`#0000FF`,"accent-lighten-2":`#0000FF`,"accent-lighten-3":`#0000FF`,"accent-muted":`#0178D4`,background:`#121212`,"background-darken-1":`#121212`,"background-darken-2":`#121212`,"background-darken-3":`#121212`,"background-lighten-1":`#121212`,"background-lighten-2":`#121212`,"background-lighten-3":`#121212`,"block-cursor-background":`#000080`,"block-cursor-blurred-background":`#0000804C`,"block-cursor-blurred-foreground":`#E0E0E0`,"block-cursor-foreground":`#E0E0E0`,"block-hover-background":`#00000019`,boost:`#0178D4`,"boost-darken-1":`#0178D4`,"boost-darken-2":`#0178D4`,"boost-darken-3":`#0178D4`,"boost-lighten-1":`#0178D4`,"boost-lighten-2":`#0178D4`,"boost-lighten-3":`#0178D4`,border:`#0000FF`,"border-blurred":`#000080`,"button-color-foreground":`#E0E0E0`,"button-foreground":`#E0E0E0`,error:`#800000`,"error-darken-1":`#800000`,"error-darken-2":`#800000`,"error-darken-3":`#800000`,"error-lighten-1":`#800000`,"error-lighten-2":`#800000`,"error-lighten-3":`#800000`,"error-muted":`#0178D4`,"footer-background":`#121212`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0E0E0`,"footer-foreground":`#E0E0E0`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#0000FF`,foreground:`#E0E0E0`,"foreground-darken-1":`#E0E0E0`,"foreground-darken-2":`#E0E0E0`,"foreground-darken-3":`#E0E0E0`,"foreground-disabled":`#00000060`,"foreground-lighten-1":`#E0E0E0`,"foreground-lighten-2":`#E0E0E0`,"foreground-lighten-3":`#E0E0E0`,"foreground-muted":`#00000099`,"input-cursor-background":`#121212`,"input-cursor-foreground":`#E0E0E0`,"input-selection-background":`#000080`,"link-background":`#00000000`,"link-background-hover":`#000080`,"link-color":`#E0E0E0`,"link-color-hover":`#0178D4`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#000080`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#000080`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#000080`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0E0E0`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0E0E0`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#00000099`,panel:`#121212`,"panel-darken-1":`#121212`,"panel-darken-2":`#121212`,"panel-darken-3":`#121212`,"panel-lighten-1":`#121212`,"panel-lighten-2":`#121212`,"panel-lighten-3":`#121212`,primary:`#000080`,"primary-background":`#000080`,"primary-background-darken-1":`#000080`,"primary-background-darken-2":`#000080`,"primary-background-darken-3":`#000080`,"primary-background-lighten-1":`#000080`,"primary-background-lighten-2":`#000080`,"primary-background-lighten-3":`#000080`,"primary-darken-1":`#000080`,"primary-darken-2":`#000080`,"primary-darken-3":`#000080`,"primary-lighten-1":`#000080`,"primary-lighten-2":`#000080`,"primary-lighten-3":`#000080`,"primary-muted":`#0178D4`,scrollbar:`#000080`,"scrollbar-active":`#000080`,"scrollbar-background":`#121212`,"scrollbar-background-active":`#121212`,"scrollbar-background-hover":`#121212`,"scrollbar-corner-color":`#E0E0E0`,"scrollbar-hover":`#000040`,secondary:`#008080`,"secondary-background":`#008080`,"secondary-background-darken-1":`#008080`,"secondary-background-darken-2":`#008080`,"secondary-background-darken-3":`#008080`,"secondary-background-lighten-1":`#008080`,"secondary-background-lighten-2":`#008080`,"secondary-background-lighten-3":`#008080`,"secondary-darken-1":`#008080`,"secondary-darken-2":`#008080`,"secondary-darken-3":`#008080`,"secondary-lighten-1":`#008080`,"secondary-lighten-2":`#008080`,"secondary-lighten-3":`#008080`,"secondary-muted":`#0178D4`,success:`#008000`,"success-darken-1":`#008000`,"success-darken-2":`#008000`,"success-darken-3":`#008000`,"success-lighten-1":`#008000`,"success-lighten-2":`#008000`,"success-lighten-3":`#008000`,"success-muted":`#0178D4`,surface:`#121212`,"surface-active":`#131313`,"surface-darken-1":`#121212`,"surface-darken-2":`#121212`,"surface-darken-3":`#121212`,"surface-lighten-1":`#121212`,"surface-lighten-2":`#121212`,"surface-lighten-3":`#121212`,text:`#E0E0E0`,"text-accent":`#5656FF`,"text-disabled":`#E0E0E0`,"text-error":`#AB5656`,"text-muted":`#E0E0E0`,"text-primary":`#5656AB`,"text-secondary":`#56ABAB`,"text-success":`#56AB56`,"text-warning":`#ABAB56`,warning:`#808000`,"warning-darken-1":`#808000`,"warning-darken-2":`#808000`,"warning-darken-3":`#808000`,"warning-lighten-1":`#808000`,"warning-lighten-2":`#808000`,"warning-lighten-3":`#808000`,"warning-muted":`#0178D4`}},"textual-dark":{name:`textual-dark`,dark:!0,ansi:Nd,vars:{accent:`#FEA62B`,"accent-darken-1":`#E7920D`,"accent-darken-2":`#CF7E00`,"accent-darken-3":`#B86B00`,"accent-lighten-1":`#FFBA41`,"accent-lighten-2":`#FFCF56`,"accent-lighten-3":`#FFE46B`,"accent-muted":`#593E19`,background:`#121212`,"background-darken-1":`#000000`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#212121`,"background-lighten-2":`#313131`,"background-lighten-3":`#414141`,"block-cursor-background":`#0178D4`,"block-cursor-blurred-background":`#0178D44C`,"block-cursor-blurred-foreground":`#E0E0E0`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#0178D4`,"border-blurred":`#191919`,"button-color-foreground":`#FFFFFFDD`,"button-foreground":`#E0E0E0`,error:`#B93C5B`,"error-darken-1":`#A32549`,"error-darken-2":`#8D0638`,"error-darken-3":`#780028`,"error-lighten-1":`#D0506D`,"error-lighten-2":`#E76580`,"error-lighten-3":`#FE7993`,"error-muted":`#441E27`,"footer-background":`#242F38`,"footer-description-background":`#00000000`,"footer-description-foreground":`#E0E0E0`,"footer-foreground":`#E0E0E0`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FFA62B`,foreground:`#E0E0E0`,"foreground-darken-1":`#CACACA`,"foreground-darken-2":`#B6B6B6`,"foreground-darken-3":`#A2A2A2`,"foreground-disabled":`#E0E0E060`,"foreground-lighten-1":`#F5F5F5`,"foreground-lighten-2":`#FFFFFF`,"foreground-lighten-3":`#FFFFFF`,"foreground-muted":`#E0E0E099`,"input-cursor-background":`#E0E0E0`,"input-cursor-foreground":`#121212`,"input-selection-background":`#368AE966`,"link-background":`#00000000`,"link-background-hover":`#0178D4`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#0178D4`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#0178D4`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#0178D4`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#E0E0E0`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#E0E0E0`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#E0E0E099`,panel:`#242F38`,"panel-darken-1":`#141F27`,"panel-darken-2":`#000F18`,"panel-darken-3":`#000003`,"panel-lighten-1":`#343F49`,"panel-lighten-2":`#45505A`,"panel-lighten-3":`#57626D`,primary:`#0178D4`,"primary-background":`#33424E`,"primary-background-darken-1":`#21313E`,"primary-background-darken-2":`#0F212F`,"primary-background-darken-3":`#0F212F`,"primary-background-lighten-1":`#45525D`,"primary-background-lighten-2":`#57636D`,"primary-background-lighten-3":`#69747D`,"primary-darken-1":`#0065BE`,"primary-darken-2":`#0053AA`,"primary-darken-3":`#004295`,"primary-lighten-1":`#368AE9`,"primary-lighten-2":`#539EFF`,"primary-lighten-3":`#6DB2FF`,"primary-muted":`#0C304C`,scrollbar:`#003054`,"scrollbar-active":`#0178D4`,"scrollbar-background":`#000000`,"scrollbar-background-active":`#000000`,"scrollbar-background-hover":`#000000`,"scrollbar-corner-color":`#000000`,"scrollbar-hover":`#003C6A`,secondary:`#004578`,"secondary-background":`#333B42`,"secondary-background-darken-1":`#212A31`,"secondary-background-darken-2":`#0F1921`,"secondary-background-darken-3":`#0F1921`,"secondary-background-lighten-1":`#454C52`,"secondary-background-lighten-2":`#575E63`,"secondary-background-lighten-3":`#696F74`,"secondary-darken-1":`#003465`,"secondary-darken-2":`#002452`,"secondary-darken-3":`#001541`,"secondary-lighten-1":`#23568B`,"secondary-lighten-2":`#3B689F`,"secondary-lighten-3":`#507BB3`,"secondary-muted":`#0C2130`,success:`#4EBF71`,"success-darken-1":`#36AA5E`,"success-darken-2":`#18954B`,"success-darken-3":`#008139`,"success-lighten-1":`#64D484`,"success-lighten-2":`#7AE998`,"success-lighten-3":`#8FFFAC`,"success-muted":`#24452E`,surface:`#1E1E1E`,"surface-active":`#2A2A2A`,"surface-darken-1":`#0D0D0D`,"surface-darken-2":`#000000`,"surface-darken-3":`#000000`,"surface-lighten-1":`#2D2D2D`,"surface-lighten-2":`#3E3E3E`,"surface-lighten-3":`#4F4F4F`,text:`#FFFFFFDD`,"text-accent":`#FFC473`,"text-disabled":`#FFFFFF60`,"text-error":`#D17E92`,"text-muted":`#FFFFFF99`,"text-primary":`#57A5E2`,"text-secondary":`#5684A5`,"text-success":`#8AD4A1`,"text-warning":`#FFC473`,warning:`#FEA62B`,"warning-darken-1":`#E7920D`,"warning-darken-2":`#CF7E00`,"warning-darken-3":`#B86B00`,"warning-lighten-1":`#FFBA41`,"warning-lighten-2":`#FFCF56`,"warning-lighten-3":`#FFE46B`,"warning-muted":`#593E19`}},"textual-light":{name:`textual-light`,dark:!1,ansi:{black:`#000000`,red:`#AA3731`,green:`#448C27`,yellow:`#CB9000`,blue:`#325CC0`,magenta:`#7A3E9D`,cyan:`#0083B2`,white:`#F7F7F7`,brightBlack:`#777777`,brightRed:`#F05050`,brightGreen:`#60CB00`,brightYellow:`#FFBC5D`,brightBlue:`#007ACC`,brightMagenta:`#E64CE6`,brightCyan:`#00AACB`,brightWhite:`#F7F7F7`},vars:{accent:`#FEA62B`,"accent-darken-1":`#E7920D`,"accent-darken-2":`#CF7E00`,"accent-darken-3":`#B86B00`,"accent-lighten-1":`#FFBA41`,"accent-lighten-2":`#FFCF56`,"accent-lighten-3":`#FFE46B`,"accent-muted":`#E9CEA9`,background:`#E0E0E0`,"background-darken-1":`#CACACA`,"background-darken-2":`#B6B6B6`,"background-darken-3":`#A2A2A2`,"background-lighten-1":`#F5F5F5`,"background-lighten-2":`#FFFFFF`,"background-lighten-3":`#FFFFFF`,"block-cursor-background":`#004578`,"block-cursor-blurred-background":`#0045784C`,"block-cursor-blurred-foreground":`#1F1F1F`,"block-cursor-foreground":`#000000DD`,"block-hover-background":`#00000019`,boost:`#0000000A`,"boost-darken-1":`#0000000A`,"boost-darken-2":`#0000000A`,"boost-darken-3":`#0000000A`,"boost-lighten-1":`#1616160A`,"boost-lighten-2":`#2525250A`,"boost-lighten-3":`#3535350A`,border:`#004578`,"border-blurred":`#D0D1D0`,"button-color-foreground":`#000000DD`,"button-foreground":`#1F1F1F`,error:`#B93C5B`,"error-darken-1":`#A32549`,"error-darken-2":`#8D0638`,"error-darken-3":`#780028`,"error-lighten-1":`#D0506D`,"error-lighten-2":`#E76580`,"error-lighten-3":`#FE7993`,"error-muted":`#D4AEB8`,"footer-background":`#D0D0D0`,"footer-description-background":`#00000000`,"footer-description-foreground":`#1F1F1F`,"footer-foreground":`#1F1F1F`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#0178D4`,foreground:`#1F1F1F`,"foreground-darken-1":`#0E0E0E`,"foreground-darken-2":`#000000`,"foreground-darken-3":`#000000`,"foreground-disabled":`#1F1F1F60`,"foreground-lighten-1":`#2E2E2E`,"foreground-lighten-2":`#3F3F3F`,"foreground-lighten-3":`#505050`,"foreground-muted":`#1F1F1F99`,"input-cursor-background":`#1F1F1F`,"input-cursor-foreground":`#E0E0E0`,"input-selection-background":`#23568B66`,"link-background":`#00000000`,"link-background-hover":`#004578`,"link-color":`#000000DD`,"link-color-hover":`#000000DD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#004578`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#004578`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#004578`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#1F1F1F`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#1F1F1F`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#1F1F1F99`,panel:`#D0D0D0`,"panel-darken-1":`#BBBBBB`,"panel-darken-2":`#A6A6A6`,"panel-darken-3":`#939393`,"panel-lighten-1":`#E5E5E5`,"panel-lighten-2":`#FAFAFA`,"panel-lighten-3":`#FFFFFF`,primary:`#004578`,"primary-background":`#004578`,"primary-background-darken-1":`#003465`,"primary-background-darken-2":`#002452`,"primary-background-darken-3":`#001541`,"primary-background-lighten-1":`#23568B`,"primary-background-lighten-2":`#3B689F`,"primary-background-lighten-3":`#507BB3`,"primary-darken-1":`#003465`,"primary-darken-2":`#002452`,"primary-darken-3":`#001541`,"primary-lighten-1":`#23568B`,"primary-lighten-2":`#3B689F`,"primary-lighten-3":`#507BB3`,"primary-muted":`#9CB1C0`,scrollbar:`#7994A9`,"scrollbar-active":`#004578`,"scrollbar-background":`#CACACA`,"scrollbar-background-active":`#CACACA`,"scrollbar-background-hover":`#CACACA`,"scrollbar-corner-color":`#CACACA`,"scrollbar-hover":`#6587A1`,secondary:`#0178D4`,"secondary-background":`#0178D4`,"secondary-background-darken-1":`#0065BE`,"secondary-background-darken-2":`#0053AA`,"secondary-background-darken-3":`#004295`,"secondary-background-lighten-1":`#368AE9`,"secondary-background-lighten-2":`#539EFF`,"secondary-background-lighten-3":`#6DB2FF`,"secondary-darken-1":`#0065BE`,"secondary-darken-2":`#0053AA`,"secondary-darken-3":`#004295`,"secondary-lighten-1":`#368AE9`,"secondary-lighten-2":`#539EFF`,"secondary-lighten-3":`#6DB2FF`,"secondary-muted":`#9DC0DC`,success:`#4EBF71`,"success-darken-1":`#36AA5E`,"success-darken-2":`#18954B`,"success-darken-3":`#008139`,"success-lighten-1":`#64D484`,"success-lighten-2":`#7AE998`,"success-lighten-3":`#8FFFAC`,"success-muted":`#B4D6BE`,surface:`#D8D8D8`,"surface-active":`#E8E8E8`,"surface-darken-1":`#C3C3C3`,"surface-darken-2":`#AEAEAE`,"surface-darken-3":`#9A9A9A`,"surface-lighten-1":`#EDEDED`,"surface-lighten-2":`#FFFFFF`,"surface-lighten-3":`#FFFFFF`,text:`#000000DD`,"text-accent":`#A86D1C`,"text-disabled":`#00000060`,"text-error":`#7A273C`,"text-muted":`#00000099`,"text-primary":`#002D4F`,"text-secondary":`#004F8B`,"text-success":`#337E4A`,"text-warning":`#A86D1C`,warning:`#FEA62B`,"warning-darken-1":`#E7920D`,"warning-darken-2":`#CF7E00`,"warning-darken-3":`#B86B00`,"warning-lighten-1":`#FFBA41`,"warning-lighten-2":`#FFCF56`,"warning-lighten-3":`#FFE46B`,"warning-muted":`#E9CEA9`}},"tokyo-night":{name:`tokyo-night`,dark:!0,ansi:{black:`#15161E`,red:`#F7768E`,green:`#9ECE6A`,yellow:`#E0AF68`,blue:`#7AA2F7`,magenta:`#BB9AF7`,cyan:`#7DCFFF`,white:`#A9B1D6`,brightBlack:`#414868`,brightRed:`#F7768E`,brightGreen:`#9ECE6A`,brightYellow:`#E0AF68`,brightBlue:`#7AA2F7`,brightMagenta:`#BB9AF7`,brightCyan:`#7DCFFF`,brightWhite:`#C0CAF5`},vars:{accent:`#FE9E64`,"accent-darken-1":`#E78A51`,"accent-darken-2":`#D0763E`,"accent-darken-3":`#BA632C`,"accent-lighten-1":`#FFB277`,"accent-lighten-2":`#FFC78A`,"accent-lighten-3":`#FFDC9E`,"accent-muted":`#5E4238`,background:`#1A1B26`,"background-darken-1":`#070817`,"background-darken-2":`#000000`,"background-darken-3":`#000000`,"background-lighten-1":`#292A36`,"background-lighten-2":`#3A3A47`,"background-lighten-3":`#4B4B58`,"block-cursor-background":`#BB9AF7`,"block-cursor-blurred-background":`#BB9AF74C`,"block-cursor-blurred-foreground":`#A9B1D6`,"block-cursor-foreground":`#FFFFFFDD`,"block-hover-background":`#FFFFFF19`,boost:`#FFFFFF0A`,"boost-darken-1":`#E9E9E90A`,"boost-darken-2":`#D4D4D40A`,"boost-darken-3":`#BFBFBF0A`,"boost-lighten-1":`#FFFFFF0A`,"boost-lighten-2":`#FFFFFF0A`,"boost-lighten-3":`#FFFFFF0A`,border:`#BB9AF7`,"border-blurred":`#1E2235`,"button-color-foreground":`#24283B`,"button-foreground":`#A9B1D6`,error:`#F6768E`,"error-darken-1":`#E0617A`,"error-darken-2":`#C94D68`,"error-darken-3":`#B33856`,"error-lighten-1":`#FF8AA1`,"error-lighten-2":`#FF9FB5`,"error-lighten-3":`#FFB4CA`,"error-muted":`#5C3645`,"footer-background":`#414868`,"footer-description-background":`#00000000`,"footer-description-foreground":`#A9B1D6`,"footer-foreground":`#A9B1D6`,"footer-item-background":`#00000000`,"footer-key-background":`#00000000`,"footer-key-foreground":`#FF9E64`,foreground:`#A9B1D6`,"foreground-darken-1":`#949CC1`,"foreground-darken-2":`#8189AC`,"foreground-darken-3":`#6D7698`,"foreground-disabled":`#A9B1D660`,"foreground-lighten-1":`#BDC5EB`,"foreground-lighten-2":`#D2DAFF`,"foreground-lighten-3":`#E7EFFF`,"foreground-muted":`#A9B1D699`,"input-cursor-background":`#A9B1D6`,"input-cursor-foreground":`#1A1B26`,"input-selection-background":`#D0AEFF66`,"link-background":`#00000000`,"link-background-hover":`#BB9AF7`,"link-color":`#FFFFFFDD`,"link-color-hover":`#FFFFFFDD`,"markdown-h1-background":`#00000000`,"markdown-h1-color":`#BB9AF7`,"markdown-h2-background":`#00000000`,"markdown-h2-color":`#BB9AF7`,"markdown-h3-background":`#00000000`,"markdown-h3-color":`#BB9AF7`,"markdown-h4-background":`#00000000`,"markdown-h4-color":`#A9B1D6`,"markdown-h5-background":`#00000000`,"markdown-h5-color":`#A9B1D6`,"markdown-h6-background":`#00000000`,"markdown-h6-color":`#A9B1D699`,panel:`#414868`,"panel-darken-1":`#2F3755`,"panel-darken-2":`#1E2744`,"panel-darken-3":`#0C1733`,"panel-lighten-1":`#53597A`,"panel-lighten-2":`#656B8E`,"panel-lighten-3":`#787EA1`,primary:`#BB9AF7`,"primary-background":`#504D60`,"primary-background-darken-1":`#413D52`,"primary-background-darken-2":`#322E45`,"primary-background-darken-3":`#322E45`,"primary-background-lighten-1":`#605D6E`,"primary-background-lighten-2":`#6F6C7C`,"primary-background-lighten-3":`#7E7C8A`,"primary-darken-1":`#A686E1`,"primary-darken-2":`#9173CC`,"primary-darken-3":`#7D60B7`,"primary-lighten-1":`#D0AEFF`,"primary-lighten-2":`#E5C2FF`,"primary-lighten-3":`#FBD7FF`,"primary-muted":`#4A4164`,scrollbar:`#4F4270`,"scrollbar-active":`#BB9AF7`,"scrollbar-background":`#070817`,"scrollbar-background-active":`#070817`,"scrollbar-background-hover":`#070817`,"scrollbar-corner-color":`#070817`,"scrollbar-hover":`#615187`,secondary:`#7AA2F7`,"secondary-background":`#484E60`,"secondary-background-darken-1":`#383E52`,"secondary-background-darken-2":`#282F45`,"secondary-background-darken-3":`#282F45`,"secondary-background-lighten-1":`#585D6E`,"secondary-background-lighten-2":`#686D7C`,"secondary-background-lighten-3":`#787D8A`,"secondary-darken-1":`#648EE1`,"secondary-darken-2":`#4D7BCC`,"secondary-darken-3":`#3468B7`,"secondary-lighten-1":`#8FB6FF`,"secondary-lighten-2":`#A5CAFF`,"secondary-lighten-3":`#BBDFFF`,"secondary-muted":`#364364`,success:`#9ECE6A`,"success-darken-1":`#89B956`,"success-darken-2":`#75A443`,"success-darken-3":`#619030`,"success-lighten-1":`#B2E37D`,"success-lighten-2":`#C8F891`,"success-lighten-3":`#DDFFA6`,"success-muted":`#41503A`,surface:`#24283B`,"surface-active":`#313448`,"surface-darken-1":`#14182A`,"surface-darken-2":`#00031B`,"surface-darken-3":`#000009`,"surface-lighten-1":`#34384C`,"surface-lighten-2":`#45495E`,"surface-lighten-3":`#575A70`,text:`#FFFFFFDD`,"text-accent":`#FFBE98`,"text-disabled":`#FFFFFF60`,"text-error":`#F9A4B4`,"text-muted":`#FFFFFF99`,"text-primary":`#D2BCF9`,"text-secondary":`#A7C1F9`,"text-success":`#BEDE9C`,"text-warning":`#EACA9B`,warning:`#DFAF68`,"warning-darken-1":`#C99A55`,"warning-darken-2":`#B48742`,"warning-darken-3":`#9E7430`,"warning-lighten-1":`#F6C37B`,"warning-lighten-2":`#FFD88F`,"warning-lighten-3":`#FFEDA3`,"warning-muted":`#554739`}}},lee=Object.freeze(Object.keys(Pd).sort()),uee=new el;function dee(){return lee}function fee(e){return pee(e)?uee.get(e,()=>mee(Pd[e])):null}function pee(e){return Object.hasOwn(Pd,e)}function Fd(e){let t=Pd[e],n=Id(t.vars.background,t.name,`background`),r=Ru(t.name,n),i=e=>r(Id(t.vars[e],t.name,e));return{name:t.name,dark:t.dark,bg:n,fg:i(`foreground`),primary:i(`primary`),secondary:i(`secondary`),accent:i(`accent`),success:i(`success`),warning:i(`warning`),error:i(`error`),ansi:new kl(jd.map(e=>hee(t.ansi[e],t.name,`ansi.${e}`)))}}function mee(e){let t=Object.entries(e.vars).map(([t,n])=>[t,Id(n,e.name,`var ${t}`)]);return Sd(e.name,e.dark,Object.fromEntries(t))}function Id(e,t,n){try{return iu(e)}catch(e){throw e instanceof Bl?Error(`Theme ${t}: ${n}: ${e.message}`,{cause:e}):e}}function hee(e,t,n){let r=Id(e,t,n);if(r.alpha!==1)throw Error(`Theme ${t}: ${n} has alpha in ${JSON.stringify(e)} (expected #RRGGBB)`);return r}function Ld(e){return new su(e.bg,e.fg,e.ansi,Sd(e.name,e.dark,{primary:e.primary,secondary:e.secondary,accent:e.accent,success:e.success,warning:e.warning,error:e.error,background:e.bg,foreground:e.fg}))}const gee=Ld(Fd(`default`));Ld(Fd(`svg-export`)),Ld(Fd(`monokai`)),Ld(Fd(`nord`)),Ld(Fd(`gruvbox`)),Ld(Fd(`dracula`)),Ld(Fd(`tokyo-night`)),Ld(Fd(`flexoki`)),Ld(Fd(`cyberpunk`)),Ld(Fd(`catppuccin-mocha`)),Ld(Fd(`catppuccin-latte`)),Ld(Fd(`catppuccin-frappe`)),Ld(Fd(`catppuccin-macchiato`)),Ld(Fd(`solarized-dark`)),Ld(Fd(`solarized-light`)),Ld(Fd(`rose-pine`)),Ld(Fd(`rose-pine-moon`)),Ld(Fd(`rose-pine-dawn`)),Ld(Fd(`atom-one-dark`)),Ld(Fd(`atom-one-light`)),Ld(Fd(`textual-dark`)),Ld(Fd(`textual-light`)),Ld(Fd(`textual-ansi`));const _ee=new Set([`error`,`success`,`warning`]),vee=nl(/^(?:text|on)-/);function yee(e){let t=e.replace(vee,``),n=t.indexOf(`-`);return n===-1?t:t.slice(0,n)}function bee(e){return _ee.has(yee(e))}function xee(e,t,n){if(Tu(t))return new Lu(n??e.name,e.dark,e.mapRoles(e=>e));let r={...t,hueShift:0},i=e.mapRoles((e,n)=>Iu.fromRgba(e).applyKey(bee(n)?r:t).toRgba()),a=Iu.fromRgba(i.background).l<.5;return new Lu(n??e.name,a,i)}function Rd(e,t,n,r){for(let[i,a]of[[`x1`,e],[`y1`,t],[`x2`,n],[`y2`,r]])if(!Number.isFinite(a))throw RangeError(`cubicBezier ${i} must be finite, got ${a}`);if(e<0||e>1||n<0||n>1)throw RangeError(`cubicBezier x1 and x2 must lie in [0, 1], got ${e} and ${n}`);let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c,u=e=>((o*e+a)*e+i)*e,d=e=>((l*e+c)*e+s)*e,f=e=>(3*o*e+2*a)*e+i,p=1e-9,m=e=>{let t=e;for(let n=0;n<8;n++){let n=u(t)-e;if(Math.abs(n)<p)return t;let r=f(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;for(t=e;r-n>p;)u(t)<e?n=t:r=t,t=(n+r)/2;return t};return Bd(e=>d(m(e)))}function zd(e,t=`jump-end`){let n=t===`jump-none`?2:1;if(!Number.isInteger(e)||e<n)throw RangeError(`steps(${e}, "${t}") needs a whole number of steps ≥ ${n}`);let r=t===`jump-start`||t===`start`||t===`jump-both`,i={"jump-start":e,start:e,"jump-end":e,end:e,"jump-both":e+1,"jump-none":e-1}[t],a=+!!r;return Bd(t=>Math.min(i,Math.floor(t*e)+a)/i)}const Bd=e=>t=>{let n=Math.min(1,Math.max(0,t));return n===1?1:e(n)},See=Bd(e=>e),Vd=zd(1,`jump-end`),Cee=Bd(e=>(1-Math.cos(Math.PI*e))/2),Hd=.001,Ud={stiffness:100,damping:10,mass:1};function Wd(e={}){let{stiffness:t,damping:n,mass:r}={...Ud,...e};for(let[e,i]of[[`stiffness`,t],[`damping`,n],[`mass`,r]])of(`spring ${e}`,i);let i=Math.sqrt(t/r),a=n/(2*Math.sqrt(t*r)),o=a*i,{displacement:s,seconds:c}=a<1?Kd(i,a,o):qd(i,a,o);return{seconds:c,ease:Bd(e=>1-s(e*c))}}function Gd(e,t,n){for(let r=0;r<64;r++){let r=(t+n)/2;Math.abs(e(r))>.001?t=r:n=r}return n}function Kd(e,t,n){let r=e*Math.sqrt(1-t*t),i=n/r,a=e=>Math.exp(-n*e)*(Math.cos(r*e)+i*Math.sin(r*e)),o=Math.ceil(Math.log(1/Hd)/(n*Math.PI/r));return{displacement:a,seconds:Gd(a,(o-1)*Math.PI/r,(o*Math.PI-Math.atan(1/i))/r)}}function qd(e,t,n){let{displacement:r,far:i}=t===1?Jd(e):Yd(e,t,n);return{displacement:r,seconds:Gd(r,0,i)}}function Jd(e){return{displacement:t=>Math.exp(-e*t)*(1+e*t),far:10/e}}function Yd(e,t,n){let r=Math.sqrt(t*t-1),i=e*r,a=e/(t+r),o=n+i,s=n/i;return{displacement:e=>((1+s)*Math.exp(-a*e)+(1-s)*Math.exp(-o*e))/2,far:Math.log((1+s)/(2*Hd))/a}}const Xd=[{until:1/2.75,centre:0,floor:0},{until:2/2.75,centre:1.5/2.75,floor:.75},{until:2.5/2.75,centre:2.25/2.75,floor:.9375},{until:1/0,centre:2.625/2.75,floor:.984375}],Zd=Bd(e=>{let t=Xd.find(({until:t})=>e<t);return 7.5625*(e-t.centre)**2+t.floor}),Qd=1.70158,$d=Bd(e=>e**3+Qd*e**2*(e-1)),ef=Bd(e=>{let t=e-1;return 1+t**3+Qd*t**2*(t+1)}),tf=2*Math.PI/3,nf=Bd(e=>2**(-10*e)*Math.sin((10*e-.75)*tf)+1),rf={linear:See,ease:Rd(.25,.1,.25,1),"ease-in":Rd(.42,0,1,1),"ease-out":Rd(0,0,.58,1),"ease-in-out":Rd(.42,0,.58,1),"step-start":zd(1,`jump-start`),"step-end":Vd,step:Vd,sine:Cee,spring:Wd().ease,bounce:Zd,"back-in":$d,"back-out":ef,elastic:nf};function af(e){if(!Object.hasOwn(rf,e))throw RangeError(`unknown ease ${JSON.stringify(e)}; expected one of `+Object.keys(rf).map(e=>JSON.stringify(e)).join(`, `));return rf[e]}function of(e,t,n=``){if(!(Number.isFinite(t)&&t>0))throw RangeError(`${e} must be a positive number${n}, got ${t}`)}function sf(e,t){of(e,t,` of seconds`)}const cf={holds:[1/0],period:1/0,at:()=>0,lastChange:()=>-1/0,nextChange:()=>1/0,reduced:()=>cf};function lf(e,t){if(!Number.isFinite(t))throw RangeError(`${e} needs a finite t, got ${t}`);return t}function uf(e,t,n){let r=lf(e,t)%n;if(r>=0)return r;let i=r+n;return i>=n?0:i}function df(e,t,n){let r=uf(e,t,n),i=Math.round((t-r)/n)+0;if(!Number.isFinite(i))throw RangeError(`${e}: a period of ${n} s is finer than time resolves near t = ${t}`);return{pass:i,into:r}}const ff=2**-1022;function pf(e){if(e===0)return Number.MIN_VALUE;let t=Math.abs(e);if(t<ff)return e+Number.MIN_VALUE;let n=Math.floor(Math.log2(t));2**n>t?--n:2**(n+1)<=t&&(n+=1);let r=2**(n-52);return e>0?e+r:e+(t===2**n&&t>ff?r/2:r)}function mf(e,t,n){let r=e;for(let e=0;!t(r);e++){if(e===8)throw RangeError(n());r=pf(r)}return r}function hf(e,t){if(!Number.isFinite(e))throw RangeError(`firstReaching needs a finite guess, got ${e}`);let n=e,r=e;for(let i=pf(Math.abs(e))-Math.abs(e);t(n);i*=2){if(n===-Number.MAX_VALUE)return-1/0;r=n,n=Math.max(e-i,-Number.MAX_VALUE)}for(let i=pf(Math.abs(e))-Math.abs(e);!t(r);i*=2){if(r===Number.MAX_VALUE)return 1/0;n=r,r=Math.min(e+i,Number.MAX_VALUE)}for(;;){let e=n+(r-n)/2;if(e<=n||e>=r)return r;t(e)?r=e:n=e}}function gf(e){if(e.length===0)throw RangeError(`a beat needs at least one hold`);e.forEach((e,t)=>sf(`beat hold ${t}`,e));let t=e.reduce((e,t)=>e+t,0),n=[],r=0;for(let t of e)n.push(r),r+=t;let i=[...e],a=e=>{let t=i.length-1;for(;n[t]>e;)t--;return t},o=(e,r,o,s)=>mf(r*t+n[o],n=>{let{pass:i,into:s}=df(e,n,t);return a(s)===o&&i===r},()=>`${e}: hold ${o} (${i[o]} s) is finer than time resolves near t = ${s}`);return{holds:i,period:t,at(e){return a(uf(`Beat.at`,e,t))},lastChange(e){let{pass:n,into:r}=df(`Beat.lastChange`,e,t);return o(`Beat.lastChange`,n,a(r),e)},nextChange(e){let{pass:n,into:r}=df(`Beat.nextChange`,e,t),s=a(r),c=s===i.length-1;return o(`Beat.nextChange`,n+ +!!c,c?0:s+1,e)},reduced:()=>cf}}const _f={once(e,t){if(!Number.isFinite(e))throw RangeError(`Phase.once start must be finite, got ${e}`);return sf(`Phase.once duration`,t),n=>Math.min(1,Math.max(0,(n-e)/t))},loop(e){return sf(`Phase.loop period`,e),t=>uf(`Phase.loop`,t,e)/e},pingPong(e){sf(`Phase.pingPong period`,e);let t=_f.loop(e);return e=>1-Math.abs(2*t(e)-1)}};function vf(e,t){return{owner:e.owner,row:e.row,col:e.col+t,inner:e.inner&&vf(e.inner,t)}}function yf(e,t){return bf(e,t)!==void 0}function bf(e,t){let n=e;for(;n!==void 0&&n.owner!==t;)n=n.inner;return n}const xf=[`bold`,`dim`,`italic`,`underline`,`blink`,`blink2`,`reverse`,`conceal`,`strike`,`underline2`,`frame`,`encircle`,`overline`],Sf={bold:1,dim:2,italic:3,underline:4,blink:5,blink2:6,reverse:7,conceal:8,strike:9,underline2:21,frame:51,encircle:52,overline:53},Cf={b:`bold`,d:`dim`,i:`italic`,u:`underline`,s:`strike`,r:`reverse`,o:`overline`,uu:`underline2`},wf={lastChange:-1/0,nextChange:1/0};var Tf=class extends Error{constructor(e,t){super(e,t),this.name=`StyleSyntaxError`}};const Ef=new el;var U=class e{color;bgcolor;bold;dim;italic;underline;blink;blink2;reverse;conceal;strike;underline2;frame;encircle;overline;link;meta;anchor;hold;constructor(e={}){let t=e.hold??wf,{lastChange:n,nextChange:r}=t;if(!(r>-1/0))throw RangeError(`Style nextChange must be a time in seconds or Infinity, got ${r}`);if(!(n<1/0))throw RangeError(`Style lastChange must be a time in seconds or -Infinity, got ${n}`);this.hold=t,this.color=Lf(e.color),this.bgcolor=Rf(e.bgcolor),this.bold=e.bold,this.dim=e.dim,this.italic=e.italic,this.underline=e.underline,this.blink=e.blink,this.blink2=e.blink2,this.reverse=e.reverse,this.conceal=e.conceal,this.strike=e.strike,this.underline2=e.underline2,this.frame=e.frame,this.encircle=e.encircle,this.overline=e.overline,this.link=e.link||void 0,this.meta=e.meta,this.anchor=e.anchor}get isNull(){return this.color===void 0&&this.bgcolor===void 0&&this.bold===void 0&&this.dim===void 0&&this.italic===void 0&&this.underline===void 0&&this.blink===void 0&&this.blink2===void 0&&this.reverse===void 0&&this.conceal===void 0&&this.strike===void 0&&this.underline2===void 0&&this.frame===void 0&&this.encircle===void 0&&this.overline===void 0&&this.link===void 0&&this.meta===void 0&&this.anchor===void 0&&this.hold.nextChange===1/0&&this.hold.lastChange===-1/0}get transparentBackground(){return this.bgcolor===void 0||this.bgcolor.isDefault}get backgroundStyle(){return new e({bgcolor:this.bgcolor})}with(t){return new e({...this,...t})}get withoutColor(){return this.with({color:void 0,bgcolor:void 0})}withLink(e){return this.with({link:e})}clearMetaAndLinks(){return this.with({link:void 0,meta:void 0})}withAnchor(e){return this.with({anchor:e})}get attributes(){return Object.fromEntries(xf.map(e=>[e,this[e]]))}withAttributes(e){return this.with(Object.fromEntries(xf.filter(t=>t in e).map(t=>[t,e[t]])))}reduced(){return this.blink||this.blink2?this.withAttributes({blink:void 0,blink2:void 0}):this}shiftedBy(e){return this.anchor?this.withAnchor(vf(this.anchor,e)):this}add(t){return!t||t.isNull?this:this.isNull?t:new e({color:t.color??this.color,bgcolor:t.bgcolor??this.bgcolor,bold:t.bold??this.bold,dim:t.dim??this.dim,italic:t.italic??this.italic,underline:t.underline??this.underline,blink:t.blink??this.blink,blink2:t.blink2??this.blink2,reverse:t.reverse??this.reverse,conceal:t.conceal??this.conceal,strike:t.strike??this.strike,underline2:t.underline2??this.underline2,frame:t.frame??this.frame,encircle:t.encircle??this.encircle,overline:t.overline??this.overline,link:t.link??this.link,meta:t.meta&&this.meta?{...this.meta,...t.meta}:t.meta??this.meta,anchor:t.anchor??this.anchor,hold:{lastChange:Math.max(this.hold.lastChange,t.hold.lastChange),nextChange:Math.min(this.hold.nextChange,t.hold.nextChange)}})}equals(e){return this===e?!0:this.color?.name===e.color?.name&&this.bgcolor?.name===e.bgcolor?.name&&this.bold===e.bold&&this.dim===e.dim&&this.italic===e.italic&&this.underline===e.underline&&this.blink===e.blink&&this.blink2===e.blink2&&this.reverse===e.reverse&&this.conceal===e.conceal&&this.strike===e.strike&&this.underline2===e.underline2&&this.frame===e.frame&&this.encircle===e.encircle&&this.overline===e.overline&&this.link===e.link&&Vf(this.anchor,e.anchor)&&this.hold.nextChange===e.hold.nextChange&&this.hold.lastChange===e.hold.lastChange}drawnColors(e){let t=wl,n=this.bgcolor?.flattenAlpha(t),r=n?.getTruecolor(void 0,!1)??t,i=this.color?.flattenAlpha(r),a=t=>e===void 0?t:t.downgrade(e);return{color:i===void 0?void 0:a(i),bgcolor:n===void 0?void 0:a(n)}}toSgrCodes(e){if(this.isNull)return``;let t=this.drawnColors(e);return[...xf.filter(e=>this[e]===!0).map(e=>`${Sf[e]}`),...t.color?.getAnsiCodes(!0)??[],...t.bgcolor?.getAnsiCodes(!1)??[]].join(`;`)}toString(){if(this.isNull)return`none`;let e=[];for(let t of xf)this[t]===!1&&e.push(`not ${t}`);for(let t of xf)this[t]===!0&&e.push(t);return this.color&&e.push(this.color.name),this.bgcolor&&e.push(`on ${this.bgcolor.name}`),this.link&&e.push(`link ${this.link}`),e.join(` `)||`none`}static null(){return Df}static fromColor(t,n){return new e({color:t,bgcolor:n})}static fromMeta(t){return new e({meta:t})}static pickFirst(...e){for(let t of e)if(t!==void 0)return t;throw Error(`All arguments are undefined`)}static combine(e){let t=Df;for(let n of e)n&&(t=t.add(n));return t}static chain(...t){return e.combine(t)}static normalize(e){return e.trim().replace(/\s+/g,` `)}static parse(t){let n=e.normalize(t);return n===``||n===`none`?Df:Ef.get(n,If)}};const Df=new U,Of=nl(/^[a-z][a-z0-9._-]*$/);function kf(e,t){return e instanceof U?e.add(t):e===``?t:typeof e==`string`?{under:e,over:t}:{under:e.under,over:e.over.add(t)}}var Af=class{styles;constructor(e={},t){let n=t?.inherit===!1?[]:Object.entries(zf),r=Object.entries(e).map(([e,t])=>{if(!Of.test(e))throw Error(`Invalid style name: "${e}" (must be lowercase, start with letter, contain only letters, digits, ".", "-", "_")`);return[e,U.parse(t)]});this.styles=new Map([...n,...r])}get(e){return this.styles.get(e)}resolve(e){return e instanceof U?e:typeof e==`string`?this.styles.get(e)??U.parse(e):this.resolve(e.under).add(e.over)}has(e){return this.styles.has(e)}};const jf=new Set(xf),Mf=[`not`,`on`,`link`,...xf,...xu];function Nf(e,t){let n=[],r=Array.from({length:t.length+1},(e,t)=>t);for(let i=1;i<=e.length;i++){let a=[i];for(let o=1;o<=t.length;o++){let s=i>1&&o>1&&e[i-1]===t[o-2]&&e[i-2]===t[o-1];a[o]=Math.min(r[o]+1,a[o-1]+1,r[o-1]+Number(e[i-1]!==t[o-1]),s?n[o-2]+1:1/0)}[n,r]=[r,a]}return r[t.length]}function Pf(e,t){let n=e.toLowerCase(),r=Math.max(1,Math.floor(n.length/3)),i=t.filter(e=>Math.abs(e.length-n.length)<=r).map(e=>({name:e,distance:Nf(n,e)})),a=Math.min(r,...i.map(e=>e.distance)),o=i.filter(e=>e.distance===a).map(e=>`"${e.name}"`).sort();return o.length===0?``:` (did you mean ${o.join(` or `)}?)`}function Ff(e,t,n){try{return H.parse(e)}catch(r){throw new Tf(`${t} "${e}"${Pf(e,n)}: ${String(r)}`,{cause:r})}}function If(e){let t=e.split(/\s+/),n={},r=0;for(;r<t.length;){let e=t[r];if(e===`not`){r++;let e=t[r];if(!e)throw new Tf(`Expected attribute after "not" in style definition`);let i=Cf[e]??e;if(!jf.has(i))throw new Tf(`Invalid attribute: "${e}"${Pf(e,xf)}`);n[i]=!1,r++;continue}if(e===`on`){r++;let e=t[r];if(!e)throw new Tf(`Expected color after "on" in style definition`);n.bgcolor=Ff(e,`Invalid background color`,xu),r++;continue}if(e===`link`){r++;let e=t[r];e&&(n.link=e),r++;continue}let i=Cf[e]??e;if(jf.has(i)){n[i]=!0,r++;continue}n.color=Ff(e,`Invalid style definition`,Mf),r++}return new U(n)}function Lf(e){if(e!==void 0)return e instanceof H?e:H.parse(e)}function Rf(e){let t=Lf(e);return t?.value?.alpha===0?void 0:t}const zf={none:Df,reset:new U({color:H.default(),bgcolor:H.default(),bold:!1,dim:!1,italic:!1,underline:!1,blink:!1,blink2:!1,reverse:!1,conceal:!1,strike:!1,underline2:!1,frame:!1,encircle:!1,overline:!1}),bold:new U({bold:!0}),dim:new U({dim:!0}),italic:new U({italic:!0}),underline:new U({underline:!0}),blink:new U({blink:!0}),blink2:new U({blink2:!0}),reverse:new U({reverse:!0}),conceal:new U({conceal:!0}),strike:new U({strike:!0}),underline2:new U({underline2:!0}),frame:new U({frame:!0}),encircle:new U({encircle:!0}),overline:new U({overline:!0}),"table.header":new U({bold:!0}),"table.footer":new U({bold:!0}),"table.cell":Df,"table.title":new U({italic:!0}),"table.caption":new U({italic:!0,dim:!0}),"repr.ellipsis":U.parse(`yellow`),"repr.indent":U.parse(`dim green`),"repr.error":U.parse(`bold red`),"repr.str":U.parse(`not bold not italic green`),"repr.brace":U.parse(`bold`),"repr.comma":U.parse(`bold`),"repr.ipv4":U.parse(`bold bright_green`),"repr.ipv6":U.parse(`bold bright_green`),"repr.eui48":U.parse(`bold bright_green`),"repr.eui64":U.parse(`bold bright_green`),"repr.tag_start":U.parse(`bold`),"repr.tag_name":U.parse(`bold bright_magenta`),"repr.tag_contents":U.parse(`default`),"repr.tag_end":U.parse(`bold`),"repr.attrib_name":U.parse(`not italic yellow`),"repr.attrib_equal":U.parse(`bold`),"repr.attrib_value":U.parse(`not italic magenta`),"repr.number":U.parse(`bold not italic cyan`),"repr.number_complex":U.parse(`bold not italic cyan`),"repr.bool_true":U.parse(`italic bright_green`),"repr.bool_false":U.parse(`italic bright_red`),"repr.none":U.parse(`italic magenta`),"repr.url":U.parse(`not bold not italic underline bright_blue`),"repr.uuid":U.parse(`not bold bright_yellow`),"repr.call":U.parse(`bold magenta`),"repr.path":U.parse(`magenta`),"repr.filename":U.parse(`bright_magenta`),"log.time":U.parse(`cyan dim`),"log.message":Df,"log.path":U.parse(`dim`),"log.line_no":U.parse(`cyan`),"log.level":Df,"rule.line":U.parse(`bright_green`),"rule.text":Df,"strip.separator":U.parse(`bright_black`),"strip.rail":U.parse(`bright_black`),"json.brace":U.parse(`bold`),"json.bool_true":U.parse(`italic bright_green`),"json.bool_false":U.parse(`italic bright_red`),"json.key":U.parse(`bold blue`),"json.null":U.parse(`italic magenta`),"json.number":U.parse(`bold not italic cyan`),"json.str":U.parse(`not bold not italic green`),"syntax.keyword":U.parse(`bold magenta`),"syntax.constant":U.parse(`italic bright_magenta`),"syntax.string":U.parse(`green`),"syntax.number":U.parse(`cyan`),"syntax.comment":U.parse(`dim italic`),"syntax.line_number":U.parse(`dim`),"syntax.line_number.highlight":U.parse(`bold grey93 on grey27`),"markdown.h1":U.parse(`bold underline`),"markdown.h2":U.parse(`underline magenta`),"markdown.h3":U.parse(`bold magenta`),"markdown.h4":U.parse(`italic magenta`),"markdown.h5":U.parse(`italic`),"markdown.h6":U.parse(`dim`),"markdown.code":U.parse(`bold dark_turquoise on grey11`),"markdown.em":U.parse(`italic`),"markdown.strong":U.parse(`bold`),"markdown.s":U.parse(`strike`),"markdown.kbd":U.parse(`bold bright_yellow`),"markdown.block_quote":U.parse(`magenta`),"markdown.hr":U.parse(`dim`),"markdown.item":Df,"markdown.item.bullet":U.parse(`bold`),"markdown.item.number":U.parse(`cyan`),"markdown.link":U.parse(`bright_blue`),"markdown.link_url":U.parse(`underline blue`),"markdown.table.border":U.parse(`cyan`),"markdown.table.header":U.parse(`not bold cyan`),"progress.description":Df,"progress.percentage":U.parse(`magenta`),"progress.remaining":U.parse(`cyan`),"progress.elapsed":U.parse(`yellow`),"progress.spinner":U.parse(`green`),"progress.download":U.parse(`green`),"progress.filesize":U.parse(`green`),"progress.filesize.total":U.parse(`green`),"progress.data.speed":U.parse(`red`),"bar.back":U.parse(`grey23`),"bar.complete":U.parse(`rgb(249,38,114)`),"bar.finished":U.parse(`rgb(114,156,31)`),"bar.pulse":U.parse(`rgb(249,38,114)`),"scrollbar.thumb":Df,"scrollbar.track":U.parse(`grey37`),tree:Df,"tree.guide":Df,"status.spinner":U.parse(`green`),"status.message":Df,prompt:Df,"prompt.choices":U.parse(`bold magenta`),"prompt.default":U.parse(`bold cyan`),"prompt.invalid":U.parse(`red`),"prompt.invalid.choice":U.parse(`red`),"inspect.attr":U.parse(`yellow italic`),"inspect.attr.dunder":U.parse(`yellow italic dim`),"inspect.callable":U.parse(`bold magenta`),"inspect.error":U.parse(`bold red`),"inspect.help":U.parse(`cyan`),"inspect.doc":U.parse(`dim`),"inspect.value.border":U.parse(`green`),"traceback.border":U.parse(`red`),"traceback.text":U.parse(`red`),"traceback.title":U.parse(`bold red`),"traceback.exc_type":U.parse(`bold bright_red`),"traceback.exc_value":Df,"traceback.offset":U.parse(`bold bright_red`),"scope.border":U.parse(`blue`),"scope.key":U.parse(`italic`),"scope.key.special":U.parse(`dim italic`),pretty:Df,"iso8601.date":U.parse(`blue`),"iso8601.time":U.parse(`magenta`),"iso8601.timezone":U.parse(`yellow`),"iso8601.year":Df,"iso8601.month":Df,"iso8601.day":Df,"iso8601.week":Df,"iso8601.hour":Df,"iso8601.minute":Df,"iso8601.second":Df,"iso8601.frac":Df,"iso8601.ms":Df,"iso8601.hyphen":Df},Bf=new Af;function Vf(e,t){return e===t?!0:!e||!t?!1:e.owner===t.owner&&e.row===t.row&&e.col===t.col&&Vf(e.inner,t.inner)}const Hf=e=>/^[\x00-\x7F]*$/.test(e);function Uf(e,t,n,r=String){return e.asciiOnly===!0&&!Hf(r(t))?n:t}function Wf(e,t){return(e.theme??Bf).resolve(t)}U.parse(`default on default`);function Gf(e){return{...e,maxWidth:dl(e.maxWidth)}}function Kf(e){return dl(e.maxWidth)<1}let qf;function Jf(e,t){let n=qf;qf=e;try{return t()}finally{qf=n}}function Yf(e){return Jf(void 0,e)}function Xf(){return qf?.pass}const Zf=()=>qf??{pass:{},effects:[]};function Qf(e){Jf(void 0,()=>{for(let t of e.effects.splice(0))t()})}function $f(e,t){return Array.isArray(t)?(Qf(e),t):{[Symbol.iterator]:()=>{let n=Jf(e,()=>t[Symbol.iterator]());return Object.assign(Object.create(ep),{next:()=>{let t=Jf(e,()=>n.next());return t.done===!0&&Qf(e),t},return:t=>Jf(e,()=>n.return?.(t)??{done:!0,value:void 0}),throw:t=>Jf(e,()=>{if(n.throw)return n.throw(t);throw t})})}}}const ep=Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));function tp(e,t){let n=qf===void 0,r=Kf(t)?`held`:`drawn`,{phase:i,drawing:a}=r===`drawn`?{phase:Zf(),drawing:t}:np(t),o=Jf(i,()=>(t.onPresent?.(e,r),e.render(a)));return r===`held`?(Jf(i,()=>{for(let e of o);}),[]):n?$f(i,o):o}function np(e){let{onPresent:t}=e;return{phase:{pass:Zf().pass,effects:[]},drawing:{...e,maxWidth:0,onPresent:t&&(e=>t(e,`held`))}}}function rp(e,t){return Jf({pass:Zf().pass,effects:[]},()=>e.measure(ip(t)))}function ip(e){return{...e,onPresent:void 0}}function ap(e,t){let n=Gf(e);if(Number.isFinite(n.maxWidth))return n;let r=rp(t,n).maximum;if(!Number.isFinite(r))throw RangeError(`maxWidth is unbounded and this renderable has no natural width to fall back on: its content does not implement measure(), or something inside it asked for an unbounded width of its own. Render it at a finite width, or give the content a measure() that reports a finite maximum.`);return{...n,maxWidth:dl(r)}}function op(e){return typeof e==`object`&&!!e&&`render`in e&&typeof e.render==`function`}function sp(e){return typeof e==`object`&&!!e&&`measure`in e&&typeof e.measure==`function`}var cp=class e{minimum;maximum;constructor(e,t){this.minimum=e,this.maximum=t}get span(){return this.maximum-this.minimum}normalize(){let t=e=>Number.isNaN(e)?0:e;return new e(Math.max(0,Math.min(t(this.minimum),t(this.maximum))),Math.max(0,t(this.maximum)))}withMaximum(t){return new e(Math.min(this.minimum,t),Math.min(this.maximum,t))}withMinimum(t){let n=Math.max(this.minimum,t);return new e(n,Math.max(this.maximum,n))}clamp(t,n){return new e(Math.min(Math.max(this.minimum,t),n),Math.min(Math.max(this.maximum,t),n))}static get(t,n){if(Kf(t))return new e(0,0);if(!sp(n))return new e(0,t.maxWidth);let{minimum:r,maximum:i}=rp(n,t);return new e(r,Math.min(i,t.maxWidth)).normalize()}},lp;(function(e){e.BELL=`bell`,e.CARRIAGE_RETURN=`carriage_return`,e.HOME=`home`,e.CLEAR=`clear`,e.SHOW_CURSOR=`show_cursor`,e.HIDE_CURSOR=`hide_cursor`,e.ENABLE_ALT_SCREEN=`enable_alt_screen`,e.DISABLE_ALT_SCREEN=`disable_alt_screen`,e.CURSOR_UP=`cursor_up`,e.CURSOR_DOWN=`cursor_down`,e.CURSOR_FORWARD=`cursor_forward`,e.CURSOR_BACKWARD=`cursor_backward`,e.CURSOR_MOVE_TO_COLUMN=`cursor_move_to_column`,e.CURSOR_MOVE_TO=`cursor_move_to`,e.ERASE_IN_LINE=`erase_in_line`,e.SET_WINDOW_TITLE=`set_window_title`})(lp||={});var W=class e{text;style;control;constructor(e,t,n){this.text=e,this.style=t,this.control=n}get cellLength(){return this.control?0:z(this.text)}get hasText(){return this.text.length>0}get isControl(){return this.control!==void 0}splitCells(t){return t>=this.cellLength?[this,new e(``)]:t<=0?[new e(``),this]:this.cutAt([t])}cutAt(t){return pl(this.text,t).map((n,r)=>new e(n,r===0?this.style:this.style?.shiftedBy(t[r-1])))}static _line=new e(`
43
43
  `);static line(){return e._line}static anchorLines(t,n,r=0){return t.map((t,i)=>{let a=r+i,o=0;return t.map(t=>{if(t.isControl)return t;let r=t.style??U.null(),i=new e(t.text,r.withAnchor({owner:n,row:a,col:o,inner:r.anchor}));return o+=t.cellLength,i})})}static nextChange(e){let t=1/0;for(let n of e)t=Math.min(t,n.style?.hold.nextChange??1/0);return t}static lastChange(e){let t=-1/0;for(let n of e)t=Math.max(t,n.style?.hold.lastChange??-1/0);return t}static anchorAt(e,t,n){if(!Number.isInteger(t)||t<0)return;let r=0;for(let i of e[n]??[]){let e=r+i.cellLength;if(t<e){let e=i.style?.anchor;return e&&vf(e,t-r)}r=e}}static*applyStyle(t,n,r){let i=n?.isNull?void 0:n,a=r?.isNull?void 0:r;if(!i&&!a){yield*t;return}for(let n of t){if(n.isControl){yield n;continue}let t=n.style;i&&(t=i.add(t)),a&&(t=t?t.add(a):a),yield new e(n.text,t,n.control)}}static*filterControl(e,t){for(let n of e)n.isControl===t&&(yield n)}static splitLines(t){let n=[],r=[];for(let i of t){if(i.isControl){r.push(i);continue}let t=i.text;if(!t.includes(`
44
44
  `)){r.push(i);continue}let a=t.split(`
@@ -55,7 +55,7 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
55
55
 
56
56
  `)}},sb=class extends Error{constructor(e){super(e.map(e=>e.message).join(`
57
57
  `)),this.errors=e,this.name=`DroppedPlacements`}};function q(e,t){return cb(e)(t)}function cb(e){let t,n=()=>(t??={node:lb(e)},t.node);return t=>ub(e,n,t)}function lb(e){try{return Ua(e)}catch(e){if(e instanceof La)return;throw e}}function ub(e,t,n){let r=n.some(e=>/^\d+$/.test(e))?db(e,t(),n):void 0;if(r!==void 0)return r;let i=0,a;for(let t of n){if(t===``||/^\d+$/.test(t))continue;let n=fb(e,i,t);if(n===-1)return a===void 0?void 0:pb(e,a);i=n,a=n}return a===void 0?void 0:pb(e,a)}function db(e,t,n){if(t===void 0)return;let r=t,i,a=!1;for(let e of n){let t=r.kind===`array`&&/^\d+$/.test(e),n=r.kind===`array`?t?r.elements[Number(e)]:void 0:Wa(r,e)?.value;if(n===void 0)break;a||=t,r=n,i=n}return i===void 0||!a?void 0:pb(e,i.span.start)}function fb(e,t,n){let r=n.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),i=RegExp(`(?:["']${r}["']|\\b${r}\\b)\\s*:`,`g`);i.lastIndex=t;let a=i.exec(e);return a?a.index:-1}function pb(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e.charCodeAt(r)===10&&n++;return n}function mb(e,t){try{return Ua(t),null}catch(n){if(!(n instanceof La))throw n;return`${e}:${pb(t,n.offset)}: ${n.reason} — the settings menu cannot edit this file until it is fixed`}}function hb(e,t){if(t.length===0)return`${e}: invalid config (no details)`;let n=[`Invalid config in ${e} (${t.length} issue${t.length===1?``:`s`}):`];for(let e of t){let t=[];e.line!==void 0&&t.push(`line ${e.line}${e.col===void 0?``:`:${e.col}`}`),e.path&&t.push(e.path);let r=t.length>0?`[${t.join(` • `)}] `:``;n.push(` ${r}${e.message}`)}return n.join(`
58
- `)}function gb(e,t,n,r){let i=n[r];return typeof i==`string`?i:(e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be a string, got ${Sb(i)}`,line:q(e.source,[...t.split(`.`),r])}),null)}function _b(e,t,n,r){let i=n.default;if(i!==void 0){if(!(r===`string`&&typeof i==`string`||r===`number`&&typeof i==`number`||r===`boolean`&&typeof i==`boolean`)){e.issues.push({path:`${t}.default`,message:`default must be a ${r}, got ${Sb(i)}`,line:q(e.source,[...t.split(`.`),`default`])});return}return i}}function vb(e,t,n,r){let i=n[r];if(i!==void 0){if(typeof i!=`string`){e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be a string, got ${Sb(i)}`,line:q(e.source,[...t.split(`.`),r])});return}return i}}function yb(e,t,n){let r=vb(e,t,n,`palette`);if(r!==void 0){if(!e.allowedPalettes.has(r)){e.issues.push({path:`${t}.palette`,message:`Unknown palette "${r}"${Hv(r)}. Expected one of: ${[...e.allowedPalettes].sort().join(`, `)}`,line:q(e.source,[...t.split(`.`),`palette`])});return}return r}}function bb(e,t,n,r,i){let a=n[r];if(a!==void 0){if(typeof a!=`string`||!i.includes(a)){e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be one of: ${i.join(`, `)}; got ${J(a)}`,line:q(e.source,[...t.split(`.`),r])});return}return a}}function xb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sb(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function J(e){return typeof e==`string`?JSON.stringify(e):e===void 0?`undefined`:String(e)}function Cb(e,t,n,r){return xb(r)?(Db(e,n,r,t.noun,new Set(Object.keys(t.fields)),wb(e,t.removed??{},n,r)),Tb(e,t.fields,n,r)):(e.issues.push({path:n,message:`${n} must be an object, got ${Sb(r)}`,line:q(e.source,n.split(`.`))}),null)}function wb(e,t,n,r){let i=Object.entries(t).filter(([e])=>r[e]!==void 0);for(let[t,r]of i)Ob(e,`${n}.${t}`,`${n}.${t} was removed: ${r}`);return new Set(i.map(([e])=>`${n}.${e}`))}function Tb(e,t,n,r){let i=t,a={},o=!0;for(let[t,s]of Object.entries(i)){let i=s.parse(e,n,t,r);i===void 0?s.required&&(o=!1):a[t]=i}return o?a:null}const Eb=new Set;function Db(e,t,n,r,i,a=Eb){for(let o of Object.keys(n))!i.has(o)&&!a.has(`${t}.${o}`)&&e.issues.push({path:`${t}.${o}`,message:`Unknown ${r} "${o}". Expected one of: ${[...i].join(`, `)}`,line:q(e.source,[...t.split(`.`),o])})}function Ob(e,t,n){return e.issues.push({path:t,message:n,line:q(e.source,t.split(`.`))}),null}function kb(e,t,n,r){if(!xb(r))return e.issues.push({path:n,message:`${t.noun} must be an object, got ${Sb(r)}`,line:q(e.source,n.split(`.`))}),null;let i=t.arms,a=Object.keys(i),o=Object.keys(r).filter(e=>e in i),s=Object.keys(r).filter(e=>!(e in i));for(let r of s)e.issues.push({path:`${n}.${r}`,message:`Unknown ${t.noun} key "${r}". Expected exactly one of: ${a.join(`, `)}`,line:q(e.source,[...n.split(`.`),r])});if(o.length===0)return e.issues.push({path:n,message:`${t.noun} must declare exactly one of: ${a.join(`, `)}`,line:q(e.source,n.split(`.`))}),null;if(o.length>1)return e.issues.push({path:n,message:`${t.noun} must declare exactly one of: ${a.join(`, `)} (found: ${o.join(`, `)})`,line:q(e.source,n.split(`.`))}),null;let c=o[0];return i[c].parse(e,`${n}.${c}`,r[c])}function Ab(e,t,n,r){if(!xb(r))return e.issues.push({path:n,message:`${n} must be an object, got ${Sb(r)}`,line:q(e.source,n.split(`.`))}),null;let i=r[t.tag];if(typeof i!=`string`)return e.issues.push({path:`${n}.${t.tag}`,message:`${n}.${t.tag} must be a string, got ${Sb(i)}`,line:q(e.source,n.split(`.`))}),null;let a=t.arms;if(!Object.hasOwn(a,i)){let o=Object.hasOwn(t.retired,i)?t.retired[i](r):`Unknown ${t.noun} "${i}". Expected one of: ${Object.keys(a).join(`, `)}`;return e.issues.push({path:`${n}.${t.tag}`,message:o,line:q(e.source,[...n.split(`.`),t.tag])}),null}let o=a[i],s=e.issues.length,c=o.parse(e,n,r),l=new Set(e.issues.slice(s).map(e=>e.path));return Db(e,n,r,`${i} ${t.memberNoun} key`,o.keys,l),c}function jb(e,t,n){return{json:Gb(Ub(n),e,t),keys:new Set([e,...Object.keys(n)])}}function Mb(e){return(...t)=>e()(...t)}function Nb(e,...t){return(n,r,i)=>{let a=e(n,r,i);if(a===null)return null;for(let e of t){if(e.ok(a))continue;let{field:t,message:i}=e.issue(a),o=t===``?r:`${r}.${t}`;return n.issues.push({path:o,message:i,line:q(n.source,o.split(`.`))}),null}return a}}function Pb(){return{required:!1,json:{type:`string`},parse:(e,t,n,r)=>vb(e,t,r,n)}}function Fb(){return{required:!1,json:{type:`boolean`},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(typeof i!=`boolean`){e.issues.push({path:`${t}.${n}`,message:`${n} must be a boolean, got ${Sb(i)}`,line:q(e.source,[n])});return}return i}}}}function Ib(e){let{min:t,max:n}=e;return{required:!1,json:{type:`integer`,minimum:t,maximum:n},parse:(e,r,i,a)=>{let o=a[i];if(o!==void 0){if(typeof o!=`number`||!Number.isInteger(o)||o<t||o>n){e.issues.push({path:`${r}.${i}`,message:`${i} must be an integer between ${t} and ${n}, got ${J(o)}`,line:q(e.source,[i])});return}return o}}}}function Lb(e={}){let{min:t}=e;return{required:!1,json:{type:`number`,...t!==void 0&&{minimum:t}},parse:(e,n,r,i)=>{let a=i[r];if(a!==void 0){if(typeof a!=`number`||!Number.isFinite(a)||t!==void 0&&a<t){let i=t===void 0?`a finite number`:`a finite number >= ${t}`;e.issues.push({path:`${n}.${r}`,message:`${r} must be ${i}, got ${J(a)}`,line:q(e.source,[r])});return}return a}}}}function Rb(){return{required:!1,json:{type:`string`},parse:(e,t,n,r)=>yb(e,t,r)}}function zb(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>gb(e,t,r,n)??void 0}}function Bb(e,t){return re(t)?null:`${e} must be an absolute path (\`~\` and relative paths are not expanded), got ${JSON.stringify(t)}`}function Vb(){return{required:!0,json:{type:`string`,pattern:`^/`},parse:(e,t,n,r)=>{let i=gb(e,t,r,n);if(i===null)return;let a=Bb(`${t}.${n}`,i);return a===null?i:Ob(e,`${t}.${n}`,a)??void 0}}}function Hb(e){return{required:!1,json:{enum:[...e]},parse:(t,n,r,i)=>bb(t,n,i,r,e)}}function Ub(e,t={closed:!0}){let n=e,r={},i=[];for(let[e,t]of Object.entries(n))r[e]=t.json,t.required&&i.push(e);return{type:`object`,properties:r,...i.length>0&&{required:i},...t.closed&&{additionalProperties:!1}}}function Wb(e){return Ub(e.fields)}function Gb(e,t,n){let r=e,i={[t]:{const:n},...r.properties},a=[t,...r.required??[]];return{...r,properties:i,required:a}}function Kb(e){let t=e.arms;return{anyOf:Object.values(t).map(e=>e.json)}}function qb(e){let t=e.arms;return{anyOf:Object.entries(t).map(([e,t])=>({type:`object`,properties:{[e]:t.json},required:[e],additionalProperties:!1}))}}const Jb=[`claude`,`tmux`],Yb=`ne .tmux.pane ""`,Xb={band:{switch:{setting:`experimentalBand`,on:!0,inTmux:!1},label:`🧪 band (A)`,handsOff:!0,rows:null},statusline:{switch:{setting:`experimentalStatusline`,on:!0,inTmux:!1},label:`🧪 statusline (B)`,handsOff:!1,rows:null},pane:{switch:{setting:`experimentalPane`,on:!0,inTmux:!1},label:`🧪 tmux pane (C)`,handsOff:!0,rows:null},tmuxStatus:{switch:{setting:`renderer`,on:`tmux`,inTmux:!0},label:`tmux status line`,handsOff:!0,rows:5}},Zb=Object.keys(Xb),Qb=Zb.filter(e=>Xb[e].switch.on===!0),$b={by:`request`},ex=e=>`drawing.${e}`,tx={subscribers:0,fps:0,shown:!0},nx=(e,t)=>`feeds.${e}.${t}`;function rx(e){return Object.fromEntries(Zb.map(t=>[t,e(t)]))}const ix=rx(()=>tx);function ax(e){return typeof e==`string`&&Object.hasOwn(Xb,e)?e:null}const ox=(e,t)=>Array.from({length:e*2},(e,n)=>({lit:n%2==0,seconds:t})),sx=[...ox(3,1),...ox(3,.25)],cx=sx.reduce((e,{seconds:t})=>e+t,0),lx={min:15,max:600,step:15},ux=(e,t)=>e+t,dx=e=>e-cx,fx=(e,t,{previews:n=[],shown:r=`true`}={})=>({label:e,place:t,previews:n,shown:r}),px=(e,t,n={})=>({spec:Hb(e),domain:{from:e},parse:t=>e.includes(t)?t:null,...t!==void 0&&{optionDomain:{name:t,members:e,...n}}}),mx=e=>t=>e.includes(t)?`🧪 ${t}`:t,hx={spec:Fb(),domain:`bool`,parse:Ty},gx=e=>({spec:Ib(e),domain:e,parse:t=>Ey(t,e)});function _x(e,t,n,r={}){return{kind:`session`,...px(e,r.optionDomain,{library:r.library,labelOf:r.labelOf}),floor:t,control:n,themeDefault:r.themeDefault??!1}}function vx(e,t){return{kind:`session`,...hx,floor:e,control:t,themeDefault:!1}}function yx(e,t,n){return{kind:`session`,...gx(e),floor:t,control:n,themeDefault:!1}}function bx(e,t,n,r,i={}){return{kind:`selection`,sessionKey:e,spec:t,domain:n,control:r,themeDefault:i.themeDefault??!1}}const xx=e=>({kind:`text`,spec:e}),Lee={required:!1,json:{enum:[...gy]},parse:(e,t,n,r)=>{if(r[n]===`auto`){e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: "auto" is not supported — the render daemon runs detached, so terminal detection would read the daemon's environment, not your terminal's. Pick an explicit depth: ${gy.join(`, `)}`,line:q(e.source,[...t.split(`.`),n])});return}return bb(e,t,r,n,gy)}},Ree={required:!1,json:{type:`string`},parse:(e,t,n,r)=>{let i=vb(e,t,r,n);return Zv(i)?i:yb(e,t,r)}},zee={required:!1,json:{anyOf:[{enum:[...oy]},{type:`string`,pattern:`\\{\\{`}]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&Zv(i)?i:bb(e,t,r,n,oy)}},Sx=/^[^\r\n]*\S[^\r\n]*$/u,Cx=RegExp(`^(?:✖|✕)[\\uFE0E\\uFE0F]?$`,`u`),Bee={required:!1,json:{type:`string`,pattern:Sx.source,not:{pattern:Cx.source}},parse:(e,t,n,r)=>{let i=vb(e,t,r,n);if(i===void 0||Sx.test(i)&&!Cx.test(i))return i;e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: must be one line of visible text other than a close glyph ("✖", "✕") — the settings menu needs a glyph to click`,line:q(e.source,[...t.split(`.`),n])})}},Vee=Object.fromEntries(Qb.map(e=>[Xb[e].switch.setting,vx(!1,fx(Xb[e].label,`toggles`))])),Hee={claude:`Claude Code's status line`,tmux:`the tmux status line, while this pane is shown`},Uee={groups:[{id:`renderer`,label:`draw the bar in`}],entry:e=>({group:`renderer`,description:Hee[e]})},wx={palette:bx(`theme`,Ree,{themes:`themes`},fx(`🎨 theme`,`door`)),preset:bx(`preset`,Pb(),{from:`presets`},fx(`▦ preset`,`door`,{previews:[`layout`,`presetDelete`]})),style:bx(`style`,Pb(),{from:`styles`},fx(`◐ style`,`gear`,{previews:[`palette`]}),{themeDefault:!0}),effect:bx(`effect`,zee,{from:oy},fx(`✨ effect`,`look`)),endcaps:_x(py,`powerline`,fx(`✦ endcaps`,`look`),{optionDomain:`endcaps`}),variation:_x(yy,`accent`,fx(`🎼 variation`,`gear`,{previews:[`layout`]}),{optionDomain:`variations`,labelOf:mx(V_),themeDefault:!0}),shade:_x(by,`middle`,fx(`🔆 shade`,`gear`,{previews:[`layout`]}),{optionDomain:`shades`,labelOf:mx(A_),themeDefault:!0}),transitions:vx(!1,fx(`fade in/out`,`look`)),animationSpeed:_x(cy,`1x`,fx(`speed`,`look`)),autoWrap:vx(!0,fx(`wrap`,`config`)),padding:yx({...wy,step:1},1,fx(`padding`,`config`)),updateNotice:vx(!0,fx(`update notice`,`config`)),menuTimeout:yx(lx,120,fx(`menu timeout`,`config`)),renderer:_x(Jb,`claude`,fx(`renderer`,`config`,{shown:Yb}),{optionDomain:`renderers`,library:Uee}),...Vee,colorCompatibility:{kind:`config`,...px(gy,`colorCompatibilities`),spec:Lee,floor:`truecolor`},default_empty_value:xx(Pb()),default_separator:xx(Pb()),menuGlyph:xx(Bee)},Tx=Object.entries(wx),Ex=Tx.filter(([,e])=>e.kind===`session`||e.kind===`config`).map(([e])=>e),Wee=Tx.filter(([,e])=>e.kind===`session`||e.kind===`selection`).map(([e])=>e),Dx=Tx.filter(([,e])=>(e.kind===`session`||e.kind===`selection`)&&e.themeDefault).map(([e])=>e),Gee=Tx.flatMap(([,e])=>`optionDomain`in e&&e.optionDomain!==void 0?[e.optionDomain]:[]);function Ox(e){return wx[e]}const kx=e=>Ox(e).floor;function Ax(e){let t=wx[e];if(t.kind===`text`)return`string`;let{domain:n}=t;return n===`bool`?`boolean`:typeof n==`object`&&`min`in n?`number`:`string`}const jx=e=>`${e}.effective`,Kee=e=>{let t=wx[e];return t.kind===`selection`?t.sessionKey:e},Mx=Object.fromEntries(Wee.map(e=>{let t=Kee(e);return[t,{configKey:e,sessionKey:t,effectiveVar:jx(t),...wx[e].control}]})),Nx=Object.keys(Mx),Px=Object.values(Mx),Fx=Ex.filter(e=>wx[e].kind===`config`).map(e=>({configKey:e,effectiveVar:jx(e)})),qee=new Set(Fx.map(e=>e.configKey)),Ix=new Map([...Px,...Fx].map(e=>[e.configKey,e.effectiveVar])),Lx=new Map(Px.map(e=>[e.sessionKey,e.effectiveVar]));function Rx(e){return Object.fromEntries(Nx.map(t=>[t,e(t)]))}const zx=new Map(Nx.map(e=>[Mx[e].sessionKey,e])),Bx=new Map;function Vx(e){let t=Ux(e);if(t===null)throw Error(`Palette "${e}" did not resolve in the theme registry — allowed names and the registry are inconsistent`);return t}function Hx(e,t){return e===`bar`?t:Vx(e)}function Ux(e){let t=Bx.get(e);if(t!==void 0)return t;let n=fee(e);return n===null?null:(Bx.set(e,n),n)}function Wx(e,t){return Jee(e,`${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,()=>xee(e,t))}const Jee=g_();function Gx(e){let t=Ux(e);return t===null?null:{kind:`decided`,name:e,value:t}}function Kx(e,t,n){let r=Gx(e);return r===null?(n(ay(t,`palette`,`"${e}" names no installed theme${Hv(e)}`)),qx()):r}function Yee(e,t,n){return Qv(e,t,n,qx(),Gx)}function qx(){return{kind:`decided`,name:Uv,value:Vx(Uv)}}const Jx=/^[A-Za-z_][A-Za-z0-9_]*$/;function Xee(e){return`#${e+1}`}const Yx={rows:{}};function Xx(e){return`rows`in e}function Zx(e){return Object.fromEntries(e.map((e,t)=>[Xee(t),e]))}function Zee(e){if(e.kind===`container`&&e.direction===`vertical`){let{kind:t,direction:n,children:r,...i}=e;return{...i,rows:Zx(r)}}let{when:t,...n}=e;return{...t!==void 0&&{when:t},rows:Zx([n])}}function Qx(e){let{rows:t,...n}=e;return{kind:`container`,direction:`vertical`,children:Object.values(t),...n}}function $x(e){return Xx(e)?Qx(e):e}function*eS(e,t){if(!Xx(e)){yield*Iy(e,t);return}yield[Qx(e),t];for(let[n,r]of Object.entries(e.rows))yield*Iy(r,`${t}.rows.${n}`)}function tS(e,t){return Xx(e)?{...t,...e,rows:{...t.rows,...e.rows}}:Zee(e)}function nS(e,t){return t.reduce((e,t)=>{let n=t.id??t.seg,r=[...Ny(Qx(e.root))].flatMap(e=>e.kind===`segment`?[e]:[]);if(r.some(e=>e.name===t.seg&&(t.id===void 0||ky(e)===t.id)))return e;let i=r.find(e=>ky(e)===n);if(i!==void 0)return rS(e,t,`as "${n}", but placement "${n}" is already segment "${i.name}" — give the cell its own id`);let a={kind:`segment`,name:t.seg,...t.id!==void 0&&{id:t.id},insertedBy:t.by},o=Object.entries(e.root.rows).map(([e,n])=>[e,n,Qee(n,t.anchor,a,t.relation)]);return o.some(([,,e])=>e!==null)?{...e,root:{...e.root,rows:Object.fromEntries(o.map(([e,t,n])=>[e,n??t]))}}:rS(e,t,`${t.relation} "${t.anchor}", but there is no placement "${t.anchor}"`)},{root:e,unplaced:[]})}function rS(e,t,n){return{...e,unplaced:[...e.unplaced,{cell:t,reason:n}]}}function Qee(e,t,n,r){if(e.kind===`segment`&&ky(e)===t){let{when:t,...i}=e;return{kind:`container`,direction:`horizontal`,children:r===`before`?[n,i]:[i,n],...t!==void 0&&{when:t}}}return e.kind===`container`?iS(e,t,n,r):aS(e,t,n,r)}function iS(e,t,n,r){let i=e.children.findIndex(e=>e.kind===`segment`&&ky(e)===t);if(i>=0){let t=r===`before`?i:i+1,{when:a}=e.children[i];return{...e,children:[...e.children.slice(0,t),{...n,...a!==void 0&&{when:a}},...e.children.slice(t)]}}for(let[i,a]of e.children.entries()){let o=a.kind===`container`?iS(a,t,n,r):aS(a,t,n,r);if(o!==null)return{...e,children:e.children.map((e,t)=>t===i?o:e)}}return null}function aS(e,t,n,r){let i=!1,a=My(e,e=>{let a=iS(e,t,n,r);return i=a!==null,a??e});return i?a:null}function oS(e){if(!Xx(e))return!0;let{rows:t,...n}=e;return Object.values(n).some(e=>e!==void 0)||Object.keys(t).length>0}const sS=`default`,cS={};function lS(e){return[...new Set([sS,...Object.keys(e)])]}function uS(e,t,n){return Yv(void 0,e,t,sS,n)}function dS(e,t){let n={[sS]:cS,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${sS}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function fS(e,t){let n=dS(e.presets,t).root??Yx;return{node:Qx(tS(n,e.root)),path:oS(n)?`presets.${t}.root`:`root`}}function pS(e,t,n){if(t.length===0)return{config:e,notices:[]};let r=nS(e.root,t),i=Object.entries(e.presets).filter(([,e])=>oS(e.root??Yx)).map(([n,r])=>({name:n,preset:r,...nS(tS(r.root??Yx,e.root),t)})),a=new Map,o=e=>({cell:t,reason:n})=>{let r=a.get(t)??new Map;r.set(n,[...r.get(n)??[],e]),a.set(t,r)};(n.root?r.unplaced:[]).forEach(o(`the root`));for(let{name:e,unplaced:t}of i.filter(({name:e})=>n.presets.has(e)))t.forEach(o(`preset "${e}"`));return{config:{...e,root:r.root,presets:{...e.presets,...Object.fromEntries(i.map(({name:e,preset:t,root:n})=>[e,{...t,root:Qx(n)}]))}},notices:[...a].flatMap(([e,t])=>[...t].map(([t,n])=>mS(e,`${t} (in ${n.join(`, `)})`)))}}function mS(e,t){return`${e.by.file}: ${e.by.entry} places "${e.seg}" ${t}`}function hS(e,t){return{...e.globals,...dS(e.presets,t).globals}}const gS=new Map;function _S(e,t,n={}){gS.set(e,{permanent:!0,resolve:t,...n})}_S(`themes`,()=>Gv(),{paletteOf:e=>Vx(e)});const vS=`placementThemes`;_S(vS,Kv,{paletteOf:(e,t)=>Hx(e,t.palette)});for(let{name:e,members:t,library:n,labelOf:r}of Gee)_S(e,()=>t,{library:n,labelOf:r});function yS(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>Wx(n.basePalette,e.styles[t])}],[`presets`,{members:lS(e.presets)}]])}function bS(e){return[...new Set([...gS.keys(),...e.keys()])]}function xS(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=gS.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf,library:r.library,labelOf:r.labelOf};throw Error(CS(e,t))}const SS=new Map([[`looks`,`styles`],[`progressions`,`variations`]]);function CS(e,t){let n=SS.get(e);return`unknown option domain "${e}"${n===void 0?``:` — it was renamed "${n}"; write from: "${n}"`} (have: ${bS(t).join(`, `)})`}const wS=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`themeDefault`,`doctor`,`slash`,`run`,`do`];function TS(e){return JSON.stringify([e.run,Object.entries(e.env),e.cwd,e.refreshes])}function*ES(e){let t=[];DS(e,(e,n)=>(t.push([n,e]),e)),yield*t}function DS(e,t){if(`copy`in e)return{...e,copy:t(e.copy,`copy`)};if(`open`in e)return{...e,open:t(e.open,`open`)};if(`preset`in e&&e.preset===`delete`)return{...e,name:t(e.name,`name`)};if(`run`in e){let n=e.run.map((e,n)=>t(e,`run.${n}`));return{...e,run:n,env:Object.fromEntries(Object.entries(e.env).map(([e,n])=>[e,t(n,`env.${e}`)]))}}return e}function OS(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}const kS=[`plugins`,`repo`];function AS({scope:e,name:t}){return`${e}.${t}`}function jS(e){return t=>t===e||t.startsWith(`${e}.`)}const MS=`self`;function NS(e){return kS.find(t=>e===t||e.startsWith(`${t}.`))}function PS(e,t){let n=NS(e);if(n===void 0||n===e)return``;let r=kS.filter(e=>e!==n).map(t=>`${t}${e.slice(n.length)}`).find(t);return r===void 0?``:` ("${r}" is declared: a repository's own plugins are named under repo., installed ones under plugins., and a name in one is never looked up in the other)`}const FS=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*IS(e){let t=e.indexOf(`{{`);for(;t!==-1;){let n=``,r=t+2,i=[[0,r]];for(;r<e.length&&!e.startsWith(`}}`,r);){if(e.startsWith(`/*`,r)){let t=e.indexOf(`*/`,r+2);r=t===-1?e.length:t+2,i.push([n.length,r]);continue}let t=r,a=e[r];if(r+=1,a===`"`||a===`'`||a==="`"){for(;r<e.length&&e[r]!==a;)r+=e[r]===`\\`&&a!=="`"?2:1;r+=1}n+=e.slice(t,r)}if(r>=e.length)return;yield{text:n,at:e=>{let[t,n]=i[0];for(let[r,a]of i)r<=e&&([t,n]=[r,a]);return n+e-t}},t=e.indexOf(`{{`,r+2)}}const LS=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,RS=RegExp(`^(?:(\\$)(?:\\.(${LS}))?|\\.(${LS})?)(?=[\\s)]|$)`);function zS(e,t,n){let r=RS.exec(e.trimStart());if(r===null)return null;let[i,a]=r[1]===void 0?[t,r[3]]:[n,r[2]];return i===null?null:a===void 0?i:`${i}${a}.`}const BS=/^(\w+)\b\s*([\s\S]*)$/;function*VS(e,t){let n=[t];for(let r of IS(e)){let e=r.text.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=BS.exec(e)??[],o=n[n.length-1],s=n.length>1?n[n.length-2]:o;if(i===`end`){n.length>1&&n.pop();continue}if(i===`else`){yield{code:e,dot:s,block:r};let i=/^with\b([\s\S]*)$/.exec(a);n[n.length-1]=i===null?s:zS(i[1],s,t);continue}yield{code:e,dot:o,block:r},i===`if`&&n.push(o),i===`with`&&n.push(zS(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const HS=/(?<![.$])\btemplate\s+$/;function*US(e,t,n){let r=0;for(let i of[...e.matchAll(FS)]){let a=i.index+i[0].length;HS.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:zS(e.slice(a),t,n),index:i.index}),r=a}}function*WS(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...VS(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...US(s,c,i)]){let i=Object.hasOwn(t,e.name)?t[e.name]:void 0,a=`${e.name}\0${e.at??`\0`}`;i===void 0||o.has(e.name)||n.has(a)||(n.add(a),yield*r(i,e.at,e.name,new Set([...o,e.name])))}}}yield*r(e,``,null,new Set)}function GS(e){let t=new Map;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))}const KS=new WeakMap;function qS(e,t){let n=KS.get(t);return n===void 0&&(n=GS(e=>[...WS(e,t)]),KS.set(t,n)),n(e)}const JS=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${LS})`,`g`);function*YS({code:e,dot:t,root:n}){let r=e.replace(FS,``);for(let e of[...r.matchAll(JS)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function XS(e,t){let n=new Map;for(let r of qS(e,t))for(let e of YS(r))n.has(e)||n.set(e,r.via);return n}const ZS=/(?<![.$])\b(action|picker|menu|carousel|swatches|swatch|themePreview)\s+$/,QS={action:1,picker:2,menu:1,carousel:2,swatch:1,swatches:2,themePreview:1};function*$S(e){let t=0,n=0,r=`action`;for(let i of[...e.matchAll(FS)]){let a=e.slice(t,i.index),o=ZS.exec(a);o===null?a.trim()!==``&&(n=0):(n=QS[o[1]],r=o[1]===`action`?`action`:`options`),n>0&&(yield{name:i[0].slice(1,-1),site:r,index:i.index},n--),t=i.index+i[0].length}}function eC(e,t){let n=new Map;for(let{code:r,via:i}of qS(e,t))for(let{name:e,site:t}of $S(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}const tC=e=>Object.keys(QS).filter(t=>QS[t]>=e).join(`|`),nC=RegExp(`(?<![\\w.$])(?:(?:${tC(1)})\\s+|(?:${tC(2)})\\s+""\\s+)(?=[^\\s"\`)|}])`);function rC(e,t){for(let{code:n}of qS(e,t))if(nC.test(n.replace(FS,`""`)))return!0;return!1}const iC=/(?<![\w.$])[A-Za-z_]\w*/g;function aC(e,t){let n=new Set;for(let{code:r}of qS(e,t))for(let[e]of r.replace(FS,``).matchAll(iC))n.add(e);return n}function oC(e,t){return new Set([...sC(e,t)].filter(e=>Object.hasOwn(t,e)))}function sC(e,t){let n=new Set;for(let{code:r,dot:i,root:a}of qS(e,t))for(let{name:e}of US(r,i,a))n.add(e);return n}const cC=e=>RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.${e}(?![A-Za-z0-9_])`,`g`);function lC(e,t,n){let r=cC(t),i=jS(t),a=[];for(let{dot:t,block:n}of VS(e,``)){let e=n.text.replace(FS,e=>` `.repeat(e.length));for(let i of e.matchAll(r))(i[1]===`$`?``:t)===``&&a.push(n.at(i.index+i[1].length+1));for(let{name:e,index:r}of[...US(n.text,t,``),...$S(n.text)])i(e)&&a.push(n.at(r+1))}return[...new Set(a)].sort((e,t)=>t-e).reduce((e,r)=>e.slice(0,r)+n+e.slice(r+t.length),e)}function*uC(e){for(let[t,n]of Object.entries(e.variables))yield[t,n,[`variables`,t]];for(let[t,n]of Object.entries(e.segments))for(let[e,r]of Object.entries(n.vars??{}))yield[`${t}.${e}`,r,[`segments`,t,`vars`,e]]}function*dC(e){for(let[t,n]of uC(e))yield[t,n]}function fC(e,t){let n=e.split(`.`);for(let e=n.length;e>0;e--){let r=n.slice(0,e).join(`.`);if(t.has(r))return[r]}let r=`${e}.`;return[...t].filter(e=>e.startsWith(r))}function pC(e,t){return fC(e,t.names).some(n=>!e.startsWith(`${n}.`)||t.documents.has(n))}function mC(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),hC(r)&&n.add(e)};for(let[t,n]of dC(e))r(t,n);return{names:t,documents:n,helpers:e.helpers}}function hC(e){return e.kind===`dropped`||e.kind===`source`||(e.kind===`shell`||e.kind===`file`)&&Ry(e.parse)===`json`}var gC=Ee((e=>{function t(e,...t){throw Error(`[MobX] minified error nr: ${e}${t.length?` `+t.map(String).join(`,`):``}. See mobx.js.org/errors`)}function n(e){let t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}function r(e){return typeof e==`function`}function i(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function a(e){return typeof e==`object`&&!!e}function o(e){if(!a(e))return!1;let t=Object.getPrototypeOf(e);if(t==null)return!0;let n=p(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===Bt}function s(e){let t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function c(e,t,n){It(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function l(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return a(e)&&!0===e[n]}}function u(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function d(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function f(e){return e===null?null:typeof e==`object`?``+e:e}function p(e,t){return Lt.hasOwnProperty.call(e,t)}function m(e,t){return!!(e&t)}function h(e,t,n){return n?e|=t:e&=~t,e}function g(e,t=Vt,n=Vt){let r=new Wt(e);return t!==Vt&&(r.onBOL=new Set([t])),n!==Vt&&(r.onBUOL=new Set([n])),r}function _(e,t){return kt(e,t)}function v(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||Qe(e)?e:Array.isArray(e)?sn.array(e,{name:n}):o(e)?sn.object(e,void 0,{name:n}):u(e)?sn.map(e,{name:n}):d(e)?sn.set(e,{name:n}):typeof e!=`function`||Ve(e)||Ye(e)?e:s(e)?Gn(e):Ln(n,e)}function y(e){return e}function b(e,t){return{t:e,i:t,o:x,u:S}}function x(e,t,n,r){var i;return(i=this.i)!=null&&i.bound?this.u(e,t,n,!1)===null?0:1:r===e.h?this.u(e,t,n,!1)===null?0:2:Ve(n.value)?1:(It(r,t,w(e,this,t,n,!1)),2)}function S(e,t,n,r){let i=w(e,this,t,n);return e.l(t,i,r)}function C(e,n,r){let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>{var t;return _e(s.i?.name??a.toString(),e,(t=s.i?.autoAction)!=null&&t)};return i==`field`?function(e){var t;let n=e;return Ve(n)||(n=c(n)),(t=s.i)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n}:i==`method`?(Ve(n)||(n=c(n)),(l=s.i)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),n):void t(43,s.t,String(a),i);var l}function w(e,t,n,r,i=N.safeDescriptors){var a,o,s;let{value:c}=r;return(a=t.i)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:_e(t.i?.name??n.toString(),c,(o=t.i?.autoAction)!=null&&o,(s=t.i)!=null&&s.bound?e.v??e.h:void 0),configurable:!i||e.p,enumerable:!1,writable:!i}}function T(e,t){return{t:e,i:t,o:ee,u:te}}function ee(e,t,n,r){var i;return r===e.h?this.u(e,t,n,!1)===null?0:2:(i=this.i)!=null&&i.bound&&(!p(e.h,t)||!Ye(e.h[t]))&&this.u(e,t,n,!1)===null?0:Ye(n.value)?1:(It(r,t,ne(e,0,0,n,!1,!1)),2)}function te(e,t,n,r){let i=ne(e,0,0,n,this.i?.bound);return e.l(t,i,r)}function E(e,t,n){var r;let{name:i,addInitializer:a}=n;return Ye(t)||(t=Gn(t)),(r=e.i)!=null&&r.bound&&a(function(){let e=this,t=e[i].bind(e);t.isMobXFlow=!0,e[i]=t}),t}function ne(e,t,n,r,i,a=N.safeDescriptors){let{value:o}=r;return Ye(o)||(o=Gn(o)),i&&(o=o.bind(e.v??e.h),o.isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function D(e,t){return{t:e,i:t,o:re,u:ie}}function re(e,t,n){return this.u(e,t,n,!1)===null?0:1}function ie(e,t,n,r){return e.m(t,Pt({},this.i,{get:n.get,set:n.set}),r)}function O(e,t,n){function r(e){let n=Pt({},i.i,{get:t,context:e});return n.name||=`ObservableObject.${a.toString()}`,new yn(n)}let i=e,{name:a,addInitializer:o}=n,s;return o(function(){let e=St(this)[j],n=this,i=e.j.get(a);i instanceof yn&&i.derivation!==t&&e.j.delete(a),(e.O??=new Map).set(a,()=>r(n))}),function(){let e=this[j],n=e.j.get(a);if(n instanceof yn&&n.derivation!==t){let e=s?.get(this);return e||(e=r(this),(s??=new WeakMap).set(this,e)),e.get()}return e._(a)}}function ae(e,t){return{t:e,i:t,o:oe,u:se}}function oe(e,t,n){return this.u(e,t,n,!1)===null?0:1}function se(e,t,n,r){return e.S(t,n.value,this.i?.A??v,r)}function ce(e,t,n){function r(e,t){let n=St(e)[j];return(n.V??=new Map).set(o,()=>new _n(t,i.i?.A??v,`ObservableObject.${o.toString()}`,!1)),n}let i=e,{kind:a,name:o}=n;if(a===`accessor`)return{get(){return(this[j]??r(this,t.get.call(this)))._(o)},set(e){return(this[j]??r(this,e)).M(o,e)},init(e){return r(this,e),e}}}function le(e){return{t:Jt,i:e,o:ue,u:de}}function ue(e,t,n,r){var i,a,o;if(n.get)return dn.o(e,t,n,r);if(n.set){let i=Ve(n.set)?n.set:_e(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!N.safeDescriptors||e.p,set:i})===null?0:2:(It(r,t,{configurable:!0,set:i}),2)}if(r!==e.h&&typeof n.value==`function`)return s(n.value)?((o=this.i)!=null&&o.autoBind?Kn:Gn).o(e,t,n,r):((a=this.i)!=null&&a.autoBind?zn:Ln).o(e,t,n,r);let c=!1===this.i?.deep?nn:sn;return typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),c.o(e,t,n,r)}function de(e,t,n,r){var i;return n.get?dn.u(e,t,n,r):n.set?e.l(t,{configurable:!N.safeDescriptors||e.p,set:_e(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),(!1===this.i?.deep?nn:sn).u(e,t,n,r))}function fe(e,t){return Pt(function(n,r){if(r&&typeof r.kind==`string`)return t(e,n,r)},e)}function pe(e){return e||Xt}function me(e){return fe(e,ce)}function he(e){return!0===e.deep?v:!1===e.deep?y:(t=e.defaultDecorator)&&(n=(r=t.i)?.A)!=null?n:v;var t,n,r}function ge(e){return fe(e,O)}function _e(e,t,n=!1,r){function i(){return ve(0,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=()=>t.toString(),hn&&(gn.value=e,It(i,`name`,gn)),i}function ve(e,t,n,r,i){let a=ye(0,t);try{return n.apply(r,i)}catch(e){throw a.N=e,e}finally{be(a)}}function ye(e,t){let n=N.trackingDerivation,r=!t||!n;k();let i=N.allowStateChanges;r&&De();let a={R:r,k:n,C:i,I:N.allowStateReads,P:!1,T:0,B:mn++,D:pn};return pn=a.B,a}function be(e){pn!==e.B&&t(30),pn=e.D,e.N!==void 0&&(N.suppressReactionErrors=!0),Ne(),e.R&&Oe(e.k),N.suppressReactionErrors=!1}function xe(e,t){let n=function(e){let t=N.allowStateChanges;return N.allowStateChanges=e,t}(e);try{return t()}finally{(function(e){N.allowStateChanges=e})(n)}}function Se(e){return e instanceof xn}function Ce(e){switch(e.K){case 0:return!1;case-1:case 2:return!0;case 1:{let t=De(),n=e.L,r=n.length;for(let i=0;i<r;i++){let r=n[i];if(bn(r)){if(N.disableErrorBoundaries)r.get();else try{r.get()}catch{return Oe(t),!0}if(e.K===2)return Oe(t),!0}}return ke(e),Oe(t),!1}}}function we(e,t,n){ke(e),e.$=Array(e.U===0?100:e.L.length),e.W=0,e.U=++N.runId;let r=N.trackingDerivation,i;if(N.trackingDerivation=e,N.inBatch++,!0===N.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new xn(e)}return N.inBatch--,N.trackingDerivation=r,function(e){let t=e.L,n=e.L=e.$,r=0,i=0,a=e.W;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.K>r&&(r=t.K)}for(n.length=i,e.$=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&je(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,Ae(t,e))}r!==0&&(e.K=r,e.q())}(e),i}function Te(e){let t=e.L;e.L=[];let n=t.length;for(;n--;)je(t[n],e);e.K=-1}function Ee(e){let t=De();try{return e()}finally{Oe(t)}}function De(){let e=N.trackingDerivation;return N.trackingDerivation=null,e}function Oe(e){N.trackingDerivation=e}function ke(e){if(e.K===0)return;e.K=0;let t=e.L,n=t.length;for(;n--;)t[n].F=0}function Ae(e,t){(e.H??=new Set).add(t),e.F>t.K&&(e.F=t.K)}function je(e,t){let n=e.H;n&&(n.delete(t),n.size===0&&Me(e))}function Me(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,N.pendingUnobservations.push(e))}function k(){N.inBatch++}function Ne(){--N.inBatch===0&&(Ie(),!N.isRunningUnobservations&&N.pendingUnobservations.length>0&&function(){N.isRunningUnobservations=!0;try{let e=N.pendingUnobservations;for(let t=0;t<e.length;t++){let n=e[t];n.isPendingUnobservation=!1,n.H&&n.H.size!==0||(n.H=null,n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof yn&&n.G())}N.pendingUnobservations=[]}finally{N.isRunningUnobservations=!1}}())}function Pe(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.L)==null||t.forEach(Pe))}function Fe(e){let t=N.trackingDerivation;return t===null?((!e.H||e.H.size===0)&&N.inBatch>0&&Me(e),!1):(t.U!==e.J&&(e.J=t.U,t.$[t.W++]=e,!e.isBeingObserved&&N.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function A(e){var t;e.F!==2&&(e.F=2,(t=e.H)==null||t.forEach(e=>{e.K===0&&e.q(),e.K=2}))}function Ie(){N.inBatch>0||N.isRunningReactions||On(Le)}function Le(){N.isRunningReactions=!0;let e=N.pendingReactions,t=0;for(;e.length>0;){++t===Dn&&(console.error(`[mobx] cycle in reaction: ${e[0]}`),e.splice(0));let n=e.splice(0);for(let e=0,t=n.length;e<t;e++)n[e].X()}N.isRunningReactions=!1}function Re(e){return fe(e,C)}function ze(e){return function(t,n){return n&&typeof n.kind==`string`?C(e?Pn:Mn,t,n):r(t)?_e(t.name||`<unnamed action>`,t,e):r(n)?_e(t,n,e):i(t)?Re(b(e?jn:An,{name:t,autoAction:e})):void 0}}function Be(e){return ve(0,!1,e,this,void 0)}function Ve(e){return r(e)&&!0===e.isMobxAction}function He(e,t=zt){function n(){e(a)}var r;let i=t?.name??`Autorun`,a;if(t.scheduler||t.delay){let e=Ue(t),r=!1;a=new En(i,()=>{r||(r=!0,e(()=>{r=!1,a.isDisposed||a.track(n)}))},t.onError,t.requiresObservable)}else a=new En(i,function(){this.track(n)},t.onError,t.requiresObservable);return t!=null&&(r=t.signal)!=null&&r.aborted||a.Y(),a.Z(t?.signal)}function Ue(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Bn}function We(e,t,n,i){let a=typeof i==`function`?Tt(t,n):Tt(t),o=r(i)?i:n,s=`${e}L`;return a[s]?a[s].add(o):a[s]=new Set([o]),function(){let e=a[s];e&&(e.delete(o),e.size===0&&delete a[s])}}function Ge(e,t,n,r){let i=Ut(t);return Ot(()=>{let t=St(e,r)[j];Ht(i).forEach(e=>{t.u(e,i[e],!n||!(e in n)||n[e])})}),e}function Ke(e){let t={name:e.tt};var n;return e.L&&e.L.length>0&&(t.dependencies=(n=e.L,Array.from(new Set(n))).map(Ke)),t}function qe(e){let t={name:e.tt};return function(e){return!!e.H&&e.H.size>0}(e)&&(t.observers=Array.from(function(e){return e.H??new Set}(e),qe)),t}function Je(e){r(e.cancel)&&e.cancel()}function Ye(e){return!0===e?.isMobXFlow}function Xe(e,t){var n;if(t===void 0)return bn(e);if(!1===wt(e))return!1;let r=e[j];return(n=r.O)!=null&&n.has(t)?!0:r.j.has(t)?bn(Tt(e,t)):!1}function Ze(e,t){if(!e)return!1;if(t!==void 0){if(wt(e)){var n,r;let i=e[j];return i.j.has(t)||!((n=i.O)==null||!n.has(t))||!((r=i.V)==null||!r.has(t))}return!1}return wt(e)||!!e[j]||Gt(e)||kn(e)||bn(e)}function Qe(e){return Ze(e)}function $e(e){return wt(e)?e[j].nt():ir(e)||sr(e)?Array.from(e.keys()):yt(e)?e.map((e,t)=>t):void t(5)}function et(e,n){return wt(e)?e[j].et(n):ir(e)||sr(e)?e.has(n):yt(e)?n>=0&&n<e.length:void t(10)}function tt(e){if(wt(e))return e[j].it();t(38)}function nt(e,t,n){if(bn(e)){let r,i=!0;return He(()=>{let a=e.get();if(!i||n){let n=De();t({observableKind:`computed`,debugObjectName:e.tt,type:Xn,object:e,newValue:a,oldValue:r}),Oe(n)}i=!1,r=a})}return n&&t({observableKind:`value`,debugObjectName:e.tt,object:e,type:Xn,newValue:e.rt,oldValue:void 0}),ft(e,t)}function rt(e,t,n){return e.set(t,n),n}function it(e,t){if(typeof e!=`object`||!e||e instanceof Date||!Qe(e))return e;if(vn(e)||bn(e))return it(e.get(),t);if(t.has(e))return t.get(e);if(yt(e)){let n=rt(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=it(e,t)}),n}if(sr(e)){let n=rt(t,e,new Set);return e.forEach(e=>{n.add(it(e,t))}),n}if(ir(e)){let n=rt(t,e,new Map);return e.forEach((e,r)=>{n.set(r,it(e,t))}),n}{let n=rt(t,e,{});return tt(e).forEach(r=>{Lt.propertyIsEnumerable.call(e,r)&&(n[r]=it(e[r],t))}),n}}function at(e,t){k();try{return e.apply(t)}finally{Ne()}}function ot(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[j].isDisposed){if(a(),!n.onError)throw e;n.onError(e)}},n.timeout)}n.name=`When`;let i=_e(`When-effect`,t);var a=He(t=>{xe(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function st(e){return e[j]}function ct(e){return e.st!==void 0&&e.st.length>0}function lt(e,t){let r=e.st;return r?r.push(t):r=e.st=[t],n(()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)})}function ut(e,n){let r=De();try{let r=[...e.st||[]];for(let e=0,i=r.length;e<i&&((n=r[e](n))&&!n.type&&t(14),n);e++);return n}finally{Oe(r)}}function dt(e){return e.ot!==void 0&&e.ot.length>0}function ft(e,t){let r=e.ot;return r?r.push(t):r=e.ot=[t],n(()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)})}function pt(e,t){let n=De(),r=e.ot;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Oe(n)}}function mt(e,n,r){if(!0===r&&(r=e.ut),!1===r)return;n in e.h||t(1,r.t,`${e.tt}.${n.toString()}`);let i=e.h;for(;i&&i!==Lt;){let t=Ft(i,n);if(t){let a=r.o(e,n,t,i);if(a===0)return;if(a===1)break}i=Object.getPrototypeOf(i)}}function ht(e,t){typeof Array.prototype[e]==`function`&&($n[e]=t(e))}function gt(e){return function(){let t=this[j];t.ct.reportObserved();let n=t.ht(t.j);return n[e].apply(n,arguments)}}function _t(e){return function(t,n){let r=this[j];return r.ct.reportObserved(),r.ht(r.j)[e]((e,r)=>t.call(n,e,r,this))}}function vt(e){return function(){let t=this[j];t.ct.reportObserved();let n=t.ht(t.j),r=arguments[0];return arguments[0]=(e,t,n)=>r(e,t,n,this),n[e].apply(n,arguments)}}function yt(e){return a(e)&&er(e[j])}function bt(e){return e[Symbol.toStringTag]=`MapIterator`,Mt(e)}function xt(e){return e[Symbol.toStringTag]=`SetIterator`,Mt(e)}function St(e,t){if(p(e,j))return e;let n=t?.name??`ObservableObject`;return c(e,j,new ur(e,new Map,String(n),function(e){return e?e.defaultDecorator??function(e){let t=!1!==e.deep,n=!!e.autoBind,r=!t|(n?2:0);return M[r]??(M[r]=le({deep:t,autoBind:n}))}(e):void 0}(t))),e}function Ct(e){return cr[e]||(cr[e]={get(){return this[j]._(e)},set(t){return this[j].M(e,t)}})}function wt(e){return!!a(e)&&dr(e[j])}function Tt(e,n){if(typeof e==`object`&&e){if(yt(e))return n!==void 0&&t(23),e[j].ct;if(sr(e))return e.ct;if(ir(e)){if(n===void 0)return e.lt;let r=e.ft.get(n)||e.dt.get(n);return r||t(25,n,Dt(e)),r}if(wt(e)){if(!n)return t(26);let r=e[j],i=r.j.get(n)??r.vt(n)??r.bt(n);return i||t(27,n,Dt(e)),i}if(Gt(e)||bn(e)||kn(e))return e}else if(r(e)&&kn(e[j]))return e[j];t(28)}function Et(e,n){return e||t(29),n===void 0?Gt(e)||bn(e)||kn(e)||ir(e)||sr(e)?e:e[j]?e[j]:void t(24,e):Et(Tt(e,n))}function Dt(e,t){let n;if(t!==void 0)n=Tt(e,t);else{if(Ve(e))return e.name;n=wt(e)||ir(e)||sr(e)?Et(e):Tt(e)}return n.tt}function Ot(e){let t=De();k();try{return e()}finally{Ne(),Oe(t)}}function kt(e,t,n=-1){return At(e,t,n)}function At(e,t,n,i,a){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!=e)return t!=t;let o=typeof e;if(o!==`function`&&o!==`object`&&typeof t!=`object`)return!1;let s=fr.call(e);if(s!==fr.call(t))return!1;switch(s){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++}e=jt(e),t=jt(t);let c=s===`[object Array]`;if(!c){if(typeof e!=`object`||typeof t!=`object`)return!1;let n=e.constructor,i=t.constructor;if(n!==i&&!(r(n)&&n instanceof n&&r(i)&&i instanceof i)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),a||=[];let l=(i||=[]).length;for(;l--;)if(i[l]===e)return a[l]===t;if(i.push(e),a.push(t),c){if(l=e.length,l!==t.length)return!1;for(;l--;)if(!At(e[l],t[l],n-1,i,a))return!1}else{let r=Object.keys(e),o=r.length;if(Object.keys(t).length!==o)return!1;for(let s=0;s<o;s++){let o=r[s];if(!p(t,o)||!At(e[o],t[o],n-1,i,a))return!1}}return i.pop(),a.pop(),!0}function jt(e){return yt(e)?e.slice():u(e)||ir(e)||d(e)||sr(e)?Array.from(e.entries()):e}function Mt(e){return e[Symbol.iterator]=Nt,Pt(Object.create(pr),e)}function Nt(){return this}Object.defineProperty(e,`__esModule`,{value:!0});let Pt=Object.assign,Ft=Object.getOwnPropertyDescriptor,It=Object.defineProperty,Lt=Object.prototype,Rt=[];Object.freeze(Rt);let zt={};Object.freeze(zt);let Bt=Object.toString(),Vt=()=>{},Ht=Reflect.ownKeys,Ut=Object.getOwnPropertyDescriptors,j=Symbol(`mobx administration`);var Wt=class{constructor(e=`Atom`){this.tt=void 0,this.yt=0,this.H=null,this.J=0,this.F=-1,this.onBOL=void 0,this.onBUOL=void 0,this.tt=e}get isBeingObserved(){return m(this.yt,1)}set isBeingObserved(e){this.yt=h(this.yt,1,e)}get isPendingUnobservation(){return m(this.yt,2)}set isPendingUnobservation(e){this.yt=h(this.yt,2,e)}get diffValue(){return+!!m(this.yt,4)}set diffValue(e){this.yt=h(this.yt,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return Fe(this)}reportChanged(){k(),A(this),Ne()}toString(){return this.tt}};let Gt=l(`Atom`,Wt),Kt=Object.is,qt={t:`override`,o:function(){return 0},u:function(){t(44,this.t)}},Jt=`true`,Yt=le(),M=[Yt],Xt={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Xt);let Zt=ae(`observable`),Qt=ae(`observable.ref`,{A:y}),$t=ae(`observable.shallow`,{A:function(e,t,n){return e==null||wt(e)||yt(e)||ir(e)||sr(e)?e:Array.isArray(e)?sn.array(e,{name:n,deep:!1}):o(e)?sn.object(e,void 0,{name:n,deep:!1}):u(e)?sn.map(e,{name:n,deep:!1}):d(e)?sn.set(e,{name:n,deep:!1}):void 0}}),en=ae(`observable.struct`,{A:function(e,t){return kt(e,t)?t:e}}),tn={box(e,t){let n=pe(t);return new _n(e,he(n),n.name,!0,n.equals)},array(e,t){let n=pe(t);return function(e,t,n=`ObservableArray`,r=!1){return Ot(()=>{let i=new Qn(n,t,r);It(i.j,j,{enumerable:!1,writable:!1,configurable:!0,value:i});let a=new Proxy(i.j,Zn);return i.v=a,e&&e.length&&i.wt(0,0,e),a})}(e,he(n),n.name)},map(e,t){let n=pe(t);return new rr(e,he(n),n.name)},set(e,t){let n=pe(t);return new or(e,he(n),n.name)},object:(e,t,n)=>Ot(()=>Ge(function(e,t){var n;return(n=(e=St(e,t))[j]).v??(n.v=new Proxy(e,qn))}({},n),e,t))},nn=me(Qt),rn=me($t),an=me(Zt),on=me(en);var sn=Pt(function(e,t,n){return t&&typeof t.kind==`string`?ce(Zt,e,t):Qe(e)?e:o(e)?sn.object(e,t,n):Array.isArray(e)?sn.array(e,t):u(e)?sn.map(e,t):d(e)?sn.set(e,t):typeof e==`object`&&e?e:sn.box(e,t)},Zt,tn);let cn=`computed`,ln=D(cn),un=ge(D(`computed.struct`,{equals:_})),dn=function(e,t){if(t&&typeof t.kind==`string`)return O(ln,e,t);if(o(e))return ge(D(cn,e));let n=o(t)?t:{};return n.get=e,n.name||=e.name||``,new yn(n)};var fn;Pt(dn,ln);let pn=0,mn=1,hn=(fn=Ft(()=>{},`name`)?.configurable)!=null&&fn,gn={value:`action`,configurable:!0,writable:!1,enumerable:!1};var _n=class extends Wt{constructor(e,t,n=`ObservableValue`,r=!0,i=Kt){super(n),this.A=void 0,this.tt=void 0,this.xt=void 0,this.gt=!1,this.st=void 0,this.ot=void 0,this.rt=void 0,this.dehancer=void 0,this.A=t,this.tt=n,this.xt=i,this.rt=t(e,void 0,n)}dehanceValue(e){return this.dehancer===void 0?e:this.dehancer(e)}set(e){(e=this.jt(e))!==N.UNCHANGED&&this.Ot(e)}jt(e){if(ct(this)){let t=ut(this,{object:this,type:Xn,newValue:e});if(!t)return N.UNCHANGED;e=t.newValue}return e=this.A(e,this.rt,this.tt),this.xt(this.rt,e)?N.UNCHANGED:e}Ot(e){let t=this.rt;this.rt=e,this.reportChanged(),dt(this)&&pt(this,{type:Xn,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.rt)}raw(){return this.rt}toJSON(){return this.get()}toString(){return`${this.tt}[${this.rt}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let vn=l(`ObservableValue`,_n);var yn=class{constructor(e){this.K=-1,this.L=[],this.$=null,this.H=null,this.U=0,this.J=0,this.F=0,this.W=0,this.rt=new xn(null),this.tt=void 0,this._t=void 0,this.yt=0,this.derivation=void 0,this.St=void 0,this.At=void 0,this.xt=void 0,this.Vt=void 0,this.Mt=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||t(31),this.derivation=e.get,this.tt=e.name||`ComputedValue`,e.set&&(this.St=_e(`ComputedValue-setter`,e.set)),this.xt=e.equals||Kt,this.At=e.context,this.Vt=e.requiresReaction,this.Mt=!!e.keepAlive}q(){(function(e){var t;e.F===0&&(e.F=1,(t=e.H)==null||t.forEach(e=>{e.K===0&&(e.K=1,e.q())}))})(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return m(this.yt,1)}set isComputing(e){this.yt=h(this.yt,1,e)}get isRunningSetter(){return m(this.yt,2)}set isRunningSetter(e){this.yt=h(this.yt,2,e)}get isBeingObserved(){return m(this.yt,4)}set isBeingObserved(e){this.yt=h(this.yt,4,e)}get isPendingUnobservation(){return m(this.yt,8)}set isPendingUnobservation(e){this.yt=h(this.yt,8,e)}get diffValue(){return+!!m(this.yt,16)}set diffValue(e){this.yt=h(this.yt,16,e===1)}get(){if(this.isComputing&&t(32,this.tt,this.derivation),N.inBatch!==0||this.H&&this.H.size!==0||this.Mt){let e=this.isBeingObserved;if(Fe(this),Ce(this)){let e=N.trackingContext;e||!this.Mt&&!this.isBeingObserved||(N.trackingContext=this),this.trackAndCompute()&&function(e){var t;e.F!==2&&(e.F=2,(t=e.H)==null||t.forEach(t=>{t.K===1?t.K=2:t.K===0&&(e.F=0)}))}(this),N.trackingContext=e}else !e&&this.isBeingObserved&&this.L.forEach(Pe)}else Ce(this)&&(this.Nt(),k(),this.rt=this.Rt(!1),Ne());let e=this.rt;if(Se(e))throw e.cause;return e}set(e){if(this.St){this.isRunningSetter&&t(33,this.tt),this.isRunningSetter=!0;try{this.St.call(this.At,e)}finally{this.isRunningSetter=!1}}else t(34,this.tt)}trackAndCompute(){let e=this.rt,t=this.K===-1,n=this.Rt(!0),r=t||Se(e)||Se(n)||!this.xt(e,n);return r&&(this.rt=n),r}Rt(e){let t;if(this.isComputing=!0,e)t=we(this,this.derivation,this.At);else if(!0===N.disableErrorBoundaries)t=this.derivation.call(this.At);else try{t=this.derivation.call(this.At)}catch(e){t=new xn(e)}return this.isComputing=!1,t}G(){this.Mt||(Te(this),this.rt=void 0)}Nt(){}toString(){return`${this.tt}[${this.derivation.toString()}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let bn=l(`ComputedValue`,yn);var xn=class{constructor(e){this.cause=void 0,this.cause=e}};let Sn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var Cn=class{constructor(){this.version=7,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.isRunningUnobservations=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.safeDescriptors=!0}};let wn=!0,Tn=!1,N=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(wn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(wn=!1),wn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Cn):(setTimeout(()=>{Tn||t(35)},1),new Cn)}();var En=class{constructor(e=`Reaction`,t,n,r){this.tt=void 0,this.Et=void 0,this.kt=void 0,this.Ct=void 0,this.L=[],this.$=[],this.K=-1,this.U=0,this.W=0,this.yt=0,this.It=void 0,this.tt=e,this.Et=t,this.kt=n,this.Ct=r}get isDisposed(){return m(this.yt,1)}set isDisposed(e){this.yt=h(this.yt,1,e)}get isScheduled(){return m(this.yt,2)}set isScheduled(e){this.yt=h(this.yt,2,e)}get isTrackPending(){return m(this.yt,4)}set isTrackPending(e){this.yt=h(this.yt,4,e)}get isRunning(){return m(this.yt,8)}set isRunning(e){this.yt=h(this.yt,8,e)}get diffValue(){return+!!m(this.yt,16)}set diffValue(e){this.yt=h(this.yt,16,e===1)}q(){this.Y()}Y(){this.isScheduled||(this.isScheduled=!0,N.pendingReactions.push(this),Ie())}X(){if(!this.isDisposed){k(),this.isScheduled=!1;let e=N.trackingContext;if(N.trackingContext=this,Ce(this)){this.isTrackPending=!0;try{this.Et()}catch(e){this.Pt(e)}}N.trackingContext=e,Ne()}}track(e){if(this.isDisposed)return;k(),this.isRunning=!0;let t=N.trackingContext;N.trackingContext=this;let n=we(this,e,void 0);N.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Te(this),Se(n)&&this.Pt(n.cause),Ne()}Pt(e){if(this.kt)this.kt(e,this);else{if(N.disableErrorBoundaries)throw e;N.suppressReactionErrors||console.error(`[mobx] uncaught error in '${this}'`,e),N.globalReactionErrorHandlers.forEach(t=>t(e,this))}}dispose(){var e;this.isDisposed||(this.isDisposed=!0,(e=this.It)==null||e.call(this),this.isRunning||(k(),Te(this),Ne()))}Z(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.It=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[j]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.tt}]`}};let Dn=100,On=e=>e(),kn=l(`Reaction`,En),An=`action`,jn=`autoAction`,Mn=b(An),Nn=b(`action.bound`,{bound:!0}),Pn=b(jn,{autoAction:!0}),Fn=b(`autoAction.bound`,{autoAction:!0,bound:!0}),In=ze(!1);Pt(In,Mn);let Ln=ze(!0);Pt(Ln,Pn);let Rn=Re(Nn),zn=Re(Fn),Bn=e=>e(),Vn=`always`;var Hn=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};let Un=T(`flow`),Wn=T(`flow.bound`,{bound:!0}),Gn=Pt(function(e,t){if(t&&typeof t.kind==`string`)return E(Un,e,t);let n=e,i=n.name||`flow`,a=function(){let e=arguments,t=In(i,n).apply(this,e),a,o,s=new Promise(function(e,n){function s(e){let r;o=void 0;try{r=In(i,t.next).call(t,e)}catch(e){return n(e)}l(r)}function c(e){let r;o=void 0;try{r=In(i,t.throw).call(t,e)}catch(e){return n(e)}l(r)}function l(t){if(!r(t?.then))return t.done?e(t.value):(o=Promise.resolve(t.value),o.then(s,c));t.then(l,n)}a=n,s(void 0)});return s.cancel=In(i,function(){try{o&&Je(o);let e=t.return(void 0),n=Promise.resolve(e.value);n.then(Vt,Vt),Je(n),a(new Hn)}catch(e){a(e)}}),s};return a.isMobXFlow=!0,a},Un),Kn=fe(Wn,E),qn={has:(e,t)=>st(e).et(t),get:(e,t)=>st(e).Tt(t),set(e,t,n){var r;return!!i(t)&&((r=st(e).Bt(t,n,!0))==null||r)},deleteProperty(e,t){var n;return!!i(t)&&((n=st(e).Dt(t,!0))==null||n)},defineProperty(e,t,n){var r;return(r=st(e).l(t,n))==null||r},ownKeys:e=>st(e).it(),preventExtensions(e){t(13)}},Jn=Symbol(`mobx-keys`),Yn=`splice`,Xn=`update`,Zn={get(e,t){let n=e[j];return t===j?n:t===`length`?n.Kt():typeof t!=`string`||isNaN(t)?p($n,t)?$n[t]:e[t]:n.Tt(parseInt(t))},set(e,t,n){let r=e[j];return t===`length`?r.Lt(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.Bt(parseInt(t),n),!0},preventExtensions(){t(15)}};var Qn=class{constructor(e=`ObservableArray`,t,n){this.$t=void 0,this.ct=void 0,this.j=[],this.st=void 0,this.ot=void 0,this.A=void 0,this.dehancer=void 0,this.v=void 0,this.Ut=0,this.$t=n,this.ct=new Wt(e),this.A=(e,n)=>t(e,n,`ObservableArray[..]`)}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}ht(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e}Kt(){return this.ct.reportObserved(),this.j.length}Lt(e){(!Number.isInteger(e)||e<0)&&t(40,e);let n=this.j.length;if(e!==n)if(e>n){let t=Array.from({length:e-n});this.wt(n,0,t)}else this.wt(e,n-e)}zt(e,n){e!==this.Ut&&t(16),this.Ut+=n}wt(e,t,n){let r=this.j.length;if(e===void 0?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=arguments.length===1?r-e:t==null?0:Math.max(0,Math.min(t,r-e)),n===void 0&&(n=Rt),ct(this)){let r=ut(this,{object:this.v,type:Yn,index:e,removedCount:t,added:n});if(!r)return Rt;t=r.removedCount,n=r.added}n=n.length===0?n:n.map(e=>this.A(e,void 0));let i=this.qt(e,t,n);return t===0&&n.length===0||this.Ft(e,n,i),this.ht(i)}qt(e,t,n){if(n.length<1e4)return this.j.splice(e,t,...n);{let r=this.j.slice(e,e+t),i=this.j.slice(e+t);this.j.length+=n.length-t;for(let t=0;t<n.length;t++)this.j[e+t]=n[t];for(let t=0;t<i.length;t++)this.j[e+n.length+t]=i[t];return r}}Ht(e,t,n){let r=dt(this),i=r?{observableKind:`array`,object:this.v,type:Xn,debugObjectName:this.ct.tt,index:e,newValue:t,oldValue:n}:null;this.ct.reportChanged(),r&&pt(this,i)}Ft(e,t,n){let r=dt(this),i=r?{observableKind:`array`,object:this.v,debugObjectName:this.ct.tt,type:Yn,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.ct.reportChanged(),r&&pt(this,i)}Tt(e){return this.ct.reportObserved(),this.Wt(this.j[e])}Bt(e,t){let n=this.j;if(e<n.length){let r=n[e];if(ct(this)){let n=ut(this,{type:Xn,object:this.v,index:e,newValue:t});if(!n)return;t=n.newValue}(t=this.A(t,r))!==r&&(n[e]=t,this.Ht(e,t,r))}else{let r=Array.from({length:e+1-n.length});r[r.length-1]=t,this.wt(n.length,0,r)}}},$n={clear(){return this.splice(0)},replace(e){let t=this[j];return t.wt(0,t.j.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[j];switch(arguments.length){case 0:return[];case 1:return r.wt(e);case 2:return r.wt(e,t)}return r.wt(e,t,n)},spliceWithArray(e,t,n){return this[j].wt(e,t,n)},push(...e){let t=this[j];return t.wt(t.j.length,0,e),t.j.length},pop(){return this.splice(Math.max(this[j].j.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[j];return t.wt(0,0,e),t.j.length},reverse(){return N.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){N.trackingDerivation&&t(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[j],n=t.ht(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};ht(`at`,gt),ht(`concat`,gt),ht(`flat`,gt),ht(`includes`,gt),ht(`indexOf`,gt),ht(`join`,gt),ht(`lastIndexOf`,gt),ht(`slice`,gt),ht(`toString`,gt),ht(`toLocaleString`,gt),ht(`toSorted`,gt),ht(`toSpliced`,gt),ht(`with`,gt),ht(`every`,_t),ht(`filter`,_t),ht(`find`,_t),ht(`findIndex`,_t),ht(`findLast`,_t),ht(`findLastIndex`,_t),ht(`flatMap`,_t),ht(`forEach`,_t),ht(`map`,_t),ht(`some`,_t),ht(`toReversed`,_t),ht(`reduce`,vt),ht(`reduceRight`,vt);let er=l(`ObservableArrayAdministration`,Qn),tr={},nr=`delete`;var rr=class{constructor(e,t=v,n=`ObservableMap`){this.A=void 0,this.tt=void 0,this[j]=tr,this.ft=void 0,this.dt=void 0,this.lt=void 0,this.st=void 0,this.ot=void 0,this.dehancer=void 0,this.A=t,this.tt=n,Ot(()=>{this.lt=g(`ObservableMap.keys()`),this.ft=new Map,this.dt=new Map,e&&this.merge(e)})}et(e){return this.ft.has(e)}has(e){if(!N.trackingDerivation)return this.et(e);let t=this.dt.get(e);if(!t){let n=t=new _n(this.et(e),y,`ObservableMap.key?`,!1);this.dt.set(e,n),n.onBUOL=new Set([()=>this.dt.delete(e)])}return t.get()}set(e,t){let n=this.et(e);if(ct(this)){let r=ut(this,{type:n?Xn:`add`,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.Gt(e,t):this.Jt(e,t),this}delete(e){if(ct(this)&&!ut(this,{type:nr,object:this,name:e}))return!1;if(this.et(e)){let t=dt(this),n=t?{observableKind:`map`,debugObjectName:this.tt,type:nr,object:this,oldValue:this.ft.get(e).rt,name:e}:null;return at(()=>{var t;this.lt.reportChanged(),(t=this.dt.get(e))==null||t.Ot(!1),this.ft.get(e).Ot(void 0),this.ft.delete(e)}),t&&pt(this,n),!0}return!1}Gt(e,t){let n=this.ft.get(e);if((t=n.jt(t))!==N.UNCHANGED){let r=dt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:Xn,object:this,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}}Jt(e,t){at(()=>{var n;let r=new _n(t,this.A,`ObservableMap.key`,!1);this.ft.set(e,r),t=r.rt,(n=this.dt.get(e))==null||n.Ot(!0),this.lt.reportChanged()});let n=dt(this);n&&pt(this,n?{observableKind:`map`,debugObjectName:this.tt,type:`add`,object:this,name:e,newValue:t}:null)}get(e){return this.has(e)?this.Wt(this.ft.get(e).get()):this.Wt(void 0)}getOrInsert(e,t){return this.has(e)||this.set(e,t),this.get(e)}getOrInsertComputed(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}keys(){return this.lt.reportObserved(),this.ft.keys()}values(){let e=this,t=this.keys();return bt({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e.get(r)}}})}entries(){let e=this,t=this.keys();return bt({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:[r,e.get(r)]}}})}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}merge(e){return ir(e)&&(e=new Map(e)),at(()=>{o(e)?function(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>Lt.propertyIsEnumerable.call(e,t))]:t}(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):u(e)?(function(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}(e)||t(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&t(20,e)}),this}clear(){at(()=>{Ee(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return at(()=>{let n=function(e){if(u(e)||ir(e))return e;if(Array.isArray(e))return new Map(e);if(o(e)){let t=new Map;for(let n in e)t.set(n,e[n]);return t}return t(21,e)}(e),r=new Map,i=!1;for(let e of this.ft.keys())if(!n.has(e))if(this.delete(e))i=!0;else{let t=this.ft.get(e);r.set(e,t)}for(let[e,t]of n.entries()){let n=this.ft.has(e);if(this.set(e,t),this.ft.has(e)){let t=this.ft.get(e);r.set(e,t),n||(i=!0)}}if(!i)if(this.ft.size!==r.size)this.lt.reportChanged();else{let e=this.ft.keys(),t=r.keys(),n=e.next(),i=t.next();for(;!n.done;){if(n.value!==i.value){this.lt.reportChanged();break}n=e.next(),i=t.next()}}this.ft=r}),this}get size(){return this.lt.reportObserved(),this.ft.size}toString(){return`[object ObservableMap]`}toJSON(){return Array.from(this)}get[Symbol.toStringTag](){return`Map`}},ir=l(`ObservableMap`,rr);let ar={};var or=class{constructor(e,t=v,n=`ObservableSet`){this.tt=void 0,this[j]=ar,this.ft=new Set,this.ct=void 0,this.ot=void 0,this.st=void 0,this.dehancer=void 0,this.A=void 0,this.tt=n,this.A=(e,r)=>t(e,r,n),Ot(()=>{this.ct=g(this.tt),e&&this.replace(e)})}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){at(()=>{Ee(()=>{for(let e of this.ft.values())this.delete(e)})})}forEach(e,t){for(let n of this)e.call(t,n,n,this)}get size(){return this.ct.reportObserved(),this.ft.size}add(e){if(ct(this)){let t=ut(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){at(()=>{e=this.A(e,void 0),this.ft.add(e),this.ct.reportChanged()});let t=dt(this);t&&pt(this,t?{observableKind:`set`,debugObjectName:this.tt,type:`add`,object:this,newValue:e}:null)}return this}delete(e){if(ct(this)&&!ut(this,{type:nr,object:this,oldValue:e}))return!1;if(this.has(e)){let t=dt(this),n=t?{observableKind:`set`,debugObjectName:this.tt,type:nr,object:this,oldValue:e}:null;return at(()=>{this.ct.reportChanged(),this.ft.delete(e)}),t&&pt(this,n),!0}return!1}has(e){return this.ct.reportObserved(),this.ft.has(this.Wt(e))}entries(){let e=this.values();return xt({next(){let{value:t,done:n}=e.next();return n?{value:void 0,done:n}:{value:[t,t],done:n}}})}keys(){return this.values()}values(){this.ct.reportObserved();let e=this,t=this.ft.values();return xt({next(){let{value:n,done:r}=t.next();return r?{value:void 0,done:r}:{value:e.Wt(n),done:r}}})}intersection(e){return new Set(this).intersection(e)}union(e){return new Set(this).union(e)}difference(e){return new Set(this).difference(e)}symmetricDifference(e){return new Set(this).symmetricDifference(e)}isSubsetOf(e){return new Set(this).isSubsetOf(e)}isSupersetOf(e){return new Set(this).isSupersetOf(e)}isDisjointFrom(e){return new Set(this).isDisjointFrom(e)}replace(e){return sr(e)&&(e=new Set(e)),Array.isArray(e)||d(e)?at(()=>{let t=d(e)?e:new Set(e);if(t.size!==0)if(this.ft.size!==0){for(let e of this.ft.values())t.has(this.Wt(e))||this.delete(e);t.forEach(e=>this.add(e))}else t.forEach(e=>this.add(e));else this.clear()}):e!=null&&t(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},sr=l(`ObservableSet`,or);let cr=Object.create(null),lr=`remove`;var ur=class{constructor(e,t=new Map,n,r=Yt){this.h=void 0,this.j=void 0,this.tt=void 0,this.ut=void 0,this.lt=void 0,this.ot=void 0,this.st=void 0,this.v=void 0,this.p=void 0,this.Xt=void 0,this.Qt=void 0,this.O=void 0,this.V=void 0,this.h=e,this.j=t,this.tt=n,this.ut=r,this.lt=new Wt(`ObservableObject.keys`),this.p=o(this.h)}_(e){return(this.j.get(e)??this.vt(e)??this.bt(e)).get()}vt(e){let t=this.O?.get(e);if(!t)return;this.O.delete(e),this.O.size===0&&(this.O=void 0);let n=t();return this.j.set(e,n),n}bt(e){let t=this.V?.get(e);if(!t)return;this.V.delete(e),this.V.size===0&&(this.V=void 0);let n=t();return this.j.set(e,n),n}M(e,t){let n=this.j.get(e)??this.vt(e)??this.bt(e);if(n instanceof yn)return n.set(t),!0;if(ct(this)){let n=ut(this,{type:Xn,object:this.v||this.h,name:e,newValue:t});if(!n)return null;t=n.newValue}if((t=n.jt(t))!==N.UNCHANGED){let r=dt(this),i=r?{type:Xn,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}return!0}Tt(e){return N.trackingDerivation&&!p(this.h,e)&&this.et(e),this.h[e]}Bt(e,t,n=!1){return p(this.h,e)?this.j.has(e)?this.M(e,t):n?Reflect.set(this.h,e,t):(this.h[e]=t,!0):this.u(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.ut,n)}et(e){if(!N.trackingDerivation)return e in this.h;this.Qt||=new Map;let t=this.Qt.get(e);return t||(t=new _n(e in this.h,y,`ObservableObject.key?`,!1),this.Qt.set(e,t)),t.get()}u(e,t,n,r=!1){return!0===n&&(n=this.ut),!1===n?this.l(e,t,r):n.u(this,e,t,r)}l(e,t,n=!1){try{k();let r=this.Dt(e);if(!r)return r;if(ct(this)){let n=ut(this,{object:this.v||this.h,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:r}=n;t.value!==r&&(t=Pt({},t,{value:r}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else It(this.h,e,t);this.Yt(e,t.value)}finally{Ne()}return!0}S(e,t,n,r=!1){try{k();let i=this.Dt(e);if(!i)return i;if(ct(this)){let n=ut(this,{object:this.v||this.h,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let a=Ct(e),o={configurable:!N.safeDescriptors||this.p,enumerable:!0,get:a.get,set:a.set};if(r){if(!Reflect.defineProperty(this.h,e,o))return!1}else It(this.h,e,o);let s=new _n(t,n,`ObservableObject.key`,!1);this.j.set(e,s),this.Yt(e,s.rt)}finally{Ne()}return!0}m(e,t,n=!1){try{k();let r=this.Dt(e);if(!r)return r;if(ct(this)&&!ut(this,{object:this.v||this.h,name:e,type:`add`,newValue:void 0}))return null;t.name||=`ObservableObject.key`,t.context=this.v||this.h;let i=Ct(e),a={configurable:!N.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else It(this.h,e,a);this.j.set(e,new yn(t)),this.Yt(e,void 0)}finally{Ne()}return!0}Dt(e,t=!1){if(!p(this.h,e))return!0;if(ct(this)&&!ut(this,{object:this.v||this.h,name:e,type:lr}))return null;try{var n;k();let r=dt(this),i=this.j.get(e),a;if(i||!r||(a=Ft(this.h,e)?.value),t){if(!Reflect.deleteProperty(this.h,e))return!1}else delete this.h[e];i&&(this.j.delete(e),i instanceof _n&&(a=i.rt),A(i)),this.lt.reportChanged(),(n=this.Qt)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&pt(this,{type:lr,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{Ne()}return!0}Yt(e,t){var n;let r=dt(this);r&&r&&pt(this,r?{type:`add`,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,name:e,newValue:t}:null),(n=this.Qt)==null||(n=n.get(e))==null||n.set(!0),this.lt.reportChanged()}it(){return this.lt.reportObserved(),Ht(this.h)}nt(){return this.lt.reportObserved(),Object.keys(this.h)}};let dr=l(`ObservableObjectAdministration`,ur),fr=Lt.toString,pr=globalThis.Iterator?.prototype||{};e.$mobx=j,e.FlowCancellationError=Hn,e.ObservableMap=rr,e.ObservableSet=or,e.Reaction=En,e._allowStateChanges=xe,e._allowStateChangesInsideComputed=Be,e._allowStateReadsEnd=function(e){N.allowStateReads=e},e._allowStateReadsStart=function(e){let t=N.allowStateReads;return N.allowStateReads=e,t},e._autoAction=Ln,e._autoActionBound=zn,e._endAction=be,e._getAdministration=Et,e._getGlobalState=function(){return N},e._interceptReads=function(e,t,n){let r;return ir(e)||yt(e)||vn(e)?r=Et(e):wt(e)&&(r=Et(e,t)),r.dehancer=typeof t==`function`?t:n,()=>{r.dehancer=void 0}},e._isComputingDerivation=function(){return N.trackingDerivation!==null},e._resetGlobalState=function(){let e=new Cn;for(let t in e)Sn.indexOf(t)===-1&&(N[t]=e[t]);N.allowStateChanges=!N.enforceActions},e._startAction=ye,e.action=In,e.actionBound=Rn,e.autorun=He,e.compareDefault=Kt,e.compareIdentity=function(e,t){return e===t},e.compareShallow=function(e,t){return kt(e,t,1)},e.compareStructural=_,e.computed=dn,e.computedStruct=un,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((N.pendingReactions.length||N.inBatch||N.isRunningReactions)&&t(36),Tn=!0,wn){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),N=new Cn}}();let{enforceActions:n}=e;if(n!==void 0){let e=n===Vn?Vn:n===`observed`;N.enforceActions=e,N.allowStateChanges=!0!==e&&e!==Vn}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(N[t]=!!e[t])}),N.allowStateReads=!N.observableRequiresReaction,e.reactionScheduler&&function(e){let t=On;On=n=>e(()=>t(n))}(e.reactionScheduler)},e.createAtom=g,e.defineProperty=function(e,n,r){if(wt(e))return e[j].l(n,r);t(39)},e.entries=function(e){return wt(e)?$e(e).map(t=>[t,e[t]]):ir(e)?$e(e).map(t=>[t,e.get(t)]):sr(e)?Array.from(e.entries()):yt(e)?e.map((e,t)=>[t,e]):void t(7)},e.extendObservable=Ge,e.flow=Gn,e.flowBound=Kn,e.flowResult=function(e){return e},e.get=function(e,n){if(et(e,n))return wt(e)?e[j].Tt(n):ir(e)?e.get(n):yt(e)?e[n]:void t(11)},e.getAtom=Tt,e.getDebugName=Dt,e.getDependencyTree=function(e,t){return Ke(Tt(e,t))},e.getObserverTree=function(e,t){return qe(Tt(e,t))},e.has=et,e.intercept=function(e,t,n){return r(n)?function(e,t,n){return lt(Et(e,t),n)}(e,t,n):function(e,t){return lt(Et(e),t)}(e,t)},e.isAction=Ve,e.isBoxedObservable=vn,e.isComputed=function(e){return Xe(e)},e.isComputedProp=function(e,t){return Xe(e,t)},e.isFlow=Ye,e.isFlowCancellationError=function(e){return e instanceof Hn},e.isObservable=Qe,e.isObservableArray=yt,e.isObservableMap=ir,e.isObservableObject=wt,e.isObservableProp=function(e,t){return Ze(e,t)},e.isObservableSet=sr,e.keys=$e,e.makeAutoObservable=function(e,t,n){return o(e)?Ge(e,e,t,n):(Ot(()=>{let r=St(e,n)[j];if(!e[Jn]){let t=Object.getPrototypeOf(e),n=new Set([...Ht(e),...Ht(t)]);n.delete(`constructor`),n.delete(j),c(t,Jn,n)}e[Jn].forEach(e=>mt(r,e,!t||!(e in t)||t[e]))}),e)},e.makeObservable=function(e,t,n){return Ot(()=>{let r=St(e,n)[j];Ht(t).forEach(e=>mt(r,e,t[e]))}),e},e.observable=sn,e.observableDeep=an,e.observableRef=nn,e.observableShallow=rn,e.observableStruct=on,e.observe=function(e,t,n,i){return r(n)?function(e,t,n,r){return nt(Et(e,t),n,r)}(e,t,n,i):function(e,t,n){let r=Et(e);if(yt(e))n&&t({observableKind:`array`,object:r.v,debugObjectName:r.ct.tt,type:`splice`,index:0,added:r.j.slice(),addedCount:r.j.length,removed:[],removedCount:0});else if(!ir(e)&&!sr(e)&&!wt(e))return nt(r,t,n);return ft(r,t)}(e,t,n)},e.onBecomeObserved=function(e,t,n){return We(`onBO`,e,t,n)},e.onBecomeUnobserved=function(e,t,n){return We(`onBUO`,e,t,n)},e.onReactionError=function(e){return N.globalReactionErrorHandlers.push(e),()=>{let t=N.globalReactionErrorHandlers.indexOf(e);t>=0&&N.globalReactionErrorHandlers.splice(t,1)}},e.override=qt,e.ownKeys=tt,e.reaction=function(e,t,n=zt){function r(){if(p=!1,h.isDisposed)return;let t=!1,r=d;h.track(()=>{let n=xe(!1,()=>e(h));t=f||!m(d,n),d=n}),(f&&n.fireImmediately||!f&&t)&&o(d,r,h),f=!1}var i;let a=n.name??`Reaction`,o=In(a,n.onError?(s=n.onError,c=t,function(){try{return c.apply(this,arguments)}catch(e){s.call(this,e)}}):t);var s,c;let l=!n.scheduler&&!n.delay,u=Ue(n),d,f=!0,p=!1,m=n.equals||Kt,h=new En(a,()=>{f||l?r():p||(p=!0,u(r))},n.onError,n.requiresObservable);return n!=null&&(i=n.signal)!=null&&i.aborted||h.Y(),h.Z(n?.signal)},e.remove=function(e,n){wt(e)?e[j].Dt(n):ir(e)||sr(e)?e.delete(n):yt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=Be,e.set=function e(n,r,i){if(arguments.length===2&&!sr(n)){k();let t=r;try{for(let r in t)e(n,r,t[r])}finally{Ne()}return}wt(n)?n[j].Bt(r,i):ir(n)?n.set(r,i):sr(n)?n.add(r):yt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(42,r),k(),r>=n.length&&(n.length=r+1),n[r]=i,Ne()):t(8)},e.spy=function(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}},e.toJS=function(e){return it(e,new Map)},e.transaction=at,e.untracked=Ee,e.values=function(e){return wt(e)?$e(e).map(t=>e[t]):ir(e)?$e(e).map(t=>e.get(t)):sr(e)?Array.from(e.values()):yt(e)?e.slice():void t(6)},e.when=function(e,t,n){return arguments.length===1||t&&typeof t==`object`?function(e,t){var n;if(t!=null&&(n=t.signal)!=null&&n.aborted)return Pt(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let r,i,a=new Promise((n,a)=>{var o;let s=ot(e,n,Pt({},t,{onError:a}));r=()=>{s(),a(Error(`WHEN_CANCELLED`))},i=()=>{s(),a(Error(`WHEN_ABORTED`))},t==null||(o=t.signal)==null||o.addEventListener==null||o.addEventListener(`abort`,i)}).finally(()=>{var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,i)});return a.cancel=r,a}(e,t):ot(e,t,n||{})}})),_C=Ee((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t={0:`Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'`,1(e,t){return`Cannot apply '${e}' to '${t.toString()}': Field not found.`},5:`'keys()' can only be used on observable objects, arrays, sets and maps`,6:`'values()' can only be used on observable objects, arrays, sets and maps`,7:`'entries()' can only be used on observable objects, arrays and maps`,8:`'set()' can only be used on observable objects, arrays and maps`,9:`'remove()' can only be used on observable objects, arrays and maps`,10:`'has()' can only be used on observable objects, arrays and maps`,11:`'get()' can only be used on observable objects, arrays and maps`,12:`Invalid annotation`,13:`Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,14:`Intercept handlers should return nothing or a change object`,15:`Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,16:`Modification exception: the internal structure of an observable array was changed.`,19(e){return`Cannot initialize from classes that inherit from Map: `+e.constructor.name},20(e){return`Cannot initialize map from `+e},21(e){return`Cannot convert to map from '${e}'`},23:`It is not possible to get index atoms from arrays`,24(e){return`Cannot obtain administration from `+e},25(e,t){return`the entry '${e}' does not exist in the observable map '${t}'`},26:`please specify a property`,27(e,t){return`no observable property '${e.toString()}' found on the observable object '${t}'`},28(e){return`Cannot obtain atom from `+e},29:`Expecting some object`,30:`invalid action stack. did you forget to finish an action?`,31:`missing option for computed: get`,32(e,t){return`Cycle detected in computation ${e}: ${t}`},33(e){return`The setter of computed value '${e}' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?`},34(e){return`[ComputedValue '${e}'] It is not possible to assign a new value to a computed value.`},35:"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`",36:`isolateGlobalState should be called before MobX is running any reactions`,37(e){return`[mobx] \`observableArray.${e}()\` mutates the array in-place, which is not allowed inside a derivation. Use \`array.slice().${e}()\` instead`},38:`'ownKeys()' can only be used on observable objects`,39:`'defineProperty()' can only be used on observable objects`,40(e){return`Out of range: `+e},41(e){return`Cannot initialize set from `+e},42(e){return`Invalid index: '${e}'`},43(e,t,n){return`Cannot apply '${e}' to '${t}' (kind: ${n}):\n'${e}' can only be used on properties with a function value.`},44(e){return`'${e}' can only be used with 'makeObservable'`}};function n(e,...n){{let r=typeof e==`string`?e:t[e];throw typeof r==`function`&&(r=r.apply(null,n)),Error(`[MobX] ${r}`)}}let r=Object.assign,i=Object.getOwnPropertyDescriptor,a=Object.defineProperty,o=Object.prototype,s=[];Object.freeze(s);let c={};Object.freeze(c);let l=Object.toString();function u(){return++M.mobxGuid}function d(e){let t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}let f=()=>{};function p(e){return typeof e==`function`}function m(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function h(e){return typeof e==`object`&&!!e}function g(e){if(!h(e))return!1;let t=Object.getPrototypeOf(e);if(t==null)return!0;let n=E(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===l}function _(e){let t=e?.constructor;return t?t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`:!1}function v(e,t,n){a(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function y(e,t,n){a(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function b(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return h(e)&&e[n]===!0}}function x(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function S(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function C(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function w(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>o.propertyIsEnumerable.call(e,t))]:t}let T=Reflect.ownKeys;function ee(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function te(e){return e===null?null:typeof e==`object`?``+e:e}function E(e,t){return o.hasOwnProperty.call(e,t)}let ne=Object.getOwnPropertyDescriptors;function D(e,t){return!!(e&t)}function re(e,t,n){return n?e|=t:e&=~t,e}function ie(e,t){t.includes(e.kind)||n(`The decorator applied to '${String(e.name)}' cannot be used on a ${e.kind} element`)}let O=Symbol(`mobx administration`);var ae=class{constructor(e=`Atom@`+u()){this.name_=void 0,this.flags_=0,this.observers_=null,this.lastAccessedBy_=0,this.lowestObserverState_=-1,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}get isBeingObserved(){return D(this.flags_,1)}set isBeingObserved(e){this.flags_=re(this.flags_,1,e)}get isPendingUnobservation(){return D(this.flags_,2)}set isPendingUnobservation(e){this.flags_=re(this.flags_,2,e)}get diffValue(){return+!!D(this.flags_,4)}set diffValue(e){this.flags_=re(this.flags_,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return ln(this)}reportChanged(){an(),un(this),on()}toString(){return this.name_}};let oe=b(`Atom`,ae);function se(e,t=f,n=f){let r=new ae(e);return t!==f&&(r.onBOL=new Set([t])),n!==f&&(r.onBUOL=new Set([n])),r}function ce(e,t){return e===t}function le(e,t){return Li(e,t)}function ue(e,t){return Li(e,t,1)}let de=Object.is;function fe(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||xr(e)?e:Array.isArray(e)?ut.array(e,{name:n}):g(e)?ut.object(e,void 0,{name:n}):x(e)?ut.map(e,{name:n}):C(e)?ut.set(e,{name:n}):typeof e==`function`&&!zn(e)&&!fr(e)?_(e)?cr(e):Fn(n,e):e}function pe(e,t,r){if(e==null||Ai(e)||pi(e)||_i(e)||Si(e))return e;if(Array.isArray(e))return ut.array(e,{name:r,deep:!1});if(g(e))return ut.object(e,void 0,{name:r,deep:!1});if(x(e))return ut.map(e,{name:r,deep:!1});if(C(e))return ut.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function me(e){return e}function he(e,t){return xr(e)&&n(`observable.struct should not be used with observable values`),Li(e,t)?t:e}let ge=`override`,_e={annotationType_:ge,make_:ye,extend_:be};function ve(e){return e.annotationType_===ge}function ye(e,t){return e.isPlainObject_&&n(`Cannot apply '${this.annotationType_}' to '${e.name_}.${t.toString()}':\n'${this.annotationType_}' cannot be used on plain objects.`),E(e.appliedAnnotations_,t)||n(`'${e.name_}.${t.toString()}' is annotated with '${this.annotationType_}', but no such annotated member was found on prototype.`),0}function be(e,t,r,i){n(44,this.annotationType_)}function xe(e,t){return{annotationType_:e,options_:t,make_:Se,extend_:Ce}}function Se(e,t,n,r){var i;return(i=this.options_)!=null&&i.bound?this.extend_(e,t,n,!1)===null?0:1:r===e.target_?this.extend_(e,t,n,!1)===null?0:2:zn(n.value)?1:(a(r,t,Ee(e,this,t,n,!1)),2)}function Ce(e,t,n,r){let i=Ee(e,this,t,n);return e.defineProperty_(t,i,r)}function we(e,t,r){ie(r,[`method`,`field`]);let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>bt(s.options_?.name??a.toString(),e,s.options_?.autoAction??!1);if(i==`field`)return function(e){var t;let n=e;return zn(n)||(n=c(n)),(t=s.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(i==`method`){var l;return zn(t)||(t=c(t)),(l=s.options_)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),t}n(43,s.annotationType_,String(a),i)}function Te(e,{annotationType_:t},r,{value:i}){p(i)||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on properties with a function value.`)}function Ee(e,t,n,r,i=M.safeDescriptors){var a,o;Te(e,t,n,r);let{value:s}=r;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:bt(t.options_?.name??n.toString(),s,t.options_?.autoAction??!1,(o=t.options_)!=null&&o.bound?e.proxy_??e.target_:void 0),configurable:i?e.isPlainObject_:!0,enumerable:!1,writable:!i}}function De(e,t){return{annotationType_:e,options_:t,make_:Oe,extend_:ke}}function Oe(e,t,n,r){var i;return r===e.target_?this.extend_(e,t,n,!1)===null?0:2:(i=this.options_)!=null&&i.bound&&(!E(e.target_,t)||!fr(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:fr(n.value)?1:(a(r,t,Me(e,this,t,n,!1,!1)),2)}function ke(e,t,n,r){let i=Me(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function Ae(e,t,n){var r;ie(n,[`method`]);let{name:i,addInitializer:a}=n;return fr(t)||(t=cr(t)),(r=e.options_)!=null&&r.bound&&a(function(){let e=this,t=e[i].bind(e);t.isMobXFlow=!0,e[i]=t}),t}function je(e,{annotationType_:t},r,{value:i}){p(i)||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on properties with a generator function value.`)}function Me(e,t,n,r,i,a=M.safeDescriptors){je(e,t,n,r);let{value:o}=r;return fr(o)||(o=cr(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function k(e,t){return{annotationType_:e,options_:t,make_:Ne,extend_:Pe}}function Ne(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Pe(e,t,n,i){return A(e,this,t,n),e.defineComputedProperty_(t,r({},this.options_,{get:n.get,set:n.set}),i)}function Fe(e,t,n){ie(n,[`getter`]);let i=e,{name:a,addInitializer:o}=n,s;function c(e,n){let o=r({},i.options_,{get:t,context:e});return o.name||=`${n.name_}.${a.toString()}`,new kt(o)}return o(function(){let e=Di(this)[O],n=this,r=e.values_.get(a);r instanceof kt&&r.derivation!==t&&e.values_.delete(a),(e.lazyComputedKeys_??=new Map).set(a,()=>c(n,e))}),function(){let e=this[O],n=e.values_.get(a);if(n instanceof kt&&n.derivation!==t){let t=s?.get(this);return t||(t=c(this,e),(s??=new WeakMap).set(this,t)),t.get()}return e.getObservablePropValue_(a)}}function A(e,{annotationType_:t},r,{get:i}){i||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on getter(+setter) properties.`)}function Ie(e,t){return{annotationType_:e,options_:t,make_:Le,extend_:Re}}function Le(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Re(e,t,n,r){return Be(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer_??fe,r)}function ze(e,t,r){if(r.kind===`field`)throw n(`Please use \`@observable accessor ${String(r.name)}\` instead of \`@observable ${String(r.name)}\``);ie(r,[`accessor`]);let i=e,{kind:a,name:o}=r;if(a!==`accessor`)return;function s(e,t){let n=Di(e)[O];return(n.lazyObservableKeys_??=new Map).set(o,()=>new Dt(t,i.options_?.enhancer_??fe,`${n.name_}.${o.toString()}`,!1)),n}return{get(){return(this[O]??s(this,t.get.call(this))).getObservablePropValue_(o)},set(e){return(this[O]??s(this,e)).setObservablePropValue_(o,e)},init(e){return s(this,e),e}}}function Be(e,{annotationType_:t},r,i){`value`in i||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' cannot be used on getter/setter properties`)}let Ve=He();function He(e){return{annotationType_:`true`,options_:e,make_:Ge,extend_:Ke}}let Ue=[Ve];function We(e){let t=e.deep!==!1,n=!!e.autoBind,r=!t|(n?2:0);return Ue[r]??(Ue[r]=He({deep:t,autoBind:n}))}function Ge(e,t,n,r){var i;if(n.get)return ht.make_(e,t,n,r);if(n.set){let i=zn(n.set)?n.set:bt(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:M.safeDescriptors?e.isPlainObject_:!0,set:i})===null?0:2:(a(r,t,{configurable:!0,set:i}),2)}if(r!==e.target_&&typeof n.value==`function`){var o;if(_(n.value)){var s;return((s=this.options_)!=null&&s.autoBind?lr:cr).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?Ln:Fn).make_(e,t,n,r)}let c=this.options_?.deep===!1?ot:ut;return typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),c.make_(e,t,n,r)}function Ke(e,t,n,r){var i;return n.get?ht.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:M.safeDescriptors?e.isPlainObject_:!0,set:bt(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),(this.options_?.deep===!1?ot:ut).extend_(e,t,n,r))}function qe(e,t){return r(function(r,i){if(i&&typeof i.kind==`string`)return t(e,r,i);n(`Invalid arguments for \`${e.annotationType_}\``)},e)}let Je={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Je);function Ye(e){return e||Je}let Xe=Ie(`observable`),Ze=Ie(`observable.ref`,{enhancer_:me}),Qe=Ie(`observable.shallow`,{enhancer_:pe}),$e=Ie(`observable.struct`,{enhancer_:he});function et(e){return qe(e,ze)}function tt(e){return e.deep===!0?fe:e.deep===!1?me:rt(e.defaultDecorator)}function nt(e){return e?e.defaultDecorator??We(e):void 0}function rt(e){return e?e.options_?.enhancer_??fe:fe}function it(e,t,n){return t&&typeof t.kind==`string`?ze(Xe,e,t):xr(e)?e:g(e)?ut.object(e,t,n):Array.isArray(e)?ut.array(e,t):x(e)?ut.map(e,t):C(e)?ut.set(e,t):typeof e==`object`&&e?e:ut.box(e,t)}let at={box(e,t){let n=Ye(t);return new Dt(e,tt(n),n.name,!0,n.equals)},array(e,t){let n=Ye(t);return oi(e,tt(n),n.name)},map(e,t){let n=Ye(t);return new gi(e,tt(n),n.name)},set(e,t){let n=Ye(t);return new xi(e,tt(n),n.name)},object(e,t,n){return Fi(()=>Xn(Gr({},n),e,t))}},ot=et(Ze),st=et(Qe),ct=et(Xe),lt=et($e);var ut=r(it,Xe,at);let dt=`computed`;function ft(e){return qe(e,Fe)}let pt=k(dt),mt=ft(k(`computed.struct`,{equals:le})),ht=function(e,t){if(t&&typeof t.kind==`string`)return Fe(pt,e,t);if(g(e))return ft(k(dt,e));p(e)||n("First argument to `computed` should be an expression."),p(t)&&n("A setter as second argument is no longer supported, use `{ set: fn }` option instead");let r=g(t)?t:{};return r.get=e,r.name||=e.name||``,new kt(r)};r(ht,pt);let gt=0,_t=1,vt=i(()=>{},`name`)?.configurable??!1,yt={value:`action`,configurable:!0,writable:!1,enumerable:!1};function bt(e,t,r=!1,i){p(t)||n("`action` can only be invoked on functions"),(typeof e!=`string`||!e)&&n(`actions should have valid names, got: '${e}'`);function o(){return xt(e,r,t,i||this,arguments)}return o.isMobxAction=!0,o.toString=()=>t.toString(),vt&&(yt.value=e,a(o,`name`,yt)),o}function xt(e,t,n,r,i){let a=St(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{Ct(a)}}function St(e,t,n,r){let i=bn()&&!!e,a=0;i&&(a=Date.now(),Sn({type:N,name:e,object:n,arguments:r?Array.from(r):s}));let o=M.trackingDerivation,c=!t||!o;an();let l=M.allowStateChanges;c&&(Ht(),l=Tt(!0));let u=M.allowStateReads;j(!0);let d={runAsAction_:c,prevDerivation_:o,prevAllowStateChanges_:l,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:_t++,parentActionId_:gt};return gt=d.actionId_,d}function Ct(e){gt!==e.actionId_&&n(30),gt=e.parentActionId_,e.error_!==void 0&&(M.suppressReactionErrors=!0),Et(e.prevAllowStateChanges_),Wt(e.prevAllowStateReads_),on(),e.runAsAction_&&Ut(e.prevDerivation_),e.notifySpy_&&wn({time:Date.now()-e.startTime_}),M.suppressReactionErrors=!1}function wt(e,t){let n=Tt(e);try{return t()}finally{Et(n)}}function Tt(e){let t=M.allowStateChanges;return M.allowStateChanges=e,t}function Et(e){M.allowStateChanges=e}var Dt=class extends ae{constructor(e,t,n=`ObservableValue@`+u(),r=!0,i=de){super(n),this.enhancer_=void 0,this.name_=void 0,this.equals_=void 0,this.hasUnreportedChange_=!1,this.interceptors_=void 0,this.changeListeners_=void 0,this.value_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,this.equals_=i,this.value_=t(e,void 0,n),r&&bn()&&xn({type:`create`,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:this.value_})}dehanceValue(e){return this.dehancer===void 0?e:this.dehancer(e)}set(e){let t=this.value_;if(e=this.prepareNewValue_(e),e!==M.UNCHANGED){let n=bn();n&&Sn({type:ri,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&wn()}}prepareNewValue_(e){if(Ft(this),Kr(this)){let t=Jr(this,{object:this,type:ri,newValue:e});if(!t)return M.UNCHANGED;e=t.newValue}return e=this.enhancer_(e,this.value_,this.name_),this.equals_(this.value_,e)?M.UNCHANGED:e}setNewValue_(e){let t=this.value_;this.value_=e,this.reportChanged(),Yr(this)&&Zr(this,{type:ri,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.value_)}raw(){return this.value_}toJSON(){return this.get()}toString(){return`${this.name_}[${this.value_}]`}valueOf(){return te(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let Ot=b(`ObservableValue`,Dt);var kt=class{constructor(e){this.dependenciesState_=-1,this.observing_=[],this.newObserving_=null,this.observers_=null,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=0,this.unboundDepsCount_=0,this.value_=new jt(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||n(31),this.derivation=e.get,this.name_=e.name||`ComputedValue@`+u(),e.set&&(this.setter_=bt(this.name_+`-setter`,e.set)),this.equals_=e.equals||de,this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}onBecomeStale_(){fn(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return D(this.flags_,1)}set isComputing(e){this.flags_=re(this.flags_,1,e)}get isRunningSetter(){return D(this.flags_,2)}set isRunningSetter(e){this.flags_=re(this.flags_,2,e)}get isBeingObserved(){return D(this.flags_,4)}set isBeingObserved(e){this.flags_=re(this.flags_,4,e)}get isPendingUnobservation(){return D(this.flags_,8)}set isPendingUnobservation(e){this.flags_=re(this.flags_,8,e)}get diffValue(){return+!!D(this.flags_,16)}set diffValue(e){this.flags_=re(this.flags_,16,e===1)}get(){if(this.isComputing&&n(32,this.name_,this.derivation),M.inBatch===0&&(!this.observers_||this.observers_.size===0)&&!this.keepAlive_)Nt(this)&&(this.warnAboutUntrackedRead_(),an(),this.value_=this.computeValue_(!1),on());else{let e=this.isBeingObserved;if(ln(this),Nt(this)){let e=M.trackingContext;!e&&(this.keepAlive_||this.isBeingObserved)&&(M.trackingContext=this),this.trackAndCompute()&&dn(this),M.trackingContext=e}else !e&&this.isBeingObserved&&this.observing_.forEach(cn)}let e=this.value_;if(Mt(e))throw e.cause;return e}set(e){if(this.setter_){this.isRunningSetter&&n(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,e)}finally{this.isRunningSetter=!1}}else n(34,this.name_)}trackAndCompute(){let e=this.value_,t=this.dependenciesState_===-1,n=this.computeValue_(!0),r=t||Mt(e)||Mt(n)||!this.equals_(e,n);return r&&(this.value_=n,bn()&&xn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r}computeValue_(e){this.isComputing=!0;let t=Tt(!1),n;if(e)n=Lt(this,this.derivation,this.scope_);else if(M.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new jt(e)}return Et(t),this.isComputing=!1,n}suspend_(){this.keepAlive_||(Bt(this),this.value_=void 0)}warnAboutUntrackedRead_(){(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:M.computedRequiresReaction)&&console.warn(`[mobx] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`)}toString(){return`${this.name_}[${this.derivation.toString()}]`}valueOf(){return te(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let At=b(`ComputedValue`,kt);var jt=class{constructor(e){this.cause=void 0,this.cause=e}};function Mt(e){return e instanceof jt}function Nt(e){switch(e.dependenciesState_){case 0:return!1;case-1:case 2:return!0;case 1:{let t=j(!0),n=Ht(),r=e.observing_,i=r.length;for(let a=0;a<i;a++){let i=r[a];if(At(i)){if(M.disableErrorBoundaries)i.get();else try{i.get()}catch{return Ut(n),Wt(t),!0}if(e.dependenciesState_===2)return Ut(n),Wt(t),!0}}return Gt(e),Ut(n),Wt(t),!1}}}function Pt(){return M.trackingDerivation!==null}function Ft(e){let t=!!e.observers_&&e.observers_.size>0;!M.allowStateChanges&&(t||M.enforceActions===`always`)&&console.warn(`[MobX] `+(M.enforceActions?`Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: `:`Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: `)+e.name_)}function It(e){!M.allowStateReads&&M.observableRequiresReaction&&console.warn(`[mobx] Observable '${e.name_}' being read outside a reactive context.`)}function Lt(e,t,n){let r=j(!0);Gt(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++M.runId;let i=M.trackingDerivation;M.trackingDerivation=e,M.inBatch++;let a;if(M.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new jt(e)}return M.inBatch--,M.trackingDerivation=i,zt(e),Rt(e),Wt(r),a}function Rt(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:M.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '${e.name_}' is created/updated without reading any observable value.`)}function zt(e){let t=e.observing_,n=e.observing_=e.newObserving_,r=0,i=0,a=e.unboundDepsCount_;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.dependenciesState_>r&&(r=t.dependenciesState_)}for(n.length=i,e.newObserving_=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&nn(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,tn(t,e))}r!==0&&(e.dependenciesState_=r,e.onBecomeStale_())}function Bt(e){let t=e.observing_;e.observing_=[];let n=t.length;for(;n--;)nn(t[n],e);e.dependenciesState_=-1}function Vt(e){let t=Ht();try{return e()}finally{Ut(t)}}function Ht(){let e=M.trackingDerivation;return M.trackingDerivation=null,e}function Ut(e){M.trackingDerivation=e}function j(e){let t=M.allowStateReads;return M.allowStateReads=e,t}function Wt(e){M.allowStateReads=e}function Gt(e){if(e.dependenciesState_===0)return;e.dependenciesState_=0;let t=e.observing_,n=t.length;for(;n--;)t[n].lowestObserverState_=0}let Kt=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var qt=class{constructor(){this.version=7,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.isRunningUnobservations=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.safeDescriptors=!0}};let Jt=!0,Yt=!1,M=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Jt=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Jt=!1),Jt?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new qt):(setTimeout(()=>{Yt||n(35)},1),new qt)}();function Xt(){if((M.pendingReactions.length||M.inBatch||M.isRunningReactions)&&n(36),Yt=!0,Jt){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),M=new qt}}function Zt(){return M}function Qt(){let e=new qt;for(let t in e)Kt.indexOf(t)===-1&&(M[t]=e[t]);M.allowStateChanges=!M.enforceActions}function $t(e){return!!e.observers_&&e.observers_.size>0}function en(e){return e.observers_??new Set}function tn(e,t){(e.observers_??=new Set).add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function nn(e,t){let n=e.observers_;n&&(n.delete(t),n.size===0&&rn(e))}function rn(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,M.pendingUnobservations.push(e))}function an(){M.inBatch++}function on(){--M.inBatch===0&&(gn(),!M.isRunningUnobservations&&M.pendingUnobservations.length>0&&sn())}function sn(){M.isRunningUnobservations=!0;try{let e=M.pendingUnobservations;for(let t=0;t<e.length;t++){let n=e[t];n.isPendingUnobservation=!1,(!n.observers_||n.observers_.size===0)&&(n.observers_=null,n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof kt&&n.suspend_())}M.pendingUnobservations=[]}finally{M.isRunningUnobservations=!1}}function cn(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.observing_)==null||t.forEach(cn))}function ln(e){It(e);let t=M.trackingDerivation;return t===null?((!e.observers_||e.observers_.size===0)&&M.inBatch>0&&rn(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&M.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function un(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&e.onBecomeStale_(),e.dependenciesState_=2}))}function dn(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(t=>{t.dependenciesState_===1?t.dependenciesState_=2:t.dependenciesState_===0&&(e.lowestObserverState_=0)}))}function fn(e){var t;e.lowestObserverState_===0&&(e.lowestObserverState_=1,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&(e.dependenciesState_=1,e.onBecomeStale_())}))}var pn=class{constructor(e=`Reaction@`+u(),t,n,r){this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=-1,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.removeAbortListener_=void 0,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}get isDisposed(){return D(this.flags_,1)}set isDisposed(e){this.flags_=re(this.flags_,1,e)}get isScheduled(){return D(this.flags_,2)}set isScheduled(e){this.flags_=re(this.flags_,2,e)}get isTrackPending(){return D(this.flags_,4)}set isTrackPending(e){this.flags_=re(this.flags_,4,e)}get isRunning(){return D(this.flags_,8)}set isRunning(e){this.flags_=re(this.flags_,8,e)}get diffValue(){return+!!D(this.flags_,16)}set diffValue(e){this.flags_=re(this.flags_,16,e===1)}onBecomeStale_(){this.schedule_()}schedule_(){this.isScheduled||(this.isScheduled=!0,M.pendingReactions.push(this),gn())}runReaction_(){if(!this.isDisposed){an(),this.isScheduled=!1;let e=M.trackingContext;if(M.trackingContext=this,Nt(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&bn()&&xn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}M.trackingContext=e,on()}}track(e){if(this.isDisposed)return;an();let t=bn(),n;t&&(n=Date.now(),Sn({name:this.name_,type:`reaction`})),this.isRunning=!0;let r=M.trackingContext;M.trackingContext=this;let i=Lt(this,e,void 0);M.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Bt(this),Mt(i)&&this.reportExceptionInDerivation_(i.cause),t&&wn({time:Date.now()-n}),on()}reportExceptionInDerivation_(e){if(this.errorHandler_){this.errorHandler_(e,this);return}if(M.disableErrorBoundaries)throw e;let t=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`;M.suppressReactionErrors?console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`):console.error(t,e),bn()&&xn({type:`error`,name:this.name_,message:t,error:``+e}),M.globalReactionErrorHandlers.forEach(t=>t(e,this))}dispose(){if(!this.isDisposed){var e;this.isDisposed=!0,(e=this.removeAbortListener_)==null||e.call(this),this.isRunning||(an(),Bt(this),on())}}getDisposer_(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.removeAbortListener_=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[O]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.name_}]`}};function mn(e){return M.globalReactionErrorHandlers.push(e),()=>{let t=M.globalReactionErrorHandlers.indexOf(e);t>=0&&M.globalReactionErrorHandlers.splice(t,1)}}let hn=e=>e();function gn(){M.inBatch>0||M.isRunningReactions||hn(_n)}function _n(){M.isRunningReactions=!0;let e=M.pendingReactions,t=0;for(;e.length>0;){++t===100&&(console.error(`Reaction doesn't converge to a stable state after 100 iterations. Probably there is a cycle in the reactive function: ${e[0]}`),e.splice(0));let n=e.splice(0);for(let e=0,t=n.length;e<t;e++)n[e].runReaction_()}M.isRunningReactions=!1}let vn=b(`Reaction`,pn);function yn(e){let t=hn;hn=n=>e(()=>t(n))}function bn(){return!!M.spyListeners.length}function xn(e){if(!M.spyListeners.length)return;let t=M.spyListeners;for(let n=0,r=t.length;n<r;n++)t[n](e)}function Sn(e){xn(r({},e,{spyReportStart:!0}))}let Cn={type:`report-end`,spyReportEnd:!0};function wn(e){xn(e?r({},e,{type:`report-end`,spyReportEnd:!0}):Cn)}function Tn(e){return M.spyListeners.push(e),d(()=>{M.spyListeners=M.spyListeners.filter(t=>t!==e)})}let N=`action`,En=`autoAction`,Dn=`<unnamed action>`,On=xe(N),kn=xe(`action.bound`,{bound:!0}),An=xe(En,{autoAction:!0}),jn=xe(`autoAction.bound`,{autoAction:!0,bound:!0});function Mn(e){return qe(e,we)}function Nn(e){return function(t,r){if(r&&typeof r.kind==`string`)return we(e?An:On,t,r);if(p(t))return bt(t.name||Dn,t,e);if(p(r))return bt(t,r,e);if(m(t))return Mn(xe(e?En:N,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}let Pn=Nn(!1);r(Pn,On);let Fn=Nn(!0);r(Fn,An);let In=Mn(kn),Ln=Mn(jn);function Rn(e){return xt(e.name||Dn,!1,e,this,void 0)}function zn(e){return p(e)&&e.isMobxAction===!0}function Bn(e,t=c){var r;p(e)||n(`Autorun expects a function as first argument`),zn(e)&&n(`Autorun does not accept actions since actions are untrackable`);let i=t?.name??(e.name||`Autorun@`+u()),a=!t.scheduler&&!t.delay,o;if(a)o=new pn(i,function(){this.track(s)},t.onError,t.requiresObservable);else{let e=Hn(t),n=!1;o=new pn(i,()=>{n||(n=!0,e(()=>{n=!1,o.isDisposed||o.track(s)}))},t.onError,t.requiresObservable)}function s(){e(o)}return t!=null&&(r=t.signal)!=null&&r.aborted||o.schedule_(),o.getDisposer_(t?.signal)}let Vn=e=>e();function Hn(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Vn}function Un(e,t,r=c){var i;(!p(e)||!p(t))&&n(`First and second argument to reaction should be functions`),g(r)||n(`Third argument of reactions should be an object`);let a=r.name??`Reaction@`+u(),o=Pn(a,r.onError?Wn(r.onError,t):t),s=!r.scheduler&&!r.delay,l=Hn(r),d=!0,f=!1,m,h=r.equals||de,_=new pn(a,()=>{d||s?v():f||(f=!0,l(v))},r.onError,r.requiresObservable);function v(){if(f=!1,_.isDisposed)return;let t=!1,n=m;_.track(()=>{let n=wt(!1,()=>e(_));t=d||!h(m,n),m=n}),(d&&r.fireImmediately||!d&&t)&&o(m,n,_),d=!1}return r!=null&&(i=r.signal)!=null&&i.aborted||_.schedule_(),_.getDisposer_(r?.signal)}function Wn(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}function Gn(e,t,n){return qn(`onBO`,e,t,n)}function Kn(e,t,n){return qn(`onBUO`,e,t,n)}function qn(e,t,n,r){let i=typeof r==`function`?Ni(t,n):Ni(t),a=p(r)?r:n,o=`${e}L`;return i[o]?i[o].add(a):i[o]=new Set([a]),function(){let e=i[o];e&&(e.delete(a),e.size===0&&delete i[o])}}let Jn=`always`;function Yn(e){e.isolateGlobalState===!0&&Xt();let{enforceActions:t}=e;if(t!==void 0){let e=t===Jn?Jn:t===`observed`;M.enforceActions=e,M.allowStateChanges=!(e===!0||e===Jn)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(M[t]=!!e[t])}),M.allowStateReads=!M.observableRequiresReaction,M.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&yn(e.reactionScheduler)}function Xn(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),_i(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),g(t)||n(`'extendObservable' only accepts plain objects as second argument`),(xr(t)||xr(r))&&n(`Extending an object with another observable (object) is not supported`);let a=ne(t);return Fi(()=>{let t=Di(e,i)[O];T(a).forEach(e=>{t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Zn(e,t){return Qn(Ni(e,t))}function Qn(e){let t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=tr(e.observing_).map(Qn)),t}function $n(e,t){return er(Ni(e,t))}function er(e){let t={name:e.name_};return $t(e)&&(t.observers=Array.from(en(e),er)),t}function tr(e){return Array.from(new Set(e))}let nr=0;var rr=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};function ir(e){return e instanceof rr}function ar(e){return qe(e,Ae)}let or=De(`flow`),sr=De(`flow.bound`,{bound:!0}),cr=r(function(e,t){if(t&&typeof t.kind==`string`)return Ae(or,e,t);arguments.length!==1&&n(`Flow expects single argument with generator function`);let r=e,i=r.name||`<unnamed flow>`,a=function(){let e=this,t=arguments,n=++nr,a=Pn(`${i} - runid: ${n} - init`,r).apply(e,t),o,s,c=new Promise(function(e,t){let r=0;o=t;function c(e){s=void 0;let o;try{o=Pn(`${i} - runid: ${n} - yield ${r++}`,a.next).call(a,e)}catch(e){return t(e)}u(o)}function l(e){s=void 0;let o;try{o=Pn(`${i} - runid: ${n} - yield ${r++}`,a.throw).call(a,e)}catch(e){return t(e)}u(o)}function u(n){if(p(n?.then)){n.then(u,t);return}return n.done?e(n.value):(s=Promise.resolve(n.value),s.then(c,l))}c(void 0)});return c.cancel=Pn(`${i} - runid: ${n} - cancel`,function(){try{s&&ur(s);let e=a.return(void 0),t=Promise.resolve(e.value);t.then(f,f),ur(t),o(new rr)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},or),lr=ar(sr);function ur(e){p(e.cancel)&&e.cancel()}function dr(e){return e}function fr(e){return e?.isMobXFlow===!0}function pr(e,t,r){let i;if(_i(e)||pi(e)||Ot(e))i=Pi(e);else if(Ai(e)){if(!m(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=Pi(e,t)}else return n(`Expected observable map, object or array as first array`);return i.dehancer===void 0?(i.dehancer=typeof t==`function`?t:r,()=>{i.dehancer=void 0}):n(`An intercept reader was already established`)}function mr(e,t,n){return p(n)?gr(e,t,n):hr(e,t)}function hr(e,t){return qr(Pi(e),t)}function gr(e,t,n){return qr(Pi(e,t),n)}function _r(e,t){var n;if(t===void 0)return At(e);if(Ai(e)===!1)return!1;let r=e[O];return(n=r.lazyComputedKeys_)!=null&&n.has(t)?!0:r.values_.has(t)?At(Ni(e,t)):!1}function vr(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):_r(e)}function yr(e,t){return m(t)?_r(e,t):n(`isComputed expected a property name as second argument`)}function br(e,t){if(!e)return!1;if(t!==void 0){if(_i(e)||pi(e))return n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`);if(Ai(e)){var r,i;let n=e[O];return n.values_.has(t)||!!((r=n.lazyComputedKeys_)!=null&&r.has(t))||!!((i=n.lazyObservableKeys_)!=null&&i.has(t))}return!1}return Ai(e)||!!e[O]||oe(e)||vn(e)||At(e)}function xr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),br(e)}function Sr(e,t){return m(t)?br(e,t):n(`expected a property name as second argument`)}function Cr(e){if(Ai(e))return e[O].keys_();if(_i(e)||Si(e))return Array.from(e.keys());if(pi(e))return e.map((e,t)=>t);n(5)}function wr(e){if(Ai(e))return Cr(e).map(t=>e[t]);if(_i(e))return Cr(e).map(t=>e.get(t));if(Si(e))return Array.from(e.values());if(pi(e))return e.slice();n(6)}function Tr(e){if(Ai(e))return Cr(e).map(t=>[t,e[t]]);if(_i(e))return Cr(e).map(t=>[t,e.get(t)]);if(Si(e))return Array.from(e.entries());if(pi(e))return e.map((e,t)=>[t,e]);n(7)}function Er(e,t,r){if(arguments.length===2&&!Si(e)){an();let n=t;try{for(let t in n)Er(e,t,n[t])}finally{on()}return}Ai(e)?e[O].set_(t,r):_i(e)?e.set(t,r):Si(e)?e.add(t):pi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(42,t),an(),t>=e.length&&(e.length=t+1),e[t]=r,on()):n(8)}function Dr(e,t){Ai(e)?e[O].delete_(t):_i(e)||Si(e)?e.delete(t):pi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function Or(e,t){if(Ai(e))return e[O].has_(t);if(_i(e)||Si(e))return e.has(t);if(pi(e))return t>=0&&t<e.length;n(10)}function kr(e,t){if(Or(e,t)){if(Ai(e))return e[O].get_(t);if(_i(e))return e.get(t);if(pi(e))return e[t];n(11)}}function Ar(e,t,r){if(Ai(e))return e[O].defineProperty_(t,r);n(39)}function jr(e){if(Ai(e))return e[O].ownKeys_();n(38)}function Mr(e,t,n,r){return p(n)?Pr(e,t,n,r):Nr(e,t,n)}function Nr(e,t,r){let i=Pi(e);if(pi(e))r&&t({observableKind:`array`,object:i.proxy_,debugObjectName:i.atom_.name_,type:`splice`,index:0,added:i.values_.slice(),addedCount:i.values_.length,removed:[],removedCount:0});else if(_i(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps.");else if(Si(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets.");else if(Ai(e))r===!0&&n("`observe` doesn't support the fire immediately property for observable objects.");else return Fr(i,t,r);return Xr(i,t)}function Pr(e,t,n,r){return Fr(Pi(e,t),n,r)}function Fr(e,t,n){if(At(e)){let r=!0,i;return Bn(()=>{let a=e.get();if(!r||n){let n=Ht();t({observableKind:`computed`,debugObjectName:e.name_,type:ri,object:e,newValue:a,oldValue:i}),Ut(n)}r=!1,i=a})}return n&&t({observableKind:`value`,debugObjectName:e.name_,object:e,type:ri,newValue:e.value_,oldValue:void 0}),Xr(e,t)}function Ir(e,t,n){return e.set(t,n),n}function Lr(e,t){if(typeof e!=`object`||!e||e instanceof Date||!xr(e))return e;if(Ot(e)||At(e))return Lr(e.get(),t);if(t.has(e))return t.get(e);if(pi(e)){let n=Ir(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=Lr(e,t)}),n}if(Si(e)){let n=Ir(t,e,new Set);return e.forEach(e=>{n.add(Lr(e,t))}),n}if(_i(e)){let n=Ir(t,e,new Map);return e.forEach((e,r)=>{n.set(r,Lr(e,t))}),n}else{let n=Ir(t,e,{});return jr(e).forEach(r=>{o.propertyIsEnumerable.call(e,r)&&(n[r]=Lr(e[r],t))}),n}}function Rr(e,t){return t&&n(`toJS no longer supports options`),Lr(e,new Map)}function zr(e,t=void 0){an();try{return e.apply(t)}finally{on()}}function Br(e,t,n){return arguments.length===1||t&&typeof t==`object`?Hr(e,t):Vr(e,t,n||{})}function Vr(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[O].isDisposed)if(a(),n.onError)n.onError(e);else throw e},n.timeout)}n.name=n.name||`When@`+u();let i=bt(n.name+`-effect`,t);var a=Bn(t=>{wt(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function Hr(e,t){var i;if(t&&t.onError)return n(`the options 'onError' and 'promise' cannot be combined`);if(t!=null&&(i=t.signal)!=null&&i.aborted)return r(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let a,o,s=new Promise((n,i)=>{var s;let c=Vr(e,n,r({},t,{onError:i}));a=()=>{c(),i(Error(`WHEN_CANCELLED`))},o=()=>{c(),i(Error(`WHEN_ABORTED`))},t==null||(s=t.signal)==null||s.addEventListener==null||s.addEventListener(`abort`,o)}).finally(()=>{var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,o)});return s.cancel=a,s}function Ur(e){return e[O]}let Wr={has(e,t){return Ur(e).has_(t)},get(e,t){return Ur(e).get_(t)},set(e,t,n){return m(t)?Ur(e).set_(t,n,!0)??!0:!1},deleteProperty(e,t){return m(t)?Ur(e).delete_(t,!0)??!0:!1},defineProperty(e,t,n){return Ur(e).defineProperty_(t,n)??!0},ownKeys(e){return Ur(e).ownKeys_()},preventExtensions(e){n(13)}};function Gr(e,t){var n;return e=Di(e,t),(n=e[O]).proxy_??(n.proxy_=new Proxy(e,Wr))}function Kr(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function qr(e,t){let n=e.interceptors_;return n?n.push(t):n=e.interceptors_=[t],d(()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function Jr(e,t){let r=Ht();try{let r=[...e.interceptors_||[]];for(let e=0,i=r.length;e<i&&(t=r[e](t),t&&!t.type&&n(14),t);e++);return t}finally{Ut(r)}}function Yr(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function Xr(e,t){let n=e.changeListeners_;return n?n.push(t):n=e.changeListeners_=[t],d(()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function Zr(e,t){let n=Ht(),r=e.changeListeners_;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Ut(n)}}function Qr(e,t,n){return Fi(()=>{let r=Di(e,n)[O];T(t).forEach(e=>ti(r,e,t[e]))}),e}let $r=Symbol(`mobx-keys`);function ei(e,t,r){return!g(e)&&!g(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),Ai(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),g(e)?Xn(e,e,t,r):(Fi(()=>{let n=Di(e,r)[O];if(!e[$r]){let t=Object.getPrototypeOf(e),n=new Set([...T(e),...T(t)]);n.delete(`constructor`),n.delete(O),v(t,$r,n)}e[$r].forEach(e=>ti(n,e,t&&e in t?t[e]:!0))}),e)}function ti(e,t,r){if(r===!0&&(r=e.defaultAnnotation_),r===!1)return;Mi(e,r,t),t in e.target_||n(1,r.annotationType_,`${e.name_}.${t.toString()}`);let a=e.target_;for(;a&&a!==o;){let n=i(a,t);if(n){let i=r.make_(e,t,n,a);if(i===0)return;if(i===1)break}a=Object.getPrototypeOf(a)}ji(e,r,t)}let ni=`splice`,ri=`update`,ii={get(e,t){let n=e[O];return t===O?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):E(si,t)?si[t]:e[t]},set(e,t,n){let r=e[O];return t===`length`?r.setArrayLength_(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions(){n(15)}};var ai=class{constructor(e=`ObservableArray@`+u(),t,n){this.owned_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=n,this.atom_=new ae(e),this.enhancer_=(n,r)=>t(n,r,e+`[..]`)}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}dehanceValues_(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e}getArrayLength_(){return this.atom_.reportObserved(),this.values_.length}setArrayLength_(e){(!Number.isInteger(e)||e<0)&&n(40,e);let t=this.values_.length;if(e!==t)if(e>t){let n=Array.from({length:e-t});this.spliceWithArray_(t,0,n)}else this.spliceWithArray_(e,t-e)}updateArrayLength_(e,t){e!==this.lastKnownLength_&&n(16),this.lastKnownLength_+=t}spliceWithArray_(e,t,n){Ft(this.atom_);let r=this.values_.length;if(e===void 0?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=arguments.length===1?r-e:t==null?0:Math.max(0,Math.min(t,r-e)),n===void 0&&(n=s),Kr(this)){let r=Jr(this,{object:this.proxy_,type:ni,index:e,removedCount:t,added:n});if(!r)return s;t=r.removedCount,n=r.added}n=n.length===0?n:n.map(e=>this.enhancer_(e,void 0));{let e=n.length-t;this.updateArrayLength_(r,e)}let i=this.spliceItemsIntoValues_(e,t,n);return(t!==0||n.length!==0)&&this.notifyArraySplice_(e,n,i),this.dehanceValues_(i)}spliceItemsIntoValues_(e,t,n){if(n.length<1e4)return this.values_.splice(e,t,...n);{let r=this.values_.slice(e,e+t),i=this.values_.slice(e+t);this.values_.length+=n.length-t;for(let t=0;t<n.length;t++)this.values_[e+t]=n[t];for(let t=0;t<i.length;t++)this.values_[e+n.length+t]=i[t];return r}}notifyArrayChildUpdate_(e,t,n){let r=!this.owned_&&bn(),i=Yr(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:ri,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&Sn(a),this.atom_.reportChanged(),i&&Zr(this,a),r&&wn()}notifyArraySplice_(e,t,n){let r=!this.owned_&&bn(),i=Yr(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:ni,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&Sn(a),this.atom_.reportChanged(),i&&Zr(this,a),r&&wn()}get_(e){return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])}set_(e,t){let n=this.values_;if(e<n.length){Ft(this.atom_);let r=n[e];if(Kr(this)){let n=Jr(this,{type:ri,object:this.proxy_,index:e,newValue:t});if(!n)return;t=n.newValue}t=this.enhancer_(t,r),t!==r&&(n[e]=t,this.notifyArrayChildUpdate_(e,t,r))}else{let r=Array.from({length:e+1-n.length});r[r.length-1]=t,this.spliceWithArray_(n.length,0,r)}}};function oi(e,t,n=`ObservableArray@`+u(),r=!1){return Fi(()=>{let i=new ai(n,t,r);y(i.values_,O,i);let a=new Proxy(i.values_,ii);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var si={clear(){return this.splice(0)},replace(e){let t=this[O];return t.spliceWithArray_(0,t.values_.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[O];switch(arguments.length){case 0:return[];case 1:return r.spliceWithArray_(e);case 2:return r.spliceWithArray_(e,t)}return r.spliceWithArray_(e,t,n)},spliceWithArray(e,t,n){return this[O].spliceWithArray_(e,t,n)},push(...e){let t=this[O];return t.spliceWithArray_(t.values_.length,0,e),t.values_.length},pop(){return this.splice(Math.max(this[O].values_.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[O];return t.spliceWithArray_(0,0,e),t.values_.length},reverse(){return M.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){M.trackingDerivation&&n(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[O],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};ci(`at`,li),ci(`concat`,li),ci(`flat`,li),ci(`includes`,li),ci(`indexOf`,li),ci(`join`,li),ci(`lastIndexOf`,li),ci(`slice`,li),ci(`toString`,li),ci(`toLocaleString`,li),ci(`toSorted`,li),ci(`toSpliced`,li),ci(`with`,li),ci(`every`,ui),ci(`filter`,ui),ci(`find`,ui),ci(`findIndex`,ui),ci(`findLast`,ui),ci(`findLastIndex`,ui),ci(`flatMap`,ui),ci(`forEach`,ui),ci(`map`,ui),ci(`some`,ui),ci(`toReversed`,ui),ci(`reduce`,di),ci(`reduceRight`,di);function ci(e,t){typeof Array.prototype[e]==`function`&&(si[e]=t(e))}function li(e){return function(){let t=this[O];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function ui(e){return function(t,n){let r=this[O];return r.atom_.reportObserved(),r.dehanceValues_(r.values_)[e]((e,r)=>t.call(n,e,r,this))}}function di(e){return function(){let t=this[O];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_),r=arguments[0];return arguments[0]=(e,t,n)=>r(e,t,n,this),n[e].apply(n,arguments)}}let fi=b(`ObservableArrayAdministration`,ai);function pi(e){return h(e)&&fi(e[O])}let mi={},hi=`delete`;var gi=class{constructor(e,t=fe,n=`ObservableMap@`+u()){this.enhancer_=void 0,this.name_=void 0,this[O]=mi,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,Fi(()=>{this.keysAtom_=se(`${this.name_}.keys()`),this.data_=new Map,this.hasMap_=new Map,e&&this.merge(e)})}has_(e){return this.data_.has(e)}has(e){if(!M.trackingDerivation)return this.has_(e);let t=this.hasMap_.get(e);if(!t){let n=t=new Dt(this.has_(e),me,`${this.name_}.${ee(e)}?`,!1);this.hasMap_.set(e,n),n.onBUOL=new Set([()=>this.hasMap_.delete(e)])}return t.get()}set(e,t){let n=this.has_(e);if(Kr(this)){let r=Jr(this,{type:n?ri:`add`,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this}delete(e){if(Ft(this.keysAtom_),Kr(this)&&!Jr(this,{type:hi,object:this,name:e}))return!1;if(this.has_(e)){let t=bn(),n=Yr(this),r=n||t?{observableKind:`map`,debugObjectName:this.name_,type:hi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return t&&Sn(r),zr(()=>{var t;this.keysAtom_.reportChanged(),(t=this.hasMap_.get(e))==null||t.setNewValue_(!1),this.data_.get(e).setNewValue_(void 0),this.data_.delete(e)}),n&&Zr(this,r),t&&wn(),!0}return!1}updateValue_(e,t){let n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==M.UNCHANGED){let r=bn(),i=Yr(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:ri,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&Sn(a),n.setNewValue_(t),i&&Zr(this,a),r&&wn()}}addValue_(e,t){Ft(this.keysAtom_),zr(()=>{var n;let r=new Dt(t,this.enhancer_,`${this.name_}.${ee(e)}`,!1);this.data_.set(e,r),t=r.value_,(n=this.hasMap_.get(e))==null||n.setNewValue_(!0),this.keysAtom_.reportChanged()});let n=bn(),r=Yr(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:`add`,object:this,name:e,newValue:t}:null;n&&Sn(i),r&&Zr(this,i),n&&wn()}get(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)}getOrInsert(e,t){return this.has(e)||this.set(e,t),this.get(e)}getOrInsertComputed(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}keys(){return this.keysAtom_.reportObserved(),this.data_.keys()}values(){let e=this,t=this.keys();return vi({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e.get(r)}}})}entries(){let e=this,t=this.keys();return vi({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:[r,e.get(r)]}}})}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}merge(e){return _i(e)&&(e=new Map(e)),zr(()=>{g(e)?w(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):x(e)?(S(e)||n(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&n(20,e)}),this}clear(){zr(()=>{Vt(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return zr(()=>{let t=yi(e),n=new Map,r=!1;for(let e of this.data_.keys())if(!t.has(e))if(this.delete(e))r=!0;else{let t=this.data_.get(e);n.set(e,t)}for(let[e,i]of t.entries()){let t=this.data_.has(e);if(this.set(e,i),this.data_.has(e)){let i=this.data_.get(e);n.set(e,i),t||(r=!0)}}if(!r)if(this.data_.size!==n.size)this.keysAtom_.reportChanged();else{let e=this.data_.keys(),t=n.keys(),r=e.next(),i=t.next();for(;!r.done;){if(r.value!==i.value){this.keysAtom_.reportChanged();break}r=e.next(),i=t.next()}}this.data_=n}),this}get size(){return this.keysAtom_.reportObserved(),this.data_.size}toString(){return`[object ObservableMap]`}toJSON(){return Array.from(this)}get[Symbol.toStringTag](){return`Map`}},_i=b(`ObservableMap`,gi);function vi(e){return e[Symbol.toStringTag]=`MapIterator`,Vi(e)}function yi(e){if(x(e)||_i(e))return e;if(Array.isArray(e))return new Map(e);if(g(e)){let t=new Map;for(let n in e)t.set(n,e[n]);return t}else return n(21,e)}let bi={};var xi=class{constructor(e,t=fe,n=`ObservableSet@`+u()){this.name_=void 0,this[O]=bi,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=n,this.enhancer_=(e,r)=>t(e,r,n),Fi(()=>{this.atom_=se(this.name_),e&&this.replace(e)})}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){zr(()=>{Vt(()=>{for(let e of this.data_.values())this.delete(e)})})}forEach(e,t){for(let n of this)e.call(t,n,n,this)}get size(){return this.atom_.reportObserved(),this.data_.size}add(e){if(Ft(this.atom_),Kr(this)){let t=Jr(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){zr(()=>{e=this.enhancer_(e,void 0),this.data_.add(e),this.atom_.reportChanged()});let t=bn(),n=Yr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:`add`,object:this,newValue:e}:null;t&&Sn(r),n&&Zr(this,r),t&&wn()}return this}delete(e){if(Kr(this)&&!Jr(this,{type:hi,object:this,oldValue:e}))return!1;if(this.has(e)){let t=bn(),n=Yr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:hi,object:this,oldValue:e}:null;return t&&Sn(r),zr(()=>{this.atom_.reportChanged(),this.data_.delete(e)}),n&&Zr(this,r),t&&wn(),!0}return!1}has(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))}entries(){let e=this.values();return Ci({next(){let{value:t,done:n}=e.next();return n?{value:void 0,done:n}:{value:[t,t],done:n}}})}keys(){return this.values()}values(){this.atom_.reportObserved();let e=this,t=this.data_.values();return Ci({next(){let{value:n,done:r}=t.next();return r?{value:void 0,done:r}:{value:e.dehanceValue_(n),done:r}}})}intersection(e){return new Set(this).intersection(e)}union(e){return new Set(this).union(e)}difference(e){return new Set(this).difference(e)}symmetricDifference(e){return new Set(this).symmetricDifference(e)}isSubsetOf(e){return new Set(this).isSubsetOf(e)}isSupersetOf(e){return new Set(this).isSupersetOf(e)}isDisjointFrom(e){return new Set(this).isDisjointFrom(e)}replace(e){return Si(e)&&(e=new Set(e)),Array.isArray(e)||C(e)?zr(()=>{let t=C(e)?e:new Set(e);if(t.size===0){this.clear();return}if(this.data_.size===0){t.forEach(e=>this.add(e));return}for(let e of this.data_.values())t.has(this.dehanceValue_(e))||this.delete(e);t.forEach(e=>this.add(e))}):e!=null&&n(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},Si=b(`ObservableSet`,xi);function Ci(e){return e[Symbol.toStringTag]=`SetIterator`,Vi(e)}let wi=Object.create(null),Ti=`remove`;var Ei=class{constructor(e,t=new Map,r,i=Ve){this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.lazyComputedKeys_=void 0,this.lazyObservableKeys_=void 0,this.target_=e,this.values_=t,this.name_=r,this.defaultAnnotation_=i,this.keysAtom_=new ae(`${this.name_}.keys`),this.isPlainObject_=g(this.target_),Ui(this.defaultAnnotation_)||n(`defaultAnnotation must be valid annotation`),this.appliedAnnotations_={}}getObservablePropValue_(e){return(this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e)).get()}materializeLazyComputed_(e){let t=this.lazyComputedKeys_?.get(e);if(!t)return;this.lazyComputedKeys_.delete(e),this.lazyComputedKeys_.size===0&&(this.lazyComputedKeys_=void 0);let n=t();return this.values_.set(e,n),n}materializeLazyObservable_(e){let t=this.lazyObservableKeys_?.get(e);if(!t)return;this.lazyObservableKeys_.delete(e),this.lazyObservableKeys_.size===0&&(this.lazyObservableKeys_=void 0);let n=t();return this.values_.set(e,n),n}setObservablePropValue_(e,t){let n=this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e);if(n instanceof kt)return n.set(t),!0;if(Kr(this)){let n=Jr(this,{type:ri,object:this.proxy_||this.target_,name:e,newValue:t});if(!n)return null;t=n.newValue}if(t=n.prepareNewValue_(t),t!==M.UNCHANGED){let r=Yr(this),i=bn(),a=r||i?{type:ri,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;i&&Sn(a),n.setNewValue_(t),r&&Zr(this,a),i&&wn()}return!0}get_(e){return M.trackingDerivation&&!E(this.target_,e)&&this.has_(e),this.target_[e]}set_(e,t,n=!1){return E(this.target_,e)?this.values_.has(e)?this.setObservablePropValue_(e,t):n?Reflect.set(this.target_,e,t):(this.target_[e]=t,!0):this.extend_(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,n)}has_(e){if(!M.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;let t=this.pendingKeys_.get(e);return t||(t=new Dt(e in this.target_,me,`${this.name_}.${ee(e)}?`,!1),this.pendingKeys_.set(e,t)),t.get()}extend_(e,t,n,r=!1){if(n===!0&&(n=this.defaultAnnotation_),n===!1)return this.defineProperty_(e,t,r);Mi(this,n,e);let i=n.extend_(this,e,t,r);return i&&ji(this,n,e),i}defineProperty_(e,t,n=!1){Ft(this.keysAtom_);try{an();let i=this.delete_(e);if(!i)return i;if(Kr(this)){let n=Jr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:i}=n;t.value!==i&&(t=r({},t,{value:i}))}if(n){if(!Reflect.defineProperty(this.target_,e,t))return!1}else a(this.target_,e,t);this.notifyPropertyAddition_(e,t.value)}finally{on()}return!0}defineObservableProperty_(e,t,n,r=!1){Ft(this.keysAtom_);try{an();let i=this.delete_(e);if(!i)return i;if(Kr(this)){let n=Jr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let o=ki(e),s={configurable:M.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.target_,e,s))return!1}else a(this.target_,e,s);let c=new Dt(t,n,`${this.name_}.${e.toString()}`,!1);this.values_.set(e,c),this.notifyPropertyAddition_(e,c.value_)}finally{on()}return!0}defineComputedProperty_(e,t,n=!1){Ft(this.keysAtom_);try{an();let r=this.delete_(e);if(!r)return r;if(Kr(this)&&!Jr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:void 0}))return null;t.name||=`${this.name_}.${e.toString()}`,t.context=this.proxy_||this.target_;let i=ki(e),o={configurable:M.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.target_,e,o))return!1}else a(this.target_,e,o);this.values_.set(e,new kt(t)),this.notifyPropertyAddition_(e,void 0)}finally{on()}return!0}delete_(e,t=!1){if(Ft(this.keysAtom_),!E(this.target_,e))return!0;if(Kr(this)&&!Jr(this,{object:this.proxy_||this.target_,name:e,type:Ti}))return null;try{var n;an();let r=Yr(this),a=bn(),o=this.values_.get(e),s;if(!o&&(r||a)&&(s=i(this.target_,e)?.value),t){if(!Reflect.deleteProperty(this.target_,e))return!1}else delete this.target_[e];if(delete this.appliedAnnotations_[e],o&&(this.values_.delete(e),o instanceof Dt&&(s=o.value_),un(o)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||a){let t={type:Ti,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};a&&Sn(t),r&&Zr(this,t),a&&wn()}}finally{on()}return!0}notifyPropertyAddition_(e,t){var n;let r=Yr(this),i=bn();if(r||i){let n=r||i?{type:`add`,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,name:e,newValue:t}:null;i&&Sn(n),r&&Zr(this,n),i&&wn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()}ownKeys_(){return this.keysAtom_.reportObserved(),T(this.target_)}keys_(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)}};function Di(e,t){if(t&&Ai(e)&&n(`Options can't be provided for already observable objects.`),E(e,O))return Pi(e)instanceof Ei||n(`Cannot convert '${P(e)}' into observable object:\nThe target is already observable of different type.\nExtending builtins is not supported.`),e;Object.isExtensible(e)||n(`Cannot make the designated object observable; it is not extensible`);let r=t?.name??`${g(e)?`ObservableObject`:e.constructor.name}@${u()}`;return v(e,O,new Ei(e,new Map,String(r),nt(t))),e}let Oi=b(`ObservableObjectAdministration`,Ei);function ki(e){return wi[e]||(wi[e]={get(){return this[O].getObservablePropValue_(e)},set(t){return this[O].setObservablePropValue_(e,t)}})}function Ai(e){return h(e)?Oi(e[O]):!1}function ji(e,t,n){e.appliedAnnotations_[n]=t}function Mi(e,t,r){if(Ui(t)||n(`Cannot annotate '${e.name_}.${r.toString()}': Invalid annotation.`),!ve(t)&&E(e.appliedAnnotations_,r)){let i=`${e.name_}.${r.toString()}`,a=e.appliedAnnotations_[r].annotationType_,o=t.annotationType_;n(`Cannot apply '${o}' to '${i}':\nThe field is already annotated with '${a}'.\nRe-annotating fields is not allowed.\nUse 'override' annotation for methods overridden by subclass.`)}}function Ni(e,t){if(typeof e==`object`&&e){if(pi(e))return t!==void 0&&n(23),e[O].atom_;if(Si(e))return e.atom_;if(_i(e)){if(t===void 0)return e.keysAtom_;let r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,P(e)),r}if(Ai(e)){if(!t)return n(26);let r=e[O],i=r.values_.get(t)??r.materializeLazyComputed_(t)??r.materializeLazyObservable_(t);return i||n(27,t,P(e)),i}if(oe(e)||At(e)||vn(e))return e}else if(p(e)&&vn(e[O]))return e[O];n(28)}function Pi(e,t){if(e||n(29),t!==void 0)return Pi(Ni(e,t));if(oe(e)||At(e)||vn(e)||_i(e)||Si(e))return e;if(e[O])return e[O];n(24,e)}function P(e,t){let n;if(t!==void 0)n=Ni(e,t);else if(zn(e))return e.name;else n=Ai(e)||_i(e)||Si(e)?Pi(e):Ni(e);return n.name_}function Fi(e){let t=Ht(),n=Tt(!0);an();try{return e()}finally{on(),Et(n),Ut(t)}}let Ii=o.toString;function Li(e,t,n=-1){return Ri(e,t,n)}function Ri(e,t,n,r,i){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!==e)return t!==t;let a=typeof e;if(a!==`function`&&a!==`object`&&typeof t!=`object`)return!1;let o=Ii.call(e);if(o!==Ii.call(t))return!1;switch(o){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++;break}e=zi(e),t=zi(t);let s=o===`[object Array]`;if(!s){if(typeof e!=`object`||typeof t!=`object`)return!1;let n=e.constructor,r=t.constructor;if(n!==r&&!(p(n)&&n instanceof n&&p(r)&&r instanceof r)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),r||=[],i||=[];let c=r.length;for(;c--;)if(r[c]===e)return i[c]===t;if(r.push(e),i.push(t),s){if(c=e.length,c!==t.length)return!1;for(;c--;)if(!Ri(e[c],t[c],n-1,r,i))return!1}else{let a=Object.keys(e),o=a.length;if(Object.keys(t).length!==o)return!1;for(let s=0;s<o;s++){let o=a[s];if(!(E(t,o)&&Ri(e[o],t[o],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function zi(e){return pi(e)?e.slice():x(e)||_i(e)||C(e)||Si(e)?Array.from(e.entries()):e}let Bi=globalThis.Iterator?.prototype||{};function Vi(e){return e[Symbol.iterator]=Hi,r(Object.create(Bi),e)}function Hi(){return this}function Ui(e){return e instanceof Object&&typeof e.annotationType_==`string`&&p(e.make_)&&p(e.extend_)}{let e=globalThis;[`Symbol`,`Map`,`Set`,`Proxy`].forEach(t=>{e[t]===void 0&&n(`MobX requires global '${t}' to be available or polyfilled`)})}typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__==`object`&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:Tn,extras:{getDebugName:P},$mobx:O}),e.$mobx=O,e.FlowCancellationError=rr,e.ObservableMap=gi,e.ObservableSet=xi,e.Reaction=pn,e._allowStateChanges=wt,e._allowStateChangesInsideComputed=Rn,e._allowStateReadsEnd=Wt,e._allowStateReadsStart=j,e._autoAction=Fn,e._autoActionBound=Ln,e._endAction=Ct,e._getAdministration=Pi,e._getGlobalState=Zt,e._interceptReads=pr,e._isComputingDerivation=Pt,e._resetGlobalState=Qt,e._startAction=St,e.action=Pn,e.actionBound=In,e.autorun=Bn,e.compareDefault=de,e.compareIdentity=ce,e.compareShallow=ue,e.compareStructural=le,e.computed=ht,e.computedStruct=mt,e.configure=Yn,e.createAtom=se,e.defineProperty=Ar,e.entries=Tr,e.extendObservable=Xn,e.flow=cr,e.flowBound=lr,e.flowResult=dr,e.get=kr,e.getAtom=Ni,e.getDebugName=P,e.getDependencyTree=Zn,e.getObserverTree=$n,e.has=Or,e.intercept=mr,e.isAction=zn,e.isBoxedObservable=Ot,e.isComputed=vr,e.isComputedProp=yr,e.isFlow=fr,e.isFlowCancellationError=ir,e.isObservable=xr,e.isObservableArray=pi,e.isObservableMap=_i,e.isObservableObject=Ai,e.isObservableProp=Sr,e.isObservableSet=Si,e.keys=Cr,e.makeAutoObservable=ei,e.makeObservable=Qr,e.observable=ut,e.observableDeep=ct,e.observableRef=ot,e.observableShallow=st,e.observableStruct=lt,e.observe=Mr,e.onBecomeObserved=Gn,e.onBecomeUnobserved=Kn,e.onReactionError=mn,e.override=_e,e.ownKeys=jr,e.reaction=Un,e.remove=Dr,e.runInAction=Rn,e.set=Er,e.spy=Tn,e.toJS=Rr,e.transaction=zr,e.untracked=Vt,e.values=wr,e.when=Br})),Y=Ee(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=gC():t.exports=_C()}))();function vC(e){if(e===null)return!0;switch(typeof e){case`string`:case`boolean`:return!0;case`number`:return Number.isFinite(e);case`object`:{if(Array.isArray(e))return e.every(vC);let t=Object.getPrototypeOf(e);return(t===Object.prototype||t===null)&&Object.values(e).every(vC)}default:return!1}}function yC(e){if(Array.isArray(e))return Object.freeze(e.map(yC));if(typeof e==`object`&&e){let t=Object.create(null),n=Object.entries(e).sort(([e],[t])=>e<t?-1:+(e>t));for(let[e,r]of n)t[e]=yC(r);return Object.freeze(t)}return e}function bC(e){let t=typeof e;if(t===`string`||t===`number`||t===`boolean`)return t;throw TypeError(`Variable values must be string|number|boolean (got ${t})`)}function xC(e){return typeof e==`string`?e:String(e)}function SC(e){if(typeof e==`number`)return e;if(typeof e==`boolean`)return+!!e;let t=e.trim();if(t===``)throw TypeError(`Cannot cast empty string to number`);let n=Number(t);if(!Number.isFinite(n))throw TypeError(`Cannot cast ${JSON.stringify(e)} to number`);return n}function CC(e){if(typeof e==`boolean`)return e;if(typeof e==`number`){if(e===0||e===1)return e===1;throw TypeError(`Cannot cast number ${e} to bool (only 0 and 1 are accepted)`)}if(e===`true`)return!0;if(e===`false`)return!1;throw TypeError(`Cannot cast ${JSON.stringify(e)} to bool (expected "true" or "false")`)}var wC=class extends Error{constructor(e,t){super(t),this.variable=e}};function TC(e){return e instanceof wC?e:e instanceof Error&&e.cause!==void 0?TC(e.cause):void 0}const EC=e=>jo(e);var DC=class{kind=`box`;cell;lastChangedAt;constructor(e,t,n,r){this.name=e,this.type=t,this.clock=r,EC(n)||LC(e,t,n,`initial value`),this.cell=Y.observable.box(n,{deep:!1}),this.lastChangedAt=EC(n)?null:r.now()}read(){let e=this.cell.get();if(EC(e))throw new wC(this.name,`variable "${this.name}" has no value yet: nothing has written it`);return e}set(e){EC(e)||LC(this.name,this.type,e,`set value`),!(0,Y.compareStructural)(this.cell.get(),e)&&(this.cell.set(e),this.lastChangedAt=this.clock.now())}lastUpdatedMs(){return this.lastChangedAt}stored(){return this.cell.get()}},OC=class{cell;constructor(e,t,n){if(this.cell=(0,Y.computed)(t,{keepAlive:!0,...n!==void 0&&{equals:n}}),typeof this.cell.suspend_!=`function`)throw TypeError(`${e}: this MobX's computed has no suspend_; release() cannot unsubscribe it`);if(typeof this.cell.keepAlive_!=`boolean`)throw TypeError(`${e}: this MobX's computed has no keepAlive_ flag; release() cannot lift it`)}read(){return this.cell.get()}release(){this.cell.keepAlive_=!1,this.cell.suspend_()}},kC=class{constructor(e){this.deriver=e}read(){return this.deriver()}},AC=class{kind=`computed`;cell;constructor(e,t,n){this.name=e,this.type=t,this.cell=new OC(`Variable "${e}"`,()=>{let e=n();return LC(this.name,this.type,e,`computed result`),e})}read(){return this.cell.read()}release(){this.cell.release()}lastUpdatedMs(){return null}},jC=class{kind=`projection`;cell;constructor(e,t,n){this.name=e,this.type=t,this.cell=new kC(()=>{let e=n();return LC(this.name,this.type,e,`projection result`),e})}read(){return this.cell.read()}lastUpdatedMs(){return null}},MC=class{kind=`document`;cell;lastChangedAt;constructor(e,t,n){this.name=e,this.clock=n,this.cell=Y.observable.box(IC(t),{deep:!1}),this.lastChangedAt=t.kind===`pending`?null:n.now()}read(){return this.cell.get()}set(e){let t=IC(e);FC(this.cell.get(),t)||(this.cell.set(t),this.lastChangedAt=this.clock.now())}lastUpdatedMs(){return this.lastChangedAt}},NC=class{kind=`document`;cell;constructor(e,t){this.name=e,this.cell=new OC(`Variable "${e}"`,()=>IC(t()),FC)}read(){return this.cell.read()}release(){this.cell.release()}lastUpdatedMs(){return null}};function PC(e){return JSON.stringify(e)}function FC(e,t){return PC(e)===PC(t)}function IC(e){return e.kind===`ok`?{kind:`ok`,value:yC(e.value)}:e}function LC(e,t,n,r){let i=bC(n);if(i!==t)throw TypeError(`Variable "${e}": ${r} type ${i} does not match declared type ${t}`)}var RC=class{constructor(e,t=null){this.clock=e,this.parent=t}nodes=Y.observable.map(void 0,{deep:!1});defineBox(e,t,n){this.declare(e,new DC(e,t,n,this.clock))}defineDocument(e,t){this.declare(e,new MC(e,t,this.clock))}defineDerivedDocument(e,t){this.declare(e,new NC(e,t))}defineComputed(e,t,n){this.defineDerived(e,t,`computed`,n)}defineDerived(e,t,n,r){let i=e=>this.read(e),a=n===`computed`?AC:jC;this.declare(e,new a(e,t,()=>r(i)))}derive(e,t,n){if(this.refuseDisposed(`Derived value "${e}"`),t===`projection`)return new kC(n);let r=new OC(`Derived value "${e}"`,n);return this.kept.push(r),r}kept=[];read(e){return this.requireVar(e).read()}readDocument(e){let t=this.requireNode(e);if(t.kind!==`document`)throw TypeError(`Variable "${e}" is a ${t.kind}, not a document`);return t.read()}stored(e){let t=this.requireNode(e);if(t.kind===`document`)return t.read();if(t.kind!==`box`)throw TypeError(`Variable "${e}" is a ${t.kind}, not a written node`);return t.stored()}setDocument(e,t){let n=this.requireOwn(e);if(!(n instanceof MC))throw TypeError(n.kind===`document`?`Variable "${e}" is a derived document: what it reads decides it, and nothing writes it`:`Variable "${e}" is a ${n.kind}, not a document (use defineDocument to create one)`);(0,Y.runInAction)(()=>n.set(t))}setBox(e,t){let n=this.requireOwn(e);if(n.kind!==`box`)throw TypeError(`Variable "${e}" is a ${n.kind}, not a box (use defineBox to create a settable variable)`);(0,Y.runInAction)(()=>n.set(t))}runInAction(e){(0,Y.runInAction)(e)}has(e){return this.nodes.has(e)||(this.parent?.has(e)??!1)}getType(e){return this.requireVar(e).type}getKind(e){return this.requireNode(e).kind}changeKey(e){let t=this.requireNode(e);if(t.kind===`document`){let e=t.read();return e.kind===`pending`?e:F(PC(e))}try{return F(String(t.read()))}catch(e){return TC(e)===void 0?F(` failed:${e instanceof Error?e.message:String(e)}`):Ao(`unread`)}}getNode(e){let t=this.requireNode(e);return t.kind===`document`?{name:t.name,kind:t.kind,read:()=>t.read(),lastUpdatedMs:()=>t.lastUpdatedMs()}:{name:t.name,type:t.type,kind:t.kind,read:()=>t.read(),lastUpdatedMs:()=>t.lastUpdatedMs()}}names(){return[...this.parent?.names()??[],...this.nodes.keys()]}dispose(){if(this.disposed)return 0;this.disposed=!0;let e=0;return(0,Y.runInAction)(()=>{for(let t of this.nodes.values())(t instanceof AC||t instanceof NC)&&(t.release(),e++);for(let e of this.kept)e.release()}),e+this.kept.length}disposed=!1;requireNode(e){let t=this.nodes.get(e)??this.parent?.requireNode(e);if(!t)throw ReferenceError(`Unknown variable "${e}"`);return t}requireOwn(e){let t=this.nodes.get(e);if(t!==void 0)return t;throw this.parent?.has(e)?Error(`Variable "${e}" lives in the directory's store; a session's view cannot write it`):ReferenceError(`Unknown variable "${e}"`)}requireVar(e){let t=this.requireNode(e);if(t.kind===`document`)throw TypeError(`Variable "${e}" is a document; read its fields by path (.${e}.<field>)`);return t}refuseDisposed(e){if(this.disposed)throw Error(`${e}: cannot declare on a disposed store`)}declare(e,t){if(this.refuseDisposed(`Variable "${e}"`),this.has(e))throw Error(`Variable "${e}" is already declared`);(0,Y.runInAction)(()=>this.nodes.set(e,t))}},zC=class extends Error{name=`TemplateError`;kind=`EvalError`;pos;source;constructor(e,t,n={}){super(e,{cause:n.cause}),this.pos=t,this.source=n.source}get sourceSnippet(){return this.source?JC(this.source,this.pos):``}toString(){let e=`${this.name}: ${this.message}\n at line ${this.pos.line}, column ${this.pos.column}`,t=this.sourceSnippet;return t?`${e}\n\n${t}`:e}},BC=class extends zC{name=`ParseError`;kind=`ParseError`;expected;found;constructor(e,t,n={}){super(e,t,n),this.expected=n.expected,this.found=n.found}},VC=class extends zC{name=`EvalError`;kind=`EvalError`},HC=class extends VC{name=`FuncNotFoundError`;kind=`FuncNotFoundError`;funcName;suggestions;constructor(e,t,n={}){let r=YC(e,n.available??[]),i=r.length===0?``:` (did you mean: ${r.join(`, `)}?)`;super(`function ${JSON.stringify(e)} is not registered${i}`,t,n),this.funcName=e,this.suggestions=r}},UC=class extends VC{name=`ArgCountError`;kind=`ArgCountError`;funcName;accepted;got;constructor(e,t,n,r,i={}){let a=t.minimum===t.maximum?`${t.minimum}`:`at least ${t.minimum}`;super(`wrong number of args for ${e}: want ${a} got ${n}`,r,i),this.funcName=e,this.accepted=t,this.got=n}},WC=class extends VC{name=`TypeMismatchError`;kind=`TypeMismatchError`;funcName;argIndex;expected;receivedSummary;constructor(e,t,n,r,i,a={}){super(`function ${JSON.stringify(e)} arg ${t}: expected ${n}, but a ${r} flowed in. Pass it through \`unstyled\` (or your engine's flatten function) to convert.`,i,a),this.funcName=e,this.argIndex=t,this.expected=n,this.receivedSummary=r}},GC=class extends WC{constructor(e,t,n,r,i={}){super(e,t,`integer`,String(n),r,i),this.message=Number.isInteger(Number(n))?`integer out of range: ${String(n)}`:`expected integer; found ${String(n)}`}},KC=class extends VC{name=`MissingFieldError`;kind=`MissingFieldError`;path;constructor(e,t,n={}){super(`field "${e.join(`.`)}" not found on receiver`,t,n),this.path=e}},qC=class extends VC{name=`FailError`;kind=`FailError`;constructor(e,t={line:0,column:0,offset:0},n={}){super(e,t,n)}};function JC(e,t){let n=e.split(`
58
+ `)}function gb(e,t,n,r){let i=n[r];return typeof i==`string`?i:(e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be a string, got ${Sb(i)}`,line:q(e.source,[...t.split(`.`),r])}),null)}function _b(e,t,n,r){let i=n.default;if(i!==void 0){if(!(r===`string`&&typeof i==`string`||r===`number`&&typeof i==`number`||r===`boolean`&&typeof i==`boolean`)){e.issues.push({path:`${t}.default`,message:`default must be a ${r}, got ${Sb(i)}`,line:q(e.source,[...t.split(`.`),`default`])});return}return i}}function vb(e,t,n,r){let i=n[r];if(i!==void 0){if(typeof i!=`string`){e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be a string, got ${Sb(i)}`,line:q(e.source,[...t.split(`.`),r])});return}return i}}function yb(e,t,n){let r=vb(e,t,n,`palette`);if(r!==void 0){if(!e.allowedPalettes.has(r)){e.issues.push({path:`${t}.palette`,message:`Unknown palette "${r}"${Hv(r)}. Expected one of: ${[...e.allowedPalettes].sort().join(`, `)}`,line:q(e.source,[...t.split(`.`),`palette`])});return}return r}}function bb(e,t,n,r,i){let a=n[r];if(a!==void 0){if(typeof a!=`string`||!i.includes(a)){e.issues.push({path:`${t}.${r}`,message:`${t}.${r} must be one of: ${i.join(`, `)}; got ${J(a)}`,line:q(e.source,[...t.split(`.`),r])});return}return a}}function xb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sb(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function J(e){return typeof e==`string`?JSON.stringify(e):e===void 0?`undefined`:String(e)}function Cb(e,t,n,r){return xb(r)?(Db(e,n,r,t.noun,new Set(Object.keys(t.fields)),wb(e,t.removed??{},n,r)),Tb(e,t.fields,n,r)):(e.issues.push({path:n,message:`${n} must be an object, got ${Sb(r)}`,line:q(e.source,n.split(`.`))}),null)}function wb(e,t,n,r){let i=Object.entries(t).filter(([e])=>r[e]!==void 0);for(let[t,r]of i)Ob(e,`${n}.${t}`,`${n}.${t} was removed: ${r}`);return new Set(i.map(([e])=>`${n}.${e}`))}function Tb(e,t,n,r){let i=t,a={},o=!0;for(let[t,s]of Object.entries(i)){let i=s.parse(e,n,t,r);i===void 0?s.required&&(o=!1):a[t]=i}return o?a:null}const Eb=new Set;function Db(e,t,n,r,i,a=Eb){for(let o of Object.keys(n))!i.has(o)&&!a.has(`${t}.${o}`)&&e.issues.push({path:`${t}.${o}`,message:`Unknown ${r} "${o}". Expected one of: ${[...i].join(`, `)}`,line:q(e.source,[...t.split(`.`),o])})}function Ob(e,t,n){return e.issues.push({path:t,message:n,line:q(e.source,t.split(`.`))}),null}function kb(e,t,n,r){if(!xb(r))return e.issues.push({path:n,message:`${t.noun} must be an object, got ${Sb(r)}`,line:q(e.source,n.split(`.`))}),null;let i=t.arms,a=Object.keys(i),o=Object.keys(r).filter(e=>e in i),s=Object.keys(r).filter(e=>!(e in i));for(let r of s)e.issues.push({path:`${n}.${r}`,message:`Unknown ${t.noun} key "${r}". Expected exactly one of: ${a.join(`, `)}`,line:q(e.source,[...n.split(`.`),r])});if(o.length===0)return e.issues.push({path:n,message:`${t.noun} must declare exactly one of: ${a.join(`, `)}`,line:q(e.source,n.split(`.`))}),null;if(o.length>1)return e.issues.push({path:n,message:`${t.noun} must declare exactly one of: ${a.join(`, `)} (found: ${o.join(`, `)})`,line:q(e.source,n.split(`.`))}),null;let c=o[0];return i[c].parse(e,`${n}.${c}`,r[c])}function Ab(e,t,n,r){if(!xb(r))return e.issues.push({path:n,message:`${n} must be an object, got ${Sb(r)}`,line:q(e.source,n.split(`.`))}),null;let i=r[t.tag];if(typeof i!=`string`)return e.issues.push({path:`${n}.${t.tag}`,message:`${n}.${t.tag} must be a string, got ${Sb(i)}`,line:q(e.source,n.split(`.`))}),null;let a=t.arms;if(!Object.hasOwn(a,i)){let o=Object.hasOwn(t.retired,i)?t.retired[i](r):`Unknown ${t.noun} "${i}". Expected one of: ${Object.keys(a).join(`, `)}`;return e.issues.push({path:`${n}.${t.tag}`,message:o,line:q(e.source,[...n.split(`.`),t.tag])}),null}let o=a[i],s=e.issues.length,c=o.parse(e,n,r),l=new Set(e.issues.slice(s).map(e=>e.path));return Db(e,n,r,`${i} ${t.memberNoun} key`,o.keys,l),c}function jb(e,t,n){return{json:Gb(Ub(n),e,t),keys:new Set([e,...Object.keys(n)])}}function Mb(e){return(...t)=>e()(...t)}function Nb(e,...t){return(n,r,i)=>{let a=e(n,r,i);if(a===null)return null;for(let e of t){if(e.ok(a))continue;let{field:t,message:i}=e.issue(a),o=t===``?r:`${r}.${t}`;return n.issues.push({path:o,message:i,line:q(n.source,o.split(`.`))}),null}return a}}function Pb(){return{required:!1,json:{type:`string`},parse:(e,t,n,r)=>vb(e,t,r,n)}}function Fb(){return{required:!1,json:{type:`boolean`},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(typeof i!=`boolean`){e.issues.push({path:`${t}.${n}`,message:`${n} must be a boolean, got ${Sb(i)}`,line:q(e.source,[n])});return}return i}}}}function Ib(e){let{min:t,max:n}=e;return{required:!1,json:{type:`integer`,minimum:t,maximum:n},parse:(e,r,i,a)=>{let o=a[i];if(o!==void 0){if(typeof o!=`number`||!Number.isInteger(o)||o<t||o>n){e.issues.push({path:`${r}.${i}`,message:`${i} must be an integer between ${t} and ${n}, got ${J(o)}`,line:q(e.source,[i])});return}return o}}}}function Lb(e={}){let{min:t}=e;return{required:!1,json:{type:`number`,...t!==void 0&&{minimum:t}},parse:(e,n,r,i)=>{let a=i[r];if(a!==void 0){if(typeof a!=`number`||!Number.isFinite(a)||t!==void 0&&a<t){let i=t===void 0?`a finite number`:`a finite number >= ${t}`;e.issues.push({path:`${n}.${r}`,message:`${r} must be ${i}, got ${J(a)}`,line:q(e.source,[r])});return}return a}}}}function Rb(){return{required:!1,json:{type:`string`},parse:(e,t,n,r)=>yb(e,t,r)}}function zb(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>gb(e,t,r,n)??void 0}}function Bb(e,t){return O(t)?null:`${e} must be an absolute path (\`~\` and relative paths are not expanded), got ${JSON.stringify(t)}`}function Vb(){return{required:!0,json:{type:`string`,pattern:`^/`},parse:(e,t,n,r)=>{let i=gb(e,t,r,n);if(i===null)return;let a=Bb(`${t}.${n}`,i);return a===null?i:Ob(e,`${t}.${n}`,a)??void 0}}}function Hb(e){return{required:!1,json:{enum:[...e]},parse:(t,n,r,i)=>bb(t,n,i,r,e)}}function Ub(e,t={closed:!0}){let n=e,r={},i=[];for(let[e,t]of Object.entries(n))r[e]=t.json,t.required&&i.push(e);return{type:`object`,properties:r,...i.length>0&&{required:i},...t.closed&&{additionalProperties:!1}}}function Wb(e){return Ub(e.fields)}function Gb(e,t,n){let r=e,i={[t]:{const:n},...r.properties},a=[t,...r.required??[]];return{...r,properties:i,required:a}}function Kb(e){let t=e.arms;return{anyOf:Object.values(t).map(e=>e.json)}}function qb(e){let t=e.arms;return{anyOf:Object.entries(t).map(([e,t])=>({type:`object`,properties:{[e]:t.json},required:[e],additionalProperties:!1}))}}const Jb=[`claude`,`tmux`],Yb=`ne .tmux.pane ""`,Xb={band:{switch:{setting:`experimentalBand`,on:!0,inTmux:!1},label:`🧪 band (A)`,handsOff:!0,rows:null},statusline:{switch:{setting:`experimentalStatusline`,on:!0,inTmux:!1},label:`🧪 statusline (B)`,handsOff:!1,rows:null},pane:{switch:{setting:`experimentalPane`,on:!0,inTmux:!1},label:`🧪 tmux pane (C)`,handsOff:!0,rows:null},tmuxStatus:{switch:{setting:`renderer`,on:`tmux`,inTmux:!0},label:`tmux status line`,handsOff:!0,rows:5}},Zb=Object.keys(Xb),Qb=Zb.filter(e=>Xb[e].switch.on===!0),$b={by:`request`},ex=e=>`drawing.${e}`,tx={subscribers:0,fps:0,shown:!0},nx=(e,t)=>`feeds.${e}.${t}`;function rx(e){return Object.fromEntries(Zb.map(t=>[t,e(t)]))}const ix=rx(()=>tx);function ax(e){return typeof e==`string`&&Object.hasOwn(Xb,e)?e:null}const ox=(e,t)=>Array.from({length:e*2},(e,n)=>({lit:n%2==0,seconds:t})),sx=[...ox(3,1),...ox(3,.25)],cx=sx.reduce((e,{seconds:t})=>e+t,0),lx={min:15,max:600,step:15},ux=(e,t)=>e+t,dx=e=>e-cx,fx=(e,t,{previews:n=[],shown:r=`true`}={})=>({label:e,place:t,previews:n,shown:r}),px=(e,t,n={})=>({spec:Hb(e),domain:{from:e},parse:t=>e.includes(t)?t:null,...t!==void 0&&{optionDomain:{name:t,members:e,...n}}}),mx=e=>t=>e.includes(t)?`🧪 ${t}`:t,hx={spec:Fb(),domain:`bool`,parse:Ty},gx=e=>({spec:Ib(e),domain:e,parse:t=>Ey(t,e)});function _x(e,t,n,r={}){return{kind:`session`,...px(e,r.optionDomain,{library:r.library,labelOf:r.labelOf}),floor:t,control:n,themeDefault:r.themeDefault??!1}}function vx(e,t){return{kind:`session`,...hx,floor:e,control:t,themeDefault:!1}}function yx(e,t,n){return{kind:`session`,...gx(e),floor:t,control:n,themeDefault:!1}}function bx(e,t,n,r,i={}){return{kind:`selection`,sessionKey:e,spec:t,domain:n,control:r,themeDefault:i.themeDefault??!1}}const xx=e=>({kind:`text`,spec:e}),Lee={required:!1,json:{enum:[...gy]},parse:(e,t,n,r)=>{if(r[n]===`auto`){e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: "auto" is not supported — the render daemon runs detached, so terminal detection would read the daemon's environment, not your terminal's. Pick an explicit depth: ${gy.join(`, `)}`,line:q(e.source,[...t.split(`.`),n])});return}return bb(e,t,r,n,gy)}},Ree={required:!1,json:{type:`string`},parse:(e,t,n,r)=>{let i=vb(e,t,r,n);return Zv(i)?i:yb(e,t,r)}},zee={required:!1,json:{anyOf:[{enum:[...oy]},{type:`string`,pattern:`\\{\\{`}]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&Zv(i)?i:bb(e,t,r,n,oy)}},Sx=/^[^\r\n]*\S[^\r\n]*$/u,Cx=RegExp(`^(?:✖|✕)[\\uFE0E\\uFE0F]?$`,`u`),Bee={required:!1,json:{type:`string`,pattern:Sx.source,not:{pattern:Cx.source}},parse:(e,t,n,r)=>{let i=vb(e,t,r,n);if(i===void 0||Sx.test(i)&&!Cx.test(i))return i;e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: must be one line of visible text other than a close glyph ("✖", "✕") — the settings menu needs a glyph to click`,line:q(e.source,[...t.split(`.`),n])})}},Vee=Object.fromEntries(Qb.map(e=>[Xb[e].switch.setting,vx(!1,fx(Xb[e].label,`toggles`))])),Hee={claude:`Claude Code's status line`,tmux:`the tmux status line, while this pane is shown`},Uee={groups:[{id:`renderer`,label:`draw the bar in`}],entry:e=>({group:`renderer`,description:Hee[e]})},wx={palette:bx(`theme`,Ree,{themes:`themes`},fx(`🎨 theme`,`door`)),preset:bx(`preset`,Pb(),{from:`presets`},fx(`▦ preset`,`door`,{previews:[`layout`,`presetDelete`]})),style:bx(`style`,Pb(),{from:`styles`},fx(`◐ style`,`gear`,{previews:[`palette`]}),{themeDefault:!0}),effect:bx(`effect`,zee,{from:oy},fx(`✨ effect`,`look`)),endcaps:_x(py,`powerline`,fx(`✦ endcaps`,`look`),{optionDomain:`endcaps`}),variation:_x(yy,`accent`,fx(`🎼 variation`,`gear`,{previews:[`layout`]}),{optionDomain:`variations`,labelOf:mx(V_),themeDefault:!0}),shade:_x(by,`middle`,fx(`🔆 shade`,`gear`,{previews:[`layout`]}),{optionDomain:`shades`,labelOf:mx(A_),themeDefault:!0}),transitions:vx(!1,fx(`fade in/out`,`look`)),animationSpeed:_x(cy,`1x`,fx(`speed`,`look`)),autoWrap:vx(!0,fx(`wrap`,`config`)),padding:yx({...wy,step:1},1,fx(`padding`,`config`)),updateNotice:vx(!0,fx(`update notice`,`config`)),menuTimeout:yx(lx,120,fx(`menu timeout`,`config`)),renderer:_x(Jb,`claude`,fx(`renderer`,`config`,{shown:Yb}),{optionDomain:`renderers`,library:Uee}),...Vee,colorCompatibility:{kind:`config`,...px(gy,`colorCompatibilities`),spec:Lee,floor:`truecolor`},default_empty_value:xx(Pb()),default_separator:xx(Pb()),menuGlyph:xx(Bee)},Tx=Object.entries(wx),Ex=Tx.filter(([,e])=>e.kind===`session`||e.kind===`config`).map(([e])=>e),Wee=Tx.filter(([,e])=>e.kind===`session`||e.kind===`selection`).map(([e])=>e),Dx=Tx.filter(([,e])=>(e.kind===`session`||e.kind===`selection`)&&e.themeDefault).map(([e])=>e),Gee=Tx.flatMap(([,e])=>`optionDomain`in e&&e.optionDomain!==void 0?[e.optionDomain]:[]);function Ox(e){return wx[e]}const kx=e=>Ox(e).floor;function Ax(e){let t=wx[e];if(t.kind===`text`)return`string`;let{domain:n}=t;return n===`bool`?`boolean`:typeof n==`object`&&`min`in n?`number`:`string`}const jx=e=>`${e}.effective`,Kee=e=>{let t=wx[e];return t.kind===`selection`?t.sessionKey:e},Mx=Object.fromEntries(Wee.map(e=>{let t=Kee(e);return[t,{configKey:e,sessionKey:t,effectiveVar:jx(t),...wx[e].control}]})),Nx=Object.keys(Mx),Px=Object.values(Mx),Fx=Ex.filter(e=>wx[e].kind===`config`).map(e=>({configKey:e,effectiveVar:jx(e)})),qee=new Set(Fx.map(e=>e.configKey)),Ix=new Map([...Px,...Fx].map(e=>[e.configKey,e.effectiveVar])),Lx=new Map(Px.map(e=>[e.sessionKey,e.effectiveVar]));function Rx(e){return Object.fromEntries(Nx.map(t=>[t,e(t)]))}const zx=new Map(Nx.map(e=>[Mx[e].sessionKey,e])),Bx=new Map;function Vx(e){let t=Ux(e);if(t===null)throw Error(`Palette "${e}" did not resolve in the theme registry — allowed names and the registry are inconsistent`);return t}function Hx(e,t){return e===`bar`?t:Vx(e)}function Ux(e){let t=Bx.get(e);if(t!==void 0)return t;let n=fee(e);return n===null?null:(Bx.set(e,n),n)}function Wx(e,t){return Jee(e,`${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,()=>xee(e,t))}const Jee=g_();function Gx(e){let t=Ux(e);return t===null?null:{kind:`decided`,name:e,value:t}}function Kx(e,t,n){let r=Gx(e);return r===null?(n(ay(t,`palette`,`"${e}" names no installed theme${Hv(e)}`)),qx()):r}function Yee(e,t,n){return Qv(e,t,n,qx(),Gx)}function qx(){return{kind:`decided`,name:Uv,value:Vx(Uv)}}const Jx=/^[A-Za-z_][A-Za-z0-9_]*$/;function Xee(e){return`#${e+1}`}const Yx={rows:{}};function Xx(e){return`rows`in e}function Zx(e){return Object.fromEntries(e.map((e,t)=>[Xee(t),e]))}function Zee(e){if(e.kind===`container`&&e.direction===`vertical`){let{kind:t,direction:n,children:r,...i}=e;return{...i,rows:Zx(r)}}let{when:t,...n}=e;return{...t!==void 0&&{when:t},rows:Zx([n])}}function Qx(e){let{rows:t,...n}=e;return{kind:`container`,direction:`vertical`,children:Object.values(t),...n}}function $x(e){return Xx(e)?Qx(e):e}function*eS(e,t){if(!Xx(e)){yield*Iy(e,t);return}yield[Qx(e),t];for(let[n,r]of Object.entries(e.rows))yield*Iy(r,`${t}.rows.${n}`)}function tS(e,t){return Xx(e)?{...t,...e,rows:{...t.rows,...e.rows}}:Zee(e)}function nS(e,t){return t.reduce((e,t)=>{let n=t.id??t.seg,r=[...Ny(Qx(e.root))].flatMap(e=>e.kind===`segment`?[e]:[]);if(r.some(e=>e.name===t.seg&&(t.id===void 0||ky(e)===t.id)))return e;let i=r.find(e=>ky(e)===n);if(i!==void 0)return rS(e,t,`as "${n}", but placement "${n}" is already segment "${i.name}" — give the cell its own id`);let a={kind:`segment`,name:t.seg,...t.id!==void 0&&{id:t.id},insertedBy:t.by},o=Object.entries(e.root.rows).map(([e,n])=>[e,n,Qee(n,t.anchor,a,t.relation)]);return o.some(([,,e])=>e!==null)?{...e,root:{...e.root,rows:Object.fromEntries(o.map(([e,t,n])=>[e,n??t]))}}:rS(e,t,`${t.relation} "${t.anchor}", but there is no placement "${t.anchor}"`)},{root:e,unplaced:[]})}function rS(e,t,n){return{...e,unplaced:[...e.unplaced,{cell:t,reason:n}]}}function Qee(e,t,n,r){if(e.kind===`segment`&&ky(e)===t){let{when:t,...i}=e;return{kind:`container`,direction:`horizontal`,children:r===`before`?[n,i]:[i,n],...t!==void 0&&{when:t}}}return e.kind===`container`?iS(e,t,n,r):aS(e,t,n,r)}function iS(e,t,n,r){let i=e.children.findIndex(e=>e.kind===`segment`&&ky(e)===t);if(i>=0){let t=r===`before`?i:i+1,{when:a}=e.children[i];return{...e,children:[...e.children.slice(0,t),{...n,...a!==void 0&&{when:a}},...e.children.slice(t)]}}for(let[i,a]of e.children.entries()){let o=a.kind===`container`?iS(a,t,n,r):aS(a,t,n,r);if(o!==null)return{...e,children:e.children.map((e,t)=>t===i?o:e)}}return null}function aS(e,t,n,r){let i=!1,a=My(e,e=>{let a=iS(e,t,n,r);return i=a!==null,a??e});return i?a:null}function oS(e){if(!Xx(e))return!0;let{rows:t,...n}=e;return Object.values(n).some(e=>e!==void 0)||Object.keys(t).length>0}const sS=`default`,cS={};function lS(e){return[...new Set([sS,...Object.keys(e)])]}function uS(e,t,n){return Yv(void 0,e,t,sS,n)}function dS(e,t){let n={[sS]:cS,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${sS}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function fS(e,t){let n=dS(e.presets,t).root??Yx;return{node:Qx(tS(n,e.root)),path:oS(n)?`presets.${t}.root`:`root`}}function pS(e,t,n){if(t.length===0)return{config:e,notices:[]};let r=nS(e.root,t),i=Object.entries(e.presets).filter(([,e])=>oS(e.root??Yx)).map(([n,r])=>({name:n,preset:r,...nS(tS(r.root??Yx,e.root),t)})),a=new Map,o=e=>({cell:t,reason:n})=>{let r=a.get(t)??new Map;r.set(n,[...r.get(n)??[],e]),a.set(t,r)};(n.root?r.unplaced:[]).forEach(o(`the root`));for(let{name:e,unplaced:t}of i.filter(({name:e})=>n.presets.has(e)))t.forEach(o(`preset "${e}"`));return{config:{...e,root:r.root,presets:{...e.presets,...Object.fromEntries(i.map(({name:e,preset:t,root:n})=>[e,{...t,root:Qx(n)}]))}},notices:[...a].flatMap(([e,t])=>[...t].map(([t,n])=>mS(e,`${t} (in ${n.join(`, `)})`)))}}function mS(e,t){return`${e.by.file}: ${e.by.entry} places "${e.seg}" ${t}`}function hS(e,t){return{...e.globals,...dS(e.presets,t).globals}}const gS=new Map;function _S(e,t,n={}){gS.set(e,{permanent:!0,resolve:t,...n})}_S(`themes`,()=>Gv(),{paletteOf:e=>Vx(e)});const vS=`placementThemes`;_S(vS,Kv,{paletteOf:(e,t)=>Hx(e,t.palette)});for(let{name:e,members:t,library:n,labelOf:r}of Gee)_S(e,()=>t,{library:n,labelOf:r});function yS(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>Wx(n.basePalette,e.styles[t])}],[`presets`,{members:lS(e.presets)}]])}function bS(e){return[...new Set([...gS.keys(),...e.keys()])]}function xS(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=gS.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf,library:r.library,labelOf:r.labelOf};throw Error(CS(e,t))}const SS=new Map([[`looks`,`styles`],[`progressions`,`variations`]]);function CS(e,t){let n=SS.get(e);return`unknown option domain "${e}"${n===void 0?``:` — it was renamed "${n}"; write from: "${n}"`} (have: ${bS(t).join(`, `)})`}const wS=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`themeDefault`,`doctor`,`slash`,`run`,`do`];function TS(e){return JSON.stringify([e.run,Object.entries(e.env),e.cwd,e.refreshes])}function*ES(e){let t=[];DS(e,(e,n)=>(t.push([n,e]),e)),yield*t}function DS(e,t){if(`copy`in e)return{...e,copy:t(e.copy,`copy`)};if(`open`in e)return{...e,open:t(e.open,`open`)};if(`preset`in e&&e.preset===`delete`)return{...e,name:t(e.name,`name`)};if(`run`in e){let n=e.run.map((e,n)=>t(e,`run.${n}`));return{...e,run:n,env:Object.fromEntries(Object.entries(e.env).map(([e,n])=>[e,t(n,`env.${e}`)]))}}return e}function OS(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}const kS=[`plugins`,`repo`];function AS({scope:e,name:t}){return`${e}.${t}`}function jS(e){return t=>t===e||t.startsWith(`${e}.`)}const MS=`self`;function NS(e){return kS.find(t=>e===t||e.startsWith(`${t}.`))}function PS(e,t){let n=NS(e);if(n===void 0||n===e)return``;let r=kS.filter(e=>e!==n).map(t=>`${t}${e.slice(n.length)}`).find(t);return r===void 0?``:` ("${r}" is declared: a repository's own plugins are named under repo., installed ones under plugins., and a name in one is never looked up in the other)`}const FS=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*IS(e){let t=e.indexOf(`{{`);for(;t!==-1;){let n=``,r=t+2,i=[[0,r]];for(;r<e.length&&!e.startsWith(`}}`,r);){if(e.startsWith(`/*`,r)){let t=e.indexOf(`*/`,r+2);r=t===-1?e.length:t+2,i.push([n.length,r]);continue}let t=r,a=e[r];if(r+=1,a===`"`||a===`'`||a==="`"){for(;r<e.length&&e[r]!==a;)r+=e[r]===`\\`&&a!=="`"?2:1;r+=1}n+=e.slice(t,r)}if(r>=e.length)return;yield{text:n,at:e=>{let[t,n]=i[0];for(let[r,a]of i)r<=e&&([t,n]=[r,a]);return n+e-t}},t=e.indexOf(`{{`,r+2)}}const LS=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,RS=RegExp(`^(?:(\\$)(?:\\.(${LS}))?|\\.(${LS})?)(?=[\\s)]|$)`);function zS(e,t,n){let r=RS.exec(e.trimStart());if(r===null)return null;let[i,a]=r[1]===void 0?[t,r[3]]:[n,r[2]];return i===null?null:a===void 0?i:`${i}${a}.`}const BS=/^(\w+)\b\s*([\s\S]*)$/;function*VS(e,t){let n=[t];for(let r of IS(e)){let e=r.text.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=BS.exec(e)??[],o=n[n.length-1],s=n.length>1?n[n.length-2]:o;if(i===`end`){n.length>1&&n.pop();continue}if(i===`else`){yield{code:e,dot:s,block:r};let i=/^with\b([\s\S]*)$/.exec(a);n[n.length-1]=i===null?s:zS(i[1],s,t);continue}yield{code:e,dot:o,block:r},i===`if`&&n.push(o),i===`with`&&n.push(zS(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const HS=/(?<![.$])\btemplate\s+$/;function*US(e,t,n){let r=0;for(let i of[...e.matchAll(FS)]){let a=i.index+i[0].length;HS.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:zS(e.slice(a),t,n),index:i.index}),r=a}}function*WS(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...VS(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...US(s,c,i)]){let i=Object.hasOwn(t,e.name)?t[e.name]:void 0,a=`${e.name}\0${e.at??`\0`}`;i===void 0||o.has(e.name)||n.has(a)||(n.add(a),yield*r(i,e.at,e.name,new Set([...o,e.name])))}}}yield*r(e,``,null,new Set)}function GS(e){let t=new Map;return n=>(t.has(n)||t.set(n,e(n)),t.get(n))}const KS=new WeakMap;function qS(e,t){let n=KS.get(t);return n===void 0&&(n=GS(e=>[...WS(e,t)]),KS.set(t,n)),n(e)}const JS=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${LS})`,`g`);function*YS({code:e,dot:t,root:n}){let r=e.replace(FS,``);for(let e of[...r.matchAll(JS)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function XS(e,t){let n=new Map;for(let r of qS(e,t))for(let e of YS(r))n.has(e)||n.set(e,r.via);return n}const ZS=/(?<![.$])\b(action|picker|menu|carousel|swatches|swatch|themePreview)\s+$/,QS={action:1,picker:2,menu:1,carousel:2,swatch:1,swatches:2,themePreview:1};function*$S(e){let t=0,n=0,r=`action`;for(let i of[...e.matchAll(FS)]){let a=e.slice(t,i.index),o=ZS.exec(a);o===null?a.trim()!==``&&(n=0):(n=QS[o[1]],r=o[1]===`action`?`action`:`options`),n>0&&(yield{name:i[0].slice(1,-1),site:r,index:i.index},n--),t=i.index+i[0].length}}function eC(e,t){let n=new Map;for(let{code:r,via:i}of qS(e,t))for(let{name:e,site:t}of $S(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}const tC=e=>Object.keys(QS).filter(t=>QS[t]>=e).join(`|`),nC=RegExp(`(?<![\\w.$])(?:(?:${tC(1)})\\s+|(?:${tC(2)})\\s+""\\s+)(?=[^\\s"\`)|}])`);function rC(e,t){for(let{code:n}of qS(e,t))if(nC.test(n.replace(FS,`""`)))return!0;return!1}const iC=/(?<![\w.$])[A-Za-z_]\w*/g;function aC(e,t){let n=new Set;for(let{code:r}of qS(e,t))for(let[e]of r.replace(FS,``).matchAll(iC))n.add(e);return n}function oC(e,t){return new Set([...sC(e,t)].filter(e=>Object.hasOwn(t,e)))}function sC(e,t){let n=new Set;for(let{code:r,dot:i,root:a}of qS(e,t))for(let{name:e}of US(r,i,a))n.add(e);return n}const cC=e=>RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.${e}(?![A-Za-z0-9_])`,`g`);function lC(e,t,n){let r=cC(t),i=jS(t),a=[];for(let{dot:t,block:n}of VS(e,``)){let e=n.text.replace(FS,e=>` `.repeat(e.length));for(let i of e.matchAll(r))(i[1]===`$`?``:t)===``&&a.push(n.at(i.index+i[1].length+1));for(let{name:e,index:r}of[...US(n.text,t,``),...$S(n.text)])i(e)&&a.push(n.at(r+1))}return[...new Set(a)].sort((e,t)=>t-e).reduce((e,r)=>e.slice(0,r)+n+e.slice(r+t.length),e)}function*uC(e){for(let[t,n]of Object.entries(e.variables))yield[t,n,[`variables`,t]];for(let[t,n]of Object.entries(e.segments))for(let[e,r]of Object.entries(n.vars??{}))yield[`${t}.${e}`,r,[`segments`,t,`vars`,e]]}function*dC(e){for(let[t,n]of uC(e))yield[t,n]}function fC(e,t){let n=e.split(`.`);for(let e=n.length;e>0;e--){let r=n.slice(0,e).join(`.`);if(t.has(r))return[r]}let r=`${e}.`;return[...t].filter(e=>e.startsWith(r))}function pC(e,t){return fC(e,t.names).some(n=>!e.startsWith(`${n}.`)||t.documents.has(n))}function mC(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),hC(r)&&n.add(e)};for(let[t,n]of dC(e))r(t,n);return{names:t,documents:n,helpers:e.helpers}}function hC(e){return e.kind===`dropped`||e.kind===`source`||(e.kind===`shell`||e.kind===`file`)&&Ry(e.parse)===`json`}var gC=Te((e=>{function t(e,...t){throw Error(`[MobX] minified error nr: ${e}${t.length?` `+t.map(String).join(`,`):``}. See mobx.js.org/errors`)}function n(e){let t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}function r(e){return typeof e==`function`}function i(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function a(e){return typeof e==`object`&&!!e}function o(e){if(!a(e))return!1;let t=Object.getPrototypeOf(e);if(t==null)return!0;let n=p(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===Bt}function s(e){let t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function c(e,t,n){It(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function l(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return a(e)&&!0===e[n]}}function u(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function d(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function f(e){return e===null?null:typeof e==`object`?``+e:e}function p(e,t){return Lt.hasOwnProperty.call(e,t)}function m(e,t){return!!(e&t)}function h(e,t,n){return n?e|=t:e&=~t,e}function g(e,t=Vt,n=Vt){let r=new Wt(e);return t!==Vt&&(r.onBOL=new Set([t])),n!==Vt&&(r.onBUOL=new Set([n])),r}function _(e,t){return kt(e,t)}function v(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||Qe(e)?e:Array.isArray(e)?sn.array(e,{name:n}):o(e)?sn.object(e,void 0,{name:n}):u(e)?sn.map(e,{name:n}):d(e)?sn.set(e,{name:n}):typeof e!=`function`||Ve(e)||Ye(e)?e:s(e)?Gn(e):Ln(n,e)}function y(e){return e}function b(e,t){return{t:e,i:t,o:x,u:S}}function x(e,t,n,r){var i;return(i=this.i)!=null&&i.bound?this.u(e,t,n,!1)===null?0:1:r===e.h?this.u(e,t,n,!1)===null?0:2:Ve(n.value)?1:(It(r,t,w(e,this,t,n,!1)),2)}function S(e,t,n,r){let i=w(e,this,t,n);return e.l(t,i,r)}function C(e,n,r){let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>{var t;return ge(s.i?.name??a.toString(),e,(t=s.i?.autoAction)!=null&&t)};return i==`field`?function(e){var t;let n=e;return Ve(n)||(n=c(n)),(t=s.i)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n}:i==`method`?(Ve(n)||(n=c(n)),(l=s.i)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),n):void t(43,s.t,String(a),i);var l}function w(e,t,n,r,i=N.safeDescriptors){var a,o,s;let{value:c}=r;return(a=t.i)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:ge(t.i?.name??n.toString(),c,(o=t.i?.autoAction)!=null&&o,(s=t.i)!=null&&s.bound?e.v??e.h:void 0),configurable:!i||e.p,enumerable:!1,writable:!i}}function T(e,t){return{t:e,i:t,o:ee,u:te}}function ee(e,t,n,r){var i;return r===e.h?this.u(e,t,n,!1)===null?0:2:(i=this.i)!=null&&i.bound&&(!p(e.h,t)||!Ye(e.h[t]))&&this.u(e,t,n,!1)===null?0:Ye(n.value)?1:(It(r,t,ne(e,0,0,n,!1,!1)),2)}function te(e,t,n,r){let i=ne(e,0,0,n,this.i?.bound);return e.l(t,i,r)}function E(e,t,n){var r;let{name:i,addInitializer:a}=n;return Ye(t)||(t=Gn(t)),(r=e.i)!=null&&r.bound&&a(function(){let e=this,t=e[i].bind(e);t.isMobXFlow=!0,e[i]=t}),t}function ne(e,t,n,r,i,a=N.safeDescriptors){let{value:o}=r;return Ye(o)||(o=Gn(o)),i&&(o=o.bind(e.v??e.h),o.isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function D(e,t){return{t:e,i:t,o:O,u:re}}function O(e,t,n){return this.u(e,t,n,!1)===null?0:1}function re(e,t,n,r){return e.m(t,Pt({},this.i,{get:n.get,set:n.set}),r)}function k(e,t,n){function r(e){let n=Pt({},i.i,{get:t,context:e});return n.name||=`ObservableObject.${a.toString()}`,new yn(n)}let i=e,{name:a,addInitializer:o}=n,s;return o(function(){let e=St(this)[j],n=this,i=e.j.get(a);i instanceof yn&&i.derivation!==t&&e.j.delete(a),(e.O??=new Map).set(a,()=>r(n))}),function(){let e=this[j],n=e.j.get(a);if(n instanceof yn&&n.derivation!==t){let e=s?.get(this);return e||(e=r(this),(s??=new WeakMap).set(this,e)),e.get()}return e._(a)}}function ie(e,t){return{t:e,i:t,o:ae,u:oe}}function ae(e,t,n){return this.u(e,t,n,!1)===null?0:1}function oe(e,t,n,r){return e.S(t,n.value,this.i?.A??v,r)}function se(e,t,n){function r(e,t){let n=St(e)[j];return(n.V??=new Map).set(o,()=>new _n(t,i.i?.A??v,`ObservableObject.${o.toString()}`,!1)),n}let i=e,{kind:a,name:o}=n;if(a===`accessor`)return{get(){return(this[j]??r(this,t.get.call(this)))._(o)},set(e){return(this[j]??r(this,e)).M(o,e)},init(e){return r(this,e),e}}}function ce(e){return{t:Jt,i:e,o:le,u:ue}}function le(e,t,n,r){var i,a,o;if(n.get)return dn.o(e,t,n,r);if(n.set){let i=Ve(n.set)?n.set:ge(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!N.safeDescriptors||e.p,set:i})===null?0:2:(It(r,t,{configurable:!0,set:i}),2)}if(r!==e.h&&typeof n.value==`function`)return s(n.value)?((o=this.i)!=null&&o.autoBind?Kn:Gn).o(e,t,n,r):((a=this.i)!=null&&a.autoBind?zn:Ln).o(e,t,n,r);let c=!1===this.i?.deep?nn:sn;return typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),c.o(e,t,n,r)}function ue(e,t,n,r){var i;return n.get?dn.u(e,t,n,r):n.set?e.l(t,{configurable:!N.safeDescriptors||e.p,set:ge(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.i)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),(!1===this.i?.deep?nn:sn).u(e,t,n,r))}function de(e,t){return Pt(function(n,r){if(r&&typeof r.kind==`string`)return t(e,n,r)},e)}function fe(e){return e||Xt}function pe(e){return de(e,se)}function me(e){return!0===e.deep?v:!1===e.deep?y:(t=e.defaultDecorator)&&(n=(r=t.i)?.A)!=null?n:v;var t,n,r}function he(e){return de(e,k)}function ge(e,t,n=!1,r){function i(){return _e(0,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=()=>t.toString(),hn&&(gn.value=e,It(i,`name`,gn)),i}function _e(e,t,n,r,i){let a=ve(0,t);try{return n.apply(r,i)}catch(e){throw a.N=e,e}finally{ye(a)}}function ve(e,t){let n=N.trackingDerivation,r=!t||!n;A();let i=N.allowStateChanges;r&&Ee();let a={R:r,k:n,C:i,I:N.allowStateReads,P:!1,T:0,B:mn++,D:pn};return pn=a.B,a}function ye(e){pn!==e.B&&t(30),pn=e.D,e.N!==void 0&&(N.suppressReactionErrors=!0),Me(),e.R&&De(e.k),N.suppressReactionErrors=!1}function be(e,t){let n=function(e){let t=N.allowStateChanges;return N.allowStateChanges=e,t}(e);try{return t()}finally{(function(e){N.allowStateChanges=e})(n)}}function xe(e){return e instanceof xn}function Se(e){switch(e.K){case 0:return!1;case-1:case 2:return!0;case 1:{let t=Ee(),n=e.L,r=n.length;for(let i=0;i<r;i++){let r=n[i];if(bn(r)){if(N.disableErrorBoundaries)r.get();else try{r.get()}catch{return De(t),!0}if(e.K===2)return De(t),!0}}return Oe(e),De(t),!1}}}function Ce(e,t,n){Oe(e),e.$=Array(e.U===0?100:e.L.length),e.W=0,e.U=++N.runId;let r=N.trackingDerivation,i;if(N.trackingDerivation=e,N.inBatch++,!0===N.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new xn(e)}return N.inBatch--,N.trackingDerivation=r,function(e){let t=e.L,n=e.L=e.$,r=0,i=0,a=e.W;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.K>r&&(r=t.K)}for(n.length=i,e.$=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&Ae(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,ke(t,e))}r!==0&&(e.K=r,e.q())}(e),i}function we(e){let t=e.L;e.L=[];let n=t.length;for(;n--;)Ae(t[n],e);e.K=-1}function Te(e){let t=Ee();try{return e()}finally{De(t)}}function Ee(){let e=N.trackingDerivation;return N.trackingDerivation=null,e}function De(e){N.trackingDerivation=e}function Oe(e){if(e.K===0)return;e.K=0;let t=e.L,n=t.length;for(;n--;)t[n].F=0}function ke(e,t){(e.H??=new Set).add(t),e.F>t.K&&(e.F=t.K)}function Ae(e,t){let n=e.H;n&&(n.delete(t),n.size===0&&je(e))}function je(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,N.pendingUnobservations.push(e))}function A(){N.inBatch++}function Me(){--N.inBatch===0&&(Ie(),!N.isRunningUnobservations&&N.pendingUnobservations.length>0&&function(){N.isRunningUnobservations=!0;try{let e=N.pendingUnobservations;for(let t=0;t<e.length;t++){let n=e[t];n.isPendingUnobservation=!1,n.H&&n.H.size!==0||(n.H=null,n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof yn&&n.G())}N.pendingUnobservations=[]}finally{N.isRunningUnobservations=!1}}())}function Ne(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.L)==null||t.forEach(Ne))}function Pe(e){let t=N.trackingDerivation;return t===null?((!e.H||e.H.size===0)&&N.inBatch>0&&je(e),!1):(t.U!==e.J&&(e.J=t.U,t.$[t.W++]=e,!e.isBeingObserved&&N.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function Fe(e){var t;e.F!==2&&(e.F=2,(t=e.H)==null||t.forEach(e=>{e.K===0&&e.q(),e.K=2}))}function Ie(){N.inBatch>0||N.isRunningReactions||On(Le)}function Le(){N.isRunningReactions=!0;let e=N.pendingReactions,t=0;for(;e.length>0;){++t===Dn&&(console.error(`[mobx] cycle in reaction: ${e[0]}`),e.splice(0));let n=e.splice(0);for(let e=0,t=n.length;e<t;e++)n[e].X()}N.isRunningReactions=!1}function Re(e){return de(e,C)}function ze(e){return function(t,n){return n&&typeof n.kind==`string`?C(e?Pn:Mn,t,n):r(t)?ge(t.name||`<unnamed action>`,t,e):r(n)?ge(t,n,e):i(t)?Re(b(e?jn:An,{name:t,autoAction:e})):void 0}}function Be(e){return _e(0,!1,e,this,void 0)}function Ve(e){return r(e)&&!0===e.isMobxAction}function He(e,t=zt){function n(){e(a)}var r;let i=t?.name??`Autorun`,a;if(t.scheduler||t.delay){let e=Ue(t),r=!1;a=new En(i,()=>{r||(r=!0,e(()=>{r=!1,a.isDisposed||a.track(n)}))},t.onError,t.requiresObservable)}else a=new En(i,function(){this.track(n)},t.onError,t.requiresObservable);return t!=null&&(r=t.signal)!=null&&r.aborted||a.Y(),a.Z(t?.signal)}function Ue(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Bn}function We(e,t,n,i){let a=typeof i==`function`?Tt(t,n):Tt(t),o=r(i)?i:n,s=`${e}L`;return a[s]?a[s].add(o):a[s]=new Set([o]),function(){let e=a[s];e&&(e.delete(o),e.size===0&&delete a[s])}}function Ge(e,t,n,r){let i=Ut(t);return Ot(()=>{let t=St(e,r)[j];Ht(i).forEach(e=>{t.u(e,i[e],!n||!(e in n)||n[e])})}),e}function Ke(e){let t={name:e.tt};var n;return e.L&&e.L.length>0&&(t.dependencies=(n=e.L,Array.from(new Set(n))).map(Ke)),t}function qe(e){let t={name:e.tt};return function(e){return!!e.H&&e.H.size>0}(e)&&(t.observers=Array.from(function(e){return e.H??new Set}(e),qe)),t}function Je(e){r(e.cancel)&&e.cancel()}function Ye(e){return!0===e?.isMobXFlow}function Xe(e,t){var n;if(t===void 0)return bn(e);if(!1===wt(e))return!1;let r=e[j];return(n=r.O)!=null&&n.has(t)?!0:r.j.has(t)?bn(Tt(e,t)):!1}function Ze(e,t){if(!e)return!1;if(t!==void 0){if(wt(e)){var n,r;let i=e[j];return i.j.has(t)||!((n=i.O)==null||!n.has(t))||!((r=i.V)==null||!r.has(t))}return!1}return wt(e)||!!e[j]||Gt(e)||kn(e)||bn(e)}function Qe(e){return Ze(e)}function $e(e){return wt(e)?e[j].nt():ir(e)||sr(e)?Array.from(e.keys()):yt(e)?e.map((e,t)=>t):void t(5)}function et(e,n){return wt(e)?e[j].et(n):ir(e)||sr(e)?e.has(n):yt(e)?n>=0&&n<e.length:void t(10)}function tt(e){if(wt(e))return e[j].it();t(38)}function nt(e,t,n){if(bn(e)){let r,i=!0;return He(()=>{let a=e.get();if(!i||n){let n=Ee();t({observableKind:`computed`,debugObjectName:e.tt,type:Xn,object:e,newValue:a,oldValue:r}),De(n)}i=!1,r=a})}return n&&t({observableKind:`value`,debugObjectName:e.tt,object:e,type:Xn,newValue:e.rt,oldValue:void 0}),ft(e,t)}function rt(e,t,n){return e.set(t,n),n}function it(e,t){if(typeof e!=`object`||!e||e instanceof Date||!Qe(e))return e;if(vn(e)||bn(e))return it(e.get(),t);if(t.has(e))return t.get(e);if(yt(e)){let n=rt(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=it(e,t)}),n}if(sr(e)){let n=rt(t,e,new Set);return e.forEach(e=>{n.add(it(e,t))}),n}if(ir(e)){let n=rt(t,e,new Map);return e.forEach((e,r)=>{n.set(r,it(e,t))}),n}{let n=rt(t,e,{});return tt(e).forEach(r=>{Lt.propertyIsEnumerable.call(e,r)&&(n[r]=it(e[r],t))}),n}}function at(e,t){A();try{return e.apply(t)}finally{Me()}}function ot(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[j].isDisposed){if(a(),!n.onError)throw e;n.onError(e)}},n.timeout)}n.name=`When`;let i=ge(`When-effect`,t);var a=He(t=>{be(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function st(e){return e[j]}function ct(e){return e.st!==void 0&&e.st.length>0}function lt(e,t){let r=e.st;return r?r.push(t):r=e.st=[t],n(()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)})}function ut(e,n){let r=Ee();try{let r=[...e.st||[]];for(let e=0,i=r.length;e<i&&((n=r[e](n))&&!n.type&&t(14),n);e++);return n}finally{De(r)}}function dt(e){return e.ot!==void 0&&e.ot.length>0}function ft(e,t){let r=e.ot;return r?r.push(t):r=e.ot=[t],n(()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)})}function pt(e,t){let n=Ee(),r=e.ot;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);De(n)}}function mt(e,n,r){if(!0===r&&(r=e.ut),!1===r)return;n in e.h||t(1,r.t,`${e.tt}.${n.toString()}`);let i=e.h;for(;i&&i!==Lt;){let t=Ft(i,n);if(t){let a=r.o(e,n,t,i);if(a===0)return;if(a===1)break}i=Object.getPrototypeOf(i)}}function ht(e,t){typeof Array.prototype[e]==`function`&&($n[e]=t(e))}function gt(e){return function(){let t=this[j];t.ct.reportObserved();let n=t.ht(t.j);return n[e].apply(n,arguments)}}function _t(e){return function(t,n){let r=this[j];return r.ct.reportObserved(),r.ht(r.j)[e]((e,r)=>t.call(n,e,r,this))}}function vt(e){return function(){let t=this[j];t.ct.reportObserved();let n=t.ht(t.j),r=arguments[0];return arguments[0]=(e,t,n)=>r(e,t,n,this),n[e].apply(n,arguments)}}function yt(e){return a(e)&&er(e[j])}function bt(e){return e[Symbol.toStringTag]=`MapIterator`,Mt(e)}function xt(e){return e[Symbol.toStringTag]=`SetIterator`,Mt(e)}function St(e,t){if(p(e,j))return e;let n=t?.name??`ObservableObject`;return c(e,j,new ur(e,new Map,String(n),function(e){return e?e.defaultDecorator??function(e){let t=!1!==e.deep,n=!!e.autoBind,r=!t|(n?2:0);return M[r]??(M[r]=ce({deep:t,autoBind:n}))}(e):void 0}(t))),e}function Ct(e){return cr[e]||(cr[e]={get(){return this[j]._(e)},set(t){return this[j].M(e,t)}})}function wt(e){return!!a(e)&&dr(e[j])}function Tt(e,n){if(typeof e==`object`&&e){if(yt(e))return n!==void 0&&t(23),e[j].ct;if(sr(e))return e.ct;if(ir(e)){if(n===void 0)return e.lt;let r=e.ft.get(n)||e.dt.get(n);return r||t(25,n,Dt(e)),r}if(wt(e)){if(!n)return t(26);let r=e[j],i=r.j.get(n)??r.vt(n)??r.bt(n);return i||t(27,n,Dt(e)),i}if(Gt(e)||bn(e)||kn(e))return e}else if(r(e)&&kn(e[j]))return e[j];t(28)}function Et(e,n){return e||t(29),n===void 0?Gt(e)||bn(e)||kn(e)||ir(e)||sr(e)?e:e[j]?e[j]:void t(24,e):Et(Tt(e,n))}function Dt(e,t){let n;if(t!==void 0)n=Tt(e,t);else{if(Ve(e))return e.name;n=wt(e)||ir(e)||sr(e)?Et(e):Tt(e)}return n.tt}function Ot(e){let t=Ee();A();try{return e()}finally{Me(),De(t)}}function kt(e,t,n=-1){return At(e,t,n)}function At(e,t,n,i,a){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!=e)return t!=t;let o=typeof e;if(o!==`function`&&o!==`object`&&typeof t!=`object`)return!1;let s=fr.call(e);if(s!==fr.call(t))return!1;switch(s){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++}e=jt(e),t=jt(t);let c=s===`[object Array]`;if(!c){if(typeof e!=`object`||typeof t!=`object`)return!1;let n=e.constructor,i=t.constructor;if(n!==i&&!(r(n)&&n instanceof n&&r(i)&&i instanceof i)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),a||=[];let l=(i||=[]).length;for(;l--;)if(i[l]===e)return a[l]===t;if(i.push(e),a.push(t),c){if(l=e.length,l!==t.length)return!1;for(;l--;)if(!At(e[l],t[l],n-1,i,a))return!1}else{let r=Object.keys(e),o=r.length;if(Object.keys(t).length!==o)return!1;for(let s=0;s<o;s++){let o=r[s];if(!p(t,o)||!At(e[o],t[o],n-1,i,a))return!1}}return i.pop(),a.pop(),!0}function jt(e){return yt(e)?e.slice():u(e)||ir(e)||d(e)||sr(e)?Array.from(e.entries()):e}function Mt(e){return e[Symbol.iterator]=Nt,Pt(Object.create(pr),e)}function Nt(){return this}Object.defineProperty(e,`__esModule`,{value:!0});let Pt=Object.assign,Ft=Object.getOwnPropertyDescriptor,It=Object.defineProperty,Lt=Object.prototype,Rt=[];Object.freeze(Rt);let zt={};Object.freeze(zt);let Bt=Object.toString(),Vt=()=>{},Ht=Reflect.ownKeys,Ut=Object.getOwnPropertyDescriptors,j=Symbol(`mobx administration`);var Wt=class{constructor(e=`Atom`){this.tt=void 0,this.yt=0,this.H=null,this.J=0,this.F=-1,this.onBOL=void 0,this.onBUOL=void 0,this.tt=e}get isBeingObserved(){return m(this.yt,1)}set isBeingObserved(e){this.yt=h(this.yt,1,e)}get isPendingUnobservation(){return m(this.yt,2)}set isPendingUnobservation(e){this.yt=h(this.yt,2,e)}get diffValue(){return+!!m(this.yt,4)}set diffValue(e){this.yt=h(this.yt,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return Pe(this)}reportChanged(){A(),Fe(this),Me()}toString(){return this.tt}};let Gt=l(`Atom`,Wt),Kt=Object.is,qt={t:`override`,o:function(){return 0},u:function(){t(44,this.t)}},Jt=`true`,Yt=ce(),M=[Yt],Xt={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Xt);let Zt=ie(`observable`),Qt=ie(`observable.ref`,{A:y}),$t=ie(`observable.shallow`,{A:function(e,t,n){return e==null||wt(e)||yt(e)||ir(e)||sr(e)?e:Array.isArray(e)?sn.array(e,{name:n,deep:!1}):o(e)?sn.object(e,void 0,{name:n,deep:!1}):u(e)?sn.map(e,{name:n,deep:!1}):d(e)?sn.set(e,{name:n,deep:!1}):void 0}}),en=ie(`observable.struct`,{A:function(e,t){return kt(e,t)?t:e}}),tn={box(e,t){let n=fe(t);return new _n(e,me(n),n.name,!0,n.equals)},array(e,t){let n=fe(t);return function(e,t,n=`ObservableArray`,r=!1){return Ot(()=>{let i=new Qn(n,t,r);It(i.j,j,{enumerable:!1,writable:!1,configurable:!0,value:i});let a=new Proxy(i.j,Zn);return i.v=a,e&&e.length&&i.wt(0,0,e),a})}(e,me(n),n.name)},map(e,t){let n=fe(t);return new rr(e,me(n),n.name)},set(e,t){let n=fe(t);return new or(e,me(n),n.name)},object:(e,t,n)=>Ot(()=>Ge(function(e,t){var n;return(n=(e=St(e,t))[j]).v??(n.v=new Proxy(e,qn))}({},n),e,t))},nn=pe(Qt),rn=pe($t),an=pe(Zt),on=pe(en);var sn=Pt(function(e,t,n){return t&&typeof t.kind==`string`?se(Zt,e,t):Qe(e)?e:o(e)?sn.object(e,t,n):Array.isArray(e)?sn.array(e,t):u(e)?sn.map(e,t):d(e)?sn.set(e,t):typeof e==`object`&&e?e:sn.box(e,t)},Zt,tn);let cn=`computed`,ln=D(cn),un=he(D(`computed.struct`,{equals:_})),dn=function(e,t){if(t&&typeof t.kind==`string`)return k(ln,e,t);if(o(e))return he(D(cn,e));let n=o(t)?t:{};return n.get=e,n.name||=e.name||``,new yn(n)};var fn;Pt(dn,ln);let pn=0,mn=1,hn=(fn=Ft(()=>{},`name`)?.configurable)!=null&&fn,gn={value:`action`,configurable:!0,writable:!1,enumerable:!1};var _n=class extends Wt{constructor(e,t,n=`ObservableValue`,r=!0,i=Kt){super(n),this.A=void 0,this.tt=void 0,this.xt=void 0,this.gt=!1,this.st=void 0,this.ot=void 0,this.rt=void 0,this.dehancer=void 0,this.A=t,this.tt=n,this.xt=i,this.rt=t(e,void 0,n)}dehanceValue(e){return this.dehancer===void 0?e:this.dehancer(e)}set(e){(e=this.jt(e))!==N.UNCHANGED&&this.Ot(e)}jt(e){if(ct(this)){let t=ut(this,{object:this,type:Xn,newValue:e});if(!t)return N.UNCHANGED;e=t.newValue}return e=this.A(e,this.rt,this.tt),this.xt(this.rt,e)?N.UNCHANGED:e}Ot(e){let t=this.rt;this.rt=e,this.reportChanged(),dt(this)&&pt(this,{type:Xn,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.rt)}raw(){return this.rt}toJSON(){return this.get()}toString(){return`${this.tt}[${this.rt}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let vn=l(`ObservableValue`,_n);var yn=class{constructor(e){this.K=-1,this.L=[],this.$=null,this.H=null,this.U=0,this.J=0,this.F=0,this.W=0,this.rt=new xn(null),this.tt=void 0,this._t=void 0,this.yt=0,this.derivation=void 0,this.St=void 0,this.At=void 0,this.xt=void 0,this.Vt=void 0,this.Mt=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||t(31),this.derivation=e.get,this.tt=e.name||`ComputedValue`,e.set&&(this.St=ge(`ComputedValue-setter`,e.set)),this.xt=e.equals||Kt,this.At=e.context,this.Vt=e.requiresReaction,this.Mt=!!e.keepAlive}q(){(function(e){var t;e.F===0&&(e.F=1,(t=e.H)==null||t.forEach(e=>{e.K===0&&(e.K=1,e.q())}))})(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return m(this.yt,1)}set isComputing(e){this.yt=h(this.yt,1,e)}get isRunningSetter(){return m(this.yt,2)}set isRunningSetter(e){this.yt=h(this.yt,2,e)}get isBeingObserved(){return m(this.yt,4)}set isBeingObserved(e){this.yt=h(this.yt,4,e)}get isPendingUnobservation(){return m(this.yt,8)}set isPendingUnobservation(e){this.yt=h(this.yt,8,e)}get diffValue(){return+!!m(this.yt,16)}set diffValue(e){this.yt=h(this.yt,16,e===1)}get(){if(this.isComputing&&t(32,this.tt,this.derivation),N.inBatch!==0||this.H&&this.H.size!==0||this.Mt){let e=this.isBeingObserved;if(Pe(this),Se(this)){let e=N.trackingContext;e||!this.Mt&&!this.isBeingObserved||(N.trackingContext=this),this.trackAndCompute()&&function(e){var t;e.F!==2&&(e.F=2,(t=e.H)==null||t.forEach(t=>{t.K===1?t.K=2:t.K===0&&(e.F=0)}))}(this),N.trackingContext=e}else !e&&this.isBeingObserved&&this.L.forEach(Ne)}else Se(this)&&(this.Nt(),A(),this.rt=this.Rt(!1),Me());let e=this.rt;if(xe(e))throw e.cause;return e}set(e){if(this.St){this.isRunningSetter&&t(33,this.tt),this.isRunningSetter=!0;try{this.St.call(this.At,e)}finally{this.isRunningSetter=!1}}else t(34,this.tt)}trackAndCompute(){let e=this.rt,t=this.K===-1,n=this.Rt(!0),r=t||xe(e)||xe(n)||!this.xt(e,n);return r&&(this.rt=n),r}Rt(e){let t;if(this.isComputing=!0,e)t=Ce(this,this.derivation,this.At);else if(!0===N.disableErrorBoundaries)t=this.derivation.call(this.At);else try{t=this.derivation.call(this.At)}catch(e){t=new xn(e)}return this.isComputing=!1,t}G(){this.Mt||(we(this),this.rt=void 0)}Nt(){}toString(){return`${this.tt}[${this.derivation.toString()}]`}valueOf(){return f(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let bn=l(`ComputedValue`,yn);var xn=class{constructor(e){this.cause=void 0,this.cause=e}};let Sn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var Cn=class{constructor(){this.version=7,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.isRunningUnobservations=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.safeDescriptors=!0}};let wn=!0,Tn=!1,N=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(wn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(wn=!1),wn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Cn):(setTimeout(()=>{Tn||t(35)},1),new Cn)}();var En=class{constructor(e=`Reaction`,t,n,r){this.tt=void 0,this.Et=void 0,this.kt=void 0,this.Ct=void 0,this.L=[],this.$=[],this.K=-1,this.U=0,this.W=0,this.yt=0,this.It=void 0,this.tt=e,this.Et=t,this.kt=n,this.Ct=r}get isDisposed(){return m(this.yt,1)}set isDisposed(e){this.yt=h(this.yt,1,e)}get isScheduled(){return m(this.yt,2)}set isScheduled(e){this.yt=h(this.yt,2,e)}get isTrackPending(){return m(this.yt,4)}set isTrackPending(e){this.yt=h(this.yt,4,e)}get isRunning(){return m(this.yt,8)}set isRunning(e){this.yt=h(this.yt,8,e)}get diffValue(){return+!!m(this.yt,16)}set diffValue(e){this.yt=h(this.yt,16,e===1)}q(){this.Y()}Y(){this.isScheduled||(this.isScheduled=!0,N.pendingReactions.push(this),Ie())}X(){if(!this.isDisposed){A(),this.isScheduled=!1;let e=N.trackingContext;if(N.trackingContext=this,Se(this)){this.isTrackPending=!0;try{this.Et()}catch(e){this.Pt(e)}}N.trackingContext=e,Me()}}track(e){if(this.isDisposed)return;A(),this.isRunning=!0;let t=N.trackingContext;N.trackingContext=this;let n=Ce(this,e,void 0);N.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&we(this),xe(n)&&this.Pt(n.cause),Me()}Pt(e){if(this.kt)this.kt(e,this);else{if(N.disableErrorBoundaries)throw e;N.suppressReactionErrors||console.error(`[mobx] uncaught error in '${this}'`,e),N.globalReactionErrorHandlers.forEach(t=>t(e,this))}}dispose(){var e;this.isDisposed||(this.isDisposed=!0,(e=this.It)==null||e.call(this),this.isRunning||(A(),we(this),Me()))}Z(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.It=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[j]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.tt}]`}};let Dn=100,On=e=>e(),kn=l(`Reaction`,En),An=`action`,jn=`autoAction`,Mn=b(An),Nn=b(`action.bound`,{bound:!0}),Pn=b(jn,{autoAction:!0}),Fn=b(`autoAction.bound`,{autoAction:!0,bound:!0}),In=ze(!1);Pt(In,Mn);let Ln=ze(!0);Pt(Ln,Pn);let Rn=Re(Nn),zn=Re(Fn),Bn=e=>e(),Vn=`always`;var Hn=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};let Un=T(`flow`),Wn=T(`flow.bound`,{bound:!0}),Gn=Pt(function(e,t){if(t&&typeof t.kind==`string`)return E(Un,e,t);let n=e,i=n.name||`flow`,a=function(){let e=arguments,t=In(i,n).apply(this,e),a,o,s=new Promise(function(e,n){function s(e){let r;o=void 0;try{r=In(i,t.next).call(t,e)}catch(e){return n(e)}l(r)}function c(e){let r;o=void 0;try{r=In(i,t.throw).call(t,e)}catch(e){return n(e)}l(r)}function l(t){if(!r(t?.then))return t.done?e(t.value):(o=Promise.resolve(t.value),o.then(s,c));t.then(l,n)}a=n,s(void 0)});return s.cancel=In(i,function(){try{o&&Je(o);let e=t.return(void 0),n=Promise.resolve(e.value);n.then(Vt,Vt),Je(n),a(new Hn)}catch(e){a(e)}}),s};return a.isMobXFlow=!0,a},Un),Kn=de(Wn,E),qn={has:(e,t)=>st(e).et(t),get:(e,t)=>st(e).Tt(t),set(e,t,n){var r;return!!i(t)&&((r=st(e).Bt(t,n,!0))==null||r)},deleteProperty(e,t){var n;return!!i(t)&&((n=st(e).Dt(t,!0))==null||n)},defineProperty(e,t,n){var r;return(r=st(e).l(t,n))==null||r},ownKeys:e=>st(e).it(),preventExtensions(e){t(13)}},Jn=Symbol(`mobx-keys`),Yn=`splice`,Xn=`update`,Zn={get(e,t){let n=e[j];return t===j?n:t===`length`?n.Kt():typeof t!=`string`||isNaN(t)?p($n,t)?$n[t]:e[t]:n.Tt(parseInt(t))},set(e,t,n){let r=e[j];return t===`length`?r.Lt(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.Bt(parseInt(t),n),!0},preventExtensions(){t(15)}};var Qn=class{constructor(e=`ObservableArray`,t,n){this.$t=void 0,this.ct=void 0,this.j=[],this.st=void 0,this.ot=void 0,this.A=void 0,this.dehancer=void 0,this.v=void 0,this.Ut=0,this.$t=n,this.ct=new Wt(e),this.A=(e,n)=>t(e,n,`ObservableArray[..]`)}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}ht(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e}Kt(){return this.ct.reportObserved(),this.j.length}Lt(e){(!Number.isInteger(e)||e<0)&&t(40,e);let n=this.j.length;if(e!==n)if(e>n){let t=Array.from({length:e-n});this.wt(n,0,t)}else this.wt(e,n-e)}zt(e,n){e!==this.Ut&&t(16),this.Ut+=n}wt(e,t,n){let r=this.j.length;if(e===void 0?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=arguments.length===1?r-e:t==null?0:Math.max(0,Math.min(t,r-e)),n===void 0&&(n=Rt),ct(this)){let r=ut(this,{object:this.v,type:Yn,index:e,removedCount:t,added:n});if(!r)return Rt;t=r.removedCount,n=r.added}n=n.length===0?n:n.map(e=>this.A(e,void 0));let i=this.qt(e,t,n);return t===0&&n.length===0||this.Ft(e,n,i),this.ht(i)}qt(e,t,n){if(n.length<1e4)return this.j.splice(e,t,...n);{let r=this.j.slice(e,e+t),i=this.j.slice(e+t);this.j.length+=n.length-t;for(let t=0;t<n.length;t++)this.j[e+t]=n[t];for(let t=0;t<i.length;t++)this.j[e+n.length+t]=i[t];return r}}Ht(e,t,n){let r=dt(this),i=r?{observableKind:`array`,object:this.v,type:Xn,debugObjectName:this.ct.tt,index:e,newValue:t,oldValue:n}:null;this.ct.reportChanged(),r&&pt(this,i)}Ft(e,t,n){let r=dt(this),i=r?{observableKind:`array`,object:this.v,debugObjectName:this.ct.tt,type:Yn,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.ct.reportChanged(),r&&pt(this,i)}Tt(e){return this.ct.reportObserved(),this.Wt(this.j[e])}Bt(e,t){let n=this.j;if(e<n.length){let r=n[e];if(ct(this)){let n=ut(this,{type:Xn,object:this.v,index:e,newValue:t});if(!n)return;t=n.newValue}(t=this.A(t,r))!==r&&(n[e]=t,this.Ht(e,t,r))}else{let r=Array.from({length:e+1-n.length});r[r.length-1]=t,this.wt(n.length,0,r)}}},$n={clear(){return this.splice(0)},replace(e){let t=this[j];return t.wt(0,t.j.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[j];switch(arguments.length){case 0:return[];case 1:return r.wt(e);case 2:return r.wt(e,t)}return r.wt(e,t,n)},spliceWithArray(e,t,n){return this[j].wt(e,t,n)},push(...e){let t=this[j];return t.wt(t.j.length,0,e),t.j.length},pop(){return this.splice(Math.max(this[j].j.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[j];return t.wt(0,0,e),t.j.length},reverse(){return N.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){N.trackingDerivation&&t(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[j],n=t.ht(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};ht(`at`,gt),ht(`concat`,gt),ht(`flat`,gt),ht(`includes`,gt),ht(`indexOf`,gt),ht(`join`,gt),ht(`lastIndexOf`,gt),ht(`slice`,gt),ht(`toString`,gt),ht(`toLocaleString`,gt),ht(`toSorted`,gt),ht(`toSpliced`,gt),ht(`with`,gt),ht(`every`,_t),ht(`filter`,_t),ht(`find`,_t),ht(`findIndex`,_t),ht(`findLast`,_t),ht(`findLastIndex`,_t),ht(`flatMap`,_t),ht(`forEach`,_t),ht(`map`,_t),ht(`some`,_t),ht(`toReversed`,_t),ht(`reduce`,vt),ht(`reduceRight`,vt);let er=l(`ObservableArrayAdministration`,Qn),tr={},nr=`delete`;var rr=class{constructor(e,t=v,n=`ObservableMap`){this.A=void 0,this.tt=void 0,this[j]=tr,this.ft=void 0,this.dt=void 0,this.lt=void 0,this.st=void 0,this.ot=void 0,this.dehancer=void 0,this.A=t,this.tt=n,Ot(()=>{this.lt=g(`ObservableMap.keys()`),this.ft=new Map,this.dt=new Map,e&&this.merge(e)})}et(e){return this.ft.has(e)}has(e){if(!N.trackingDerivation)return this.et(e);let t=this.dt.get(e);if(!t){let n=t=new _n(this.et(e),y,`ObservableMap.key?`,!1);this.dt.set(e,n),n.onBUOL=new Set([()=>this.dt.delete(e)])}return t.get()}set(e,t){let n=this.et(e);if(ct(this)){let r=ut(this,{type:n?Xn:`add`,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.Gt(e,t):this.Jt(e,t),this}delete(e){if(ct(this)&&!ut(this,{type:nr,object:this,name:e}))return!1;if(this.et(e)){let t=dt(this),n=t?{observableKind:`map`,debugObjectName:this.tt,type:nr,object:this,oldValue:this.ft.get(e).rt,name:e}:null;return at(()=>{var t;this.lt.reportChanged(),(t=this.dt.get(e))==null||t.Ot(!1),this.ft.get(e).Ot(void 0),this.ft.delete(e)}),t&&pt(this,n),!0}return!1}Gt(e,t){let n=this.ft.get(e);if((t=n.jt(t))!==N.UNCHANGED){let r=dt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:Xn,object:this,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}}Jt(e,t){at(()=>{var n;let r=new _n(t,this.A,`ObservableMap.key`,!1);this.ft.set(e,r),t=r.rt,(n=this.dt.get(e))==null||n.Ot(!0),this.lt.reportChanged()});let n=dt(this);n&&pt(this,n?{observableKind:`map`,debugObjectName:this.tt,type:`add`,object:this,name:e,newValue:t}:null)}get(e){return this.has(e)?this.Wt(this.ft.get(e).get()):this.Wt(void 0)}getOrInsert(e,t){return this.has(e)||this.set(e,t),this.get(e)}getOrInsertComputed(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}keys(){return this.lt.reportObserved(),this.ft.keys()}values(){let e=this,t=this.keys();return bt({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e.get(r)}}})}entries(){let e=this,t=this.keys();return bt({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:[r,e.get(r)]}}})}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}merge(e){return ir(e)&&(e=new Map(e)),at(()=>{o(e)?function(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>Lt.propertyIsEnumerable.call(e,t))]:t}(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):u(e)?(function(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}(e)||t(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&t(20,e)}),this}clear(){at(()=>{Te(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return at(()=>{let n=function(e){if(u(e)||ir(e))return e;if(Array.isArray(e))return new Map(e);if(o(e)){let t=new Map;for(let n in e)t.set(n,e[n]);return t}return t(21,e)}(e),r=new Map,i=!1;for(let e of this.ft.keys())if(!n.has(e))if(this.delete(e))i=!0;else{let t=this.ft.get(e);r.set(e,t)}for(let[e,t]of n.entries()){let n=this.ft.has(e);if(this.set(e,t),this.ft.has(e)){let t=this.ft.get(e);r.set(e,t),n||(i=!0)}}if(!i)if(this.ft.size!==r.size)this.lt.reportChanged();else{let e=this.ft.keys(),t=r.keys(),n=e.next(),i=t.next();for(;!n.done;){if(n.value!==i.value){this.lt.reportChanged();break}n=e.next(),i=t.next()}}this.ft=r}),this}get size(){return this.lt.reportObserved(),this.ft.size}toString(){return`[object ObservableMap]`}toJSON(){return Array.from(this)}get[Symbol.toStringTag](){return`Map`}},ir=l(`ObservableMap`,rr);let ar={};var or=class{constructor(e,t=v,n=`ObservableSet`){this.tt=void 0,this[j]=ar,this.ft=new Set,this.ct=void 0,this.ot=void 0,this.st=void 0,this.dehancer=void 0,this.A=void 0,this.tt=n,this.A=(e,r)=>t(e,r,n),Ot(()=>{this.ct=g(this.tt),e&&this.replace(e)})}Wt(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){at(()=>{Te(()=>{for(let e of this.ft.values())this.delete(e)})})}forEach(e,t){for(let n of this)e.call(t,n,n,this)}get size(){return this.ct.reportObserved(),this.ft.size}add(e){if(ct(this)){let t=ut(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){at(()=>{e=this.A(e,void 0),this.ft.add(e),this.ct.reportChanged()});let t=dt(this);t&&pt(this,t?{observableKind:`set`,debugObjectName:this.tt,type:`add`,object:this,newValue:e}:null)}return this}delete(e){if(ct(this)&&!ut(this,{type:nr,object:this,oldValue:e}))return!1;if(this.has(e)){let t=dt(this),n=t?{observableKind:`set`,debugObjectName:this.tt,type:nr,object:this,oldValue:e}:null;return at(()=>{this.ct.reportChanged(),this.ft.delete(e)}),t&&pt(this,n),!0}return!1}has(e){return this.ct.reportObserved(),this.ft.has(this.Wt(e))}entries(){let e=this.values();return xt({next(){let{value:t,done:n}=e.next();return n?{value:void 0,done:n}:{value:[t,t],done:n}}})}keys(){return this.values()}values(){this.ct.reportObserved();let e=this,t=this.ft.values();return xt({next(){let{value:n,done:r}=t.next();return r?{value:void 0,done:r}:{value:e.Wt(n),done:r}}})}intersection(e){return new Set(this).intersection(e)}union(e){return new Set(this).union(e)}difference(e){return new Set(this).difference(e)}symmetricDifference(e){return new Set(this).symmetricDifference(e)}isSubsetOf(e){return new Set(this).isSubsetOf(e)}isSupersetOf(e){return new Set(this).isSupersetOf(e)}isDisjointFrom(e){return new Set(this).isDisjointFrom(e)}replace(e){return sr(e)&&(e=new Set(e)),Array.isArray(e)||d(e)?at(()=>{let t=d(e)?e:new Set(e);if(t.size!==0)if(this.ft.size!==0){for(let e of this.ft.values())t.has(this.Wt(e))||this.delete(e);t.forEach(e=>this.add(e))}else t.forEach(e=>this.add(e));else this.clear()}):e!=null&&t(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},sr=l(`ObservableSet`,or);let cr=Object.create(null),lr=`remove`;var ur=class{constructor(e,t=new Map,n,r=Yt){this.h=void 0,this.j=void 0,this.tt=void 0,this.ut=void 0,this.lt=void 0,this.ot=void 0,this.st=void 0,this.v=void 0,this.p=void 0,this.Xt=void 0,this.Qt=void 0,this.O=void 0,this.V=void 0,this.h=e,this.j=t,this.tt=n,this.ut=r,this.lt=new Wt(`ObservableObject.keys`),this.p=o(this.h)}_(e){return(this.j.get(e)??this.vt(e)??this.bt(e)).get()}vt(e){let t=this.O?.get(e);if(!t)return;this.O.delete(e),this.O.size===0&&(this.O=void 0);let n=t();return this.j.set(e,n),n}bt(e){let t=this.V?.get(e);if(!t)return;this.V.delete(e),this.V.size===0&&(this.V=void 0);let n=t();return this.j.set(e,n),n}M(e,t){let n=this.j.get(e)??this.vt(e)??this.bt(e);if(n instanceof yn)return n.set(t),!0;if(ct(this)){let n=ut(this,{type:Xn,object:this.v||this.h,name:e,newValue:t});if(!n)return null;t=n.newValue}if((t=n.jt(t))!==N.UNCHANGED){let r=dt(this),i=r?{type:Xn,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.rt,name:e,newValue:t}:null;n.Ot(t),r&&pt(this,i)}return!0}Tt(e){return N.trackingDerivation&&!p(this.h,e)&&this.et(e),this.h[e]}Bt(e,t,n=!1){return p(this.h,e)?this.j.has(e)?this.M(e,t):n?Reflect.set(this.h,e,t):(this.h[e]=t,!0):this.u(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.ut,n)}et(e){if(!N.trackingDerivation)return e in this.h;this.Qt||=new Map;let t=this.Qt.get(e);return t||(t=new _n(e in this.h,y,`ObservableObject.key?`,!1),this.Qt.set(e,t)),t.get()}u(e,t,n,r=!1){return!0===n&&(n=this.ut),!1===n?this.l(e,t,r):n.u(this,e,t,r)}l(e,t,n=!1){try{A();let r=this.Dt(e);if(!r)return r;if(ct(this)){let n=ut(this,{object:this.v||this.h,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:r}=n;t.value!==r&&(t=Pt({},t,{value:r}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else It(this.h,e,t);this.Yt(e,t.value)}finally{Me()}return!0}S(e,t,n,r=!1){try{A();let i=this.Dt(e);if(!i)return i;if(ct(this)){let n=ut(this,{object:this.v||this.h,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let a=Ct(e),o={configurable:!N.safeDescriptors||this.p,enumerable:!0,get:a.get,set:a.set};if(r){if(!Reflect.defineProperty(this.h,e,o))return!1}else It(this.h,e,o);let s=new _n(t,n,`ObservableObject.key`,!1);this.j.set(e,s),this.Yt(e,s.rt)}finally{Me()}return!0}m(e,t,n=!1){try{A();let r=this.Dt(e);if(!r)return r;if(ct(this)&&!ut(this,{object:this.v||this.h,name:e,type:`add`,newValue:void 0}))return null;t.name||=`ObservableObject.key`,t.context=this.v||this.h;let i=Ct(e),a={configurable:!N.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else It(this.h,e,a);this.j.set(e,new yn(t)),this.Yt(e,void 0)}finally{Me()}return!0}Dt(e,t=!1){if(!p(this.h,e))return!0;if(ct(this)&&!ut(this,{object:this.v||this.h,name:e,type:lr}))return null;try{var n;A();let r=dt(this),i=this.j.get(e),a;if(i||!r||(a=Ft(this.h,e)?.value),t){if(!Reflect.deleteProperty(this.h,e))return!1}else delete this.h[e];i&&(this.j.delete(e),i instanceof _n&&(a=i.rt),Fe(i)),this.lt.reportChanged(),(n=this.Qt)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&pt(this,{type:lr,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{Me()}return!0}Yt(e,t){var n;let r=dt(this);r&&r&&pt(this,r?{type:`add`,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,name:e,newValue:t}:null),(n=this.Qt)==null||(n=n.get(e))==null||n.set(!0),this.lt.reportChanged()}it(){return this.lt.reportObserved(),Ht(this.h)}nt(){return this.lt.reportObserved(),Object.keys(this.h)}};let dr=l(`ObservableObjectAdministration`,ur),fr=Lt.toString,pr=globalThis.Iterator?.prototype||{};e.$mobx=j,e.FlowCancellationError=Hn,e.ObservableMap=rr,e.ObservableSet=or,e.Reaction=En,e._allowStateChanges=be,e._allowStateChangesInsideComputed=Be,e._allowStateReadsEnd=function(e){N.allowStateReads=e},e._allowStateReadsStart=function(e){let t=N.allowStateReads;return N.allowStateReads=e,t},e._autoAction=Ln,e._autoActionBound=zn,e._endAction=ye,e._getAdministration=Et,e._getGlobalState=function(){return N},e._interceptReads=function(e,t,n){let r;return ir(e)||yt(e)||vn(e)?r=Et(e):wt(e)&&(r=Et(e,t)),r.dehancer=typeof t==`function`?t:n,()=>{r.dehancer=void 0}},e._isComputingDerivation=function(){return N.trackingDerivation!==null},e._resetGlobalState=function(){let e=new Cn;for(let t in e)Sn.indexOf(t)===-1&&(N[t]=e[t]);N.allowStateChanges=!N.enforceActions},e._startAction=ve,e.action=In,e.actionBound=Rn,e.autorun=He,e.compareDefault=Kt,e.compareIdentity=function(e,t){return e===t},e.compareShallow=function(e,t){return kt(e,t,1)},e.compareStructural=_,e.computed=dn,e.computedStruct=un,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((N.pendingReactions.length||N.inBatch||N.isRunningReactions)&&t(36),Tn=!0,wn){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),N=new Cn}}();let{enforceActions:n}=e;if(n!==void 0){let e=n===Vn?Vn:n===`observed`;N.enforceActions=e,N.allowStateChanges=!0!==e&&e!==Vn}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(N[t]=!!e[t])}),N.allowStateReads=!N.observableRequiresReaction,e.reactionScheduler&&function(e){let t=On;On=n=>e(()=>t(n))}(e.reactionScheduler)},e.createAtom=g,e.defineProperty=function(e,n,r){if(wt(e))return e[j].l(n,r);t(39)},e.entries=function(e){return wt(e)?$e(e).map(t=>[t,e[t]]):ir(e)?$e(e).map(t=>[t,e.get(t)]):sr(e)?Array.from(e.entries()):yt(e)?e.map((e,t)=>[t,e]):void t(7)},e.extendObservable=Ge,e.flow=Gn,e.flowBound=Kn,e.flowResult=function(e){return e},e.get=function(e,n){if(et(e,n))return wt(e)?e[j].Tt(n):ir(e)?e.get(n):yt(e)?e[n]:void t(11)},e.getAtom=Tt,e.getDebugName=Dt,e.getDependencyTree=function(e,t){return Ke(Tt(e,t))},e.getObserverTree=function(e,t){return qe(Tt(e,t))},e.has=et,e.intercept=function(e,t,n){return r(n)?function(e,t,n){return lt(Et(e,t),n)}(e,t,n):function(e,t){return lt(Et(e),t)}(e,t)},e.isAction=Ve,e.isBoxedObservable=vn,e.isComputed=function(e){return Xe(e)},e.isComputedProp=function(e,t){return Xe(e,t)},e.isFlow=Ye,e.isFlowCancellationError=function(e){return e instanceof Hn},e.isObservable=Qe,e.isObservableArray=yt,e.isObservableMap=ir,e.isObservableObject=wt,e.isObservableProp=function(e,t){return Ze(e,t)},e.isObservableSet=sr,e.keys=$e,e.makeAutoObservable=function(e,t,n){return o(e)?Ge(e,e,t,n):(Ot(()=>{let r=St(e,n)[j];if(!e[Jn]){let t=Object.getPrototypeOf(e),n=new Set([...Ht(e),...Ht(t)]);n.delete(`constructor`),n.delete(j),c(t,Jn,n)}e[Jn].forEach(e=>mt(r,e,!t||!(e in t)||t[e]))}),e)},e.makeObservable=function(e,t,n){return Ot(()=>{let r=St(e,n)[j];Ht(t).forEach(e=>mt(r,e,t[e]))}),e},e.observable=sn,e.observableDeep=an,e.observableRef=nn,e.observableShallow=rn,e.observableStruct=on,e.observe=function(e,t,n,i){return r(n)?function(e,t,n,r){return nt(Et(e,t),n,r)}(e,t,n,i):function(e,t,n){let r=Et(e);if(yt(e))n&&t({observableKind:`array`,object:r.v,debugObjectName:r.ct.tt,type:`splice`,index:0,added:r.j.slice(),addedCount:r.j.length,removed:[],removedCount:0});else if(!ir(e)&&!sr(e)&&!wt(e))return nt(r,t,n);return ft(r,t)}(e,t,n)},e.onBecomeObserved=function(e,t,n){return We(`onBO`,e,t,n)},e.onBecomeUnobserved=function(e,t,n){return We(`onBUO`,e,t,n)},e.onReactionError=function(e){return N.globalReactionErrorHandlers.push(e),()=>{let t=N.globalReactionErrorHandlers.indexOf(e);t>=0&&N.globalReactionErrorHandlers.splice(t,1)}},e.override=qt,e.ownKeys=tt,e.reaction=function(e,t,n=zt){function r(){if(p=!1,h.isDisposed)return;let t=!1,r=d;h.track(()=>{let n=be(!1,()=>e(h));t=f||!m(d,n),d=n}),(f&&n.fireImmediately||!f&&t)&&o(d,r,h),f=!1}var i;let a=n.name??`Reaction`,o=In(a,n.onError?(s=n.onError,c=t,function(){try{return c.apply(this,arguments)}catch(e){s.call(this,e)}}):t);var s,c;let l=!n.scheduler&&!n.delay,u=Ue(n),d,f=!0,p=!1,m=n.equals||Kt,h=new En(a,()=>{f||l?r():p||(p=!0,u(r))},n.onError,n.requiresObservable);return n!=null&&(i=n.signal)!=null&&i.aborted||h.Y(),h.Z(n?.signal)},e.remove=function(e,n){wt(e)?e[j].Dt(n):ir(e)||sr(e)?e.delete(n):yt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=Be,e.set=function e(n,r,i){if(arguments.length===2&&!sr(n)){A();let t=r;try{for(let r in t)e(n,r,t[r])}finally{Me()}return}wt(n)?n[j].Bt(r,i):ir(n)?n.set(r,i):sr(n)?n.add(r):yt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(42,r),A(),r>=n.length&&(n.length=r+1),n[r]=i,Me()):t(8)},e.spy=function(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}},e.toJS=function(e){return it(e,new Map)},e.transaction=at,e.untracked=Te,e.values=function(e){return wt(e)?$e(e).map(t=>e[t]):ir(e)?$e(e).map(t=>e.get(t)):sr(e)?Array.from(e.values()):yt(e)?e.slice():void t(6)},e.when=function(e,t,n){return arguments.length===1||t&&typeof t==`object`?function(e,t){var n;if(t!=null&&(n=t.signal)!=null&&n.aborted)return Pt(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let r,i,a=new Promise((n,a)=>{var o;let s=ot(e,n,Pt({},t,{onError:a}));r=()=>{s(),a(Error(`WHEN_CANCELLED`))},i=()=>{s(),a(Error(`WHEN_ABORTED`))},t==null||(o=t.signal)==null||o.addEventListener==null||o.addEventListener(`abort`,i)}).finally(()=>{var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,i)});return a.cancel=r,a}(e,t):ot(e,t,n||{})}})),_C=Te((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t={0:`Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'`,1(e,t){return`Cannot apply '${e}' to '${t.toString()}': Field not found.`},5:`'keys()' can only be used on observable objects, arrays, sets and maps`,6:`'values()' can only be used on observable objects, arrays, sets and maps`,7:`'entries()' can only be used on observable objects, arrays and maps`,8:`'set()' can only be used on observable objects, arrays and maps`,9:`'remove()' can only be used on observable objects, arrays and maps`,10:`'has()' can only be used on observable objects, arrays and maps`,11:`'get()' can only be used on observable objects, arrays and maps`,12:`Invalid annotation`,13:`Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,14:`Intercept handlers should return nothing or a change object`,15:`Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,16:`Modification exception: the internal structure of an observable array was changed.`,19(e){return`Cannot initialize from classes that inherit from Map: `+e.constructor.name},20(e){return`Cannot initialize map from `+e},21(e){return`Cannot convert to map from '${e}'`},23:`It is not possible to get index atoms from arrays`,24(e){return`Cannot obtain administration from `+e},25(e,t){return`the entry '${e}' does not exist in the observable map '${t}'`},26:`please specify a property`,27(e,t){return`no observable property '${e.toString()}' found on the observable object '${t}'`},28(e){return`Cannot obtain atom from `+e},29:`Expecting some object`,30:`invalid action stack. did you forget to finish an action?`,31:`missing option for computed: get`,32(e,t){return`Cycle detected in computation ${e}: ${t}`},33(e){return`The setter of computed value '${e}' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?`},34(e){return`[ComputedValue '${e}'] It is not possible to assign a new value to a computed value.`},35:"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`",36:`isolateGlobalState should be called before MobX is running any reactions`,37(e){return`[mobx] \`observableArray.${e}()\` mutates the array in-place, which is not allowed inside a derivation. Use \`array.slice().${e}()\` instead`},38:`'ownKeys()' can only be used on observable objects`,39:`'defineProperty()' can only be used on observable objects`,40(e){return`Out of range: `+e},41(e){return`Cannot initialize set from `+e},42(e){return`Invalid index: '${e}'`},43(e,t,n){return`Cannot apply '${e}' to '${t}' (kind: ${n}):\n'${e}' can only be used on properties with a function value.`},44(e){return`'${e}' can only be used with 'makeObservable'`}};function n(e,...n){{let r=typeof e==`string`?e:t[e];throw typeof r==`function`&&(r=r.apply(null,n)),Error(`[MobX] ${r}`)}}let r=Object.assign,i=Object.getOwnPropertyDescriptor,a=Object.defineProperty,o=Object.prototype,s=[];Object.freeze(s);let c={};Object.freeze(c);let l=Object.toString();function u(){return++M.mobxGuid}function d(e){let t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}let f=()=>{};function p(e){return typeof e==`function`}function m(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function h(e){return typeof e==`object`&&!!e}function g(e){if(!h(e))return!1;let t=Object.getPrototypeOf(e);if(t==null)return!0;let n=E(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===l}function _(e){let t=e?.constructor;return t?t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`:!1}function v(e,t,n){a(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function y(e,t,n){a(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function b(e,t){let n=`isMobX`+e;return t.prototype[n]=!0,function(e){return h(e)&&e[n]===!0}}function x(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function S(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function C(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function w(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);return n.length?[...t,...n.filter(t=>o.propertyIsEnumerable.call(e,t))]:t}let T=Reflect.ownKeys;function ee(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function te(e){return e===null?null:typeof e==`object`?``+e:e}function E(e,t){return o.hasOwnProperty.call(e,t)}let ne=Object.getOwnPropertyDescriptors;function D(e,t){return!!(e&t)}function O(e,t,n){return n?e|=t:e&=~t,e}function re(e,t){t.includes(e.kind)||n(`The decorator applied to '${String(e.name)}' cannot be used on a ${e.kind} element`)}let k=Symbol(`mobx administration`);var ie=class{constructor(e=`Atom@`+u()){this.name_=void 0,this.flags_=0,this.observers_=null,this.lastAccessedBy_=0,this.lowestObserverState_=-1,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}get isBeingObserved(){return D(this.flags_,1)}set isBeingObserved(e){this.flags_=O(this.flags_,1,e)}get isPendingUnobservation(){return D(this.flags_,2)}set isPendingUnobservation(e){this.flags_=O(this.flags_,2,e)}get diffValue(){return+!!D(this.flags_,4)}set diffValue(e){this.flags_=O(this.flags_,4,e===1)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}reportObserved(){return ln(this)}reportChanged(){an(),un(this),on()}toString(){return this.name_}};let ae=b(`Atom`,ie);function oe(e,t=f,n=f){let r=new ie(e);return t!==f&&(r.onBOL=new Set([t])),n!==f&&(r.onBUOL=new Set([n])),r}function se(e,t){return e===t}function ce(e,t){return Li(e,t)}function le(e,t){return Li(e,t,1)}let ue=Object.is;function de(e,t,n){return e===null||typeof e!=`object`&&typeof e!=`function`||xr(e)?e:Array.isArray(e)?ut.array(e,{name:n}):g(e)?ut.object(e,void 0,{name:n}):x(e)?ut.map(e,{name:n}):C(e)?ut.set(e,{name:n}):typeof e==`function`&&!zn(e)&&!fr(e)?_(e)?cr(e):Fn(n,e):e}function fe(e,t,r){if(e==null||Ai(e)||pi(e)||_i(e)||Si(e))return e;if(Array.isArray(e))return ut.array(e,{name:r,deep:!1});if(g(e))return ut.object(e,void 0,{name:r,deep:!1});if(x(e))return ut.map(e,{name:r,deep:!1});if(C(e))return ut.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function pe(e){return e}function me(e,t){return xr(e)&&n(`observable.struct should not be used with observable values`),Li(e,t)?t:e}let he=`override`,ge={annotationType_:he,make_:ve,extend_:ye};function _e(e){return e.annotationType_===he}function ve(e,t){return e.isPlainObject_&&n(`Cannot apply '${this.annotationType_}' to '${e.name_}.${t.toString()}':\n'${this.annotationType_}' cannot be used on plain objects.`),E(e.appliedAnnotations_,t)||n(`'${e.name_}.${t.toString()}' is annotated with '${this.annotationType_}', but no such annotated member was found on prototype.`),0}function ye(e,t,r,i){n(44,this.annotationType_)}function be(e,t){return{annotationType_:e,options_:t,make_:xe,extend_:Se}}function xe(e,t,n,r){var i;return(i=this.options_)!=null&&i.bound?this.extend_(e,t,n,!1)===null?0:1:r===e.target_?this.extend_(e,t,n,!1)===null?0:2:zn(n.value)?1:(a(r,t,Te(e,this,t,n,!1)),2)}function Se(e,t,n,r){let i=Te(e,this,t,n);return e.defineProperty_(t,i,r)}function Ce(e,t,r){re(r,[`method`,`field`]);let{kind:i,name:a,addInitializer:o}=r,s=e,c=e=>bt(s.options_?.name??a.toString(),e,s.options_?.autoAction??!1);if(i==`field`)return function(e){var t;let n=e;return zn(n)||(n=c(n)),(t=s.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(i==`method`){var l;return zn(t)||(t=c(t)),(l=s.options_)!=null&&l.bound&&o(function(){let e=this,t=e[a].bind(e);t.isMobxAction=!0,e[a]=t}),t}n(43,s.annotationType_,String(a),i)}function we(e,{annotationType_:t},r,{value:i}){p(i)||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on properties with a function value.`)}function Te(e,t,n,r,i=M.safeDescriptors){var a,o;we(e,t,n,r);let{value:s}=r;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:bt(t.options_?.name??n.toString(),s,t.options_?.autoAction??!1,(o=t.options_)!=null&&o.bound?e.proxy_??e.target_:void 0),configurable:i?e.isPlainObject_:!0,enumerable:!1,writable:!i}}function Ee(e,t){return{annotationType_:e,options_:t,make_:De,extend_:Oe}}function De(e,t,n,r){var i;return r===e.target_?this.extend_(e,t,n,!1)===null?0:2:(i=this.options_)!=null&&i.bound&&(!E(e.target_,t)||!fr(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:fr(n.value)?1:(a(r,t,je(e,this,t,n,!1,!1)),2)}function Oe(e,t,n,r){let i=je(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function ke(e,t,n){var r;re(n,[`method`]);let{name:i,addInitializer:a}=n;return fr(t)||(t=cr(t)),(r=e.options_)!=null&&r.bound&&a(function(){let e=this,t=e[i].bind(e);t.isMobXFlow=!0,e[i]=t}),t}function Ae(e,{annotationType_:t},r,{value:i}){p(i)||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on properties with a generator function value.`)}function je(e,t,n,r,i,a=M.safeDescriptors){Ae(e,t,n,r);let{value:o}=r;return fr(o)||(o=cr(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function A(e,t){return{annotationType_:e,options_:t,make_:Me,extend_:Ne}}function Me(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Ne(e,t,n,i){return Fe(e,this,t,n),e.defineComputedProperty_(t,r({},this.options_,{get:n.get,set:n.set}),i)}function Pe(e,t,n){re(n,[`getter`]);let i=e,{name:a,addInitializer:o}=n,s;function c(e,n){let o=r({},i.options_,{get:t,context:e});return o.name||=`${n.name_}.${a.toString()}`,new kt(o)}return o(function(){let e=Di(this)[k],n=this,r=e.values_.get(a);r instanceof kt&&r.derivation!==t&&e.values_.delete(a),(e.lazyComputedKeys_??=new Map).set(a,()=>c(n,e))}),function(){let e=this[k],n=e.values_.get(a);if(n instanceof kt&&n.derivation!==t){let t=s?.get(this);return t||(t=c(this,e),(s??=new WeakMap).set(this,t)),t.get()}return e.getObservablePropValue_(a)}}function Fe(e,{annotationType_:t},r,{get:i}){i||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' can only be used on getter(+setter) properties.`)}function Ie(e,t){return{annotationType_:e,options_:t,make_:Le,extend_:Re}}function Le(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function Re(e,t,n,r){return Be(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer_??de,r)}function ze(e,t,r){if(r.kind===`field`)throw n(`Please use \`@observable accessor ${String(r.name)}\` instead of \`@observable ${String(r.name)}\``);re(r,[`accessor`]);let i=e,{kind:a,name:o}=r;if(a!==`accessor`)return;function s(e,t){let n=Di(e)[k];return(n.lazyObservableKeys_??=new Map).set(o,()=>new Dt(t,i.options_?.enhancer_??de,`${n.name_}.${o.toString()}`,!1)),n}return{get(){return(this[k]??s(this,t.get.call(this))).getObservablePropValue_(o)},set(e){return(this[k]??s(this,e)).setObservablePropValue_(o,e)},init(e){return s(this,e),e}}}function Be(e,{annotationType_:t},r,i){`value`in i||n(`Cannot apply '${t}' to '${e.name_}.${r.toString()}':\n'${t}' cannot be used on getter/setter properties`)}let Ve=He();function He(e){return{annotationType_:`true`,options_:e,make_:Ge,extend_:Ke}}let Ue=[Ve];function We(e){let t=e.deep!==!1,n=!!e.autoBind,r=!t|(n?2:0);return Ue[r]??(Ue[r]=He({deep:t,autoBind:n}))}function Ge(e,t,n,r){var i;if(n.get)return ht.make_(e,t,n,r);if(n.set){let i=zn(n.set)?n.set:bt(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:M.safeDescriptors?e.isPlainObject_:!0,set:i})===null?0:2:(a(r,t,{configurable:!0,set:i}),2)}if(r!==e.target_&&typeof n.value==`function`){var o;if(_(n.value)){var s;return((s=this.options_)!=null&&s.autoBind?lr:cr).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?Ln:Fn).make_(e,t,n,r)}let c=this.options_?.deep===!1?ot:ut;return typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),c.make_(e,t,n,r)}function Ke(e,t,n,r){var i;return n.get?ht.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:M.safeDescriptors?e.isPlainObject_:!0,set:bt(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),(this.options_?.deep===!1?ot:ut).extend_(e,t,n,r))}function qe(e,t){return r(function(r,i){if(i&&typeof i.kind==`string`)return t(e,r,i);n(`Invalid arguments for \`${e.annotationType_}\``)},e)}let Je={deep:!0,name:void 0,defaultDecorator:void 0};Object.freeze(Je);function Ye(e){return e||Je}let Xe=Ie(`observable`),Ze=Ie(`observable.ref`,{enhancer_:pe}),Qe=Ie(`observable.shallow`,{enhancer_:fe}),$e=Ie(`observable.struct`,{enhancer_:me});function et(e){return qe(e,ze)}function tt(e){return e.deep===!0?de:e.deep===!1?pe:rt(e.defaultDecorator)}function nt(e){return e?e.defaultDecorator??We(e):void 0}function rt(e){return e?e.options_?.enhancer_??de:de}function it(e,t,n){return t&&typeof t.kind==`string`?ze(Xe,e,t):xr(e)?e:g(e)?ut.object(e,t,n):Array.isArray(e)?ut.array(e,t):x(e)?ut.map(e,t):C(e)?ut.set(e,t):typeof e==`object`&&e?e:ut.box(e,t)}let at={box(e,t){let n=Ye(t);return new Dt(e,tt(n),n.name,!0,n.equals)},array(e,t){let n=Ye(t);return oi(e,tt(n),n.name)},map(e,t){let n=Ye(t);return new gi(e,tt(n),n.name)},set(e,t){let n=Ye(t);return new xi(e,tt(n),n.name)},object(e,t,n){return Fi(()=>Xn(Gr({},n),e,t))}},ot=et(Ze),st=et(Qe),ct=et(Xe),lt=et($e);var ut=r(it,Xe,at);let dt=`computed`;function ft(e){return qe(e,Pe)}let pt=A(dt),mt=ft(A(`computed.struct`,{equals:ce})),ht=function(e,t){if(t&&typeof t.kind==`string`)return Pe(pt,e,t);if(g(e))return ft(A(dt,e));p(e)||n("First argument to `computed` should be an expression."),p(t)&&n("A setter as second argument is no longer supported, use `{ set: fn }` option instead");let r=g(t)?t:{};return r.get=e,r.name||=e.name||``,new kt(r)};r(ht,pt);let gt=0,_t=1,vt=i(()=>{},`name`)?.configurable??!1,yt={value:`action`,configurable:!0,writable:!1,enumerable:!1};function bt(e,t,r=!1,i){p(t)||n("`action` can only be invoked on functions"),(typeof e!=`string`||!e)&&n(`actions should have valid names, got: '${e}'`);function o(){return xt(e,r,t,i||this,arguments)}return o.isMobxAction=!0,o.toString=()=>t.toString(),vt&&(yt.value=e,a(o,`name`,yt)),o}function xt(e,t,n,r,i){let a=St(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{Ct(a)}}function St(e,t,n,r){let i=bn()&&!!e,a=0;i&&(a=Date.now(),Sn({type:N,name:e,object:n,arguments:r?Array.from(r):s}));let o=M.trackingDerivation,c=!t||!o;an();let l=M.allowStateChanges;c&&(Ht(),l=Tt(!0));let u=M.allowStateReads;j(!0);let d={runAsAction_:c,prevDerivation_:o,prevAllowStateChanges_:l,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:_t++,parentActionId_:gt};return gt=d.actionId_,d}function Ct(e){gt!==e.actionId_&&n(30),gt=e.parentActionId_,e.error_!==void 0&&(M.suppressReactionErrors=!0),Et(e.prevAllowStateChanges_),Wt(e.prevAllowStateReads_),on(),e.runAsAction_&&Ut(e.prevDerivation_),e.notifySpy_&&wn({time:Date.now()-e.startTime_}),M.suppressReactionErrors=!1}function wt(e,t){let n=Tt(e);try{return t()}finally{Et(n)}}function Tt(e){let t=M.allowStateChanges;return M.allowStateChanges=e,t}function Et(e){M.allowStateChanges=e}var Dt=class extends ie{constructor(e,t,n=`ObservableValue@`+u(),r=!0,i=ue){super(n),this.enhancer_=void 0,this.name_=void 0,this.equals_=void 0,this.hasUnreportedChange_=!1,this.interceptors_=void 0,this.changeListeners_=void 0,this.value_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,this.equals_=i,this.value_=t(e,void 0,n),r&&bn()&&xn({type:`create`,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:this.value_})}dehanceValue(e){return this.dehancer===void 0?e:this.dehancer(e)}set(e){let t=this.value_;if(e=this.prepareNewValue_(e),e!==M.UNCHANGED){let n=bn();n&&Sn({type:ri,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&wn()}}prepareNewValue_(e){if(Ft(this),Kr(this)){let t=Jr(this,{object:this,type:ri,newValue:e});if(!t)return M.UNCHANGED;e=t.newValue}return e=this.enhancer_(e,this.value_,this.name_),this.equals_(this.value_,e)?M.UNCHANGED:e}setNewValue_(e){let t=this.value_;this.value_=e,this.reportChanged(),Yr(this)&&Zr(this,{type:ri,object:this,newValue:e,oldValue:t})}get(){return this.reportObserved(),this.dehanceValue(this.value_)}raw(){return this.value_}toJSON(){return this.get()}toString(){return`${this.name_}[${this.value_}]`}valueOf(){return te(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let Ot=b(`ObservableValue`,Dt);var kt=class{constructor(e){this.dependenciesState_=-1,this.observing_=[],this.newObserving_=null,this.observers_=null,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=0,this.unboundDepsCount_=0,this.value_=new jt(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||n(31),this.derivation=e.get,this.name_=e.name||`ComputedValue@`+u(),e.set&&(this.setter_=bt(this.name_+`-setter`,e.set)),this.equals_=e.equals||ue,this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}onBecomeStale_(){fn(this)}onBO(){this.onBOL&&this.onBOL.forEach(e=>e())}onBUO(){this.onBUOL&&this.onBUOL.forEach(e=>e())}get isComputing(){return D(this.flags_,1)}set isComputing(e){this.flags_=O(this.flags_,1,e)}get isRunningSetter(){return D(this.flags_,2)}set isRunningSetter(e){this.flags_=O(this.flags_,2,e)}get isBeingObserved(){return D(this.flags_,4)}set isBeingObserved(e){this.flags_=O(this.flags_,4,e)}get isPendingUnobservation(){return D(this.flags_,8)}set isPendingUnobservation(e){this.flags_=O(this.flags_,8,e)}get diffValue(){return+!!D(this.flags_,16)}set diffValue(e){this.flags_=O(this.flags_,16,e===1)}get(){if(this.isComputing&&n(32,this.name_,this.derivation),M.inBatch===0&&(!this.observers_||this.observers_.size===0)&&!this.keepAlive_)Nt(this)&&(this.warnAboutUntrackedRead_(),an(),this.value_=this.computeValue_(!1),on());else{let e=this.isBeingObserved;if(ln(this),Nt(this)){let e=M.trackingContext;!e&&(this.keepAlive_||this.isBeingObserved)&&(M.trackingContext=this),this.trackAndCompute()&&dn(this),M.trackingContext=e}else !e&&this.isBeingObserved&&this.observing_.forEach(cn)}let e=this.value_;if(Mt(e))throw e.cause;return e}set(e){if(this.setter_){this.isRunningSetter&&n(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,e)}finally{this.isRunningSetter=!1}}else n(34,this.name_)}trackAndCompute(){let e=this.value_,t=this.dependenciesState_===-1,n=this.computeValue_(!0),r=t||Mt(e)||Mt(n)||!this.equals_(e,n);return r&&(this.value_=n,bn()&&xn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r}computeValue_(e){this.isComputing=!0;let t=Tt(!1),n;if(e)n=Lt(this,this.derivation,this.scope_);else if(M.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new jt(e)}return Et(t),this.isComputing=!1,n}suspend_(){this.keepAlive_||(Bt(this),this.value_=void 0)}warnAboutUntrackedRead_(){(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:M.computedRequiresReaction)&&console.warn(`[mobx] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`)}toString(){return`${this.name_}[${this.derivation.toString()}]`}valueOf(){return te(this.get())}[Symbol.toPrimitive](){return this.valueOf()}};let At=b(`ComputedValue`,kt);var jt=class{constructor(e){this.cause=void 0,this.cause=e}};function Mt(e){return e instanceof jt}function Nt(e){switch(e.dependenciesState_){case 0:return!1;case-1:case 2:return!0;case 1:{let t=j(!0),n=Ht(),r=e.observing_,i=r.length;for(let a=0;a<i;a++){let i=r[a];if(At(i)){if(M.disableErrorBoundaries)i.get();else try{i.get()}catch{return Ut(n),Wt(t),!0}if(e.dependenciesState_===2)return Ut(n),Wt(t),!0}}return Gt(e),Ut(n),Wt(t),!1}}}function Pt(){return M.trackingDerivation!==null}function Ft(e){let t=!!e.observers_&&e.observers_.size>0;!M.allowStateChanges&&(t||M.enforceActions===`always`)&&console.warn(`[MobX] `+(M.enforceActions?`Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: `:`Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: `)+e.name_)}function It(e){!M.allowStateReads&&M.observableRequiresReaction&&console.warn(`[mobx] Observable '${e.name_}' being read outside a reactive context.`)}function Lt(e,t,n){let r=j(!0);Gt(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++M.runId;let i=M.trackingDerivation;M.trackingDerivation=e,M.inBatch++;let a;if(M.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new jt(e)}return M.inBatch--,M.trackingDerivation=i,zt(e),Rt(e),Wt(r),a}function Rt(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:M.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '${e.name_}' is created/updated without reading any observable value.`)}function zt(e){let t=e.observing_,n=e.observing_=e.newObserving_,r=0,i=0,a=e.unboundDepsCount_;for(let e=0;e<a;e++){let t=n[e];t.diffValue===0&&(t.diffValue=1,i!==e&&(n[i]=t),i++),t.dependenciesState_>r&&(r=t.dependenciesState_)}for(n.length=i,e.newObserving_=null,a=t.length;a--;){let n=t[a];n.diffValue===0&&nn(n,e),n.diffValue=0}for(;i--;){let t=n[i];t.diffValue===1&&(t.diffValue=0,tn(t,e))}r!==0&&(e.dependenciesState_=r,e.onBecomeStale_())}function Bt(e){let t=e.observing_;e.observing_=[];let n=t.length;for(;n--;)nn(t[n],e);e.dependenciesState_=-1}function Vt(e){let t=Ht();try{return e()}finally{Ut(t)}}function Ht(){let e=M.trackingDerivation;return M.trackingDerivation=null,e}function Ut(e){M.trackingDerivation=e}function j(e){let t=M.allowStateReads;return M.allowStateReads=e,t}function Wt(e){M.allowStateReads=e}function Gt(e){if(e.dependenciesState_===0)return;e.dependenciesState_=0;let t=e.observing_,n=t.length;for(;n--;)t[n].lowestObserverState_=0}let Kt=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`];var qt=class{constructor(){this.version=7,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.isRunningUnobservations=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.safeDescriptors=!0}};let Jt=!0,Yt=!1,M=function(){let e=globalThis;return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Jt=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==7&&(Jt=!1),Jt?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new qt):(setTimeout(()=>{Yt||n(35)},1),new qt)}();function Xt(){if((M.pendingReactions.length||M.inBatch||M.isRunningReactions)&&n(36),Yt=!0,Jt){let e=globalThis;--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),M=new qt}}function Zt(){return M}function Qt(){let e=new qt;for(let t in e)Kt.indexOf(t)===-1&&(M[t]=e[t]);M.allowStateChanges=!M.enforceActions}function $t(e){return!!e.observers_&&e.observers_.size>0}function en(e){return e.observers_??new Set}function tn(e,t){(e.observers_??=new Set).add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function nn(e,t){let n=e.observers_;n&&(n.delete(t),n.size===0&&rn(e))}function rn(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,M.pendingUnobservations.push(e))}function an(){M.inBatch++}function on(){--M.inBatch===0&&(gn(),!M.isRunningUnobservations&&M.pendingUnobservations.length>0&&sn())}function sn(){M.isRunningUnobservations=!0;try{let e=M.pendingUnobservations;for(let t=0;t<e.length;t++){let n=e[t];n.isPendingUnobservation=!1,(!n.observers_||n.observers_.size===0)&&(n.observers_=null,n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof kt&&n.suspend_())}M.pendingUnobservations=[]}finally{M.isRunningUnobservations=!1}}function cn(e){var t;e.isBeingObserved||(e.isBeingObserved=!0,e.onBO(),(t=e.observing_)==null||t.forEach(cn))}function ln(e){It(e);let t=M.trackingDerivation;return t===null?((!e.observers_||e.observers_.size===0)&&M.inBatch>0&&rn(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&M.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function un(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&e.onBecomeStale_(),e.dependenciesState_=2}))}function dn(e){var t;e.lowestObserverState_!==2&&(e.lowestObserverState_=2,(t=e.observers_)==null||t.forEach(t=>{t.dependenciesState_===1?t.dependenciesState_=2:t.dependenciesState_===0&&(e.lowestObserverState_=0)}))}function fn(e){var t;e.lowestObserverState_===0&&(e.lowestObserverState_=1,(t=e.observers_)==null||t.forEach(e=>{e.dependenciesState_===0&&(e.dependenciesState_=1,e.onBecomeStale_())}))}var pn=class{constructor(e=`Reaction@`+u(),t,n,r){this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=-1,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.removeAbortListener_=void 0,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}get isDisposed(){return D(this.flags_,1)}set isDisposed(e){this.flags_=O(this.flags_,1,e)}get isScheduled(){return D(this.flags_,2)}set isScheduled(e){this.flags_=O(this.flags_,2,e)}get isTrackPending(){return D(this.flags_,4)}set isTrackPending(e){this.flags_=O(this.flags_,4,e)}get isRunning(){return D(this.flags_,8)}set isRunning(e){this.flags_=O(this.flags_,8,e)}get diffValue(){return+!!D(this.flags_,16)}set diffValue(e){this.flags_=O(this.flags_,16,e===1)}onBecomeStale_(){this.schedule_()}schedule_(){this.isScheduled||(this.isScheduled=!0,M.pendingReactions.push(this),gn())}runReaction_(){if(!this.isDisposed){an(),this.isScheduled=!1;let e=M.trackingContext;if(M.trackingContext=this,Nt(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&bn()&&xn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}M.trackingContext=e,on()}}track(e){if(this.isDisposed)return;an();let t=bn(),n;t&&(n=Date.now(),Sn({name:this.name_,type:`reaction`})),this.isRunning=!0;let r=M.trackingContext;M.trackingContext=this;let i=Lt(this,e,void 0);M.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Bt(this),Mt(i)&&this.reportExceptionInDerivation_(i.cause),t&&wn({time:Date.now()-n}),on()}reportExceptionInDerivation_(e){if(this.errorHandler_){this.errorHandler_(e,this);return}if(M.disableErrorBoundaries)throw e;let t=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`;M.suppressReactionErrors?console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`):console.error(t,e),bn()&&xn({type:`error`,name:this.name_,message:t,error:``+e}),M.globalReactionErrorHandlers.forEach(t=>t(e,this))}dispose(){if(!this.isDisposed){var e;this.isDisposed=!0,(e=this.removeAbortListener_)==null||e.call(this),this.isRunning||(an(),Bt(this),on())}}getDisposer_(e){let t=()=>this.dispose();return e!=null&&e.addEventListener&&!this.isDisposed&&(e.addEventListener(`abort`,t),this.removeAbortListener_=()=>e.removeEventListener==null?void 0:e.removeEventListener(`abort`,t)),t[k]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(t[Symbol.dispose]=t),t}toString(){return`Reaction[${this.name_}]`}};function mn(e){return M.globalReactionErrorHandlers.push(e),()=>{let t=M.globalReactionErrorHandlers.indexOf(e);t>=0&&M.globalReactionErrorHandlers.splice(t,1)}}let hn=e=>e();function gn(){M.inBatch>0||M.isRunningReactions||hn(_n)}function _n(){M.isRunningReactions=!0;let e=M.pendingReactions,t=0;for(;e.length>0;){++t===100&&(console.error(`Reaction doesn't converge to a stable state after 100 iterations. Probably there is a cycle in the reactive function: ${e[0]}`),e.splice(0));let n=e.splice(0);for(let e=0,t=n.length;e<t;e++)n[e].runReaction_()}M.isRunningReactions=!1}let vn=b(`Reaction`,pn);function yn(e){let t=hn;hn=n=>e(()=>t(n))}function bn(){return!!M.spyListeners.length}function xn(e){if(!M.spyListeners.length)return;let t=M.spyListeners;for(let n=0,r=t.length;n<r;n++)t[n](e)}function Sn(e){xn(r({},e,{spyReportStart:!0}))}let Cn={type:`report-end`,spyReportEnd:!0};function wn(e){xn(e?r({},e,{type:`report-end`,spyReportEnd:!0}):Cn)}function Tn(e){return M.spyListeners.push(e),d(()=>{M.spyListeners=M.spyListeners.filter(t=>t!==e)})}let N=`action`,En=`autoAction`,Dn=`<unnamed action>`,On=be(N),kn=be(`action.bound`,{bound:!0}),An=be(En,{autoAction:!0}),jn=be(`autoAction.bound`,{autoAction:!0,bound:!0});function Mn(e){return qe(e,Ce)}function Nn(e){return function(t,r){if(r&&typeof r.kind==`string`)return Ce(e?An:On,t,r);if(p(t))return bt(t.name||Dn,t,e);if(p(r))return bt(t,r,e);if(m(t))return Mn(be(e?En:N,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}let Pn=Nn(!1);r(Pn,On);let Fn=Nn(!0);r(Fn,An);let In=Mn(kn),Ln=Mn(jn);function Rn(e){return xt(e.name||Dn,!1,e,this,void 0)}function zn(e){return p(e)&&e.isMobxAction===!0}function Bn(e,t=c){var r;p(e)||n(`Autorun expects a function as first argument`),zn(e)&&n(`Autorun does not accept actions since actions are untrackable`);let i=t?.name??(e.name||`Autorun@`+u()),a=!t.scheduler&&!t.delay,o;if(a)o=new pn(i,function(){this.track(s)},t.onError,t.requiresObservable);else{let e=Hn(t),n=!1;o=new pn(i,()=>{n||(n=!0,e(()=>{n=!1,o.isDisposed||o.track(s)}))},t.onError,t.requiresObservable)}function s(){e(o)}return t!=null&&(r=t.signal)!=null&&r.aborted||o.schedule_(),o.getDisposer_(t?.signal)}let Vn=e=>e();function Hn(e){return e.scheduler?e.scheduler:e.delay?t=>setTimeout(t,e.delay):Vn}function Un(e,t,r=c){var i;(!p(e)||!p(t))&&n(`First and second argument to reaction should be functions`),g(r)||n(`Third argument of reactions should be an object`);let a=r.name??`Reaction@`+u(),o=Pn(a,r.onError?Wn(r.onError,t):t),s=!r.scheduler&&!r.delay,l=Hn(r),d=!0,f=!1,m,h=r.equals||ue,_=new pn(a,()=>{d||s?v():f||(f=!0,l(v))},r.onError,r.requiresObservable);function v(){if(f=!1,_.isDisposed)return;let t=!1,n=m;_.track(()=>{let n=wt(!1,()=>e(_));t=d||!h(m,n),m=n}),(d&&r.fireImmediately||!d&&t)&&o(m,n,_),d=!1}return r!=null&&(i=r.signal)!=null&&i.aborted||_.schedule_(),_.getDisposer_(r?.signal)}function Wn(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}function Gn(e,t,n){return qn(`onBO`,e,t,n)}function Kn(e,t,n){return qn(`onBUO`,e,t,n)}function qn(e,t,n,r){let i=typeof r==`function`?Ni(t,n):Ni(t),a=p(r)?r:n,o=`${e}L`;return i[o]?i[o].add(a):i[o]=new Set([a]),function(){let e=i[o];e&&(e.delete(a),e.size===0&&delete i[o])}}let Jn=`always`;function Yn(e){e.isolateGlobalState===!0&&Xt();let{enforceActions:t}=e;if(t!==void 0){let e=t===Jn?Jn:t===`observed`;M.enforceActions=e,M.allowStateChanges=!(e===!0||e===Jn)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(t=>{t in e&&(M[t]=!!e[t])}),M.allowStateReads=!M.observableRequiresReaction,M.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&yn(e.reactionScheduler)}function Xn(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),_i(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),g(t)||n(`'extendObservable' only accepts plain objects as second argument`),(xr(t)||xr(r))&&n(`Extending an object with another observable (object) is not supported`);let a=ne(t);return Fi(()=>{let t=Di(e,i)[k];T(a).forEach(e=>{t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Zn(e,t){return Qn(Ni(e,t))}function Qn(e){let t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=tr(e.observing_).map(Qn)),t}function $n(e,t){return er(Ni(e,t))}function er(e){let t={name:e.name_};return $t(e)&&(t.observers=Array.from(en(e),er)),t}function tr(e){return Array.from(new Set(e))}let nr=0;var rr=class extends Error{constructor(){super(`FLOW_CANCELLED`),Object.setPrototypeOf(this,new.target.prototype),this.name=`FlowCancellationError`}toString(){return`Error: ${this.message}`}};function ir(e){return e instanceof rr}function ar(e){return qe(e,ke)}let or=Ee(`flow`),sr=Ee(`flow.bound`,{bound:!0}),cr=r(function(e,t){if(t&&typeof t.kind==`string`)return ke(or,e,t);arguments.length!==1&&n(`Flow expects single argument with generator function`);let r=e,i=r.name||`<unnamed flow>`,a=function(){let e=this,t=arguments,n=++nr,a=Pn(`${i} - runid: ${n} - init`,r).apply(e,t),o,s,c=new Promise(function(e,t){let r=0;o=t;function c(e){s=void 0;let o;try{o=Pn(`${i} - runid: ${n} - yield ${r++}`,a.next).call(a,e)}catch(e){return t(e)}u(o)}function l(e){s=void 0;let o;try{o=Pn(`${i} - runid: ${n} - yield ${r++}`,a.throw).call(a,e)}catch(e){return t(e)}u(o)}function u(n){if(p(n?.then)){n.then(u,t);return}return n.done?e(n.value):(s=Promise.resolve(n.value),s.then(c,l))}c(void 0)});return c.cancel=Pn(`${i} - runid: ${n} - cancel`,function(){try{s&&ur(s);let e=a.return(void 0),t=Promise.resolve(e.value);t.then(f,f),ur(t),o(new rr)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},or),lr=ar(sr);function ur(e){p(e.cancel)&&e.cancel()}function dr(e){return e}function fr(e){return e?.isMobXFlow===!0}function pr(e,t,r){let i;if(_i(e)||pi(e)||Ot(e))i=Pi(e);else if(Ai(e)){if(!m(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=Pi(e,t)}else return n(`Expected observable map, object or array as first array`);return i.dehancer===void 0?(i.dehancer=typeof t==`function`?t:r,()=>{i.dehancer=void 0}):n(`An intercept reader was already established`)}function mr(e,t,n){return p(n)?gr(e,t,n):hr(e,t)}function hr(e,t){return qr(Pi(e),t)}function gr(e,t,n){return qr(Pi(e,t),n)}function _r(e,t){var n;if(t===void 0)return At(e);if(Ai(e)===!1)return!1;let r=e[k];return(n=r.lazyComputedKeys_)!=null&&n.has(t)?!0:r.values_.has(t)?At(Ni(e,t)):!1}function vr(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):_r(e)}function yr(e,t){return m(t)?_r(e,t):n(`isComputed expected a property name as second argument`)}function br(e,t){if(!e)return!1;if(t!==void 0){if(_i(e)||pi(e))return n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`);if(Ai(e)){var r,i;let n=e[k];return n.values_.has(t)||!!((r=n.lazyComputedKeys_)!=null&&r.has(t))||!!((i=n.lazyObservableKeys_)!=null&&i.has(t))}return!1}return Ai(e)||!!e[k]||ae(e)||vn(e)||At(e)}function xr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),br(e)}function Sr(e,t){return m(t)?br(e,t):n(`expected a property name as second argument`)}function Cr(e){if(Ai(e))return e[k].keys_();if(_i(e)||Si(e))return Array.from(e.keys());if(pi(e))return e.map((e,t)=>t);n(5)}function wr(e){if(Ai(e))return Cr(e).map(t=>e[t]);if(_i(e))return Cr(e).map(t=>e.get(t));if(Si(e))return Array.from(e.values());if(pi(e))return e.slice();n(6)}function Tr(e){if(Ai(e))return Cr(e).map(t=>[t,e[t]]);if(_i(e))return Cr(e).map(t=>[t,e.get(t)]);if(Si(e))return Array.from(e.entries());if(pi(e))return e.map((e,t)=>[t,e]);n(7)}function Er(e,t,r){if(arguments.length===2&&!Si(e)){an();let n=t;try{for(let t in n)Er(e,t,n[t])}finally{on()}return}Ai(e)?e[k].set_(t,r):_i(e)?e.set(t,r):Si(e)?e.add(t):pi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(42,t),an(),t>=e.length&&(e.length=t+1),e[t]=r,on()):n(8)}function Dr(e,t){Ai(e)?e[k].delete_(t):_i(e)||Si(e)?e.delete(t):pi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function Or(e,t){if(Ai(e))return e[k].has_(t);if(_i(e)||Si(e))return e.has(t);if(pi(e))return t>=0&&t<e.length;n(10)}function kr(e,t){if(Or(e,t)){if(Ai(e))return e[k].get_(t);if(_i(e))return e.get(t);if(pi(e))return e[t];n(11)}}function Ar(e,t,r){if(Ai(e))return e[k].defineProperty_(t,r);n(39)}function jr(e){if(Ai(e))return e[k].ownKeys_();n(38)}function Mr(e,t,n,r){return p(n)?Pr(e,t,n,r):Nr(e,t,n)}function Nr(e,t,r){let i=Pi(e);if(pi(e))r&&t({observableKind:`array`,object:i.proxy_,debugObjectName:i.atom_.name_,type:`splice`,index:0,added:i.values_.slice(),addedCount:i.values_.length,removed:[],removedCount:0});else if(_i(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps.");else if(Si(e))r===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets.");else if(Ai(e))r===!0&&n("`observe` doesn't support the fire immediately property for observable objects.");else return Fr(i,t,r);return Xr(i,t)}function Pr(e,t,n,r){return Fr(Pi(e,t),n,r)}function Fr(e,t,n){if(At(e)){let r=!0,i;return Bn(()=>{let a=e.get();if(!r||n){let n=Ht();t({observableKind:`computed`,debugObjectName:e.name_,type:ri,object:e,newValue:a,oldValue:i}),Ut(n)}r=!1,i=a})}return n&&t({observableKind:`value`,debugObjectName:e.name_,object:e,type:ri,newValue:e.value_,oldValue:void 0}),Xr(e,t)}function Ir(e,t,n){return e.set(t,n),n}function Lr(e,t){if(typeof e!=`object`||!e||e instanceof Date||!xr(e))return e;if(Ot(e)||At(e))return Lr(e.get(),t);if(t.has(e))return t.get(e);if(pi(e)){let n=Ir(t,e,Array(e.length));return e.forEach((e,r)=>{n[r]=Lr(e,t)}),n}if(Si(e)){let n=Ir(t,e,new Set);return e.forEach(e=>{n.add(Lr(e,t))}),n}if(_i(e)){let n=Ir(t,e,new Map);return e.forEach((e,r)=>{n.set(r,Lr(e,t))}),n}else{let n=Ir(t,e,{});return jr(e).forEach(r=>{o.propertyIsEnumerable.call(e,r)&&(n[r]=Lr(e[r],t))}),n}}function Rr(e,t){return t&&n(`toJS no longer supports options`),Lr(e,new Map)}function zr(e,t=void 0){an();try{return e.apply(t)}finally{on()}}function Br(e,t,n){return arguments.length===1||t&&typeof t==`object`?Hr(e,t):Vr(e,t,n||{})}function Vr(e,t,n){let r;if(typeof n.timeout==`number`){let e=Error(`WHEN_TIMEOUT`);r=setTimeout(()=>{if(!a[k].isDisposed)if(a(),n.onError)n.onError(e);else throw e},n.timeout)}n.name=n.name||`When@`+u();let i=bt(n.name+`-effect`,t);var a=Bn(t=>{wt(!1,e)&&(t.dispose(),r&&clearTimeout(r),i())},n);return a}function Hr(e,t){var i;if(t&&t.onError)return n(`the options 'onError' and 'promise' cannot be combined`);if(t!=null&&(i=t.signal)!=null&&i.aborted)return r(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:()=>null});let a,o,s=new Promise((n,i)=>{var s;let c=Vr(e,n,r({},t,{onError:i}));a=()=>{c(),i(Error(`WHEN_CANCELLED`))},o=()=>{c(),i(Error(`WHEN_ABORTED`))},t==null||(s=t.signal)==null||s.addEventListener==null||s.addEventListener(`abort`,o)}).finally(()=>{var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,o)});return s.cancel=a,s}function Ur(e){return e[k]}let Wr={has(e,t){return Ur(e).has_(t)},get(e,t){return Ur(e).get_(t)},set(e,t,n){return m(t)?Ur(e).set_(t,n,!0)??!0:!1},deleteProperty(e,t){return m(t)?Ur(e).delete_(t,!0)??!0:!1},defineProperty(e,t,n){return Ur(e).defineProperty_(t,n)??!0},ownKeys(e){return Ur(e).ownKeys_()},preventExtensions(e){n(13)}};function Gr(e,t){var n;return e=Di(e,t),(n=e[k]).proxy_??(n.proxy_=new Proxy(e,Wr))}function Kr(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function qr(e,t){let n=e.interceptors_;return n?n.push(t):n=e.interceptors_=[t],d(()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function Jr(e,t){let r=Ht();try{let r=[...e.interceptors_||[]];for(let e=0,i=r.length;e<i&&(t=r[e](t),t&&!t.type&&n(14),t);e++);return t}finally{Ut(r)}}function Yr(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function Xr(e,t){let n=e.changeListeners_;return n?n.push(t):n=e.changeListeners_=[t],d(()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function Zr(e,t){let n=Ht(),r=e.changeListeners_;if(r){r=r.slice();for(let e=0,n=r.length;e<n;e++)r[e](t);Ut(n)}}function Qr(e,t,n){return Fi(()=>{let r=Di(e,n)[k];T(t).forEach(e=>ti(r,e,t[e]))}),e}let $r=Symbol(`mobx-keys`);function ei(e,t,r){return!g(e)&&!g(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),Ai(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),g(e)?Xn(e,e,t,r):(Fi(()=>{let n=Di(e,r)[k];if(!e[$r]){let t=Object.getPrototypeOf(e),n=new Set([...T(e),...T(t)]);n.delete(`constructor`),n.delete(k),v(t,$r,n)}e[$r].forEach(e=>ti(n,e,t&&e in t?t[e]:!0))}),e)}function ti(e,t,r){if(r===!0&&(r=e.defaultAnnotation_),r===!1)return;Mi(e,r,t),t in e.target_||n(1,r.annotationType_,`${e.name_}.${t.toString()}`);let a=e.target_;for(;a&&a!==o;){let n=i(a,t);if(n){let i=r.make_(e,t,n,a);if(i===0)return;if(i===1)break}a=Object.getPrototypeOf(a)}ji(e,r,t)}let ni=`splice`,ri=`update`,ii={get(e,t){let n=e[k];return t===k?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):E(si,t)?si[t]:e[t]},set(e,t,n){let r=e[k];return t===`length`?r.setArrayLength_(n):typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions(){n(15)}};var ai=class{constructor(e=`ObservableArray@`+u(),t,n){this.owned_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=n,this.atom_=new ie(e),this.enhancer_=(n,r)=>t(n,r,e+`[..]`)}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}dehanceValues_(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e}getArrayLength_(){return this.atom_.reportObserved(),this.values_.length}setArrayLength_(e){(!Number.isInteger(e)||e<0)&&n(40,e);let t=this.values_.length;if(e!==t)if(e>t){let n=Array.from({length:e-t});this.spliceWithArray_(t,0,n)}else this.spliceWithArray_(e,t-e)}updateArrayLength_(e,t){e!==this.lastKnownLength_&&n(16),this.lastKnownLength_+=t}spliceWithArray_(e,t,n){Ft(this.atom_);let r=this.values_.length;if(e===void 0?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=arguments.length===1?r-e:t==null?0:Math.max(0,Math.min(t,r-e)),n===void 0&&(n=s),Kr(this)){let r=Jr(this,{object:this.proxy_,type:ni,index:e,removedCount:t,added:n});if(!r)return s;t=r.removedCount,n=r.added}n=n.length===0?n:n.map(e=>this.enhancer_(e,void 0));{let e=n.length-t;this.updateArrayLength_(r,e)}let i=this.spliceItemsIntoValues_(e,t,n);return(t!==0||n.length!==0)&&this.notifyArraySplice_(e,n,i),this.dehanceValues_(i)}spliceItemsIntoValues_(e,t,n){if(n.length<1e4)return this.values_.splice(e,t,...n);{let r=this.values_.slice(e,e+t),i=this.values_.slice(e+t);this.values_.length+=n.length-t;for(let t=0;t<n.length;t++)this.values_[e+t]=n[t];for(let t=0;t<i.length;t++)this.values_[e+n.length+t]=i[t];return r}}notifyArrayChildUpdate_(e,t,n){let r=!this.owned_&&bn(),i=Yr(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:ri,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&Sn(a),this.atom_.reportChanged(),i&&Zr(this,a),r&&wn()}notifyArraySplice_(e,t,n){let r=!this.owned_&&bn(),i=Yr(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:ni,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&Sn(a),this.atom_.reportChanged(),i&&Zr(this,a),r&&wn()}get_(e){return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])}set_(e,t){let n=this.values_;if(e<n.length){Ft(this.atom_);let r=n[e];if(Kr(this)){let n=Jr(this,{type:ri,object:this.proxy_,index:e,newValue:t});if(!n)return;t=n.newValue}t=this.enhancer_(t,r),t!==r&&(n[e]=t,this.notifyArrayChildUpdate_(e,t,r))}else{let r=Array.from({length:e+1-n.length});r[r.length-1]=t,this.spliceWithArray_(n.length,0,r)}}};function oi(e,t,n=`ObservableArray@`+u(),r=!1){return Fi(()=>{let i=new ai(n,t,r);y(i.values_,k,i);let a=new Proxy(i.values_,ii);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var si={clear(){return this.splice(0)},replace(e){let t=this[k];return t.spliceWithArray_(0,t.values_.length,e)},toJSON(){return this.slice()},splice(e,t,...n){let r=this[k];switch(arguments.length){case 0:return[];case 1:return r.spliceWithArray_(e);case 2:return r.spliceWithArray_(e,t)}return r.spliceWithArray_(e,t,n)},spliceWithArray(e,t,n){return this[k].spliceWithArray_(e,t,n)},push(...e){let t=this[k];return t.spliceWithArray_(t.values_.length,0,e),t.values_.length},pop(){return this.splice(Math.max(this[k].values_.length-1,0),1)[0]},shift(){return this.splice(0,1)[0]},unshift(...e){let t=this[k];return t.spliceWithArray_(0,0,e),t.values_.length},reverse(){return M.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort(){M.trackingDerivation&&n(37,`sort`);let e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove(e){let t=this[k],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};ci(`at`,li),ci(`concat`,li),ci(`flat`,li),ci(`includes`,li),ci(`indexOf`,li),ci(`join`,li),ci(`lastIndexOf`,li),ci(`slice`,li),ci(`toString`,li),ci(`toLocaleString`,li),ci(`toSorted`,li),ci(`toSpliced`,li),ci(`with`,li),ci(`every`,ui),ci(`filter`,ui),ci(`find`,ui),ci(`findIndex`,ui),ci(`findLast`,ui),ci(`findLastIndex`,ui),ci(`flatMap`,ui),ci(`forEach`,ui),ci(`map`,ui),ci(`some`,ui),ci(`toReversed`,ui),ci(`reduce`,di),ci(`reduceRight`,di);function ci(e,t){typeof Array.prototype[e]==`function`&&(si[e]=t(e))}function li(e){return function(){let t=this[k];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function ui(e){return function(t,n){let r=this[k];return r.atom_.reportObserved(),r.dehanceValues_(r.values_)[e]((e,r)=>t.call(n,e,r,this))}}function di(e){return function(){let t=this[k];t.atom_.reportObserved();let n=t.dehanceValues_(t.values_),r=arguments[0];return arguments[0]=(e,t,n)=>r(e,t,n,this),n[e].apply(n,arguments)}}let fi=b(`ObservableArrayAdministration`,ai);function pi(e){return h(e)&&fi(e[k])}let mi={},hi=`delete`;var gi=class{constructor(e,t=de,n=`ObservableMap@`+u()){this.enhancer_=void 0,this.name_=void 0,this[k]=mi,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,Fi(()=>{this.keysAtom_=oe(`${this.name_}.keys()`),this.data_=new Map,this.hasMap_=new Map,e&&this.merge(e)})}has_(e){return this.data_.has(e)}has(e){if(!M.trackingDerivation)return this.has_(e);let t=this.hasMap_.get(e);if(!t){let n=t=new Dt(this.has_(e),pe,`${this.name_}.${ee(e)}?`,!1);this.hasMap_.set(e,n),n.onBUOL=new Set([()=>this.hasMap_.delete(e)])}return t.get()}set(e,t){let n=this.has_(e);if(Kr(this)){let r=Jr(this,{type:n?ri:`add`,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this}delete(e){if(Ft(this.keysAtom_),Kr(this)&&!Jr(this,{type:hi,object:this,name:e}))return!1;if(this.has_(e)){let t=bn(),n=Yr(this),r=n||t?{observableKind:`map`,debugObjectName:this.name_,type:hi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return t&&Sn(r),zr(()=>{var t;this.keysAtom_.reportChanged(),(t=this.hasMap_.get(e))==null||t.setNewValue_(!1),this.data_.get(e).setNewValue_(void 0),this.data_.delete(e)}),n&&Zr(this,r),t&&wn(),!0}return!1}updateValue_(e,t){let n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==M.UNCHANGED){let r=bn(),i=Yr(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:ri,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&Sn(a),n.setNewValue_(t),i&&Zr(this,a),r&&wn()}}addValue_(e,t){Ft(this.keysAtom_),zr(()=>{var n;let r=new Dt(t,this.enhancer_,`${this.name_}.${ee(e)}`,!1);this.data_.set(e,r),t=r.value_,(n=this.hasMap_.get(e))==null||n.setNewValue_(!0),this.keysAtom_.reportChanged()});let n=bn(),r=Yr(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:`add`,object:this,name:e,newValue:t}:null;n&&Sn(i),r&&Zr(this,i),n&&wn()}get(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)}getOrInsert(e,t){return this.has(e)||this.set(e,t),this.get(e)}getOrInsertComputed(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}keys(){return this.keysAtom_.reportObserved(),this.data_.keys()}values(){let e=this,t=this.keys();return vi({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e.get(r)}}})}entries(){let e=this,t=this.keys();return vi({next(){let{done:n,value:r}=t.next();return{done:n,value:n?void 0:[r,e.get(r)]}}})}[Symbol.iterator](){return this.entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}merge(e){return _i(e)&&(e=new Map(e)),zr(()=>{g(e)?w(e).forEach(t=>this.set(t,e[t])):Array.isArray(e)?e.forEach(([e,t])=>this.set(e,t)):x(e)?(S(e)||n(19,e),e.forEach((e,t)=>this.set(t,e))):e!=null&&n(20,e)}),this}clear(){zr(()=>{Vt(()=>{for(let e of this.keys())this.delete(e)})})}replace(e){return zr(()=>{let t=yi(e),n=new Map,r=!1;for(let e of this.data_.keys())if(!t.has(e))if(this.delete(e))r=!0;else{let t=this.data_.get(e);n.set(e,t)}for(let[e,i]of t.entries()){let t=this.data_.has(e);if(this.set(e,i),this.data_.has(e)){let i=this.data_.get(e);n.set(e,i),t||(r=!0)}}if(!r)if(this.data_.size!==n.size)this.keysAtom_.reportChanged();else{let e=this.data_.keys(),t=n.keys(),r=e.next(),i=t.next();for(;!r.done;){if(r.value!==i.value){this.keysAtom_.reportChanged();break}r=e.next(),i=t.next()}}this.data_=n}),this}get size(){return this.keysAtom_.reportObserved(),this.data_.size}toString(){return`[object ObservableMap]`}toJSON(){return Array.from(this)}get[Symbol.toStringTag](){return`Map`}},_i=b(`ObservableMap`,gi);function vi(e){return e[Symbol.toStringTag]=`MapIterator`,Vi(e)}function yi(e){if(x(e)||_i(e))return e;if(Array.isArray(e))return new Map(e);if(g(e)){let t=new Map;for(let n in e)t.set(n,e[n]);return t}else return n(21,e)}let bi={};var xi=class{constructor(e,t=de,n=`ObservableSet@`+u()){this.name_=void 0,this[k]=bi,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=n,this.enhancer_=(e,r)=>t(e,r,n),Fi(()=>{this.atom_=oe(this.name_),e&&this.replace(e)})}dehanceValue_(e){return this.dehancer===void 0?e:this.dehancer(e)}clear(){zr(()=>{Vt(()=>{for(let e of this.data_.values())this.delete(e)})})}forEach(e,t){for(let n of this)e.call(t,n,n,this)}get size(){return this.atom_.reportObserved(),this.data_.size}add(e){if(Ft(this.atom_),Kr(this)){let t=Jr(this,{type:`add`,object:this,newValue:e});if(!t)return this;e=t.newValue}if(!this.has(e)){zr(()=>{e=this.enhancer_(e,void 0),this.data_.add(e),this.atom_.reportChanged()});let t=bn(),n=Yr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:`add`,object:this,newValue:e}:null;t&&Sn(r),n&&Zr(this,r),t&&wn()}return this}delete(e){if(Kr(this)&&!Jr(this,{type:hi,object:this,oldValue:e}))return!1;if(this.has(e)){let t=bn(),n=Yr(this),r=n||t?{observableKind:`set`,debugObjectName:this.name_,type:hi,object:this,oldValue:e}:null;return t&&Sn(r),zr(()=>{this.atom_.reportChanged(),this.data_.delete(e)}),n&&Zr(this,r),t&&wn(),!0}return!1}has(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))}entries(){let e=this.values();return Ci({next(){let{value:t,done:n}=e.next();return n?{value:void 0,done:n}:{value:[t,t],done:n}}})}keys(){return this.values()}values(){this.atom_.reportObserved();let e=this,t=this.data_.values();return Ci({next(){let{value:n,done:r}=t.next();return r?{value:void 0,done:r}:{value:e.dehanceValue_(n),done:r}}})}intersection(e){return new Set(this).intersection(e)}union(e){return new Set(this).union(e)}difference(e){return new Set(this).difference(e)}symmetricDifference(e){return new Set(this).symmetricDifference(e)}isSubsetOf(e){return new Set(this).isSubsetOf(e)}isSupersetOf(e){return new Set(this).isSupersetOf(e)}isDisjointFrom(e){return new Set(this).isDisjointFrom(e)}replace(e){return Si(e)&&(e=new Set(e)),Array.isArray(e)||C(e)?zr(()=>{let t=C(e)?e:new Set(e);if(t.size===0){this.clear();return}if(this.data_.size===0){t.forEach(e=>this.add(e));return}for(let e of this.data_.values())t.has(this.dehanceValue_(e))||this.delete(e);t.forEach(e=>this.add(e))}):e!=null&&n(41,e),this}toJSON(){return Array.from(this)}toString(){return`[object ObservableSet]`}[Symbol.iterator](){return this.values()}get[Symbol.toStringTag](){return`Set`}},Si=b(`ObservableSet`,xi);function Ci(e){return e[Symbol.toStringTag]=`SetIterator`,Vi(e)}let wi=Object.create(null),Ti=`remove`;var Ei=class{constructor(e,t=new Map,r,i=Ve){this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.lazyComputedKeys_=void 0,this.lazyObservableKeys_=void 0,this.target_=e,this.values_=t,this.name_=r,this.defaultAnnotation_=i,this.keysAtom_=new ie(`${this.name_}.keys`),this.isPlainObject_=g(this.target_),Ui(this.defaultAnnotation_)||n(`defaultAnnotation must be valid annotation`),this.appliedAnnotations_={}}getObservablePropValue_(e){return(this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e)).get()}materializeLazyComputed_(e){let t=this.lazyComputedKeys_?.get(e);if(!t)return;this.lazyComputedKeys_.delete(e),this.lazyComputedKeys_.size===0&&(this.lazyComputedKeys_=void 0);let n=t();return this.values_.set(e,n),n}materializeLazyObservable_(e){let t=this.lazyObservableKeys_?.get(e);if(!t)return;this.lazyObservableKeys_.delete(e),this.lazyObservableKeys_.size===0&&(this.lazyObservableKeys_=void 0);let n=t();return this.values_.set(e,n),n}setObservablePropValue_(e,t){let n=this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e);if(n instanceof kt)return n.set(t),!0;if(Kr(this)){let n=Jr(this,{type:ri,object:this.proxy_||this.target_,name:e,newValue:t});if(!n)return null;t=n.newValue}if(t=n.prepareNewValue_(t),t!==M.UNCHANGED){let r=Yr(this),i=bn(),a=r||i?{type:ri,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;i&&Sn(a),n.setNewValue_(t),r&&Zr(this,a),i&&wn()}return!0}get_(e){return M.trackingDerivation&&!E(this.target_,e)&&this.has_(e),this.target_[e]}set_(e,t,n=!1){return E(this.target_,e)?this.values_.has(e)?this.setObservablePropValue_(e,t):n?Reflect.set(this.target_,e,t):(this.target_[e]=t,!0):this.extend_(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,n)}has_(e){if(!M.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;let t=this.pendingKeys_.get(e);return t||(t=new Dt(e in this.target_,pe,`${this.name_}.${ee(e)}?`,!1),this.pendingKeys_.set(e,t)),t.get()}extend_(e,t,n,r=!1){if(n===!0&&(n=this.defaultAnnotation_),n===!1)return this.defineProperty_(e,t,r);Mi(this,n,e);let i=n.extend_(this,e,t,r);return i&&ji(this,n,e),i}defineProperty_(e,t,n=!1){Ft(this.keysAtom_);try{an();let i=this.delete_(e);if(!i)return i;if(Kr(this)){let n=Jr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t.value});if(!n)return null;let{newValue:i}=n;t.value!==i&&(t=r({},t,{value:i}))}if(n){if(!Reflect.defineProperty(this.target_,e,t))return!1}else a(this.target_,e,t);this.notifyPropertyAddition_(e,t.value)}finally{on()}return!0}defineObservableProperty_(e,t,n,r=!1){Ft(this.keysAtom_);try{an();let i=this.delete_(e);if(!i)return i;if(Kr(this)){let n=Jr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:t});if(!n)return null;t=n.newValue}let o=ki(e),s={configurable:M.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.target_,e,s))return!1}else a(this.target_,e,s);let c=new Dt(t,n,`${this.name_}.${e.toString()}`,!1);this.values_.set(e,c),this.notifyPropertyAddition_(e,c.value_)}finally{on()}return!0}defineComputedProperty_(e,t,n=!1){Ft(this.keysAtom_);try{an();let r=this.delete_(e);if(!r)return r;if(Kr(this)&&!Jr(this,{object:this.proxy_||this.target_,name:e,type:`add`,newValue:void 0}))return null;t.name||=`${this.name_}.${e.toString()}`,t.context=this.proxy_||this.target_;let i=ki(e),o={configurable:M.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.target_,e,o))return!1}else a(this.target_,e,o);this.values_.set(e,new kt(t)),this.notifyPropertyAddition_(e,void 0)}finally{on()}return!0}delete_(e,t=!1){if(Ft(this.keysAtom_),!E(this.target_,e))return!0;if(Kr(this)&&!Jr(this,{object:this.proxy_||this.target_,name:e,type:Ti}))return null;try{var n;an();let r=Yr(this),a=bn(),o=this.values_.get(e),s;if(!o&&(r||a)&&(s=i(this.target_,e)?.value),t){if(!Reflect.deleteProperty(this.target_,e))return!1}else delete this.target_[e];if(delete this.appliedAnnotations_[e],o&&(this.values_.delete(e),o instanceof Dt&&(s=o.value_),un(o)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||a){let t={type:Ti,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};a&&Sn(t),r&&Zr(this,t),a&&wn()}}finally{on()}return!0}notifyPropertyAddition_(e,t){var n;let r=Yr(this),i=bn();if(r||i){let n=r||i?{type:`add`,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,name:e,newValue:t}:null;i&&Sn(n),r&&Zr(this,n),i&&wn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()}ownKeys_(){return this.keysAtom_.reportObserved(),T(this.target_)}keys_(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)}};function Di(e,t){if(t&&Ai(e)&&n(`Options can't be provided for already observable objects.`),E(e,k))return Pi(e)instanceof Ei||n(`Cannot convert '${P(e)}' into observable object:\nThe target is already observable of different type.\nExtending builtins is not supported.`),e;Object.isExtensible(e)||n(`Cannot make the designated object observable; it is not extensible`);let r=t?.name??`${g(e)?`ObservableObject`:e.constructor.name}@${u()}`;return v(e,k,new Ei(e,new Map,String(r),nt(t))),e}let Oi=b(`ObservableObjectAdministration`,Ei);function ki(e){return wi[e]||(wi[e]={get(){return this[k].getObservablePropValue_(e)},set(t){return this[k].setObservablePropValue_(e,t)}})}function Ai(e){return h(e)?Oi(e[k]):!1}function ji(e,t,n){e.appliedAnnotations_[n]=t}function Mi(e,t,r){if(Ui(t)||n(`Cannot annotate '${e.name_}.${r.toString()}': Invalid annotation.`),!_e(t)&&E(e.appliedAnnotations_,r)){let i=`${e.name_}.${r.toString()}`,a=e.appliedAnnotations_[r].annotationType_,o=t.annotationType_;n(`Cannot apply '${o}' to '${i}':\nThe field is already annotated with '${a}'.\nRe-annotating fields is not allowed.\nUse 'override' annotation for methods overridden by subclass.`)}}function Ni(e,t){if(typeof e==`object`&&e){if(pi(e))return t!==void 0&&n(23),e[k].atom_;if(Si(e))return e.atom_;if(_i(e)){if(t===void 0)return e.keysAtom_;let r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,P(e)),r}if(Ai(e)){if(!t)return n(26);let r=e[k],i=r.values_.get(t)??r.materializeLazyComputed_(t)??r.materializeLazyObservable_(t);return i||n(27,t,P(e)),i}if(ae(e)||At(e)||vn(e))return e}else if(p(e)&&vn(e[k]))return e[k];n(28)}function Pi(e,t){if(e||n(29),t!==void 0)return Pi(Ni(e,t));if(ae(e)||At(e)||vn(e)||_i(e)||Si(e))return e;if(e[k])return e[k];n(24,e)}function P(e,t){let n;if(t!==void 0)n=Ni(e,t);else if(zn(e))return e.name;else n=Ai(e)||_i(e)||Si(e)?Pi(e):Ni(e);return n.name_}function Fi(e){let t=Ht(),n=Tt(!0);an();try{return e()}finally{on(),Et(n),Ut(t)}}let Ii=o.toString;function Li(e,t,n=-1){return Ri(e,t,n)}function Ri(e,t,n,r,i){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!==e)return t!==t;let a=typeof e;if(a!==`function`&&a!==`object`&&typeof t!=`object`)return!1;let o=Ii.call(e);if(o!==Ii.call(t))return!1;switch(o){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++;break}e=zi(e),t=zi(t);let s=o===`[object Array]`;if(!s){if(typeof e!=`object`||typeof t!=`object`)return!1;let n=e.constructor,r=t.constructor;if(n!==r&&!(p(n)&&n instanceof n&&p(r)&&r instanceof r)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),r||=[],i||=[];let c=r.length;for(;c--;)if(r[c]===e)return i[c]===t;if(r.push(e),i.push(t),s){if(c=e.length,c!==t.length)return!1;for(;c--;)if(!Ri(e[c],t[c],n-1,r,i))return!1}else{let a=Object.keys(e),o=a.length;if(Object.keys(t).length!==o)return!1;for(let s=0;s<o;s++){let o=a[s];if(!(E(t,o)&&Ri(e[o],t[o],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function zi(e){return pi(e)?e.slice():x(e)||_i(e)||C(e)||Si(e)?Array.from(e.entries()):e}let Bi=globalThis.Iterator?.prototype||{};function Vi(e){return e[Symbol.iterator]=Hi,r(Object.create(Bi),e)}function Hi(){return this}function Ui(e){return e instanceof Object&&typeof e.annotationType_==`string`&&p(e.make_)&&p(e.extend_)}{let e=globalThis;[`Symbol`,`Map`,`Set`,`Proxy`].forEach(t=>{e[t]===void 0&&n(`MobX requires global '${t}' to be available or polyfilled`)})}typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__==`object`&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:Tn,extras:{getDebugName:P},$mobx:k}),e.$mobx=k,e.FlowCancellationError=rr,e.ObservableMap=gi,e.ObservableSet=xi,e.Reaction=pn,e._allowStateChanges=wt,e._allowStateChangesInsideComputed=Rn,e._allowStateReadsEnd=Wt,e._allowStateReadsStart=j,e._autoAction=Fn,e._autoActionBound=Ln,e._endAction=Ct,e._getAdministration=Pi,e._getGlobalState=Zt,e._interceptReads=pr,e._isComputingDerivation=Pt,e._resetGlobalState=Qt,e._startAction=St,e.action=Pn,e.actionBound=In,e.autorun=Bn,e.compareDefault=ue,e.compareIdentity=se,e.compareShallow=le,e.compareStructural=ce,e.computed=ht,e.computedStruct=mt,e.configure=Yn,e.createAtom=oe,e.defineProperty=Ar,e.entries=Tr,e.extendObservable=Xn,e.flow=cr,e.flowBound=lr,e.flowResult=dr,e.get=kr,e.getAtom=Ni,e.getDebugName=P,e.getDependencyTree=Zn,e.getObserverTree=$n,e.has=Or,e.intercept=mr,e.isAction=zn,e.isBoxedObservable=Ot,e.isComputed=vr,e.isComputedProp=yr,e.isFlow=fr,e.isFlowCancellationError=ir,e.isObservable=xr,e.isObservableArray=pi,e.isObservableMap=_i,e.isObservableObject=Ai,e.isObservableProp=Sr,e.isObservableSet=Si,e.keys=Cr,e.makeAutoObservable=ei,e.makeObservable=Qr,e.observable=ut,e.observableDeep=ct,e.observableRef=ot,e.observableShallow=st,e.observableStruct=lt,e.observe=Mr,e.onBecomeObserved=Gn,e.onBecomeUnobserved=Kn,e.onReactionError=mn,e.override=ge,e.ownKeys=jr,e.reaction=Un,e.remove=Dr,e.runInAction=Rn,e.set=Er,e.spy=Tn,e.toJS=Rr,e.transaction=zr,e.untracked=Vt,e.values=wr,e.when=Br})),Y=Te(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=gC():t.exports=_C()}))();function vC(e){if(e===null)return!0;switch(typeof e){case`string`:case`boolean`:return!0;case`number`:return Number.isFinite(e);case`object`:{if(Array.isArray(e))return e.every(vC);let t=Object.getPrototypeOf(e);return(t===Object.prototype||t===null)&&Object.values(e).every(vC)}default:return!1}}function yC(e){if(Array.isArray(e))return Object.freeze(e.map(yC));if(typeof e==`object`&&e){let t=Object.create(null),n=Object.entries(e).sort(([e],[t])=>e<t?-1:+(e>t));for(let[e,r]of n)t[e]=yC(r);return Object.freeze(t)}return e}function bC(e){let t=typeof e;if(t===`string`||t===`number`||t===`boolean`)return t;throw TypeError(`Variable values must be string|number|boolean (got ${t})`)}function xC(e){return typeof e==`string`?e:String(e)}function SC(e){if(typeof e==`number`)return e;if(typeof e==`boolean`)return+!!e;let t=e.trim();if(t===``)throw TypeError(`Cannot cast empty string to number`);let n=Number(t);if(!Number.isFinite(n))throw TypeError(`Cannot cast ${JSON.stringify(e)} to number`);return n}function CC(e){if(typeof e==`boolean`)return e;if(typeof e==`number`){if(e===0||e===1)return e===1;throw TypeError(`Cannot cast number ${e} to bool (only 0 and 1 are accepted)`)}if(e===`true`)return!0;if(e===`false`)return!1;throw TypeError(`Cannot cast ${JSON.stringify(e)} to bool (expected "true" or "false")`)}var wC=class extends Error{constructor(e,t){super(t),this.variable=e}};function TC(e){return e instanceof wC?e:e instanceof Error&&e.cause!==void 0?TC(e.cause):void 0}const EC=e=>jo(e);var DC=class{kind=`box`;cell;lastChangedAt;constructor(e,t,n,r){this.name=e,this.type=t,this.clock=r,EC(n)||LC(e,t,n,`initial value`),this.cell=Y.observable.box(n,{deep:!1}),this.lastChangedAt=EC(n)?null:r.now()}read(){let e=this.cell.get();if(EC(e))throw new wC(this.name,`variable "${this.name}" has no value yet: nothing has written it`);return e}set(e){EC(e)||LC(this.name,this.type,e,`set value`),!(0,Y.compareStructural)(this.cell.get(),e)&&(this.cell.set(e),this.lastChangedAt=this.clock.now())}lastUpdatedMs(){return this.lastChangedAt}stored(){return this.cell.get()}},OC=class{cell;constructor(e,t,n){if(this.cell=(0,Y.computed)(t,{keepAlive:!0,...n!==void 0&&{equals:n}}),typeof this.cell.suspend_!=`function`)throw TypeError(`${e}: this MobX's computed has no suspend_; release() cannot unsubscribe it`);if(typeof this.cell.keepAlive_!=`boolean`)throw TypeError(`${e}: this MobX's computed has no keepAlive_ flag; release() cannot lift it`)}read(){return this.cell.get()}release(){this.cell.keepAlive_=!1,this.cell.suspend_()}},kC=class{constructor(e){this.deriver=e}read(){return this.deriver()}},AC=class{kind=`computed`;cell;constructor(e,t,n){this.name=e,this.type=t,this.cell=new OC(`Variable "${e}"`,()=>{let e=n();return LC(this.name,this.type,e,`computed result`),e})}read(){return this.cell.read()}release(){this.cell.release()}lastUpdatedMs(){return null}},jC=class{kind=`projection`;cell;constructor(e,t,n){this.name=e,this.type=t,this.cell=new kC(()=>{let e=n();return LC(this.name,this.type,e,`projection result`),e})}read(){return this.cell.read()}lastUpdatedMs(){return null}},MC=class{kind=`document`;cell;lastChangedAt;constructor(e,t,n){this.name=e,this.clock=n,this.cell=Y.observable.box(IC(t),{deep:!1}),this.lastChangedAt=t.kind===`pending`?null:n.now()}read(){return this.cell.get()}set(e){let t=IC(e);FC(this.cell.get(),t)||(this.cell.set(t),this.lastChangedAt=this.clock.now())}lastUpdatedMs(){return this.lastChangedAt}},NC=class{kind=`document`;cell;constructor(e,t){this.name=e,this.cell=new OC(`Variable "${e}"`,()=>IC(t()),FC)}read(){return this.cell.read()}release(){this.cell.release()}lastUpdatedMs(){return null}};function PC(e){return JSON.stringify(e)}function FC(e,t){return PC(e)===PC(t)}function IC(e){return e.kind===`ok`?{kind:`ok`,value:yC(e.value)}:e}function LC(e,t,n,r){let i=bC(n);if(i!==t)throw TypeError(`Variable "${e}": ${r} type ${i} does not match declared type ${t}`)}var RC=class{constructor(e,t=null){this.clock=e,this.parent=t}nodes=Y.observable.map(void 0,{deep:!1});defineBox(e,t,n){this.declare(e,new DC(e,t,n,this.clock))}defineDocument(e,t){this.declare(e,new MC(e,t,this.clock))}defineDerivedDocument(e,t){this.declare(e,new NC(e,t))}defineComputed(e,t,n){this.defineDerived(e,t,`computed`,n)}defineDerived(e,t,n,r){let i=e=>this.read(e),a=n===`computed`?AC:jC;this.declare(e,new a(e,t,()=>r(i)))}derive(e,t,n){if(this.refuseDisposed(`Derived value "${e}"`),t===`projection`)return new kC(n);let r=new OC(`Derived value "${e}"`,n);return this.kept.push(r),r}kept=[];read(e){return this.requireVar(e).read()}readDocument(e){let t=this.requireNode(e);if(t.kind!==`document`)throw TypeError(`Variable "${e}" is a ${t.kind}, not a document`);return t.read()}stored(e){let t=this.requireNode(e);if(t.kind===`document`)return t.read();if(t.kind!==`box`)throw TypeError(`Variable "${e}" is a ${t.kind}, not a written node`);return t.stored()}setDocument(e,t){let n=this.requireOwn(e);if(!(n instanceof MC))throw TypeError(n.kind===`document`?`Variable "${e}" is a derived document: what it reads decides it, and nothing writes it`:`Variable "${e}" is a ${n.kind}, not a document (use defineDocument to create one)`);(0,Y.runInAction)(()=>n.set(t))}setBox(e,t){let n=this.requireOwn(e);if(n.kind!==`box`)throw TypeError(`Variable "${e}" is a ${n.kind}, not a box (use defineBox to create a settable variable)`);(0,Y.runInAction)(()=>n.set(t))}runInAction(e){(0,Y.runInAction)(e)}has(e){return this.nodes.has(e)||(this.parent?.has(e)??!1)}getType(e){return this.requireVar(e).type}getKind(e){return this.requireNode(e).kind}changeKey(e){let t=this.requireNode(e);if(t.kind===`document`){let e=t.read();return e.kind===`pending`?e:F(PC(e))}try{return F(String(t.read()))}catch(e){return TC(e)===void 0?F(` failed:${e instanceof Error?e.message:String(e)}`):Ao(`unread`)}}getNode(e){let t=this.requireNode(e);return t.kind===`document`?{name:t.name,kind:t.kind,read:()=>t.read(),lastUpdatedMs:()=>t.lastUpdatedMs()}:{name:t.name,type:t.type,kind:t.kind,read:()=>t.read(),lastUpdatedMs:()=>t.lastUpdatedMs()}}names(){return[...this.parent?.names()??[],...this.nodes.keys()]}dispose(){if(this.disposed)return 0;this.disposed=!0;let e=0;return(0,Y.runInAction)(()=>{for(let t of this.nodes.values())(t instanceof AC||t instanceof NC)&&(t.release(),e++);for(let e of this.kept)e.release()}),e+this.kept.length}disposed=!1;requireNode(e){let t=this.nodes.get(e)??this.parent?.requireNode(e);if(!t)throw ReferenceError(`Unknown variable "${e}"`);return t}requireOwn(e){let t=this.nodes.get(e);if(t!==void 0)return t;throw this.parent?.has(e)?Error(`Variable "${e}" lives in the directory's store; a session's view cannot write it`):ReferenceError(`Unknown variable "${e}"`)}requireVar(e){let t=this.requireNode(e);if(t.kind===`document`)throw TypeError(`Variable "${e}" is a document; read its fields by path (.${e}.<field>)`);return t}refuseDisposed(e){if(this.disposed)throw Error(`${e}: cannot declare on a disposed store`)}declare(e,t){if(this.refuseDisposed(`Variable "${e}"`),this.has(e))throw Error(`Variable "${e}" is already declared`);(0,Y.runInAction)(()=>this.nodes.set(e,t))}},zC=class extends Error{name=`TemplateError`;kind=`EvalError`;pos;source;constructor(e,t,n={}){super(e,{cause:n.cause}),this.pos=t,this.source=n.source}get sourceSnippet(){return this.source?JC(this.source,this.pos):``}toString(){let e=`${this.name}: ${this.message}\n at line ${this.pos.line}, column ${this.pos.column}`,t=this.sourceSnippet;return t?`${e}\n\n${t}`:e}},BC=class extends zC{name=`ParseError`;kind=`ParseError`;expected;found;constructor(e,t,n={}){super(e,t,n),this.expected=n.expected,this.found=n.found}},VC=class extends zC{name=`EvalError`;kind=`EvalError`},HC=class extends VC{name=`FuncNotFoundError`;kind=`FuncNotFoundError`;funcName;suggestions;constructor(e,t,n={}){let r=YC(e,n.available??[]),i=r.length===0?``:` (did you mean: ${r.join(`, `)}?)`;super(`function ${JSON.stringify(e)} is not registered${i}`,t,n),this.funcName=e,this.suggestions=r}},UC=class extends VC{name=`ArgCountError`;kind=`ArgCountError`;funcName;accepted;got;constructor(e,t,n,r,i={}){let a=t.minimum===t.maximum?`${t.minimum}`:`at least ${t.minimum}`;super(`wrong number of args for ${e}: want ${a} got ${n}`,r,i),this.funcName=e,this.accepted=t,this.got=n}},WC=class extends VC{name=`TypeMismatchError`;kind=`TypeMismatchError`;funcName;argIndex;expected;receivedSummary;constructor(e,t,n,r,i,a={}){super(`function ${JSON.stringify(e)} arg ${t}: expected ${n}, but a ${r} flowed in. Pass it through \`unstyled\` (or your engine's flatten function) to convert.`,i,a),this.funcName=e,this.argIndex=t,this.expected=n,this.receivedSummary=r}},GC=class extends WC{constructor(e,t,n,r,i={}){super(e,t,`integer`,String(n),r,i),this.message=Number.isInteger(Number(n))?`integer out of range: ${String(n)}`:`expected integer; found ${String(n)}`}},KC=class extends VC{name=`MissingFieldError`;kind=`MissingFieldError`;path;constructor(e,t,n={}){super(`field "${e.join(`.`)}" not found on receiver`,t,n),this.path=e}},qC=class extends VC{name=`FailError`;kind=`FailError`;constructor(e,t={line:0,column:0,offset:0},n={}){super(e,t,n)}};function JC(e,t){let n=e.split(`
59
59
  `),r=t.line-1,i=[];if(r-1>=0&&r-1<n.length&&i.push({num:r,text:n[r-1]??``}),r>=0&&r<n.length&&i.push({num:r+1,text:n[r]??``}),r+1<n.length&&i.push({num:r+2,text:n[r+1]??``}),i.length===0)return``;let a=String(i[i.length-1]?.num??1).length,o=[];for(let e of i)if(o.push(` ${String(e.num).padStart(a,` `)} | ${e.text}`),e.num===t.line){let e=` ${` `.repeat(a)} | `,n=` `.repeat(Math.max(0,t.column-1));o.push(`${e}${n}^`)}return o.join(`
60
60
  `)}function YC(e,t){if(t.length===0)return[];let n=t.map(t=>({name:t,dist:XC(e,t)})).sort((e,t)=>e.dist-t.dist),r=Math.max(2,Math.floor(e.length/2));return n.filter(e=>e.dist<=r).slice(0,3).map(e=>e.name)}function XC(e,t){if(e===t)return 0;let n=e.length,r=t.length;if(n===0)return r;if(r===0)return n;let i=Array(r+1),a=Array(r+1);for(let e=0;e<=r;e++)i[e]=e;for(let o=1;o<=n;o++){a[0]=o;for(let n=1;n<=r;n++){let r=e[o-1]===t[n-1]?0:1;a[n]=Math.min((a[n-1]??0)+1,(i[n]??0)+1,(i[n-1]??0)+r)}for(let e=0;e<=r;e++)i[e]=a[e]??0}return i[r]??0}function ZC(e){throw Error(`unhandled node kind: ${JSON.stringify(e)}`)}const QC=new Map([[`if`,`If`],[`else`,`Else`],[`end`,`End`],[`range`,`Range`],[`with`,`With`],[`break`,`Break`],[`continue`,`Continue`],[`define`,`Define`],[`template`,`Template`],[`block`,`Block`],[`true`,`Bool`],[`false`,`Bool`],[`nil`,`Nil`]]),$C={left:`{{`,right:`}}`};var ew=class{src;leftDelim;rightDelim;offset=0;line=1;column=1;mode=`text`;pending;constructor(e,t=$C){this.src=e,this.leftDelim=t.left,this.rightDelim=t.right}pos(){return{line:this.line,column:this.column,offset:this.offset}}err(e,t,n={}){return new BC(e,t,{...n,source:this.src})}next(){if(this.pending){let e=this.pending;return this.pending=void 0,e}return this.read()}peek(){return this.pending||=this.read(),this.pending}read(){switch(this.mode){case`text`:return this.readText();case`action`:return this.readAction();case`done`:return this.makeToken(`EOF`,``,this.pos())}}readText(){if(this.offset>=this.src.length)return this.mode=`done`,this.makeToken(`EOF`,``,this.pos());let e=this.pos(),t=this.offset;for(;t<this.src.length&&!this.src.startsWith(this.leftDelim,t);)t+=1;let n=t<this.src.length&&this.src[t+this.leftDelim.length]===`-`,r=t;if(n)for(;r>this.offset&&tw(this.src[r-1]??``);)--r;if(r>this.offset){let t=this.src.slice(this.offset,r);return this.advanceTo(r),this.makeToken(`Text`,t,e)}return this.advanceTo(t),this.emitLeftDelim(n)}emitLeftDelim(e){let t=this.pos();if(this.advanceBy(this.leftDelim.length),e)for(this.advanceBy(1);tw(this.src[this.offset]??``);)this.advanceBy(1);return this.mode=`action`,this.src.startsWith(`/*`,this.offset)?this.readComment(t,e):this.makeToken(`LeftDelim`,e?`${this.leftDelim}-`:this.leftDelim,t,e?{trimLeft:!0}:{})}readComment(e,t){this.advanceBy(2);let n=this.offset,r=this.src.indexOf(`*/`,this.offset);if(r===-1)throw this.err(`unclosed comment`,e,{expected:`*/${this.rightDelim}`,found:`end of input`});this.advanceTo(r);let i=this.src.slice(n,r).trim();for(this.advanceBy(2);tw(this.src[this.offset]??``);)this.advanceBy(1);let a=!1;if(this.src[this.offset]===`-`&&(a=!0,this.advanceBy(1)),!this.src.startsWith(this.rightDelim,this.offset))throw this.err(`expected \`${this.rightDelim}\` to close comment`,this.pos(),{expected:this.rightDelim,found:this.src[this.offset]??`end of input`});if(this.advanceBy(this.rightDelim.length),a)for(;tw(this.src[this.offset]??``);)this.advanceBy(1);return this.mode=`text`,this.makeToken(`Comment`,i,e,{...t?{trimLeft:!0}:{},...a?{trimRight:!0}:{}})}readAction(){if(this.skipActionSpaces(),this.src.startsWith(`-${this.rightDelim}`,this.offset)){let e=this.pos();for(this.advanceBy(1+this.rightDelim.length),this.mode=`text`;tw(this.src[this.offset]??``);)this.advanceBy(1);return this.makeToken(`RightDelim`,`-${this.rightDelim}`,e,{trimRight:!0})}if(this.src.startsWith(this.rightDelim,this.offset)){let e=this.pos();return this.advanceBy(this.rightDelim.length),this.mode=`text`,this.makeToken(`RightDelim`,this.rightDelim,e)}if(this.offset>=this.src.length)throw this.err(`unclosed action`,this.pos(),{expected:this.rightDelim,found:`end of input`});let e=this.src[this.offset],t=this.pos();switch(e){case`(`:return this.advanceBy(1),this.makeToken(`LeftParen`,`(`,t);case`)`:return this.advanceBy(1),this.makeToken(`RightParen`,`)`,t);case`|`:return this.advanceBy(1),this.makeToken(`Pipe`,`|`,t);case`,`:return this.advanceBy(1),this.makeToken(`Comma`,`,`,t);case`:`:if(this.src[this.offset+1]===`=`)return this.advanceBy(2),this.makeToken(`Declare`,`:=`,t);throw this.err("expected `:=`",t,{expected:`:=`,found:`:`});case`=`:return this.advanceBy(1),this.makeToken(`Assign`,`=`,t);case`"`:return this.readQuotedString(t);case"`":return this.readRawString(t);case`'`:return this.readChar(t)}if(e===`$`)return this.readVariable(t);if(e!==void 0&&(rw(e)||nw(e)&&rw(this.src[this.offset+1]??``)||e===`.`&&rw(this.src[this.offset+1]??``)))return this.readNumber(t);if(e===`.`)return this.readDotOrField(t);if(e!==void 0&&cw(e))return this.readIdentifier(t);throw this.err(`unexpected character ${JSON.stringify(e)}`,t,{found:e??`end of input`})}readQuotedString(e){let t=this.offset;for(this.advanceBy(1);this.offset<this.src.length;){let n=this.src[this.offset];if(n===`\\`){this.advanceBy(1),this.offset<this.src.length&&this.advanceBy(1);continue}if(n===`
61
61
  `)throw this.err(`newline in interpreted string`,e,{found:`\\n`});if(n===`"`)return this.advanceBy(1),this.makeToken(`String`,this.src.slice(t,this.offset),e);this.advanceBy(1)}throw this.err(`unterminated string literal`,e,{expected:`"`,found:`end of input`})}readRawString(e){let t=this.offset;for(this.advanceBy(1);this.offset<this.src.length;){if(this.src[this.offset]==="`")return this.advanceBy(1),this.makeToken(`String`,this.src.slice(t,this.offset),e);this.advanceBy(1)}throw this.err(`unterminated raw string literal`,e,{expected:"`",found:`end of input`})}readChar(e){let t=this.offset;for(this.advanceBy(1);this.offset<this.src.length;){let n=this.src[this.offset];if(n===`\\`){this.advanceBy(1),this.offset<this.src.length&&this.advanceBy(1);continue}if(n===`
@@ -67,7 +67,7 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
67
67
  `).map(e=>n+e).join(`
68
68
  `)}function nk(e){let t=new TextEncoder;return e.split(/\s+/).filter(e=>e.length>0).map(e=>String.fromCharCode(...t.encode(e).slice(0,1))).join(``)}function rk(e,t){let n=[];for(let e of t){if(typeof e==`object`&&e)throw WD(`join`,2,`list of strings/primitives`,`list element of type ${ik(e)}`);n.push(String(e))}return n.join(e)}function ik(e){return Array.isArray(e)?`array`:e instanceof Map?`Map`:e instanceof Set?`Set`:`object`}function ak(e){return JO(e,`-`)}function ok(e){return e.toLowerCase()}function sk(e,t){return`\n${tk(e,t)}`}function ck(e){return e.replace(/\s+/g,``)}function lk(e,t,n){return n===1?e:t}function uk(...e){return e.map(e=>`"${e}"`).join(` `)}function dk(e){return e.replace(/[\\.+*?()|[\]{}^$]/g,`\\$&`)}function fk(e,t){return t.repeat(Math.max(0,e))}function pk(e,t,n){return MO(e,n).join(t)}function mk(e){return JO(e,`_`)}function hk(e,t){let n=MO(e,t),r={};for(let e=0;e<n.length;e++)r[`_${e}`]=n[e];return r}function gk(e,t){return MO(e,t)}function _k(e,t,n){let r=vk(n,e,t),i={};for(let e=0;e<r.length;e++)i[`_${e}`]=r[e]??``;return i}function vk(e,t,n){if(n===0)return[];let r=MO(t,e);if(n<0||r.length<=n)return r;let i=r.slice(0,n-1),a=r.slice(n-1).join(t);return[...i,a]}function yk(...e){return e.map(e=>`'${e}'`).join(` `)}function bk(e,t,n){let r=jO(n),i=t<0||t>r.length?r.length:t,a=Math.min(Math.max(0,e),i);return r.slice(a,i).join(``)}function xk(e){let t=``;for(let n of e)Sk(n)?t+=n.toLowerCase():Ck(n)?t+=n.toUpperCase():t+=n;return t}function Sk(e){return e!==e.toLowerCase()&&e===e.toUpperCase()}function Ck(e){return e!==e.toUpperCase()&&e===e.toLowerCase()}function wk(e){return e.replace(/\b([a-zA-Z])/g,e=>e.toUpperCase())}function Tk(e){return e.trim()}function Ek(e,t){if(e.length===0)return t;let n=new Set(jO(e)),r=jO(t),i=0;for(;i<r.length&&n.has(r[i]);)i+=1;let a=r.length;for(;a>i&&n.has(r[a-1]);)--a;return r.slice(i,a).join(``)}function Dk(e,t){return t.startsWith(e)?t.slice(e.length):t}function Ok(e,t){return t.endsWith(e)?t.slice(0,t.length-e.length):t}function kk(e,t){let n=jO(t);if(e<0){let r=-e;return r>=n.length?t:n.slice(n.length-r).join(``)}return e>=n.length?t:n.slice(0,e).join(``)}function Ak(e){return e.replace(/\b([A-Z])/g,e=>e.toLowerCase())}function jk(e){return e.toUpperCase()}function Mk(e,t){return Nk(e,`
69
69
  `,t)}function Nk(e,t,n){if(e<=0)return n;let r=[];for(let t of n.split(`
70
- `)){let n=``;for(let i of t.split(/\s+/))i.length!==0&&(n.length===0?n=i:n.length+1+i.length<=e?n+=` ${i}`:(r.push(n),n=i));n.length>0&&r.push(n)}return r.join(t)}function Pk(e,t,n){return Nk(e,t,n)}function Fk(){return{abbrev:{fn:(e,t)=>NO(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},abbrevboth:{fn:(e,t,n)=>PO(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},camelcase:{fn:e=>XO(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},cat:{fn:(...e)=>ZO(...e),argTypes:[`string`],arity:{kind:`variadic`}},contains:{fn:(e,t)=>QO(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasPrefix:{fn:(e,t)=>$O(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasSuffix:{fn:(e,t)=>ek(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},indent:{fn:(e,t)=>tk(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},initials:{fn:e=>nk(e),argTypes:[`string`],arity:{kind:`exact`}},join:{fn:(e,t)=>rk(e,t),argTypes:[`string`,`list`],arity:{kind:`exact`}},kebabcase:{fn:e=>ak(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},lower:{fn:e=>ok(e),argTypes:[`string`],arity:{kind:`exact`}},nindent:{fn:(e,t)=>sk(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},nospace:{fn:e=>ck(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},plural:{fn:(e,t,n)=>lk(e,t,n),argTypes:[`string`,`string`,`int`],arity:{kind:`exact`},returnType:`string`},quote:{fn:(...e)=>uk(...e),argTypes:[`string`],arity:{kind:`variadic`}},regexQuoteMeta:{fn:e=>dk(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},repeat:{fn:(e,t)=>fk(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},replace:{fn:(e,t,n)=>pk(e,t,n),argTypes:[`string`,`string`,`string`],arity:{kind:`exact`}},snakecase:{fn:e=>mk(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},split:{fn:(e,t)=>hk(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitList:{fn:(e,t)=>gk(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitn:{fn:(e,t,n)=>_k(e,t,n),argTypes:[`string`,`int`,`string`],arity:{kind:`exact`},returnType:`dict`},squote:{fn:(...e)=>yk(...e),argTypes:[`string`],arity:{kind:`variadic`}},substr:{fn:(e,t,n)=>bk(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},swapcase:{fn:e=>xk(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},title:{fn:e=>wk(e),argTypes:[`string`],arity:{kind:`exact`}},trim:{fn:e=>Tk(e),argTypes:[`string`],arity:{kind:`exact`}},trimAll:{fn:(e,t)=>Ek(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimPrefix:{fn:(e,t)=>Dk(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimSuffix:{fn:(e,t)=>Ok(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trunc:{fn:(e,t)=>kk(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},untitle:{fn:e=>Ak(e),argTypes:[`string`],arity:{kind:`exact`}},upper:{fn:e=>jk(e),argTypes:[`string`],arity:{kind:`exact`}},wrap:{fn:(e,t)=>Mk(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},wrapWith:{fn:(e,t,n)=>Pk(e,t,n),argTypes:[`int`,`string`,`string`],arity:{kind:`exact`}}}}function Ik(e,t){let n=Lk(e),r=n.copy();return r.style=kf(n.style,t),r}function Lk(e){if(!(e instanceof K))throw TypeError(`template function expected a RichText fragment, got ${typeof e==`object`?Object.prototype.toString.call(e):typeof e}`);return e}function Rk(e){return{fn:(t=>Ik(t,e)),argTypes:[`liftable`],arity:{kind:`exact`},returnType:`T`}}function zk(e){return{fn:((t,n)=>Ik(n,new U({[e]:H.parse(t)}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`}}function Bk(e,t){return new U({[e]:t})}function Vk(){let e={};for(let t of xf)e[t]=Rk(Bk(t,!0)),e[`not_${t}`]=Rk(Bk(t,!1));for(let[t,n]of Object.entries(Cf))e[t]=Rk(Bk(n,!0));return e}const Hk={fn:((e,t)=>Ik(t,U.parse(e))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`},Uk={fn:((e,t)=>Ik(t,new U({link:e}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`};function Wk(){return{fg:zk(`color`),bg:zk(`bgcolor`),...Vk(),link:Uk,style:Hk}}function Gk(e,t){let n;try{n=iu(e.trim())}catch(n){throw n instanceof Bl?TypeError(`${t} expected a color (#RRGGBB or #RRGGBBAA), got ${JSON.stringify(e)} — to use a palette name here, wrap it: ${t} (color ${JSON.stringify(e)}) …`,{cause:n}):n}return Kk(n,t,JSON.stringify(e))}function Kk(e,t,n){if(e.alpha===0)throw RangeError(`${t} got ${n}, which is fully transparent: it draws no colour of its own, so there is nothing to compute with — use the colour of the surface it sits on, e.g. (color "background")`);return e}function qk(e,t){return{fn:t,argTypes:e,arity:{kind:`exact`},returnType:`string`}}function Jk(e,t,n,r){let i=r===void 0||e>=r.min&&e<=r.max;if(!Number.isFinite(e)||!i){let i=r===void 0?`a finite number`:`within ${r.min}..${r.max} (${r.note})`;throw RangeError(`${t}'s ${n} must be ${i}, got ${e}`)}return e}const Yk=qk([`string`,`int`],((e,t)=>Ku(Gk(e,`darken`),t).hex)),Xk=qk([`string`,`int`],((e,t)=>Ku(Gk(e,`lighten`),-t).hex)),Zk={min:0,max:100,note:`0 = from, 100 = toward`},Qk=qk([`string`,`string`,`float`],((e,t,n)=>au(Gk(e,`mix`),Gk(t,`mix`),Jk(n,`mix`,`percentage`,Zk)/100).hex)),$k={min:1,max:21,note:`4.5 = AA body text, 3 = AA large text`},eA=qk([`string`],(e=>Zu(Gk(e,`contrastOn`)).hex)),tA={depth:V.TRUECOLOR},nA=e=>qk([`string`,`string`,`float`],((t,n,r)=>{let{depth:i,terminal:a}=e();return Qu(Gk(t,`readableOn`),Gk(n,`readableOn`),Jk(r,`readableOn`,`ratio`,$k),i,void 0,a).hex})),rA={hueShift:`shiftHue`,chromaScale:`scaleChroma`,lightnessScale:`scaleLightness`,lightnessShift:`shiftLightness`};function iA(){let e={};for(let[t,n]of Object.entries(rA)){let r=t;e[n]=qk([`string`,`float`],((e,t)=>{let i={...wu,[r]:Jk(t,n,`amount`)};return Iu.fromRgba(Gk(e,n)).applyKey(i).toRgba().hex}))}return e}function aA(e=()=>tA){return{darken:Yk,lighten:Xk,mix:Qk,contrastOn:eA,readableOn:nA(e),...iA()}}function oA(e,t){if(e.length%2!=0)throw RangeError(`ramp's last stop (position ${String(e[e.length-1])}) has no color — stops are <position> <color> pairs`);let n=[];for(let r=0;r<e.length;r+=2)n.push({at:e[r],color:Kk(Bu(t,e[r+1]),`ramp`,JSON.stringify(e[r+1]))});return n}function sA(e){return{color:{fn:(t=>Bu(e(),t).hex),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},ramp:{fn:((t,n,...r)=>new Sp(af(n),oA(r,e())).at(t).hex),argTypes:[`float`,`string`],arity:{kind:`alternating`,minimum:4},returnType:`string`}}}const cA=kp.play(0);function lA(e,t,n){if(t.length%2!=0)throw RangeError(`last hold (${String(t[t.length-1])} s) has no ${e} — the arguments are <seconds> <${e}> pairs`);let r=[];for(let e=0;e<t.length;e+=2){let i=t[e];if(!Number.isFinite(i)||i<=0)throw RangeError(`hold ${e/2} must be a positive number of seconds, got ${i}`);r.push({seconds:i,value:n(t[e+1])})}return r}const uA={...s_.loops,typewriter:e=>s_.transitions.typewriter(e).effect,scramble:e=>s_.transitions.scramble(e).effect,backspace:e=>s_.transitions.backspace(e).effect,scrambleOut:e=>s_.transitions.scrambleOut(e).effect};function dA(e){if(!Object.hasOwn(uA,e))throw RangeError(`unknown glyph effect ${JSON.stringify(e)}; expected one of ${Object.keys(uA).map(e=>JSON.stringify(e)).join(`, `)}`);return uA[e]}function fA(e,t={}){let n=t.timeline??(()=>cA),r=(e,t,r)=>[kp.run(n(),t),lf(e,r.time)],i=(t,n)=>{let i=e(),[a,o]=r(t,n,i),s=dp(a,o,i);return i.onHold?.(fp(s,o)),s.value},a=(e,t)=>kp.run(kp.play(e),t);return{frames:{fn:((...t)=>{let n=lA(`frame`,t,Lk).map(({seconds:e,value:t})=>({seconds:e,text:t})),i=e();return l_(...r(`frames`,new c_(n),i),i)}),argTypes:[`float`,`liftable`],arity:{kind:`alternating`,minimum:2},returnType:`T`},stepped:{fn:((...e)=>{let t=lA(`color`,e,e=>Gk(e,`stepped`));return t[i(`stepped`,gf(t.map(e=>e.seconds)))].value.hex}),argTypes:[`float`,`string`],arity:{kind:`alternating`,minimum:2},returnType:`string`},tween:{fn:((e,t,n,r,o)=>i(`tween`,a(n,xp(r,o,{seconds:e,ease:af(t)})))),argTypes:[`float`,`string`,`float`,`float`,`float`],arity:{kind:`exact`},returnType:`float`},loop:{fn:((e,t)=>i(`loop`,a(t,G.continuous(_f.loop(e))))),argTypes:[`float`,`float`],arity:{kind:`exact`},returnType:`float`},glyphs:{fn:((t,n,i)=>{let o=dA(t),s=Lk(i),c=s.plain,l=e();return l_(...r(`glyphs`,a(n,zg(s,o({z:hh(c,0,0)}),{key:c,asciiOnly:l.asciiOnly===!0})),l),l)}),argTypes:[`string`,`float`,`liftable`],arity:{kind:`exact`},returnType:`T`}}}function pA(e){return{...Wk(),...aA(e)}}new U({color:`red`,dim:!0});const mA=/^(?:(?:global|apac|au|eu|us|us-east-\d|us-west-\d|eu-west-\d|eu-central-\d)\.)?(?:anthropic\.|azure_ai\/|bedrock\/|vertex_ai\/)?claude-(?:(?<family>opus|sonnet|haiku)-(?<newMajor>\d+)(?:-(?<newMinor>\d))?|(?<oldMajor>\d+)(?:-(?<oldMinor>\d))?-(?<oldFamily>opus|sonnet|haiku))(?:[-@]\d{8})?(?:-v\d+:\d+)?(?:-latest)?$/i,hA=/^(?<family>opus|sonnet|haiku)\s+(?<major>\d+)(?:\.(?<minor>\d))?$/i;function gA(e){if(!e)return`Claude`;let t=e.trim().replace(/\s*\([^)]*\)\s*$/,``).replace(/\s*\[[^\]]*\]\s*$/,``).trim(),n=t.match(mA);if(n?.groups){let{family:e,newMajor:t,newMinor:r,oldMajor:i,oldMinor:a,oldFamily:o}=n.groups,s=e||o,c=t||i,l=r||a;if(s&&c)return`${s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()} ${l?`${c}.${l}`:c}`}let r=t.match(hA);if(r?.groups){let e=r.groups.family,t=r.groups.major,n=r.groups.minor;return`${e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()} ${n?`${t}.${n}`:t}`}return t||e}function _A(e){let t=e.match(hA);if(!t?.groups)return e;let n=t.groups.family,r=t.groups.major,i=t.groups.minor;return`${n.charAt(0).toUpperCase()}${i?`${r}.${i}`:r}`}function vA(e){let t=e.split(`/`),n=t.length-1;return t.map((e,t)=>{if(t===n)return e;let r=e.match(/^\.*./);return r?r[0]:e}).join(`/`)}function yA(e){return e.toLocaleString()}function bA(e){if(e.length===0)throw Error(`a cascade needs at least one stop, e.g. "0:calm"`);let t=[];for(let[n,r]of e.entries()){let e=r.indexOf(`:`),i=e<0?NaN:Number(r.slice(0,e));if(!Number.isFinite(i))throw Error(`cascade stop ${n} ("${r}") must be "<position>:<result>", e.g. "80:hot" — the position must be a number`);let a=t[n-1];if(a!==void 0&&i<a.at)throw Error(`cascade stops must be in ascending position order; stop ${n} at ${i} follows stop ${n-1} at ${a.at}`);t.push({at:i,text:r.slice(e+1)})}return t}function xA(e,t){if(!Number.isFinite(e))throw Error(`a cascade needs a finite value, got ${e}`);let n=-1;for(;n+1<t.length&&t[n+1].at<=e;)n++;return(n<0?t[0]:t[n]).text}const SA=[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],CA=SA.length;function wA(e,t){let n=t===void 0?e:t<=0?[]:e.slice(-t);if(n.length===0)return``;let r=n[0],i=n[0];for(let e of n)e<r&&(r=e),e>i&&(i=e);let a=i-r,o=``;for(let e of n){let t=a===0?0:Math.round((e-r)/a*(CA-1));o+=SA[t]}return o}function TA(e){let t=[];for(let n of e.split(`,`)){let e=n.trim();if(e===``)continue;let r=Number(e);if(!Number.isFinite(r))throw TypeError(`sparkline: non-numeric series element ${JSON.stringify(n)}`);t.push(r)}return t}function EA(e,t,n){if(n.length!==0)throw Error(`${e}: takes at most ${t.length} optional argument${t.length===1?``:`s`} (${t.join(`, `)}), got ${t.length+n.length}`)}const DA=Gv(),OA=[...py];function kA(){return{basename:{fn:e=>ne(e),argTypes:[`string`],arity:{kind:`exact`}},dirname:{fn:e=>D(e),argTypes:[`string`],arity:{kind:`exact`}},abbreviatePath:{fn:e=>vA(e),argTypes:[`string`],arity:{kind:`exact`}},int:{fn:e=>Math.trunc(SC(e)),argTypes:[`value`],arity:{kind:`exact`}},string:{fn:e=>xC(e),argTypes:[`value`],arity:{kind:`exact`}},bool:{fn:e=>CC(e),argTypes:[`value`],arity:{kind:`exact`}},urlEncode:{fn:e=>encodeURIComponent(e),argTypes:[`string`],arity:{kind:`exact`}},themes:{fn:()=>DA,argTypes:[],arity:{kind:`exact`}},endcaps:{fn:()=>OA,argTypes:[],arity:{kind:`exact`}},sparkline:{fn:(e,t,...n)=>(EA(`sparkline`,[`width`],n),wA(TA(e),t)),argTypes:[`string`,`int`],arity:{kind:`variadic`}},cascade:{fn:(e,...t)=>xA(e,bA(t)),argTypes:[`float`,`string`],arity:{kind:`variadic`}}}}function AA(e,t,n,r){let i=n*6e4-(t*1e3-r);if(i<3e5||e<=0)return-1;let a=e/i;return Math.max(0,Math.round((100-e)/a/6e4))}const jA=e=>({minutesUntilReset:{fn:t=>Math.round(Math.max(0,t*1e3-e.now().getTime())/6e4),argTypes:[`int`],arity:{kind:`exact`}},etaMinutes:{fn:(t,n,r)=>AA(t,n,r,e.now().getTime()),argTypes:[`float`,`int`,`int`],arity:{kind:`exact`}}});function MA(){return{formatInteger:{fn:e=>yA(e),argTypes:[`int`],arity:{kind:`exact`}},round:{fn:e=>Math.round(e),argTypes:[`float`],arity:{kind:`exact`}},formatModelName:{fn:e=>gA(e),argTypes:[`string`],arity:{kind:`exact`}},shortenModelName:{fn:e=>_A(e),argTypes:[`string`],arity:{kind:`exact`}}}}let NA=null;function PA(e,t){if(NA!==null)throw Error(`a draw is already in progress: draws do not nest`);let n={at:e,timeline:t,frame:{time:e,onHold:({nextChange:e})=>{n.soonest=Math.min(n.soonest,e)}},soonest:1/0};return NA=n,{heard:()=>n.soonest,[Symbol.dispose]:()=>{NA=null}}}function FA(e){if((0,Y._isComputingDerivation)())throw Error(`the clock was read by a value that keeps its answer (${e}): a template reaching a time variable or a clock function by a name it does not spell (index, get) is not known to read the instant — name it: {{ .clock }}`);if(NA===null)throw Error(`the clock was read outside a draw (${e})`);return NA}const IA={now:()=>He(FA(`now`).at),frame:()=>FA(`frame`).frame,timeline:()=>FA(`timeline`).timeline};function LA(e,t){let{frames:n,stepped:r}=fA(e,t===void 0?{}:{timeline:t});if(n===void 0||r===void 0)throw Error(`rich-js's animationFuncs no longer registers frames and stepped`);return{frames:n,stepped:r}}const RA=new Set([`now`,`ago`]);function zA(e,t){return Object.fromEntries(Object.entries(fD(e)).filter(([e])=>RA.has(e)===t))}const BA=zA(()=>{throw Error(`a sprig date function other than now and ago read the clock: add it to SPRIG_CLOCK_READERS`)},!1),VA=[e=>zA(e.now,!0),e=>LA(e.frame,e.timeline),e=>Object.fromEntries(Object.entries(LA(e.frame)).map(([e,t])=>[`realtime${e.replace(/^./,e=>e.toUpperCase())}`,t])),jA];function HA(e){return Object.assign({},...e.map(e=>e(IA)))}const UA=new Set(Object.keys(HA(VA)));function WA(e){return new Set([...UA,...Object.keys(HA(e))])}const GA={readableOn:nA},KA=new Set(Object.keys(GA));function qA(e){let{drawnAt:t,extraFuncs:n}=e,r=()=>({depth:t()});return jT({fromString:e=>new K(e),toString:e=>e.plain,isT:e=>e instanceof K,missingKey:`error`,funcs:{...bD(),...Fk(),...cO(),...AO(),...nE(),...ID(),...PD(),...BA,...pA(r),...Object.fromEntries(Object.entries(GA).map(([e,t])=>[e,t(r)])),...HA([...VA,...e.clockFuncs??[]]),...kA(),...MA(),...n??{}}})}function JA(e){return YA(e,new Set(e.names()),``)}function YA(e,t,n){return new Proxy(Object.create(null),{has(r,i){if(typeof i!=`string`)return!1;let a=n?`${n}.${i}`:i;if(t.has(a))return!$ee(e,a);let o=`${a}.`;for(let e of t)if(e.startsWith(o))return!0;return!1},get(r,i){if(typeof i!=`string`)return;let a=n?`${n}.${i}`:i;if(t.has(a)){if(e.getKind(a)!==`document`)return e.read(a);let t=e.readDocument(a);return t.kind===`absent`?void 0:ZA(a,t)}let o=`${a}.`;for(let n of t)if(n.startsWith(o))return YA(e,t,a)}})}function XA(e,t){return new Proxy(e,{has:(e,t)=>t===`settings`||Reflect.has(e,t),get:(e,n)=>n===`settings`?t:Reflect.get(e,n)})}function $ee(e,t){return e.getKind(t)===`document`&&e.readDocument(t).kind===`absent`}function ZA(e,t){switch(t.kind){case`ok`:return t.value;case`pending`:throw new wC(e,`variable "${e}" has no value yet: its source has not completed a scan`);case`failed`:throw Error(`variable "${e}": ${t.reason}`)}}var QA=class{held=new Map;declaring=null;closed=!1;take(e,t){if(this.closed)throw Error(`hold taken after close: ${e}`);this.declaring?.taken.add(e),!this.held.has(e)&&(this.held.set(e,t()),this.declaring!==null&&this.declaring.acquired++)}declare(e){if(this.declaring!==null)throw Error(`declaration within one`);let t={taken:new Set,acquired:0};this.declaring=t;let n;try{n=e()}finally{this.declaring=null}let r=0;for(let[e,n]of this.held)t.taken.has(e)||(this.held.delete(e),n(),r++);return{result:n,acquired:t.acquired,released:r}}close(){this.closed=!0;let e=this.held.size;for(let e of this.held.values())e();return this.held.clear(),e}get size(){return this.held.size}};function $A(e){let t=E.basename(e),n=E.dirname(e);for(;;){let r=ej(n);if(r!==null)return{dir:r,name:t,leaf:n===E.dirname(e)};t=E.basename(n),n=E.dirname(n)}}function ej(e){try{return s.statSync(e).isDirectory()?s.realpathSync(e):null}catch{return null}}const tj=(e,t)=>k(t);function nj(e){let t=[],n=!0,r=new Map;for(let i of e.named){let{hops:e,stopped:a}=An(i);a!==null&&t.push({path:i,reason:a.message});for(let t of e){let{dir:e,name:i,leaf:a}=$A(t);n&&=a;let o=r.has(e)?r.get(e):new Set;o?.add(i),r.set(e,o)}}for(let t of e.whole.map(ej))t!==null&&r.set(t,null);let i={dirs:[...r.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>t===null?{path:e}:{path:e,filenames:[...t].sort()})},a=new Map(i.dirs.map(e=>{let t=Rc(e.path);return[e.path,Bc(t)?zc(t):null]}));return{key:JSON.stringify([i,[...a]]),targets:i,unbound:[...a.values()].includes(null),bound:a,reached:n,unresolved:t}}function rj(e,t,n){let r=[...t.derived.unresolved.map(e=>`cannot follow a link chain — ${e.reason}`),...t.held.handle.deaf.map(e=>e.kind===`refused`?`cannot watch ${e.path} — ${e.reason}`:`watching ${e.path} failed — ${e.reason}`),...n===null?[]:[n]];return r.length===0?null:`${e}: ${r.join(`; `)}`}function ij(e,t){if(t.kind===`failed`)return t;if(e.kind!==`changed`)return e;if(t.kind===`unknown`)return t;for(let n of t.paths)e.paths.add(n);return e}const aj=(e,t)=>t===null?{kind:`unknown`}:{kind:`changed`,paths:new Set([E.join(e,t)])},oj=e=>({kind:`failed`,reason:`${e.path}: ${e.reason}`}),sj=(e,t)=>e.kind===`listening`&&e.handle===t,cj=e=>`${e.recursive===!0?`tree`:`dir`}:${e.path}`;var lj=class{slots=new Map;dirs=new Map;counters;logger;clock;closed=!1;constructor(e){this.clock=e.clock,this.counters=e.counters,this.logger=e.logger??tj}acquire(e,t,n){if(this.closed)return{release:()=>{},deaf:t.dirs.map(e=>({kind:`refused`,path:e.path,reason:`the watcher registry is closed`}))};let r=this.slots.get(e);for(let{dir:e}of r?.listeners??[])this.judged(e,`acquire`);let i=r??this.opened(e,t),a={onInvalidate:n};return i.holders.add(a),this.makeHandle(i,a)}follow(e,t,n){if(e!==null&&(e.key===t.key||t.unbound))return{watch:e,move:`kept`};let r={key:t.key,handle:this.acquire(t.key,t.targets,n)};return e?.handle.release(),{watch:r,move:`rebound`}}opened(e,t){let n={key:e,listeners:[],holders:new Set,debounce:null};for(let e of t.dirs){let t=this.dirFor(e),r={slot:n,dir:t,filter:e.filenames?new Set(e.filenames):null};t.listeners.add(r),n.listeners.push(r)}return this.slots.set(e,n),this.counters&&(n.listeners.every(e=>e.dir.state.kind===`listening`)?this.counters.watchersOpened++:this.counters.watchRefusals++),n}dirFor(e){let t=cj(e),n=this.dirs.get(t);if(n!==void 0)return this.judged(n,`acquire`),n;let r={path:e.path,recursive:e.recursive===!0},i={id:t,...r,listeners:new Set,state:this.open(r,()=>i,`acquire`,null)};return this.dirs.set(t,i),i}judged(e,t){if(e.state.kind===`deaf`){this.reopen(e,t);return}let n=Rc(e.path);Bc(n)&&zc(n)!==e.state.bound&&this.reopen(e,`another folder is at its path`)}judge(){for(let e of this.dirs.values())this.judged(e,`period`)}reopen(e,t){let n=e.state;n.kind===`listening`&&this.closeHandle(e.path,n.handle,t),e.state=this.open(e,()=>e,t,n),e.state.kind===`listening`?this.tell(e,{kind:`unknown`}):n.kind===`listening`&&this.tell(e,oj(e.state.deafness))}open(e,t,n,r){let i=e.path,a=zc(Rc(i));try{s.opendirSync(i).closeSync();let r=s.watch(i,{persistent:!1,recursive:e.recursive},(e,n)=>this.heard(t(),r,n));return r.on(`error`,e=>{this.logger(`warn`,`watcher error ${i}: ${e.message}`),this.counters&&this.counters.watchErrors++;let n=t();if(!sj(n.state,r))return;this.closeHandle(i,r,`error`);let a={kind:`failed`,path:i,reason:e.message};n.state={kind:`deaf`,deafness:a},this.tell(n,oj(a))}),this.counters&&this.counters.dirWatchesOpened++,this.logger(`info`,`dir watch opened path=${R(i)} cause=${R(n)}`),{kind:`listening`,handle:r,bound:a}}catch(e){let t=e.message;return r?.kind===`deaf`&&r.deafness.kind===`refused`&&r.deafness.reason===t||this.logger(`warn`,`watch failed ${i}: ${t}`),{kind:`deaf`,deafness:{kind:`refused`,path:i,reason:t}}}}heard(e,t,n){let{state:r}=e;if(!sj(r,t))return;let i=n===E.basename(e.path)&&zc(Rc(e.path))!==r.bound;for(let{slot:t,filter:r}of e.listeners)(r===null||n===null||r.has(n)||i)&&this.fire(t,aj(e.path,n));i&&this.judged(e,`moved`)}tell(e,t){for(let{slot:n}of e.listeners)this.fire(n,t)}fire(e,t){if(e.debounce!==null){e.debounce.window=ij(e.debounce.window,t);return}let n={window:t,cancel:this.clock.after(50,()=>{e.debounce=null;for(let t of e.holders)try{t.onInvalidate(n.window)}catch(t){this.logger(`warn`,`watcher invalidate threw key=${R(e.key)}: ${t.message}`)}},{unref:!0})};e.debounce=n}makeHandle(e,t){return{get deaf(){return e.listeners.flatMap(({dir:e})=>e.state.kind===`deaf`?[e.state.deafness]:[])},release:()=>{!e.holders.delete(t)||e.holders.size>0||this.slots.get(e.key)===e&&(this.closeSlot(e,`last release`),this.slots.delete(e.key))}}}closeHandle(e,t,n){try{t.close()}catch{}this.counters&&this.counters.dirWatchesClosed++,this.logger(`info`,`dir watch closed path=${R(e)} cause=${R(n)}`)}closeSlot(e,t){e.debounce!==null&&(e.debounce.cancel(),e.debounce=null);for(let n of e.listeners){let{dir:e}=n;e.listeners.delete(n),!(e.listeners.size>0)&&(e.state.kind===`listening`&&this.closeHandle(e.path,e.state.handle,t),this.dirs.delete(e.id))}this.counters&&this.counters.watchersClosed++}size(){return this.slots.size}dirWatches(){return[...this.dirs.values()].filter(e=>e.state.kind===`listening`).length}watchedDirs(){return[...this.dirs.values()].map(e=>e.path)}closeAll(){this.closed=!0;for(let e of this.slots.values())this.closeSlot(e,`close`);this.slots.clear()}};function uj(e,t){return t.kind===`failed`?e.failedMs:e.okMs}function dj(e,t,n){return t===0?e.okMs:Math.min(e.failedMs*2**(t-1),n)}var fj=class{stop=null;state=`released`;last=null;constructor(e,t){this.tick=e,this.clock=t}landed(e,t=this.clock.monotonic()){this.last={at:t,periodMs:e},this.schedule()}hold(e){if(this.state===`disposed`)return;let t=e?`held`:`released`;t!==this.state&&(this.state=t,this.schedule())}dispose(){this.state=`disposed`,this.cancel()}schedule(){if(this.cancel(),this.state!==`held`||this.last===null)return;let e=Math.max(0,this.last.at+this.last.periodMs-this.clock.monotonic());this.stop=this.clock.after(e,()=>{this.stop=null,this.tick()},{unref:!0})}cancel(){this.stop?.(),this.stop=null}};function pj(){return Y.observable.box(mj(`unread`),{deep:!1})}function mj(e){let t;return{kind:`pending`,why:e,landed:new Promise(e=>{t=e}),land:t}}function hj(e,t){let n=e.reading.get();n.kind!==`pending`&&(0,Y.compareStructural)(n,t)||((0,Y.runInAction)(()=>e.reading.set(t)),n.kind===`pending`&&n.land())}function gj(e,t){let n=e.reading.get();n.kind===`pending`?n.why!==t&&t===`unread`&&(0,Y.runInAction)(()=>e.reading.set({...n,why:t})):(0,Y.runInAction)(()=>e.reading.set(mj(t)))}function _j(e,t){e.reading.get().kind===`pending`&&hj(e,t)}function vj(e){return e.reading.get()}function yj(e,t,n,r){let i=new AbortController,a=r(Math.max(0,t),()=>i.abort());return new Promise((t,r)=>{i.signal.addEventListener(`abort`,()=>t(`deadline`)),e(i.signal).then(()=>t(`answered`),e=>i.signal.aborted?n(e):r(e))}).finally(()=>{a(),i.abort()})}function bj(e){return{current:()=>e}}const xj=()=>()=>{};var Sj=class{entries=new Map;refreshes;closed=!1;constructor(e){this.spec=e,this.refreshes=e.ledger.declare({name:e.name,scope:e.scope,refresh:[`first`,`period`,`change`,`supersede`]})}declare(e,t){if(this.closed)return bj(L(`${this.spec.name} closed`,`read`));let n=this.spec.keyOf(t),r=this.touched(n)??this.firstRead(this.created(n,t));return e.take(`${this.spec.name}:${n}`,()=>this.hold(r)),{current:()=>vj(r)}}supersede(e){if(this.closed)return()=>{};let t=this.spec.keyOf(e),n=this.touched(t)??this.created(t,e);n.superseding++,gj(n,`superseded`),this.abandon(n),n.changed=!1,this.evict();let r=!1;return()=>{r||(r=!0,n.superseding--,this.entries.get(n.key)===n&&this.refresh(n,`supersede`))}}changed(e){for(let t of this.entries.values())e(t.input)&&this.heard(t)}heard(e){e.holders>0&&this.refresh(e,`change`)}isHeld(e){for(let t of this.entries.values())if(t.holders>0&&e(t.input))return!0;return!1}stats(){let e=0;for(let t of this.entries.values())t.holders>0&&e++;let{refreshes:t,failures:n,abandoned:r,lastMs:i}=this.refreshes.record();return{entries:this.entries.size,held:e,refreshes:t,failures:n,abandoned:r,lastMs:i}}close(){this.closed=!0;for(let e of[...this.entries.values()])this.drop(e)}touched(e){let t=this.entries.get(e);if(t!==void 0)return this.entries.delete(e),this.entries.set(e,t),t}created(e,t){let n={key:e,input:t,reading:pj(),holders:0,flight:null,changed:!1,superseding:0,revisit:Cj(this.spec.every(t),this.spec.clock,{period:()=>this.refresh(n,`period`),holdReturned:()=>this.refresh(n,`change`)}),unwatch:()=>{}};return this.entries.set(e,n),n.unwatch=this.spec.watch(t,()=>this.heard(n)),n}firstRead(e){return this.refresh(e,`first`),e}refresh(e,t){if(e.superseding>0)return;if(e.flight!==null){e.changed||=t===`change`;return}let n=new AbortController;e.flight=n;let r=this.spec.clock.monotonic();Tj(()=>this.spec.read(e.input,n.signal)).then(i=>{let a=this.spec.fields(e.input,e.holders),o=A(this.spec.clock,r);if(n.signal.aborted){this.refreshes.abandoned(a,t,o);return}try{this.refreshes.recorded(a,t,i,o)}finally{this.store(e,i)}}).catch(t=>{this.spec.logger(`error`,`${this.spec.name} refresh threw (${this.spec.fields(e.input,e.holders)}): ${String(t)}`)})}store(e,t){e.flight=null;try{hj(e,t)}finally{e.revisit.landed(t),e.changed&&(e.changed=!1,this.refresh(e,`change`))}}hold(e){return e.holders++,e.revisit.hold(!0),this.evict(),()=>{e.holders--,e.revisit.hold(e.holders>0),this.evict()}}evict(){for(let e of[...this.entries.values()]){if(this.entries.size<=this.spec.maxEntries)return;e.holders===0&&e.superseding===0&&this.drop(e)}}drop(e){this.entries.delete(e.key),this.abandon(e),e.unwatch(),e.revisit.dispose(),_j(e,L(`${this.spec.name} entry dropped`,`read`))}abandon(e){let t=e.flight;e.flight=null,t?.abort(Error(`${this.spec.name} read abandoned`))}};function Cj(e,t,n){if(e===null)return new wj(n.holdReturned);let r=new fj(n.period,t);return{landed:t=>r.landed(uj(e,t)),hold:e=>r.hold(e),dispose:()=>r.dispose()}}var wj=class{state=`released`;answered=!1;constructor(e){this.reread=e}landed(){this.answered=!0}hold(e){if(this.state===`disposed`)return;let t=e&&this.state===`released`&&this.answered;this.state=e?`held`:`released`,t&&this.reread()}dispose(){this.state=`disposed`}};function Tj(e){let t=e=>L(`read threw: ${String(e)}`,`read`);try{return e().catch(t)}catch(e){return Promise.resolve(t(e))}}const Ej=[`first`,`period`,`change`,`request`,`supersede`];var Dj=class{tallies=new Map;constructor(e=Pe){this.logger=e}declare(e){let t=`${e.scope}/${e.name}`,n=this.tallies.get(t)??{name:e.name,scope:e.scope,refreshes:{},failures:0,abandoned:0,lastMs:null};for(let t of e.refresh)n.refreshes[t]??=0;return this.tallies.set(t,n),new kj(n,this.logger)}snapshot(){return[...this.tallies.entries()].sort(([e],[t])=>e<t?-1:+(e>t)).map(([,e])=>({...e,refreshes:{...e.refreshes}}))}totals(){let e=Object.fromEntries(Ej.map(e=>[e,0]));for(let t of this.tallies.values())for(let n of Ej)e[n]+=t.refreshes[n]??0;return e}};const Oj={first:!0,period:!0,change:!0,request:!1,supersede:!0};var kj=class{constructor(e,t){this.tally=e,this.logger=t}record(){return{...this.tally,refreshes:{...this.tally.refreshes}}}recorded(e,t,n,r){this.tally.refreshes[t]=(this.tally.refreshes[t]??0)+1,this.tally.lastMs=r,n.kind===`failed`&&this.tally.failures++;let i=n.kind===`failed`;if(!i&&!Oj[t])return;let a=i?` reason=${JSON.stringify(n.reason)}`:``;this.logger(i?`warn`:`info`,`${this.tally.name} refresh ${e} by=${t} outcome=${n.kind}${a} took=${r}ms`)}abandoned(e,t,n){this.tally.abandoned++,this.logger(`info`,`${this.tally.name} refresh ${e} by=${t} abandoned took=${n}ms`)}};function Aj(e){return oe(`sha256`).update(JSON.stringify(jj(e))).digest(`hex`)}function jj(e){return Array.isArray(e)?e.map(jj):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,t])=>[e,jj(t)])):e}const Mj=/\r\n|\r|\n/g,Nj=e=>F(e.replace(Mj,` `).trim());function Pj(e){return t=>{let n=e.exec(t)?.[1];return n===void 0?L(`regex no-match`,`parse`):F(n.replace(Mj,` `))}}const Fj=e=>{try{return F(JSON.parse(e))}catch(e){return L(`JSON parse failed: ${e.message}`,`parse`)}},Ij=e=>Aj(e);function Lj(e){return ae.createHash(`sha256`).update(e).digest(`hex`)}const Rj=e=>e.kind===`shell`?`output of "${e.command}" in ${e.cwd}`:`"${e.path}"`;function zj(e,t,n,r){return{where:Rj({kind:`shell`,command:t,cwd:n}),read:async()=>{let i=await e.launch({bin:`/bin/sh`,args:[`-c`,t],cwd:n,category:`user-shell`,timeoutMs:1e4,signal:r});return i.ok?F(i.stdout):L(`shell "${t}" ${Ze(i,` in ${n}`)}`,`read`)}}}function Bj(e,t,n){return{where:Rj({kind:`file`,path:e,readMode:t}),read:async()=>{try{let r=await me(e,{encoding:`utf8`,signal:n});return F(t===`first-line`?r.split(/\r?\n/)[0]??``:r)}catch(t){let r=t.code??String(t);return L(n.aborted?`file read aborted: ${String(n.reason)}`:`file unreadable (${r}): ${e}`,`read`)}}}}function Vj(e,t,n){switch(t.kind){case`shell`:return zj(e,t.command,t.cwd,n);case`file`:return Bj(t.path,t.readMode,n)}}function Hj(e){switch(e.kind){case`text`:return Nj;case`regex`:return Pj(new RegExp(e.source,e.flags));case`json`:return e=>e.trim()===``?I:Fj(e)}}function Uj(e,t,n){if(e.kind!==`ok`)return e;let r=t(e.value);return r.kind===`failed`?L(`${r.reason} in ${n}`,r.failedAt):r}var Wj=class{entries=new Map;releaseDelivery;constructor(e,t){this.watchers=e,this.fileEvents=t,this.releaseDelivery=t.subscribe(e=>this.noticed(e))}subscribe(e,t,n){let r=this.entries.get(e)??this.arm(e);return r.subscribers.set(t,n),n(this.faultOf(e,r)),()=>this.unsubscribe(e,t)}arm(e){let t=Gj(e),n={bound:{derived:t,held:this.watchers.follow(null,t,t=>this.heard(e,n,t)).watch},subscribers:new Map};return this.entries.set(e,n),n}rederive(e,t){let n=Gj(e),{watch:r}=this.watchers.follow(t.bound.held,n,n=>this.heard(e,t,n));t.bound={derived:n,held:r},this.report(e,t)}heard(e,t,n){let r=t.bound.derived.reached;if(this.rederive(e,t),!(n.kind!==`failed`&&!r&&!t.bound.derived.reached))for(let e of t.subscribers.keys())e()}report(e,t){let n=this.faultOf(e,t);for(let e of t.subscribers.values())e(n)}faultOf(e,t){return rj(`watch_file ${e}`,t.bound,qc(this.fileEvents.delivery()))}noticed(e){switch(e.kind){case`period`:return;case`moved`:case`caught-up`:(0,Y.runInAction)(()=>{for(let[e,t]of this.entries){this.rederive(e,t);for(let e of t.subscribers.keys())e()}});return}}unsubscribe(e,t){let n=this.entries.get(e);n&&(n.subscribers.delete(t),n.subscribers.size===0&&(n.bound.held.handle.release(),this.entries.delete(e)))}dispose(){this.releaseDelivery();for(let e of this.entries.values())e.bound.held.handle.release();this.entries.clear()}size(){return this.entries.size}};const Gj=e=>nj({named:[e],whole:[e]});var Kj=class{byKind;watchMgr;faults=Y.observable.map(void 0,{deep:!1});constructor(e){let t=e.logger??Pe,n=e.ledger??new Dj(t);this.watchMgr=new Wj(e.watchers??new lj({clock:e.clock}),e.fileEvents??Hc);let r=r=>new Sj({name:`source.${r}`,scope:`daemon`,keyOf:Ij,fields:(e,t)=>`digest=${en(Ij(e))} where=${R(Rj(e.read))} sharedBy=${t}`,read:async(t,n)=>{let r=Vj(e.launcher,t.read,n);return Uj(await r.read(),Hj(t.parse),r.where)},every:({refresh:e})=>e.kind===`ttl`?{okMs:e.durationMs,failedMs:e.durationMs}:null,watch:(e,t)=>{if(e.refresh.kind!==`watch_file`)return xj();let n=Ij(e),r=this.watchMgr.subscribe(e.refresh.path,t,e=>(0,Y.runInAction)(()=>{e===null?this.faults.delete(n):this.faults.set(n,e)}));return()=>{r(),(0,Y.runInAction)(()=>this.faults.delete(n))}},maxEntries:0,logger:t,ledger:n,clock:e.clock});this.byKind={shell:r(`shell`),file:r(`file`)}}declare(e,t){let n=Ij(t),r=this.byKind[t.read.kind].declare(e,t);return{digest:n,current:()=>r.current(),fault:()=>this.faults.get(n)??null}}stats(){return{shell:this.byKind.shell.stats(),file:this.byKind.file.stats(),watches:this.watchMgr.size()}}close(){this.byKind.shell.close(),this.byKind.file.close(),this.watchMgr.dispose()}};function qj(e,t){return t.kind!==`ttl`||t.durationMs>=500?t:(k(`declareShell "${e}": ttl ${t.durationMs}ms below floor 500ms; clamping`),{kind:`ttl`,durationMs:500})}function Jj(e){let t=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/.exec(e);if(!t)throw RangeError(`Invalid duration: "${e}"`);let n=parseFloat(t[1]);switch(t[2]){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*6e4;case`h`:return n*36e5;default:throw RangeError(`Unexpected duration unit: "${t[2]}"`)}}const Yj=`session.id`;function Xj(e){switch(e.kind){case`text`:return{kind:`text`};case`regex`:return{kind:`regex`,source:e.regex.source,flags:e.regex.flags};case`json`:return{kind:`json`}}}const Zj={read:()=>Ao(`unread`),drawnAt:()=>{throw new wC(`colorCompatibility.effective`,`the drawn depth has no value yet: no view source is bound`)}},Qj=e=>({kind:`found`,value:e});function $j(e,t){let n=e,r=!1;for(let e of t.split(`.`)){if(!r&&jo(n))return n;if(typeof n!=`object`||!n)return Qj(void 0);r||=e===`value`&&n.kind===`ok`,n=n[e]}return!r&&jo(n)?n:Qj(n)}function eM(e,t){if(t.kind===`pending`)return t;let n=t.value;if(n===void 0)return L(`variable "${e}": the view's payload has no "${e}": its declaration did not take the source the config declares`,`read`);switch(typeof n==`object`&&n?n.kind:void 0){case`ok`:case`absent`:case`failed`:return n;default:return L(`variable "${e}": the view's payload holds no source reading at "${e}"`,`read`)}}function tM(e,t){if(typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`)throw TypeError(`Expected string|number|boolean from payload, got ${typeof e}`);return t===`string`?xC(e):t===`number`?SC(e):CC(e)}function nM(e){return e===`number`?0:e===`boolean`?!1:``}var rM=class e{lastErrors=new Map;policyFaults=Y.observable.map(void 0,{deep:!1});cleanups=[];holds=new QA;identities=new Map;lanes=Y.observable.map(void 0,{deep:!1});inputs=Y.observable.box(Zj,{deep:!1});drawnAt=()=>this.inputs.get().drawnAt();engine=qA({drawnAt:this.drawnAt});sourceNames=Y.observable.array([],{deep:!1});publishedNow=(0,Y.computed)(()=>({values:this.sourceNames.map(e=>this.store.stored(e)),faults:[...this.policyFaults.values()]}));published(){return this.publishedNow.get()}sessionState;constructor(e,t,n=``,r,i=null,a={}){this.runs=e,this.store=t,this.defaultEmptyValue=n,this.parent=i,this.env=a,this.sessionState=r}view(){return new e(this.runs,new RC(this.store.clock,this.store),this.defaultEmptyValue,this.sessionState,this,this.env)}get variableStore(){return this.store}declareLiteral(e,t){this.store.defineBox(e,bC(t),t)}declareFailedDocument(e,t){this.store.defineDocument(e,L(t,`parse`))}declareSourceDocument(e){this.store.defineDerivedDocument(e,()=>eM(e,this.inputs.get().read(e)))}own(e){this.cleanups.push(e)}declareInput(e,t,n,r,i){this.store.defineDerived(e,n,i,()=>this.inputAt(e,t,n,r))}inputAt(e,t,n,r){let i=this.inputs.get().read(t);if(i.kind===`pending`)throw this.lastErrors.delete(e),new wC(e,`variable "${e}" has no value yet: its source has not answered`);let a=i.value;if(a===void 0)return this.fallbackOf(e,n,r,`input path "${t}" not found in payload`);try{let t=tM(a,n);return this.lastErrors.delete(e),t}catch(t){return this.fallbackOf(e,n,r,t instanceof Error?t.message:String(t))}}declareEnv(e,t,n){let r=this.env[t];if(r!==void 0){this.store.defineBox(e,`string`,r);return}let i=n===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:n;this.store.defineBox(e,`string`,i),this.recordError(e,`env var "${t}" is not set`)}declareShell(e,t,n){this.declareSource(e,{kind:`shell`,command:t,cwd:n.cwd},qj(e,n.cache),n.parse)}declareFile(e,t,n){this.declareSource(e,{kind:`file`,path:t,readMode:n.readMode??`whole`},n.cache,n.parse)}declareSource(e,t,n,r){let i=this.publisherFor(e,r);(0,Y.runInAction)(()=>this.sourceNames.push(e)),this.cleanups.push((0,Y.reaction)(()=>this.lanes.get(e)?.current(),e=>{e===void 0||e.kind===`pending`||i(e)},{fireImmediately:!0})),this.registerCachePolicy(e,n,n=>this.hold(e,{read:t,parse:Xj(r),refresh:n}))}hold(e,t){this.identities.set(e,t);let{result:n}=this.holds.declare(()=>[...this.identities].map(([e,t])=>{let n=this.runs.declare(this.holds,t),r=this.lanes.get(e);return[e,r?.digest===n.digest?r:n]}));(0,Y.runInAction)(()=>{for(let[e,t]of n)this.lanes.set(e,t)})}publisherFor(e,t){switch(t.kind){case`text`:case`regex`:return this.scalarPublisher(e,t.default);case`json`:return this.documentPublisher(e,t.default)}}scalarPublisher(e,t){let n=this.stringInitial(t);return this.store.defineBox(e,`string`,n),t=>{this.noteOutcome(e,t),this.store.setBox(e,Oo(t,n))}}documentPublisher(e,t){let n=t===void 0?Ao(`unread`):F(t);this.store.defineDocument(e,n);let r,i=!1;return this.cleanups.push(()=>r?.()),a=>{r?.();let o=a;this.noteOutcome(e,o);let s=o.kind===`ok`||o.kind===`failed`&&o.failedAt===`parse`,c=s||t===void 0?o:n,l=i&&s&&o.kind!==`ok`,u=()=>{i=o.kind===`ok`,this.store.setDocument(e,c)};l?r=this.store.clock.after(250,u):u()}}async inFlight(e){for(;!e.aborted&&this.awaited().length>0;)try{await(0,Y.when)(()=>this.awaited().length===0,{signal:e})}catch(t){if(!e.aborted)throw t}return this.awaited()}awaited(){return[...[...this.lanes].filter(([,e])=>e.current().kind===`pending`).map(([e])=>e),...this.parent?.awaited()??[]]}settled(e){return this.inFlight(Re(this.store.clock,e))}declareTemplate(e,t,n){let r=this.engine.parse(t);this.declareDerived(e,n.type,n.derivation,()=>r.evaluate(JA(this.store)).map(e=>e.plain).join(``),n.varDefault)}declareTime(e,t){let n=this.engine.parse(`{{ date .layout now }}`),r={layout:t.format};this.declareDerived(e,`string`,`projection`,()=>n.evaluate(r).map(e=>e.plain).join(``),t.varDefault)}declareDerived(e,t,n,r,i){this.store.defineDerived(e,t,n,()=>{try{let n=tM(r(),t);return this.lastErrors.delete(e),n}catch(t){let n=TC(t);if(n!==void 0)throw this.lastErrors.delete(e),n;let r=t instanceof Error?t.message:String(t);if(this.recordError(e,r),i===void 0)throw Error(`variable "${e}": ${r}`);return i}})}declareState(e,t){if(!this.sessionState)throw Error(`declareState("${e}"): SourceRegistry was constructed without a SessionState — state-kind variables require a SessionState (the daemon provides one; tests must supply one)`);let n=this.sessionState,r=t.varDefault??this.stringInitial(void 0);this.store.defineComputed(e,`string`,e=>{let i=e(Yj);if(typeof i!=`string`||!i)return r;let a=n.get(i,t.key);return a===null?r:a})}stateRevision(){let e=this.store.has(`session.id`)?this.store.read(Yj):``;return this.sessionState!==void 0&&typeof e==`string`&&e!==``?this.sessionState.revision(e):0}bindInputs(e){(0,Y.runInAction)(()=>this.inputs.set(e))}getLastError(e){if(!this.declaredHere(e))return this.parent?.getLastError(e);let t=this.lastErrors.get(e),n=this.policyFaults.get(e);return n===void 0?t:t===void 0?n:{timestamp:t.timestamp,message:`${n.message}; ${t.message}`}}cachePolicyFaults(){return new Map([...this.parent?.cachePolicyFaults()??[],...this.policyFaults])}declaredHere(e){return this.store.has(e)&&!(this.parent?.store.has(e)??!1)}dispose(){for(let e of this.cleanups)e();return this.cleanups.length=0,this.holds.close(),this.store.dispose()}registerCachePolicy(e,t,n){switch(t.kind){case`never`:n({kind:`never`});break;case`ttl`:n({kind:`ttl`,durationMs:t.durationMs});break;case`watch_file`:n({kind:`watch_file`,path:t.path}),this.cleanups.push((0,Y.reaction)(()=>this.lanes.get(e)?.fault()??null,t=>this.notePolicy(e,t===null?F(void 0):L(t,`read`)),{fireImmediately:!0}));break;case`key`:{let r=this.engine.parse(t.template);this.onReads(e,()=>{try{return F(r.evaluate(JA(this.store)).map(e=>e.plain).join(``))}catch(e){return TC(e)===void 0?L(`cache key: ${e instanceof Error?e.message:String(e)}`,`read`):Ao(`unread`)}},e=>n({kind:`key`,hash:Lj(e)}));break}case`depends_on`:this.onReads(e,()=>{let e=t.varNames.map(e=>this.store.changeKey(e));return e.every(e=>e.kind===`ok`)?F(e.map(e=>e.value).join(`,`)):Ao(`unread`)},e=>n({kind:`key`,hash:Lj(e)}));break}}onReads(e,t,n){let r,i=(0,Y.reaction)(t,t=>{this.notePolicy(e,t),!(t.kind!==`ok`||t.value===r)&&(r=t.value,n(t.value))},{fireImmediately:!0});this.cleanups.push(i)}fallbackOf(e,t,n,r){if(this.recordError(e,r),n!==void 0)return n;try{return tM(this.defaultEmptyValue,t)}catch{return nM(t)}}stringInitial(e){return e===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:e}recordError(e,t){this.lastErrors.set(e,{timestamp:this.store.clock.now(),message:t})}notePolicy(e,t){(0,Y.runInAction)(()=>{t.kind===`failed`?this.policyFaults.get(e)?.message!==t.reason&&this.policyFaults.set(e,{timestamp:this.store.clock.now(),message:t.reason}):this.policyFaults.delete(e)})}noteOutcome(e,t){t.kind===`ok`?this.lastErrors.delete(e):this.recordError(e,t.kind===`failed`?t.reason:`no value`)}};function iM(e,t){let n=wx[e],r=Ax(e),i=n.kind===`session`||n.kind===`config`?n.floor:``;return r===`string`?{kind:`input`,path:t,default:``}:{kind:`input`,path:t,type:r,default:i}}const aM=Object.fromEntries([...Ix].map(([e,t])=>[t,iM(e,t)])),oM={subscribers:`number`,fps:`number`,shown:`boolean`},sM=Object.keys(oM),cM={project_dir:{kind:`input`,path:`workspace.project_dir`,default:``},[Yj]:{kind:`input`,path:`session_id`,default:``},transcript_path:{kind:`input`,path:`transcript_path`,default:``},resume_command:{kind:`input`,path:`resumeCommand`,default:``},config_path:{kind:`input`,path:`configPath`,default:``},...aM,"preset.customized":{kind:`input`,path:`preset.customized`,type:`boolean`,default:!1},"preset.bundled":{kind:`input`,path:`preset.bundled`,type:`boolean`,default:!0},...Object.fromEntries(Zb.flatMap(e=>sM.map(t=>[nx(e,t),{kind:`input`,path:nx(e,t),type:oM[t],default:tx[t]}]))),[ex(`by`)]:{kind:`input`,path:ex(`by`),default:$b.by},[ex(`fps`)]:{kind:`input`,path:ex(`fps`),type:`number`,default:0},...Object.fromEntries([`label`,`fg`,`bg`,`open`].map(e=>[`diagnostics.${e}`,{kind:`input`,path:`diagnostics.${e}`,default:``}])),"term.cols":{kind:`input`,path:`term.cols`,type:`number`,default:80},"tmux.pane":{kind:`input`,path:`tmux.pane`,default:``},"autocompact.window":{kind:`input`,path:`autocompact.window`,type:`number`,default:-1},...Object.fromEntries([`applied`,`lower`,`higher`].map(e=>[`autocompact.${e}`,{kind:`input`,path:`autocompact.${e}`,type:`number`,default:0}])),"autocompact.error":{kind:`input`,path:`autocompact.error`,default:``},"location.main":{kind:`input`,path:`location.main`,default:``},"location.worktree":{kind:`input`,path:`location.worktree`,default:``},"location.subpath":{kind:`input`,path:`location.subpath`,default:``},"location.noRepo":{kind:`input`,path:`location.noRepo`,type:`boolean`,default:!1},"git.repoUrl":{kind:`input`,path:`git.repoUrl`,default:``}},lM={today:`the day the draw is at`,feeds:`the frames a lane was sent up to the draw's instant`,drawing:`who the draw is for`,diagnostics:`the errors and warnings the draw owes its reader`};function uM(e){let t=e.split(`.`,1)[0];return Object.hasOwn(lM,t)?t:void 0}const dM=Object.fromEntries(Xv.map(e=>[e,Ix.get(e)]));function fM(e){return Xv.find(t=>dM[t]===e)}function pM(e,t,n){let r=new Set,i=(e,t=n)=>{for(let n of XS(e??``,t).keys())r.add(n)};for(let t of Object.values(e.segments)){let e=t.partials===void 0?n:{...n,...t.partials};i(t.template,e),i(t.bg,e),i(t.fg,e),i(t.when,e);for(let n of Object.values(t.partials??{}))i(n,e)}for(let e of t)for(let t of Ny(e))i(t.when),t.kind===`segment`&&(i(t.lead),i(t.trail));for(let t of Object.values(e.variables))t.kind===`template`&&i(t.template),t.kind===`state`&&r.add(Yj);for(let t of Object.values(e.actions)){r.add(Yj);for(let[,e]of ES(t))i(e);let e=`set`in t?Lx.get(t.set):void 0,n=`persist`in t?Ix.get(t.persist):void 0;e!==void 0&&r.add(e),n!==void 0&&r.add(n)}return r}function mM(e,t,n){let r=mC({...n,variables:{...n.variables,...e.variables},segments:{...n.segments,...e.segments}}),i={};for(let a of pM(e,t,n.helpers)){if(pC(a,r))continue;let e=cM[a];if(e===void 0)throw Error(`synthesized chrome reads ".${a}", which it does not declare and PAYLOAD_INPUTS does not supply`);i[a]=e}return i}function hM(e){return e.replace(/[^A-Za-z0-9]+/g,`_`)}function gM(e){return e}function _M(e,t,n){return n===void 0?Mi+hM(e)+`.`+hM(t):vM(n)}function vM(e){return Mi+hM(e)}function yM(e,t){return e+`.`+t}function bM(e){return Ni+e}const xM=[`closeOnPick`,`paged`,`key`,`distribution`],SM=e=>xM.includes(e),CM=`"closeOnPick" (bool, default false), "paged" (bool, default true), "key" (string, accordion grouping), "distribution" (one of ${$_.map(e=>`"${e}"`).join(`, `)}; default "van-der-corput")`;function wM(e){for(let t of Object.keys(e))if(!SM(t))throw Error(`unknown {{ menu }} option "${t}" — the options dict takes ${CM}`);let t=(t,n)=>{let r=e[t];if(r===void 0)return n;if(typeof r!=`boolean`)throw Error(`{{ menu }} option "${t}" must be a boolean, got ${JSON.stringify(r)} (e.g. (dict "${t}" ${String(!n)}))`);return r},n=e.key;if(n!==void 0&&typeof n!=`string`)throw Error(`{{ menu }} option "key" must be a string naming the accordion group, got ${JSON.stringify(n)}`);if(n===``)throw Error(`{{ menu }} has an empty accordion key — a shared key must be a non-empty name (or omit "key" for an independent menu)`);let r=e.distribution;if(r!==void 0&&!ev(r))throw Error(`{{ menu }} option "distribution" must be one of: ${$_.join(`, `)}; got ${JSON.stringify(r)}`);return{closeOnPick:t(`closeOnPick`,!1),paged:t(`paged`,!0),key:n,distribution:nv(r)}}const TM=e=>`from`in e?e.from:e.themes;function EM(e,t,n){return e===`bool`?Ty(t)!==null:`min`in e?Ey(t,e)!==null:xS(TM(e),n).members.includes(t)}function DM(e,t){if(e===`bool`)return Cy.join(` or `);if(!(`min`in e)){let n=TM(e),{members:r}=xS(n,t),i=r.map(e=>JSON.stringify(e));if(r.length<=8)return`one of ${i.join(`, `)}`;let a=typeof n==`string`?` "${n}"`:``;return`one of the ${r.length}${a} names, such as ${i.slice(0,3).join(`, `)}`}return`an integer from ${e.min} to ${e.max}`}function OM(e){return{label:e.label,domain:kM(e.domain)}}function kM(e){return e===`theme`?{themes:vS}:e===`bool`||`min`in e?e:{from:e}}function AM(e,t,n,r,i){let a=xi(e.label),{domain:o}=e;if(o===`bool`)return{kind:`inline`,template:`{{ action "${r}" "☑ ${a}" "☐ ${a}" }}`,actions:{[r]:{set:t,cycle:[...Cy]}},variables:{}};if(`from`in o)return jM(t,r,i,o.from,e=>({template:`{{ carousel "${e.apply}" "${e.open}" "${a}" }}`,rows:[`{{ picker "${e.apply}" "${e.page}" false true true }}`]}));if(`themes`in o)return jM(t,r,i,o.themes,e=>({template:`{{ action "${e.open}" "${a}" .${n} }} {{ action "${e.open}" (swatch "${e.apply}") }}`,rows:[`{{ swatches "${e.apply}" "${e.page}" }}`,`{{ themePreview "${e.apply}" }}`]}));let s=e=>({set:t,min:o.min,max:o.max,by:e});return{kind:`inline`,template:`{{ action "${r}.down" "◀" }} {{ "${a}" }} {{ .${n} }} {{ action "${r}.up" "▶" }}`,actions:{[`${r}.down`]:s(-o.step),[`${r}.up`]:s(o.step)},variables:{}}}function jM(e,t,n,r,i){let a={variable:n,key:n,member:t},o=yM(n,t),s=`${t}.open`,c=bM(n),l=`${c}.current`,{template:u,rows:d}=i({apply:t,open:s,page:c});return{kind:`picker`,template:u,actions:{[t]:{set:e,from:r},[o]:ki(n,t),[c]:{set:c,int:!0},[l]:{set:c,to:`-1`},[s]:{do:[o,l]}},variables:{[n]:Oi(n,gi),[c]:{kind:`state`,key:c,default:`0`}},list:{ref:a,rows:d}}}const MM=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],NM=Object.fromEntries(MM.map(e=>[e.member,e.label])),PM={gear:{beside:`theme`,trigger:`⚙`},toggles:{beside:`updateNotice`,trigger:`🧪 toggles`}},FM=Object.keys(PM),IM=Rx(e=>Mx[e].place),LM=e=>Object.hasOwn(PM,e),RM=(e,t)=>e===t||LM(e)&&RM(IM[PM[e].beside],t),zM=e=>LM(e)?`${zM(IM[PM[e].beside])} › ${PM[e].trigger}`:e===`door`?`first line`:NM[e],BM=e=>zM(IM[e]),VM=()=>[`door`,...MM.map(e=>e.member)].flatMap(e=>[e,...FM.filter(t=>RM(t,e))]).map(e=>({path:zM(e),names:Nx.filter(t=>IM[t]===e)})).filter(({names:e})=>e.length>0),HM=e=>{let{setting:t,on:n,inTmux:r}=Xb[e].switch;return`${Xb[e].label} is off — turn it on in the settings menu's ${BM(t)}, or set globals.${t}: ${JSON.stringify(n)}${r?`; it runs only for a session inside a tmux pane`:``}`},UM=Object.fromEntries(Object.entries(wx).map(([e,t])=>[e,t.spec]));function WM(e){return GM(wx[e])}function GM(e){return`optionDomain`in e&&e.optionDomain!==void 0?{from:e.optionDomain.name}:e.domain}function KM(e,t){return{required:!1,json:{not:{},description:`not allowed here — ${e}`},parse:(e,n,r,i)=>{i[r]!==void 0&&e.issues.push({path:`${n}.${r}`,message:t(`${n}.${r}`),line:q(e.source,[...n.split(`.`),r])})}}}function qM(e){return KM(`${e} cannot select a preset`,t=>`${t}: ${e} cannot select a preset. Which preset is active is resolved once, as session pick over globals.preset over "default"; a fragment naming another would be a second authority over that. Set the default arrangement in the top-level globals.preset instead.`)}function JM(e){return KM(`${e} cannot change the settings menu glyph`,t=>`${t}: ${e} cannot change the settings menu glyph — one menu is shared by every preset. Set it in the top-level globals.menuGlyph instead.`)}function YM(e,t,n){return{...e,json:{...e.json,not:{pattern:`\\{\\{`}},parse:(r,i,a,o)=>{let s=o[a];if(typeof s==`string`&&Zv(s)){r.issues.push({path:`${i}.${a}`,message:`${i}.${a}: a rule is not allowed here — ${t} ${n}, so it names a value. Write the rule in globals.${a} (or a preset's globals.${a}) instead.`,line:q(r.source,[...i.split(`.`),a])});return}return e.parse(r,i,a,o)}}}const XM={default_bg:"nothing reads it — a segment with no `bg:` wears the decoration tint of its place in the bar. Delete the key, and author `bg:` on the segments that need a fixed colour.",default_fg:"nothing reads it — a segment with no `fg:` wears text chosen for contrast against its background. Delete the key, and author `fg:` on the segments that need a fixed colour.",default_truncate_marker:'nothing reads it — a segment clipped to its `width:` always ends in "…". Delete the key.',look:`it was renamed "style" — write the same name as style: "<name>"`,progression:`it was renamed "variation", and its values with it: accent (was secondary-accent), duo (was primary-secondary), mono (was primary)`,experimentalTmuxStatus:`it became the renderer setting — write renderer: "tmux" (or pick tmux in ${BM(`renderer`)} › renderer, from a session inside tmux)`,charset:"the bar always draws Nerd Font glyphs. Delete the key; `cc-candybar doctor` names what your terminal's font is missing."},ZM={noun:`globals key`,fields:UM,removed:XM},QM={preset:qM(`a preset`),menuGlyph:JM(`a preset`)},$M={noun:`preset globals key`,fields:{...UM,...QM},removed:XM};function eN(e){return uN(e)&&!(e in QM)}const tN=`is decided later than any rule could be settled`,nN={noun:`editGlobals key`,removed:XM,fields:{...UM,preset:qM(`the editGlobals fragment`),menuGlyph:JM(`the editGlobals fragment`),palette:YM(UM.palette,`the editGlobals fragment`,tN),style:YM(UM.style,`the editGlobals fragment`,tN),effect:YM(UM.effect,`the editGlobals fragment`,tN)}},rN={noun:`theme default key`,fields:{...Object.fromEntries(Dx.map(e=>[e,UM[e]])),style:YM(UM.style,`a theme's default`,`is the look that theme wears by name`)}};function iN(e,t){if(!xb(t))return e.issues.push({path:`themeDefaults`,message:`themeDefaults must be an object mapping theme names to { shade, variation, style }, got ${Sb(t)}`,line:q(e.source,[`themeDefaults`])}),{};let n={};for(let[r,i]of Object.entries(t)){let t=`themeDefaults.${r}`;if(!e.allowedPalettes.has(r)){e.issues.push({path:t,message:`${t}: "${r}" is not an installed theme${Hv(r)}. Expected one of: ${[...e.allowedPalettes].sort().join(`, `)}`,line:q(e.source,[`themeDefaults`,r])});continue}let a=Cb(e,rN,t,i);a!==null&&(n[r]=a)}return n}function aN(e,t,n){return n===void 0?{}:Cb(e,ZM,t,n)??{}}function oN(e,t,n){return Cb(e,$M,t,n)??{}}function sN(){return Wb($M)}function cN(e,t,n){return Cb(e,nN,t,n)??{}}const lN=new Set(Object.keys(UM));function uN(e){return lN.has(e)}function dN(e){return Object.hasOwn(XM,e)?XM[e]:void 0}function fN(){return[...lN]}const pN=new Map(Object.entries(wx).flatMap(([e,t])=>`floor`in t&&typeof t.floor==`number`?[[e,t.floor]]:[]));function mN(e){let t=new Map;for(let[n,r]of pN){let i=e[n];t.set(n,typeof i==`number`?i:r)}return t}const hN=/^segments\.([^.]+)\.palette$/,gN=/^presets\.(.+)\.root$/,_N=/^presets\.(.+)\.globals\.([^.]+)$/,vN=/^themeDefaults\.(.+)\.([^.]+)$/;function yN(e){return`presets.${e}.root`}function bN(e,t){return`themeDefaults.${e}.${t}`}const xN=e=>Dx.includes(e);function SN(e,t){return`presets.${e}.globals.${t}`}function CN(e){if(uN(e))return{scope:`globals`,field:e};let t=hN.exec(e);if(t)return{scope:`segment-palette`,segment:t[1]};let n=_N.exec(e);if(n&&eN(n[2]))return{scope:`preset-globals`,preset:n[1],field:n[2]};let r=vN.exec(e);if(r&&xN(r[2]))return{scope:`theme-default`,theme:r[1],field:r[2]};let i=gN.exec(e);return i?{scope:`preset-root`,preset:i[1]}:null}function wN(e){switch(e.scope){case`globals`:return[`globals`,e.field];case`preset-globals`:return[`presets`,e.preset,`globals`,e.field];case`segment-palette`:return[`segments`,e.segment,`palette`];case`theme-default`:return[`themeDefaults`,e.theme,e.field]}}const TN=[`location`,`git`,`model-context`,`cost-limits`,`activity`,`session-tools`],EN=[...TN,`other`],DN={location:`location`,git:`git`,"model-context":`model & context`,"cost-limits":`cost & limits`,activity:`activity`,"session-tools":`session tools`,other:`other`},ON=jT({fromString:e=>e});function kN(e){let t=hM(e);return Fi.find(e=>t.startsWith(hM(e)))}function AN(e,t,n,r){for(let i of[`variables`,`actions`,`segments`])for(let a of Object.keys(t[i]??{}))a.startsWith(n)&&e.issues.push({path:`${i}.${a}`,message:`"${a}" is in the reserved "${n}" namespace (synthesized by ${r}) — rename it`,line:q(e.source,[`root`])})}function jN(e,t,n){for(let r of[`variables`,`actions`,`helpers`,`segments`])for(let i of Object.keys(t[r]??{})){let t=NS(i);t!==void 0&&(r!==`variables`&&i===t||r===`segments`&&n.has(i)||e.issues.push({path:`${r}.${i}`,message:`"${i}" is in "${t}", the namespace plugins own (each declares its names there from its own definition) — rename it`,line:q(e.source,[r,i])}))}for(let[r,i]of Object.entries(t.segments??{}))for(let t of Object.keys(i.vars??{})){let i=`${r}.${t}`,a=NS(i);a===void 0||n.has(r)||e.issues.push({path:`segments.${r}.vars.${t}`,message:`segment "${r}"'s var "${t}" is named "${i}", in "${a}", the namespace plugins own — rename the var or the segment`,line:q(e.source,[`segments`,r,`vars`,t])})}}const MN=`edit.mode`,NN=`edit.configure`,PN=`edit.toggle`,FN=`arrange`,IN=`${Pi}draft.`;function LN(e,t){return`${e}:${t}`}const RN={variable:MN,key:MN,member:FN},zN=Ci(RN);function BN(e){try{return ON.parse(e).referencedCalls().some(e=>e.name===`action`&&e.args[0]===`edit.toggle`)}catch{return!1}}function VN(e){if(Object.values(e.actions??{}).some(e=>`do`in e&&e.do.includes(`edit.toggle`)))return!0;for(let t of Object.values(e.segments??{})){let e=[t.template,t.bg,t.fg,...Object.values(t.partials??{})];for(let t of e)if(typeof t==`string`&&BN(t))return!0}return!1}function HN(e,t){if(AN(e,t,Pi,`edit mode`),!VN(t))return;let{variables:n,actions:r}=UN();t.variables={...t.variables??{},...n},t.actions={...t.actions??{},...r}}function UN(){return{variables:{[MN]:{...Oi(MN,gi),within:[zi]},[NN]:{...Oi(NN,gi),within:[RN]}},actions:{[PN]:ki(MN,FN),"edit.unconfigure":{set:NN,to:gi}}}}function WN(e,t,n,r){let i={variable:e,key:e,member:_i};return r.variables[e]={...Oi(e,gi),...n.length>0&&{within:n}},r.actions[e]=ki(e,_i),r.segments[e]={template:Ti(e,`(?)`,`✕`),...GN(n)},Si(e,i,{kind:`container`,direction:`horizontal`,children:t.map((t,n)=>{let i=`${e}.${n}`;return r.segments[i]={template:t},{kind:`segment`,name:i}})},`drop`)}function GN(e){let[t,...n]=e;return t===void 0?{}:{when:Ci(t,...n)}}const KN=`none`;function qN(e){return Bu(e,`background`)}var JN=class extends Error{constructor(e,t,n){super(`Invalid ${t} color ${JSON.stringify(e)}: ${n}`),this.name=`ColorSpecError`}};function YN(e,t,n,r,i){let{palette:a,tint:o,text:s}=e,c=XN(n,i),l=c!==KN,u=l?c===void 0?o:ZN(a,c,`bg`):qN(a);e.bg=u;let d=XN(r,i),f=d===void 0?l?(e=>e.hex===o.hex?s:vv(a,e,t))(u):void 0:ZN(a,d,`fg`);return new U({...l&&{bgcolor:H.fromRgba(u)},...f!==void 0&&{color:H.fromRgba(f)}})}function XN(e,t){if(e!==void 0)return e.evaluate(t).map(e=>e.plain).join(``)}function ZN(e,t,n){try{return Bu(e,t)}catch(e){throw e instanceof zu?new JN(t,n,e.message):e}}const QN=`🔧`,$N={help:[`-h`,`--help`],version:[`-V`,`--version`]},eP=[...new Set(Object.values(Xb).map(e=>BM(e.switch.setting)))].join(` or `),tP=Math.max(...Object.values(Mx).map(e=>e.configKey.length))+2,nP=[`✚ inserts`,`✖ removes`,`${QN} configures`,`↺ resets layout`],rP={band:[`animates the bar in the band above the prompt, through a Claude Code mod`,`on: installs the candybar-band mod from this checkout and types /reload-plugins`],statusline:[`animates the statusline itself, through the attach launcher shipped with cc-candybar`,`on: exits this Claude Code and starts it again under that launcher, on this session`,`or start one yourself: cc-candybar --help prints the line to type`],pane:[`animates the bar in a tmux pane under this session's`,`on: opens that pane · off: closes it`],tmuxStatus:[`draws the bar in the tmux status line, while this session's pane is the one it shows`,`tmux: the daemon draws it there · claude: puts the status line back as it was`]},iP=`
70
+ `)){let n=``;for(let i of t.split(/\s+/))i.length!==0&&(n.length===0?n=i:n.length+1+i.length<=e?n+=` ${i}`:(r.push(n),n=i));n.length>0&&r.push(n)}return r.join(t)}function Pk(e,t,n){return Nk(e,t,n)}function Fk(){return{abbrev:{fn:(e,t)=>NO(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},abbrevboth:{fn:(e,t,n)=>PO(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},camelcase:{fn:e=>XO(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},cat:{fn:(...e)=>ZO(...e),argTypes:[`string`],arity:{kind:`variadic`}},contains:{fn:(e,t)=>QO(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasPrefix:{fn:(e,t)=>$O(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasSuffix:{fn:(e,t)=>ek(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},indent:{fn:(e,t)=>tk(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},initials:{fn:e=>nk(e),argTypes:[`string`],arity:{kind:`exact`}},join:{fn:(e,t)=>rk(e,t),argTypes:[`string`,`list`],arity:{kind:`exact`}},kebabcase:{fn:e=>ak(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},lower:{fn:e=>ok(e),argTypes:[`string`],arity:{kind:`exact`}},nindent:{fn:(e,t)=>sk(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},nospace:{fn:e=>ck(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},plural:{fn:(e,t,n)=>lk(e,t,n),argTypes:[`string`,`string`,`int`],arity:{kind:`exact`},returnType:`string`},quote:{fn:(...e)=>uk(...e),argTypes:[`string`],arity:{kind:`variadic`}},regexQuoteMeta:{fn:e=>dk(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},repeat:{fn:(e,t)=>fk(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},replace:{fn:(e,t,n)=>pk(e,t,n),argTypes:[`string`,`string`,`string`],arity:{kind:`exact`}},snakecase:{fn:e=>mk(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},split:{fn:(e,t)=>hk(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitList:{fn:(e,t)=>gk(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitn:{fn:(e,t,n)=>_k(e,t,n),argTypes:[`string`,`int`,`string`],arity:{kind:`exact`},returnType:`dict`},squote:{fn:(...e)=>yk(...e),argTypes:[`string`],arity:{kind:`variadic`}},substr:{fn:(e,t,n)=>bk(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},swapcase:{fn:e=>xk(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},title:{fn:e=>wk(e),argTypes:[`string`],arity:{kind:`exact`}},trim:{fn:e=>Tk(e),argTypes:[`string`],arity:{kind:`exact`}},trimAll:{fn:(e,t)=>Ek(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimPrefix:{fn:(e,t)=>Dk(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimSuffix:{fn:(e,t)=>Ok(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trunc:{fn:(e,t)=>kk(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},untitle:{fn:e=>Ak(e),argTypes:[`string`],arity:{kind:`exact`}},upper:{fn:e=>jk(e),argTypes:[`string`],arity:{kind:`exact`}},wrap:{fn:(e,t)=>Mk(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},wrapWith:{fn:(e,t,n)=>Pk(e,t,n),argTypes:[`int`,`string`,`string`],arity:{kind:`exact`}}}}function Ik(e,t){let n=Lk(e),r=n.copy();return r.style=kf(n.style,t),r}function Lk(e){if(!(e instanceof K))throw TypeError(`template function expected a RichText fragment, got ${typeof e==`object`?Object.prototype.toString.call(e):typeof e}`);return e}function Rk(e){return{fn:(t=>Ik(t,e)),argTypes:[`liftable`],arity:{kind:`exact`},returnType:`T`}}function zk(e){return{fn:((t,n)=>Ik(n,new U({[e]:H.parse(t)}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`}}function Bk(e,t){return new U({[e]:t})}function Vk(){let e={};for(let t of xf)e[t]=Rk(Bk(t,!0)),e[`not_${t}`]=Rk(Bk(t,!1));for(let[t,n]of Object.entries(Cf))e[t]=Rk(Bk(n,!0));return e}const Hk={fn:((e,t)=>Ik(t,U.parse(e))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`},Uk={fn:((e,t)=>Ik(t,new U({link:e}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`};function Wk(){return{fg:zk(`color`),bg:zk(`bgcolor`),...Vk(),link:Uk,style:Hk}}function Gk(e,t){let n;try{n=iu(e.trim())}catch(n){throw n instanceof Bl?TypeError(`${t} expected a color (#RRGGBB or #RRGGBBAA), got ${JSON.stringify(e)} — to use a palette name here, wrap it: ${t} (color ${JSON.stringify(e)}) …`,{cause:n}):n}return Kk(n,t,JSON.stringify(e))}function Kk(e,t,n){if(e.alpha===0)throw RangeError(`${t} got ${n}, which is fully transparent: it draws no colour of its own, so there is nothing to compute with — use the colour of the surface it sits on, e.g. (color "background")`);return e}function qk(e,t){return{fn:t,argTypes:e,arity:{kind:`exact`},returnType:`string`}}function Jk(e,t,n,r){let i=r===void 0||e>=r.min&&e<=r.max;if(!Number.isFinite(e)||!i){let i=r===void 0?`a finite number`:`within ${r.min}..${r.max} (${r.note})`;throw RangeError(`${t}'s ${n} must be ${i}, got ${e}`)}return e}const Yk=qk([`string`,`int`],((e,t)=>Ku(Gk(e,`darken`),t).hex)),Xk=qk([`string`,`int`],((e,t)=>Ku(Gk(e,`lighten`),-t).hex)),Zk={min:0,max:100,note:`0 = from, 100 = toward`},Qk=qk([`string`,`string`,`float`],((e,t,n)=>au(Gk(e,`mix`),Gk(t,`mix`),Jk(n,`mix`,`percentage`,Zk)/100).hex)),$k={min:1,max:21,note:`4.5 = AA body text, 3 = AA large text`},eA=qk([`string`],(e=>Zu(Gk(e,`contrastOn`)).hex)),tA={depth:V.TRUECOLOR},nA=e=>qk([`string`,`string`,`float`],((t,n,r)=>{let{depth:i,terminal:a}=e();return Qu(Gk(t,`readableOn`),Gk(n,`readableOn`),Jk(r,`readableOn`,`ratio`,$k),i,void 0,a).hex})),rA={hueShift:`shiftHue`,chromaScale:`scaleChroma`,lightnessScale:`scaleLightness`,lightnessShift:`shiftLightness`};function iA(){let e={};for(let[t,n]of Object.entries(rA)){let r=t;e[n]=qk([`string`,`float`],((e,t)=>{let i={...wu,[r]:Jk(t,n,`amount`)};return Iu.fromRgba(Gk(e,n)).applyKey(i).toRgba().hex}))}return e}function aA(e=()=>tA){return{darken:Yk,lighten:Xk,mix:Qk,contrastOn:eA,readableOn:nA(e),...iA()}}function oA(e,t){if(e.length%2!=0)throw RangeError(`ramp's last stop (position ${String(e[e.length-1])}) has no color — stops are <position> <color> pairs`);let n=[];for(let r=0;r<e.length;r+=2)n.push({at:e[r],color:Kk(Bu(t,e[r+1]),`ramp`,JSON.stringify(e[r+1]))});return n}function sA(e){return{color:{fn:(t=>Bu(e(),t).hex),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},ramp:{fn:((t,n,...r)=>new Sp(af(n),oA(r,e())).at(t).hex),argTypes:[`float`,`string`],arity:{kind:`alternating`,minimum:4},returnType:`string`}}}const cA=kp.play(0);function lA(e,t,n){if(t.length%2!=0)throw RangeError(`last hold (${String(t[t.length-1])} s) has no ${e} — the arguments are <seconds> <${e}> pairs`);let r=[];for(let e=0;e<t.length;e+=2){let i=t[e];if(!Number.isFinite(i)||i<=0)throw RangeError(`hold ${e/2} must be a positive number of seconds, got ${i}`);r.push({seconds:i,value:n(t[e+1])})}return r}const uA={...s_.loops,typewriter:e=>s_.transitions.typewriter(e).effect,scramble:e=>s_.transitions.scramble(e).effect,backspace:e=>s_.transitions.backspace(e).effect,scrambleOut:e=>s_.transitions.scrambleOut(e).effect};function dA(e){if(!Object.hasOwn(uA,e))throw RangeError(`unknown glyph effect ${JSON.stringify(e)}; expected one of ${Object.keys(uA).map(e=>JSON.stringify(e)).join(`, `)}`);return uA[e]}function fA(e,t={}){let n=t.timeline??(()=>cA),r=(e,t,r)=>[kp.run(n(),t),lf(e,r.time)],i=(t,n)=>{let i=e(),[a,o]=r(t,n,i),s=dp(a,o,i);return i.onHold?.(fp(s,o)),s.value},a=(e,t)=>kp.run(kp.play(e),t);return{frames:{fn:((...t)=>{let n=lA(`frame`,t,Lk).map(({seconds:e,value:t})=>({seconds:e,text:t})),i=e();return l_(...r(`frames`,new c_(n),i),i)}),argTypes:[`float`,`liftable`],arity:{kind:`alternating`,minimum:2},returnType:`T`},stepped:{fn:((...e)=>{let t=lA(`color`,e,e=>Gk(e,`stepped`));return t[i(`stepped`,gf(t.map(e=>e.seconds)))].value.hex}),argTypes:[`float`,`string`],arity:{kind:`alternating`,minimum:2},returnType:`string`},tween:{fn:((e,t,n,r,o)=>i(`tween`,a(n,xp(r,o,{seconds:e,ease:af(t)})))),argTypes:[`float`,`string`,`float`,`float`,`float`],arity:{kind:`exact`},returnType:`float`},loop:{fn:((e,t)=>i(`loop`,a(t,G.continuous(_f.loop(e))))),argTypes:[`float`,`float`],arity:{kind:`exact`},returnType:`float`},glyphs:{fn:((t,n,i)=>{let o=dA(t),s=Lk(i),c=s.plain,l=e();return l_(...r(`glyphs`,a(n,zg(s,o({z:hh(c,0,0)}),{key:c,asciiOnly:l.asciiOnly===!0})),l),l)}),argTypes:[`string`,`float`,`liftable`],arity:{kind:`exact`},returnType:`T`}}}function pA(e){return{...Wk(),...aA(e)}}new U({color:`red`,dim:!0});const mA=/^(?:(?:global|apac|au|eu|us|us-east-\d|us-west-\d|eu-west-\d|eu-central-\d)\.)?(?:anthropic\.|azure_ai\/|bedrock\/|vertex_ai\/)?claude-(?:(?<family>opus|sonnet|haiku)-(?<newMajor>\d+)(?:-(?<newMinor>\d))?|(?<oldMajor>\d+)(?:-(?<oldMinor>\d))?-(?<oldFamily>opus|sonnet|haiku))(?:[-@]\d{8})?(?:-v\d+:\d+)?(?:-latest)?$/i,hA=/^(?<family>opus|sonnet|haiku)\s+(?<major>\d+)(?:\.(?<minor>\d))?$/i;function gA(e){if(!e)return`Claude`;let t=e.trim().replace(/\s*\([^)]*\)\s*$/,``).replace(/\s*\[[^\]]*\]\s*$/,``).trim(),n=t.match(mA);if(n?.groups){let{family:e,newMajor:t,newMinor:r,oldMajor:i,oldMinor:a,oldFamily:o}=n.groups,s=e||o,c=t||i,l=r||a;if(s&&c)return`${s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()} ${l?`${c}.${l}`:c}`}let r=t.match(hA);if(r?.groups){let e=r.groups.family,t=r.groups.major,n=r.groups.minor;return`${e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()} ${n?`${t}.${n}`:t}`}return t||e}function _A(e){let t=e.match(hA);if(!t?.groups)return e;let n=t.groups.family,r=t.groups.major,i=t.groups.minor;return`${n.charAt(0).toUpperCase()}${i?`${r}.${i}`:r}`}function vA(e){let t=e.split(`/`),n=t.length-1;return t.map((e,t)=>{if(t===n)return e;let r=e.match(/^\.*./);return r?r[0]:e}).join(`/`)}function yA(e){return e.toLocaleString()}function bA(e){if(e.length===0)throw Error(`a cascade needs at least one stop, e.g. "0:calm"`);let t=[];for(let[n,r]of e.entries()){let e=r.indexOf(`:`),i=e<0?NaN:Number(r.slice(0,e));if(!Number.isFinite(i))throw Error(`cascade stop ${n} ("${r}") must be "<position>:<result>", e.g. "80:hot" — the position must be a number`);let a=t[n-1];if(a!==void 0&&i<a.at)throw Error(`cascade stops must be in ascending position order; stop ${n} at ${i} follows stop ${n-1} at ${a.at}`);t.push({at:i,text:r.slice(e+1)})}return t}function xA(e,t){if(!Number.isFinite(e))throw Error(`a cascade needs a finite value, got ${e}`);let n=-1;for(;n+1<t.length&&t[n+1].at<=e;)n++;return(n<0?t[0]:t[n]).text}const SA=[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],CA=SA.length;function wA(e,t){let n=t===void 0?e:t<=0?[]:e.slice(-t);if(n.length===0)return``;let r=n[0],i=n[0];for(let e of n)e<r&&(r=e),e>i&&(i=e);let a=i-r,o=``;for(let e of n){let t=a===0?0:Math.round((e-r)/a*(CA-1));o+=SA[t]}return o}function TA(e){let t=[];for(let n of e.split(`,`)){let e=n.trim();if(e===``)continue;let r=Number(e);if(!Number.isFinite(r))throw TypeError(`sparkline: non-numeric series element ${JSON.stringify(n)}`);t.push(r)}return t}function EA(e,t,n){if(n.length!==0)throw Error(`${e}: takes at most ${t.length} optional argument${t.length===1?``:`s`} (${t.join(`, `)}), got ${t.length+n.length}`)}const DA=Gv(),OA=[...py];function kA(){return{basename:{fn:e=>ne(e),argTypes:[`string`],arity:{kind:`exact`}},dirname:{fn:e=>D(e),argTypes:[`string`],arity:{kind:`exact`}},abbreviatePath:{fn:e=>vA(e),argTypes:[`string`],arity:{kind:`exact`}},int:{fn:e=>Math.trunc(SC(e)),argTypes:[`value`],arity:{kind:`exact`}},string:{fn:e=>xC(e),argTypes:[`value`],arity:{kind:`exact`}},bool:{fn:e=>CC(e),argTypes:[`value`],arity:{kind:`exact`}},urlEncode:{fn:e=>encodeURIComponent(e),argTypes:[`string`],arity:{kind:`exact`}},themes:{fn:()=>DA,argTypes:[],arity:{kind:`exact`}},endcaps:{fn:()=>OA,argTypes:[],arity:{kind:`exact`}},sparkline:{fn:(e,t,...n)=>(EA(`sparkline`,[`width`],n),wA(TA(e),t)),argTypes:[`string`,`int`],arity:{kind:`variadic`}},cascade:{fn:(e,...t)=>xA(e,bA(t)),argTypes:[`float`,`string`],arity:{kind:`variadic`}}}}function AA(e,t,n,r){let i=n*6e4-(t*1e3-r);if(i<3e5||e<=0)return-1;let a=e/i;return Math.max(0,Math.round((100-e)/a/6e4))}const jA=e=>({minutesUntilReset:{fn:t=>Math.round(Math.max(0,t*1e3-e.now().getTime())/6e4),argTypes:[`int`],arity:{kind:`exact`}},etaMinutes:{fn:(t,n,r)=>AA(t,n,r,e.now().getTime()),argTypes:[`float`,`int`,`int`],arity:{kind:`exact`}}});function MA(){return{formatInteger:{fn:e=>yA(e),argTypes:[`int`],arity:{kind:`exact`}},round:{fn:e=>Math.round(e),argTypes:[`float`],arity:{kind:`exact`}},formatModelName:{fn:e=>gA(e),argTypes:[`string`],arity:{kind:`exact`}},shortenModelName:{fn:e=>_A(e),argTypes:[`string`],arity:{kind:`exact`}}}}let NA=null;function PA(e,t){if(NA!==null)throw Error(`a draw is already in progress: draws do not nest`);let n={at:e,timeline:t,frame:{time:e,onHold:({nextChange:e})=>{n.soonest=Math.min(n.soonest,e)}},soonest:1/0};return NA=n,{heard:()=>n.soonest,[Symbol.dispose]:()=>{NA=null}}}function FA(e){if((0,Y._isComputingDerivation)())throw Error(`the clock was read by a value that keeps its answer (${e}): a template reaching a time variable or a clock function by a name it does not spell (index, get) is not known to read the instant — name it: {{ .clock }}`);if(NA===null)throw Error(`the clock was read outside a draw (${e})`);return NA}const IA={now:()=>He(FA(`now`).at),frame:()=>FA(`frame`).frame,timeline:()=>FA(`timeline`).timeline};function LA(e,t){let{frames:n,stepped:r}=fA(e,t===void 0?{}:{timeline:t});if(n===void 0||r===void 0)throw Error(`rich-js's animationFuncs no longer registers frames and stepped`);return{frames:n,stepped:r}}const RA=new Set([`now`,`ago`]);function zA(e,t){return Object.fromEntries(Object.entries(fD(e)).filter(([e])=>RA.has(e)===t))}const BA=zA(()=>{throw Error(`a sprig date function other than now and ago read the clock: add it to SPRIG_CLOCK_READERS`)},!1),VA=[e=>zA(e.now,!0),e=>LA(e.frame,e.timeline),e=>Object.fromEntries(Object.entries(LA(e.frame)).map(([e,t])=>[`realtime${e.replace(/^./,e=>e.toUpperCase())}`,t])),jA];function HA(e){return Object.assign({},...e.map(e=>e(IA)))}const UA=new Set(Object.keys(HA(VA)));function WA(e){return new Set([...UA,...Object.keys(HA(e))])}const GA={readableOn:nA},KA=new Set(Object.keys(GA));function qA(e){let{drawnAt:t,extraFuncs:n}=e,r=()=>({depth:t()});return jT({fromString:e=>new K(e),toString:e=>e.plain,isT:e=>e instanceof K,missingKey:`error`,funcs:{...bD(),...Fk(),...cO(),...AO(),...nE(),...ID(),...PD(),...BA,...pA(r),...Object.fromEntries(Object.entries(GA).map(([e,t])=>[e,t(r)])),...HA([...VA,...e.clockFuncs??[]]),...kA(),...MA(),...n??{}}})}function JA(e){return YA(e,new Set(e.names()),``)}function YA(e,t,n){return new Proxy(Object.create(null),{has(r,i){if(typeof i!=`string`)return!1;let a=n?`${n}.${i}`:i;if(t.has(a))return!ZA(e,a);let o=`${a}.`;for(let e of t)if(e.startsWith(o))return!0;return!1},get(r,i){if(typeof i!=`string`)return;let a=n?`${n}.${i}`:i;if(t.has(a)){if(e.getKind(a)!==`document`)return e.read(a);let t=e.readDocument(a);return t.kind===`absent`?void 0:QA(a,t)}let o=`${a}.`;for(let n of t)if(n.startsWith(o))return YA(e,t,a)}})}function XA(e,t){return new Proxy(e,{has:(e,t)=>t===`settings`||Reflect.has(e,t),get:(e,n)=>n===`settings`?t:Reflect.get(e,n)})}function ZA(e,t){return e.getKind(t)===`document`&&e.readDocument(t).kind===`absent`}function QA(e,t){switch(t.kind){case`ok`:return t.value;case`pending`:throw new wC(e,`variable "${e}" has no value yet: its source has not completed a scan`);case`failed`:throw Error(`variable "${e}": ${t.reason}`)}}var $A=class{held=new Map;declaring=null;closed=!1;take(e,t){if(this.closed)throw Error(`hold taken after close: ${e}`);this.declaring?.taken.add(e),!this.held.has(e)&&(this.held.set(e,t()),this.declaring!==null&&this.declaring.acquired++)}declare(e){if(this.declaring!==null)throw Error(`declaration within one`);let t={taken:new Set,acquired:0};this.declaring=t;let n;try{n=e()}finally{this.declaring=null}let r=0;for(let[e,n]of this.held)t.taken.has(e)||(this.held.delete(e),n(),r++);return{result:n,acquired:t.acquired,released:r}}close(){this.closed=!0;let e=this.held.size;for(let e of this.held.values())e();return this.held.clear(),e}get size(){return this.held.size}};function ej(e){let t=E.basename(e),n=E.dirname(e);for(;;){let r=tj(n);if(r!==null)return{dir:r,name:t,leaf:n===E.dirname(e)};t=E.basename(n),n=E.dirname(n)}}function tj(e){try{return s.statSync(e).isDirectory()?s.realpathSync(e):null}catch{return null}}const $ee=(e,t)=>A(t);function nj(e){let t=[],n=!0,r=new Map;for(let i of e.named){let{hops:e,stopped:a}=An(i);a!==null&&t.push({path:i,reason:a.message});for(let t of e){let{dir:e,name:i,leaf:a}=ej(t);n&&=a;let o=r.has(e)?r.get(e):new Set;o?.add(i),r.set(e,o)}}for(let t of e.whole.map(tj))t!==null&&r.set(t,null);let i={dirs:[...r.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>t===null?{path:e}:{path:e,filenames:[...t].sort()})},a=new Map(i.dirs.map(e=>{let t=Rc(e.path);return[e.path,Bc(t)?zc(t):null]}));return{key:JSON.stringify([i,[...a]]),targets:i,unbound:[...a.values()].includes(null),bound:a,reached:n,unresolved:t}}function rj(e,t,n){let r=[...t.derived.unresolved.map(e=>`cannot follow a link chain — ${e.reason}`),...t.held.handle.deaf.map(e=>e.kind===`refused`?`cannot watch ${e.path} — ${e.reason}`:`watching ${e.path} failed — ${e.reason}`),...n===null?[]:[n]];return r.length===0?null:`${e}: ${r.join(`; `)}`}function ij(e,t){if(t.kind===`failed`)return t;if(e.kind!==`changed`)return e;if(t.kind===`unknown`)return t;for(let n of t.paths)e.paths.add(n);return e}const aj=(e,t)=>t===null?{kind:`unknown`}:{kind:`changed`,paths:new Set([E.join(e,t)])},oj=e=>({kind:`failed`,reason:`${e.path}: ${e.reason}`}),sj=(e,t)=>e.kind===`listening`&&e.handle===t,cj=e=>`${e.recursive===!0?`tree`:`dir`}:${e.path}`;var lj=class{slots=new Map;dirs=new Map;counters;logger;clock;closed=!1;constructor(e){this.clock=e.clock,this.counters=e.counters,this.logger=e.logger??$ee}acquire(e,t,n){if(this.closed)return{release:()=>{},deaf:t.dirs.map(e=>({kind:`refused`,path:e.path,reason:`the watcher registry is closed`}))};let r=this.slots.get(e);for(let{dir:e}of r?.listeners??[])this.judged(e,`acquire`);let i=r??this.opened(e,t),a={onInvalidate:n};return i.holders.add(a),this.makeHandle(i,a)}follow(e,t,n){if(e!==null&&(e.key===t.key||t.unbound))return{watch:e,move:`kept`};let r={key:t.key,handle:this.acquire(t.key,t.targets,n)};return e?.handle.release(),{watch:r,move:`rebound`}}opened(e,t){let n={key:e,listeners:[],holders:new Set,debounce:null};for(let e of t.dirs){let t=this.dirFor(e),r={slot:n,dir:t,filter:e.filenames?new Set(e.filenames):null};t.listeners.add(r),n.listeners.push(r)}return this.slots.set(e,n),this.counters&&(n.listeners.every(e=>e.dir.state.kind===`listening`)?this.counters.watchersOpened++:this.counters.watchRefusals++),n}dirFor(e){let t=cj(e),n=this.dirs.get(t);if(n!==void 0)return this.judged(n,`acquire`),n;let r={path:e.path,recursive:e.recursive===!0},i={id:t,...r,listeners:new Set,state:this.open(r,()=>i,`acquire`,null)};return this.dirs.set(t,i),i}judged(e,t){if(e.state.kind===`deaf`){this.reopen(e,t);return}let n=Rc(e.path);Bc(n)&&zc(n)!==e.state.bound&&this.reopen(e,`another folder is at its path`)}judge(){for(let e of this.dirs.values())this.judged(e,`period`)}reopen(e,t){let n=e.state;n.kind===`listening`&&this.closeHandle(e.path,n.handle,t),e.state=this.open(e,()=>e,t,n),e.state.kind===`listening`?this.tell(e,{kind:`unknown`}):n.kind===`listening`&&this.tell(e,oj(e.state.deafness))}open(e,t,n,r){let i=e.path,a=zc(Rc(i));try{s.opendirSync(i).closeSync();let r=s.watch(i,{persistent:!1,recursive:e.recursive},(e,n)=>this.heard(t(),r,n));return r.on(`error`,e=>{this.logger(`warn`,`watcher error ${i}: ${e.message}`),this.counters&&this.counters.watchErrors++;let n=t();if(!sj(n.state,r))return;this.closeHandle(i,r,`error`);let a={kind:`failed`,path:i,reason:e.message};n.state={kind:`deaf`,deafness:a},this.tell(n,oj(a))}),this.counters&&this.counters.dirWatchesOpened++,this.logger(`info`,`dir watch opened path=${R(i)} cause=${R(n)}`),{kind:`listening`,handle:r,bound:a}}catch(e){let t=e.message;return r?.kind===`deaf`&&r.deafness.kind===`refused`&&r.deafness.reason===t||this.logger(`warn`,`watch failed ${i}: ${t}`),{kind:`deaf`,deafness:{kind:`refused`,path:i,reason:t}}}}heard(e,t,n){let{state:r}=e;if(!sj(r,t))return;let i=n===E.basename(e.path)&&zc(Rc(e.path))!==r.bound;for(let{slot:t,filter:r}of e.listeners)(r===null||n===null||r.has(n)||i)&&this.fire(t,aj(e.path,n));i&&this.judged(e,`moved`)}tell(e,t){for(let{slot:n}of e.listeners)this.fire(n,t)}fire(e,t){if(e.debounce!==null){e.debounce.window=ij(e.debounce.window,t);return}let n={window:t,cancel:this.clock.after(50,()=>{e.debounce=null;for(let t of e.holders)try{t.onInvalidate(n.window)}catch(t){this.logger(`warn`,`watcher invalidate threw key=${R(e.key)}: ${t.message}`)}},{unref:!0})};e.debounce=n}makeHandle(e,t){return{get deaf(){return e.listeners.flatMap(({dir:e})=>e.state.kind===`deaf`?[e.state.deafness]:[])},release:()=>{!e.holders.delete(t)||e.holders.size>0||this.slots.get(e.key)===e&&(this.closeSlot(e,`last release`),this.slots.delete(e.key))}}}closeHandle(e,t,n){try{t.close()}catch{}this.counters&&this.counters.dirWatchesClosed++,this.logger(`info`,`dir watch closed path=${R(e)} cause=${R(n)}`)}closeSlot(e,t){e.debounce!==null&&(e.debounce.cancel(),e.debounce=null);for(let n of e.listeners){let{dir:e}=n;e.listeners.delete(n),!(e.listeners.size>0)&&(e.state.kind===`listening`&&this.closeHandle(e.path,e.state.handle,t),this.dirs.delete(e.id))}this.counters&&this.counters.watchersClosed++}size(){return this.slots.size}dirWatches(){return[...this.dirs.values()].filter(e=>e.state.kind===`listening`).length}watchedDirs(){return[...this.dirs.values()].map(e=>e.path)}closeAll(){this.closed=!0;for(let e of this.slots.values())this.closeSlot(e,`close`);this.slots.clear()}};function uj(e,t){return t.kind===`failed`?e.failedMs:e.okMs}function dj(e,t,n){return t===0?e.okMs:Math.min(e.failedMs*2**(t-1),n)}var fj=class{stop=null;state=`released`;last=null;constructor(e,t){this.tick=e,this.clock=t}landed(e,t=this.clock.monotonic()){this.last={at:t,periodMs:e},this.schedule()}hold(e){if(this.state===`disposed`)return;let t=e?`held`:`released`;t!==this.state&&(this.state=t,this.schedule())}dispose(){this.state=`disposed`,this.cancel()}schedule(){if(this.cancel(),this.state!==`held`||this.last===null)return;let e=Math.max(0,this.last.at+this.last.periodMs-this.clock.monotonic());this.stop=this.clock.after(e,()=>{this.stop=null,this.tick()},{unref:!0})}cancel(){this.stop?.(),this.stop=null}};function pj(){return Y.observable.box(mj(`unread`),{deep:!1})}function mj(e){let t;return{kind:`pending`,why:e,landed:new Promise(e=>{t=e}),land:t}}function hj(e,t){let n=e.reading.get();n.kind!==`pending`&&(0,Y.compareStructural)(n,t)||((0,Y.runInAction)(()=>e.reading.set(t)),n.kind===`pending`&&n.land())}function gj(e,t){let n=e.reading.get();n.kind===`pending`?n.why!==t&&t===`unread`&&(0,Y.runInAction)(()=>e.reading.set({...n,why:t})):(0,Y.runInAction)(()=>e.reading.set(mj(t)))}function _j(e,t){e.reading.get().kind===`pending`&&hj(e,t)}function vj(e){return e.reading.get()}function yj(e,t,n,r){let i=new AbortController,a=r(Math.max(0,t),()=>i.abort());return new Promise((t,r)=>{i.signal.addEventListener(`abort`,()=>t(`deadline`)),e(i.signal).then(()=>t(`answered`),e=>i.signal.aborted?n(e):r(e))}).finally(()=>{a(),i.abort()})}function bj(e){return{current:()=>e}}const xj=()=>()=>{};var Sj=class{entries=new Map;refreshes;closed=!1;constructor(e){this.spec=e,this.refreshes=e.ledger.declare({name:e.name,scope:e.scope,refresh:[`first`,`period`,`change`,`supersede`]})}declare(e,t){if(this.closed)return bj(L(`${this.spec.name} closed`,`read`));let n=this.spec.keyOf(t),r=this.touched(n)??this.firstRead(this.created(n,t));return e.take(`${this.spec.name}:${n}`,()=>this.hold(r)),{current:()=>vj(r)}}supersede(e){if(this.closed)return()=>{};let t=this.spec.keyOf(e),n=this.touched(t)??this.created(t,e);n.superseding++,gj(n,`superseded`),this.abandon(n),n.changed=!1,this.evict();let r=!1;return()=>{r||(r=!0,n.superseding--,this.entries.get(n.key)===n&&this.refresh(n,`supersede`))}}changed(e){for(let t of this.entries.values())e(t.input)&&this.heard(t)}heard(e){e.holders>0&&this.refresh(e,`change`)}isHeld(e){for(let t of this.entries.values())if(t.holders>0&&e(t.input))return!0;return!1}stats(){let e=0;for(let t of this.entries.values())t.holders>0&&e++;let{refreshes:t,failures:n,abandoned:r,lastMs:i}=this.refreshes.record();return{entries:this.entries.size,held:e,refreshes:t,failures:n,abandoned:r,lastMs:i}}close(){this.closed=!0;for(let e of[...this.entries.values()])this.drop(e)}touched(e){let t=this.entries.get(e);if(t!==void 0)return this.entries.delete(e),this.entries.set(e,t),t}created(e,t){let n={key:e,input:t,reading:pj(),holders:0,flight:null,changed:!1,superseding:0,revisit:Cj(this.spec.every(t),this.spec.clock,{period:()=>this.refresh(n,`period`),holdReturned:()=>this.refresh(n,`change`)}),unwatch:()=>{}};return this.entries.set(e,n),n.unwatch=this.spec.watch(t,()=>this.heard(n)),n}firstRead(e){return this.refresh(e,`first`),e}refresh(e,t){if(e.superseding>0)return;if(e.flight!==null){e.changed||=t===`change`;return}let n=new AbortController;e.flight=n;let r=this.spec.clock.monotonic();Tj(()=>this.spec.read(e.input,n.signal)).then(i=>{let a=this.spec.fields(e.input,e.holders),o=Fe(this.spec.clock,r);if(n.signal.aborted){this.refreshes.abandoned(a,t,o);return}try{this.refreshes.recorded(a,t,i,o)}finally{this.store(e,i)}}).catch(t=>{this.spec.logger(`error`,`${this.spec.name} refresh threw (${this.spec.fields(e.input,e.holders)}): ${String(t)}`)})}store(e,t){e.flight=null;try{hj(e,t)}finally{e.revisit.landed(t),e.changed&&(e.changed=!1,this.refresh(e,`change`))}}hold(e){return e.holders++,e.revisit.hold(!0),this.evict(),()=>{e.holders--,e.revisit.hold(e.holders>0),this.evict()}}evict(){for(let e of[...this.entries.values()]){if(this.entries.size<=this.spec.maxEntries)return;e.holders===0&&e.superseding===0&&this.drop(e)}}drop(e){this.entries.delete(e.key),this.abandon(e),e.unwatch(),e.revisit.dispose(),_j(e,L(`${this.spec.name} entry dropped`,`read`))}abandon(e){let t=e.flight;e.flight=null,t?.abort(Error(`${this.spec.name} read abandoned`))}};function Cj(e,t,n){if(e===null)return new wj(n.holdReturned);let r=new fj(n.period,t);return{landed:t=>r.landed(uj(e,t)),hold:e=>r.hold(e),dispose:()=>r.dispose()}}var wj=class{state=`released`;answered=!1;constructor(e){this.reread=e}landed(){this.answered=!0}hold(e){if(this.state===`disposed`)return;let t=e&&this.state===`released`&&this.answered;this.state=e?`held`:`released`,t&&this.reread()}dispose(){this.state=`disposed`}};function Tj(e){let t=e=>L(`read threw: ${String(e)}`,`read`);try{return e().catch(t)}catch(e){return Promise.resolve(t(e))}}const Ej=[`first`,`period`,`change`,`request`,`supersede`];var Dj=class{tallies=new Map;constructor(e=Ne){this.logger=e}declare(e){let t=`${e.scope}/${e.name}`,n=this.tallies.get(t)??{name:e.name,scope:e.scope,refreshes:{},failures:0,abandoned:0,lastMs:null};for(let t of e.refresh)n.refreshes[t]??=0;return this.tallies.set(t,n),new kj(n,this.logger)}snapshot(){return[...this.tallies.entries()].sort(([e],[t])=>e<t?-1:+(e>t)).map(([,e])=>({...e,refreshes:{...e.refreshes}}))}totals(){let e=Object.fromEntries(Ej.map(e=>[e,0]));for(let t of this.tallies.values())for(let n of Ej)e[n]+=t.refreshes[n]??0;return e}};const Oj={first:!0,period:!0,change:!0,request:!1,supersede:!0};var kj=class{constructor(e,t){this.tally=e,this.logger=t}record(){return{...this.tally,refreshes:{...this.tally.refreshes}}}recorded(e,t,n,r){this.tally.refreshes[t]=(this.tally.refreshes[t]??0)+1,this.tally.lastMs=r,n.kind===`failed`&&this.tally.failures++;let i=n.kind===`failed`;if(!i&&!Oj[t])return;let a=i?` reason=${JSON.stringify(n.reason)}`:``;this.logger(i?`warn`:`info`,`${this.tally.name} refresh ${e} by=${t} outcome=${n.kind}${a} took=${r}ms`)}abandoned(e,t,n){this.tally.abandoned++,this.logger(`info`,`${this.tally.name} refresh ${e} by=${t} abandoned took=${n}ms`)}};function Aj(e){return ae(`sha256`).update(JSON.stringify(jj(e))).digest(`hex`)}function jj(e){return Array.isArray(e)?e.map(jj):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,t])=>[e,jj(t)])):e}const Mj=/\r\n|\r|\n/g,Nj=e=>F(e.replace(Mj,` `).trim());function Pj(e){return t=>{let n=e.exec(t)?.[1];return n===void 0?L(`regex no-match`,`parse`):F(n.replace(Mj,` `))}}const Fj=e=>{try{return F(JSON.parse(e))}catch(e){return L(`JSON parse failed: ${e.message}`,`parse`)}},Ij=e=>Aj(e);function Lj(e){return ie.createHash(`sha256`).update(e).digest(`hex`)}const Rj=e=>e.kind===`shell`?`output of "${e.command}" in ${e.cwd}`:`"${e.path}"`;function zj(e,t,n,r){return{where:Rj({kind:`shell`,command:t,cwd:n}),read:async()=>{let i=await e.launch({bin:`/bin/sh`,args:[`-c`,t],cwd:n,category:`user-shell`,timeoutMs:1e4,signal:r});return i.ok?F(i.stdout):L(`shell "${t}" ${Ze(i,` in ${n}`)}`,`read`)}}}function Bj(e,t,n){return{where:Rj({kind:`file`,path:e,readMode:t}),read:async()=>{try{let r=await pe(e,{encoding:`utf8`,signal:n});return F(t===`first-line`?r.split(/\r?\n/)[0]??``:r)}catch(t){let r=t.code??String(t);return L(n.aborted?`file read aborted: ${String(n.reason)}`:`file unreadable (${r}): ${e}`,`read`)}}}}function Vj(e,t,n){switch(t.kind){case`shell`:return zj(e,t.command,t.cwd,n);case`file`:return Bj(t.path,t.readMode,n)}}function Hj(e){switch(e.kind){case`text`:return Nj;case`regex`:return Pj(new RegExp(e.source,e.flags));case`json`:return e=>e.trim()===``?I:Fj(e)}}function Uj(e,t,n){if(e.kind!==`ok`)return e;let r=t(e.value);return r.kind===`failed`?L(`${r.reason} in ${n}`,r.failedAt):r}var Wj=class{entries=new Map;releaseDelivery;constructor(e,t){this.watchers=e,this.fileEvents=t,this.releaseDelivery=t.subscribe(e=>this.noticed(e))}subscribe(e,t,n){let r=this.entries.get(e)??this.arm(e);return r.subscribers.set(t,n),n(this.faultOf(e,r)),()=>this.unsubscribe(e,t)}arm(e){let t=Gj(e),n={bound:{derived:t,held:this.watchers.follow(null,t,t=>this.heard(e,n,t)).watch},subscribers:new Map};return this.entries.set(e,n),n}rederive(e,t){let n=Gj(e),{watch:r}=this.watchers.follow(t.bound.held,n,n=>this.heard(e,t,n));t.bound={derived:n,held:r},this.report(e,t)}heard(e,t,n){let r=t.bound.derived.reached;if(this.rederive(e,t),!(n.kind!==`failed`&&!r&&!t.bound.derived.reached))for(let e of t.subscribers.keys())e()}report(e,t){let n=this.faultOf(e,t);for(let e of t.subscribers.values())e(n)}faultOf(e,t){return rj(`watch_file ${e}`,t.bound,qc(this.fileEvents.delivery()))}noticed(e){switch(e.kind){case`period`:return;case`moved`:case`caught-up`:(0,Y.runInAction)(()=>{for(let[e,t]of this.entries){this.rederive(e,t);for(let e of t.subscribers.keys())e()}});return}}unsubscribe(e,t){let n=this.entries.get(e);n&&(n.subscribers.delete(t),n.subscribers.size===0&&(n.bound.held.handle.release(),this.entries.delete(e)))}dispose(){this.releaseDelivery();for(let e of this.entries.values())e.bound.held.handle.release();this.entries.clear()}size(){return this.entries.size}};const Gj=e=>nj({named:[e],whole:[e]});var Kj=class{byKind;watchMgr;faults=Y.observable.map(void 0,{deep:!1});constructor(e){let t=e.logger??Ne,n=e.ledger??new Dj(t);this.watchMgr=new Wj(e.watchers??new lj({clock:e.clock}),e.fileEvents??Hc);let r=r=>new Sj({name:`source.${r}`,scope:`daemon`,keyOf:Ij,fields:(e,t)=>`digest=${en(Ij(e))} where=${R(Rj(e.read))} sharedBy=${t}`,read:async(t,n)=>{let r=Vj(e.launcher,t.read,n);return Uj(await r.read(),Hj(t.parse),r.where)},every:({refresh:e})=>e.kind===`ttl`?{okMs:e.durationMs,failedMs:e.durationMs}:null,watch:(e,t)=>{if(e.refresh.kind!==`watch_file`)return xj();let n=Ij(e),r=this.watchMgr.subscribe(e.refresh.path,t,e=>(0,Y.runInAction)(()=>{e===null?this.faults.delete(n):this.faults.set(n,e)}));return()=>{r(),(0,Y.runInAction)(()=>this.faults.delete(n))}},maxEntries:0,logger:t,ledger:n,clock:e.clock});this.byKind={shell:r(`shell`),file:r(`file`)}}declare(e,t){let n=Ij(t),r=this.byKind[t.read.kind].declare(e,t);return{digest:n,current:()=>r.current(),fault:()=>this.faults.get(n)??null}}stats(){return{shell:this.byKind.shell.stats(),file:this.byKind.file.stats(),watches:this.watchMgr.size()}}close(){this.byKind.shell.close(),this.byKind.file.close(),this.watchMgr.dispose()}};function qj(e,t){return t.kind!==`ttl`||t.durationMs>=500?t:(A(`declareShell "${e}": ttl ${t.durationMs}ms below floor 500ms; clamping`),{kind:`ttl`,durationMs:500})}function Jj(e){let t=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/.exec(e);if(!t)throw RangeError(`Invalid duration: "${e}"`);let n=parseFloat(t[1]);switch(t[2]){case`ms`:return n;case`s`:return n*1e3;case`m`:return n*6e4;case`h`:return n*36e5;default:throw RangeError(`Unexpected duration unit: "${t[2]}"`)}}const Yj=`session.id`;function Xj(e){switch(e.kind){case`text`:return{kind:`text`};case`regex`:return{kind:`regex`,source:e.regex.source,flags:e.regex.flags};case`json`:return{kind:`json`}}}const Zj={read:()=>Ao(`unread`),drawnAt:()=>{throw new wC(`colorCompatibility.effective`,`the drawn depth has no value yet: no view source is bound`)}},Qj=e=>({kind:`found`,value:e});function $j(e,t){let n=e,r=!1;for(let e of t.split(`.`)){if(!r&&jo(n))return n;if(typeof n!=`object`||!n)return Qj(void 0);r||=e===`value`&&n.kind===`ok`,n=n[e]}return!r&&jo(n)?n:Qj(n)}function eM(e,t){if(t.kind===`pending`)return t;let n=t.value;if(n===void 0)return L(`variable "${e}": the view's payload has no "${e}": its declaration did not take the source the config declares`,`read`);switch(typeof n==`object`&&n?n.kind:void 0){case`ok`:case`absent`:case`failed`:return n;default:return L(`variable "${e}": the view's payload holds no source reading at "${e}"`,`read`)}}function tM(e,t){if(typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`)throw TypeError(`Expected string|number|boolean from payload, got ${typeof e}`);return t===`string`?xC(e):t===`number`?SC(e):CC(e)}function nM(e){return e===`number`?0:e===`boolean`?!1:``}var rM=class e{lastErrors=new Map;policyFaults=Y.observable.map(void 0,{deep:!1});cleanups=[];holds=new $A;identities=new Map;lanes=Y.observable.map(void 0,{deep:!1});inputs=Y.observable.box(Zj,{deep:!1});drawnAt=()=>this.inputs.get().drawnAt();engine=qA({drawnAt:this.drawnAt});sourceNames=Y.observable.array([],{deep:!1});publishedNow=(0,Y.computed)(()=>({values:this.sourceNames.map(e=>this.store.stored(e)),faults:[...this.policyFaults.values()]}));published(){return this.publishedNow.get()}sessionState;constructor(e,t,n=``,r,i=null,a={}){this.runs=e,this.store=t,this.defaultEmptyValue=n,this.parent=i,this.env=a,this.sessionState=r}view(){return new e(this.runs,new RC(this.store.clock,this.store),this.defaultEmptyValue,this.sessionState,this,this.env)}get variableStore(){return this.store}declareLiteral(e,t){this.store.defineBox(e,bC(t),t)}declareFailedDocument(e,t){this.store.defineDocument(e,L(t,`parse`))}declareSourceDocument(e){this.store.defineDerivedDocument(e,()=>eM(e,this.inputs.get().read(e)))}own(e){this.cleanups.push(e)}declareInput(e,t,n,r,i){this.store.defineDerived(e,n,i,()=>this.inputAt(e,t,n,r))}inputAt(e,t,n,r){let i=this.inputs.get().read(t);if(i.kind===`pending`)throw this.lastErrors.delete(e),new wC(e,`variable "${e}" has no value yet: its source has not answered`);let a=i.value;if(a===void 0)return this.fallbackOf(e,n,r,`input path "${t}" not found in payload`);try{let t=tM(a,n);return this.lastErrors.delete(e),t}catch(t){return this.fallbackOf(e,n,r,t instanceof Error?t.message:String(t))}}declareEnv(e,t,n){let r=this.env[t];if(r!==void 0){this.store.defineBox(e,`string`,r);return}let i=n===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:n;this.store.defineBox(e,`string`,i),this.recordError(e,`env var "${t}" is not set`)}declareShell(e,t,n){this.declareSource(e,{kind:`shell`,command:t,cwd:n.cwd},qj(e,n.cache),n.parse)}declareFile(e,t,n){this.declareSource(e,{kind:`file`,path:t,readMode:n.readMode??`whole`},n.cache,n.parse)}declareSource(e,t,n,r){let i=this.publisherFor(e,r);(0,Y.runInAction)(()=>this.sourceNames.push(e)),this.cleanups.push((0,Y.reaction)(()=>this.lanes.get(e)?.current(),e=>{e===void 0||e.kind===`pending`||i(e)},{fireImmediately:!0})),this.registerCachePolicy(e,n,n=>this.hold(e,{read:t,parse:Xj(r),refresh:n}))}hold(e,t){this.identities.set(e,t);let{result:n}=this.holds.declare(()=>[...this.identities].map(([e,t])=>{let n=this.runs.declare(this.holds,t),r=this.lanes.get(e);return[e,r?.digest===n.digest?r:n]}));(0,Y.runInAction)(()=>{for(let[e,t]of n)this.lanes.set(e,t)})}publisherFor(e,t){switch(t.kind){case`text`:case`regex`:return this.scalarPublisher(e,t.default);case`json`:return this.documentPublisher(e,t.default)}}scalarPublisher(e,t){let n=this.stringInitial(t);return this.store.defineBox(e,`string`,n),t=>{this.noteOutcome(e,t),this.store.setBox(e,Oo(t,n))}}documentPublisher(e,t){let n=t===void 0?Ao(`unread`):F(t);this.store.defineDocument(e,n);let r,i=!1;return this.cleanups.push(()=>r?.()),a=>{r?.();let o=a;this.noteOutcome(e,o);let s=o.kind===`ok`||o.kind===`failed`&&o.failedAt===`parse`,c=s||t===void 0?o:n,l=i&&s&&o.kind!==`ok`,u=()=>{i=o.kind===`ok`,this.store.setDocument(e,c)};l?r=this.store.clock.after(250,u):u()}}async inFlight(e){for(;!e.aborted&&this.awaited().length>0;)try{await(0,Y.when)(()=>this.awaited().length===0,{signal:e})}catch(t){if(!e.aborted)throw t}return this.awaited()}awaited(){return[...[...this.lanes].filter(([,e])=>e.current().kind===`pending`).map(([e])=>e),...this.parent?.awaited()??[]]}settled(e){return this.inFlight(Re(this.store.clock,e))}declareTemplate(e,t,n){let r=this.engine.parse(t);this.declareDerived(e,n.type,n.derivation,()=>r.evaluate(JA(this.store)).map(e=>e.plain).join(``),n.varDefault)}declareTime(e,t){let n=this.engine.parse(`{{ date .layout now }}`),r={layout:t.format};this.declareDerived(e,`string`,`projection`,()=>n.evaluate(r).map(e=>e.plain).join(``),t.varDefault)}declareDerived(e,t,n,r,i){this.store.defineDerived(e,t,n,()=>{try{let n=tM(r(),t);return this.lastErrors.delete(e),n}catch(t){let n=TC(t);if(n!==void 0)throw this.lastErrors.delete(e),n;let r=t instanceof Error?t.message:String(t);if(this.recordError(e,r),i===void 0)throw Error(`variable "${e}": ${r}`);return i}})}declareState(e,t){if(!this.sessionState)throw Error(`declareState("${e}"): SourceRegistry was constructed without a SessionState — state-kind variables require a SessionState (the daemon provides one; tests must supply one)`);let n=this.sessionState,r=t.varDefault??this.stringInitial(void 0);this.store.defineComputed(e,`string`,e=>{let i=e(Yj);if(typeof i!=`string`||!i)return r;let a=n.get(i,t.key);return a===null?r:a})}stateRevision(){let e=this.store.has(`session.id`)?this.store.read(Yj):``;return this.sessionState!==void 0&&typeof e==`string`&&e!==``?this.sessionState.revision(e):0}bindInputs(e){(0,Y.runInAction)(()=>this.inputs.set(e))}getLastError(e){if(!this.declaredHere(e))return this.parent?.getLastError(e);let t=this.lastErrors.get(e),n=this.policyFaults.get(e);return n===void 0?t:t===void 0?n:{timestamp:t.timestamp,message:`${n.message}; ${t.message}`}}cachePolicyFaults(){return new Map([...this.parent?.cachePolicyFaults()??[],...this.policyFaults])}declaredHere(e){return this.store.has(e)&&!(this.parent?.store.has(e)??!1)}dispose(){for(let e of this.cleanups)e();return this.cleanups.length=0,this.holds.close(),this.store.dispose()}registerCachePolicy(e,t,n){switch(t.kind){case`never`:n({kind:`never`});break;case`ttl`:n({kind:`ttl`,durationMs:t.durationMs});break;case`watch_file`:n({kind:`watch_file`,path:t.path}),this.cleanups.push((0,Y.reaction)(()=>this.lanes.get(e)?.fault()??null,t=>this.notePolicy(e,t===null?F(void 0):L(t,`read`)),{fireImmediately:!0}));break;case`key`:{let r=this.engine.parse(t.template);this.onReads(e,()=>{try{return F(r.evaluate(JA(this.store)).map(e=>e.plain).join(``))}catch(e){return TC(e)===void 0?L(`cache key: ${e instanceof Error?e.message:String(e)}`,`read`):Ao(`unread`)}},e=>n({kind:`key`,hash:Lj(e)}));break}case`depends_on`:this.onReads(e,()=>{let e=t.varNames.map(e=>this.store.changeKey(e));return e.every(e=>e.kind===`ok`)?F(e.map(e=>e.value).join(`,`)):Ao(`unread`)},e=>n({kind:`key`,hash:Lj(e)}));break}}onReads(e,t,n){let r,i=(0,Y.reaction)(t,t=>{this.notePolicy(e,t),!(t.kind!==`ok`||t.value===r)&&(r=t.value,n(t.value))},{fireImmediately:!0});this.cleanups.push(i)}fallbackOf(e,t,n,r){if(this.recordError(e,r),n!==void 0)return n;try{return tM(this.defaultEmptyValue,t)}catch{return nM(t)}}stringInitial(e){return e===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:e}recordError(e,t){this.lastErrors.set(e,{timestamp:this.store.clock.now(),message:t})}notePolicy(e,t){(0,Y.runInAction)(()=>{t.kind===`failed`?this.policyFaults.get(e)?.message!==t.reason&&this.policyFaults.set(e,{timestamp:this.store.clock.now(),message:t.reason}):this.policyFaults.delete(e)})}noteOutcome(e,t){t.kind===`ok`?this.lastErrors.delete(e):this.recordError(e,t.kind===`failed`?t.reason:`no value`)}};function iM(e,t){let n=wx[e],r=Ax(e),i=n.kind===`session`||n.kind===`config`?n.floor:``;return r===`string`?{kind:`input`,path:t,default:``}:{kind:`input`,path:t,type:r,default:i}}const aM=Object.fromEntries([...Ix].map(([e,t])=>[t,iM(e,t)])),oM={subscribers:`number`,fps:`number`,shown:`boolean`},sM=Object.keys(oM),cM={project_dir:{kind:`input`,path:`workspace.project_dir`,default:``},[Yj]:{kind:`input`,path:`session_id`,default:``},transcript_path:{kind:`input`,path:`transcript_path`,default:``},resume_command:{kind:`input`,path:`resumeCommand`,default:``},config_path:{kind:`input`,path:`configPath`,default:``},...aM,"preset.customized":{kind:`input`,path:`preset.customized`,type:`boolean`,default:!1},"preset.bundled":{kind:`input`,path:`preset.bundled`,type:`boolean`,default:!0},...Object.fromEntries(Zb.flatMap(e=>sM.map(t=>[nx(e,t),{kind:`input`,path:nx(e,t),type:oM[t],default:tx[t]}]))),[ex(`by`)]:{kind:`input`,path:ex(`by`),default:$b.by},[ex(`fps`)]:{kind:`input`,path:ex(`fps`),type:`number`,default:0},...Object.fromEntries([`label`,`fg`,`bg`,`open`].map(e=>[`diagnostics.${e}`,{kind:`input`,path:`diagnostics.${e}`,default:``}])),"term.cols":{kind:`input`,path:`term.cols`,type:`number`,default:80},"tmux.pane":{kind:`input`,path:`tmux.pane`,default:``},"autocompact.window":{kind:`input`,path:`autocompact.window`,type:`number`,default:-1},...Object.fromEntries([`applied`,`lower`,`higher`].map(e=>[`autocompact.${e}`,{kind:`input`,path:`autocompact.${e}`,type:`number`,default:0}])),"autocompact.error":{kind:`input`,path:`autocompact.error`,default:``},"location.main":{kind:`input`,path:`location.main`,default:``},"location.worktree":{kind:`input`,path:`location.worktree`,default:``},"location.subpath":{kind:`input`,path:`location.subpath`,default:``},"location.noRepo":{kind:`input`,path:`location.noRepo`,type:`boolean`,default:!1},"git.repoUrl":{kind:`input`,path:`git.repoUrl`,default:``}},lM={today:`the day the draw is at`,feeds:`the frames a lane was sent up to the draw's instant`,drawing:`who the draw is for`,diagnostics:`the errors and warnings the draw owes its reader`};function uM(e){let t=e.split(`.`,1)[0];return Object.hasOwn(lM,t)?t:void 0}const dM=Object.fromEntries(Xv.map(e=>[e,Ix.get(e)]));function fM(e){return Xv.find(t=>dM[t]===e)}function pM(e,t,n){let r=new Set,i=(e,t=n)=>{for(let n of XS(e??``,t).keys())r.add(n)};for(let t of Object.values(e.segments)){let e=t.partials===void 0?n:{...n,...t.partials};i(t.template,e),i(t.bg,e),i(t.fg,e),i(t.when,e);for(let n of Object.values(t.partials??{}))i(n,e)}for(let e of t)for(let t of Ny(e))i(t.when),t.kind===`segment`&&(i(t.lead),i(t.trail));for(let t of Object.values(e.variables))t.kind===`template`&&i(t.template),t.kind===`state`&&r.add(Yj);for(let t of Object.values(e.actions)){r.add(Yj);for(let[,e]of ES(t))i(e);let e=`set`in t?Lx.get(t.set):void 0,n=`persist`in t?Ix.get(t.persist):void 0;e!==void 0&&r.add(e),n!==void 0&&r.add(n)}return r}function mM(e,t,n){let r=mC({...n,variables:{...n.variables,...e.variables},segments:{...n.segments,...e.segments}}),i={};for(let a of pM(e,t,n.helpers)){if(pC(a,r))continue;let e=cM[a];if(e===void 0)throw Error(`synthesized chrome reads ".${a}", which it does not declare and PAYLOAD_INPUTS does not supply`);i[a]=e}return i}function hM(e){return e.replace(/[^A-Za-z0-9]+/g,`_`)}function gM(e){return e}function _M(e,t,n){return n===void 0?Mi+hM(e)+`.`+hM(t):vM(n)}function vM(e){return Mi+hM(e)}function yM(e,t){return e+`.`+t}function bM(e){return Ni+e}const xM=[`closeOnPick`,`paged`,`key`,`distribution`],SM=e=>xM.includes(e),CM=`"closeOnPick" (bool, default false), "paged" (bool, default true), "key" (string, accordion grouping), "distribution" (one of ${$_.map(e=>`"${e}"`).join(`, `)}; default "van-der-corput")`;function wM(e){for(let t of Object.keys(e))if(!SM(t))throw Error(`unknown {{ menu }} option "${t}" — the options dict takes ${CM}`);let t=(t,n)=>{let r=e[t];if(r===void 0)return n;if(typeof r!=`boolean`)throw Error(`{{ menu }} option "${t}" must be a boolean, got ${JSON.stringify(r)} (e.g. (dict "${t}" ${String(!n)}))`);return r},n=e.key;if(n!==void 0&&typeof n!=`string`)throw Error(`{{ menu }} option "key" must be a string naming the accordion group, got ${JSON.stringify(n)}`);if(n===``)throw Error(`{{ menu }} has an empty accordion key — a shared key must be a non-empty name (or omit "key" for an independent menu)`);let r=e.distribution;if(r!==void 0&&!ev(r))throw Error(`{{ menu }} option "distribution" must be one of: ${$_.join(`, `)}; got ${JSON.stringify(r)}`);return{closeOnPick:t(`closeOnPick`,!1),paged:t(`paged`,!0),key:n,distribution:nv(r)}}const TM=e=>`from`in e?e.from:e.themes;function EM(e,t,n){return e===`bool`?Ty(t)!==null:`min`in e?Ey(t,e)!==null:xS(TM(e),n).members.includes(t)}function DM(e,t){if(e===`bool`)return Cy.join(` or `);if(!(`min`in e)){let n=TM(e),{members:r}=xS(n,t),i=r.map(e=>JSON.stringify(e));if(r.length<=8)return`one of ${i.join(`, `)}`;let a=typeof n==`string`?` "${n}"`:``;return`one of the ${r.length}${a} names, such as ${i.slice(0,3).join(`, `)}`}return`an integer from ${e.min} to ${e.max}`}function OM(e){return{label:e.label,domain:kM(e.domain)}}function kM(e){return e===`theme`?{themes:vS}:e===`bool`||`min`in e?e:{from:e}}function AM(e,t,n,r,i){let a=xi(e.label),{domain:o}=e;if(o===`bool`)return{kind:`inline`,template:`{{ action "${r}" "☑ ${a}" "☐ ${a}" }}`,actions:{[r]:{set:t,cycle:[...Cy]}},variables:{}};if(`from`in o)return jM(t,r,i,o.from,e=>({template:`{{ carousel "${e.apply}" "${e.open}" "${a}" }}`,rows:[`{{ picker "${e.apply}" "${e.page}" false true true }}`]}));if(`themes`in o)return jM(t,r,i,o.themes,e=>({template:`{{ action "${e.open}" "${a}" .${n} }} {{ action "${e.open}" (swatch "${e.apply}") }}`,rows:[`{{ swatches "${e.apply}" "${e.page}" }}`,`{{ themePreview "${e.apply}" }}`]}));let s=e=>({set:t,min:o.min,max:o.max,by:e});return{kind:`inline`,template:`{{ action "${r}.down" "◀" }} {{ "${a}" }} {{ .${n} }} {{ action "${r}.up" "▶" }}`,actions:{[`${r}.down`]:s(-o.step),[`${r}.up`]:s(o.step)},variables:{}}}function jM(e,t,n,r,i){let a={variable:n,key:n,member:t},o=yM(n,t),s=`${t}.open`,c=bM(n),l=`${c}.current`,{template:u,rows:d}=i({apply:t,open:s,page:c});return{kind:`picker`,template:u,actions:{[t]:{set:e,from:r},[o]:ki(n,t),[c]:{set:c,int:!0},[l]:{set:c,to:`-1`},[s]:{do:[o,l]}},variables:{[n]:Oi(n,gi),[c]:{kind:`state`,key:c,default:`0`}},list:{ref:a,rows:d}}}const MM=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],NM=Object.fromEntries(MM.map(e=>[e.member,e.label])),PM={gear:{beside:`theme`,trigger:`⚙`},toggles:{beside:`updateNotice`,trigger:`🧪 toggles`}},FM=Object.keys(PM),IM=Rx(e=>Mx[e].place),LM=e=>Object.hasOwn(PM,e),RM=(e,t)=>e===t||LM(e)&&RM(IM[PM[e].beside],t),zM=e=>LM(e)?`${zM(IM[PM[e].beside])} › ${PM[e].trigger}`:e===`door`?`first line`:NM[e],BM=e=>zM(IM[e]),VM=()=>[`door`,...MM.map(e=>e.member)].flatMap(e=>[e,...FM.filter(t=>RM(t,e))]).map(e=>({path:zM(e),names:Nx.filter(t=>IM[t]===e)})).filter(({names:e})=>e.length>0),HM=e=>{let{setting:t,on:n,inTmux:r}=Xb[e].switch;return`${Xb[e].label} is off — turn it on in the settings menu's ${BM(t)}, or set globals.${t}: ${JSON.stringify(n)}${r?`; it runs only for a session inside a tmux pane`:``}`},UM=Object.fromEntries(Object.entries(wx).map(([e,t])=>[e,t.spec]));function WM(e){return GM(wx[e])}function GM(e){return`optionDomain`in e&&e.optionDomain!==void 0?{from:e.optionDomain.name}:e.domain}function KM(e,t){return{required:!1,json:{not:{},description:`not allowed here — ${e}`},parse:(e,n,r,i)=>{i[r]!==void 0&&e.issues.push({path:`${n}.${r}`,message:t(`${n}.${r}`),line:q(e.source,[...n.split(`.`),r])})}}}function qM(e){return KM(`${e} cannot select a preset`,t=>`${t}: ${e} cannot select a preset. Which preset is active is resolved once, as session pick over globals.preset over "default"; a fragment naming another would be a second authority over that. Set the default arrangement in the top-level globals.preset instead.`)}function JM(e){return KM(`${e} cannot change the settings menu glyph`,t=>`${t}: ${e} cannot change the settings menu glyph — one menu is shared by every preset. Set it in the top-level globals.menuGlyph instead.`)}function YM(e,t,n){return{...e,json:{...e.json,not:{pattern:`\\{\\{`}},parse:(r,i,a,o)=>{let s=o[a];if(typeof s==`string`&&Zv(s)){r.issues.push({path:`${i}.${a}`,message:`${i}.${a}: a rule is not allowed here — ${t} ${n}, so it names a value. Write the rule in globals.${a} (or a preset's globals.${a}) instead.`,line:q(r.source,[...i.split(`.`),a])});return}return e.parse(r,i,a,o)}}}const XM={default_bg:"nothing reads it — a segment with no `bg:` wears the decoration tint of its place in the bar. Delete the key, and author `bg:` on the segments that need a fixed colour.",default_fg:"nothing reads it — a segment with no `fg:` wears text chosen for contrast against its background. Delete the key, and author `fg:` on the segments that need a fixed colour.",default_truncate_marker:'nothing reads it — a segment clipped to its `width:` always ends in "…". Delete the key.',look:`it was renamed "style" — write the same name as style: "<name>"`,progression:`it was renamed "variation", and its values with it: accent (was secondary-accent), duo (was primary-secondary), mono (was primary)`,experimentalTmuxStatus:`it became the renderer setting — write renderer: "tmux" (or pick tmux in ${BM(`renderer`)} › renderer, from a session inside tmux)`,charset:"the bar always draws Nerd Font glyphs. Delete the key; `cc-candybar doctor` names what your terminal's font is missing."},ZM={noun:`globals key`,fields:UM,removed:XM},QM={preset:qM(`a preset`),menuGlyph:JM(`a preset`)},$M={noun:`preset globals key`,fields:{...UM,...QM},removed:XM};function eN(e){return uN(e)&&!(e in QM)}const tN=`is decided later than any rule could be settled`,nN={noun:`editGlobals key`,removed:XM,fields:{...UM,preset:qM(`the editGlobals fragment`),menuGlyph:JM(`the editGlobals fragment`),palette:YM(UM.palette,`the editGlobals fragment`,tN),style:YM(UM.style,`the editGlobals fragment`,tN),effect:YM(UM.effect,`the editGlobals fragment`,tN)}},rN={noun:`theme default key`,fields:{...Object.fromEntries(Dx.map(e=>[e,UM[e]])),style:YM(UM.style,`a theme's default`,`is the look that theme wears by name`)}};function iN(e,t){if(!xb(t))return e.issues.push({path:`themeDefaults`,message:`themeDefaults must be an object mapping theme names to { shade, variation, style }, got ${Sb(t)}`,line:q(e.source,[`themeDefaults`])}),{};let n={};for(let[r,i]of Object.entries(t)){let t=`themeDefaults.${r}`;if(!e.allowedPalettes.has(r)){e.issues.push({path:t,message:`${t}: "${r}" is not an installed theme${Hv(r)}. Expected one of: ${[...e.allowedPalettes].sort().join(`, `)}`,line:q(e.source,[`themeDefaults`,r])});continue}let a=Cb(e,rN,t,i);a!==null&&(n[r]=a)}return n}function aN(e,t,n){return n===void 0?{}:Cb(e,ZM,t,n)??{}}function oN(e,t,n){return Cb(e,$M,t,n)??{}}function sN(){return Wb($M)}function cN(e,t,n){return Cb(e,nN,t,n)??{}}const lN=new Set(Object.keys(UM));function uN(e){return lN.has(e)}function dN(e){return Object.hasOwn(XM,e)?XM[e]:void 0}function fN(){return[...lN]}const pN=new Map(Object.entries(wx).flatMap(([e,t])=>`floor`in t&&typeof t.floor==`number`?[[e,t.floor]]:[]));function mN(e){let t=new Map;for(let[n,r]of pN){let i=e[n];t.set(n,typeof i==`number`?i:r)}return t}const hN=/^segments\.([^.]+)\.palette$/,gN=/^presets\.(.+)\.root$/,_N=/^presets\.(.+)\.globals\.([^.]+)$/,vN=/^themeDefaults\.(.+)\.([^.]+)$/;function yN(e){return`presets.${e}.root`}function bN(e,t){return`themeDefaults.${e}.${t}`}const xN=e=>Dx.includes(e);function SN(e,t){return`presets.${e}.globals.${t}`}function CN(e){if(uN(e))return{scope:`globals`,field:e};let t=hN.exec(e);if(t)return{scope:`segment-palette`,segment:t[1]};let n=_N.exec(e);if(n&&eN(n[2]))return{scope:`preset-globals`,preset:n[1],field:n[2]};let r=vN.exec(e);if(r&&xN(r[2]))return{scope:`theme-default`,theme:r[1],field:r[2]};let i=gN.exec(e);return i?{scope:`preset-root`,preset:i[1]}:null}function wN(e){switch(e.scope){case`globals`:return[`globals`,e.field];case`preset-globals`:return[`presets`,e.preset,`globals`,e.field];case`segment-palette`:return[`segments`,e.segment,`palette`];case`theme-default`:return[`themeDefaults`,e.theme,e.field]}}const TN=[`location`,`git`,`model-context`,`cost-limits`,`activity`,`session-tools`],EN=[...TN,`other`],DN={location:`location`,git:`git`,"model-context":`model & context`,"cost-limits":`cost & limits`,activity:`activity`,"session-tools":`session tools`,other:`other`},ON=jT({fromString:e=>e});function kN(e){let t=hM(e);return Fi.find(e=>t.startsWith(hM(e)))}function AN(e,t,n,r){for(let i of[`variables`,`actions`,`segments`])for(let a of Object.keys(t[i]??{}))a.startsWith(n)&&e.issues.push({path:`${i}.${a}`,message:`"${a}" is in the reserved "${n}" namespace (synthesized by ${r}) — rename it`,line:q(e.source,[`root`])})}function jN(e,t,n){for(let r of[`variables`,`actions`,`helpers`,`segments`])for(let i of Object.keys(t[r]??{})){let t=NS(i);t!==void 0&&(r!==`variables`&&i===t||r===`segments`&&n.has(i)||e.issues.push({path:`${r}.${i}`,message:`"${i}" is in "${t}", the namespace plugins own (each declares its names there from its own definition) — rename it`,line:q(e.source,[r,i])}))}for(let[r,i]of Object.entries(t.segments??{}))for(let t of Object.keys(i.vars??{})){let i=`${r}.${t}`,a=NS(i);a===void 0||n.has(r)||e.issues.push({path:`segments.${r}.vars.${t}`,message:`segment "${r}"'s var "${t}" is named "${i}", in "${a}", the namespace plugins own — rename the var or the segment`,line:q(e.source,[`segments`,r,`vars`,t])})}}const MN=`edit.mode`,NN=`edit.configure`,PN=`edit.toggle`,FN=`arrange`,IN=`${Pi}draft.`;function LN(e,t){return`${e}:${t}`}const RN={variable:MN,key:MN,member:FN},zN=Ci(RN);function BN(e){try{return ON.parse(e).referencedCalls().some(e=>e.name===`action`&&e.args[0]===`edit.toggle`)}catch{return!1}}function VN(e){if(Object.values(e.actions??{}).some(e=>`do`in e&&e.do.includes(`edit.toggle`)))return!0;for(let t of Object.values(e.segments??{})){let e=[t.template,t.bg,t.fg,...Object.values(t.partials??{})];for(let t of e)if(typeof t==`string`&&BN(t))return!0}return!1}function HN(e,t){if(AN(e,t,Pi,`edit mode`),!VN(t))return;let{variables:n,actions:r}=UN();t.variables={...t.variables??{},...n},t.actions={...t.actions??{},...r}}function UN(){return{variables:{[MN]:{...Oi(MN,gi),within:[zi]},[NN]:{...Oi(NN,gi),within:[RN]}},actions:{[PN]:ki(MN,FN),"edit.unconfigure":{set:NN,to:gi}}}}function WN(e,t,n,r){let i={variable:e,key:e,member:_i};return r.variables[e]={...Oi(e,gi),...n.length>0&&{within:n}},r.actions[e]=ki(e,_i),r.segments[e]={template:Ti(e,`(?)`,`✕`),...GN(n)},Si(e,i,{kind:`container`,direction:`horizontal`,children:t.map((t,n)=>{let i=`${e}.${n}`;return r.segments[i]={template:t},{kind:`segment`,name:i}})},`drop`)}function GN(e){let[t,...n]=e;return t===void 0?{}:{when:Ci(t,...n)}}const KN=`none`;function qN(e){return Bu(e,`background`)}var JN=class extends Error{constructor(e,t,n){super(`Invalid ${t} color ${JSON.stringify(e)}: ${n}`),this.name=`ColorSpecError`}};function YN(e,t,n,r,i){let{palette:a,tint:o,text:s}=e,c=XN(n,i),l=c!==KN,u=l?c===void 0?o:ZN(a,c,`bg`):qN(a);e.bg=u;let d=XN(r,i),f=d===void 0?l?(e=>e.hex===o.hex?s:vv(a,e,t))(u):void 0:ZN(a,d,`fg`);return new U({...l&&{bgcolor:H.fromRgba(u)},...f!==void 0&&{color:H.fromRgba(f)}})}function XN(e,t){if(e!==void 0)return e.evaluate(t).map(e=>e.plain).join(``)}function ZN(e,t,n){try{return Bu(e,t)}catch(e){throw e instanceof zu?new JN(t,n,e.message):e}}const QN=`🔧`,$N={help:[`-h`,`--help`],version:[`-V`,`--version`]},eP=[...new Set(Object.values(Xb).map(e=>BM(e.switch.setting)))].join(` or `),tP=Math.max(...Object.values(Mx).map(e=>e.configKey.length))+2,nP=[`✚ inserts`,`✖ removes`,`${QN} configures`,`↺ resets layout`],rP={band:[`animates the bar in the band above the prompt, through a Claude Code mod`,`on: installs the candybar-band mod from this checkout and types /reload-plugins`],statusline:[`animates the statusline itself, through the attach launcher shipped with cc-candybar`,`on: exits this Claude Code and starts it again under that launcher, on this session`,`or start one yourself: cc-candybar --help prints the line to type`],pane:[`animates the bar in a tmux pane under this session's`,`on: opens that pane · off: closes it`],tmuxStatus:[`draws the bar in the tmux status line, while this session's pane is the one it shows`,`tmux: the daemon draws it there · claude: puts the status line back as it was`]},iP=`
71
71
  cc-candybar - Beautiful powerline statusline for Claude Code
72
72
 
73
73
  Usage: cc-candybar [options]
@@ -173,11 +173,11 @@ Config tooling:
173
173
  config [--json] The effective merged config. (All three query the
174
174
  running daemon; none spawn one.)
175
175
 
176
- `,aP=`readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3`;function oP(e,t){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?t+e.slice(1):e}function sP(e,t,n){return E.resolve(e,oP(t,n))}function cP(e,t,n){return typeof t==`string`&&t!==``?sP(e,t,n):void 0}const lP=`CC_CANDYBAR_CONFIG`;function uP({env:e,home:t},n){return cP(n,e[lP],t)}function dP(e,t){return e===void 0?t===void 0?{source:`search`}:{source:`environment`,path:t}:{source:`argument`,path:e}}function fP(e,t,n){return dP(cP(n,e,t.home),uP(t,n))}function pP(e,t=`bundled default (no config file loaded)`){return e.join(` < `)||t}const mP=new Af({"strip.separator":`default`,"strip.rail":`default`});function hP(e){return mP.resolve(e)}const gP={kind:`still`},_P=e=>kp.at(e.timeline,e.wall),vP=Symbol(`bar`);function yP(e){return e.name!==ry}function bP(e){return t=>G.map(G.all(e.map(({timeline:e,effect:n})=>kp.run(e,n(t)))),e=>(t,n)=>e.reduce((e,t)=>t(e,n),t))}const xP=gee;function SP(e,t){let n=new su(t,xP.foregroundColor,xP.ansiColors,xP.palette);return t=>e({...t,theme:n})}function CP(e,t){return n=>yh(()=>e(n),...t)(n)}function wP(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t/4294967296}const TP=4096;function EP(e,t,n){let r=(n,{terminal:r})=>({...n,bg:r.bg?n.bg:e,fg:r.fg?n.fg:r.bg?e:t}),i=e=>e,a=sx.reduceRight((e,{lit:t,seconds:n})=>G.sequence(G.constant(t?r:i),n,e),G.constant(i)),o=G.sequence(G.constant(i),n,a);return()=>o}var DP=class{inForce=null;anchor=kp.play(0);placements=new Map;made=new Map;passages=null;frame={effect:ry,t:0,speed:1,made:0,reused:0,own:[],basis:`off`,revision:0,fades:[],leaves:[]};constructor(e){this.key=e}lastFrame(){return this.frame}get heldCount(){let e=this.passages?.size??0;return[...this.made.values()].reduce((e,t)=>e+t.size,e)}clockAt(e,t){return{wall:e,timeline:kp.withRate(this.anchor,e,t)}}motion(e,t,n,r=null){let i=_P(t),a=e=>kp.seek(t.timeline,t.wall,e),o=this.inForce?.name===e?this.inForce:{name:e,since:i},s={scope:vP,name:e,t:i-o.since},c=this.placements,l=new Map,u=this.made,d=new Map,f=[],{last:p}=n,m=this.passages,h=n.transitions?m!==null&&p!==null?`compared`:`fresh`:`off`,g=h===`compared`?e=>{let t=p.placements.get(e);return t?.kind===`drew`?{drawing:t.drawing,passage:m.get(e)??null}:void 0}:null,_=new Set,v=new Map,y=[],b=[],x={effect:e,t:s.t,speed:t.timeline.rate,made:0,reused:0,own:f,basis:h,revision:n.source.revision,fades:y,leaves:b},S=(e,t,{ground:n})=>{let r=Ig.transitions[e]({z:wP(`${this.key}@${t}`)*TP});return{name:e,since:i,done:e=>r.done(e),effect:SP(r.effect,n)}},C=({since:e,done:t})=>t(i-e),w=(e,t,n)=>({drawing:t,passage:g===null?null:n===void 0||n.passage?.name===`dissolve`?S(`fade`,e,t):n.passage!==null&&!C(n.passage)?n.passage:null}),T=(e,t)=>{if(t===void 0||t.drawing.opened||t.drawing.own.length===0)return;if(t.passage?.name===`dissolve`)return C(t.passage)?void 0:t;let r={...t.drawing,own:t.drawing.own.map(n.hold)};return{drawing:r,passage:S(`dissolve`,e,r)}},ee=(e,t)=>{if(_.has(e))throw Error(`placement "${e}" was reached twice in one frame`);_.add(e);let r=g?.(e),{drawing:a,deeper:o}=n.returned(e,t),s=a===null?T(e,r):w(e,a,r);return s===void 0?t:(s.passage!==null&&(v.set(e,s.passage),(s.passage.name===`fade`?y:b).push({placement:e,t:i-s.passage.since})),a===null?[...s.drawing.own,...o]:t)},te=(e,t)=>{let n=l.get(e)??c.get(e),r=n?.name===t?n:{name:t,since:i},a=i-r.since;return l.has(e)||(l.set(e,r),f.push({placement:e,effect:t,t:a})),{scope:e,name:t,t:a}},E=(e,t)=>{let n=d.get(e)??new Map;d.set(e,n);let r=n.get(t.scope);if(r!==void 0)return r.effect;let i=u.get(e)?.get(t.scope),a=i?.name===t.name,o=wP(t.scope===vP?e:`${e}@${t.scope}`),s=a?i.effect:Ig.loops[t.name]({z:o*TP});return x[a?`reused`:`made`]++,n.set(t.scope,{name:t.name,effect:s}),s},ne=e=>{let t=new Map;for(let{owner:n,placement:r}of e){let e=r.effect===`bar`?s:te(r.id,r.effect),i=t.get(e.scope);i===void 0?t.set(e.scope,{...e,owners:[n]}):i.owners.push(n)}return[...t.values()]},D=e=>{let t=new Map;for(let{owner:n,placement:r}of e){let e=t.get(r.id);e===void 0?t.set(r.id,[n]):e.push(n)}return[...t].flatMap(([e,t])=>{let n=v.get(e)??null;return n===null?[]:[{timeline:a(i-n.since),effect:yh(n.effect,...t)}]})},re=r===null?[]:[{timeline:kp.play(r.idleSince),effect:EP(r.fill,r.text,dx(r.timeoutS))}],ie=e=>e===`menu`?re:[];return{placed:h===`off`?(e,t)=>t:ee,row:(e,n,r)=>{let i=(r.some(e=>e.placement.effect!==`bar`)?ne(r):[{...s,owners:void 0}]).filter(yP),o=D(r),c=ie(n);if(i.length===0&&o.length===0&&c.length===0)return gP;let l=`${this.key}#${e}`;return{kind:`moving`,time:t.wall,wrap:e=>new mh(e,bP([...i.map(e=>{let t=E(l,e);return{timeline:a(e.t),effect:e.owners===void 0?t:CP(t,e.owners)}}),...o,...c]),{key:l,theme:xP})}},drawn:()=>{this.anchor=t.timeline,this.inForce=o,this.placements=l,this.made=d,this.passages=h===`off`?null:v,this.frame=x}}}},ete=class{sessions=new Map;constructor(e=256){this.maxSessions=e}of(e){let t=this.sessions.get(e)??new DP(e);this.sessions.delete(e),this.sessions.set(e,t);for(let e of this.sessions.keys()){if(this.sessions.size<=this.maxSessions)break;this.sessions.delete(e)}return t}getStats(){let e=0;for(let t of this.sessions.values())e+=t.heldCount;return{sessions:this.sessions.size,effects:e}}};const OP={fg:`#ffffff`,bg:`#c82828`},tte={fg:`#000000`,bg:`#dca028`},nte={fg:`#ffffff`,bg:`#2f6db5`};function kP(e,t){return`\x1b[${e};2;${[1,3,5].map(e=>Number.parseInt(t.slice(e,e+2),16)).join(`;`)}m`}const rte=kP(38,OP.fg),ite=kP(48,OP.bg),ate=[[0,31],[127,159],[8234,8238],[8294,8303]];function ote(e){return ate.some(([t,n])=>e>=t&&e<=n)}function AP(e){let t=``;for(let n of e)t+=ote(n.codePointAt(0)??0)?` `:n;return t.replace(/\s+/g,` `).trim()}function jP(e,t){let n=AP(e),r=``,i=0;for(let e of n){if(i===t)return r.replace(/.$/u,`…`);r+=e,i++}return r}const ste=`${ite}${rte}`;function MP(e){return`⚠ cc-candybar: ${lte(e)}`}function cte(e){return`${ste}${MP(e)}\n`}function lte(e){switch(e.cause){case`version_mismatch`:{let t=e.daemonV===0?`unknown`:`v${e.daemonV}`;return`protocol mismatch (client v${e.clientV} ≠ daemon ${t})`}case`bad_request`:return`daemon rejected request: ${jP(e.message,60)}`;case`render_failed`:return`render failed: ${jP(e.message,60)}`;case`switched_off`:return`switched off: ${jP(e.message,60)}`;case`malformed_response`:return`malformed daemon response: ${jP(e.message,60)}`}}function NP(e,t){return{depth:e.depth,rows:t,nextChange:1/0,motion:e.motion===`still`?`still`:`can-move`,pending:[]}}function PP(e,t){return{depth:`truecolor`,rows:[{kind:`diagnostic`,runs:[{text:AP(e),...t}]}],nextChange:1/0,motion:`still`,pending:[]}}function ute(e){return PP(MP({kind:`permanent`,cause:`render_failed`,message:e}),OP)}function FP(e,t){try{return e(t)}catch(t){return e(PP(`⚠ cc-candybar ${t instanceof Error?t.message:String(t)}`,OP))}}function IP(e){return e.type===V.TRUECOLOR?e.value.hex:e.number===void 0?e.name:`color(${e.number})`}const dte=Object.keys(new U().attributes);function fte(e,t){let{color:n,bgcolor:r}=e.drawnColors(t),i=dte.filter(t=>e[t]===!0);return{...n!==void 0&&{fg:IP(n)},...r!==void 0&&{bg:IP(r)},...i.length>0&&{attrs:i}}}function pte({text:e,style:t},n){return{text:e,...t!==void 0&&n!==null&&fte(t,n),...t?.link!==void 0&&{link:t.link}}}function mte(e,t){let n=e.filter(e=>!e.isControl&&e.text.length>0);return W.splitLines(n).map(e=>e.map(e=>pte(e,t)))}function hte({text:e,fg:t,bg:n,attrs:r=[],link:i}){return new W(e,new U({color:t,bgcolor:n,link:i,...Object.fromEntries(r.map(e=>[e,!0]))}))}function LP(e,t){let n=Rl(t);return e.map(e=>Eee(e.map(hte),n)).join(`
176
+ `,aP=`readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3`;function oP(e,t){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?t+e.slice(1):e}function sP(e,t,n){return E.resolve(e,oP(t,n))}function cP(e,t,n){return typeof t==`string`&&t!==``?sP(e,t,n):void 0}const lP=`CC_CANDYBAR_CONFIG`;function uP({env:e,home:t},n){return cP(n,e[lP],t)}function dP(e,t){return e===void 0?t===void 0?{source:`search`}:{source:`environment`,path:t}:{source:`argument`,path:e}}function fP(e,t,n){return dP(cP(n,e,t.home),uP(t,n))}function pP(e,t=`bundled default (no config file loaded)`){return e.join(` < `)||t}const mP=new Af({"strip.separator":`default`,"strip.rail":`default`});function hP(e){return mP.resolve(e)}const gP={kind:`still`},_P=e=>kp.at(e.timeline,e.wall),vP=Symbol(`bar`);function yP(e){return e.name!==ry}function bP(e){return t=>G.map(G.all(e.map(({timeline:e,effect:n})=>kp.run(e,n(t)))),e=>(t,n)=>e.reduce((e,t)=>t(e,n),t))}const xP=gee;function SP(e,t){let n=new su(t,xP.foregroundColor,xP.ansiColors,xP.palette);return t=>e({...t,theme:n})}function CP(e,t){return n=>yh(()=>e(n),...t)(n)}function wP(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t/4294967296}const TP=4096;function EP(e,t,n){let r=(n,{terminal:r})=>({...n,bg:r.bg?n.bg:e,fg:r.fg?n.fg:r.bg?e:t}),i=e=>e,a=sx.reduceRight((e,{lit:t,seconds:n})=>G.sequence(G.constant(t?r:i),n,e),G.constant(i)),o=G.sequence(G.constant(i),n,a);return()=>o}var DP=class{inForce=null;anchor=kp.play(0);placements=new Map;made=new Map;passages=null;frame={effect:ry,t:0,speed:1,made:0,reused:0,own:[],basis:`off`,revision:0,fades:[],leaves:[]};constructor(e){this.key=e}lastFrame(){return this.frame}get heldCount(){let e=this.passages?.size??0;return[...this.made.values()].reduce((e,t)=>e+t.size,e)}clockAt(e,t){return{wall:e,timeline:kp.withRate(this.anchor,e,t)}}motion(e,t,n,r=null){let i=_P(t),a=e=>kp.seek(t.timeline,t.wall,e),o=this.inForce?.name===e?this.inForce:{name:e,since:i},s={scope:vP,name:e,t:i-o.since},c=this.placements,l=new Map,u=this.made,d=new Map,f=[],{last:p}=n,m=this.passages,h=n.transitions?m!==null&&p!==null?`compared`:`fresh`:`off`,g=h===`compared`?e=>{let t=p.placements.get(e);return t?.kind===`drew`?{drawing:t.drawing,passage:m.get(e)??null}:void 0}:null,_=new Set,v=new Map,y=[],b=[],x={effect:e,t:s.t,speed:t.timeline.rate,made:0,reused:0,own:f,basis:h,revision:n.source.revision,fades:y,leaves:b},S=(e,t,{ground:n})=>{let r=Ig.transitions[e]({z:wP(`${this.key}@${t}`)*TP});return{name:e,since:i,done:e=>r.done(e),effect:SP(r.effect,n)}},C=({since:e,done:t})=>t(i-e),w=(e,t,n)=>({drawing:t,passage:g===null?null:n===void 0||n.passage?.name===`dissolve`?S(`fade`,e,t):n.passage!==null&&!C(n.passage)?n.passage:null}),T=(e,t)=>{if(t===void 0||t.drawing.opened||t.drawing.own.length===0)return;if(t.passage?.name===`dissolve`)return C(t.passage)?void 0:t;let r={...t.drawing,own:t.drawing.own.map(n.hold)};return{drawing:r,passage:S(`dissolve`,e,r)}},ee=(e,t)=>{if(_.has(e))throw Error(`placement "${e}" was reached twice in one frame`);_.add(e);let r=g?.(e),{drawing:a,deeper:o}=n.returned(e,t),s=a===null?T(e,r):w(e,a,r);return s===void 0?t:(s.passage!==null&&(v.set(e,s.passage),(s.passage.name===`fade`?y:b).push({placement:e,t:i-s.passage.since})),a===null?[...s.drawing.own,...o]:t)},te=(e,t)=>{let n=l.get(e)??c.get(e),r=n?.name===t?n:{name:t,since:i},a=i-r.since;return l.has(e)||(l.set(e,r),f.push({placement:e,effect:t,t:a})),{scope:e,name:t,t:a}},E=(e,t)=>{let n=d.get(e)??new Map;d.set(e,n);let r=n.get(t.scope);if(r!==void 0)return r.effect;let i=u.get(e)?.get(t.scope),a=i?.name===t.name,o=wP(t.scope===vP?e:`${e}@${t.scope}`),s=a?i.effect:Ig.loops[t.name]({z:o*TP});return x[a?`reused`:`made`]++,n.set(t.scope,{name:t.name,effect:s}),s},ne=e=>{let t=new Map;for(let{owner:n,placement:r}of e){let e=r.effect===`bar`?s:te(r.id,r.effect),i=t.get(e.scope);i===void 0?t.set(e.scope,{...e,owners:[n]}):i.owners.push(n)}return[...t.values()]},D=e=>{let t=new Map;for(let{owner:n,placement:r}of e){let e=t.get(r.id);e===void 0?t.set(r.id,[n]):e.push(n)}return[...t].flatMap(([e,t])=>{let n=v.get(e)??null;return n===null?[]:[{timeline:a(i-n.since),effect:yh(n.effect,...t)}]})},O=r===null?[]:[{timeline:kp.play(r.idleSince),effect:EP(r.fill,r.text,dx(r.timeoutS))}],re=e=>e===`menu`?O:[];return{placed:h===`off`?(e,t)=>t:ee,row:(e,n,r)=>{let i=(r.some(e=>e.placement.effect!==`bar`)?ne(r):[{...s,owners:void 0}]).filter(yP),o=D(r),c=re(n);if(i.length===0&&o.length===0&&c.length===0)return gP;let l=`${this.key}#${e}`;return{kind:`moving`,time:t.wall,wrap:e=>new mh(e,bP([...i.map(e=>{let t=E(l,e);return{timeline:a(e.t),effect:e.owners===void 0?t:CP(t,e.owners)}}),...o,...c]),{key:l,theme:xP})}},drawn:()=>{this.anchor=t.timeline,this.inForce=o,this.placements=l,this.made=d,this.passages=h===`off`?null:v,this.frame=x}}}},ete=class{sessions=new Map;constructor(e=256){this.maxSessions=e}of(e){let t=this.sessions.get(e)??new DP(e);this.sessions.delete(e),this.sessions.set(e,t);for(let e of this.sessions.keys()){if(this.sessions.size<=this.maxSessions)break;this.sessions.delete(e)}return t}getStats(){let e=0;for(let t of this.sessions.values())e+=t.heldCount;return{sessions:this.sessions.size,effects:e}}};const OP={fg:`#ffffff`,bg:`#c82828`},tte={fg:`#000000`,bg:`#dca028`},nte={fg:`#ffffff`,bg:`#2f6db5`};function kP(e,t){return`\x1b[${e};2;${[1,3,5].map(e=>Number.parseInt(t.slice(e,e+2),16)).join(`;`)}m`}const rte=kP(38,OP.fg),ite=kP(48,OP.bg),ate=[[0,31],[127,159],[8234,8238],[8294,8303]];function ote(e){return ate.some(([t,n])=>e>=t&&e<=n)}function AP(e){let t=``;for(let n of e)t+=ote(n.codePointAt(0)??0)?` `:n;return t.replace(/\s+/g,` `).trim()}function jP(e,t){let n=AP(e),r=``,i=0;for(let e of n){if(i===t)return r.replace(/.$/u,`…`);r+=e,i++}return r}const ste=`${ite}${rte}`;function MP(e){return`⚠ cc-candybar: ${lte(e)}`}function cte(e){return`${ste}${MP(e)}\n`}function lte(e){switch(e.cause){case`version_mismatch`:{let t=e.daemonV===0?`unknown`:`v${e.daemonV}`;return`protocol mismatch (client v${e.clientV} ≠ daemon ${t})`}case`bad_request`:return`daemon rejected request: ${jP(e.message,60)}`;case`render_failed`:return`render failed: ${jP(e.message,60)}`;case`switched_off`:return`switched off: ${jP(e.message,60)}`;case`malformed_response`:return`malformed daemon response: ${jP(e.message,60)}`}}function NP(e,t){return{depth:e.depth,rows:t,nextChange:1/0,motion:e.motion===`still`?`still`:`can-move`,pending:[]}}function PP(e,t){return{depth:`truecolor`,rows:[{kind:`diagnostic`,runs:[{text:AP(e),...t}]}],nextChange:1/0,motion:`still`,pending:[]}}function ute(e){return PP(MP({kind:`permanent`,cause:`render_failed`,message:e}),OP)}function FP(e,t){try{return e(t)}catch(t){return e(PP(`⚠ cc-candybar ${t instanceof Error?t.message:String(t)}`,OP))}}function IP(e){return e.type===V.TRUECOLOR?e.value.hex:e.number===void 0?e.name:`color(${e.number})`}const dte=Object.keys(new U().attributes);function fte(e,t){let{color:n,bgcolor:r}=e.drawnColors(t),i=dte.filter(t=>e[t]===!0);return{...n!==void 0&&{fg:IP(n)},...r!==void 0&&{bg:IP(r)},...i.length>0&&{attrs:i}}}function pte({text:e,style:t},n){return{text:e,...t!==void 0&&n!==null&&fte(t,n),...t?.link!==void 0&&{link:t.link}}}function mte(e,t){let n=e.filter(e=>!e.isControl&&e.text.length>0);return W.splitLines(n).map(e=>e.map(e=>pte(e,t)))}function hte({text:e,fg:t,bg:n,attrs:r=[],link:i}){return new W(e,new U({color:t,bgcolor:n,link:i,...Object.fromEntries(r.map(e=>[e,!0]))}))}function LP(e,t){let n=Rl(t);return e.map(e=>Eee(e.map(hte),n)).join(`
177
177
  `)}function RP(e){return LP(e.rows.map(e=>e.runs),e.depth)}function gte(e){return RP(e)+`
178
178
  `}const _te=(e,t)=>e.fg===t.fg&&e.bg===t.bg&&e.link===t.link&&e.attrs?.join()===t.attrs?.join();function zP({runs:e}){let t=[];for(let n of e){let e=t.at(-1);e!==void 0&&_te(e,n)?t[t.length-1]={...e,text:e.text+n.text}:t.push(n)}return t}function BP(e){return e.map(e=>e.text).join(``)}const vte={};function VP(e,t){let n=Rl(t.colorSystem),{time:r}=t,i=1/0,a=[...tp(e,{maxWidth:t.width??80,isTerminal:!1,asciiOnly:!1,theme:mP,colorSystem:n.colorSystem,...r===void 0?{}:{frame:{time:r,host:vte}},onStyleError:e=>{throw e},onHold:({nextChange:e})=>{i=Math.min(i,e)}})];return{lines:mte(a,n.colorSystem),nextChange:Math.min(W.nextChange(a),i)}}const HP=new Map;function yte(e){let t=HP.get(e);if(t!==void 0)return t;let n=t=>({seam:t.seam.map(t=>`cap`in t?t:{...t,glyph:e})}),{seam:r,caps:i}=ph.plain,a=new Lm({glyph:n(r.glyph),ascii:r.ascii},i);return HP.set(e,a),a}function UP(e,t){return e===`plain`&&t!==void 0?yte(t):ph[e]}const WP=new Map;function GP(e){let t=JSON.stringify([e.endcaps,e.separator??null]),n=WP.get(t);if(n!==void 0)return n;let r=UP(e.endcaps,e.separator),i=e=>new K(`x`,{end:``,overflow:`ignore`,style:new U({bgcolor:e})}),a=e=>{let{lines:t}=VP(new om(e,r),{colorSystem:null});return new K(BP(t.flat())).cellLength},o=a([i(`#101010`)]),s={chrome:o-1,seam:a([i(`#101010`),i(`#202020`)])-o-1};return WP.set(t,s),s}function KP(e){return GP(e).chrome}function qP(e){return GP(e).seam}const bte=/[\u{E000}-\u{F8FF}\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}]/gu;function JP(e){return[...new Set(e.match(bte)??[])].join(``)}function xte(e){let t=UP(e.endcaps,e.separator),n=e=>new K(`x`,{end:``,style:new U({bgcolor:e})}),{lines:r}=VP(new om([n(`#101010`),n(`#202020`)],t),{colorSystem:null});return JP(BP(r.flat()))}function YP(e){return e.wrap?e.width:1/0}function Ste(e,t){return VP(new K(e,{overflow:`fold`,end:``}),{colorSystem:null,width:t}).lines.map(BP)}function XP(e,t,n=gP){if(e.length===0)return{lines:[[]],nextChange:1/0};let r=UP(t.endcaps,t.separator),i=Number.isFinite(YP(t)),a={colorSystem:t.colorCompatibility,...i?{width:t.width}:{}},o=i?new h_([...e],{joiner:r}):new om([...e],r),s=n.kind===`still`?VP(o,a):VP(n.wrap(o),{...a,time:n.time});if(s.lines.length===0)throw Error(`drawStripCells: rich-js strip drew no line`);return s}function Cte(e,t){return LP(XP(e,t).lines,t.colorCompatibility)}const wte=[`moves`,`can-move`,`still`];function ZP(e){let t=e.context_window?.current_usage;return t===null?`no`:t===void 0?`unknown`:`yes`}const Tte=[`statusline`,`frames`],QP=e=>e?.kind===`frames`?`frames`:`statusline`,Ete=[`carried`,`missing`,`unanswered`];function Dte(e){let t=e.rate_limits;return t?.five_hour!=null||t?.seven_day!=null?`carried`:ZP(e)===`no`?`unanswered`:`missing`}function Ote(e){return{path:e.transcript_path,answered:ZP(e)===`yes`}}const $P=[...wte,`failed`,`drawing`];var kte=class{seen=new Map;see(e,t,n,r){let i=QP(t.client),a=JSON.stringify([e,i]),o=this.seen.get(a);o!==void 0&&o.order>r||(this.seen.delete(a),this.seen.set(a,{sessionId:e,said:{...t,role:i},at:n,order:r}),this.seen.size>64&&this.seen.delete(this.seen.keys().next().value))}list(e){return[...this.seen.values()].map(({sessionId:t,said:n,at:r})=>({...n,sessionId:t,ago:e-r}))}ofSession(e,t){return this.list(t).filter(t=>t.sessionId===e)}};const eF={kitty:{label:`kitty`,xtversion:`kitty`,program:null,programVersion:!0,term:`xterm-kitty`,links:{since:`0.19.0`},glyphs:{kind:`bundled`,since:`0.36.0`}},wezterm:{label:`WezTerm`,xtversion:`WezTerm`,program:`WezTerm`,programVersion:!0,term:`wezterm`,links:{since:null},glyphs:{kind:`bundled`,since:`20230712`}},ghostty:{label:`Ghostty`,xtversion:`ghostty`,program:`ghostty`,programVersion:!0,term:`xterm-ghostty`,links:{since:null},glyphs:{kind:`bundled`,since:null}},iterm2:{label:`iTerm2`,xtversion:`iTerm2`,program:`iTerm.app`,programVersion:!0,term:null,links:{since:`3.1`},glyphs:{kind:`configured`}},alacritty:{label:`Alacritty`,xtversion:`alacritty`,program:null,programVersion:!0,term:`alacritty`,links:{since:`0.11.0`},glyphs:{kind:`configured`}},"apple-terminal":{label:`Terminal`,xtversion:null,program:`Apple_Terminal`,programVersion:!0,term:null,links:null,glyphs:{kind:`unread`}},vscode:{label:`VS Code`,xtversion:null,program:`vscode`,programVersion:!1,term:null,links:{since:`1.72`},glyphs:{kind:`unread`}}},tF=e=>eF[e];function Ate(e){return tF(e).glyphs.kind===`bundled`}function jte(e){return tF(e).glyphs.kind===`configured`}const nF=e=>tF(e).label,Mte=[{since:`3.5.0`,from:57504,to:57507},{since:`3.5.0`,from:57520,to:57554},{since:`3.5.0`,from:57556,to:57556},{since:`3.5.6`,from:57558,to:57559}];function Nte(e,t){let n=t.codePointAt(0);return Mte.some(({since:t,from:r,to:i})=>r<=n&&n<=i&&e!==null&&aF(e,t)===!0)}const rF=Object.keys(eF);function iF(e){let t=/^\d+(?:\.\d+)*/.exec(e);return t===null?null:t[0].split(`.`).map(Number)}function aF(e,t){let n=iF(e),r=iF(t);if(n===null)return null;for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]??0,i=r[e]??0;if(t!==i)return t>i}return!0}function Pte(e){for(let t of rF){let n=tF(t).xtversion;if(n!==null&&e.toLowerCase().startsWith(n.toLowerCase())){let r=e.slice(n.length).replace(/^[\s(]+/,``);return{name:t,version:/^[^\s)]+/.exec(r)?.[0]??null}}}return null}function oF(e){let t=rF.find(t=>tF(t).term===e);return t===void 0?null:{name:t,version:null}}function Fte(e){let t=Pte(e.termtype)??oF(e.termname);if(t!==null)return{kind:`known`,terminal:t};let n=/^[^\s(]*/.exec(e.termtype)[0];return n===``?{kind:`unnamed`,term:e.termname}:{kind:`unknown`,called:n}}function Ite(e){let t=e.TERM_PROGRAM,n=rF.find(e=>tF(e).program===t),r=n===void 0?oF(e.TERM):{name:n,version:tF(n).programVersion?e.TERM_PROGRAM_VERSION??null:null};return r===null?t===void 0||t===`tmux`?{kind:`unnamed`,term:e.TERM??``}:{kind:`unknown`,called:t}:{kind:`known`,terminal:r}}function sF(e){switch(e.kind){case`known`:return nF(e.terminal.name);case`unknown`:return e.called;case`unnamed`:return e.term||null}}function cF(e){switch(e.kind){case`known`:return nF(e.terminal.name);case`unknown`:return e.called;case`unnamed`:return e.term||`this terminal`}}function Lte({name:e,version:t}){let n=tF(e).links;if(n===null)return{kind:`none`};if(n.since===null)return{kind:`draws`};if(t===null)return{kind:`unsaid`,since:n.since};let r=aF(t,n.since);return r===null?{kind:`unsaid`,since:n.since}:r?{kind:`draws`}:{kind:`older`,since:n.since,version:t}}const Rte=rF.filter(e=>tF(e).links!==null).map(nF).join(`, `);function lF(e){if(e.kind===`failed`)return{kind:`unread`,reason:e.reason};let t=e.value.flatMap(({scope:e,path:t,settings:n})=>`statusLine`in n?[{from:{scope:e,path:t},line:n.statusLine}]:[]),n=t[0];if(n===void 0)return{kind:`absent`,read:e.value.map(e=>e.path)};if(!ls(n.line))return{kind:`not-an-object`,value:n.line,from:n.from};for(let{from:e,line:r}of t){if(e.scope!==n.from.scope||!ls(r))break;if(`refreshInterval`in r)return{kind:`present`,refreshInterval:r.refreshInterval,from:e}}return{kind:`present`,refreshInterval:void 0,from:n.from}}function uF(e,t){if(e.kind===`failed`)return e;let n=e.value.find(e=>Object.hasOwn(e.env,t));return{kind:`ok`,value:n===void 0?{kind:`unset`}:{kind:`set`,value:n.env[t],from:{scope:n.scope,path:n.path}}}}const zte=[`managed`,`project`],Bte=e=>!zte.includes(e.scope),Vte={managed:()=>null,"project-local":e=>({scope:`project-local`,path:e}),project:(e,t)=>({scope:`project-local`,path:os(t.projectDir)}),user:e=>({scope:`user`,path:e})},dF=[`drawn`,`boxes`],fF=1024*1024,pF=e=>e.kind===`session`?`session ${e.sessionId}'s statusline client`:`this command's terminal`;function Hte(e){switch(e.kind){case`claude-settings`:return`${e.kind} ${e.path.join(`.`)}=${JSON.stringify(e.value)} file=${JSON.stringify(e.file.path)} scope=${e.file.scope}`;case`post-mortems-read`:return`${e.kind} through=${e.through}`}}function mF(e){let[t,...n]=e;return t===void 0?{ok:!0}:{ok:!1,reason:t,more:n}}const hF=Mc.truecolor;function gF(e,t){switch(e.kind){case`unreported`:return{ok:!1,reason:"the client reported no tmux facts — re-run `cc-candybar install` to stage a current client"};case`outside`:return{ok:!0};case`inside`:return e.client.kind===`failed`?{ok:!1,reason:`tmux could not be asked: ${e.client.reason}`}:e.client.value===null?{ok:!0}:t(e.client.value,e.hint)}}const Ute={name:`tmuxTruecolor`,label:`tmux truecolor`,takesMark:!1,probe:({tmux:e,claudeSettings:{origin:t}})=>gF(e,(e,n)=>{if(!e.features.includes(`RGB`)||n.truecolor!==null)return{ok:!0};let r=uF(t.sources,hF);if(r.kind===`failed`)return{ok:!1,reason:r.reason};let i=r.value;if(i.kind===`set`&&typeof i.value==`string`&&i.value!==``)return{ok:!1,reason:`${hF} is set in ${i.from.path} — restart Claude Code to apply`};let a=`Claude Code renders the bar in 256 colours inside tmux`,o=e=>({ok:!1,reason:a,fix:{kind:`claude-settings`,file:e,path:[`env`,hF],value:`1`}});if(i.kind===`unset`)return o({scope:`user`,path:t.at.userFile});let s=Vte[i.from.scope](i.from.path,t.at);return s===null?{ok:!1,reason:`${a} — the value that counts is in managed settings, ${i.from.path}: set ${hF} to "1" there`}:o(s)})},Wte={name:`utf8`,label:`UTF-8`,takesMark:!1,probe:({tmux:e})=>gF(e,e=>e.utf8?{ok:!0}:{ok:!1,reason:"tmux draws this terminal without UTF-8, so every glyph on the bar arrives as `_` — attach with `tmux -u`, or set a UTF-8 LC_ALL/LC_CTYPE/LANG in the shell that runs tmux"})},Gte={name:`termWidth`,label:`terminal width`,takesMark:!1,probe:({width:e})=>e.kind===`failed`?{ok:!1,reason:e.reason}:e.value.columns===null?{ok:!1,reason:`${pF(e.value.of)} measured no width (no COLUMNS, and no terminal to ask — or the daemon refused the width sent, which the bar's diagnostics name), so the bar is laid out as if the terminal were 120 columns wide`}:{ok:!0,note:`${e.value.columns} columns, as ${pF(e.value.of)} measured`}},Kte={variable:`is never read`,action:`is never clicked`,helper:`is never called`,segment:`is in no preset`},qte={argument:`command argument`,environment:`$${lP}`,pick:`load-config pick`,unknown:`source unknown`};function Jte({target:e,layers:t}){return e.source===`search`?t.length===0?pP(t):`${pP(t)} (searched)`:`${e.path} (${qte[e.source]})`}function Yte(e){switch(e.kind){case`failed`:{let t=[...e.error.split(`
179
179
  `).map(e=>e.trim()).filter(e=>e!==``),...e.warnings];return t.length===0?[`the config failed to load`]:t}case`loaded`:return[...e.warnings,...e.unused.map(({kind:e,name:t})=>`${e} "${t}" ${Kte[e]}`)]}}const Xte={name:`config`,label:`config`,takesMark:!1,probe:({config:e})=>{let t=Jte(e),n=mF(Yte(e));return n.ok?{ok:!0,note:t}:{...n,reason:`${t}: ${n.reason}`}}},_F="re-run `cc-candybar install`";function Zte(e){if(e.kind===`failed`)return[`Launch Services could not be asked which app opens cc-candybar:// — ${e.reason}`];if(e.value===null)return[`no app is registered for cc-candybar:// — ${_F}`];let{app:t,forwarder:n}=e.value;return n?[]:[`${t} opens cc-candybar://, but it is not the forwarder app \`cc-candybar install\` builds — ${_F}`]}const Qte={name:`urlHandler`,label:`URL handler`,takesMark:!1,probe:({urlHandler:e})=>{switch(e.kind){case`unsupported`:return{ok:!0};case`unprobed`:return{ok:!1,reason:e.reason};case`arrived`:return e.delivery.kind===`forwarder`?{ok:!0}:{ok:!1,reason:`the link was delivered by a click request (\`cc-candybar url-handle\`), not the forwarder app — ${_F}`};case`lost`:return mF([...Zte(e.opener),e.unopened===null?`a cc-candybar:// link was opened and did not arrive at the daemon`:`a cc-candybar:// link could not be opened — ${e.unopened}`])}}};function vF({bundle:e,checkout:t},n){return{bundle:n.bundle.kind===`failed`?{kind:`unresolved`,reason:n.bundle.reason}:n.bundle.value===e?{kind:`same`}:{kind:`other`,path:n.bundle.value},source:n.client!==`native`||t===null?{kind:`uncompared`}:t.rustSource.kind===`failed`?{kind:`unreadable`,root:t.root,reason:t.rustSource.reason}:n.source===null?{kind:`unstamped`}:n.source===t.rustSource.value?{kind:`same`}:{kind:`other`,root:t.root}}}function yF(e,t){return t===`frames`?`run \`node ${e.bundle} frames --lane <${Zb.join(`|`)}>\``:e.checkout===null?_F:`run \`just install-rust\` and point the statusLine command at ${e.checkout.root}/bin/cc-candybar-native`}function $te(e,t,n){let{checkout:r}=e;if(n.kind===`unreported`)return[`the bar is drawn by a statusline client too old to say what it is — ${yF(e,`native`)}`];let{bundle:i,source:a}=vF(e,n);switch(i.kind){case`unresolved`:return[`the statusline client's bundle cannot be resolved: ${i.reason}`];case`other`:return[`the statusline client runs ${i.path}, not the daemon's ${e.bundle} — ${yF(e,n.client)}`];case`same`:break}if(n.client===`node`&&(t||r!==null))return[`the bar is drawn by the Node fallback, which starts node on every render — ${yF(e,`native`)}`];switch(a.kind){case`uncompared`:case`same`:return[];case`unreadable`:return[`${a.root}/rust-client could not be read: ${a.reason}`];case`unstamped`:return["the native client carries no source stamp, so which source it was built from is unknown — run `just install-rust`"];case`other`:return[`the native client was built from other source than ${a.root}/rust-client holds — run \`just install-rust\``]}}const bF=e=>{let t=`restarted since the bar was drawn, or has served 64 newer sessions`;return e.kind===`clicked`?`this daemon holds no render of this bar (it ${t})`:`this daemon holds no render of session ${e.sessionId}'s bar (its statusLine does not run cc-candybar — a \`claude -p\` session draws none — or the daemon ${t}; unset CLAUDE_CODE_SESSION_ID to judge every bar drawn recently)`},ene={name:`install`,label:`install`,takesMark:!1,probe:({install:e,sighted:t})=>{if(e.kind===`failed`)return{ok:!1,reason:`the daemon could not be asked which clients draw the bar: ${e.reason}`};let{daemon:n,nativeShipped:r,clients:i}=e.value;return i.length===0?{ok:!1,reason:t.kind===`recent`?`no statusline client has drawn a bar for this daemon in the last ${300/60} minutes — run the doctor again once the bar has redrawn; if it never does, the statusLine command does not run cc-candybar`:`${bF(t)}, so which client draws it is unknown — run the doctor again once the bar has redrawn`}:mF([...new Set(i.flatMap(e=>$te(n,r,e)))])}};function xF({postMortems:e},t){return e.kind===`ok`&&t.kind===`ok`?e.value.filter(e=>t.value.through===null||Rr(e.identity,t.value.through)):[]}function SF(e,t){return e.kind===`failed`?t:t.filter(t=>t.pid!==e.value.pid)}const tne={name:`daemon`,label:`daemon`,takesMark:!1,probe:({daemon:{serving:e,processes:t,read:n}})=>{let r=t.kind===`failed`?[`the process table could not be read: ${t.reason}`]:[],i=t.kind===`ok`?SF(e,t.value):[];if(e.kind===`failed`){let t=i.length>0?` — daemon ${i.map(e=>e.pid).join(`, `)} running`:``;return mF([`${e.reason}${t}`,...r])}let{pid:a,memory:o,limit:s,postMortems:c}=e.value,l=xF(e.value,n),u=mF([...l.map(e=>`the daemon ran out of memory and restarted (${e.identity}) — post-mortem: ${Object.values(e.artifacts).join(`, `)}`),...c.kind===`failed`?[`the daemon's post-mortems could not be listed: ${c.reason}`]:[],...n.kind===`failed`&&!(c.kind===`ok`&&c.value.length===0)?[`which post-mortems were read could not be read: ${n.reason}`]:[],...r,...i.map(e=>`daemon ${e.pid} (started ${e.started}, rss ${Fr(e.rss)} MB${e.ppid===1?``:`, child of ${e.ppid}`}) runs beside the one serving the bar (${a}) — \`kill ${e.pid}\``),...o.kind===`measured`&&o.charge.kind===`stand-in`?[`the daemon could not read what macOS charges it (${o.charge.unread}), so its memory limit judges ${o.charge.gap===0?`RSS, which counts pages macOS has reclaimed`:`RSS less the ${Fr(o.charge.gap)} MB it last ran over that charge, an estimate`}`]:[],...o.kind===`measured`&&Vr(o.charge.bytes,s)?[`the daemon holds ${Gr(o.charge)} of its ${Fr(s)} MB limit — at the limit it records a post-mortem and restarts`]:[]]);if(u.ok&&o.kind===`unmeasured`)return{ok:!0,note:`the daemon has not measured its memory yet`};let d=l[0];return u.ok||d===void 0?u:{...u,fix:{kind:`post-mortems-read`,through:d.identity}}}},CF=`click 🩺 doctor in the bar's settings menu: if it runs, links work`;function nne(e,t){let n=sF(e);return t.kind===`ok`&&n!==null&&t.value.includes(n)?{kind:`draws`}:e.kind===`known`?Lte(e.terminal):{kind:`unknown`}}function rne({identified:e,tmuxClient:t},n){let r=cF(e),i=nne(e,n),a=sF(e)===null?CF:`${CF}, and the doctor remembers it for this terminal`,o=(()=>{switch(i.kind){case`draws`:return[];case`none`:return[`${r} draws no links (OSC 8), so nothing on the bar can be clicked — run Claude Code in a terminal that draws them: ${Rte}`];case`older`:return[`${r} ${i.version} draws no links (OSC 8 came in ${i.since}) — update ${r}`];case`unsaid`:return[`${r} draws links (OSC 8) since ${i.since}, and did not say which release this is — ${a}`];case`unknown`:return[`the doctor does not know whether ${r} draws links (OSC 8) — ${a}`]}})(),s=n.kind===`failed`&&i.kind!==`draws`?[`the terminals a doctor click came back from could not be read: ${n.reason}`]:[],c=i.kind===`none`||t===null||t.features.includes(`hyperlinks`)?[]:[`tmux does not pass links through to ${r} — add \`set -as terminal-features ",${t.termname}:hyperlinks"\` to tmux.conf, then detach and reattach (tmux 3.4 or later)`];return[...o,...s,...c]}const ine={name:`links`,label:`links`,takesMark:!1,probe:({sighted:e,terminal:t,clicked:n})=>{if(e.kind===`clicked`&&e.via===`link`)return{ok:!0};switch(t.kind){case`unreported`:return{ok:!1,reason:"the client reported no terminal — re-run `cc-candybar install` to stage a current client"};case`unasked`:return{ok:!1,reason:`tmux could not be asked which terminal is attached: ${t.reason}`};case`seen`:return mF(rne(t,n))}}},wF=e=>e.filter(e=>e.role===`statusline`),ane={name:`effectRefresh`,label:`effect refresh`,takesMark:!1,probe:({frames:e,claudeSettings:{origin:t,elsewhere:n},sighted:r})=>{let i=[t,...n].flatMap(({sources:e,bars:t})=>sne(e,one(t))??[]),[a]=i;if(a===void 0)return e.kind===`failed`?{ok:!1,reason:e.reason}:TF(r.kind===`recent`?`no session has drawn a statusline for this daemon in the last ${300/60} minutes`:bF(r));let[o,...s]=i.flatMap(e=>e.ok?[]:[e]);if(o===void 0)return a;let c=[...new Set(s.map(e=>e.reason))].filter(e=>e!==o.reason);return c.length===0?o:{...o,more:c}}},one=e=>{let t=wF(e).map(e=>e.frame);return t.includes(`moves`)?{kind:`moving`,wearing:`the bar moves (an effect, a fade, an animated segment, or an open menu counting down to its close)`}:t.includes(`can-move`)?{kind:`moving`,wearing:`the bar can start moving (an open menu, which flashes and closes on its own, a globals.effect rule, placements that fade in and out, a placement with an effect of its own that is not drawn now, or a moving bar handed off to another lane, which comes back here when the handoff ends)`}:t.includes(`still`)?{kind:`still`}:t.includes(`drawing`)?{kind:`unknown`,unseen:`the bar's latest render has not finished`}:t.length>0?{kind:`unknown`,unseen:`the bar's recent renders failed`}:e.length>0?{kind:`unknown`,unseen:"only a `cc-candybar frames` display has drawn this bar, not Claude Code's statusline"}:{kind:`none`}},TF=e=>({ok:!1,reason:`${e}, so whether it moves is unknown — run the doctor again once the bar has redrawn`});function sne(e,t){let n=lF(e);if(n.kind===`present`&&n.refreshInterval===1)return{ok:!0,note:`statusLine.refreshInterval is 1 in ${n.from.path}`};switch(t.kind){case`none`:return null;case`still`:return{ok:!0};case`unknown`:return TF(t.unseen);case`moving`:break}let{wearing:r}=t;switch(n.kind){case`unread`:return{ok:!1,reason:`${r}, and Claude Code's settings could not be read: ${n.reason}`};case`absent`:return{ok:!1,reason:`${r}, and no settings file Claude Code reads here sets a statusLine (read: ${n.read.join(`, `)||`none`}) — the one that runs the bar comes from --settings, MDM or server-managed settings, which the doctor cannot read; set "refreshInterval": 1 beside its command there`};case`not-an-object`:return{ok:!1,reason:`${r}, and ${n.from.path} sets statusLine to ${JSON.stringify(n.value)}, not a statusLine object — ${n.from.scope===`user`?"re-run `cc-candybar install` to write one":`replace it there with the statusLine object that runs cc-candybar`}`};case`present`:{let{from:e,refreshInterval:t}=n,i=t===void 0?`its statusLine sets no refreshInterval, so Claude Code redraws it only on events`:typeof t==`number`&&t>1?`its statusLine redraws it only every ${t} s`:`its statusLine.refreshInterval is ${JSON.stringify(t)}, not a number of seconds Claude Code accepts (its minimum is 1)`;return Bte(e)?{ok:!1,reason:`${r}, but ${i} (statusLine from ${e.path})`,fix:{kind:`claude-settings`,file:e,path:[`statusLine`,`refreshInterval`],value:1}}:{ok:!1,reason:`${r}, but ${i} — its statusLine is in ${e.scope===`managed`?`managed settings`:`the project's shared settings`}, ${e.path}: set "refreshInterval": 1 there`}}}}const EF=e=>[...e].map(e=>`U+${e.codePointAt(0).toString(16).toUpperCase()}`).join(` `);function cne(e){switch(e.kind){case`unreported`:case`unasked`:return`this terminal`;case`unknown`:case`unnamed`:return cF(e);case`bundling`:case`unread`:case`configured`:return[nF(e.name),e.version].filter(e=>e!==null).join(` `)}}function lne(e){switch(e.kind){case`unreported`:case`unasked`:return null;case`unknown`:case`unnamed`:return sF(e);case`bundling`:case`unread`:return nF(e.name);case`configured`:{let t=nF(e.name);return e.font.kind===`ok`?`${t} with ${e.font.value.font} (${e.font.value.from})`:`${t}, its font unread: ${e.font.reason}`}}}function DF(e){let t=lne(e.terminal);return t===null?void 0:{glyphs:e.glyphs,id:`${t}|${EF(e.glyphs)}`}}const OF={name:`nerdFont`,label:`Nerd Font`,takesMark:!0,probe:({nerdFont:e,marks:t})=>{if(e.kind===`none`)return{ok:!0};let n=DF(e),r=e=>t.kind===`failed`&&n!==void 0?{ok:!1,reason:e,more:[`the mark book could not be read: ${t.reason}`]}:{ok:!1,reason:e,...n!==void 0&&{sighting:n}},i=e.terminal,a=cne(i);switch(n===void 0||t.kind===`failed`?null:t.value.nerdFont?.[n.id]??null){case`drawn`:return{ok:!0};case`boxes`:return r(`${a} draws ${EF(e.glyphs)} as boxes — set a Nerd Font as its font`);case null:break}switch(i.kind){case`unreported`:return r("the client reported no terminal — re-run `cc-candybar install` to stage a current client");case`unasked`:return r(`tmux could not be asked which terminal is attached: ${i.reason}`);case`unknown`:case`unnamed`:case`unread`:return r(`the doctor cannot read ${a}'s font`);case`bundling`:{let e=eF[i.name].glyphs.since;if(e===null)return{ok:!0};let t=i.version===null?null:aF(i.version,e);if(t===!0)return{ok:!0};let n=nF(i.name);return r(t===null?`${n} ships Nerd Font symbols since ${e}, and did not say which release this is`:`${a} ships no Nerd Font symbols (they came in ${e}) — update ${n}, or set a Nerd Font as its font`)}case`configured`:{if(i.font.kind===`failed`)return r(`the doctor cannot read ${a}'s font: ${i.font.reason}`);let{font:e,from:t,lacks:n}=i.font.value;return n===null?r(`${a} is set to ${e} (${t}), which is not installed — install it or set a Nerd Font`):n.length===0?{ok:!0}:r(`${a} draws with ${e} (${t}), which has no ${EF(n)} — set a Nerd Font as its font`)}}}};function kF(e){return e.join(`, `)}function AF(e){return`or set missingData: "ignore" on ${kF(e)}`}function jF(e){if(e.kind===`unneeded`)return[];let{segments:t,fact:n}=e;if(n.kind===`failed`)return[`${kF(t)}: whether the forge CLI is ready could not be asked: ${n.reason}`];if(n.value===null)return[];let{cli:r,host:i,status:a}=n.value;return a===`ready`?[]:a===`missing`?[`${kF(t)}: ${r} is not installed, so no pull request is ever shown — install it, ${AF(t)}`]:[`${kF(t)}: ${r} is not logged in to ${i} (${a.loggedOut}) — run \`${r} auth login --hostname ${i}\`, ${AF(t)}`]}function MF(e,t){if(e.kind===`unneeded`)return[];let{segments:n,fact:r}=e;return r.kind===`failed`?[`${kF(n)}: ${r.reason}`]:r.value.length===0?[t.kind===`recent`?`${kF(n)}: no session of this Claude Code has drawn a bar for this daemon in the last ${300/60} minutes, so whether it sends rate_limits is unseen — run the doctor again once the bar has redrawn`:`${kF(n)}: ${bF(t)}, so whether Claude Code sends rate_limits is unseen — run the doctor again once the bar has redrawn`]:r.value.includes(`missing`)&&!r.value.includes(`carried`)?[`${kF(n)}: Claude Code sent no rate_limits — it sends them only to Claude.ai subscription sessions; on any other account, set missingData: "ignore" on ${kF(n)}`]:[]}const NF={name:`segmentData`,label:`segment data`,takesMark:!1,probe:({data:e,sighted:t})=>mF([...jF(e.pullRequests),...MF(e.rateLimits,t)])};function PF({path:e,answered:t,read:n}){switch(n.kind){case`absent`:return t?[`the transcript ${e} does not exist, though Claude Code has answered in its session — the bar's session cost, metrics and activity read nothing`]:[];case`failed`:return[`the transcript ${e} cannot be read: ${n.reason}`];case`ok`:{let{lines:t,unparsed:r,whole:i}=n.value;return r===0?[]:[`${r} of the ${t} lines ${i?`in`:`in the last ${fF/1024/1024} MiB of`} the transcript ${e} are not JSON objects — the bar skips them, so what it counts from them is missing`]}}}const FF=[Xte,ene,tne,Qte,ine,Ute,Wte,Gte,ane,OF,NF,{name:`sessionData`,label:`session data`,takesMark:!1,probe:({transcripts:e,sighted:t})=>e.kind===`failed`?{ok:!1,reason:e.reason}:e.value.length===0?{ok:!1,reason:t.kind===`recent`?`no session has drawn a bar for this daemon in the last ${300/60} minutes, so no transcript was named — run the doctor again once the bar has redrawn`:`${bF(t)}, so which transcript it reads is unknown — run the doctor again once the bar has redrawn`}:mF(e.value.flatMap(PF))}],IF=FF.filter(e=>e.takesMark);function LF(e){return FF.map(t=>({check:t,verdict:t.probe(e)}))}function RF(e){return FF.find(t=>t.name===e)}const zF=`${P}doctor.`;function BF(e){let t=`${zF}${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`,sighting:`${t}sighting`}}function VF({target:e}){return`configTarget=${e.source}`}function HF(e,t){let n=e.kind===`seen`?e.tmuxClient:null,r=e.kind===`seen`?sF(e.identified):null,i=t.kind===`failed`?`unread`:r===null?`-`:t.value.includes(r)?`yes`:`no`;return`tmuxLinks=${n===null?`-`:n.features.includes(`hyperlinks`)?`yes`:`no`} clicked=${i}`}function UF(e,t){let n=e.kind===`seen`?e.tmuxClient:null;return`cols=${t.kind===`failed`?`failed widthOf=-`:`${t.value.columns??`-`} widthOf=${t.value.of.kind}`} clientUtf8=${n===null?`-`:n.utf8?`yes`:`no`}`}function WF(e){if(e.kind===`failed`)return`clients=unasked`;let{daemon:t,clients:n}=e.value;return`clients=${n.map(e=>{if(e.kind===`unreported`)return`unreported/-/-`;let{bundle:n,source:r}=vF(t,e);return`${e.client}/${n.kind}/${r.kind===`uncompared`?`-`:r.kind}`}).join(`,`)||`-`}`}const GF=e=>`${e>=0?`+`:``}${Fr(e)}`;function KF({serving:e,processes:t,read:n}){let r=t.kind===`failed`?`daemons=unread others=-`:`daemons=${t.value.length} others=${SF(e,t.value).map(e=>e.pid).join(`,`)||`-`}`;if(e.kind===`failed`)return`${r} memory=unasked postMortems=unasked`;let{memory:i,limit:a,postMortems:o}=e.value,s=o.kind===`failed`||n.kind===`failed`?`unread`:`${xF(e.value,n).length}/${o.value.length}`;return`${r} memory=${i.kind===`unmeasured`?`unmeasured`:`${Kr(i.charge)}${i.charge.kind===`stand-in`?`(${GF(-i.charge.gap)})`:``}:${Fr(i.charge.bytes)}`}/${Fr(a)} postMortems=${s}`}function qF(e){return`data=pr:${(()=>{if(e.pullRequests.kind===`unneeded`)return`-`;let t=e.pullRequests.fact;if(t.kind===`failed`)return`failed`;if(t.value===null)return`no-forge`;let{status:n}=t.value;return typeof n==`string`?n:`logged-out`})()},rateLimits:${(()=>{if(e.rateLimits.kind===`unneeded`)return`-`;let t=e.rateLimits.fact;if(t.kind===`failed`)return`failed`;let n=e=>t.value.filter(t=>t===e).length;return`${n(`carried`)}/${n(`missing`)}/${n(`unanswered`)}`})()}`}function JF(e,{origin:t,elsewhere:n}){let r=[t,...n],i=r.map(({sources:e})=>YF(e)).join(`,`);if(e.kind===`failed`)return`frames=failed chains=${R(i)}`;let a=wF(r.flatMap(e=>e.bars));return`frames=${$P.map(e=>a.filter(t=>t.frame===e).length).join(`/`)} chains=${R(i)}`}function YF(e){let t=lF(e);switch(t.kind){case`unread`:return`failed`;case`absent`:case`not-an-object`:return t.kind;case`present`:return`${t.from.scope}:${t.refreshInterval===void 0?`-`:JSON.stringify(t.refreshInterval)}`}}function XF(e){let t=uF(e,hF);return t.kind===`failed`?`truecolorEnv=failed`:t.value.kind===`unset`?`truecolorEnv=unset`:`truecolorEnv=${R(`${t.value.from.scope}:${JSON.stringify(t.value.value)}`)}`}function ZF(e){if(e.kind===`failed`)return`transcripts=failed`;let t=t=>e.value.filter(e=>e.read.kind===t).length,n=e.value.reduce((e,t)=>e+(t.read.kind===`ok`?t.read.value.unparsed:0),0);return`transcripts=${t(`ok`)}/${t(`absent`)}/${t(`failed`)} unparsed=${n}`}function QF(e,t){if(e.kind===`none`)return`glyphs=- terminal=- font=- mark=-`;let{glyphs:n,terminal:r}=e,i=[...n].map(e=>e.codePointAt(0).toString(16)),a=(()=>{switch(r.kind){case`unreported`:case`unasked`:return r.kind;case`unknown`:return`unknown:${JSON.stringify(r.called)}`;case`unnamed`:return`unnamed:${JSON.stringify(r.term)}`;case`bundling`:case`unread`:case`configured`:return`${r.name}@${r.version??`-`}`}})(),o=(()=>{if(r.kind!==`configured`)return`-`;if(r.font.kind===`failed`)return`failed`;let{font:e,lacks:t}=r.font.value;return`${JSON.stringify(e)}:${t===null?`not-installed`:`lacks${t.length}`}`})(),s=DF(e),c=t.kind===`failed`?`unread`:s===void 0?`-`:t.value.nerdFont?.[s.id]??`-`;return`glyphs=${i.join(`,`)} terminal=${a} font=${o} mark=${c}`}function $F(e,t=[]){return t.length===0?e:`${e} (+${t.length} more — run \`cc-candybar doctor\`)`}function eI(e){return e.flatMap(({check:e,verdict:t})=>{let n=BF(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:t.note??``},{key:n.fixable,value:Sy},{key:n.sighting,value:``}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:$F(t.reason,t.more)},{key:n.fixable,value:t.fix===void 0?Sy:xy},{key:n.sighting,value:t.sighting?.glyphs??``}]})}const tI={copySession:{copy:`{{ .session.id }}`},copyResume:{copy:`{{ .resume_command }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},openConfig:{open:`{{ .config_path }}`}};function nI(e){let t=t=>`${e}${t}`;return{template:`{{ action "${t(`copySession`)}" "⎘ id" }}{{ if ne .resume_command "" }} {{ action "${t(`copyResume`)}" "⎘ resume" }}{{ end }} {{ action "${t(`openProject`)}" "↗ proj" }} {{ action "${t(`openTranscript`)}" "↗ log" }}{{ if ne .git.repoUrl "" }} {{ link .git.repoUrl "↗ repo" }}{{ end }}{{ if ne .config_path "" }} {{ action "${t(`openConfig`)}" "↗ config" }}{{ end }}`,actions:Object.fromEntries(Object.entries(tI).map(([t,n])=>[`${e}${t}`,n]))}}const rI=`armed`,iI=`disarmed`,aI=`.armed`,oI=e=>e.endsWith(aI);function sI(e,t,n){let r=[...new Set(n.map(e=>e.when))].filter(e=>e!==`true`),i=t=>r.length===0?e:`${e}.${t}`,a={};for(let e=0;e<2**r.length;e++)a[i(e)]={do:[t,...n.filter(t=>t.when===`true`||e&1<<r.indexOf(t.when)).map(e=>e.action)]};let o=(e,t)=>e===r.length?`"${i(t)}"`:`(ternary ${o(e+1,t|1<<e)} ${o(e+1,t)} (${r[e]}))`;return{link:o(0,0),actions:a}}function cI(e,t,n){let r=`${e}${aI}`,i=`${e}.arm`,a=`${e}.disarm`,o=`(eq .${e} "${rI}")`,s=sI(e,a,n);return{template:`{{ if ${o} }}{{ action ${s.link} "${t.confirm}" }} {{ action "${a}" "✕" }}{{ else }}{{ action "${i}" "${t.arm}" }}{{ end }}`,actions:{[i]:{set:r,to:rI},[a]:{set:r,to:iI},...s.actions},armed:o,variables:{[e]:{kind:`state`,key:r,default:iI}},disarm:a}}const lI=RegExp(`^/[^\\s\\x00-\\x1f\\x7f-\\x9f/][^\\x00-\\x1f\\x7f-\\x9f]*$`);function uI(e){return typeof e==`string`&&lI.test(e)?{kind:`line`,line:e}:{kind:`refused`,reason:`a slash command is "/" then its name, e.g. "/compact" or "/model opus", on one line with no control characters, got ${JSON.stringify(e)}`}}function dI(e){let t=uI(e);if(t.kind===`refused`)throw Error(t.reason);return t.line}const fI=[`/compact`,`/model`],pI=`/clear`;function mI(e){let t=t=>`${e}${t.slice(1)}`,n=`${e}clear.slash`,r=cI(`${e}clear`,{arm:pI,confirm:`${pI} ✓ confirm`},[{action:n,when:`true`}]);return{template:fI.map(e=>`{{ action "${t(e)}" "${e}" }} `).join(``)+r.template,when:`{{ ${Yb} }}`,actions:{...Object.fromEntries(fI.map(e=>[t(e),{slash:dI(e)}])),...r.actions,[n]:{slash:dI(pI)}},variables:r.variables,disarm:r.disarm}}const hI=Array.from({length:10},(e,t)=>(t+1)*1e5),gI=hI[0],_I=hI[hI.length-1];function vI(e){let t=rs(e);if(t.kind!==`ok`)return t;let n=t.value.autoCompactWindow;return n===void 0?F(`auto`):typeof n==`number`&&Number.isInteger(n)&&n>=gI&&n<=_I?F(n):L(`${e}: autoCompactWindow is ${JSON.stringify(n)}, not a window /autocompact accepts (${gI}–${_I} tokens)`,`parse`)}function yI(e,t){let n=Math.min(t??_I,_I),r=e===`auto`?n:Math.min(e,n);return{window:e===`auto`?0:e,applied:e===`auto`?0:r,lower:hI.filter(e=>e<r).at(-1)??0,higher:hI.find(e=>e>r&&e<=n)??0}}function bI(e,t){return{template:`{{ if ne .autocompact.error "" }}⇲ ⚠ {{ .autocompact.error }}{{ else }}⇲ {{ if eq .autocompact.window 0 }}auto{{ else }}${t(`.autocompact.applied`)}{{ end }}{{ if ${Yb} }}{{ if gt .autocompact.lower 0 }} {{ action (printf "${e}%d" .autocompact.lower) "−" }}{{ end }}{{ if gt .autocompact.higher 0 }} {{ action (printf "${e}%d" .autocompact.higher) "+" }}{{ end }}{{ if gt .autocompact.window 0 }} {{ action "${e}auto" "↺" }}{{ end }}{{ end }}{{ end }}`,bg:`{{ if ne .autocompact.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .autocompact.window 0) (ne .autocompact.error "") }}`,actions:{[`${e}auto`]:{slash:dI(`/autocompact auto`)},...Object.fromEntries(hI.map(t=>[`${e}${t}`,{slash:dI(`/autocompact ${t}`)}]))}}}const xI=e=>`{{ if ge ${e} 1000000 }}{{ printf "%.1f" (divf ${e} 1000000) }}M{{ else if ge ${e} 1000 }}{{ printf "%.1f" (divf ${e} 1000) }}K{{ else }}{{ ${e} }}{{ end }}`,SI=`${P}edit`,CI=`${P}toolbar`,wI=nI(P),TI=`${P}commands`,EI=mI(`${TI}.`),DI=`${P}autocompact`,OI=bI(`${DI}.`,xI),kI=e=>({kind:`segment`,name:e}),AI=`${P}tab`,jI=e=>`${AI}.${e}`,MI=e=>`${jI(e)}.toggle`,NI=e=>({variable:AI,key:AI,member:e}),PI=`${P}save`,FI=`${P}preset.save`,II=`${P}preset.delete`,LI=e=>`${P}${e}`,RI=e=>`${P}apply.${e}`,zI=e=>`${P}reset.${e}`,BI=`${P}themeDefault.save`,VI=`${P}themeDefault.differs`,HI=`${P}themeDefault.theme`,UI={when:`{{ .${VI} }}`,template:`{{ action "${BI}" (printf "⤓ default for %s" .${HI}) }} {{ swatch "${RI(`theme`)}" .${HI} }}`},WI=`${P}resetAll`,GI=`${Li}.toggle`,KI=`${P}undo`,qI=`${P}back`,JI=`${qI}.step`,YI=`${P}navigation.back`,XI=qI,ZI={template:`{{ if gt .${YI} 0 }}{{ action "${qI}" "◁" }}{{ else }}{{ fg (${aP}) "◁" }}{{ end }}`},QI=`${P}redo`,$I=`${P}doctor`,eL=`${$I}.run`,tL=e=>`${$I}.fix.${e}`,nL=(e,t)=>`${$I}.mark.${e}.${t}`,rL=e=>`${$I}.${e}`,iL={drawn:`[✓ shapes]`,boxes:`[✗ boxes]`},aL=vM(`${P}pickers`),oL=e=>`${P}${e}`,sL=e=>`${oL(e)}.toggle`,cL=e=>LM(e)?vM(`${P}${e}Pickers`):aL,lL=e=>{let t=cL(IM[PM[e].beside]);return{variable:t,key:t,member:e}},uL={layout:{template:`{{ layoutPreview }}`},palette:{template:`{{ themePreview }}`},presetDelete:{when:`{{ not .preset.bundled }}`,template:`{{ action "${II}" (printf "🚮 delete %s" .${Mx.preset.effectiveVar}) }}`}},dL=(e,t)=>`${P}list.${e}.${t}`,fL=e=>`${P}resettable.${e}`,pL=e=>e.length===0?`false`:`(or ${e.map(e=>`(and (${e.shown}) .${fL(e.name)})`).join(` `)})`,mL=Zb.map(e=>[Xb[e].switch.setting,e]),hL={variables:{},actions:{},segments:{}},gL=Object.fromEntries(mL.map(([e,t])=>[e,WN(`${P}help.${e}`,rP[t],[],hL)])),_L=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],vL=e=>{let t=t=>`.${nx(e,t)}`,n=_L.map(e=>`${1/30} "${e}"`).join(` `);return`{{ if eq .${Mx[Xb[e].switch.setting].effectiveVar} ${JSON.stringify(Xb[e].switch.on)} }} {{ if ${t(`subscribers`)} }}{{ realtimeFrames ${n} }} {{ ${t(`fps`)} }} fps{{ if not ${t(`shown`)} }} · off screen{{ end }}{{ else }}no subscriber{{ end }}{{ end }}`},yL=`{{ if .diagnostics.label }} {{ bg .diagnostics.bg (fg .diagnostics.fg (action "${Bi}" .diagnostics.label .diagnostics.open)) }}{{ end }}`,bL=`${P}fps`,xL=`{{ if eq .${ex(`by`)} "feed" }}{{ printf "%3s" (printf "≤%d" (int .${ex(`fps`)})) }} fps{{ else }}${`polled`.padStart(7)}{{ end }}`,SL=Object.fromEntries(mL.map(([e,t])=>[e,vL(t)])),CL=e=>FM.filter(t=>PM[t].beside===e),wL=Object.keys(Mx).map(e=>{let t=Mx[e],n=IM[e];return{...t,name:e,place:n,control:AM({label:t.label,domain:WM(t.configKey)},t.sessionKey,t.effectiveVar,RI(e),cL(n)),beneath:t.previews.map(e=>uL[e]),help:[gL[e]].filter(e=>e!==void 0),submenus:CL(e)}}),TL=e=>wL.filter(t=>t.place===e),EL=e=>wL.filter(t=>RM(t.place,e)),DL=e=>t=>`(print ${Di(t)} (ternary ${Di(` •`)} "" ${pL(EL(e))}))`,OL=e=>TL(e).flatMap(e=>[BL(e),...e.help,...e.submenus.map(e=>Si(oL(e),lL(e),qL(e),`drop`))].map(t=>({...t,when:`{{ ${e.shown} }}`})));new Set(wL.flatMap(e=>[e.sessionKey,e.configKey]));const kL=cI(WI,{arm:`⟲`,confirm:`⟲ reset all?`},wL.map(e=>({action:zI(e.name),when:e.shown}))),AL=[`unsaved`,`history.undo`,`history.redo`],jL=e=>`${P}${e}`,ML=jL(`unsaved`),NL=(e,t)=>({body:t,shown:`(gt .${jL(e)} 0)`}),PL=[NL(`unsaved`,`{{ action "${PI}" (printf "💾 save %d" .${ML}) }}`),NL(`history.undo`,`{{ action "${KI}" "↶" }}`),NL(`history.redo`,`{{ action "${QI}" "↷" }}`),{body:kL.template,shown:`(or ${pL(wL)} ${kL.armed})`}],FL={when:`{{ or ${PL.map(e=>e.shown).join(` `)} }}`,template:`{{ $sep := "" }}`+PL.map(e=>`{{ if ${e.shown} }}{{ $sep }}${e.body}{{ $sep = " " }}{{ end }}`).join(``)},IL=[{step:kL,place:`door`},{step:EI,place:`session`}],LL=e=>e.map(e=>e.step.disarm),RL=LL(IL),zL=LL(IL.filter(e=>e.place!==`door`));function BL(e){let t=LI(e.name);return e.control.kind===`inline`?kI(t):Si(t,e.control.list.ref,{kind:`container`,direction:`vertical`,children:[...e.control.list.rows,...e.beneath].map((t,n)=>kI(dL(e.name,n)))},`drop`)}function VL(e){return e===Li}function HL(e){let t=kI(Li);if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[HL(n),...r]}:{kind:`container`,direction:`vertical`,children:[t,e]}}if(e.kind===`segment`)return{kind:`container`,direction:`horizontal`,children:[t,e]};if(e.when===void 0)return{...e,children:[t,...e.children]};let{when:n,children:r,...i}=e;return{...i,children:[t,{kind:`container`,direction:i.direction,when:n,children:r}]}}function UL(e){return WL(e)>0?e:HL(e)}function WL(e){let t=0;for(let n of Ny(e))n.kind===`segment`&&VL(n.name)&&(t+=1);return t}function GL(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&VL(e.name)||e.opens!==void 0&&GL(e.opens.body,!0):e.children.some(e=>GL(e,n))}const KL={door:{direction:`horizontal`,content:[kI(XI)],after:[kI(SI),kI(PI)]},session:{direction:`vertical`,content:[kI(CI),{kind:`container`,direction:`horizontal`,children:[kI(TI),kI(DI)]}],after:[]},look:{direction:`horizontal`,content:[],after:[]},layout:{direction:`horizontal`,content:[kI(FI)],after:[]},config:{direction:`horizontal`,content:[],after:[]},tools:{direction:`vertical`,content:[kI($I),...FF.map(e=>kI(rL(e.name)))],after:[]},gear:{direction:`horizontal`,content:[],after:[kI(BI)]},toggles:{direction:`horizontal`,content:[],after:[]}};function qL(e){let{direction:t,content:n,after:r}=KL[e];return{kind:`container`,direction:t,children:[...n,...OL(e),...r]}}function JL(e){return e.kind===`segment`?VL(e.name)?{kind:`container`,direction:`horizontal`,children:[Si(e.name,zi,XL,`above`),kI(bL)]}:e:ZL(e)}function YL(){return{kind:`container`,direction:`vertical`,children:[qL(`door`),{kind:`container`,direction:`horizontal`,children:MM.map(({member:e})=>Si(jI(e),NI(e),qL(e),`drop`))}]}}const XL=YL();function ZL(e){return{...e,children:e.children.map(e=>JL(e))}}function QL(e){let t={variables:{[Li]:Oi(Li,gi),[Bi]:{kind:`state`,key:Bi,default:`0`}},actions:{[GI]:ki(Li,Ri),[Bi]:{set:Bi,int:!0},[Li]:{do:[GI,...RL]},[eL]:{doctor:`run`},...wI.actions,...EI.actions,...OI.actions,[PI]:{save:!0},[KI]:{undo:!0},[JI]:{back:!0},[qI]:{do:[JI,...RL]},[QI]:{redo:!0},[FI]:{preset:`save`},[BI]:{themeDefault:`save`},[II]:{preset:`delete`,name:`{{ .${Mx.preset.effectiveVar} }}`}},segments:{[Li]:{template:`{{ $door := ${Ei(Li,Di(e),Di(`✖`))} }}{{ if ${wi(zi)} }}{{ fg (keptOn (roleTextOn "error" (bgOf)) (bgOf)) $door }}{{ else }}{{ $door }}{{ end }}`+yL},[bL]:{template:xL},[CI]:{template:wI.template},[TI]:{template:EI.template,when:EI.when},[DI]:{template:OI.template,bg:OI.bg,when:OI.when},[XI]:ZI,[PI]:FL,[BI]:UI,[FI]:{template:`{{ action "${FI}" "+ preset" }}`},[$I]:{template:`{{ action "${eL}" "🩺 doctor" }}`},[SI]:{template:`{{ action "${PN}" "✎ arrange" "✎ done" }}`}}};t.variables[VI]={kind:`input`,path:`themeDefault.differs`,type:`boolean`,default:!1},t.variables[HI]={kind:`input`,path:`themeDefault.theme`,type:`string`,default:``},t.variables[YI]={kind:`input`,path:`navigation.back`,type:`number`,default:0};for(let e of AL)t.variables[jL(e)]={kind:`input`,path:e,type:`number`,default:0};t.variables[AI]=Oi(AI,gi);for(let{member:e,label:n}of MM){t.actions[MI(e)]=ki(AI,e),t.actions[jI(e)]={do:[MI(e),...zL]};let r=DL(e);t.segments[jI(e)]={template:`{{ ${Ei(jI(e),r(n),r(`▾ ${n}`))} }}`}}return Object.assign(t.variables,EI.variables,kL.variables),eR(t),$L(t),t}function $L(e){for(let t of FF){let n=BF(t.name),r=tL(t.name);for(let t of Object.values(n))e.variables[t]={kind:`state`,key:t,default:``};e.actions[r]={doctor:`fix`,check:t.name};let i=t.takesMark?dF:[];for(let n of i)e.actions[nL(t.name,n)]={doctor:`mark`,check:t.name,mark:n};let a=i.map(e=>` {{ action "${nL(t.name,e)}" "${iL[e]}" }}`).join(``);e.segments[rL(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ if ne .${n.reason} "" }} — {{ .${n.reason} }}{{ end }}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${xy}" }} {{ action "${r}" "[fix]" }}{{ end }}`+(a===``?``:`{{ if ne .${n.sighting} "" }} {{ .${n.sighting} }}${a}{{ end }}`)+`{{ end }}`}}}function eR(e){for(let t of wL){Object.assign(e.actions,t.control.actions);let n=zI(t.name);e.actions[n]={reset:t.configKey},e.variables[fL(t.name)]={kind:`input`,path:`resettable.${t.name}`,type:`boolean`,default:!1};let r=`{{ if .${fL(t.name)} }} {{ action "${n}" "↺" }}{{ end }}`;Object.assign(e.variables,t.control.variables),e.segments[LI(t.name)]={template:`${t.control.template}${SL[t.name]??``}${r}`},t.control.kind===`picker`&&[...t.control.list.rows.map(e=>({template:e})),...t.beneath].forEach((n,r)=>{e.segments[dL(t.name,r)]=n})}Object.assign(e.actions,kL.actions),Object.assign(e.variables,hL.variables),Object.assign(e.actions,hL.actions),Object.assign(e.segments,hL.segments);for(let t of FM){let n=lL(t);e.actions[sL(t)]=ki(n.key,n.member),e.segments[oL(t)]={template:`{{ action "${sL(t)}" ${DL(t)(PM[t].trigger)} }}`}}}function tR(e){let{variables:t,actions:n}=UN();Object.assign(e.variables,t),Object.assign(e.actions,n)}function nR(e){let t=QL(e.globals.menuGlyph??`🍫`);tR(t);let n={...e.presets},r=[];for(let t of lS(e.presets)){let{node:i}=fS(e,t),a=JL(UL(i));r.push(a),n[t]={...dS(e.presets,t),root:a}}let i=mM(t,r,e);return{...e,variables:{...i,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:n}}const rR=`${Pi}live`,iR=[`☐ live`,`☑ live`],aR=`${Pi}done`,oR=`${Pi}cancel`,sR=`${Pi}rewind`,cR=`${Pi}changes`,lR=`(gt .${cR} 0)`,uR=`(or ${lR} (gt .${ML} 0))`,dR={variable:rR,key:rR,member:_i};function fR(e){return`${Pi}configuring.p${e}`}function pR(e){return`and ${wi(RN)} (not ${wi(dR)}) (ne .${fR(e)} "true")`}function mR(e){return{kind:`template`,template:`{{ or ${e.map(e=>`(eq .${NN} "${xi(e)}")`).join(` `)} false }}`}}function hR(e,t,n){return`{{ if ${pR(e)} }}${t}{{ else }}${n}{{ end }}`}const gR=`{{ and ${wi(RN)} .preset.customized }}`,_R=Ii;function vR(e){return new Map([...yS(e),...bR(e)])}const yR=`${Pi}addable`;function bR(e){return new Map([[yR,{members:Object.keys(e.segments).filter(e=>!_R(e)),library:{groups:EN.map(e=>({id:e,label:DN[e]})),entry:t=>{let n=e.segments[t];return{group:n.group??`other`,...n.description!==void 0&&{description:n.description}}}}}]])}function xR(e,t,n){return n.segments[e]={template:t,when:zN,bg:KN},{kind:`segment`,name:e}}function SR(e,t,n){let r=`${Pi}${e.presetIdent}.remove.${t}`;return e.artifacts.actions[r]={persist:e.rootKey,removeSegment:n},`{{ fg (${`readableOn (color "error") (bgOf) ${_v}`}) (action "${r}" "✖") }}`}function CR(e){return`{{ if ${wi(RN)} }}${e}{{ end }}`}function wR(e,t){return e.reduce((e,t)=>`{{ if and ${wi(RN)} ${wi(t)} }}true{{ else }}${e}{{ end }}`,t)}function TR(e){return e.flatMap(e=>[...Ny(e)].flatMap(e=>e.kind===`segment`&&e.opens?.ref.key===`edit.configure`?[e.opens.ref]:[]))}function ER(e,t,n){return`${IN}${e}.${t}.${n}`}function DR(e,t,n,r){let i=ky(n),a=`${Pi}${e.presetIdent}`,o=LN(e.presetIdent,i);e.configured.push(o);let s=`${a}.configure.${t}`,c=vM(s),l=`${s}.fold`;e.artifacts.actions[l]={set:c,to:gi},e.artifacts.actions[s]={do:[`${s}.open`,l]},e.artifacts.actions[`${s}.open`]={set:NN,to:o};let u={},d=Object.entries(r).map(([r,o])=>{let s=ER(e.presetIdent,i,r),l=`${IN}p${e.presetIdent}.d${t}.${r}`;e.artifacts.variables[l]={kind:`state`,key:s,default:$y(n.settings?.[r]??o.default)},u[r]={id:i,key:s,variable:l};let d=`${a}.setting.${t}.${r}`,f=AM(OM(o),s,l,d,c);if(Object.assign(e.artifacts.actions,f.actions),Object.assign(e.artifacts.variables,f.variables),f.kind===`inline`)return e.artifacts.segments[d]={template:f.template},{kind:`segment`,name:d};e.artifacts.segments[d]={template:f.template};let p=f.list.rows.map((t,n)=>{let r=`${d}.list.${n}`;return e.artifacts.segments[r]={template:t},{kind:`segment`,name:r}});return Si(d,f.list.ref,{kind:`container`,direction:`vertical`,children:p},`drop`)});return{term:`{{ action "${s}" "${QN}" }}`,ref:{variable:NN,key:NN,member:o},body:{kind:`container`,direction:`vertical`,children:d},drafts:u}}const OR=`${Pi}label:`;function kR(e){if(e.startsWith(OR)){let t=e.slice(OR.length);return t.slice(t.indexOf(`:`)+1)}return e.startsWith(`edit.`)?void 0:e}function AR(e,t,n,r){let i=ky(e),a=jR(n,i,e,t,i),o=Object.fromEntries(Jy.flatMap(t=>{let n=e.settings?.[t];return n===void 0?[]:[[t,n]]}));return{...Si(a,r.ref,r.body,`drop`,wR([r.ref],`{{ ${pR(n.presetIdent)} }}`)),...Object.keys(o).length>0&&{settings:o},drafts:Object.fromEntries(Jy.map(e=>[e,r.drafts[e]]))}}function jR(e,t,n,r,i){let a=`${OR}${t}:${n.name}`;return e.artifacts.segments[a]={template:`{{ "${xi(i)}" }}`,...r.palette!==void 0&&{palette:r.palette}},a}function MR(e,t,n,r){let i=ky(e),a=n?[FR(r,String(r.posCounter.n++),i,`before`)]:[],o=String(r.posCounter.n++),s=FR(r,o,i,`after`),c=SR(r,o,i),l=r.segments[e.name],u=DR(r,o,e,Yy(l)),d=CR(c),f=CR(u.term);return[...a.map(e=>xR(e.host,e.template,r.artifacts)),{...AR(e,l,r,u),lead:d,trail:f},{...t,when:hR(r.presetIdent,`false`,e.when??`true`),lead:d,trail:f,drafts:u.drafts},xR(s.host,s.template,r.artifacts)]}function NR(e){return E.join(E.basename(E.dirname(e)),E.basename(e))}function PR(e,t,n,r){let i=r.segments[e.name],a=ky(e);return[{kind:`segment`,name:jR(r,`${a}/${r.presetIdent}`,e,i,`${a} · ${NR(t.file)} ${t.entry}`),when:`{{ ${pR(r.presetIdent)} }}`},{...n,when:hR(r.presetIdent,`false`,e.when??`true`)}]}function FR(e,t,n,r){let{presetIdent:i,artifacts:a}=e,o=`${Pi}${i}.insert.${t}`,s=`${Pi}${i}.insertSeg.${t}`;a.actions[o]={persist:e.rootKey,insertSegmentFrom:yR,anchor:n,relation:r};let c=gM(o),l=_M(s,o,void 0),u=bM(l),d=yM(l,c);return a.variables[l]={...Oi(l,gi),within:[RN]},a.variables[u]={kind:`state`,key:u,default:`0`},a.actions[d]=ki(l,c),a.actions[u]={set:u,int:!0},{host:s,template:`{{ $m := menu "${o}" "✚" "✕" }}{{ if ${wi({variable:l,key:l,member:c})} }}{{ $m }}{{ else }}{{ fg (${`readableOn (color "success") (bgOf) ${_v}`}) $m }}{{ end }}`}}function IR(e,t){let n=[],r=e.children.findIndex(e=>e.kind===`segment`&&!_R(e.name)&&e.insertedBy===void 0),i=e=>IR(e,t);for(let[a,o]of e.children.entries()){if(o.kind===`container`){n.push(i(o));continue}let s=My(o,i);if(_R(o.name)){n.push(s);continue}let c={kind:`container`,direction:`horizontal`,children:o.insertedBy===void 0?MR(o,s,a===r,t):PR(o,o.insertedBy,s,t),unit:!0};n.push(e.direction===`vertical`?{kind:`container`,direction:`horizontal`,children:[c]}:c)}return{...e,children:n,...e.when!==void 0&&{when:wR(TR(n),hR(t.presetIdent,`true`,e.when))}}}function LR(e,t,n,r,i,a,o){let s=`${Pi}${t}.resetLayout`,c=`${Pi}${t}.customized`;return r.actions[s]={reset:n},r.segments[c]={template:`{{ action "${s}" "↺ reset layout" }}`,when:gR},{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[...i,{kind:`segment`,name:c},a]},RR(e,o)]}}function RR(e,t){if(e.kind===`segment`)return{kind:`container`,direction:`horizontal`,children:[e,t]};let n=e.children.at(-1);return e.direction===`vertical`&&n!==void 0&&(n.kind===`segment`||n.when===void 0)?{...e,children:[...e.children.slice(0,-1),RR(n,t)]}:{...e,children:[...e.children,t]}}function zR(e,t,n,r,i,a){let{node:o}=fS(e,t),s={presetIdent:hM(t),rootKey:yN(t),segments:e.segments,artifacts:n,posCounter:{n:0},configured:[]},c=IR(o,s);return n.variables[fR(s.presetIdent)]=mR(s.configured),LR(c,s.presetIdent,s.rootKey,n,r,i,a)}function BR(e){let t={variables:{},actions:{},segments:{}},n=WN(`${Pi}help`,nP,[RN],t);t.variables[rR]=Oi(rR,gi),t.actions[rR]=ki(rR,dR.member),t.segments[rR]={template:Ti(rR,...iR),when:zN};let r={kind:`segment`,name:rR},i=n;t.variables[cR]={kind:`input`,path:`history.sinceEdit`,type:`number`,default:0},t.actions[aR]={do:[PI,PN]},t.segments[aR]={template:`{{ if ${uR} }}{{ action "${aR}" "✓ save" }}{{ else }}{{ action "${aR}" "✓ done" }}{{ end }}`,when:zN},t.actions[sR]={rewind:!0},t.actions[oR]={do:[sR,PN]},t.segments[oR]={template:`{{ action "${oR}" "↩ cancel" }}`,when:`{{ and ${wi(RN)} ${lR} }}`};let a=[{kind:`segment`,name:aR},{kind:`segment`,name:oR}],o={...e.presets},s=[];for(let n of lS(e.presets)){let c=zR(e,n,t,a,r,i);s.push(c),o[n]={...dS(e.presets,n),root:c}}let c=mM(t,s,e);return{...e,variables:{...c,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:o}}function VR(e){return e.op===`remove`?`remove:${e.target}`:`insert:${e.segment}:${e.anchor}:${e.relation}`}function HR(e){let t=e.split(`:`);return t[0]===`remove`&&t.length===2&&t[1]?{op:`remove`,target:t[1]}:t[0]===`insert`&&t.length===4&&t[1]&&t[2]&&(t[3]===`before`||t[3]===`after`)?{op:`insert`,segment:t[1],anchor:t[2],relation:t[3]}:null}function UR(e,t,n){let r=jy(e,new Set(n.map(Ay).filter(e=>e.includes(t)).flat()));return r===e?{seg:e}:{seg:e,id:r}}const WR=/^-?\d+$/;function GR(e,t,n=`set-state`){let r=e.filter(e=>e.includes(`/`));if(r.length>0)throw Error(`makeAllowListValidator(${t}): values contain "/" — the ${n} wire shape splits values on "/" so slash-bearing options cannot be addressed. Offending values: ${r.join(`, `)}`);if(e.includes(``))throw Error(`makeAllowListValidator(${t}): empty string is not a writable option — the validator rejects empty input before the allow-list check, so an "" in the allowed list could be rendered but never delivered. Remove "" from the allowed list.`);let i=new Set(e),a=[...e];return e=>e?i.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown ${t} "${e}" (have: ${a.join(`, `)})`}:{ok:!1,reason:`${t} value is required`}}function KR(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!WR.test(t))return{ok:!1,reason:`${e} must be an integer, got "${t}"`};let n=t[0]===`-`,r=(n?t.slice(1):t).replace(/^0+/,``);return r===``?{ok:!0,value:`0`}:{ok:!0,value:n?`-${r}`:r}}}function qR(e,t,n){return r=>r?WR.test(r)?{ok:!0,value:String(Math.max(e,Math.min(t,parseInt(r,10))))}:{ok:!1,reason:`${n} must be an integer, got "${r}"`}:{ok:!1,reason:`${n} value is required`}}function JR(e,t,n=`state`){let r=t.filter(e=>e.kind===`range`),i=t.some(e=>e.kind===`int`),a=t.flatMap(e=>e.kind===`allow-list`?e.allowed:[]);if(r.length===0&&!i)return{kind:`allow-list`,allowed:[...new Set(a)]};let o=a.filter(e=>!WR.test(e));if(o.length>0)throw Error(`${n} action table: key "${e}" is an integer spec (a paged cursor or a bounded value) but a click writes non-integer value(s) to it (${o.join(`, `)}). A ${n} key has one key shape — point that click at a distinct key, or write an integer.`);if(i&&r.length>0)throw Error(`${n} action table: key "${e}" is declared as both a paged cursor (int) and a bounded value (range) — a ${n} key has one key shape. Use distinct keys.`);if(r.length>0){let t=Math.min(...r.map(e=>e.min)),i=Math.max(...r.map(e=>e.max)),o=a.filter(e=>{let n=parseInt(e,10);return n<t||n>i});if(o.length>0)throw Error(`${n} action table: key "${e}" is a bounded range [${t},${i}] but a click writes out-of-range value(s) to it (${o.join(`, `)}). The range gate would clamp them, storing a different value than the click renders — write an in-range integer, or point that click at a distinct key.`);return{kind:`range`,min:t,max:i}}return{kind:`int`}}function YR(e){return e===`config`?`set-config`:`set-state`}function XR(e,t,n){return t.kind===`int`?KR(`menu page "${e}"`):t.kind===`range`?qR(t.min,t.max,`${n} stepper "${e}"`):GR(t.allowed,`${n} "${e}"`,YR(n))}function ZR(e,t=`state`){let n=new Map;for(let{key:t,spec:r}of e){let e=n.get(t);e?e.push(r):n.set(t,[r])}return[...n].map(([e,n])=>({key:e,spec:JR(e,n,t)}))}function QR(e,t,n,r){let i=new Map(Object.entries(e)),a=new Map,o=new Set(t.map(e=>e.key));for(let{key:e,spec:t}of n)if(o.has(e)&&t.kind!==`allow-list`)throw Error(`${r} gate: key "${e}" is written by the daemon's own links as one of a list of values, and cannot be declared as ${t.kind===`int`?`a paged cursor (int)`:`a bounded value (range)`}. Use a distinct key.`);let s=[...t.map(({key:e,allowed:t})=>({key:e,spec:{kind:`allow-list`,allowed:t}})),...n];for(let{key:t,spec:n}of ZR(s,r)){if(!t)throw Error(`${r} gate: key is required`);if(t.includes(`/`))throw Error(`${r} gate: key "${t}" contains "/" — the wire shape splits on "/" so a slash-bearing key cannot be addressed. Use a slash-free key.`);if(Object.hasOwn(e,t))throw Error(`${r} gate: key "${t}" is a built-in ${r} key and cannot be re-claimed (built-in keys: ${Object.keys(e).join(`, `)})`);i.set(t,XR(t,n,r)),n.kind===`range`&&a.set(t,{min:n.min,max:n.max})}return{validate(e,t){let n=i.get(e);return n?n(t):{ok:!1,reason:`unknown ${r} key "${e}" (have: ${[...i.keys()].join(`, `)})`}},listKeys:()=>[...i.keys()],rangeParamsFor:e=>a.get(e)??null}}function $R(e,t,n){let r=[],i=0,a=new WeakMap;return{register(n,a){let o={key:n,allowed:a};QR(e,[o],[],t),r.push(o),i++;let s=!0;return()=>{s&&(s=!1,r.splice(r.indexOf(o),1),i++)}},gateFor(o){let s=a.get(o);if(s?.epoch===i)return s.gate;let c=QR(e,r,n(o),t);return a.set(o,{epoch:i,gate:c}),c}}}function ez(){return $R({},`config`,iz)}function tz(e,t){return`persist`in e?`to`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:xS(e.from,t).members}}]:`cycle`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:e.cycle}}]:`removeSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[VR({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[VR({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:xS(e.insertSegmentFrom,t).members.map(t=>VR({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function nz(e){let t=new Set;for(let n of Object.values(e.actions)){`reset`in n&&t.add(n.reset);let e=`persist`in n?CN(n.persist):null;e?.scope===`preset-root`&&t.add(yN(e.preset))}return[...t].map(e=>({key:e,spec:{kind:`allow-list`,allowed:[]}}))}function rz(e){let t=vR(e);return[...nz(e),...Object.values(e.actions).flatMap(e=>tz(e,t))]}function iz(e){return ZR(rz(e),`config`)}const az=Gv(),oz=new Set(az),sz=new Set(py),cz=e=>e?oz.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${az.join(`, `)})`}:{ok:!1,reason:`theme name is required`},lz=e=>e?sz.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown endcaps "${e}" (have: ${py.join(`, `)})`}:{ok:!1,reason:`endcaps name is required`},uz=new Set([`1`,`true`]),dz=new Set([`0`,`false`]),fz={endcaps:lz,theme:cz,"toolbar-expanded":e=>uz.has(e)?{ok:!0,value:`1`}:dz.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}};function pz(){return $R(fz,`state`,_z)}function mz(e,t){return`set`in e?`to`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:xS(e.from,t).members}}]:`int`in e?[{key:e.set,spec:{kind:`int`}}]:`cycle`in e?[{key:e.set,spec:{kind:`allow-list`,allowed:e.cycle}}]:[{key:e.set,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function hz(e){return e.filter(e=>e.spec.kind!==`allow-list`||!Object.hasOwn(fz,e.key))}function gz(e){let t=vR(e);return hz(Object.values(e.actions).flatMap(e=>mz(e,t)))}function _z(e){return ZR(gz(e))}function vz(e){let t=pz(),n=ez();for(let{key:n,allowed:r}of e.state)t.register(n,r);for(let{key:t,allowed:r}of e.config)n.register(t,r);return{state:t,config:n}}const yz=`update.dismissed`,bz=`updateNotice`,xz=Mx.updateNotice.sessionKey;function Sz(){return vz({config:[{key:bz,allowed:[`false`]}],state:[{key:xz,allowed:[`false`]},{key:yz,allowed:[]}]})}function Cz(e){try{return s.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function wz(e,t){return{globals:{...t.globals,...e.globals??{}},variables:{...t.variables,...e.variables??{}},segments:Dz(t.segments,Tz(t.segments,e.segments??{})),root:tS(e.root??Yx,t.root),actions:{...t.actions,...e.actions??{}},styles:{...t.styles,...e.styles??{}},presets:Dz(t.presets,Ez(t.presets,e.presets??{})),themeDefaults:Dz(t.themeDefaults,e.themeDefaults??{}),editGlobals:{...t.editGlobals,...e.editGlobals??{}},helpers:{...t.helpers,...e.helpers??{}}}}function Tz(e,t){let n=(t,n,r)=>r[n]===void 0?r:{...r,[n]:{...e[t]?.[n],...r[n]}};return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,n(e,`partials`,n(e,`settings`,t))]))}function Ez(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.globals===void 0?n:{...n,globals:{...e[t]?.globals,...n.globals}}]))}function Dz(e,t){return{...e,...Object.fromEntries(Object.entries(t).map(([t,n])=>[t,{...e[t],...n}]))}}const Oz=new Map([[`gitTaculous`,{kind:`built-in`,to:`gitaculous`}],[`git`,{kind:`built-in`,to:`gitaculous`}],[`settings.menu`,{kind:`built-in`,to:`candybar.menu`}],[`ticket`,{kind:`plugin`,to:`plugins.lit.ticket`,source:`promptctl/links-issue-tracker`}],[`ceiling`,{kind:`removed`,why:`the program it showed draws it through a cc-candybar plugin of its own now — delete this reference, or place that plugin's segment`}],[`themeSwitcher`,{kind:`removed`,why:'the settings menu\'s 🎨 theme control steps themes — delete this reference, or write your own `{{ carousel "apply" "open" "label" }}`'}]]);function kz(e){let t=Oz.get(e);if(t===void 0)return``;switch(t.kind){case`built-in`:return` (the built-in segment "${e}" was renamed to "${t.to}" — update this reference)`;case`plugin`:return` (the built-in segment "${e}" became "${t.to}", a segment of the plugin \`cc-candybar plugin install ${t.source}\` installs — update this reference)`;case`removed`:return` (the built-in segment "${e}" was removed: ${t.why})`}}function Az(e,t,n,r){return n.cache===void 0?(e.issues.push({path:`${t}.cache`,message:`${r} variables must declare a cache policy (one of: ${zy.join(`, `)})`,line:q(e.source,t.split(`.`))}),null):Nz(e,`${t}.cache`,n.cache)}function jz(e){return{required:!0,json:Pz(),parse:(t,n,r,i)=>Az(t,n,i,e)??void 0}}const Mz={noun:`cache`,arms:{ttl:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&Iz(n)?{ttl:n}:Ob(e,t,`cache.ttl must be a duration string like "5s", "100ms", "2m", "1h"; got ${J(n)}`)},watch_file:{json:{type:`string`,pattern:`^/`},parse:(e,t,n)=>{if(typeof n!=`string`)return Ob(e,t,`cache.watch_file must be a path string, got ${J(n)}`);let r=Bb(`cache.watch_file`,n);return r===null?{watch_file:n}:Ob(e,t,r)}},depends_on:{json:{type:`array`,items:{type:`string`}},parse:(e,t,n)=>Array.isArray(n)&&n.every(e=>typeof e==`string`)?{depends_on:n}:Ob(e,t,`cache.depends_on must be an array of variable-name strings, got ${J(n)}`)},key:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`&&n!==``?{key:n}:Ob(e,t,`cache.key must be a non-empty template string, got ${J(n)}`)},never:{json:{const:!0},parse:(e,t,n)=>n===!0?{never:!0}:Ob(e,t,`cache.never must be the literal boolean true, got ${J(n)}`)}}};function Nz(e,t,n){return kb(e,Mz,t,n)}function Pz(){return qb(Mz)}const Fz=/^(\d+(?:\.\d+)?)(ms|s|m|h)$/;function Iz(e){return Fz.test(e)}const Lz=new Map([[`session.budget.amount`,{segment:`session`,setting:`budget`}],[`session.budget.warningThreshold`,{segment:`session`,setting:`warnAt`}],[`today.budget.amount`,{segment:`today`,setting:`budget`}],[`today.budget.warningThreshold`,{segment:`today`,setting:`warnAt`}],[`block.budget.heatThreshold`,{segment:`block`,setting:`warnAt`}],[`block.budget.warningThreshold`,{segment:`block`,setting:`errorAt`}],[`weekly.budget.heatThreshold`,{segment:`weekly`,setting:`warnAt`}],[`weekly.budget.warningThreshold`,{segment:`weekly`,setting:`errorAt`}],[`burn.eta.errorMinutes`,{segment:`burnrate`,setting:`errorWithin`}],[`burn.eta.warnMinutes`,{segment:`burnrate`,setting:`warnWithin`}]]);function Rz(e){return`it became the "${e.setting}" setting of each "${e.segment}" placement — set it on the placement where a row places "${e.segment}" ({ seg: "${e.segment}", settings: { ${e.setting}: <value> } }), or redeclare segments.${e.segment}.settings.${e.setting} with the default every placement should start from`}function zz(e){let t=Lz.get(e);return t===void 0?void 0:`variables.${e} is no longer read: ${Rz(t)}`}function Bz(e){let t=Lz.get(e);return t===void 0?``:` — ".${e}" is no longer a variable: ${Rz(t)}; a "${t.segment}" template reads it as ".settings.${t.setting}"`}const Vz=new Map([[`git.timeSinceCommit`,`the payload stores the commit's date as "git.committedAt" (epoch seconds), and the bundled template variable "git.timeSinceCommit" computes its age at the draw: drop this declaration`],[`block.etaMinutes`,`the bundled template variable "block.etaMinutes" computes it at the draw: drop this declaration`],[`weekly.etaMinutes`,`the bundled template variable "weekly.etaMinutes" computes it at the draw: drop this declaration`]]),Hz=new Map([[`branch`,{read:`.git.branch`,declare:{kind:`input`,path:`git.branch`,default:``},note:`when HEAD is on no branch it reads "detached", where this kind read ""`}],[`sha`,{read:`.git.sha`,declare:{kind:`input`,path:`git.sha`,default:``}}],[`dirty`,{read:`(ne .git.status "clean")`,declare:{kind:`template`,template:`{{ ne .git.status "clean" }}`,type:`boolean`}}],...[`ahead`,`behind`,`stash`].map(e=>[e,{read:`.git.${e}`,declare:{kind:`input`,path:`git.${e}`,type:`number`,default:0}}])]);function Uz(e){let t=e=>typeof e==`string`&&e.includes(`"`)&&!e.includes(`'`)?`'${e}'`:JSON.stringify(e);return`{ ${Object.entries(e).map(([e,n])=>`${e}: ${t(n)}`).join(`, `)} }`}function Wz(e){let t=`kind "git" is retired: every git fact is an input over the payload's git lane, which the bundled default already declares — drop this declaration and`,n=typeof e.field==`string`?Hz.get(e.field):void 0;if(n===void 0){let e=[...Hz.values()].map(({read:e})=>e);return`${t} read whichever of ${e.slice(0,-1).join(`, `)} or ${e.at(-1)} it stood for, where it was read`}let r=n.note===void 0?``:` (${n.note})`;return`${t} read ${n.read} where it was read${r}, or declare ${Uz(n.declare)} under a name of your own`}function Gz(e,t,n){if(n===void 0)return{};if(!xb(n))return e.issues.push({path:t,message:`${t} must be an object, got ${Sb(n)}`,line:q(e.source,t.split(`.`))}),{};let r={};for(let[i,a]of Object.entries(n)){let n=Ab(e,mB,`${t}.${i}`,a);n!==null&&(r[i]=n)}return r}function Kz(){return{required:!0,json:{type:[`string`,`number`,`boolean`]},parse:(e,t,n,r)=>{let i=r.value;if(typeof i!=`string`&&typeof i!=`number`&&typeof i!=`boolean`){e.issues.push({path:`${t}.value`,message:`literal value must be string|number|boolean, got ${Sb(i)}`,line:q(e.source,t.split(`.`))});return}return i}}}function qz(){return{required:!1,json:{type:[`string`,`number`,`boolean`]},parse:(e,t,n,r)=>{let i=r.type;return _b(e,t,r,i===`number`||i===`boolean`||i===`string`?i:`string`)}}}const Jz={noun:`parse`,arms:{text:{json:{const:!0},parse:(e,t,n)=>n===!0?{text:!0}:Ob(e,t,`parse.text must be the literal boolean true, got ${J(n)}`)},regex:{json:{type:`string`},parse:(e,t,n)=>typeof n==`string`?Yz(e,t,n):Ob(e,t,`parse.regex must be a pattern string, got ${J(n)}`)},json:{json:{const:!0},parse:(e,t,n)=>n===!0?{json:!0}:Ob(e,t,`parse.json must be the literal boolean true, got ${J(n)}`)}}};function Yz(e,t,n){let r;try{new RegExp(n),r=RegExp(`${n}|`).exec(``).length-1}catch(n){return Ob(e,t,`parse.regex is not a valid regular expression: ${n.message}`)}return r>=1?{regex:n}:Ob(e,t,`parse.regex must contain a capture group — its group 1 is the value; got ${JSON.stringify(n)}`)}function Xz(){return{required:!1,json:qb(Jz),parse:(e,t,n,r)=>(r.regex!==void 0&&e.issues.push({path:`${t}.regex`,message:`${t}.regex was retired; the regex is the parse step's regex arm now: parse: { regex: ${JSON.stringify(r.regex)} }`,line:q(e.source,[...t.split(`.`),`regex`])}),r.parse===void 0?void 0:kb(e,Jz,`${t}.parse`,r.parse)??void 0)}}function Zz(){return{required:!1,json:{type:[`string`,`number`,`boolean`,`array`,`object`],description:`The value published when the source fails: a string under the text/regex parse arms, any non-null JSON value under the json arm`},parse:(e,t,n,r)=>xb(r.parse)&&`json`in r.parse?Qz(e,t,r.default):vb(e,t,r,`default`)}}function Qz(e,t,n){if(n!==void 0)return $z(n)?n:Ob(e,`${t}.default`,`${t}.default must be a JSON value (a json-parsed source's document), got ${J(n)}`)??void 0}function $z(e){return e!==null&&vC(e)}const eB={value:Kz(),default:Pb()};function tB(){let e=zb();return{...e,parse:(t,n,r,i)=>{let a=e.parse(t,n,r,i),o=a===void 0?void 0:Vz.get(a);return o===void 0?a:Ob(t,`${n}.${r}`,`${n}.${r} "${a}" is no longer in the payload: ${o}`)??void 0}}}const nB={path:tB(),type:Hb([`string`,`number`,`boolean`]),default:qz()},rB={name:zb(),default:Pb()},iB={path:Vb(),readMode:Hb([`whole`,`first-line`]),parse:Xz(),cache:jz(`file`),default:Zz()},aB={command:zb(),parse:Xz(),cache:jz(`shell`),default:Zz()};function oB(e){return{cache:`${e}, so it takes no cache policy — delete the key`}}const sB={template:zb(),type:Hb([`string`,`number`,`boolean`]),default:qz()},cB=oB(`a template variable recomputes whenever a variable it reads changes`),lB={layout:zb(),default:Pb()},uB=oB(`a time variable reads the instant its render is drawn at`),dB={key:zb(),default:Pb()},fB=`kind`;function pB(e,t,n={}){return{...jb(fB,e,t),parse:(r,i,a)=>{wb(r,n,i,a);let o=Tb(r,t,i,a);return o===null?null:{kind:e,...o}}}}const mB={tag:fB,noun:`source kind`,memberNoun:`variable`,arms:{literal:pB(`literal`,eB),input:pB(`input`,nB),env:pB(`env`,rB),file:pB(`file`,iB),shell:pB(`shell`,aB),template:pB(`template`,sB,cB),time:pB(`time`,lB,uB),state:pB(`state`,dB)},retired:{git:Wz}};function hB(){return Kb(mB)}function gB(){return{type:`object`,additionalProperties:hB()}}const _B=/^[A-Za-z_][A-Za-z0-9_]*$/,vB={pattern:_B.source},yB={anyOf:[{type:`boolean`},{type:`string`},{type:`integer`}]},bB={type:`object`,additionalProperties:!1,required:[`label`,`domain`,`default`],properties:{label:{type:`string`,pattern:`^[^\\n\\r]+$`},domain:{anyOf:[{const:`bool`},{type:`array`,items:{type:`string`,pattern:`^[^/\\n\\r]+$`},minItems:1,uniqueItems:!0},{type:`object`,additionalProperties:!1,required:[`min`,`max`],properties:{min:{type:`integer`},max:{type:`integer`},step:{type:`integer`,minimum:1},atLeast:{type:`string`,...vB}}}]},default:yB}},xB=[`label`,`domain`,`default`],SB=[`min`,`max`,`step`,`atLeast`];function CB(e,t,n){e.issues.push({path:t,message:n,line:q(e.source,t.split(`.`))})}function wB(e,t,n){if(n===`bool`)return`bool`;if(Array.isArray(n)){let r=n.filter(e=>typeof e==`string`);if(n.length===0||r.length!==n.length)return CB(e,t,`a list domain must be a non-empty list of words, got ${JSON.stringify(n)}`);if(new Set(r).size!==r.length)return CB(e,t,`a list domain names each word once, got ${JSON.stringify(n)}`);let i=r.filter(e=>e===``||e.includes(`/`)||/[\n\r]/.test(e));return i.length>0?CB(e,t,`a list domain's words must be non-empty, slash-free, and newline-free — configure mode writes each on the set-state wire — got ${JSON.stringify(i)}`):r}if(xb(n)){let{min:r,max:i,step:a=1,atLeast:o}=n;return Object.keys(n).filter(e=>!SB.includes(e)).length===0&&Number.isInteger(r)&&Number.isInteger(i)&&r<=i&&Number.isInteger(a)&&a>=1&&(o===void 0||typeof o==`string`)?{min:r,max:i,step:a,...o!==void 0&&{atLeast:o}}:CB(e,t,`a range domain is { min, max, step?, atLeast? } with integers min ≤ max, a whole step ≥ 1, and atLeast naming another range setting, got ${JSON.stringify(n)}`)}return CB(e,t,`domain must be "bool", a list of words, or { min, max }, got ${J(n)}`)}function TB(e,t,n){if(!xb(n))return CB(e,t,`${t} must be { label, domain, default }, got ${Sb(n)}`);for(let r of Object.keys(n))xB.includes(r)||CB(e,`${t}.${r}`,`Unknown setting key "${r}". Expected one of: ${xB.join(`, `)}`);let{label:r}=n,i=typeof r==`string`&&r.length>0&&!/[\n\r]/.test(r);i||CB(e,`${t}.label`,`a setting needs a one-line, non-empty "label" — the name its control shows, spliced into a synthesized template string — got ${J(r)}`);let a=wB(e,`${t}.domain`,n.domain);if(!i||a===void 0)return;let o={label:r,domain:a,default:n.default};return!EB(n.default)||!Qy(o,n.default)?CB(e,`${t}.default`,`default must be ${nb(o)}, got ${J(n.default)}`):o}function EB(e){return typeof e==`boolean`||typeof e==`string`||typeof e==`number`}const DB={theme:`its default for this segment is segments.<name>.palette, and a placement sets its own with settings: { ${Ky}: "<theme>" }`,effect:`a placement follows the bar's effect, or sets its own with settings: { effect: "<effect>" }`};function OB(e){return Jy.includes(e)}function kB(){return{required:!1,json:{type:`object`,propertyNames:{...vB,not:{enum:[...Jy]}},additionalProperties:bB},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!xb(i))return CB(e,a,`${a} must be an object of name → { label, domain, default }, got ${Sb(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i)){if(!_B.test(t)){CB(e,`${a}.${t}`,`setting name "${t}" is read as .settings.${t} in a template, so it must be an identifier (letters, digits, _; not starting with a digit)`);continue}if(OB(t)){CB(e,`${a}.${t}`,`setting "${t}" is one every placement already has — ${DB[t]}`);continue}let r=TB(e,`${a}.${t}`,n);r!==void 0&&(o[t]=r)}return o}}}const AB=Fi.map(e=>e.replace(/\./g,`\\.`)).join(`|`);function jB(){return{required:!1,json:{type:`string`,minLength:1,pattern:`^(?!${AB})[^:/]+$`},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return typeof i==`string`&&i.length>0&&!/[:/]/.test(i)&&!Ii(i)?i:CB(e,`${t}.${n}`,`a placement "id" must be a non-empty string without "/" or ":", outside the reserved ${Fi.map(e=>`"${e}"`).join(`, `)} namespaces, got ${J(i)}`)}}}function MB(){return{required:!1,json:{type:`object`,propertyNames:vB,additionalProperties:yB},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;let a=`${t}.${n}`;if(!xb(i))return CB(e,a,`a placement's "settings" must be an object of setting name → value, got ${Sb(i)}`);let o=Object.create(null);for(let[t,n]of Object.entries(i))EB(n)?o[t]=n:CB(e,`${a}.${t}`,`setting "${t}" must be a boolean, a word, or a number, got ${Sb(n)}`);return o}}}function NB(e){return new Set(Object.keys(e.segments).filter(e=>!Ii(e)))}function PB(e,t,n){if(t===void 0)return{};if(!xb(t))return e.issues.push({path:`segments`,message:`segments must be an object, got ${Sb(t)}`,line:q(e.source,[`segments`])}),{};let r={};for(let[i,a]of Object.entries(t)){let t=Cb(e,n.has(i)?WB:UB,`segments.${i}`,a);t!==null&&(r[i]=t)}return r}function FB(e,t,n,r){let i=r[n];if(typeof i==`string`)return i;if(Array.isArray(i)){let r=!0,a=[];for(let[o,s]of i.entries()){if(typeof s==`string`){a.push(s);continue}r=!1,e.issues.push({path:`${t}.${n}[${o}]`,message:`${t}.${n}[${o}] must be a string, got ${Sb(s)}`,line:q(e.source,[...t.split(`.`),n])})}return r?a.join(``):void 0}e.issues.push({path:`${t}.${n}`,message:`${t}.${n} must be a string or an array of strings, got ${Sb(i)}`,line:q(e.source,[...t.split(`.`),n])})}const IB={anyOf:[{type:`string`},{type:`array`,items:{type:`string`}}]};function LB(){return{required:!0,json:IB,parse:(e,t,n,r)=>r[n]===void 0?Ob(e,`${t}.${n}`,`${t} declares no template — only a segment the bundled default declares may omit it (inheriting the bundled template); a segment of your own needs its own${kz(t.slice(9))}`)??void 0:FB(e,t,n,r)}}function RB(){return{required:!1,json:IB,parse:(e,t,n,r)=>r[n]===void 0?void 0:FB(e,t,n,r)}}function zB(){return{required:!1,json:{type:`object`,additionalProperties:IB},parse:(e,t,n,r)=>{let i=r[n];if(i===void 0)return;if(!xb(i)){e.issues.push({path:`${t}.${n}`,message:`${t}.${n} must be an object, got ${Sb(i)}`,line:q(e.source,[...t.split(`.`),n])});return}let a=Object.create(null);for(let r of Object.keys(i)){let o=FB(e,`${t}.${n}`,r,i);o!==void 0&&(a[r]=o)}return a}}}function BB(){return{required:!1,json:{anyOf:[{const:`auto`},{const:`fill`},{type:`integer`,minimum:1}]},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(i===`auto`)return`auto`;if(i===`fill`)return`fill`;if(typeof i==`number`&&Number.isInteger(i)&&i>0)return i;e.issues.push({path:`${t}.${n}`,message:`width must be "auto", "fill", or a positive integer, got ${J(i)}`,line:q(e.source,[...t.split(`.`),n])})}}}}function VB(){return{required:!1,json:gB(),parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0)return Gz(e,`${t}.${n}`,i)}}}const HB={template:LB(),description:Pb(),group:Hb(TN),width:BB(),justify:Hb(rb),truncate:Hb(ib),bg:Pb(),fg:Pb(),when:Pb(),palette:Rb(),vars:VB(),settings:kB(),missingData:Hb(Uy),partials:zB()},UB={noun:`segment key`,fields:HB},WB={noun:`segment key`,fields:{...HB,template:RB()}};function GB(e,t){if(t===void 0)return{};if(!xb(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${Sb(t)}`,line:q(e.source,[`helpers`])}),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){if(typeof i!=`string`){e.issues.push({path:`helpers.${r}`,message:`helpers.${r} must be a string template body, got ${J(i)}`,line:q(e.source,[`helpers`,r])});continue}n[r]=i}return n}function KB(e,t,n){if(t===void 0)return{};if(!xb(t))return X(e,`actions`,`actions must be an object, got ${Sb(t)}`),{};let r=Object.create(null);for(let[i,a]of Object.entries(t)){let t=qB(e,`actions.${i}`,a,n);t!==null&&(r[i]=t)}return r}function X(e,t,n){e.issues.push({path:t,message:n,line:q(e.source,t.split(`.`))})}function qB(e,t,n,r){if(!xb(n))return X(e,t,`${t} must be an action object, got ${Sb(n)}`),null;if(`persistWhen`in n)return X(e,t,`${t}.persistWhen was removed: declare the \`set\` alone — a session pick is a draft until a \`{ save: true }\` action writes every unsaved setting to the config file`),null;let i=wS.filter(e=>e in n);return i.length===1?YB(r)[i[0]](e,t,n):(X(e,t,`action must declare exactly one of: ${wS.join(`, `)}${i.length>1?` (found: ${i.join(`, `)})`:``}`),null)}function JB(e){return e===`<default>`?{dir:null}:E.isAbsolute(e)?{dir:E.dirname(e)}:{text:e}}const YB=e=>({set:(e,t,n)=>jV(e,t,n,`set`,DV),persist:(e,t,n)=>jV(e,t,n,`persist`,OV),copy:XB(`copy`),open:XB(`open`),reset:ZB,undo:$B(`undo`),redo:$B(`redo`),back:$B(`back`),rewind:$B(`rewind`),save:$B(`save`),preset:eV,themeDefault:tV,doctor:rV,slash:iV,run:sV(e),do:cV});function XB(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&X(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=gb(t,n,r,e);return i===null?null:{[e]:i}}}function ZB(e,t,n){for(let r of Object.keys(n))r!==`reset`&&X(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=lV(e,t,`reset`,n,`reset key must be non-empty (the config globals field to clear)`,e=>`reset key "${e}" contains "/" — keys must be slash-free`);return r===null?null:{reset:r}}const QB={undo:`it steps the session's settings history`,redo:`it steps the session's settings history`,back:`it steps the session's navigation history`,rewind:`it steps the session's settings history back to where edit mode opened`,save:`it saves the session's unsaved settings`};function $B(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&X(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(X(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — ${QB[e]}), got ${J(r[e])}`),null)}}function eV(e,t,n){let r=n.preset,i=r===`save`?[`preset`]:[`preset`,`name`];for(let r of Object.keys(n))i.includes(r)||X(e,`${t}.${r}`,`Unknown key "${r}" on a preset action. Expected only: ${i.join(`, `)}`);if(r!==`save`&&r!==`delete`)return X(e,`${t}.preset`,`preset must be "save" or "delete", got ${J(r)}`),null;if(r===`save`)return{preset:`save`};let a=gb(e,t,n,`name`);return a===null?null:{preset:`delete`,name:a}}function tV(e,t,n){for(let r of Object.keys(n))r!==`themeDefault`&&X(e,`${t}.${r}`,`Unknown key "${r}" on a themeDefault action. Expected only: themeDefault`);return n.themeDefault===`save`?{themeDefault:`save`}:(X(e,`${t}.themeDefault`,`themeDefault must be "save" (it saves the look the session draws as the active theme's default), got ${J(n.themeDefault)}`),null)}const nV={run:[`doctor`],fix:[`doctor`,`check`],mark:[`doctor`,`check`,`mark`]};function rV(e,t,n){let r=n.doctor,i=typeof r==`string`&&Object.hasOwn(nV,r),a=i?nV[r]:[...new Set(Object.values(nV).flat())];for(let r of Object.keys(n))a.includes(r)||X(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${a.join(`, `)}`);if(!i)return X(e,`${t}.doctor`,`doctor must be ${Object.keys(nV).map(e=>`"${e}"`).join(`, `)}, got ${J(r)}`),null;if(r===`run`)return{doctor:`run`};let o=n.check,s=r===`mark`?IF:FF;if(typeof o!=`string`||!s.some(e=>e.name===o))return X(e,`${t}.check`,`doctor ${r} must name a check (have: ${s.map(e=>e.name).join(`, `)}), got ${J(o)}`),null;if(r===`fix`)return{doctor:`fix`,check:o};let c=n.mark;return dF.includes(c)?{doctor:`mark`,check:o,mark:c}:(X(e,`${t}.mark`,`doctor mark must be ${dF.map(e=>`"${e}"`).join(` or `)}, got ${J(c)}`),null)}function iV(e,t,n){for(let r of Object.keys(n))r!==`slash`&&X(e,`${t}.${r}`,`Unknown key "${r}" on a slash action. Expected only: slash`);let r=uI(n.slash);return r.kind===`refused`?(X(e,`${t}.slash`,r.reason),null):{slash:r.line}}const aV=[`run`,`env`,`refreshes`],oV=/^[A-Za-z_][A-Za-z0-9_]*$/;function sV(e){return(t,n,r)=>{for(let e of Object.keys(r))aV.includes(e)||X(t,`${n}.${e}`,`Unknown key "${e}" on a run action. Expected only: ${aV.join(`, `)}`);let i=t.issues.length,a=r.run;(!Array.isArray(a)||a.length===0||a.some(e=>typeof e!=`string`)||a[0]===``)&&X(t,`${n}.run`,`run must list the program and its arguments, each a template string, the program first and not empty, got ${J(a)}`);let o=r.env??{};(!xb(o)||Object.entries(o).some(([e,t])=>!oV.test(e)||typeof t!=`string`))&&X(t,`${n}.env`,`env must map variable names (letters, digits and _, not starting with a digit) to template strings, got ${J(o)}`);let s=r.refreshes??[];return(!Array.isArray(s)||s.some(e=>typeof e!=`string`||e===``))&&X(t,`${n}.refreshes`,`refreshes must list the names of the sources the program writes, got ${J(s)}`),`dir`in e||X(t,`${n}.run`,`a run action runs in the directory of the file that declares it, and ${e.text} is no file`),t.issues.length>i||!(`dir`in e)?null:{run:a,env:o,refreshes:s,cwd:e.dir}}}oV.source;function cV(e,t,n){for(let r of Object.keys(n))r!==`do`&&X(e,`${t}.${r}`,`Unknown key "${r}" on a do action. Expected only: do`);let r=n.do;return!Array.isArray(r)||r.length<2||r.some(e=>typeof e!=`string`||e===``)?(X(e,`${t}.do`,`do must list at least two action names (the first is the click's face, the rest ride along in the same click), got ${J(r)}`),null):{do:r}}function lV(e,t,n,r,i,a){let o=gb(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(X(e,s,i),null):o.includes(`/`)?(X(e,s,a(o)),null):o}const uV={set:`the SessionState key to write`,persist:`the config globals field to write`};function dV(e,t,n,r){let i=uV[r],a=lV(e,t,r,n,`${r} key must be non-empty (${i})`,e=>`${r} key "${e}" contains "/" — keys must be slash-free`);return a===null?null:{[r]:a}}function fV(e){return e===`set`?`set-state`:`set-config`}const pV={to:MV(`set`)},mV={to:MV(`persist`)},hV={from:NV(`set`)},gV={from:NV(`persist`)},_V={min:RV(),max:RV(),by:RV()},vV={int:FV()},yV={cycle:PV(`set`)},bV={cycle:PV(`persist`)},xV={removeSegment:IV(`removeSegment`)},SV={insertSegment:IV(`insertSegment`),anchor:IV(`anchor`),relation:LV()},CV={insertSegmentFrom:NV(`persist`),anchor:IV(`anchor`),relation:LV()},wV={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},TV={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function EV(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=[e],s=(e,n,r)=>Tb(e,t,n,r),c=Ub(t);return{detect:a,allowed:[...o,...i],label:i.join(`/`),json:{type:`object`,properties:{...Object.fromEntries(o.map(e=>[e,{type:`string`}])),...c.properties},required:[...o,...c.required??[]],additionalProperties:!1},parse:n.length?Nb(s,...n):s}}const DV=[EV(`set`,pV),EV(`set`,hV),EV(`set`,_V,[wV,TV]),EV(`set`,vV),EV(`set`,yV)],OV=[EV(`persist`,mV),EV(`persist`,gV),EV(`persist`,_V,[wV,TV]),EV(`persist`,bV),EV(`persist`,xV),EV(`persist`,SV,[],[`insertSegment`]),EV(`persist`,CV,[],[`insertSegmentFrom`])];function kV(e){let t=[`"to" (a literal value)`,`"from" (an option domain — a registered domain name like "themes"/"endcaps"/"styles", or an inline array of literal values)`,`"min"/"max"/"by" (a bounded step)`];return e===`set`&&t.push(`"int" (an unbounded integer cursor)`),t.push(`"cycle" (an enumerated domain stepped in order)`),e===`persist`&&t.push(`"removeSegment" (remove a named segment from the layout)`,`"insertSegment"/"anchor"/"relation" (insert a named segment before/after an existing one)`,`"insertSegmentFrom"/"anchor"/"relation" (insert a segment PICKED from an option domain before/after an existing one)`),t}function AV(e){let t=kV(e),n=t[t.length-1];return`a ${e} action declares exactly one value source: ${t.length===1?n:`${t.slice(0,-1).join(`, `)}, or ${n}`}`}function jV(e,t,n,r,i){let a=dV(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return X(e,t,`${AV(r)}${o.length>1?` — found: ${o.map(e=>e.label).join(`, `)}`:``}`),null;let s=o[0];for(let i of Object.keys(n))s.allowed.includes(i)||X(e,`${t}.${i}`,`Unknown key "${i}" on this ${r} action. Expected one of: ${s.allowed.join(`, `)}`);let c=s.parse(e,t,n);return a===null||c===null?null:{...a,...c}}function MV(e){let t=fV(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>lV(n,r,i,a,`${e} value must be non-empty — an empty value cannot be delivered on the ${t} wire`,t=>`${e} value "${t}" contains "/" — ${e} values must be slash-free`)??void 0}}function NV(e){let t=fV(e);return{required:!0,json:{anyOf:[{type:`string`,minLength:1},{type:`array`,items:{type:`string`,minLength:1},minItems:1,uniqueItems:!0}]},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(typeof o==`string`){if(o===``){X(n,s,`${i} must be a non-empty domain name`);return}return o}if(Array.isArray(o)&&o.every(e=>typeof e==`string`)){let r=o;if(r.length===0){X(n,s,`${i} must name a domain (a non-empty string) or declare an inline domain (a non-empty array of values)`);return}if(r.some(e=>e===``)){X(n,s,`${i} array members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}let a=r.filter(e=>e.includes(`/`));if(a.length>0){X(n,s,`${i} array member(s) ${a.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(r).size!==r.length){X(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}X(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${J(o)}`)}}}function PV(e){let t=fV(e);return{required:!0,json:{type:`array`,items:{type:`string`,minLength:1},minItems:2,uniqueItems:!0},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(!Array.isArray(o)||o.some(e=>typeof e!=`string`)){X(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${Sb(o)}`);return}let c=o;if(c.length<2){X(n,s,`cycle needs at least two members (one member has no successor — use a literal "to")`);return}let l=c.some(e=>e===``),u=c.filter(e=>e.includes(`/`));if(l){X(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){X(n,s,`cycle member(s) ${u.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(c).size!==c.length){X(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function FV(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){X(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${J(r[n])}`);return}return!0}}}function IV(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=gb(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){X(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){X(t,o,`${e} "${a}" contains "/" or ":" — segment names in a layout op must be free of both (the click wire's own delimiter and layout-ops.ts's op-token delimiter)`);return}return a}}}function LV(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){X(e,`${t}.${n}`,`relation must be "before" or "after", got ${J(i)}`);return}return i}}}function RV(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){X(e,`${t}.${n}`,`${n} must be an integer, got ${J(i)}`);return}return i}}}function zV(e){return`plugin ${e.path} was not loaded: ${e.reason}`}const BV=new Set([`data`,`sources`,`variables`,`segments`,`helpers`,`actions`]),VV=`plugin.json5`,HV=/^[a-z][a-z0-9_]*$/;function UV(e,t){let n=E.basename(E.dirname(e));return HV.test(n)?{path:e,scope:t,name:n}:{path:e,scope:t,name:void 0}}function WV(e){return`${e}.data`}function GV(e){return`${e}.json`}function KV(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,reason:qV(e)}}}function qV(e){return e instanceof ab?e.issues.map(e=>e.path===``||e.message.includes(e.path)?e.message:`${e.path}: ${e.message}`).join(`; `):e instanceof Error?e.message:String(e)}function JV(e,t,n,r){return e.map(e=>UV(sP(E.dirname(t),e,r),n))}function YV(e,t,n,r){let i=new Map;return e.reduce((e,n)=>{let a=n.path,o=n.name===void 0?void 0:AS(n),c=(t,r)=>{let i=new Map(e.rendering);return o!==void 0&&r!==e.config&&i.delete(o),{...e,config:r,rendering:i,dropped:[...e.dropped,{...n,reason:t}]}};if(E.basename(a)!==`plugin.json5`){let t=`a plugin is a folder holding its ${VV}, and the folder's name is the plugin's: move this file to <dir>/<name>/${VV} and list that`;return c(t,o===void 0?e.config:ZV(XV(e.config,o),o,{...n,reason:t}))}if(n.name===void 0||o===void 0)return c(`its folder "${E.basename(E.dirname(a))}" is not a plugin name (one matching ${HV}: it prefixes every name the plugin declares)`,e.config);let l=i.get(o);if(l!==void 0)return c(`plugin "${n.name}" is already listed, from ${l}`,e.config);i.set(o,a);let u=XV(e.config,o),d=KV(()=>{let i=s.readFileSync(a,`utf-8`),c=wz(rH(a,n,{source:i,json:Ia.default.parse(i)},t),u);return vH(a,o,c),r(c,o,u!==e.config),c});if(d.ok)return{...e,config:d.value,loaded:[...e.loaded,n],rendering:new Map([...e.rendering,[o,n]])};let f={...n,reason:d.reason};return c(d.reason,ZV(u,o,f))},{config:n.config,rendering:n.rendering,loaded:[],dropped:[]})}function XV(e,t){let n=jS(t),r=e=>Object.fromEntries(Object.entries(e).filter(([e])=>!n(e)));return[e.variables,e.segments,e.helpers,e.actions].some(e=>Object.keys(e).some(n))?{...e,variables:r(e.variables),segments:r(e.segments),helpers:r(e.helpers),actions:r(e.actions)}:e}function ZV(e,t,n){return{...e,variables:{...e.variables,[t]:{kind:`dropped`,reason:zV(n),definition:n.path}}}}function QV(e){let t=Object.entries(e.variables).flatMap(([e,t])=>t.kind===`dropped`?[{ns:e,definition:t.definition,notice:t.reason}]:[]);return e=>t.find(({ns:t})=>jS(t)(e))}function $V(e,t){let n=QV(e.config),r=[...e.rendering.keys()].map(jS),i=[...t,...e.dropped].filter(e=>e.name===void 0);return e=>{let t=NS(e);if(t===void 0)return[];let a=n(e);return a===void 0?r.some(t=>t(e))?[]:i.filter(e=>e.scope===t).map(e=>({definition:e.path,notice:zV(e)})):[{definition:a.definition,notice:a.notice}]}}function eH(e,t,n){let r=lS(e.presets).flatMap(t=>[...Ny(fS(e,t).node)]).flatMap(e=>e.kind===`segment`?[e]:[]),i=[...new Set([...r.map(e=>e.name),...n,...Object.keys(e.segments)])].map(e=>({name:e,cause:t(e)})).filter(({cause:e})=>e.length>0),a=Object.fromEntries(i.map(({name:e,cause:t})=>[e,tH(e,t.map(e=>e.notice),r.filter(t=>t.name===e))])),o=QV(e),s=Object.values(e.variables).some(e=>e.kind===`dropped`),c=s?Object.values(e.segments).flatMap(e=>[...sH.flatMap(t=>e[t]===void 0?[]:[e[t]]),...Object.values(e.partials??{})]):[],l=s?Object.values(e.actions).flatMap(e=>`do`in e?[...e.do]:[]):[],u=(e,t)=>[...new Set(e)].flatMap(e=>{let n=e in t?void 0:o(e);return n===void 0?[]:[[e,n]]}),d=u([...c.flatMap(t=>eC(t,e.helpers).map(e=>e.name)),...l],e.actions),f=u(c.flatMap(t=>[...sC(t,e.helpers)]),e.helpers),p=Object.entries(e.actions).flatMap(([t,n])=>{if(!(`run`in n))return[];let r=new Map(u(n.refreshes,e.variables));return r.size===0?[]:[{name:t,action:{...n,refreshes:n.refreshes.filter(e=>!r.has(e))},causes:[...r.values()]}]}),m=new Set([...i.flatMap(({cause:e})=>e.map(e=>e.definition)),...[...d,...f].map(([,e])=>e.definition),...p.flatMap(({causes:e})=>e.map(e=>e.definition))]);return{config:{...e,segments:{...e.segments,...a},actions:{...e.actions,...Object.fromEntries(p.map(({name:e,action:t})=>[e,t])),...Object.fromEntries(d.map(([e,{ns:t}])=>[e,{copy:`{{ .${t} }}`}]))},helpers:{...e.helpers,...Object.fromEntries(f.map(([e,t])=>[e,`{{ fail ${JSON.stringify(t.notice)} }}`]))}},reached:m}}function tH(e,t,n){let r=`⚠ ${e}: ${t.join(`; `)}`,i=new Map;for(let e of n)for(let[t,n]of Object.entries(e.settings??{})){let e=i.get(t);i.set(t,e===void 0?[n]:[...e,n])}let a=Object.fromEntries([...i].map(([e,t])=>[e,nH(e,t)]));return{template:`{{ ${JSON.stringify(r)} }}`,bg:`error`,description:`stands in for a segment whose plugin did not load`,settings:a}}function nH(e,t){let[n]=t,r=t.filter(e=>typeof e==`number`);return typeof n==`boolean`?{label:e,domain:`bool`,default:n}:typeof n==`number`?{label:e,domain:{min:Math.min(...r),max:Math.max(...r),step:1},default:n}:{label:e,domain:[...new Set(t.map(String))],default:n}}function rH(e,t,{source:n,json:r},{checkout:i,home:a}){let o=AS(t),c=[],l=()=>{throw new ab(e,c)};if(!xb(r))return c.push({path:``,message:`a plugin definition must be an object, got ${Sb(r)}`}),l();for(let t of Object.keys(r))BV.has(t)||c.push({path:t,message:t===`plugin`?`a plugin definition does not name itself: its name is its folder's ("${E.basename(E.dirname(e))}") — remove "plugin"`:`a plugin definition may not declare "${t}". Expected only: ${[...BV].join(`, `)}`});let u=r.data===void 0?void 0:xH(r.data,e,i,a,c),d=r.sources===void 0?{}:_H(r.sources,e,c);if(c.length>0)return l();let f={source:n,issues:c,allowedPalettes:new Set(Gv()),groups:[],unplaced:[],inherited:[]},p=u===void 0?{}:Gz(f,`data`,{[WV(o)]:{kind:`file`,path:u,parse:{json:!0},cache:{watch_file:u},default:{}}}),m=Gz(f,`variables`,r.variables);for(let[e,t]of[[`variables`,Object.keys(m)],[`sources`,Object.keys(d)]])t.includes(`data`)&&c.push({path:`${e}.data`,message:`"data" names the plugin's data file (.${WV(o)}), declared by the definition's own "data" key: give this ${e===`sources`?`source`:`variable`} another name`});for(let e of Object.keys(d))Object.hasOwn(m,e)&&c.push({path:`sources.${e}`,message:`source "${e}" and variable "${e}" are one name (.${o}.${e}): give one of them another name`});let h={variables:{...p,...uH(o,d),...uH(o,Object.fromEntries(Object.entries(m).map(([e,t])=>[e,fH(o,t)])))},segments:uH(o,pH(o,PB(f,r.segments,new Set))),helpers:uH(o,GB(f,r.helpers)),actions:uH(o,mH(o,KB(f,r.actions,{dir:s.realpathSync(E.dirname(e))})))};c.push(...cH(h,t));let g=iH(o,h);for(let[e,t]of lH(g))try{ON.parse(t)}catch(t){c.push({path:e,message:`Template parse error in ${e}: ${t.message}`})}return c.length>0&&l(),g}function iH(e,t){let n=t=>lC(t,MS,e),r=t=>jS(`self`)(t)?`${e}${t.slice(4)}`:t,i=(e,t)=>Object.fromEntries(Object.entries(e??{}).map(([e,n])=>[e,t(n)]));return{...t,variables:i(t.variables,e=>aH(Vy(e,n),r)),segments:i(t.segments,e=>({...e,...Object.fromEntries(sH.flatMap(t=>e[t]===void 0?[]:[[t,n(e[t])]])),...e.partials!==void 0&&{partials:i(e.partials,n)},...e.vars!==void 0&&{vars:i(e.vars,e=>aH(Vy(e,n),r))}})),helpers:i(t.helpers,n),actions:i(t.actions,e=>oH(DS(e,n),r))}}function aH(e,t){return By(e)&&`depends_on`in e.cache?{...e,cache:{depends_on:e.cache.depends_on.map(t)}}:e}function oH(e,t){let n=`segments.`,r={...e};`do`in e&&(r.do=e.do.map(e=>t(e,`do`)));for(let n of[`removeSegment`,`insertSegment`,`anchor`])n in e&&(r[n]=t(e[n],n));return`persist`in e&&e.persist.startsWith(n)&&(r.persist=n+t(e.persist.slice(9),`persist`)),r}const sH=[`template`,`bg`,`fg`,`when`];function cH(e,t){let n=e.helpers??{},r=kS.filter(e=>e!==t.scope).map(e=>({scope:e,ns:AS({scope:e,name:t.name})})),i=new Map,a=(e,n,a)=>{let o=r.find(({ns:e})=>jS(e)(n));if(o===void 0)return;let s=a?`.`:``;i.set(`${e}\0${n}`,{path:e,message:`${e} names ${s}${n}, this plugin under "${o.scope}", but it loads as ${AS(t)}: a plugin names itself without its scope — write ${s}${MS}${n.slice(o.ns.length)}`})},o=[...[...lH(e)].filter(([e])=>!e.startsWith(`helpers.`)),...Object.entries(n).map(([e,t])=>[`helpers.${e}`,t])];for(let[e,t]of o){for(let[r,i]of XS(t,n))i===null&&a(e,r,!0);for(let{name:r,via:i}of eC(t,n))i===null&&a(e,r,!1);for(let n of sC(t,{}))a(e,n,!1)}for(let[t,n]of Object.entries(e.actions??{}))oH(n,(e,n)=>(a(`actions.${t}.${n}`,e,!1),e));let s=[...Object.entries(e.variables??{}).map(([e,t])=>[`variables.${e}`,t]),...Object.entries(e.segments??{}).flatMap(([e,t])=>Object.entries(t.vars??{}).map(([t,n])=>[`segments.${e}.vars.${t}`,n]))];for(let[e,t]of s)if(By(t)&&`depends_on`in t.cache)for(let n of t.cache.depends_on)a(`${e}.cache.depends_on`,n,!1);return[...i.values()]}function*lH(e){for(let[t,n]of Object.entries(e.variables??{}))for(let[e,r]of Hy(n))yield[`variables.${t}.${e}`,r];for(let[t,n]of Object.entries(e.segments??{})){for(let e of sH){let r=n[e];r!==void 0&&(yield[`segments.${t}.${e}`,r])}for(let[e,r]of Object.entries(n.partials??{}))yield[`segments.${t}.partials.${e}`,r];for(let[e,r]of Object.entries(n.vars??{}))for(let[n,i]of Hy(r))yield[`segments.${t}.vars.${e}.${n}`,i]}for(let[t,n]of Object.entries(e.helpers??{}))yield[`helpers.${t}`,`{{ define "${t}" }}${n}{{ end }}`];for(let[t,n]of Object.entries(e.actions??{}))for(let[e,r]of ES(n))yield[`actions.${t}.${e}`,r]}function uH(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[`${e}.${t}`,n]))}function dH(e,t){return`${e}.${t}`}function fH(e,t){return t.kind===`state`?{...t,key:dH(e,t.key)}:t}function pH(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,n.vars===void 0?n:{...n,vars:Object.fromEntries(Object.entries(n.vars).map(([t,n])=>[t,fH(e,n)]))}]))}function mH(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[t,`set`in n?{...n,set:dH(e,n.set)}:`run`in n?{...n,refreshes:n.refreshes.map(t=>dH(e,t))}:n]))}const hH=HV,gH={scope:`session`,refresh:{watch:!0},read:{file:{json:!0}}};function _H(e,t,n){if(!xb(e))return n.push({path:`sources`,message:`"sources" must be an object of named sources, got ${Sb(e)}`}),{};let r=E.join(s.realpathSync(E.dirname(t)),`session`),i=JSON.stringify(gH),a={};for(let[t,o]of Object.entries(e)){let e=`sources.${t}`;if(!hH.test(t)){n.push({path:e,message:`source name "${t}" is not one identifier (one matching ${hH}: it is the last segment of .<scope>.<plugin>.${t})`});continue}let s=bH(o,gH,e);for(let{field:e,is:t}of s)n.push({path:e,message:`${e} ${t}: what is built is a source ${i} — a session's JSON file in the plugin's managed storage, re-read when it changes`});s.length===0&&(a[t]={kind:`source`,storage:r})}return a}function vH(e,t,n){let r=Object.entries(n.variables).reduce((e,[t,n])=>{if(n.kind!==`source`)return e;let r=yH(n);return e.set(r,[...e.get(r)??[],t])},new Map),i=jS(t),a=[...r].filter(([,e])=>e.length>1&&e.some(i)).map(([e,n])=>({path:`sources.${n.find(i).slice(`${t}.`.length)}`,message:`sources ${n.map(e=>`.${e}`).join(` and `)} read the same file, ${e}: a session's file is one document, read by one source`}));if(a.length>0)throw new ab(e,a)}function yH(e){return E.join(e.storage,GV(`<session id>`))}function bH(e,t,n){return!xb(t)||!xb(e)?JSON.stringify(e)===JSON.stringify(t)?[]:[{field:n,is:`is ${JSON.stringify(e)}`}]:[...new Set([...Object.keys(t),...Object.keys(e)])].flatMap(r=>{let i=`${n}.${r}`;return Object.hasOwn(t,r)?Object.hasOwn(e,r)?bH(e[r],t[r],i):[{field:i,is:`is missing`}]:[{field:i,is:`is not built`}]})}function xH(e,t,n,r,i){if(typeof e==`string`&&e!==``)return sP(E.dirname(t),e,r);if(xb(e)&&Object.keys(e).length===1&&typeof e.checkout==`string`&&e.checkout!==``){let t=e.checkout;if(E.isAbsolute(t)||t.startsWith(`~`)||E.normalize(t).split(E.sep)[0]===`..`){i.push({path:`data.checkout`,message:`data.checkout "${t}" must be a path inside the checkout, relative to its root (like ".lit/statusline.json"): no absolute path, "~" or ".."`});return}if(n===null){i.push({path:`data.checkout`,message:`data is read from the session's checkout, and this load has no session`});return}return E.resolve(n.root,t)}if(xb(e)&&`project`in e){i.push({path:`data.project`,message:`data: { project } is now data: { checkout }: the same path, relative to the root of the git checkout the session works in (a linked worktree is its own checkout)`});return}i.push({path:`data`,message:`"data" must be the path of the plugin's JSON data file relative to this definition, or { checkout: "<path>" } relative to the root of the session's checkout`})}function SH(e,t){let n=[...[...e.dataDirs].reverse().map(e=>E.join(e,`cc-candybar`,`plugins`)),CH(e)];return[...n.filter((e,t)=>n.lastIndexOf(e)===t).map(e=>({dir:e,scope:`plugins`})),...t===null?[]:[{dir:E.join(t,wH),scope:`repo`}]]}function CH(e){return E.join(e.dataHome,`cc-candybar`,`plugins`)}const wH=E.join(`.cc-candybar`,`plugins`);function TH(e,t){let n=SH(e,t),r=new Map,i=[],a=[];for(let{dir:e,scope:t}of n){let n=EH(e);if(`error`in n){i.push(n);continue}for(let i of n.folders){let n=UV(E.join(e,i,VV),t),a=`${t}\0${i}`;r.delete(a),r.set(a,n)}for(let r of n.files)a.push({path:E.join(e,r),scope:t,name:void 0,reason:`a plugin is a folder holding its ${VV}: move this file to ${E.join(e,`<name>`,VV)}`})}return{roots:n.map(e=>e.dir),definitions:[...r.values()],unchecked:i,strays:a}}function EH(e){try{let t=s.readdirSync(e,{withFileTypes:!0}).filter(e=>!e.name.startsWith(`.`)).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)),n=t=>t.isDirectory()||DH(e,t);return{folders:t.filter(n).map(e=>e.name),files:t.filter(e=>!n(e)).map(e=>e.name)}}catch(t){return t.code===`ENOENT`?{folders:[],files:[]}:{path:e,error:t.message}}}function DH(e,t){if(!t.isSymbolicLink())return!1;try{return s.statSync(E.join(e,t.name)).isDirectory()}catch{return!0}}function OH(e){return s.existsSync(E.join(e,`.git`))}function kH(e){let t=E.resolve(e);for(;;){if(OH(t))return t;let e=E.dirname(t);if(e===t)return;t=e}}function AH(e){let t=kH(e);return t===void 0?{root:E.resolve(e),git:!1}:{root:t,git:!0}}function jH(e){try{return F(e())}catch(e){return e.code===`ENOENT`?I:L(e.message,`read`)}}const MH=e=>jH(()=>s.realpathSync.native(e)),NH=(e,t)=>t.kind===`absent`?`${e} is not there`:t.reason;function PH(e){let t=jH(()=>s.readFileSync(E.join(e,`.git`),`utf-8`));if(t.kind!==`ok`)return t;let n=t.value.match(/^gitdir:\s*(.+)$/m)?.[1]?.trim();return n===void 0?L(`${E.join(e,`.git`)} names no gitdir`,`parse`):F(E.resolve(e,n))}function FH(e){let t=jH(()=>s.readFileSync(E.join(e,`commondir`),`utf-8`));if(t.kind!==`ok`)return t;let n=t.value.trim();return n===``?L(`${E.join(e,`commondir`)} is empty`,`parse`):F(E.resolve(e,n))}const IH={kind:`unlinked`},LH=e=>({kind:`unproven`,reason:e});function RH(e){let t=kH(e);if(t===void 0)return IH;let n=E.join(t,`.git`),r=jH(()=>s.statSync(n));if(r.kind===`ok`&&r.value.isDirectory())return IH;let i=jH(()=>s.lstatSync(n));if(i.kind!==`ok`)return LH(NH(n,i));if(!i.value.isFile())return LH(`${n} is not a file`);let a=PH(t);if(a.kind!==`ok`)return LH(NH(n,a));let o=MH(a.value);if(o.kind!==`ok`)return LH(NH(a.value,o));let c=FH(o.value);if(c.kind===`absent`)return IH;if(c.kind===`failed`)return LH(c.reason);let l=MH(c.value);if(l.kind!==`ok`)return LH(NH(c.value,l));if(E.dirname(o.value)!==E.join(l.value,`worktrees`))return LH(`${o.value} is not a worktree of ${l.value}`);let u=E.join(o.value,`gitdir`),d=jH(()=>s.readFileSync(u,`utf-8`));if(d.kind!==`ok`)return LH(NH(u,d));let f=E.resolve(o.value,d.value.trim()),p=MH(E.dirname(f));if(E.basename(f)!==`.git`||p.kind!==`ok`||p.value!==t)return LH(`${o.value} is the worktree at ${f}, not ${t}`);let m=E.basename(l.value)===`.git`?E.dirname(l.value):l.value;return{kind:`linked`,main:E.join(m,E.relative(t,e))}}function zH(e){let t=MH(e),n=t.kind===`ok`?t.value:E.resolve(e),r=kH(n);if(r===void 0)return{main:``,worktree:``,subpath:``,noRepo:!0};let i=E.relative(r,n),a=i===``?``:`/${i.split(E.sep).join(`/`)}`,o=RH(n);return o.kind===`linked`?{main:E.resolve(o.main,E.relative(n,r)),worktree:E.basename(r),subpath:a,noRepo:!1}:{main:r,worktree:``,subpath:a,noRepo:!1}}const BH=[`approved`,`declined`];function VH(e){return e.link.kind===`linked`?e.link.main:e.dir}const HH=(e,t)=>Object.hasOwn(e,t)?e[t]:null;function UH(e,t){let n=VH(t);if(e.kind===`failed`)return{standing:`unread`,under:n};let r=HH(e.value,n),i=HH(e.value,t.dir);return r===null?i===null?{standing:`awaiting`,under:n}:{standing:i,under:t.dir}:{standing:i===null||i===r?r:`awaiting`,under:n}}function WH(e,t,n){let r=[...new Map([...t,...n?.ships?[n]:[]].map(e=>[e.dir,e])).values()],i=r.map(t=>({dir:t.dir,...UH(e,t)})),a=e=>i.filter(t=>t.standing===e),o=e=>[...new Set(a(e).map(e=>e.under))];return{plugins:n!==null&&UH(e,n).standing===`approved`?n.path:null,approved:a(`approved`).map(e=>e.dir),awaiting:o(`awaiting`),declined:o(`declined`),unproven:r.flatMap(e=>e.link.kind===`unproven`?[{dir:e.dir,reason:e.link.reason}]:[]),unread:e.kind===`failed`?e.reason:null}}function GH(e,t,n,r){if(e[t]===n&&r.length===0)return e;let i=Object.entries(e).filter(([e])=>!r.includes(e));return{...Object.fromEntries(i),[t]:n}}function KH(e){if(typeof e!=`object`||!e||Array.isArray(e))return{kind:`failed`,reason:`is not an object`};for(let[t,n]of Object.entries(e))if(!BH.includes(n))return{kind:`failed`,reason:`answers ${JSON.stringify(t)} ${JSON.stringify(n)}, not ${BH.join(` or `)}`};return{kind:`ok`,value:e}}function qH(e){return e.unread===null?null:`Repository config answers could not be read: ${e.unread} — no repository's config runs until they can be`}function JH(e){let t=qH(e);return[...t===null?[]:[t],...e.awaiting.map(e=>`awaiting approval: ${e} — its cc-candybar config runs once it is approved in the bar`),...e.declined.map(e=>`declined: ${e} — its cc-candybar config does not run`),...e.unproven.map(e=>`not proven a worktree: ${e.dir} — it answers for itself, because ${e.reason}`)]}const YH=[`json5`,`json`];function XH(e,t,n,r){if(r!==void 0)return[r];let i=n??process.cwd();return[...new Set([...t?YH.map(e=>E.join(t,`${ZH}.${e}`)):[],...YH.map(e=>E.join(i,`${ZH}.${e}`)),...YH.map(t=>`${QH(e)}.${t}`)])]}const ZH=`.cc-candybar`;function QH(e){return E.join(e.configHome,`cc-candybar`,`config`)}function $H(e){return{path:e,scope:`plugins`}}function eU(e,t,n,r,i){let a=[],o=new Map;for(let t of XH(e,n,r,i)){let n=Cz(t);if(n===`absent`)continue;if(n!==`present`){a.push(n);continue}let r=s.realpathSync.native(E.dirname(t)),c=E.join(r,E.basename(t).replace(/\.(json5|json)$/,``));o.has(c)||o.set(c,{file:t,repo:i!==void 0||tU(e,t)?null:{dir:r,link:RH(r)}})}let c=[...o.values()],l=WH(t,c.flatMap(e=>e.repo===null?[]:[e.repo]),nU(n)),u=c.filter(e=>e.repo===null||l.approved.includes(e.repo.dir)).reverse().map(e=>({path:e.file,scope:e.repo===null?`plugins`:`repo`}));if(i===void 0)return{kind:`chain`,layers:u,home:rU(e,u),unchecked:a,repos:l};let[d]=a,f=i;return u.length>0?{kind:`chain`,layers:u,home:f,unchecked:a,repos:l}:d===void 0?{kind:`missing`,path:i,home:f,repos:l}:{kind:`unreadable`,...d,home:f,repos:l}}function tU(e,t){return YH.some(n=>t===`${QH(e)}.${n}`)}function nU(e){if(e===void 0||Cz(e)!==`present`)return null;let t=EH(E.join(e,wH)),n=s.realpathSync.native(e);return{dir:n,link:RH(n),path:e,ships:!(`error`in t)&&t.folders.length>0}}function rU(e,t){return t.find(t=>tU(e,t.path))?.path??`${QH(e)}.${YH[0]}`}function iU(e,t,n,r,i){let a=eU(e,t,n,r,i),o=a.kind===`chain`?a.layers:[];return{path:a.home,above:o.filter(e=>e.path!==a.home),repo:a.repos.plugins,cwd:r??null,locs:e}}function aU(e){return oU(e).join(`
180
- `)||null}function oU(e){switch(e.kind){case`chain`:return e.unchecked.map(e=>`Config location could not be checked: ${e.path} — ${e.error}`);case`missing`:return[`Config file not found: ${e.path} — rendering the bundled default until it appears`];case`unreadable`:return[`Config file could not be read: ${e.path} — ${e.error} — rendering the bundled default until it can be`]}}function sU(e,t,n){let r=XH(e,t,n).filter(e=>Cz(e)===`present`),i=new Map;for(let e of r){let t=E.dirname(e),n=E.basename(e).replace(/\.(json5|json)$/,``),r=E.join(t,n);i.has(r)||i.set(r,[]),i.get(r).push(e)}let a=[...i.values()].filter(e=>e.length>1);return a.length===0?null:`config-extension collision: ${a.map(e=>{let[t,...n]=e;return`${t} shadows ${n.join(`, `)}`}).join(`; `)} — remove the duplicate`}function cU(e,t,n,r){let i=E.join(e,t),a=()=>{let e;try{e=s.readFileSync(i,`utf8`)}catch(e){return e.code===`ENOENT`?{kind:`ok`,value:n}:{kind:`failed`,reason:`${i}: ${e.message}`}}let t;try{t=JSON.parse(e)}catch(e){return{kind:`failed`,reason:`${i} is not JSON: ${e.message}`}}let a=r(t);return a.kind===`ok`?a:{kind:`failed`,reason:`${i} ${a.reason}`}};return{read:a,update:e=>{let t=a();if(t.kind===`failed`)return t;let n=e(t.value);return n!==t.value&&Dn(i,`${JSON.stringify(n,null,2)}\n`),{kind:`ok`,value:n}}}}const lU={error:{rank:0,glyph:`⚠`,colors:OP},warning:{rank:1,glyph:`⚠`,colors:tte},info:{rank:2,glyph:`ℹ`,colors:nte}},uU={level:`error`,glyph:lU.error.glyph},dU={level:`warning`,glyph:lU.warning.glyph},fU={level:`info`,glyph:`⬆`},pU={level:`info`,glyph:`🔒`},mU={level:`info`,glyph:`🧪`},hU=e=>lU[e.level].colors;function gU(e,t){return{text:AP(e),link:t}}function _U(e,t,n,r,i){let a=new Set,o=(e,t)=>{let n=vU(e,t);for(let e of n)a.add(e);return n},s=[...n.flatMap(e=>o(e,uU)),...r,...i.flatMap(e=>o(e,dU))].sort((e,t)=>xU(e)-xU(t)),c=yU(s);return s.map((n,r)=>a.has(n)?{...n,lines:[[gU(n.lines[0][0].text,bU(e,t,c[r],r+1))],...n.lines.slice(1)]}:n)}function vU({about:e,text:t,copy:n},r){let[i,...a]=t.split(/\r\n|\r|\n/).map(e=>gU(e,null)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:r,about:e,message:t,copy:n,lines:[i,...a]}]}function yU(e){return TU(e).map(e=>String(e*CU+1))}function bU(e,t,n,r){return Ea([{verb:ha,args:[e,t,n]}],`copy diagnostic ${r}`)}const xU=e=>lU[e.severity.level].rank;function SU(e){return e[0]?.severity.level??null}const CU=4096;function wU(e){let t=oe(`sha256`).update(`${e.severity.level}\0${e.severity.glyph}\0${e.about}`).digest(`hex`);return Number.parseInt(t.slice(0,9),16)%2**32}function TU(e){let t=new Map;return e.map(e=>{let n=wU(e),r=t.get(n)??0;return t.set(n,r+1),n*256+Math.min(r,255)})}function EU(e,t,n){return String(TU(e)[t]*CU+n+1)}function DU(e){let t=SU(e),n=e.length,{glyph:r,colors:i}=lU[t??`info`];return{label:t===null?``:`${r} ${n>9?`9+`:n}`,fg:i.fg,bg:i.bg,open:e.length===0?`0`:EU(e,0,0)}}function OU(e,t){let n=Number(e)-1,r=TU(t).indexOf(Math.floor(n/CU));return e===null||r===-1?null:{index:r+1,page:n%CU}}function kU(e,t){return Math.min(20,e??20,...t)}function AU(e,t,n,r,i){let{index:a}=t,o=e[a-1],s=NU(i),c=IU(o,s,[]),l=hU(o.severity),u=new U({bgcolor:l.bg,color:l.fg}),d=(e,t)=>PU(e,t===null?u:u.withLink(t)),f=(t,r)=>r===null?d(` `,null):d(t,MU(n,EU(e,r.index-1,r.page),`show diagnostic ${r.index} of ${e.length} page ${r.page+1}`)),p=(t,i)=>{let o=i>0?{index:a,page:i-1}:a>1?{index:a-1,page:0}:null,c=i<t-1?{index:a,page:i+1}:a<e.length?{index:a+1,page:0}:null,l=e.length>1||t>1,u=t>1?`[${a}/${e.length} ${i+1}/${t}]`:`[${a}/${e.length}]`;return FU([d(`✕`,MU(n,`0`)),...l?[f(`‹`,o)]:[],d(u,null),...l?[f(`›`,c)]:[],d(`⧉ copy`,bU(n,r,EU(e,a-1,0),a))],s)},m=1;for(;;){let e=Math.max(1,i.rows-m),n=Math.min(CU,Math.ceil(c.length/e)),r=Math.min(t.page,n-1),a=p(n,r);if(a.length>m){m=a.length;continue}let o=c.slice(r*e,(r+1)*e),l=c.length-(r+1)*e,u=r===n-1&&l>0?[...o.slice(0,-1),...FU([d(`… ${l+1} more rows: ⧉ copy has them all`,null)],{...s,wrap:!1})]:o;return[...a,...u]}}function jU(e,t,n,r){let{label:i,fg:a,bg:o,open:s}=DU(t),c=i===``?[]:[PU(i,new U({bgcolor:o,color:a}).withLink(MU(n,s)))];return IU(e,NU(r),c)}function MU(e,t,n){return Ea([{verb:Wi,args:[e,Bi,t]}],n)}function NU(e){return{endcaps:`plain`,separator:``,width:e.width,wrap:!0,padding:0,colorCompatibility:e.colorCompatibility}}const PU=(e,t)=>new K(`${e} `,{style:t,end:``,overflow:`ignore`}),FU=(e,t)=>XP(e,t).lines.map(e=>({kind:`diagnostic`,runs:e}));function IU(e,t,n){let r=hU(e.severity),i=new U({bgcolor:r.bg,color:r.fg}),a=e=>e===null?i:i.withLink(e),o=ll(Math.max(2,t.width-1));return e.lines.flatMap((r,s)=>{let c=PU(s===0?e.severity.glyph:` `,i),l=r.flatMap(e=>e.text.split(` `).flatMap(e=>ml(e,o)).map(t=>PU(t,a(e.link)))),u=s===0?n:[];return FU([c,...l,...u],t)})}const LU=`repo-configs.json`;function RU(e){return E.join(e,`repo-configs`)}function zU(e){return E.join(RU(e),LU)}const BU=e=>{let t=cU(RU(e),LU,{},KH),n=cU(e,LU,{},KH),r=()=>s.existsSync(zU(e));return{read:()=>(r()?t:n).read(),update:e=>{if(r())return t.update(e);let i=n.read();return i.kind===`failed`?i:t.update(()=>e(i.value))}}};function VU(e,t,n){let r={superseded:[],absent:[],unchecked:[]},i=e.update(e=>{let i=Object.keys(e).filter(e=>e!==t).map(e=>({d:e,found:Cz(e)}));return r={superseded:i.filter(({d:e,found:n})=>n===`present`&&VH({dir:e,link:RH(e)})===t).map(({d:e})=>e),absent:i.filter(({found:e})=>e===`absent`).map(({d:e})=>e),unchecked:i.flatMap(({found:e})=>typeof e==`object`?[e]:[])},GH(e,t,n,r.superseded)});return i.kind===`failed`?i:F(r)}function HU(e,t,n){return{sessionId:e,action:ma,declaration:t,evaluated:n}}function UU(e,t,n){return e.awaiting.map(e=>{let r=`a cc-candybar config for ${e} — run it?`,i=BH.map(r=>gU(`[${r===`approved`?`approve`:`decline`}]`,Ea([{verb:ma,args:[t,e,r,n.sign(HU(t,e,r))]}]))),a=[gU(r,null),...i];return{severity:pU,about:`repo-question\0${e}`,message:r,copy:r,lines:[a]}})}const WU=`#/definitions/LayoutNode`,GU={kind:`container`,direction:`vertical`,children:[]};function KU(e){return{required:!0,json:{const:e},parse:()=>e}}function qU(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&i.length>0?i:(e.issues.push({path:`${t}.${n}`,message:`a segment node must have a non-empty "name" (a segment name), got ${J(i)}`,line:q(e.source,[`root`])}),``)}}}function JU(){return{required:!0,json:{enum:[...Dy]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&Dy.includes(i)?i:(e.issues.push({path:`${t}.${n}`,message:`a container "direction" must be one of: ${Dy.join(`, `)} (got ${JSON.stringify(i)})`,line:q(e.source,[`root`])}),`vertical`)}}}function YU(e){return{required:!0,json:{type:`array`,items:{$ref:WU}},parse:(t,n,r,i)=>{let a=i[r];return Array.isArray(a)?a.map((i,a)=>e(t,`${n}.${r}[${a}]`,i)):(t.issues.push({path:`${n}.${r}`,message:`a container must have a "children" array of layout nodes, got ${Sb(a)}`,line:q(t.source,[`root`])}),[])}}}const XU={noun:`layout-node key`,fields:{kind:KU(`segment`),name:qU(),when:Pb(),id:jB(),settings:MB()}},ZU=()=>Hb($_),QU={noun:`layout-node key`,fields:{kind:KU(`container`),direction:JU(),children:YU(Mb(()=>rW)),when:Pb(),distribution:ZU()}};function $U(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&i.length>0?i:(e.issues.push({path:`${t}.${n}`,message:`a "seg" node must have a non-empty segment name, got ${J(i)}`,line:q(e.source,[...t.split(`.`),n])}),``)}}}const eW={noun:`layout-node key`,fields:{seg:$U(),when:Pb(),id:jB(),settings:MB()}},tW={noun:`layout-node key`,fields:{h:YU(Mb(()=>rW)),when:Pb(),distribution:ZU()}},nW={noun:`layout-node key`,fields:{v:YU(Mb(()=>rW)),when:Pb(),distribution:ZU()}},rW=(e,t,n)=>{if(typeof n==`string`)return n.length===0?(e.issues.push({path:t,message:`a bare-string layout node must be a non-empty segment name`,line:q(e.source,[`root`])}),GU):{kind:`segment`,name:n};if(!xb(n))return e.issues.push({path:t,message:`a layout node must be a string (segment name) or an object with "kind" / "seg" / "h" / "v", got ${Sb(n)}`,line:q(e.source,[`root`])}),GU;if(n.kind===`container`)return Cb(e,QU,t,n)??GU;if(n.kind===`segment`)return Cb(e,XU,t,n)??GU;if(n.kind===`cells`)return e.issues.push({path:t,message:`kind: "cells" is no longer supported — use the h-arm spelling instead:
180
+ `)||null}function oU(e){switch(e.kind){case`chain`:return e.unchecked.map(e=>`Config location could not be checked: ${e.path} — ${e.error}`);case`missing`:return[`Config file not found: ${e.path} — rendering the bundled default until it appears`];case`unreadable`:return[`Config file could not be read: ${e.path} — ${e.error} — rendering the bundled default until it can be`]}}function sU(e,t,n){let r=XH(e,t,n).filter(e=>Cz(e)===`present`),i=new Map;for(let e of r){let t=E.dirname(e),n=E.basename(e).replace(/\.(json5|json)$/,``),r=E.join(t,n);i.has(r)||i.set(r,[]),i.get(r).push(e)}let a=[...i.values()].filter(e=>e.length>1);return a.length===0?null:`config-extension collision: ${a.map(e=>{let[t,...n]=e;return`${t} shadows ${n.join(`, `)}`}).join(`; `)} — remove the duplicate`}function cU(e,t,n,r){let i=E.join(e,t),a=()=>{let e;try{e=s.readFileSync(i,`utf8`)}catch(e){return e.code===`ENOENT`?{kind:`ok`,value:n}:{kind:`failed`,reason:`${i}: ${e.message}`}}let t;try{t=JSON.parse(e)}catch(e){return{kind:`failed`,reason:`${i} is not JSON: ${e.message}`}}let a=r(t);return a.kind===`ok`?a:{kind:`failed`,reason:`${i} ${a.reason}`}};return{read:a,update:e=>{let t=a();if(t.kind===`failed`)return t;let n=e(t.value);return n!==t.value&&Dn(i,`${JSON.stringify(n,null,2)}\n`),{kind:`ok`,value:n}}}}const lU={error:{rank:0,glyph:`⚠`,colors:OP},warning:{rank:1,glyph:`⚠`,colors:tte},info:{rank:2,glyph:`ℹ`,colors:nte}},uU={level:`error`,glyph:lU.error.glyph},dU={level:`warning`,glyph:lU.warning.glyph},fU={level:`info`,glyph:`⬆`},pU={level:`info`,glyph:`🔒`},mU={level:`info`,glyph:`🧪`},hU=e=>lU[e.level].colors;function gU(e,t){return{text:AP(e),link:t}}function _U(e,t,n,r,i){let a=new Set,o=(e,t)=>{let n=vU(e,t);for(let e of n)a.add(e);return n},s=[...n.flatMap(e=>o(e,uU)),...r,...i.flatMap(e=>o(e,dU))].sort((e,t)=>xU(e)-xU(t)),c=yU(s);return s.map((n,r)=>a.has(n)?{...n,lines:[[gU(n.lines[0][0].text,bU(e,t,c[r],r+1))],...n.lines.slice(1)]}:n)}function vU({about:e,text:t,copy:n},r){let[i,...a]=t.split(/\r\n|\r|\n/).map(e=>gU(e,null)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:r,about:e,message:t,copy:n,lines:[i,...a]}]}function yU(e){return TU(e).map(e=>String(e*CU+1))}function bU(e,t,n,r){return Ea([{verb:ha,args:[e,t,n]}],`copy diagnostic ${r}`)}const xU=e=>lU[e.severity.level].rank;function SU(e){return e[0]?.severity.level??null}const CU=4096;function wU(e){let t=ae(`sha256`).update(`${e.severity.level}\0${e.severity.glyph}\0${e.about}`).digest(`hex`);return Number.parseInt(t.slice(0,9),16)%2**32}function TU(e){let t=new Map;return e.map(e=>{let n=wU(e),r=t.get(n)??0;return t.set(n,r+1),n*256+Math.min(r,255)})}function EU(e,t,n){return String(TU(e)[t]*CU+n+1)}function DU(e){let t=SU(e),n=e.length,{glyph:r,colors:i}=lU[t??`info`];return{label:t===null?``:`${r} ${n>9?`9+`:n}`,fg:i.fg,bg:i.bg,open:e.length===0?`0`:EU(e,0,0)}}function OU(e,t){let n=Number(e)-1,r=TU(t).indexOf(Math.floor(n/CU));return e===null||r===-1?null:{index:r+1,page:n%CU}}function kU(e,t){return Math.min(20,e??20,...t)}function AU(e,t,n,r,i){let{index:a}=t,o=e[a-1],s=NU(i),c=IU(o,s,[]),l=hU(o.severity),u=new U({bgcolor:l.bg,color:l.fg}),d=(e,t)=>PU(e,t===null?u:u.withLink(t)),f=(t,r)=>r===null?d(` `,null):d(t,MU(n,EU(e,r.index-1,r.page),`show diagnostic ${r.index} of ${e.length} page ${r.page+1}`)),p=(t,i)=>{let o=i>0?{index:a,page:i-1}:a>1?{index:a-1,page:0}:null,c=i<t-1?{index:a,page:i+1}:a<e.length?{index:a+1,page:0}:null,l=e.length>1||t>1,u=t>1?`[${a}/${e.length} ${i+1}/${t}]`:`[${a}/${e.length}]`;return FU([d(`✕`,MU(n,`0`)),...l?[f(`‹`,o)]:[],d(u,null),...l?[f(`›`,c)]:[],d(`⧉ copy`,bU(n,r,EU(e,a-1,0),a))],s)},m=1;for(;;){let e=Math.max(1,i.rows-m),n=Math.min(CU,Math.ceil(c.length/e)),r=Math.min(t.page,n-1),a=p(n,r);if(a.length>m){m=a.length;continue}let o=c.slice(r*e,(r+1)*e),l=c.length-(r+1)*e,u=r===n-1&&l>0?[...o.slice(0,-1),...FU([d(`… ${l+1} more rows: ⧉ copy has them all`,null)],{...s,wrap:!1})]:o;return[...a,...u]}}function jU(e,t,n,r){let{label:i,fg:a,bg:o,open:s}=DU(t),c=i===``?[]:[PU(i,new U({bgcolor:o,color:a}).withLink(MU(n,s)))];return IU(e,NU(r),c)}function MU(e,t,n){return Ea([{verb:Wi,args:[e,Bi,t]}],n)}function NU(e){return{endcaps:`plain`,separator:``,width:e.width,wrap:!0,padding:0,colorCompatibility:e.colorCompatibility}}const PU=(e,t)=>new K(`${e} `,{style:t,end:``,overflow:`ignore`}),FU=(e,t)=>XP(e,t).lines.map(e=>({kind:`diagnostic`,runs:e}));function IU(e,t,n){let r=hU(e.severity),i=new U({bgcolor:r.bg,color:r.fg}),a=e=>e===null?i:i.withLink(e),o=ll(Math.max(2,t.width-1));return e.lines.flatMap((r,s)=>{let c=PU(s===0?e.severity.glyph:` `,i),l=r.flatMap(e=>e.text.split(` `).flatMap(e=>ml(e,o)).map(t=>PU(t,a(e.link)))),u=s===0?n:[];return FU([c,...l,...u],t)})}const LU=`repo-configs.json`;function RU(e){return E.join(e,`repo-configs`)}function zU(e){return E.join(RU(e),LU)}const BU=e=>{let t=cU(RU(e),LU,{},KH),n=cU(e,LU,{},KH),r=()=>s.existsSync(zU(e));return{read:()=>(r()?t:n).read(),update:e=>{if(r())return t.update(e);let i=n.read();return i.kind===`failed`?i:t.update(()=>e(i.value))}}};function VU(e,t,n){let r={superseded:[],absent:[],unchecked:[]},i=e.update(e=>{let i=Object.keys(e).filter(e=>e!==t).map(e=>({d:e,found:Cz(e)}));return r={superseded:i.filter(({d:e,found:n})=>n===`present`&&VH({dir:e,link:RH(e)})===t).map(({d:e})=>e),absent:i.filter(({found:e})=>e===`absent`).map(({d:e})=>e),unchecked:i.flatMap(({found:e})=>typeof e==`object`?[e]:[])},GH(e,t,n,r.superseded)});return i.kind===`failed`?i:F(r)}function HU(e,t,n){return{sessionId:e,action:ma,declaration:t,evaluated:n}}function UU(e,t,n){return e.awaiting.map(e=>{let r=`a cc-candybar config for ${e} — run it?`,i=BH.map(r=>gU(`[${r===`approved`?`approve`:`decline`}]`,Ea([{verb:ma,args:[t,e,r,n.sign(HU(t,e,r))]}]))),a=[gU(r,null),...i];return{severity:pU,about:`repo-question\0${e}`,message:r,copy:r,lines:[a]}})}const WU=`#/definitions/LayoutNode`,GU={kind:`container`,direction:`vertical`,children:[]};function KU(e){return{required:!0,json:{const:e},parse:()=>e}}function qU(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&i.length>0?i:(e.issues.push({path:`${t}.${n}`,message:`a segment node must have a non-empty "name" (a segment name), got ${J(i)}`,line:q(e.source,[`root`])}),``)}}}function JU(){return{required:!0,json:{enum:[...Dy]},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&Dy.includes(i)?i:(e.issues.push({path:`${t}.${n}`,message:`a container "direction" must be one of: ${Dy.join(`, `)} (got ${JSON.stringify(i)})`,line:q(e.source,[`root`])}),`vertical`)}}}function YU(e){return{required:!0,json:{type:`array`,items:{$ref:WU}},parse:(t,n,r,i)=>{let a=i[r];return Array.isArray(a)?a.map((i,a)=>e(t,`${n}.${r}[${a}]`,i)):(t.issues.push({path:`${n}.${r}`,message:`a container must have a "children" array of layout nodes, got ${Sb(a)}`,line:q(t.source,[`root`])}),[])}}}const XU={noun:`layout-node key`,fields:{kind:KU(`segment`),name:qU(),when:Pb(),id:jB(),settings:MB()}},ZU=()=>Hb($_),QU={noun:`layout-node key`,fields:{kind:KU(`container`),direction:JU(),children:YU(Mb(()=>rW)),when:Pb(),distribution:ZU()}};function $U(){return{required:!0,json:{type:`string`},parse:(e,t,n,r)=>{let i=r[n];return typeof i==`string`&&i.length>0?i:(e.issues.push({path:`${t}.${n}`,message:`a "seg" node must have a non-empty segment name, got ${J(i)}`,line:q(e.source,[...t.split(`.`),n])}),``)}}}const eW={noun:`layout-node key`,fields:{seg:$U(),when:Pb(),id:jB(),settings:MB()}},tW={noun:`layout-node key`,fields:{h:YU(Mb(()=>rW)),when:Pb(),distribution:ZU()}},nW={noun:`layout-node key`,fields:{v:YU(Mb(()=>rW)),when:Pb(),distribution:ZU()}},rW=(e,t,n)=>{if(typeof n==`string`)return n.length===0?(e.issues.push({path:t,message:`a bare-string layout node must be a non-empty segment name`,line:q(e.source,[`root`])}),GU):{kind:`segment`,name:n};if(!xb(n))return e.issues.push({path:t,message:`a layout node must be a string (segment name) or an object with "kind" / "seg" / "h" / "v", got ${Sb(n)}`,line:q(e.source,[`root`])}),GU;if(n.kind===`container`)return Cb(e,QU,t,n)??GU;if(n.kind===`segment`)return Cb(e,XU,t,n)??GU;if(n.kind===`cells`)return e.issues.push({path:t,message:`kind: "cells" is no longer supported — use the h-arm spelling instead:
181
181
  Old: { kind: "cells", segments: ["seg1", "seg2"] }
182
182
  New: { h: ["seg1", "seg2"] }`,line:q(e.source,[`root`])}),GU;if(n.kind===`group`){let r=Cb(e,fW,t,n);return r===null?GU:(e.groups.push({name:r.name,label:r.label,...r.open!==void 0&&{open:r.open},...r.direction!==void 0&&{direction:r.direction},...r.key!==void 0&&{key:r.key},...r.bg!==void 0&&{bg:r.bg},...r.fg!==void 0&&{fg:r.fg},...r.when!==void 0&&{when:r.when},path:t}),mW(r))}let r=`h`in n,i=`v`in n,a=`seg`in n;if(+!!r+ +!!i+ +!!a>1){let r=[`seg`,`h`,`v`].filter(e=>e in n);return e.issues.push({path:t,message:`a layout node may have exactly one of "seg", "h", or "v" — got ${r.map(e=>`"${e}"`).join(` and `)} together`,line:q(e.source,[`root`])}),GU}if(a){let r=Cb(e,eW,t,n);return r===null?GU:{kind:`segment`,name:r.seg,...r.when!==void 0&&{when:r.when},...r.id!==void 0&&{id:r.id},...r.settings!==void 0&&{settings:r.settings}}}if(r){let r=Cb(e,tW,t,n);return r===null?GU:{kind:`container`,direction:`horizontal`,children:r.h,...r.when!==void 0&&{when:r.when},...r.distribution!==void 0&&{distribution:r.distribution}}}if(i){let r=Cb(e,nW,t,n);return r===null?GU:{kind:`container`,direction:`vertical`,children:r.v,...r.when!==void 0&&{when:r.when},...r.distribution!==void 0&&{distribution:r.distribution}}}return e.issues.push({path:`${t}.kind`,message:`a layout node "kind" must be "container", "segment", or "group", or use the terse A-grammar: a bare string, or an object with "seg", "h", or "v" (got ${JSON.stringify(n.kind)})`,line:q(e.source,[`root`])}),GU};function iW(){return{required:!0,json:{type:`object`,propertyNames:{pattern:Jx.source},additionalProperties:{$ref:WU}},parse:(e,t,n,r)=>{let i=r[n];if(!xb(i))return e.issues.push({path:`${t}.${n}`,message:`"rows" must be an object of row name → layout node, got ${Sb(i)}`,line:q(e.source,[...t.split(`.`),n])}),{};let a={};for(let[r,o]of Object.entries(i)){if(!Jx.test(r)){e.issues.push({path:`${t}.${n}.${r}`,message:`row name "${r}" must be an identifier (letters, digits, _; not starting with a digit) — it names the row in the config file and merges by name over the bundled default's rows`,line:q(e.source,[...t.split(`.`),n,r])});continue}a[r]=rW(e,`${t}.${n}.${r}`,o)}return a}}}const aW={noun:`root key`,fields:{rows:iW(),when:Pb(),distribution:ZU()}};function oW(e,t,n){return xb(n)&&`rows`in n?Cb(e,aW,t,n)??{rows:{}}:rW(e,t,n)}const sW={noun:`insert key`,fields:{seg:$U(),id:jB(),before:Pb(),after:Pb()}};function cW(e,t,n){return Array.isArray(t)?t.flatMap((t,r)=>{let i=`insert.${r}`,a=Cb(e,sW,i,t);if(a===null)return[];let o=[`before`,`after`].filter(e=>a[e]!==void 0);if(o.length!==1)return e.issues.push({path:i,message:`an insert cell names exactly one of "before" or "after" (the placement id it sits beside), got ${o.length===0?`neither`:`both`}`,line:q(e.source,i.split(`.`))}),[];if(Ii(a.seg))return e.issues.push({path:`${i}.seg`,message:`an insert cell places a segment, and "${a.seg}" is the bar's own chrome — name a segment instead`,line:q(e.source,[...i.split(`.`),`seg`])}),[];let s=o[0],c=a[s];return Ii(c)?(e.issues.push({path:`${i}.${s}`,message:`an insert cell sits beside a placement, and "${c}" is the bar's own chrome — anchor on a placement id instead`,line:q(e.source,[...i.split(`.`),s])}),[]):[{seg:a.seg,...a.id!==void 0&&{id:a.id},anchor:c,relation:s,by:{file:n,entry:i}}]}):(e.issues.push({path:`insert`,message:`"insert" must be a list of cells like { seg: "name", after: "placement" }, got ${Sb(t)}`,line:q(e.source,[`insert`])}),[])}function lW(){return{required:!0,json:{type:`string`,pattern:Jx.source},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`string`||!Jx.test(i)||i===`closed`){e.issues.push({path:`${t}.${n}`,message:`a group "name" must be an identifier (letters, digits, _; not starting with a digit) and not the reserved "${gi}", got ${J(i)}`,line:q(e.source,[`root`])});return}return i}}}function uW(){return{required:!1,json:{type:`string`,minLength:1},parse:(e,t,n,r)=>{let i=r[n];if(i!==void 0){if(typeof i!=`string`||i===``||i.includes(`/`)){e.issues.push({path:`${t}.${n}`,message:`a group "key" must be a non-empty, slash-free SessionState key, got ${J(i)}`,line:q(e.source,[`root`])});return}return i}}}}function dW(){return{required:!0,json:{type:`string`,pattern:`^[^\\n\\r]*$`},parse:(e,t,n,r)=>{let i=gb(e,t,r,n);if(i!==null){if(/[\n\r]/.test(i)){e.issues.push({path:`${t}.${n}`,message:`${t}.${n}: group label must not contain newlines`,line:q(e.source,[...t.split(`.`),n])});return}return i}}}}const fW={noun:`layout-node key`,fields:{kind:KU(`group`),name:lW(),label:dW(),open:Fb(),direction:Hb(Dy),key:uW(),bg:Pb(),fg:Pb(),when:Pb(),distribution:ZU(),children:YU(Mb(()=>rW))}};function pW(e){return e.key??`groups.`+e.name}function mW(e){let t=ji+e.name;return Si(t,{variable:t,key:pW(e),member:e.name},{kind:`container`,direction:e.direction??`vertical`,children:e.children,...e.distribution!==void 0&&{distribution:e.distribution}},`drop`,e.when)}function hW(e,t,n){e.issues.push({path:t,message:n,line:q(e.source,[`root`])})}function gW(e,t){AN(e,t,ji,`group nodes`);let n=e.groups;if(n.length===0)return;let r=new Set;for(let t of n)r.has(t.name)&&hW(e,t.path,`duplicate group name "${t.name}" — group names must be unique (they name the synthesized state var, action, and toggle segment)`),r.add(t.name);for(let t of n)for(let r of n)t!==r&&t.path.startsWith(`${r.path}.`)&&pW(t)===pW(r)&&hW(e,t.path,`group "${t.name}" shares key "${pW(t)}" with its ancestor group "${r.name}" — a shared key holds ONE open group, so an ancestor and a descendant cannot share one. Sibling accordions share a key; nested groups use distinct keys.`);let i=new Map;for(let t of n){let n=pW(t);if(i.has(n)||i.set(n,gi),t.open===!0){let r=i.get(n);r!==`closed`&&hW(e,t.path,`groups "${r}" and "${t.name}" share key "${n}" and both declare open: true — a shared key holds one open group; pick one`),i.set(n,t.name)}}let a={},o={},s={};for(let e of n){let t=ji+e.name,r=pW(e),c=n.filter(t=>t!==e&&e.path.startsWith(t.path+`.`)).length,l=` `.repeat(c);a[t]=Oi(r,i.get(r)),o[t]=ki(r,e.name),s[t]={template:Ti(t,`${l}${e.label} ▸`,`${l}${e.label} ▾`),...e.bg!==void 0&&{bg:e.bg},...e.fg!==void 0&&{fg:e.fg}}}t.variables={...t.variables??{},...a},t.actions={...t.actions??{},...o},t.segments={...t.segments??{},...s}}const _W=`menu`,vW=`a menu binds its trigger text the way a cycle action binds a display — write {{ menu "applyTheme" "▸" "▾" }} (one per state) or {{ menu "insertHere" "+" }} (one static display for both), with the rare knobs in ONE trailing dict: {{ menu "applyTheme" "▸" "▾" (dict "closeOnPick" true "paged" false "key" "pickers") }} (defaults: closeOnPick false, paged true, no key). The renderer no longer appends ▸/▾ of its own (candybar-settings-ui-aok.4), and the older positional tail ("pageAction" closeOnPick paged "key") was removed — the page cursor is synthesized from the menu's identity`,yW=e=>e.kind===`call`&&e.name===`dict`,bW=e=>e.kind===`literal`&&typeof e.value!=`object`,xW=e=>yi(``,e,2)===void 0;function SW(e){let t=e=>({kind:`issue`,message:e}),[n,...r]=e.argExprs;if(n===void 0)return t(`with no arguments — it takes an apply-action name and its trigger text (e.g. {{ menu "applyTheme" "▸" "▾" }})`);if(n.kind!==`literal`||typeof n.value!=`string`)return t(`whose apply action is not a string literal — a menu's identity is its apply-action name, which must be a literal so it can be gated at load (e.g. {{ menu "applyTheme" "▸" "▾" }})`);let i=r[r.length-1],a=i!==void 0&&yW(i)?i:void 0,o=a===void 0?r:r.slice(0,-1);if(o.some(yW))return t(`whose options (dict …) is not its last argument — ${vW}`);if(i!==void 0&&a===void 0&&!bW(i)&&xW(o.length-1))return t(`whose last argument is neither a literal nor a literal (dict …) — the renderer tells a display from the options dict by the value it evaluates to, so this call could be read as ${o.length} displays or as ${o.length-1} plus options, and both are legal. Make the options explicit as a trailing (dict …) — {{ menu "${n.value}" (printf "…") (printf "…") (dict) }} binds dynamic displays unambiguously — or bind the trigger text as literals`);let s=yi(`whose trigger`,o.length,2);if(s!==void 0)return t(`${s} — ${vW}`);let c=a===void 0?{}:SD(a);if(c===null)return t(`whose options (dict …) is not fully literal — every option value must be a literal so the menu can be gated at load (a dynamic entry like (dict "key" .x) cannot)`);let l;try{l=wM(c)}catch(e){return t(`with invalid options — ${e.message}`)}let u=l.key;if(u!==void 0){let e=kN(u);if(e!==void 0)return t(`whose accordion key "${u}" lands in the reserved "${e}" namespace — a key is collapsed to an identifier (${JSON.stringify(u)} becomes "${vM(u)}"), so it would share one open-state key with the synthesized accordion that owns that namespace instead of grouping only your own menus. Name the group without the reserved prefix`)}return{kind:`ok`,apply:n.value,options:l}}function CW(e){let t=jT({fromString:e=>e});try{return t.parse(e).referencedCalls().filter(e=>e.name===_W).map(SW)}catch{return`parse-failed`}}function wW(e,t){let n=CW(e);return n===`parse-failed`?[]:n.flatMap(e=>e.kind===`ok`?[{key:_M(t,e.apply,e.options.key),member:gM(e.apply)}]:[])}function TW(e){let t=jT({fromString:e=>e});try{return t.parse(e).referencedFunctions().has(_W)}catch{return!1}}function EW(e,t,n){e.issues.push({path:t,message:n,line:q(e.source,[`root`])})}function DW(e,t){AN(e,t,Mi,`{{ menu }} helpers`),AN(e,t,Ni,`{{ menu }} helpers`);for(let[n,r]of Object.entries(t.helpers??{}))TW(r)&&e.issues.push({path:`helpers.${n}`,message:`helper "${n}" uses {{ menu }}, but a menu must live directly in a segment template — its identity is derived from the segment it sits in, which a shared helper does not have. Inline the {{ menu }} call into each segment that needs it.`,line:q(e.source,[`helpers`,n])});let n=t.segments??{};for(let[t,r]of Object.entries(n)){for(let n of[`bg`,`fg`,`when`]){let i=r[n];typeof i==`string`&&TW(i)&&EW(e,`segments.${t}.${n}`,`segment "${t}" uses {{ menu }} in its "${n}" — a menu is only valid in a segment's "template" (its placement is published only there; "${n}" needs a ${n===`when`?`predicate`:`color`}). Move the {{ menu }} into the template.`)}for(let[n,i]of Object.entries(r.partials??{}))TW(i)&&e.issues.push({path:`segments.${t}.partials.${n}`,message:`segments.${t}.partials.${n} uses {{ menu }}, but a menu must live directly in a segment's "template" string — the synthesis pass that wires its state never follows a {{ template }} call into a partial. Inline the {{ menu }} call into the template itself.`,line:q(e.source,[`segments`,t,`partials`,n])})}if(t.root!==void 0)for(let n of Ny($x(t.root)))typeof n.when==`string`&&TW(n.when)&&EW(e,`root`,`a layout node's "when" predicate uses {{ menu }} — a menu is only valid in a segment's "template", not a node predicate. Move it into a segment.`);for(let[t,{template:r}]of Object.entries(n)){if(r===void 0||!TW(r))continue;let n=CW(r);if(n!==`parse-failed`)for(let r of n){let n=r.kind===`issue`?r.message:OW(r.apply);n!==void 0&&EW(e,`segments.${t}`,`segment "${t}" has a {{ menu }} ${n}.`)}}}function OW(e){if(e===``)return`with an empty apply-action name — an empty member aliases the absent-state sentinel ("") so the menu would render open before any click. Name the apply action`;if(gM(e)===`closed`)return`whose apply action is named "${gi}", which collides with the menu's closed-state sentinel and leaves it unopenable. Rename the action`}function kW(e,t){let n={},r={},i=new Map,a=new Set,o=(e,n)=>{let r=`segments.${e}`;a.has(`${r}\0${n}`)||(a.add(`${r}\0${n}`),t.push({path:r,message:n}))};for(let t of lS(e.presets)){let a=new Map,s=new Map;for(let c of Ny(fS(e,t).node)){if(c.kind!==`segment`)continue;let t=e.segments[c.name];if(t===void 0)continue;i.has(c.name)||i.set(c.name,CW(t.template));let l=i.get(c.name);if(l===`parse-failed`)continue;let u=ky(c);for(let[e,t]of l.entries()){if(t.kind===`issue`||OW(t.apply)!==void 0)continue;let{apply:i,options:l}=t,d=gM(i),f=_M(u,i,l.key),p=bM(f),m=l.key===void 0?`ind ${u} ${i}`:`key ${l.key}`,h=[f,p].find(e=>{let t=a.get(e);return t!==void 0&&t!==m});if(h!==void 0){o(c.name,`two {{ menu }} disclosures normalize to the same state key ("${h}") but were declared differently — distinct names that differ only by non-alphanumeric characters (e.g. "a-b" vs "a_b") collapse to one key and would silently share open-state. Rename so they don't collide.`);continue}a.set(f,m),a.set(p,m);let g=yM(f,d),_=`${c.name}\0${e}`,v=s.get(g);if(v!==void 0&&v!==_){o(c.name,`two {{ menu }} disclosures resolve to the same identity ("${g}") — ${l.key===void 0?`a segment cannot contain two menus over the same apply action "${i}"`:`menus sharing key "${l.key}" must have distinct apply actions`}.`);continue}s.set(g,_),r[g]=ki(f,d),n[f]=Oi(f,gi),n[p]={kind:`state`,key:p,default:`0`},r[p]={set:p,int:!0}}}}return{...e,variables:{...e.variables,...n},actions:{...e.actions,...r}}}function AW(e,t,n){return`${e}: "${t}" is an endcaps shape, not a style — endcaps were renamed from "style" to "endcaps"; write ${n}: "${t}"`}const jW={noun:`style key`,fields:{hueShift:Lb(),chromaScale:Lb({min:0}),lightnessScale:Lb(),lightnessShift:Lb()}};function MW(e,t){if(!xb(t))return e.issues.push({path:`styles`,message:`styles must be an object mapping style names to adaptation objects, got ${Sb(t)}`,line:q(e.source,[`styles`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)){e.issues.push({path:`styles.${r}`,message:`style name ${JSON.stringify(r)} must be non-empty and slash-free — a style picker writes the name on the set-state wire, which rejects empty values and splits on "/"`,line:q(e.source,[`styles`,r])});continue}if(hy(r)){e.issues.push({path:`styles.${r}`,message:AW(`styles.${r}`,r,`globals.endcaps`),line:q(e.source,[`styles`,r])});continue}let t=Cb(e,jW,`styles.${r}`,i);t!==null&&(n[r]={...wu,...t})}return n}const NW={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:oW(e,`${t}.${n}`,r[n])},globals:{required:!1,json:sN(),parse:(e,t,n,r)=>r[n]===void 0?void 0:oN(e,`${t}.${n}`,r[n])}}};function PW(e,t){if(!xb(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${Sb(t)}`,line:q(e.source,[`presets`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)||/[\n\r]/.test(r)){e.issues.push({path:`presets.${r}`,message:`preset name ${JSON.stringify(r)} must be non-empty, slash-free, and newline-free — a preset picker writes the name on the set-state wire (which rejects empty values and splits on "/"), and edit mode splices it into a synthesized template string`,line:q(e.source,[`presets`,r])});continue}let t=Cb(e,NW,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function FW(e,t){let n=[...t].map(([e,t])=>[jS(e),t]);return t=>{if(VL(t)||Object.hasOwn(e,t))return{kind:`declared`};let r=n.find(([e])=>e(t));if(r!==void 0)return{kind:`plugin`,definition:r[1]};let i=NS(t);return i!==void 0&&i!==t?{kind:`absent`}:{kind:`missing`}}}function IW(e){return e.kind===`plugin`||e.kind===`missing`}function LW(e,t,n){let r=new Map,i=(e,t)=>{r.set(e,[...r.get(e)??[],t])},a=e=>Xx(e)?Object.values(e.rows):[e],o=[e.root,...Object.values(e.presets).flatMap(e=>e.root===void 0?[]:[e.root])];for(let e of o.flatMap(a))for(let t of Ny(e))t.kind===`segment`&&i(ky(t),{seg:t.name});for(let e of t)i(e.id??e.seg,{seg:e.seg,anchor:e.anchor});let s=new Set,c=e=>n(e.seg).kind===`absent`||e.anchor!==void 0&&s.has(e.anchor);for(let e=!0;e;){e=!1;for(let[t,n]of r)!s.has(t)&&n.every(c)&&(s.add(t),e=!0)}return e=>s.has(e)}function RW(e){let t=0,n=FW(e.segments,new Map),r=e=>{let r=n(e).kind===`declared`;return r||(t+=1),r},i=e=>({...e,children:e.children.flatMap(e=>a(e))}),a=e=>e.kind===`container`?[i(e)]:r(e.name)?[My(e,i)]:[],o=e=>a(e)[0]??zW,s=e=>({...e,rows:Object.fromEntries(Object.entries(e.rows).map(([e,t])=>[e,o(t)]))}),c=e=>Xx(e)?s(e):o(e),l=e=>e.root===void 0?e:{...e,root:c(e.root)},u={...e,root:s(e.root),presets:Object.fromEntries(Object.entries(e.presets).map(([e,t])=>[e,l(t)]))};return t===0?e:u}const zW={kind:`container`,direction:`horizontal`,children:[]};function BW({names:e,helpers:t,actions:n}){let r=(e,t)=>{let i=Object.hasOwn(n,e)?n[e]:void 0;return i===void 0||t.has(e)?[]:(t.add(e),[...[...ES(i)].map(([,e])=>e),...`do`in i?i.do.flatMap(e=>r(e,t)):[]])},i=GS(e=>{let i=rC(e,t)?Object.keys(n):eC(e,t).map(e=>e.name),a=new Set;return[e,...i.flatMap(e=>r(e,a))]}),a=GS(n=>i(n).flatMap(n=>[...XS(n,t).keys()].map(t=>({path:t,reaches:fC(t,e)}))));return{ofTemplate:a,calls:GS(e=>new Set(i(e).flatMap(e=>[...aC(e,t)]))),ofVariable:t=>[...Hy(t).flatMap(([e,t])=>a(t).map(t=>({...t,field:e}))),...By(t)&&`depends_on`in t.cache?t.cache.depends_on.map(t=>({path:t,reaches:e.has(t)?[t]:[],field:`cache.depends_on`})):[]]}}function VW(e,t){switch(t.kind){case`input`:return t.path;case`source`:return e;default:return}}const HW=new WeakMap;function UW(e){let t=HW.get(e);return t===void 0&&(t=BW({names:new Set([...dC(e)].map(([e])=>e)),helpers:e.helpers,actions:e.actions}),HW.set(e,t)),t}function WW(e,t){for(let n of t.reads.calls(e))if(t.clock.has(n))return`calls "${n}"`;for(let{reaches:n}of t.reads.ofTemplate(e))for(let e of n){let n=t.projections.get(e);if(n!==void 0)return`reads "${e}", which ${n}`}return null}const GW=new WeakMap;function KW(e){let t=GW.get(e);return t===void 0&&(t=JW(e),GW.set(e,t)),t}function qW(e){return KW(e).projections}function JW(e){let t=new Map(dC(e)),n=new Map,r={reads:UW(e),projections:n,clock:UA};for(let[e,r]of t){r.kind===`time`&&n.set(e,`is a time variable`);let t=VW(e,r),i=t===void 0?null:uM(t);i&&n.set(e,`reads the draw's "${i}" (${lM[i]})`)}let i=XW(e),a=new Map;for(let e=!0;e;){e=!1;for(let[i,a]of t){if(a.kind!==`template`||n.has(i))continue;let t=WW(a.template,r);t!==null&&(n.set(i,t),e=!0)}for(let t of Xv)if(!a.has(t))for(let n of i[t]){let i=WW(n,r);if(i!==null){a.set(t,i),e=!0;break}}for(let[r,i]of t){let t=VW(r,i);if(t===void 0||n.has(r))continue;let o=fM(t),s=o===void 0?void 0:a.get(o);s!==void 0&&(n.set(r,`reads the ${o} rule, which ${s}`),e=!0)}}return r}function YW(e){return[[[`globals`],e.globals],...Object.entries(e.presets??{}).map(([e,t])=>[[`presets`,e,`globals`],t.globals??{}])].flatMap(([e,t])=>Xv.flatMap(n=>{let r=t[n];return Zv(r)?[{at:[...e,n],slot:n,rule:r}]:[]}))}function XW(e){let t=YW(e),n=e=>t.flatMap(t=>t.slot===e?[t.rule]:[]);return{style:n(`style`),palette:n(`palette`),effect:n(`effect`)}}function ZW(e,t){return WW(e,KW(t))}function QW(e){return t=>WW(t,e)!==null}const $W={nested:e=>`${e} sets "distribution" on a container inside a row — the row's own container places every cell along it, through any { h } or { v } nested in it, so this one would place nothing. Set it on the row (the outermost horizontal container), or, on the bar, on the root, which places the rows.`,bar:e=>`${e} sets "distribution" on a vertical container none of whose children is a segment or a horizontal container — a bar row's hue is placed by the innermost vertical container it stacks through, so it would place nothing. Set it on that container, or on the row whose children are the cells (the horizontal container).`,band:e=>`${e} sets "distribution" on a vertical container in a disclosure body — a body's items are placed along their rows, never by which row they sit on, so it would place nothing. Set it on the row whose children are the items (the horizontal container), or give a group \`direction: 'horizontal'\`.`};function eG(e,t){let n=new Map;for(let e of Object.keys(t)){let t=hM(e),r=n.get(t);r?r.push(e):n.set(t,[e])}for(let[t,r]of n)r.length<2||e.issues.push({path:`presets`,message:`preset names ${r.map(e=>JSON.stringify(e)).join(` and `)} both collapse to the same synthesis identifier "${t}" — edit mode's synthesized reset affordance would silently steal one preset's action for the other. Rename one.`,line:q(e.source,[`presets`])})}function tG(e,t){let n=[[`root`,e.root],...Object.entries(e.presets??{}).map(([e,t])=>[`presets.${e}.root`,t.root])];for(let[e,r]of n)if(r!==void 0){for(let[n,i]of eS(r,e))if(n.kind===`segment`&&n.name===t)return{layoutKey:e,path:i}}}const nG=(e,t,n,r)=>r.kind===`plugin`?`${e} entry "${t}" does not match any segment plugin "${AS(r.definition)}" declares — the plugin loaded from ${r.definition.path} declares: ${rG(AS(r.definition),n)}${iG(t,n)}`:`${e} entry "${t}" does not match any declared segment${iG(t,n)}`;function rG(e,t){let n=Object.keys(t).filter(jS(e)).sort();return n.length===0?`no segments`:n.map(e=>{let n=Object.keys(t[e].settings??{});return`${e} (${n.length===0?`no settings`:`settings: ${n.join(`, `)}`})`}).join(`, `)}function iG(e,t){return kz(e)+PS(e,e=>Object.hasOwn(t,e))}function aG(e,t,n,r){let i=[[[`globals`],t.globals.style,`globals.endcaps`],[[`editGlobals`],t.editGlobals.style,`editGlobals.endcaps`],...Object.entries(t.presets).map(([e,t])=>[[`presets`,e,`globals`],t.globals?.style,`presets.${e}.globals.endcaps`]),...Object.entries(t.themeDefaults).map(([e,t])=>[[`themeDefaults`,e],t.style,`globals.endcaps`])];for(let[n,r,a]of i){if(r===void 0||Zv(r)||Object.prototype.hasOwnProperty.call(t.styles,r))continue;let i=`${n.join(`.`)}.style`;e.issues.push({path:i,message:hy(r)?AW(i,r,a):`${i} "${r}" does not match any declared style (have: ${Object.keys(t.styles).join(`, `)})`,line:q(e.source,[...n,`style`])})}t.globals.preset!==void 0&&!Object.prototype.hasOwnProperty.call(t.presets,t.globals.preset)&&e.issues.push({path:`globals.preset`,message:`globals.preset "${t.globals.preset}" does not match any declared preset (have: ${Object.keys(t.presets).join(`, `)})`,line:q(e.source,[`globals`,`preset`])}),eG(e,t.presets);let a=mC(t);for(let t of a.names)t!==`settings`&&!t.startsWith(cG)||e.issues.push({path:`variables`,message:`variable "${t}" is named under "settings", which a segment's templates read as its placement's own settings (.settings.<name>) — rename it`,line:q(e.source,[`variables`,t])});let o=(t,n,i)=>{WL(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${Li}" ${WL(t)} times — it may appear at most once per layout (it is one disclosure, and one state key holds one open state). Remove all but the placement you want; removing every placement puts the menu at its default position.`,line:i}),GL(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${Li}" under a \`when\` or inside a disclosure body — the menu is visible under every condition, so its placement may not be gated. Move it to an ungated position, or remove it to put the menu at its default position.`,line:i});let a=s(t,`bar`);a!==void 0&&e.issues.push({path:n,message:$W[a](n),line:i});let o=new Map;for(let e of Ny(t)){if(e.kind!==`segment`||r(e.name).kind!==`declared`)continue;let t=ky(e);o.set(t,[...o.get(t)??[],e])}for(let[t,r]of o){if(r.length<2)continue;let a=r[1].name,s=jy(a,new Set(o.keys()));e.issues.push({path:n,message:`${n} has ${r.length} placements with the id "${t}" — an id names one placement (its settings, its menus' open state, and edit mode all address it), so give each its own: { seg: "${a}", id: "${s}" }. A placement without an "id" takes its segment's name.`,line:i})}};function s(e,t){if(e.kind===`segment`||e.distribution===void 0)return;if(t===`nested`)return`nested`;let n=t===`bar`&&e.children.some(e=>e.kind===`segment`||Oy[e.direction]===`cell`);return Oy[e.direction]===`row`&&!n?t:void 0}let c=(e,t)=>e.kind===`segment`?`band`:Oy[e.direction]===`cell`?`nested`:t,l=(e,t)=>e.kind===`container`?e.children.map((e,n)=>[e,Py(t,n)]):e.opens===void 0?[]:[[e.opens.body,Fy(t)]];function*u(e,t){for(let[n,r]of e){let e=s(n,t);e!==void 0&&(yield[e,r]),yield*u(l(n,r),c(n,t))}}let d=new Set,f=(n,i)=>{let o=$x(n),s=Xx(n)?Object.entries(n.rows).map(([e,t])=>[t,`${i}.rows.${e}`]):l(o,i);for(let[t,n]of u(s,c(o,`bar`)))e.issues.push({path:n,message:$W[t](n),line:q(e.source,n.split(`.`))});for(let[o,s]of eS(n,i)){let n=q(e.source,s.split(`.`));if(o.when!==void 0&&(wG(e,`${s}.when`,o.when,a,{line:n}),SG(e,`${s}.when`,o.when,n),CG(e,t,`${s}.when`,o.when,n)),o.kind!==`segment`)continue;if(VL(o.name)){(o.id!==void 0||o.settings!==void 0)&&e.issues.push({path:s,message:`${i} gives the global settings menu anchor "${Li}" an id or settings — the anchor only marks where the menu goes, so place it as the bare name "${Li}"`,line:n});continue}let c=r(o.name);IW(c)&&(d.add(o.name),e.unplaced.push({path:s,message:nG(i,o.name,t.segments,c),line:n})),gG(e,t,o,s,n)}};n.root!==void 0&&f(n.root,`root`);for(let[e,t]of Object.entries(n.presets??{}))t.root!==void 0&&f(t.root,`presets.${e}.root`);let p=new Map([[`root`,Qx(t.root)]]);for(let e of lS(t.presets)){let{node:n,path:r}=fS(t,e);p.set(r,n)}for(let[t,n]of p)o(n,t,q(e.source,t.split(`.`)));for(let[n,i]of p)for(let[a]of Iy(i,n)){if(a.kind!==`segment`||d.has(a.name))continue;let i=r(a.name);IW(i)&&(d.add(a.name),e.inherited.push({name:a.name,path:n,message:nG(`${n} inherits from a config layer below whose`,a.name,t.segments,i),line:q(e.source,n.split(`.`))}))}MG(e,t,a,()=>!0)}const oG=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function sG(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=q(e.source,[`actions`,n,r]);if(!lS(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${lS(t.presets).join(`, `)})`,line:c});return}if(r===`reset`)return;let l=`removeSegment`in o,u=`insertSegment`in o,d=`insertSegmentFrom`in o;if(!l&&!u&&!d){e.issues.push({path:s,message:`actions.${n}: "${i}" is a "presets.<name>.root" target and can only be paired with "removeSegment", "insertSegment", or "insertSegmentFrom" (not "to"/"from"/"cycle"/bounded — those have no meaning as a tree op)`,line:c});return}let f=(r,i)=>{Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})${kz(i)}`,line:c})},p=new Set(Ay(fS(t,a).node)),m=(r,i)=>{!Oz.has(i)||p.has(i)||Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" names no placement${kz(i)}`,line:c})};`removeSegment`in o&&m(`removeSegment`,o.removeSegment),`insertSegment`in o&&f(`insertSegment`,o.insertSegment),(`insertSegment`in o||`insertSegmentFrom`in o)&&m(`anchor`,o.anchor)}const cG=`settings.`;function lG(e,t){return{...e,names:new Set([...e.names,...Object.keys(t).map(e=>cG+e)])}}function uG(e,t,n){let r=e=>`segments.${t}.settings.${e}`,i=(n,i)=>{e.issues.push({path:r(n),message:`${r(n)}: ${i}`,line:q(e.source,[`segments`,t,`settings`,n])})},a=pG(n);for(let{setting:e,message:t}of a)i(e,t);if(!(a.length>0))for(let{setting:e,message:t}of Zy(n,fG(n)))i(e,`the defaults do not stand together: ${t}`)}function dG(e){return pG(e).length>0||Zy(e,fG(e)).length>0}function fG(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default]))}function pG(e){let t=t=>Xy(mG(e,t))?.atLeast;return Object.keys(e).flatMap(n=>{let r=t(n);if(r===void 0)return[];if(r===n||Xy(mG(e,r))===void 0)return[{setting:n,message:`atLeast "${r}" must name another range setting of this segment (its range settings: ${hG(e,n).join(`, `)||`none`})`}];let i=[n];for(let e=r;e!==void 0;e=t(e)){if(e===n)return i.every(e=>n<=e)?[{setting:n,message:`atLeast closes a cycle (${[...i,n].join(` ≥ `)}) — every setting on it could only ever equal the rest`}]:[];if(i.includes(e))return[];i.push(e)}return[]})}function mG(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function hG(e,t){return Object.entries(e).filter(([e,n])=>e!==t&&Xy(n)!==void 0).map(([e])=>e)}function gG(e,t,n,r,i){let a=Object.prototype.hasOwnProperty.call(t.segments,n.name)?t.segments[n.name]:void 0;if(a===void 0)return;let o=Yy(a),s=`${r}: placement "${ky(n)}" of segment "${n.name}"`;for(let[t,a]of Object.entries(n.settings??{})){let c=Object.prototype.hasOwnProperty.call(o,t)?o[t]:void 0,l=c===void 0?`sets "${t}", which segment "${n.name}" does not declare (it has: ${Object.keys(o).join(`, `)})`:Qy(c,a)?void 0:`sets "${t}" to ${JSON.stringify(a)}${c.domain===`theme`?Hv(a):``}, but it must be ${nb(c)}`;l!==void 0&&e.issues.push({path:r,message:`${s} ${l}`,line:i})}let c=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,n.settings?.[e]??t.default]));if(!(!Object.entries(c).every(([e,t])=>Qy(o[e],t))||dG(o)))for(let{message:t}of Zy(o,c))e.issues.push({path:r,message:`${s}: ${t}`,line:i})}function _G(e,t,n,r,i){for(let[a,o]of Hy(n))wG(e,`${t}.${a}`,o,r,{segCtx:i})}function vG(e,t,n,r,i){if(!(!By(n)||!(`depends_on`in n.cache)))for(let a=0;a<n.cache.depends_on.length;a++){let o=n.cache.depends_on[a];if(r.names.has(o))continue;let s=i===void 0?void 0:`${i}.${o}`,c=s!==void 0&&r.names.has(s)?` (segment-local vars are namespaced — write "${s}")`:``;e.issues.push({path:`${t}.cache.depends_on[${a}]`,message:`cache.depends_on references unknown variable "${o}"${c}`,line:q(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}const yG=`it reads the instant a frame is drawn at, which changes every frame, and a cache policy re-runs its source when a stored value changes — re-run it on a period instead: cache: { ttl: "<duration>" }`;function bG(e,t,n,r){if(!By(n))return;let i=n=>q(e.source,[...t.split(`.`),`cache`,n]);if(`key`in n.cache){let a=ZW(n.cache.key,r);a!==null&&e.issues.push({path:`${t}.cache.key`,message:`cache.key ${a}: ${yG}`,line:i(`key`)})}if(`depends_on`in n.cache){let a=qW(r);n.cache.depends_on.forEach((n,r)=>{let o=a.get(n);o!==void 0&&e.issues.push({path:`${t}.cache.depends_on[${r}]`,message:`cache.depends_on names "${n}", which ${o}: ${yG}`,line:i(`depends_on`)})})}}function xG(e,t){let n=new Map(dC(t)),r=UW(t),i=(e,t)=>{for(let{path:n,reaches:r}of e){let e=Xv.find(e=>dM[e]===n||dM[e].startsWith(`${n}.`));if(e!==void 0)return`reads "${dM[e]}", the ${e}'s own name`;for(let e of r){let n=a(e,t);if(n!==null)return n}}return null},a=(e,t)=>{if(t.has(e))return null;t.add(e);let a=n.get(e),o=VW(e,a),s=o===void 0?void 0:fM(o);if(s!==void 0)return`reads "${e}", the ${s}'s own name`;for(let n of r.ofVariable(a)){let r=i([n],t);if(r!==null)return n.field===`template`?`reads "${e}", which ${r}`:`reads "${e}", whose ${n.field} ${r}`}return null};for(let{at:n,rule:a}of YW(t)){let t=i(r.ofTemplate(a),new Set);if(t===null)continue;let o=n.join(`.`);e.issues.push({path:o,message:`${o} ${t}: a rule decides that name, so it cannot read it — read the data the rule is about instead`,line:q(e.source,[...n])})}}function SG(e,t,n,r){try{ON.parse(n)}catch(n){e.issues.push({path:t,message:`Template parse error in ${t}: ${n.message}`,line:r})}}function CG(e,t,n,r,i,a=t.helpers,o){let s=n.slice(n.lastIndexOf(`.`)+1);for(let{name:c,site:l,via:u}of eC(r,a)){if(Object.prototype.hasOwnProperty.call(t.actions,c))continue;let r=l===`options`?` (in a picker, menu, carousel, swatch, swatches or themePreview)`:``;if(u!==null){EG(e,u,`Template references unknown action "${c}"${r}`,TG(u,o));continue}e.issues.push({path:n,message:`${s} references unknown action "${c}"${r}`,line:i})}}function wG(e,t,n,r,i){for(let[a,o]of XS(n,r.helpers)){if(pC(a,r))continue;if(a.startsWith(cG)){let n=o===null?``:` through helper "${o}"`,r=a.slice(9),s=i?.segCtx===void 0||i.settings===void 0?`Template reads ".${a}"${n}, but only a segment's own templates have settings — call it from a segment that declares "${r}"`:`Template reads ".${a}"${n}, but segment "${i.segCtx}" has no setting "${r}" (it has: ${Object.keys(i.settings).join(`, `)}) — declare it under segments.${i.segCtx}.settings`;e.issues.push({path:t,message:s,line:i?.line??q(e.source,t.split(`.`))});continue}if(o!==null){EG(e,o,`Template references unknown variable ".${a}"${Bz(a)}`,TG(o,i?.segCtx===void 0?void 0:{name:i.segCtx,partials:i.partials}));continue}let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,s=n!==void 0&&pC(n,r)?` (segment-local vars are namespaced — write ".${n}")`:Bz(a);e.issues.push({path:t,message:`Template references unknown variable ".${a}"${s}`,line:i?.line??q(e.source,t.split(`.`))})}}function TG(e,t){return t?.partials!==void 0&&Object.hasOwn(t.partials,e)?[`segments`,t.name,`partials`,e]:[`helpers`,e]}function EG(e,t,n,r=[`helpers`,t]){let i=r.join(`.`);e.issues.some(e=>e.path===i&&e.message===n)||e.issues.push({path:i,message:n,line:q(e.source,r)})}function DG(e,t,n,r,i){let a=n.set,o=WM(Mx[r].configKey),s=`${a} takes ${DM(o,i)}`;if(`min`in n&&(o===`bool`||!(`min`in o))){e.issues.push({path:`actions.${t}.min`,message:`actions.${t}: a stepper writes the integers from ${n.min} to ${n.max}, and ${a} is not an integer range; ${s}`,line:q(e.source,[`actions`,t,`min`])});return}let c=AG(n,i);if(c===kG){e.issues.push({path:`actions.${t}.int`,message:`actions.${t}.int: an int cursor writes whatever integer the template binds, and a click outside the ${a} domain would change nothing; ${s}`,line:q(e.source,[`actions`,t,`int`])});return}let l=c.filter(e=>!EM(o,e.value,i));if(l.length!==0){if(a===Mx.style.sessionKey&&(`from`in n&&n.from===`endcaps`||c.every(e=>hy(e.value)))){let r=Mx.endcaps.sessionKey;e.issues.push(`to`in n?{path:`actions.${t}.to`,message:AW(`actions.${t}.to`,n.to,`set: "${r}", to`),line:q(e.source,[`actions`,t,`to`])}:{path:`actions.${t}.set`,message:`actions.${t}.set: "${a}" here writes only endcaps shapes, not styles — endcaps were renamed from "style" to "endcaps"; write set: "${r}"`,line:q(e.source,[`actions`,t,`set`])});return}for(let n of new Set(l.map(e=>e.field))){let r=l.filter(e=>e.field===n).map(e=>JSON.stringify(e.value)),i=r.length<=OG?r.join(`, `):`${r.slice(0,OG).join(`, `)} and ${r.length-OG} more`,o=`actions.${t}.${n}`;e.issues.push({path:o,message:`${o}: ${i} ${r.length===1?`is`:`are`} outside the ${a} domain — a click would write it and nothing would change; ${s}`,line:q(e.source,[`actions`,t,n])})}}}const OG=3,kG=Symbol(`any integer`);function AG(e,t){return`to`in e?[{field:`to`,value:e.to}]:`cycle`in e?e.cycle.map(e=>({field:`cycle`,value:e})):`from`in e?xS(e.from,t).members.map(e=>({field:`from`,value:e})):`min`in e?[{field:`min`,value:String(e.min)},{field:`max`,value:String(e.max)}]:kG}function jG(e,t){return Object.entries(e).filter(([e])=>t(e))}function MG(e,t,n,r){let i=vR(t),a=bS(i);for(let[n,o]of jG(t.actions,r)){let[t,r]=`from`in o?[`from`,o.from]:`insertSegmentFrom`in o?[`insertSegmentFrom`,o.insertSegmentFrom]:[null,null];if(t!==null&&typeof r==`string`&&!a.includes(r)){e.issues.push({path:`actions.${n}.${t}`,message:`actions.${n} ${t}: references ${CS(r,i)}`,line:q(e.source,[`actions`,n,t])});continue}if(!(`set`in o))continue;qee.has(o.set)&&e.issues.push({path:`actions.${n}.set`,message:`actions.${n} sets "${o.set}", which has no session pick — globals.${o.set} is set in the config file only, so a click would change nothing; write it with { persist: "${o.set}", … } instead`,line:q(e.source,[`actions`,n,`set`])});let s=zx.get(o.set);s!==void 0&&DG(e,n,o,s,i)}for(let[n,i]of jG(t.actions,r))`do`in i&&i.do.forEach((r,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,r)?t.actions[r]:void 0,s=o===void 0?`references unknown action "${r}"`:`do`in o?`"${r}" is itself a do action — list its members here instead`:i.do.indexOf(r)===a?a>0&&OS(o)?`"${r}" takes its value from the template (from/int/insertSegmentFrom), so it can only be the first member — only the first is bound the region's display`:void 0:`"${r}" is listed twice — each member fires once per click`;s!==void 0&&e.issues.push({path:`actions.${n}.do`,message:`actions.${n} do: ${s}`,line:q(e.source,[`actions`,n,`do`])})});for(let[n,i]of jG(t.actions,r))if(`run`in i)for(let r of i.refreshes){let i=Object.hasOwn(t.variables,r)?t.variables[r]:void 0;i?.kind!==`source`&&e.issues.push({path:`actions.${n}.refreshes`,message:`actions.${n} refreshes "${r}", which ${i===void 0?`is not declared`:`is a ${i.kind} variable`}: a run refreshes only a declared source (by its full name, <scope>.<plugin>.<source> where the scope is plugins or repo; a plugin names its own sources bare)`,line:q(e.source,[`actions`,n,`refreshes`])})}for(let[n,i]of jG(t.actions,r)){let r=`persist`in i?i.persist:`reset`in i?i.reset:null;if(r===null)continue;let a=`persist`in i?`persist`:`reset`,o=CN(r);if(o===null){let t=dN(r);e.issues.push({path:`actions.${n}.${a}`,message:t===void 0?`actions.${n}: "${r}" is not a config globals field (have: ${fN().join(`, `)}), a "segments.<name>.palette" target, a "presets.<name>.globals.<field>" target, a "themeDefaults.<theme>.<shade|variation|style>" target, or a "presets.<name>.root" target`:`actions.${n}: the globals field "${r}" was removed: ${t}`,line:q(e.source,[`actions`,n,a])});continue}let s=oG.filter(e=>e in i);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:q(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){sG(e,t,n,a,r,o.preset,i);continue}if(o.scope===`preset-globals`&&!lS(t.presets).includes(o.preset)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names preset "${o.preset}" which is not declared (have: ${lS(t.presets).join(`, `)})`,line:q(e.source,[`actions`,n,a])});continue}if(o.scope===`theme-default`&&!e.allowedPalettes.has(o.theme)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names theme "${o.theme}" which is not installed${Hv(o.theme)} (have: ${[...e.allowedPalettes].sort().join(`, `)})`,line:q(e.source,[`actions`,n,a])});continue}if(o.scope===`segment-palette`){if(!Object.prototype.hasOwnProperty.call(t.segments,o.segment)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})${kz(o.segment)}`,line:q(e.source,[`actions`,n,a])});continue}`min`in i&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:q(e.source,[`actions`,n,a])})}}for(let[i,a]of jG(t.variables,r)){_G(e,`variables.${i}`,a,n);let t=zz(i);t!==void 0&&e.issues.push({path:`variables.${i}`,message:t,line:q(e.source,[`variables`,i])})}for(let[i,a]of jG(t.segments,r)){if(a.vars)for(let[t,r]of Object.entries(a.vars))_G(e,`segments.${i}.vars.${t}`,r,n,i);let r=Yy(a);if(uG(e,i,r),a.partials!==void 0)for(let t of Object.keys(a.partials))Object.hasOwn(n.helpers,t)&&e.issues.push({path:`segments.${i}.partials.${t}`,message:`segments.${i}.partials.${t} reuses the name of a global helper (helpers.${t}) — partials and helpers share one define chain, so pick a name no helper already uses`,line:q(e.source,[`segments`,i,`partials`,t])});let o=a.partials===void 0?n.helpers:{...n.helpers,...a.partials},s=lG({...n,helpers:o},r);for(let n of sH){let c=a[n];typeof c==`string`&&(wG(e,`segments.${i}.${n}`,c,s,{segCtx:i,settings:r,partials:a.partials}),CG(e,t,`segments.${i}.${n}`,c,q(e.source,[`segments`,i,n]),o,{name:i,partials:a.partials}))}}for(let[i,a]of jG(t.variables,r))vG(e,`variables.${i}`,a,n),bG(e,`variables.${i}`,a,t);xG(e,t);for(let[i,a]of jG(t.segments,r))if(a.vars)for(let[r,o]of Object.entries(a.vars))vG(e,`segments.${i}.vars.${r}`,o,n,i),bG(e,`segments.${i}.vars.${r}`,o,t)}function NG(e,t,n=()=>!0){let{graph:r,nodeInfo:i}=PG(t),a=new Map,o=[];for(let e of r.keys())a.set(e,0);for(let e of r.keys())if(!(!n(e)||a.get(e)!==0)&&s(e))return;function s(t){a.set(t,1),o.push(t);for(let c of r.get(t)??[]){if(!n(c))continue;let t=a.get(c);if(t===1){let t=o.indexOf(c),n=[...o.slice(t),c],r=n[0],a=i.get(r);return e.issues.push({path:a?.declarationPath??`variables.${r}`,message:`Dependency cycle: ${n.join(` → `)}`,line:q(e.source,a?.linePathParts??[`variables`,r])}),!0}if(t===0&&s(c))return!0}return a.set(t,2),o.pop(),!1}}function PG(e){let t=new Map,n=new Map,r=UW(e),i=(e,i,a)=>{t.set(e,{declarationPath:a.join(`.`),linePathParts:a}),n.set(e,new Set(r.ofVariable(i).flatMap(({reaches:e})=>e)))};for(let[t,n]of Object.entries(e.variables))i(t,n,[`variables`,t]);for(let[t,n]of Object.entries(e.segments))for(let[e,r]of Object.entries(n.vars??{}))i(`${t}.${e}`,r,[`segments`,t,`vars`,e]);return{graph:n,nodeInfo:t}}function FG(e,t,n){let r=new Map([...uC(t)].map(([e,,t])=>[e,t]));for(let[t,i]of r){let a=t.split(`.`);for(let o=1;o<a.length;o++){let s=a.slice(0,o).join(`.`),c=r.get(s);if(c===void 0||!(n.checked(t)||n.checked(s)))continue;let[l,u,d]=n.authored(t)?[t,s,i]:[s,t,c],f=n.authored(t)===n.authored(s)?`Rename one so neither name starts with the other.`:`"${u}" is declared outside this file (the bundled default, a plugin, or a control the bar builds), so rename "${l}".`;e.issues.push({path:d.join(`.`),message:`variable "${t}" is declared under the variable "${s}" — a read of ".${t}" would name both, "${t}" and a field of "${s}". ${f}`,line:q(e.source,[...d])})}}}function IG(e){return{...GG,config:wz(GG.raw,e)}}function LG(e,t,n,r,i){let a=QG(e,t,i,(t,a)=>{let o=YV(JV(t,e,r.scope,r.home),r,{config:n,rendering:r.beneath.rendering},(t,n,r)=>UG(t,n,r,e,i)),s=$V(o,r.beneath.dropped);return{inherited:new Set([...NB(o.config),...a.filter(e=>s(e).length>0)]),layer:{plugins:o,owning:s}}}),{plugins:o,owning:s}=a.layer,c=eH(wz(a.raw,o.config),s,(a.raw.insert??[]).map(e=>e.seg));return{source:t,raw:a.raw,warnings:[...a.warnings,...o.dropped.map(zV)],plugins:{loaded:o.loaded,dropped:o.dropped,reached:c.reached,rendering:o.rendering},config:c.config}}const RG=new WeakMap;function zG(e,t,n,r){let i=JSON.stringify([[...r??[]].sort(),e.map(e=>[e.path,e.scope,VG(e.path)])]),a=RG.get(n)??new Map;RG.set(n,a);let o=JSON.stringify([t.repo,t.checkout?.root??null]),s=a.get(o);if(s?.key===i)return s.layer;let c=YV(e,t,{config:n,rendering:new Map},(e,t,n)=>UG(e,t,n,`<installed plugins>`,r));return a.set(o,{key:i,layer:c}),c}function BG(e,t,n,r){return YV(e,{repo:null,checkout:n,home:r},{config:t,rendering:new Map},(e,t,n)=>UG(e,t,n,`<plugin install>`,void 0)).dropped}function VG(e){try{let t=s.statSync(e);return`${t.ino}:${t.size}:${t.mtimeMs}`}catch(e){return e.code??`unreadable`}}function HG(e,t,n,r,i,a=e=>s.readFileSync(e,`utf-8`),o){let c={repo:i.repo,checkout:i.cwd===null?null:AH(i.cwd),home:e.home},l=TH(e,c.repo),u=zG(l.definitions,c,n,o),d={...u,dropped:[...u.dropped,...l.strays]};r.warned(l.unchecked.map(e=>`Plugin folder could not be listed: ${e.path} — ${e.error}`));let f=d.config,p=[];for(let{path:e,scope:n}of t){let t=p.at(-1)?.plugins,i=LG(e,a(e),p.at(-1)?.config??f,{...c,scope:n,beneath:{dropped:[...d.dropped,...p.flatMap(e=>e.plugins.dropped)],rendering:t?.rendering??d.rendering}},o);r.warned(i.warnings),p.push({...i,path:e})}let m=new Set(p.flatMap(e=>[...e.plugins.reached])),h=e=>m.has(e.path),g=d.dropped.filter(h),_=d.dropped.filter(e=>!h(e));r.warned(g.map(zV));let v=p.at(-1)?.plugins.rendering??d.rendering,y={checkout:c.checkout,roots:l.roots,loaded:d.loaded,dropped:g,unreached:_,reached:m,rendering:v},b=p.at(-1),x=({warnings:e,...t})=>(r.warned(e),t);if(b===void 0)return{layers:p,base:f,installed:y,...x(KG(IG(f),v,`<default>`,o))};try{return{layers:p,base:f,installed:y,...x(KG(b,v,b.path,o,p.slice(0,-1).reverse()))}}catch(e){for(let[e,t]of p.slice(0,-1).entries())KG(t,t.plugins.rendering,t.path,o,p.slice(0,e).reverse());throw e}}function UG(e,t,n,r,i){if(n){KG(WG(e),new Map,r,i);return}let a=jS(t),o=[],s={source:``,issues:o,allowedPalettes:new Set,groups:[],unplaced:[],inherited:[]};if(MG(s,e,mC(e),a),NG(s,e,a),FG(s,e,{checked:a,authored:a}),o.length>0)throw new ab(r,o)}function WG(e){return{config:e,raw:{root:e.root,presets:e.presets},source:``}}const GG={raw:{},source:``,warnings:[],plugins:{loaded:[],dropped:[],reached:new Set,rendering:new Map}};function KG(e,t,n=`<config>`,r=new Set(Gv()),i=[]){let a=FW(e.config.segments,t),o=JG({...e,path:n},i,a),s=(t,s)=>{let c=pS(e.config,t,o.authored);return qG(e,n,r,i,c.config,a,o.dropped,[...c.notices,...s])};try{return s(o.cells,[])}catch(e){if(!(e instanceof ab)||o.cells.length===0)throw e;let t=s([],[]),n=new Set(t.dropped.flatMap(e=>e.issues.map(e=>e.message))),{taken:r,refused:i}=o.cells.reduce((e,t)=>{try{return s([...e.taken,t],[]),{...e,taken:[...e.taken,t]}}catch(r){if(!(r instanceof ab))throw r;let i=r.issues.filter(e=>!n.has(e.message)).map(e=>e.message).join(`; `);return{...e,refused:[...e.refused,mS(t,`${t.relation} "${t.anchor}", but the bar refuses it there: ${i}`)]}}},{taken:[],refused:[]});return s(r,i)}}function qG({raw:e,source:t},n,r,i,a,o,s,c){let l=[],u={source:t,issues:l,allowedPalettes:r,groups:[],unplaced:[],inherited:[]},d=()=>{if(l.length>0)throw new ab(n,[...l,...u.unplaced,...u.inherited],c)};aG(u,a,e,o),NG(u,a),d();let f=XG(n,a.segments,u,o,i,s),p=kW(RW(a),l);d();let m=BR(nR(p)),h=new Set([...uC({variables:e.variables??{},segments:e.segments??{}})].map(([e])=>e));return FG(u,m,{checked:()=>!0,authored:e=>h.has(e)}),d(),{config:m,dropped:f,placed:a,warnings:c}}function JG(e,t,n){let r=[...t].reverse().concat(e),i=LW(e.config,r.flatMap(e=>e.raw.insert??[]),n),a=e=>!i(e.anchor),o=e=>n(e.seg).kind===`declared`,s=e=>IW(n(e.seg)),c=e=>(e.raw.insert??[]).filter(a);return{cells:r.flatMap(e=>c(e).filter(o)),authored:{root:r.some(e=>e.raw.root!==void 0),presets:new Set(r.flatMap(e=>Object.keys(e.raw.presets??{})))},dropped:r.flatMap(t=>{let r=cb(t.source);return(t.raw.insert??[]).filter(s).map(i=>({file:t.path,issue:{path:i.by.entry,message:nG(i.by.entry,i.seg,e.config.segments,n(i.seg)),line:r(i.by.entry.split(`.`))}}))})}}function YG(e){if(e.length>0)throw new sb(e)}function XG(e,t,n,r,i,a){let o=new Map,s=(e,t)=>{o.set(e,[...o.get(e)??[],t])};for(let{file:e,issue:t}of a)s(e,t);for(let t of n.unplaced)s(e,t);for(let{name:a,...o}of n.inherited){let n=i.flatMap(e=>{let t=tG(e.raw,a);return t===void 0?[]:[{layer:e,...t}]})[0];n===void 0?s(e,o):s(n.layer.path,{path:n.path,message:nG(n.layoutKey,a,t,r(a)),line:q(n.layer.source,n.path.split(`.`))})}return[...o].map(([e,t])=>new ob(e,t))}function ZG(e,t,n=new Set(Gv()),r=$G){return QG(e,t,n,()=>({inherited:r,layer:null})).raw}function QG(e,t,n,r){let i=eK(e,t),a=mb(e,t),o=a===null?[]:[a],s=[],c={source:t,issues:s,allowedPalettes:n??new Set(Gv()),groups:[],unplaced:[],inherited:[]};if(!xb(i))throw new ab(e,[{path:``,message:`Config root must be an object, got ${Sb(i)}`}],o);let{inherited:l,layer:u}=r(i.plugins===void 0?[]:rK({...c,issues:[]},i.plugins)??[],xb(i.segments)?Object.keys(i.segments):[]),d=tK(c,i,l,JB(e),e);if(s.length>0)throw new ab(e,s,o);return{raw:d,warnings:o,layer:u}}const $G=new Set;function eK(e,t){try{return Ia.default.parse(t)}catch(t){let n=t;throw new ab(e,[{path:``,message:`JSON5 syntax error: ${n.message}`,line:n.lineNumber,col:n.columnNumber}])}}function tK(e,t,n,r,i){for(let n of Object.keys(t))nK.has(n)||e.issues.push({path:n,message:`Unknown top-level key "${n}". Expected one of: ${[...nK].join(`, `)}`,line:q(e.source,[n])});let a={};return t.globals!==void 0&&(a.globals=aN(e,`globals`,t.globals)),t.variables!==void 0&&(a.variables=Gz(e,`variables`,t.variables)),t.segments!==void 0&&(a.segments=PB(e,t.segments,n)),t.layout!==void 0&&e.issues.push({path:`layout`,message:`"layout" is no longer supported — use "root" with the A-grammar instead.
183
183
  Replace: layout: [["seg1", "seg2"], ["seg3"]]
@@ -188,8 +188,8 @@ Config tooling:
188
188
  `,1)[0]??``}function hY(e,t){if(e.kind!==`ok`)return e;let n=t(e.value);return n===null?I:F(n)}function gY(e){if(e.kind!==`ok`)return e;let t=e.value.trim();return t?F(t):I}const _Y={github:`gh`,gitlab:`glab`};function vY(e){return!e.ok&&e.reason===`spawn-error`&&/ENOENT/i.test(e.error??``)}const yY=/^[A-Za-z]:[\\/]/;function bY(e){let t=e.trim();if(yY.test(t))return null;let n=t.match(/^(?:[^@/]+@)?(\[[^\]]+\]):(.*)$/)??t.match(/^(?:[^@/:]+@)?([^/:]+):(?!\/\/)(.*)$/),r=n?`ssh://${n[1]}/${n[2].replace(/^\/+/,``)}`:t,i;try{i=new URL(r)}catch{return null}return{scheme:i.protocol.replace(/:$/,``),host:i.hostname.toLowerCase(),port:i.port,path:i.pathname.replace(/^\/+/,``).replace(/\/+$/,``)}}function xY(e){return bY(e)?.host||null}function SY(e){let t=xY(e);return t?t===`github.com`||t.endsWith(`.github.com`)?`github`:/(^|\.)gitlab\./.test(t)?`gitlab`:null:null}const CY=[`config`,`--local`,`--get-regexp`,`^remote\\..*\\.url$`];function wY(e){let t=fY(`git config --get-regexp remote url`,e,1);return t.kind===`failed`?t:{kind:`ok`,value:t.kind===`ok`?TY(t.value):[]}}function TY(e){let t=new Map;for(let n of e.split(`
189
189
  `)){let e=n.match(/^remote\.(.+)\.url\s+(\S.*)$/);if(!e)continue;let r=t.get(e[1])??[];r.push(e[2].trim()),t.set(e[1],r)}return[...t].map(([e,t])=>({name:e,urls:t}))}function EY(e){return e.urls.find(e=>jY(e)!==null)??e.urls[0]??null}function DY(e){return e.find(e=>e.name===`origin`)??e[0]??null}function OY(e){let t=DY(e);return t?EY(t):null}function kY(e){let t=DY(e);return t?t.urls.find(e=>SY(e)!==null)??EY(t):null}function AY(e){let t=(bY(e)?.path??e.replace(/[\\/]+$/,``)).split(`/`);return(t[t.length-1]??``).replace(/\.git$/,``)||null}function jY(e){let t=bY(e);if(!t)return null;let n=t.scheme===`https`?{scheme:`https`,port:t.port}:t.scheme===`http`?{scheme:`http`,port:t.port}:t.scheme===`ssh`||t.scheme===`git`?{scheme:`https`,port:``}:null;if(!n||!t.host)return null;let r=t.path.replace(/\.git$/,``);if(!r)return null;let i=n.port?`${t.host}:${n.port}`:t.host;return`${n.scheme}://${i}/${r}`}function MY(e){let t=OY(e);return t===null?null:jY(t)}function NY(e,t,n,r){return t.ok?r(t.stdout):vY(t)||t.reason===`non-zero`&&n.test(t.stderr)?I:L(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??mY(t.stderr)].filter(Boolean).join(`, `)}`,`read`)}function PY(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function FY(e){let t=`detached`,n=I,r=I,i=I,a=0,o=0,s=0,c=0;for(let l of e.split(`
190
190
  `)){if(!l)continue;if(l.startsWith(`# `)){let e=l.slice(2);if(e.startsWith(`branch.oid `)){let t=e.slice(11).trim();n=t===`(initial)`?I:F(t)}else if(e.startsWith(`branch.head `)){let n=e.slice(12).trim();t=n===`(detached)`?`detached`:n}else if(e.startsWith(`branch.upstream `))r=F(e.slice(16).trim());else if(e.startsWith(`branch.ab `)){let t=e.slice(10).trim().match(/^\+(\d+)\s+-(\d+)$/);t&&(i=F({ahead:parseInt(t[1],10),behind:parseInt(t[2],10)}))}continue}let e=l[0];if(e===`1`||e===`2`){let e=l.slice(2,4);e[0]!==`.`&&a++,e[1]!==`.`&&o++}else e===`u`?c++:e===`?`&&s++}let l=`clean`;return c>0?l=`conflicts`:(a||o||s)&&(l=`dirty`),{branch:t,status:l,aheadBehind:i,oid:n,upstream:r,workingTree:{staged:a,unstaged:o,untracked:s,conflicts:c}}}function IY(e){let t;try{t=JSON.parse(e)}catch(e){return L(`gh pr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`,`parse`)}if(!PY(t))return L(`gh pr view: JSON is not an object`,`parse`);let{number:n,state:r,url:i,headRefOid:a}=t;if(typeof n!=`number`||typeof r!=`string`||typeof i!=`string`||typeof a!=`string`)return L(`gh pr view: missing number/state/url/headRefOid`,`parse`);let o=lY(`gh pr view`,sY,r);return o.kind===`ok`?F({number:n,state:o.value,url:i,head:a}):o}function LY(e){let t;try{t=JSON.parse(e)}catch(e){return L(`glab mr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`,`parse`)}if(!PY(t))return L(`glab mr view: JSON is not an object`,`parse`);let n=t.iid,r=t.state,i=t.web_url,a=t.sha;if(typeof n!=`number`||typeof r!=`string`||typeof i!=`string`||typeof a!=`string`)return L(`glab mr view: missing iid/state/web_url/sha`,`parse`);let o=lY(`glab mr view`,cY,r);return o.kind===`ok`?F({number:n,state:o.value,url:i,head:a}):o}function RY(e){try{let t=s.statSync(e);return{key:`${t.dev}:${t.ino}`,stamp:`${t.mtimeMs}:${t.size}`}}catch{return null}}var zY=class{constructor(e){this.launcher=e}isGitRepo(e){return OH(e)}async execGitAsync(e,t){return this.launcher.launch({bin:`git`,args:[...e],cwd:t.cwd,envOverlay:{GIT_OPTIONAL_LOCKS:`0`},timeoutMs:t.timeout,category:`git`})}resolveEffectiveGitDir(e,t){return this.isWorktree(e)?F(e):t&&this.isGitRepo(t)?F(t):this.isGitRepo(e)?F(e):this.findGitRoot(e)}findGitRoot(e){let t=kH(e);return t===void 0?I:F(t)}async getGitInfo(e,t){try{return await this.computeGitInfo(e,t)}catch(e){return L(`git: ${e instanceof Error?e.message:String(e)}`,`read`)}}async computeGitInfo(e,t){let n;if(this.isWorktree(e))n=e;else if(t&&this.isGitRepo(t))n=t;else if(this.isGitRepo(e))n=e;else{let t=this.findGitRoot(e);if(t.kind!==`ok`)return t;n=t.value}let r=await this.getCoreAsync(n);if(r.kind!==`ok`)return r;let i=await this.committedAt(n,r.value.oid),a=await this.getRemotesAsync(n);return F({branch:r.value.branch,status:r.value.status,aheadBehind:r.value.aheadBehind,head:r.value.oid,workingTree:r.value.workingTree,sha:hY(r.value.oid,e=>e.slice(0,7)),upstream:r.value.upstream,committedAt:i,stashCount:this.getStashCount(n),repoName:hY(a,e=>this.repoNameFrom(e,n)),repoUrl:hY(a,MY),operation:this.getOngoingOperation(n)})}resolveGitDir(e){return Oo(PH(e),E.join(e,`.git`))}getOngoingOperation(e){try{let t=this.resolveGitDir(e);return s.existsSync(E.join(t,`MERGE_HEAD`))?F(`MERGE`):s.existsSync(E.join(t,`CHERRY_PICK_HEAD`))?F(`CHERRY-PICK`):s.existsSync(E.join(t,`REVERT_HEAD`))?F(`REVERT`):s.existsSync(E.join(t,`BISECT_LOG`))?F(`BISECT`):s.existsSync(E.join(t,`rebase-merge`))||s.existsSync(E.join(t,`rebase-apply`))?F(`REBASE`):I}catch(e){return L(`git operation probe: ${e instanceof Error?e.message:String(e)}`,`read`)}}async committedAt(e,t){return t.kind===`ok`?this.commitTimestamp(e,t.value):t}commitTimes=new Map;async commitTimestamp(e,t){let n=this.commitTimes.get(t);if(n!==void 0)return this.commitTimes.delete(t),this.commitTimes.set(t,n),n;let r=this.readCommitTimestamp(e,t);for(this.commitTimes.set(t,r),r.then(e=>{e.kind!==`ok`&&this.commitTimes.get(t)===r&&this.commitTimes.delete(t)},()=>{this.commitTimes.get(t)===r&&this.commitTimes.delete(t)});this.commitTimes.size>256;){let e=this.commitTimes.keys().next().value;if(e===void 0)break;this.commitTimes.delete(e)}return r}async readCommitTimestamp(e,t){let n=gY(fY(`git log -1`,await this.execGitAsync([`log`,`-1`,`--format=%ct`,t,`--`],{cwd:e,timeout:2e3}),`absent`));if(n.kind!==`ok`)return n;let r=parseInt(n.value,10);return Number.isNaN(r)?L(`git log -1: unparseable timestamp "${n.value}"`,`parse`):F(r)}resolveCommonGitDir(e){return Oo(FH(e),e)}getStashCount(e){let t=E.join(this.resolveCommonGitDir(this.resolveGitDir(e)),`logs`,`refs`,`stash`),n;try{n=s.readFileSync(t,`utf-8`)}catch(e){return e.code===`ENOENT`?F(0):L(`git stash reflog ${t}: ${e instanceof Error?e.message:String(e)}`,`read`)}let r=n.trim();return F(r?r.split(`
191
- `).length:0)}async getRemotesAsync(e){let t=RY(E.join(this.resolveCommonGitDir(this.resolveGitDir(e)),`config`));if(t===null)return this.readRemotes(e);let{key:n,stamp:r}=t,i=this.remotesByConfig.get(n);if(i!==void 0&&i.stamp===r)return this.remotesByConfig.delete(n),this.remotesByConfig.set(n,i),i.remotes;let a=this.readRemotes(e);for(this.remotesByConfig.set(n,{stamp:r,remotes:a}),a.then(e=>{let t=this.remotesByConfig.get(n);e.kind!==`ok`&&t?.remotes===a&&this.remotesByConfig.delete(n)},()=>{this.remotesByConfig.get(n)?.remotes===a&&this.remotesByConfig.delete(n)});this.remotesByConfig.size>256;){let e=this.remotesByConfig.keys().next().value;if(e===void 0)break;this.remotesByConfig.delete(e)}return a}remotesByConfig=new Map;async readRemotes(e){return wY(await this.execGitAsync(CY,{cwd:e,timeout:2e3}))}repoNameFrom(e,t){let n=OY(e);return(n===null?null:AY(n))??E.basename(t)}async getRepoRemoteUrl(e){let t=await this.getRemotesAsync(e);if(t.kind!==`ok`)return t;let n=kY(t.value);return n===null?I:F(n)}async execForgeAsync(e,t,n){return this.launcher.launch({bin:e,args:[...t],cwd:n.cwd,timeoutMs:n.timeout,category:`forge`})}async resolvePullRequest(e,t){let n=SY(t);return n===`github`?NY(`gh pr view`,await this.execForgeAsync(_Y.github,[`pr`,`view`,`--json`,`number,state,url,headRefOid`],{cwd:e,timeout:5e3}),/no (open )?pull requests? found/i,IY):n===`gitlab`?NY(`glab mr view`,await this.execForgeAsync(_Y.gitlab,[`mr`,`view`,`--output`,`json`],{cwd:e,timeout:5e3}),/no (open )?merge requests? (found|available)/i,LY):I}isWorktree(e){try{let t=E.join(e,`.git`);return!!(s.existsSync(t)&&s.statSync(t).isFile())}catch{return!1}}async getCoreAsync(e){k(`[GIT-EXEC] Running git status --porcelain=v2 in ${e}`);let t=fY(`git status --porcelain=v2 --branch`,await this.execGitAsync([`status`,`--porcelain=v2`,`--branch`],{cwd:e,timeout:2e3}),`failed`);return t.kind===`ok`?F(FY(t.value)):t}};function BY(e){return Math.max(1,e-2)}const VY={cost:0,input:0,output:0,cacheCreation:0,cacheRead:0};function HY(e,t){e.cost+=t.cost,e.input+=t.input,e.output+=t.output,e.cacheCreation+=t.cacheCreation,e.cacheRead+=t.cacheRead}function UY(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function WY(e,t,n){return{[UY(He(e))]:{...VY,cost:t,input:n}}}function GY(e,t){let n=UY(He(t)),r=e.sums[n],i=e.own[n];if(r===void 0&&i===void 0)return I;let a={...VY};return r!==void 0&&HY(a,r),i!==void 0&&HY(a,i),F({cost:a.cost,tokens:a.input+a.output+a.cacheCreation+a.cacheRead,tokenBreakdown:{input:a.input,output:a.output,cacheCreation:a.cacheCreation,cacheRead:a.cacheRead},date:n})}const KY=/<command-name>\s*([^<\s][^<]*?)\s*<\/command-name>/;function qY(e){if(typeof e==`string`)return KY.exec(e)?.[1]}function JY(e){let t=e?.todos;if(!Array.isArray(t))return;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let{content:t,activeForm:r,status:i}=e,a=i===`in_progress`,o=a&&typeof r==`string`?r:t;typeof o==`string`&&n.push({text:o,active:a,done:i===`completed`})}return n}function YY(e){return typeof e==`string`?e:Array.isArray(e)?e.find(e=>typeof e==`object`&&!!e&&e.type===`text`&&typeof e.text==`string`)?.text??``:``}function XY(e,t){let n=e.message?.content,r=[],i=[],a;if(Array.isArray(n))for(let e of n){if(typeof e!=`object`||!e)continue;let t=e;switch(t.type){case`tool_use`:{let{id:e,name:n}=t;if(typeof e!=`string`||typeof n!=`string`)break;r.push({id:e,name:n}),n===`TodoWrite`&&(a=JY(t.input)??a);break}case`tool_result`:{let e=t.tool_use_id;typeof e==`string`&&i.push(e);break}default:break}}let o=t===`prompt`?qY(YY(n)):void 0;if(!(r.length===0&&i.length===0&&a===void 0&&o===void 0))return{...r.length>0&&{started:r},...i.length>0&&{finished:i},...a!==void 0&&{todos:a},...o!==void 0&&{command:o}}}function ZY(e,t){return e===void 0?[ie(t,`.config`,`claude`),ie(t,`.claude`)].filter(e=>u(e)):[e]}async function QY(e){let t=[];for(let n of e){let e=ie(n,`projects`),r=await $Y(Ro(e,{withFileTypes:!0}));for(let n of r??[])n.isDirectory()&&t.push(ie(e,n.name))}return t}async function $Y(e){try{return await e}catch(e){if(e.code===`ENOENT`)return;throw e}}async function eX(e,t,n){let r=[],i=[],a=ie(t,e,`subagents`);try{let t=(await Ro(a)).filter(e=>e.startsWith(`agent-`)&&e.endsWith(`.jsonl`));for(let o of t){let t=ie(a,o);if(n?.has(t)){r.push(t);continue}let s=await Wo(t,void 0,void 0);if(s.kind!==`ok`){k(`Failed to check agent file ${t}`);continue}i=cX(i,t,s.value);let c=aX(Go(s.value,e=>e.subarray(0,Math.max(0,e.indexOf(10))).toString(`utf-8`)));c.kind===`object`&&c.value.sessionId===e&&r.push(t)}}catch(e){k(`Failed to read subagents directory ${a}:`,e)}return{paths:r,longLines:i}}function tX(e){let t=e.message;if((e.type||t?.role||t?.type)!==`user`)return;if(rX(t)===`tool_result`)return`tool-result`;let n=typeof e.origin==`object`&&e.origin!==null?e.origin.kind:void 0;if(n!==void 0&&n!==`human`)return`turn`;let r=YY(t?.content).trimStart();return r.startsWith(`[Request interrupted by user`)?`interrupt`:e.isMeta===!0||e.isCompactSummary===!0||nX.test(r)?`claude-code`:`prompt`}const nX=/^<(?:command-name|local-command-std(?:out|err)|bash-(?:input|stdout|stderr))>/;function rX(e){let t=e?.content;return Array.isArray(t)&&typeof t[0]==`object`&&t[0]?t[0].type:void 0}function iX(e){if(!e.timestamp)return null;let t=e.message,n=t?.usage,r=tX(e);return{timestamp:new Date(e.timestamp),type:typeof e.type==`string`?e.type:void 0,message:t?{id:typeof t.id==`string`?t.id:void 0,model:typeof t.model==`string`?t.model:void 0,usage:n,role:typeof t.role==`string`?t.role:void 0,type:typeof t.type==`string`?t.type:void 0}:void 0,costUSD:typeof e.costUSD==`number`?e.costUSD:void 0,isSidechain:e.isSidechain===!0,userEntry:r,activity:XY(e,r),raw:{model:typeof e.model==`string`?e.model:void 0,message:t?{id:typeof t.id==`string`?t.id:void 0,model:typeof t.model==`string`?t.model:void 0,usage:n}:void 0,requestId:typeof e.requestId==`string`?e.requestId:void 0}}}function aX(e){let t=e.trim();if(!t)return{kind:`blank`};try{let e=JSON.parse(t);return typeof e==`object`&&e&&!Array.isArray(e)?{kind:`object`,value:e}:{kind:`unparsed`,reason:`not a JSON object`}}catch(e){return{kind:`unparsed`,reason:String(e)}}}function oX(e){let t=aX(e);if(t.kind===`unparsed`)return k(`Failed to parse JSONL line: ${t.reason}`),null;if(t.kind===`blank`)return null;try{return iX(t.value)}catch(e){return k(`Failed to project JSONL line: ${e}`),null}}function sX(e){let t=[];for(let n of e.split(`
192
- `)){let e=oX(n);e&&t.push(e)}return t}function cX(e,t,n){return n.longLine===0?e:[...e,{path:t,offset:n.start,bytes:n.longLine}]}function lX(e){return e.map(e=>`transcript long line path=${JSON.stringify(e.path)} offset=${e.offset} bytes=${e.bytes}`)}async function uX(e,t,n,r){let i=[],a=t?.cursor,o=t?.value??n,s;for(;;){let t=await Wo(e,a===void 0?void 0:{offset:a.offset,ino:a.ino},s?.size);if(t.kind!==`ok`)return t;let c=t.value;c.reset&&(o=n),i=cX(c.reset?[]:i,e,c),(s===void 0||c.reset)&&(s={size:c.size,stamp:c.stamp});let l=c.start+c.lines.length;if(o=await r(o,Go(c,e=>sX(e.toString(`utf-8`)))),a={offset:l,stamp:s.stamp,ino:c.ino},c.atEnd)return F({folded:{cursor:a,value:o},longLines:i})}}var dX=class{values=Y.observable.map(void 0,{deep:!1});order=new Set;constructor(e){this.max=e}get(e){return this.values.get(e)}get size(){return this.order.size}touch(e){this.order.delete(e)&&this.order.add(e)}set(e,t){this.order.delete(e),this.order.add(e),(0,Y.runInAction)(()=>{this.values.set(e,t);for(let e of this.order){if(this.order.size<=this.max)break;this.order.delete(e),this.values.delete(e)}})}},fX=class{sessions;constructor(e,t,n,r,i=Pe,a=256){this.empty=e,this.step=t,this.refreshes=n,this.clock=r,this.log=i,this.sessions=new dX(a)}async read(e,t){let n=this.sessions.get(e),r=n?.folded,i=Po(t);if(n?.folded&&i!==``&&n.folded.cursor.stamp===i){let{folded:t,answer:r}=n;return r.kind===`ok`&&r.value===t.value?(this.sessions.touch(e),r):this.store(e,t,{kind:`ok`,value:t.value})}let a=this.clock.monotonic(),o=await uX(t,r,this.empty,(e,t)=>t.reduce(this.step,e));if(this.refreshes.recorded(`sid=${R(e)}`,`request`,o,A(this.clock,a)),o.kind===`failed`)return this.store(e,r,o);if(o.kind===`absent`)return this.store(e,r,{kind:`ok`,value:r?.value??this.empty});let{folded:s,longLines:c}=o.value;for(let e of lX(c))this.log(`info`,e);return this.store(e,s,{kind:`ok`,value:s.value})}answer(e){return this.sessions.get(e)?.answer??Ao(`unread`)}store(e,t,n){return this.sessions.set(e,{folded:t,answer:n}),n}};function pX(e,t){let n=t.message?.usage;return!n?.input_tokens||t.isSidechain===!0?e:n.input_tokens+(n.cache_read_input_tokens||0)+(n.cache_creation_input_tokens||0)}var mX=class{fold;constructor(e){let t=e.logger??Pe;this.fold=new fX(void 0,pX,(e.ledger??new Dj(t)).declare({name:`context`,scope:`session`,refresh:[`request`]}),e.clock,t)}async refresh(e,t){return hX(await this.fold.read(e,t))}tokensOf(e){let t=this.fold.answer(e);return t.kind===`pending`?t:hX(t)}};function hX(e){return e.kind===`failed`?L(`context transcript: ${e.reason}`,e.failedAt):e.value===void 0?(k(`No main chain entries with usage data found`),I):F(e.value)}function gX(e,t){let n=Math.min(100,Math.max(0,Math.round(e/t*100)));return{percentage:n,contextLeftPercentage:Math.max(0,100-n)}}function _X(e){let t=e.context_window;if(!t?.current_usage)return null;let n=t.current_usage,r=t.context_window_size,i=(n.input_tokens||0)+(n.cache_creation_input_tokens||0)+(n.cache_read_input_tokens||0),a=gX(i,r);return{totalTokens:i,maxTokens:r,percentage:t.used_percentage==null?a.percentage:Math.round(t.used_percentage),contextLeftPercentage:t.remaining_percentage==null?a.contextLeftPercentage:Math.round(t.remaining_percentage)}}function vX(e,t){let n=_X(t);if(n!==null)return F(n);if(e.kind!==`ok`)return e;let r=yX(t);return F({totalTokens:e.value,maxTokens:r,...gX(e.value,r)})}function yX(e){return e.context_window?.context_window_size??2e5}const bX={messageCount:0,nonPrompts:0,recent:[]},xX=new Set([`turn`,`interrupt`,`claude-code`]);function SX(e,t){if(t.isSidechain)return e;let n=[...e.recent,t];return{messageCount:e.messageCount+ +(t.userEntry===`prompt`),nonPrompts:e.nonPrompts+ +!!xX.has(t.userEntry),recent:n.length>20?n.slice(-20):n}}function CX(e){let t=null,n=null;for(let r of e){let e=r.type||r.message?.role||r.message?.type;if(r.userEntry===`prompt`||r.userEntry===`turn`)t=r.timestamp;else if(e===`assistant`&&t){let e=(r.timestamp.getTime()-t.getTime())/1e3;e>.1&&e<300&&(n=e)}}return n}var wX=class{fold;constructor(e){let t=e.logger??Pe;this.fold=new fX(bX,SX,(e.ledger??new Dj(t)).declare({name:`metrics`,scope:`session`,refresh:[`request`]}),e.clock,t)}async refresh(e,t){return k(`Getting metrics from the transcript for session: ${e}`),TX(e,await this.fold.read(e,t))}foldOf(e){let t=this.fold.answer(e);return t.kind===`pending`?t:TX(e,t)}};function TX(e,t){return t.kind===`failed`?L(`metrics (${e}): ${t.reason}`,t.failedAt):F({lastResponseTime:CX(t.value.recent),messageCount:t.value.messageCount,nonPrompts:t.value.nonPrompts})}function EX(e,t){let n=t.cost;return n?e.kind===`ok`?F({...e.value,responseTime:n.total_api_duration_ms/1e3,sessionDuration:n.total_duration_ms/1e3,linesAdded:n.total_lines_added,linesRemoved:n.total_lines_removed}):e:I}function DX(e,t){return e.kind===`ok`?F({cost:t.cost?.total_cost_usd??e.value.calculatedCost,tokens:e.value.tokens}):e}function OX(e,t,n){return Ht({dir:e.project_dir,env:n===void 0?[]:[[Yo,n]],program:`claude`,args:[`--resume`,t,...e.added_dirs.flatMap(e=>[`--add-dir`,e])]})}const kX=[`session`,`today`,`context`,`metrics`,`activity`,`cache`,`speed`,`autocompact`];var AX=class{bySession=Y.observable.map(void 0,{deep:!1});of(e,t){let n=this.bySession.get(e)?.get(t);return n===void 0?void 0:L(n,`read`)}refreshed(e,t,n){let r=this.bySession.get(e);if(n===null&&r?.has(t)!==!0)return;let i=new Map(r);n===null?i.delete(t):i.set(t,n),(0,Y.runInAction)(()=>{i.size===0?this.bySession.delete(e):this.bySession.set(e,i)})}};function jX(e,t){return{endcaps:e.endcaps,separator:e.separator,colorCompatibility:e.colorCompatibility,wrap:e.autoWrap,padding:e.padding,width:t}}function MX(e){return{...Object.fromEntries(Ex.map(t=>[t,{effective:e[t]}])),preset:{effective:e.preset,customized:e.presetCustomized,bundled:gK(e.preset)}}}const NX={prNumber:!0,prState:!0,prUrl:!0,prError:!0,prEarlier:!0};function PX(e){if(jo(e))return`pending`;let{prState:t,prError:n,prEarlier:r}=e??{};return jo(t)?`pending`:t===void 0?n===void 0?r===void 0?`-`:`earlier-${String(r)}`:`failed`:t}const FX=10*1e3;function IX(e,t){if(!(t<60))return e*3600/t}function LX(e,t,n,r){let i=r-t;if(i<50||i>FX)return;let a=n-e;if(!(a<=0))return a*1e3/i}function RX(e){let{prev:t,cur:n}=e;if(t===void 0)return;let r=LX(t.input,t.atMs,n.input,n.atMs),i=LX(t.output,t.atMs,n.output,n.atMs),a=LX(t.total,t.atMs,n.total,n.atMs);if(!(r===void 0&&i===void 0&&a===void 0))return{...r!==void 0&&{input:r},...i!==void 0&&{output:i},...a!==void 0&&{total:a}}}function zX(e){let{samples:t}=e,n=[];for(let e=1;e<t.length;e++){let r=t[e-1],i=t[e],a=i.atMs-r.atMs;if(a<50||a>FX)continue;let o=LX(r.total,r.atMs,i.total,i.atMs);n.push(o??0)}if(n.length!==0)return n.join(`,`)}function BX(e){return BY(e.termCols??120)}function VX(e,t){return Qo(Zo(e.claudeConfigDir,t))}function HX(e){return[...e].map(([e,t])=>`${e}:${t===null?`…`:`${t}ms`}`).join(`,`)||`-`}async function UX(e,t,n){let{hookData:r,deps:i,hints:a}=e,o=r.session_id,s=i.usageStore.request(o,r.transcript_path),c=async(e,t)=>{let r=i.clock.monotonic();n.set(e,null);let a=null;try{await t()}catch(t){i.log(`error`,`${e} lane threw: ${x(t)}`),a=`${e}: ${String(t)}`}n.set(e,A(i.clock,r)),i.faults.refreshed(o,e,a)};await Promise.all([c(`session`,()=>s.usage()),c(`today`,()=>s.today()),c(`context`,()=>i.contextProvider.refresh(o,r.transcript_path)),c(`metrics`,()=>i.metricsProvider.refresh(o,r.transcript_path)),c(`activity`,()=>i.activityProvider.getActivityInfo(o,r)),c(`cache`,()=>i.cacheExpiry.refresh(o,r.transcript_path)),c(`speed`,()=>s.speed(He(t).getTime())),c(`autocompact`,async()=>i.autoCompact.window(VX(a,i.home)))])}function WX(e,t){let n=bj(e);return{git:n,tmux:n,hostName:n,hostUser:n,today:n,sources:new Map(t.map(e=>[e,n]))}}function GX({cwd:e,hookData:t}){return[e??t.workspace?.current_dir,t.workspace?.project_dir]}function KX(e,t,n,r){let i=n.hints.tmux??null,a=[],o=(e,t)=>{try{return t()}catch(t){return a.push(`${e}: ${x(t)}`),bj(L(`${e}: ${String(t)}`,`read`))}};return{lanes:{git:o(`git`,()=>e.gitProvider.declare(t,...GX(n))),tmux:i===null?bj(I):o(`tmux`,()=>e.tmuxService.declare(t,i)),hostName:o(`host.name`,()=>e.hostService.declareName(t)),hostUser:o(`host.user`,()=>e.hostService.declareUser(t)),today:o(`today`,()=>e.usageStore.declareToday(t,n.hints.claudeConfigDir)),sources:new Map([...r].map(([r,i])=>[r,o(r,()=>e.managedStorage.declare(t,i,n.sessionId))]))},faults:a}}function qX(e,t){let{hookData:n,deps:r}=e,i=n.session_id,a=(e,t)=>{let n=r.faults.of(i,e);if(n!==void 0)return n;try{return t()}catch(t){return r.log(`error`,`${e} read threw: ${x(t)}`),L(`${e}: ${String(t)}`,`read`)}};return{lanes:{git:t.git.current(),usage:a(`session`,()=>r.usageStore.usageOf(i)),context:a(`context`,()=>r.contextProvider.tokensOf(i)),metrics:a(`metrics`,()=>r.metricsProvider.foldOf(i)),activity:a(`activity`,()=>r.activityProvider.activityOf(i)),tmuxSession:t.tmux.current(),hostName:t.hostName.current(),hostUser:t.hostUser.current(),cache:a(`cache`,()=>r.cacheExpiry.expiryOf(i)),speed:a(`speed`,()=>r.usageStore.speedOf(i)),autoCompact:a(`autocompact`,()=>r.autoCompact.stored(VX(e.hints,r.home))),sources:new Map([...t.sources].map(([e,t])=>[e,t.current()]))},today:a(`today`,()=>JX(t.today,r.usageStore,i)),faults:kX.flatMap(e=>{let t=r.faults.of(i,e);return t===void 0?[]:[{kind:`lane`,lane:e,reason:t.reason}]})}}function JX(e,t,n){let r=e.current();if(r.kind!==`ok`)return r;let i=t.daysOutside(n,r.value.roots);return i.kind===`failed`?i:F({sums:r.value.sums,own:i.kind===`ok`?i.value:{}})}function YX({builtins:e,sources:t}){return[e.git,e.tmux,e.hostName,e.hostUser,...Object.values(t)].some(e=>e.kind===`pending`&&e.why===`unread`)}async function XX(e,t,n,r,i){await UX(e,t,n);try{await(0,Y.when)(()=>!YX(r()),{signal:i})}catch(e){if(!i.aborted)throw e}}function ZX(...e){let t=e.find(e=>e.kind===`pending`);return t?.kind===`pending`?Ao(t.why):void 0}const QX=e=>{switch(e.kind){case`pending`:return e;case`absent`:return I;case`ok`:return F(e.value);case`failed`:return L(e.reason,e.failedAt)}};function $X(e,t,n){let{hookData:r,hints:i}=t,{effective:a,configFacts:o}=n,{configPath:s,...c}=o,l=e.builtins,u={usage:DX(QX(l.session),r),context:vX(QX(l.context),r),metrics:EX(QX(l.metrics),r),activity:QX(l.activity),cache:QX(l.cache),speed:QX(l.speed),autoCompact:QX(l.autocompact),git:QX(l.git),pr:QX(l.pr),tmux:QX(l.tmux),hostName:QX(l.hostName),hostUser:QX(l.hostUser)},d=(e,t)=>{switch(e.kind){case`pending`:return Ao(e.why);case`failed`:case`absent`:return;case`ok`:return t(e.value)}},f=e=>e.kind===`ok`?e.value:void 0,p=i.tmux??null,m=u.git.kind===`pending`?Ao(u.git.why):u.git.kind===`ok`?dZ(u.git.value,u.pr,Ao):void 0,h=u.tmux.kind===`pending`?Ao(u.tmux.why):f(u.tmux)?.session,g=u.hostName.kind===`pending`?Ao(u.hostName.why):f(u.hostName),_=u.hostUser.kind===`pending`?Ao(u.hostUser.why):f(u.hostUser),v=ZX(u.context)??oZ(u.autoCompact,f(u.context)?.maxTokens),y=r.rate_limits?.five_hour,b=r.rate_limits?.seven_day,x=ZX(u.usage,u.metrics)??rZ(f(u.usage)?.cost,f(u.metrics)?.sessionDuration),S=d(u.speed,iZ),C=d(u.usage,e=>lZ({cost:e.cost,tokens:e.tokens})),w=d(u.metrics,e=>lZ({lastResponseTime:e.lastResponseTime,responseTime:e.responseTime,sessionDuration:e.sessionDuration,messageCount:e.messageCount,nonPrompts:e.nonPrompts,linesAdded:e.linesAdded,linesRemoved:e.linesRemoved})),T=d(u.activity,sZ),ee=d(u.context,e=>({totalTokens:e.totalTokens,contextLeft:e.contextLeftPercentage})),te=d(u.cache,e=>({expiresAt:e})),E=uZ(t.home),ne=r.workspace?{...r.workspace,current_dir:uZ(r.workspace.current_dir)??``,project_dir:uZ(r.workspace.project_dir)??``,added_dirs:(r.workspace.added_dirs??[]).map(e=>uZ(e)??e)}:r.workspace,D=r.session_id;return{...r,...ne!==void 0&&{workspace:ne},...E!==void 0&&{home:E},...m!==void 0&&{git:m},...r.location!==void 0&&{location:{...r.location,main:uZ(r.location.main)??``}},...p!==null&&{tmux:{pane:p.pane,...h!==void 0&&{session:h}}},host:{...g!==void 0&&{name:g},..._!==void 0&&{user:_},...i.ssh!==void 0&&{ssh:i.ssh}},...MX(a),history:n.history,navigation:{back:n.back},term:{cols:BX(i)},...c,...s!==null&&{configPath:s},resumeCommand:OX(ne,D,i.claudeConfigDir),...C!==void 0&&{session:C},...x!==void 0&&{burn:x},...S!==void 0&&{speed:S},...y!==void 0&&{block:{nativeUtilization:y.used_percentage,resetsAt:y.resets_at}},...b!==void 0&&{weekly:{percentage:b.used_percentage,resetsAt:b.resets_at}},...te!==void 0&&{cache:te},...ee!==void 0&&{context:ee},...w!==void 0&&{metrics:w},...T!==void 0&&{activity:T},...v!==void 0&&{autocompact:v},...nZ(n.sources,t=>{let n=QX(eZ(e,t));return n.kind===`pending`?Ao(n.why):n})}}const eZ=(e,t)=>e.sources[t]??Ao(`unread`);function tZ(e,t){let n=e.map(e=>[e,eZ(t,e)]);return{sources:String(n.length),sourcesPending:n.flatMap(([e,t])=>t.kind===`pending`?[`${e}:${t.why}`]:[]).join(`,`)||`-`}}function nZ(e,t){let n=Object.fromEntries(kS.map(e=>[e,{}]));for(let r of e){let e=r.split(`.`),i=e.pop(),a=e.reduce((e,t)=>e[t]??={},n);a[i]=t(r)}return n}function rZ(e,t){let n=e!=null&&t!=null?IX(e,t):void 0;return n===void 0?void 0:{costPerHour:n}}function iZ(e){let t=RX(e),n=zX(e);return t!==void 0||n!==void 0?{...t,...n!==void 0&&{history:n}}:void 0}function aZ(e,t){if(e.kind===`pending`)return Ao(e.why);if(e.kind!==`ok`)return;let n=GY(e.value,t);return n.kind===`ok`?{cost:n.value.cost,tokens:n.value.tokens}:void 0}function oZ(e,t){switch(e.kind){case`pending`:return Ao(e.why);case`absent`:return;case`failed`:return{error:e.reason};case`ok`:return yI(e.value,t)}}function sZ(e){let t=e.todos.findIndex(e=>e.active),n=e.todos.length===0?void 0:{total:e.todos.length,completed:e.todos.filter(e=>e.done).length,...t>=0&&{position:t+1,active:e.todos[t].text}},r=cZ(e.running),i=cZ(e.done),a=r===void 0&&i===void 0?void 0:{...r!==void 0&&{running:r},...i!==void 0&&{done:i}};if(!(e.command===null&&n===void 0&&a===void 0))return{...e.command!==null&&{command:e.command},...n!==void 0&&{todo:n},...a!==void 0&&{tool:a}}}function cZ(e){return e.length===0?void 0:e.map(e=>`${e.name}:${e.count}`).join(`,`)}function lZ(e){let t={},n=!1;for(let r of Object.keys(e)){let i=e[r];i!=null&&(t[r]=i,n=!0)}return n?t:void 0}function uZ(e){return e===void 0||e.length===0||E.sep!==`\\`?e:e.replace(/\\/g,`/`)}function dZ(e,t,n){let r=e=>e.kind===`ok`?e.value:void 0,i=r(e.aheadBehind),a=r(e.sha),o=r(e.operation),s=r(e.committedAt),c=r(e.stashCount),l=r(e.upstream),u=r(aY(e.upstream,e.aheadBehind)),d=r(e.repoName),f=r(e.repoUrl),p=t.kind===`pending`?t:oY(t,e.head),m={};switch(p.kind){case`pending`:{let e=n(p.why);m={prNumber:e,prState:e,prUrl:e,prError:e,prEarlier:e};break}case`ok`:m={prNumber:p.value.number,prState:p.value.state,prUrl:p.value.url};break;case`failed`:m={prError:p.reason};break;case`earlier`:m={prEarlier:p.value.state};break;case`absent`:break}return{branch:e.branch,status:e.status,...i!==void 0&&{ahead:i.ahead,behind:i.behind},staged:e.workingTree.staged,unstaged:e.workingTree.unstaged,untracked:e.workingTree.untracked,conflicts:e.workingTree.conflicts,...a!==void 0&&{sha:a},...o!==void 0&&{operation:o},...s!==void 0&&{committedAt:s},...c!==void 0&&{stash:c},...l!==void 0&&{upstream:l},...u!==void 0&&{tracking:u},...d!==void 0&&{repoName:d},...f!==void 0&&{repoUrl:f},...m}}const fZ=(e,t)=>[...e].some(e=>e===t||e.startsWith(`${t}.`)),pZ={pullRequests:e=>Object.keys(NX).some(t=>e.has(`git.${t}`)),rateLimits:e=>fZ(e,`block`)||fZ(e,`weekly`)};function mZ(e,t){let n=e.segments[t];return n?[...[n.template,n.when,n.bg,n.fg].flatMap(e=>e?[e]:[]),...Object.values(n.partials??{})]:[]}function hZ(e,t){let n=UW(e),r=new Map(dC(e)),i=t.flatMap(e=>n.ofTemplate(e).flatMap(({reaches:e})=>e)),a=new Set,o=new Set;for(;i.length>0;){let e=i.pop();if(a.has(e))continue;a.add(e);let t=r.get(e),s=VW(e,t);s!==void 0&&o.add(s);for(let{reaches:e}of n.ofVariable(t))i.push(...e)}return o}function gZ(e,t){let n=new Map;for(let r of Ny(fS(e,t).node)){if(r.kind!==`segment`)continue;let e=n.get(r.name)??[];r.when&&e.push(r.when),n.set(r.name,e)}let r=[...n.keys()].filter(t=>Wy(e.segments[t])===`fail`),i=new Map(r.map(t=>[t,hZ(e,[...mZ(e,t),...n.get(t)])])),a=e=>r.filter(t=>pZ[e](i.get(t)));return{pullRequests:a(`pullRequests`),rateLimits:a(`rateLimits`)}}
191
+ `).length:0)}async getRemotesAsync(e){let t=RY(E.join(this.resolveCommonGitDir(this.resolveGitDir(e)),`config`));if(t===null)return this.readRemotes(e);let{key:n,stamp:r}=t,i=this.remotesByConfig.get(n);if(i!==void 0&&i.stamp===r)return this.remotesByConfig.delete(n),this.remotesByConfig.set(n,i),i.remotes;let a=this.readRemotes(e);for(this.remotesByConfig.set(n,{stamp:r,remotes:a}),a.then(e=>{let t=this.remotesByConfig.get(n);e.kind!==`ok`&&t?.remotes===a&&this.remotesByConfig.delete(n)},()=>{this.remotesByConfig.get(n)?.remotes===a&&this.remotesByConfig.delete(n)});this.remotesByConfig.size>256;){let e=this.remotesByConfig.keys().next().value;if(e===void 0)break;this.remotesByConfig.delete(e)}return a}remotesByConfig=new Map;async readRemotes(e){return wY(await this.execGitAsync(CY,{cwd:e,timeout:2e3}))}repoNameFrom(e,t){let n=OY(e);return(n===null?null:AY(n))??E.basename(t)}async getRepoRemoteUrl(e){let t=await this.getRemotesAsync(e);if(t.kind!==`ok`)return t;let n=kY(t.value);return n===null?I:F(n)}async execForgeAsync(e,t,n){return this.launcher.launch({bin:e,args:[...t],cwd:n.cwd,timeoutMs:n.timeout,category:`forge`})}async resolvePullRequest(e,t){let n=SY(t);return n===`github`?NY(`gh pr view`,await this.execForgeAsync(_Y.github,[`pr`,`view`,`--json`,`number,state,url,headRefOid`],{cwd:e,timeout:5e3}),/no (open )?pull requests? found/i,IY):n===`gitlab`?NY(`glab mr view`,await this.execForgeAsync(_Y.gitlab,[`mr`,`view`,`--output`,`json`],{cwd:e,timeout:5e3}),/no (open )?merge requests? (found|available)/i,LY):I}isWorktree(e){try{let t=E.join(e,`.git`);return!!(s.existsSync(t)&&s.statSync(t).isFile())}catch{return!1}}async getCoreAsync(e){A(`[GIT-EXEC] Running git status --porcelain=v2 in ${e}`);let t=fY(`git status --porcelain=v2 --branch`,await this.execGitAsync([`status`,`--porcelain=v2`,`--branch`],{cwd:e,timeout:2e3}),`failed`);return t.kind===`ok`?F(FY(t.value)):t}};function BY(e){return Math.max(1,e-2)}const VY={cost:0,input:0,output:0,cacheCreation:0,cacheRead:0};function HY(e,t){e.cost+=t.cost,e.input+=t.input,e.output+=t.output,e.cacheCreation+=t.cacheCreation,e.cacheRead+=t.cacheRead}function UY(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function WY(e,t,n){return{[UY(He(e))]:{...VY,cost:t,input:n}}}function GY(e,t){let n=UY(He(t)),r=e.sums[n],i=e.own[n];if(r===void 0&&i===void 0)return I;let a={...VY};return r!==void 0&&HY(a,r),i!==void 0&&HY(a,i),F({cost:a.cost,tokens:a.input+a.output+a.cacheCreation+a.cacheRead,tokenBreakdown:{input:a.input,output:a.output,cacheCreation:a.cacheCreation,cacheRead:a.cacheRead},date:n})}const KY=/<command-name>\s*([^<\s][^<]*?)\s*<\/command-name>/;function qY(e){if(typeof e==`string`)return KY.exec(e)?.[1]}function JY(e){let t=e?.todos;if(!Array.isArray(t))return;let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let{content:t,activeForm:r,status:i}=e,a=i===`in_progress`,o=a&&typeof r==`string`?r:t;typeof o==`string`&&n.push({text:o,active:a,done:i===`completed`})}return n}function YY(e){return typeof e==`string`?e:Array.isArray(e)?e.find(e=>typeof e==`object`&&!!e&&e.type===`text`&&typeof e.text==`string`)?.text??``:``}function XY(e,t){let n=e.message?.content,r=[],i=[],a;if(Array.isArray(n))for(let e of n){if(typeof e!=`object`||!e)continue;let t=e;switch(t.type){case`tool_use`:{let{id:e,name:n}=t;if(typeof e!=`string`||typeof n!=`string`)break;r.push({id:e,name:n}),n===`TodoWrite`&&(a=JY(t.input)??a);break}case`tool_result`:{let e=t.tool_use_id;typeof e==`string`&&i.push(e);break}default:break}}let o=t===`prompt`?qY(YY(n)):void 0;if(!(r.length===0&&i.length===0&&a===void 0&&o===void 0))return{...r.length>0&&{started:r},...i.length>0&&{finished:i},...a!==void 0&&{todos:a},...o!==void 0&&{command:o}}}function ZY(e,t){return e===void 0?[re(t,`.config`,`claude`),re(t,`.claude`)].filter(e=>u(e)):[e]}async function QY(e){let t=[];for(let n of e){let e=re(n,`projects`),r=await $Y(Ro(e,{withFileTypes:!0}));for(let n of r??[])n.isDirectory()&&t.push(re(e,n.name))}return t}async function $Y(e){try{return await e}catch(e){if(e.code===`ENOENT`)return;throw e}}async function eX(e,t,n){let r=[],i=[],a=re(t,e,`subagents`);try{let t=(await Ro(a)).filter(e=>e.startsWith(`agent-`)&&e.endsWith(`.jsonl`));for(let o of t){let t=re(a,o);if(n?.has(t)){r.push(t);continue}let s=await Wo(t,void 0,void 0);if(s.kind!==`ok`){A(`Failed to check agent file ${t}`);continue}i=cX(i,t,s.value);let c=aX(Go(s.value,e=>e.subarray(0,Math.max(0,e.indexOf(10))).toString(`utf-8`)));c.kind===`object`&&c.value.sessionId===e&&r.push(t)}}catch(e){A(`Failed to read subagents directory ${a}:`,e)}return{paths:r,longLines:i}}function tX(e){let t=e.message;if((e.type||t?.role||t?.type)!==`user`)return;if(rX(t)===`tool_result`)return`tool-result`;let n=typeof e.origin==`object`&&e.origin!==null?e.origin.kind:void 0;if(n!==void 0&&n!==`human`)return`turn`;let r=YY(t?.content).trimStart();return r.startsWith(`[Request interrupted by user`)?`interrupt`:e.isMeta===!0||e.isCompactSummary===!0||nX.test(r)?`claude-code`:`prompt`}const nX=/^<(?:command-name|local-command-std(?:out|err)|bash-(?:input|stdout|stderr))>/;function rX(e){let t=e?.content;return Array.isArray(t)&&typeof t[0]==`object`&&t[0]?t[0].type:void 0}function iX(e){if(!e.timestamp)return null;let t=e.message,n=t?.usage,r=tX(e);return{timestamp:new Date(e.timestamp),type:typeof e.type==`string`?e.type:void 0,message:t?{id:typeof t.id==`string`?t.id:void 0,model:typeof t.model==`string`?t.model:void 0,usage:n,role:typeof t.role==`string`?t.role:void 0,type:typeof t.type==`string`?t.type:void 0}:void 0,costUSD:typeof e.costUSD==`number`?e.costUSD:void 0,isSidechain:e.isSidechain===!0,userEntry:r,activity:XY(e,r),raw:{model:typeof e.model==`string`?e.model:void 0,message:t?{id:typeof t.id==`string`?t.id:void 0,model:typeof t.model==`string`?t.model:void 0,usage:n}:void 0,requestId:typeof e.requestId==`string`?e.requestId:void 0}}}function aX(e){let t=e.trim();if(!t)return{kind:`blank`};try{let e=JSON.parse(t);return typeof e==`object`&&e&&!Array.isArray(e)?{kind:`object`,value:e}:{kind:`unparsed`,reason:`not a JSON object`}}catch(e){return{kind:`unparsed`,reason:String(e)}}}function oX(e){let t=aX(e);if(t.kind===`unparsed`)return A(`Failed to parse JSONL line: ${t.reason}`),null;if(t.kind===`blank`)return null;try{return iX(t.value)}catch(e){return A(`Failed to project JSONL line: ${e}`),null}}function sX(e){let t=[];for(let n of e.split(`
192
+ `)){let e=oX(n);e&&t.push(e)}return t}function cX(e,t,n){return n.longLine===0?e:[...e,{path:t,offset:n.start,bytes:n.longLine}]}function lX(e){return e.map(e=>`transcript long line path=${JSON.stringify(e.path)} offset=${e.offset} bytes=${e.bytes}`)}async function uX(e,t,n,r){let i=[],a=t?.cursor,o=t?.value??n,s;for(;;){let t=await Wo(e,a===void 0?void 0:{offset:a.offset,ino:a.ino},s?.size);if(t.kind!==`ok`)return t;let c=t.value;c.reset&&(o=n),i=cX(c.reset?[]:i,e,c),(s===void 0||c.reset)&&(s={size:c.size,stamp:c.stamp});let l=c.start+c.lines.length;if(o=await r(o,Go(c,e=>sX(e.toString(`utf-8`)))),a={offset:l,stamp:s.stamp,ino:c.ino},c.atEnd)return F({folded:{cursor:a,value:o},longLines:i})}}var dX=class{values=Y.observable.map(void 0,{deep:!1});order=new Set;constructor(e){this.max=e}get(e){return this.values.get(e)}get size(){return this.order.size}touch(e){this.order.delete(e)&&this.order.add(e)}set(e,t){this.order.delete(e),this.order.add(e),(0,Y.runInAction)(()=>{this.values.set(e,t);for(let e of this.order){if(this.order.size<=this.max)break;this.order.delete(e),this.values.delete(e)}})}},fX=class{sessions;constructor(e,t,n,r,i=Ne,a=256){this.empty=e,this.step=t,this.refreshes=n,this.clock=r,this.log=i,this.sessions=new dX(a)}async read(e,t){let n=this.sessions.get(e),r=n?.folded,i=Po(t);if(n?.folded&&i!==``&&n.folded.cursor.stamp===i){let{folded:t,answer:r}=n;return r.kind===`ok`&&r.value===t.value?(this.sessions.touch(e),r):this.store(e,t,{kind:`ok`,value:t.value})}let a=this.clock.monotonic(),o=await uX(t,r,this.empty,(e,t)=>t.reduce(this.step,e));if(this.refreshes.recorded(`sid=${R(e)}`,`request`,o,Fe(this.clock,a)),o.kind===`failed`)return this.store(e,r,o);if(o.kind===`absent`)return this.store(e,r,{kind:`ok`,value:r?.value??this.empty});let{folded:s,longLines:c}=o.value;for(let e of lX(c))this.log(`info`,e);return this.store(e,s,{kind:`ok`,value:s.value})}answer(e){return this.sessions.get(e)?.answer??Ao(`unread`)}store(e,t,n){return this.sessions.set(e,{folded:t,answer:n}),n}};function pX(e,t){let n=t.message?.usage;return!n?.input_tokens||t.isSidechain===!0?e:n.input_tokens+(n.cache_read_input_tokens||0)+(n.cache_creation_input_tokens||0)}var mX=class{fold;constructor(e){let t=e.logger??Ne;this.fold=new fX(void 0,pX,(e.ledger??new Dj(t)).declare({name:`context`,scope:`session`,refresh:[`request`]}),e.clock,t)}async refresh(e,t){return hX(await this.fold.read(e,t))}tokensOf(e){let t=this.fold.answer(e);return t.kind===`pending`?t:hX(t)}};function hX(e){return e.kind===`failed`?L(`context transcript: ${e.reason}`,e.failedAt):e.value===void 0?(A(`No main chain entries with usage data found`),I):F(e.value)}function gX(e,t){let n=Math.min(100,Math.max(0,Math.round(e/t*100)));return{percentage:n,contextLeftPercentage:Math.max(0,100-n)}}function _X(e){let t=e.context_window;if(!t?.current_usage)return null;let n=t.current_usage,r=t.context_window_size,i=(n.input_tokens||0)+(n.cache_creation_input_tokens||0)+(n.cache_read_input_tokens||0),a=gX(i,r);return{totalTokens:i,maxTokens:r,percentage:t.used_percentage==null?a.percentage:Math.round(t.used_percentage),contextLeftPercentage:t.remaining_percentage==null?a.contextLeftPercentage:Math.round(t.remaining_percentage)}}function vX(e,t){let n=_X(t);if(n!==null)return F(n);if(e.kind!==`ok`)return e;let r=yX(t);return F({totalTokens:e.value,maxTokens:r,...gX(e.value,r)})}function yX(e){return e.context_window?.context_window_size??2e5}const bX={messageCount:0,nonPrompts:0,recent:[]},xX=new Set([`turn`,`interrupt`,`claude-code`]);function SX(e,t){if(t.isSidechain)return e;let n=[...e.recent,t];return{messageCount:e.messageCount+ +(t.userEntry===`prompt`),nonPrompts:e.nonPrompts+ +!!xX.has(t.userEntry),recent:n.length>20?n.slice(-20):n}}function CX(e){let t=null,n=null;for(let r of e){let e=r.type||r.message?.role||r.message?.type;if(r.userEntry===`prompt`||r.userEntry===`turn`)t=r.timestamp;else if(e===`assistant`&&t){let e=(r.timestamp.getTime()-t.getTime())/1e3;e>.1&&e<300&&(n=e)}}return n}var wX=class{fold;constructor(e){let t=e.logger??Ne;this.fold=new fX(bX,SX,(e.ledger??new Dj(t)).declare({name:`metrics`,scope:`session`,refresh:[`request`]}),e.clock,t)}async refresh(e,t){return A(`Getting metrics from the transcript for session: ${e}`),TX(e,await this.fold.read(e,t))}foldOf(e){let t=this.fold.answer(e);return t.kind===`pending`?t:TX(e,t)}};function TX(e,t){return t.kind===`failed`?L(`metrics (${e}): ${t.reason}`,t.failedAt):F({lastResponseTime:CX(t.value.recent),messageCount:t.value.messageCount,nonPrompts:t.value.nonPrompts})}function EX(e,t){let n=t.cost;return n?e.kind===`ok`?F({...e.value,responseTime:n.total_api_duration_ms/1e3,sessionDuration:n.total_duration_ms/1e3,linesAdded:n.total_lines_added,linesRemoved:n.total_lines_removed}):e:I}function DX(e,t){return e.kind===`ok`?F({cost:t.cost?.total_cost_usd??e.value.calculatedCost,tokens:e.value.tokens}):e}function OX(e,t,n){return Ht({dir:e.project_dir,env:n===void 0?[]:[[Yo,n]],program:`claude`,args:[`--resume`,t,...e.added_dirs.flatMap(e=>[`--add-dir`,e])]})}const kX=[`session`,`today`,`context`,`metrics`,`activity`,`cache`,`speed`,`autocompact`];var AX=class{bySession=Y.observable.map(void 0,{deep:!1});of(e,t){let n=this.bySession.get(e)?.get(t);return n===void 0?void 0:L(n,`read`)}refreshed(e,t,n){let r=this.bySession.get(e);if(n===null&&r?.has(t)!==!0)return;let i=new Map(r);n===null?i.delete(t):i.set(t,n),(0,Y.runInAction)(()=>{i.size===0?this.bySession.delete(e):this.bySession.set(e,i)})}};function jX(e,t){return{endcaps:e.endcaps,separator:e.separator,colorCompatibility:e.colorCompatibility,wrap:e.autoWrap,padding:e.padding,width:t}}function MX(e){return{...Object.fromEntries(Ex.map(t=>[t,{effective:e[t]}])),preset:{effective:e.preset,customized:e.presetCustomized,bundled:gK(e.preset)}}}const NX={prNumber:!0,prState:!0,prUrl:!0,prError:!0,prEarlier:!0};function PX(e){if(jo(e))return`pending`;let{prState:t,prError:n,prEarlier:r}=e??{};return jo(t)?`pending`:t===void 0?n===void 0?r===void 0?`-`:`earlier-${String(r)}`:`failed`:t}const FX=10*1e3;function IX(e,t){if(!(t<60))return e*3600/t}function LX(e,t,n,r){let i=r-t;if(i<50||i>FX)return;let a=n-e;if(!(a<=0))return a*1e3/i}function RX(e){let{prev:t,cur:n}=e;if(t===void 0)return;let r=LX(t.input,t.atMs,n.input,n.atMs),i=LX(t.output,t.atMs,n.output,n.atMs),a=LX(t.total,t.atMs,n.total,n.atMs);if(!(r===void 0&&i===void 0&&a===void 0))return{...r!==void 0&&{input:r},...i!==void 0&&{output:i},...a!==void 0&&{total:a}}}function zX(e){let{samples:t}=e,n=[];for(let e=1;e<t.length;e++){let r=t[e-1],i=t[e],a=i.atMs-r.atMs;if(a<50||a>FX)continue;let o=LX(r.total,r.atMs,i.total,i.atMs);n.push(o??0)}if(n.length!==0)return n.join(`,`)}function BX(e){return BY(e.termCols??120)}function VX(e,t){return Qo(Zo(e.claudeConfigDir,t))}function HX(e){return[...e].map(([e,t])=>`${e}:${t===null?`…`:`${t}ms`}`).join(`,`)||`-`}async function UX(e,t,n){let{hookData:r,deps:i,hints:a}=e,o=r.session_id,s=i.usageStore.request(o,r.transcript_path),c=async(e,t)=>{let r=i.clock.monotonic();n.set(e,null);let a=null;try{await t()}catch(t){i.log(`error`,`${e} lane threw: ${x(t)}`),a=`${e}: ${String(t)}`}n.set(e,Fe(i.clock,r)),i.faults.refreshed(o,e,a)};await Promise.all([c(`session`,()=>s.usage()),c(`today`,()=>s.today()),c(`context`,()=>i.contextProvider.refresh(o,r.transcript_path)),c(`metrics`,()=>i.metricsProvider.refresh(o,r.transcript_path)),c(`activity`,()=>i.activityProvider.getActivityInfo(o,r)),c(`cache`,()=>i.cacheExpiry.refresh(o,r.transcript_path)),c(`speed`,()=>s.speed(He(t).getTime())),c(`autocompact`,async()=>i.autoCompact.window(VX(a,i.home)))])}function WX(e,t){let n=bj(e);return{git:n,tmux:n,hostName:n,hostUser:n,today:n,sources:new Map(t.map(e=>[e,n]))}}function GX({cwd:e,hookData:t}){return[e??t.workspace?.current_dir,t.workspace?.project_dir]}function KX(e,t,n,r){let i=n.hints.tmux??null,a=[],o=(e,t)=>{try{return t()}catch(t){return a.push(`${e}: ${x(t)}`),bj(L(`${e}: ${String(t)}`,`read`))}};return{lanes:{git:o(`git`,()=>e.gitProvider.declare(t,...GX(n))),tmux:i===null?bj(I):o(`tmux`,()=>e.tmuxService.declare(t,i)),hostName:o(`host.name`,()=>e.hostService.declareName(t)),hostUser:o(`host.user`,()=>e.hostService.declareUser(t)),today:o(`today`,()=>e.usageStore.declareToday(t,n.hints.claudeConfigDir)),sources:new Map([...r].map(([r,i])=>[r,o(r,()=>e.managedStorage.declare(t,i,n.sessionId))]))},faults:a}}function qX(e,t){let{hookData:n,deps:r}=e,i=n.session_id,a=(e,t)=>{let n=r.faults.of(i,e);if(n!==void 0)return n;try{return t()}catch(t){return r.log(`error`,`${e} read threw: ${x(t)}`),L(`${e}: ${String(t)}`,`read`)}};return{lanes:{git:t.git.current(),usage:a(`session`,()=>r.usageStore.usageOf(i)),context:a(`context`,()=>r.contextProvider.tokensOf(i)),metrics:a(`metrics`,()=>r.metricsProvider.foldOf(i)),activity:a(`activity`,()=>r.activityProvider.activityOf(i)),tmuxSession:t.tmux.current(),hostName:t.hostName.current(),hostUser:t.hostUser.current(),cache:a(`cache`,()=>r.cacheExpiry.expiryOf(i)),speed:a(`speed`,()=>r.usageStore.speedOf(i)),autoCompact:a(`autocompact`,()=>r.autoCompact.stored(VX(e.hints,r.home))),sources:new Map([...t.sources].map(([e,t])=>[e,t.current()]))},today:a(`today`,()=>JX(t.today,r.usageStore,i)),faults:kX.flatMap(e=>{let t=r.faults.of(i,e);return t===void 0?[]:[{kind:`lane`,lane:e,reason:t.reason}]})}}function JX(e,t,n){let r=e.current();if(r.kind!==`ok`)return r;let i=t.daysOutside(n,r.value.roots);return i.kind===`failed`?i:F({sums:r.value.sums,own:i.kind===`ok`?i.value:{}})}function YX({builtins:e,sources:t}){return[e.git,e.tmux,e.hostName,e.hostUser,...Object.values(t)].some(e=>e.kind===`pending`&&e.why===`unread`)}async function XX(e,t,n,r,i){await UX(e,t,n);try{await(0,Y.when)(()=>!YX(r()),{signal:i})}catch(e){if(!i.aborted)throw e}}function ZX(...e){let t=e.find(e=>e.kind===`pending`);return t?.kind===`pending`?Ao(t.why):void 0}const QX=e=>{switch(e.kind){case`pending`:return e;case`absent`:return I;case`ok`:return F(e.value);case`failed`:return L(e.reason,e.failedAt)}};function $X(e,t,n){let{hookData:r,hints:i}=t,{effective:a,configFacts:o}=n,{configPath:s,...c}=o,l=e.builtins,u={usage:DX(QX(l.session),r),context:vX(QX(l.context),r),metrics:EX(QX(l.metrics),r),activity:QX(l.activity),cache:QX(l.cache),speed:QX(l.speed),autoCompact:QX(l.autocompact),git:QX(l.git),pr:QX(l.pr),tmux:QX(l.tmux),hostName:QX(l.hostName),hostUser:QX(l.hostUser)},d=(e,t)=>{switch(e.kind){case`pending`:return Ao(e.why);case`failed`:case`absent`:return;case`ok`:return t(e.value)}},f=e=>e.kind===`ok`?e.value:void 0,p=i.tmux??null,m=u.git.kind===`pending`?Ao(u.git.why):u.git.kind===`ok`?dZ(u.git.value,u.pr,Ao):void 0,h=u.tmux.kind===`pending`?Ao(u.tmux.why):f(u.tmux)?.session,g=u.hostName.kind===`pending`?Ao(u.hostName.why):f(u.hostName),_=u.hostUser.kind===`pending`?Ao(u.hostUser.why):f(u.hostUser),v=ZX(u.context)??oZ(u.autoCompact,f(u.context)?.maxTokens),y=r.rate_limits?.five_hour,b=r.rate_limits?.seven_day,x=ZX(u.usage,u.metrics)??rZ(f(u.usage)?.cost,f(u.metrics)?.sessionDuration),S=d(u.speed,iZ),C=d(u.usage,e=>lZ({cost:e.cost,tokens:e.tokens})),w=d(u.metrics,e=>lZ({lastResponseTime:e.lastResponseTime,responseTime:e.responseTime,sessionDuration:e.sessionDuration,messageCount:e.messageCount,nonPrompts:e.nonPrompts,linesAdded:e.linesAdded,linesRemoved:e.linesRemoved})),T=d(u.activity,sZ),ee=d(u.context,e=>({totalTokens:e.totalTokens,contextLeft:e.contextLeftPercentage})),te=d(u.cache,e=>({expiresAt:e})),E=uZ(t.home),ne=r.workspace?{...r.workspace,current_dir:uZ(r.workspace.current_dir)??``,project_dir:uZ(r.workspace.project_dir)??``,added_dirs:(r.workspace.added_dirs??[]).map(e=>uZ(e)??e)}:r.workspace,D=r.session_id;return{...r,...ne!==void 0&&{workspace:ne},...E!==void 0&&{home:E},...m!==void 0&&{git:m},...r.location!==void 0&&{location:{...r.location,main:uZ(r.location.main)??``}},...p!==null&&{tmux:{pane:p.pane,...h!==void 0&&{session:h}}},host:{...g!==void 0&&{name:g},..._!==void 0&&{user:_},...i.ssh!==void 0&&{ssh:i.ssh}},...MX(a),history:n.history,navigation:{back:n.back},term:{cols:BX(i)},...c,...s!==null&&{configPath:s},resumeCommand:OX(ne,D,i.claudeConfigDir),...C!==void 0&&{session:C},...x!==void 0&&{burn:x},...S!==void 0&&{speed:S},...y!==void 0&&{block:{nativeUtilization:y.used_percentage,resetsAt:y.resets_at}},...b!==void 0&&{weekly:{percentage:b.used_percentage,resetsAt:b.resets_at}},...te!==void 0&&{cache:te},...ee!==void 0&&{context:ee},...w!==void 0&&{metrics:w},...T!==void 0&&{activity:T},...v!==void 0&&{autocompact:v},...nZ(n.sources,t=>{let n=QX(eZ(e,t));return n.kind===`pending`?Ao(n.why):n})}}const eZ=(e,t)=>e.sources[t]??Ao(`unread`);function tZ(e,t){let n=e.map(e=>[e,eZ(t,e)]);return{sources:String(n.length),sourcesPending:n.flatMap(([e,t])=>t.kind===`pending`?[`${e}:${t.why}`]:[]).join(`,`)||`-`}}function nZ(e,t){let n=Object.fromEntries(kS.map(e=>[e,{}]));for(let r of e){let e=r.split(`.`),i=e.pop(),a=e.reduce((e,t)=>e[t]??={},n);a[i]=t(r)}return n}function rZ(e,t){let n=e!=null&&t!=null?IX(e,t):void 0;return n===void 0?void 0:{costPerHour:n}}function iZ(e){let t=RX(e),n=zX(e);return t!==void 0||n!==void 0?{...t,...n!==void 0&&{history:n}}:void 0}function aZ(e,t){if(e.kind===`pending`)return Ao(e.why);if(e.kind!==`ok`)return;let n=GY(e.value,t);return n.kind===`ok`?{cost:n.value.cost,tokens:n.value.tokens}:void 0}function oZ(e,t){switch(e.kind){case`pending`:return Ao(e.why);case`absent`:return;case`failed`:return{error:e.reason};case`ok`:return yI(e.value,t)}}function sZ(e){let t=e.todos.findIndex(e=>e.active),n=e.todos.length===0?void 0:{total:e.todos.length,completed:e.todos.filter(e=>e.done).length,...t>=0&&{position:t+1,active:e.todos[t].text}},r=cZ(e.running),i=cZ(e.done),a=r===void 0&&i===void 0?void 0:{...r!==void 0&&{running:r},...i!==void 0&&{done:i}};if(!(e.command===null&&n===void 0&&a===void 0))return{...e.command!==null&&{command:e.command},...n!==void 0&&{todo:n},...a!==void 0&&{tool:a}}}function cZ(e){return e.length===0?void 0:e.map(e=>`${e.name}:${e.count}`).join(`,`)}function lZ(e){let t={},n=!1;for(let r of Object.keys(e)){let i=e[r];i!=null&&(t[r]=i,n=!0)}return n?t:void 0}function uZ(e){return e===void 0||e.length===0||E.sep!==`\\`?e:e.replace(/\\/g,`/`)}function dZ(e,t,n){let r=e=>e.kind===`ok`?e.value:void 0,i=r(e.aheadBehind),a=r(e.sha),o=r(e.operation),s=r(e.committedAt),c=r(e.stashCount),l=r(e.upstream),u=r(aY(e.upstream,e.aheadBehind)),d=r(e.repoName),f=r(e.repoUrl),p=t.kind===`pending`?t:oY(t,e.head),m={};switch(p.kind){case`pending`:{let e=n(p.why);m={prNumber:e,prState:e,prUrl:e,prError:e,prEarlier:e};break}case`ok`:m={prNumber:p.value.number,prState:p.value.state,prUrl:p.value.url};break;case`failed`:m={prError:p.reason};break;case`earlier`:m={prEarlier:p.value.state};break;case`absent`:break}return{branch:e.branch,status:e.status,...i!==void 0&&{ahead:i.ahead,behind:i.behind},staged:e.workingTree.staged,unstaged:e.workingTree.unstaged,untracked:e.workingTree.untracked,conflicts:e.workingTree.conflicts,...a!==void 0&&{sha:a},...o!==void 0&&{operation:o},...s!==void 0&&{committedAt:s},...c!==void 0&&{stash:c},...l!==void 0&&{upstream:l},...u!==void 0&&{tracking:u},...d!==void 0&&{repoName:d},...f!==void 0&&{repoUrl:f},...m}}const fZ=(e,t)=>[...e].some(e=>e===t||e.startsWith(`${t}.`)),pZ={pullRequests:e=>Object.keys(NX).some(t=>e.has(`git.${t}`)),rateLimits:e=>fZ(e,`block`)||fZ(e,`weekly`)};function mZ(e,t){let n=e.segments[t];return n?[...[n.template,n.when,n.bg,n.fg].flatMap(e=>e?[e]:[]),...Object.values(n.partials??{})]:[]}function hZ(e,t){let n=UW(e),r=new Map(dC(e)),i=t.flatMap(e=>n.ofTemplate(e).flatMap(({reaches:e})=>e)),a=new Set,o=new Set;for(;i.length>0;){let e=i.pop();if(a.has(e))continue;a.add(e);let t=r.get(e),s=VW(e,t);s!==void 0&&o.add(s);for(let{reaches:e}of n.ofVariable(t))i.push(...e)}return o}function gZ(e,t){let n=new Map;for(let r of Ny(fS(e,t).node)){if(r.kind!==`segment`)continue;let e=n.get(r.name)??[];r.when&&e.push(r.when),n.set(r.name,e)}let r=[...n.keys()].filter(t=>Wy(e.segments[t])===`fail`),i=new Map(r.map(t=>[t,hZ(e,[...mZ(e,t),...n.get(t)])])),a=e=>r.filter(t=>pZ[e](i.get(t)));return{pullRequests:a(`pullRequests`),rateLimits:a(`rateLimits`)}}
193
193
  /*!
194
194
  * Copyright (c) Squirrel Chat et al., All rights reserved.
195
195
  * SPDX-License-Identifier: BSD-3-Clause
@@ -474,43 +474,43 @@ function run(argv) {
474
474
  `:null,r=XQ(e.value);return r===null?{stdout:n??i$(e.value),stderr:``,code:0}:{stdout:n??``,stderr:`daemon-stats: ${r}\n`,code:1}}function YQ(e){return ar(e,()=>({kind:`stats`}),KQ,e=>`stats`in e?e.stats:void 0)}function XQ(e,t=ZQ){let n=GQ.referenceSnapshot(),r=QQ(Object.fromEntries(t.map(e=>[e,n[e]])),e);if(r.length===0)return null;let i=e$(e.version,e.sourceDigest??null),a=e$(tn,an());return`the daemon (${i}) reports no ${r.join(`, `)}; it is another build than this client (${a}), and restarts only when its own bundle changes`}const ZQ=Object.keys(GQ.referenceSnapshot());function QQ(e,t,n=``){if(Array.isArray(e))return Array.isArray(t)?[]:[n||`<snapshot>`];if(!$Q(e))return[];if(!$Q(t))return[n||`<snapshot>`];if(`kind`in e)return[];let r=[];for(let i of Object.keys(e)){let a=n===``?i:`${n}.${i}`;i in t?r.push(...QQ(e[i],t[i],a)):r.push(a)}return r}function $Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function e$(e,t){return`${e} [${t===null?`no digest`:en(t)}]`}function t$(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function n$(e,t){let n=e+t;return n===0?`n/a`:`${(e/n*100).toFixed(1)}%`}function r$(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m${e%60}s`:`${Math.floor(e/3600)}h${Math.floor(e%3600/60)}m`}function i$(e){let t=[];t.push(`cc-candybar daemon stats`),t.push(``),t.push(`process`),t.push(` pid ${e.pid}`),t.push(` build ${e$(e.version,e.sourceDigest)}`),t.push(` protocol ${e.protocolVersion}`),t.push(` startedAt ${e.startedAt}`),t.push(` uptime ${r$(e.uptimeSec)}`),t.push(` rss ${t$(e.rssBytes)}`),t.push(` heapUsed ${t$(e.heapUsedBytes)}`),t.push(` heapTotal ${t$(e.heapTotalBytes)}`),t.push(` external ${t$(e.externalBytes)}`),t.push(` arrayBuffers ${t$(e.arrayBuffersBytes)}`),t.push(``),t.push(`requests`),t.push(` total ${e.requests.total}`),t.push(` errored ${e.requests.errored}`),t.push(` timedOut ${e.requests.timedOut}`),t.push(` inFlight ${e.requests.inFlight}`),t.push(` unknownFields ${e.unknownHookFields.map(e=>JSON.stringify(e)).join(`, `)||`-`}`),t.push(``),t.push(`gitCache`),t.push(` size ${e.gitCache.size}`),t.push(` held ${e.gitCache.held}`),t.push(` hit rate ${n$(e.gitCache.hits,e.gitCache.misses)} (${e.gitCache.hits} / ${e.gitCache.hits+e.gitCache.misses})`),t.push(` changes ${e.gitCache.changes}`),t.push(``),t.push(`usageCache`),t.push(` size ${e.usageCache.size}`),t.push(` hit rate ${n$(e.usageCache.hits,e.usageCache.misses)} (${e.usageCache.hits} / ${e.usageCache.hits+e.usageCache.misses})`),t.push(` sweeps ${e.usageCache.sweeps}`),t.push(``),t.push(`sources`);for(let n of e.sources.records){let e=Object.entries(n.refreshes).map(([e,t])=>`${e}:${t}`).join(` `);t.push(` ${`${n.scope}/${n.name}`.padEnd(24)} failures=${n.failures} last=${n.lastMs===null?`-`:`${n.lastMs}ms`} refreshes ${e}`)}let n=Object.entries(e.sources.homes).map(([e,t])=>`${e}:${t}`).join(` `),r=Object.entries(e.sources.held).map(([e,t])=>`${e}:${t}`).join(` `);t.push(` homes ${n}`),t.push(` held ${r}`);let i=e.sources.pluginStorage,a=Object.entries(i.faults).map(([e,t])=>`${e}:${t}`).join(` `);t.push(` plugin storage folders=${i.folders} lost=${i.lost} faults ${a}`),t.push(` fileEvents ${Yc(e.fileEvents)}`);for(let n of[`shell`,`file`]){let r=e.sourceRuns[n];t.push(` runs.${n.padEnd(8)} entries=${r.entries} held=${r.held} failures=${r.failures} abandoned=${r.abandoned} last=${r.lastMs===null?`-`:`${r.lastMs}ms`}`)}t.push(` runs.watches ${e.sourceRuns.watches}`),t.push(``),t.push(`transcriptReads`),t.push(` reads ${e.transcriptReads.reads}`),t.push(` bytes ${t$(e.transcriptReads.bytes)}`),t.push(` long lines ${e.transcriptReads.longLines}`),t.push(` largest line ${t$(e.transcriptReads.largestLine)}`),t.push(``),t.push(`renderCache`),t.push(` size ${e.renderCache.size}`),t.push(` held ${e.renderCache.held}`),t.push(` retired ${e.renderCache.retired}`),t.push(` compiles ${e.renderCache.compiles}`),t.push(` views ${e.renderCache.views}`),t.push(` pinned ${e.renderCache.pinned}`),t.push(` due ${e.renderCache.due}`),t.push(` retired views ${e.renderCache.retiredViews}`),t.push(` accounted ${t$(e.renderCache.accountedBytes)} / ${t$(e.renderCache.budgetBytes)}`),t.push(``),t.push(`collector`),t.push(` sessions ${e.collector.sessions}`),t.push(` retiring ${e.collector.retiring}`),t.push(``),t.push(`effectCache`),t.push(` sessions ${e.effectCache.sessions}`),t.push(` effects ${e.effectCache.effects}`),t.push(``),t.push(`menuIdle`),t.push(` sessions ${e.menuIdle.sessions}`),t.push(` armed ${e.menuIdle.armed}`),t.push(` pending ${e.menuIdle.pending}`),t.push(``),t.push(`journalTurns`),t.push(` holder ${e.journalTurns.holder??`-`}`),t.push(` held ${e.journalTurns.heldMs}ms`),t.push(` queued ${e.journalTurns.queued}`),t.push(` gathers ${e.journalTurns.gathers}`),t.push(``),t.push(`sessionState`),t.push(` sessions ${e.sessionState.sessions}`),t.push(` observers ${e.sessionState.observers}`),t.push(` revision ${e.sessionState.revision}`),t.push(``),t.push(`watchers`),t.push(` active ${e.watchers.active}`),t.push(` opened ${e.watchers.opened}`),t.push(` closed ${e.watchers.closed}`),t.push(` refused ${e.watchers.refused}`),t.push(` errors ${e.watchers.errors}`),t.push(` dirs ${e.watchers.dirs.active} open (${e.watchers.dirs.opened} opened, ${e.watchers.dirs.closed} closed)`),t.push(``),t.push(`subprocesses`),t.push(` total ${e.subprocesses.total}`),t.push(` inFlight ${e.subprocesses.inFlight}`),t.push(` lastMinute ${e.subprocesses.lastMinute}`),t.push(` draining ${e.subprocesses.draining} (${e.subprocesses.drainedBytes} bytes dropped, ${e.subprocesses.drainsCut} cut)`),t.push(` pipeErrors ${e.subprocesses.pipeErrors}`);let o=Object.entries(e.subprocesses.byCategory),s=Object.entries(e.subprocesses.refused).map(([e,t])=>[`${e} refused`,t]),c=[...o,...s].reduce((e,[t])=>Math.max(e,t.length),13);for(let[n,r]of o){let i=e.subprocesses.p50DurationMs[n],a=e.subprocesses.p99DurationMs[n],o=i!==void 0&&a!==void 0?` (p50 ${i}ms · p99 ${a}ms)`:``;t.push(` ${n.padEnd(c)} ${r}${o}`)}for(let[e,n]of s)t.push(` ${e.padEnd(c)} ${n}`);return e.nextRestartReason&&(t.push(``),t.push(`nextRestart ${e.nextRestartReason}`)),t.join(`
475
475
  `)+`
476
476
  `}const a$=e=>({kind:`ok`,value:e}),o$=e=>({kind:`failed`,reason:e});var s$=class{arrivals=[];arrive(e){this.arrivals=[...this.arrivals,e].slice(-16)}list(){return this.arrivals}};const c$=/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;function l$(e){return c$.test(e)?e:null}function u$(e){let t=e.opener();if(t.kind===`failed`)return t;if(t.value===null)return a$(null);let n=t.value;return a$({app:n,forwarder:e.exists(As(n))})}async function d$(e,t){let n=e.monotonic()+5e3;for(;e.monotonic()<n;){await e.pause();let n=await e.daemon(),r=n.kind===`ok`?n.value.arrivals.find(e=>e.nonce===t):void 0;if(n.kind===`ok`&&r!==void 0)return{kind:`arrived`,delivery:r.delivery}}return null}async function f$(e){if(e.platform!==`darwin`)return{kind:`unsupported`};if(e.sockets.own!==e.sockets.handler)return{kind:`unprobed`,reason:`this shell's daemon is at ${e.sockets.own} (CC_CANDYBAR_SOCKET); the URL handler delivers links to ${e.sockets.handler}`};let t=await e.daemon();if(t.kind===`failed`)return{kind:`unprobed`,reason:`the daemon could not be asked whether a link arrives: ${t.reason}`};let n=e.nonce(),r=e.open(`${Vi}://${fa}/${n}`);return(r===null?await d$(e,n):null)??{kind:`lost`,unopened:r,opener:u$(e)}}function p$(e,t,n,r){let i=e.launchSync({bin:n,args:[...r],category:t,timeoutMs:5e3});return i.ok?a$(i.stdout):o$(Ze(i))}const m$=`ObjC.import("AppKit");var u = $.NSWorkspace.sharedWorkspace.URLForApplicationToOpenURL($.NSURL.URLWithString("${Vi}://probe"));u.isNil() ? "" : u.path.js`;async function h$(e){let t=await YQ(e);if(t.kind!==`ok`)return o$(fr(t).split(`
477
- `).join(` — `));let n=XQ(t.value,[`handlerProbes`]);if(n!==null)return o$(n);let r=[];for(let e of t.value.handlerProbes){let t=g$(e);if(t===null)return o$(`the daemon lists its probe arrivals without who delivered them, so it is from a build before the forwarder app — restart it to run the installed one`);r.push(t)}return a$({arrivals:r})}function g$(e){if(typeof e!=`object`||!e)return null;let{nonce:t,delivery:n}=e;if(typeof t!=`string`||typeof n!=`object`||!n)return null;let{kind:r,urlV:i}=n;return r===`cli`?{nonce:t,delivery:{kind:`cli`}}:r===`forwarder`&&typeof i==`number`?{nonce:t,delivery:{kind:`forwarder`,urlV:i}}:null}function _$(e,t){let{host:n,clock:r}=t;return{platform:process.platform,sockets:{own:fn(n),handler:pn()},monotonic:()=>r.monotonic(),nonce:le,daemon:()=>h$(t),open:t=>{let n=p$(e,`doctor.open`,`/usr/bin/open`,[`-g`,t]);return n.kind===`ok`?null:n.reason},pause:()=>Le(r,100),opener:()=>{let t=p$(e,`doctor.launch-services`,`/usr/bin/osascript`,[`-l`,`JavaScript`,`-e`,m$]);if(t.kind===`failed`)return t;let n=t.value.trim();return a$(n===``?null:n)},exists:s.existsSync}}const v$=/^─{20,}/,y$=/^❯(\s|$)/,b$=/›\s*stashed$/;function x$(e){let t=e.screen.map(e=>e.trimEnd()),n=t.flatMap((e,t)=>v$.test(e)?[t]:[]).at(-2);return n===void 0||!y$.test(t[n+1]??``)?null:{hint:t[n-1]??``,prompt:t[n+1]}}function S$(e){if(e.inMode)return{kind:`in-mode`};let t=x$(e);return t===null?{kind:`no-prompt`}:b$.test(t.hint)?{kind:`stashed`}:{kind:`ready`}}function C$(e){return/^❯\s*\S/u.test(x$(e)?.prompt??``)}const w$=/^\S+\s+\S[^…]*…\s+\((\d+[hms]\s*)+/u;function T$(e){return e.screen.some(e=>w$.test(e))}const E$={"in-mode":`the Claude Code pane is in tmux copy mode — leave it (q) and click again`,stashed:`Claude Code is holding a stashed prompt (ctrl+s) — restore or send it, then click again`,"no-prompt":`Claude Code is not at its prompt (a dialog or picker is open) — close it and click again`};function D$(e){return e===void 0?{kind:`refused`,reason:`this session's statusline client reports no tmux facts (it predates this daemon) — rebuild or reinstall cc-candybar`}:e===null?{kind:`refused`,reason:`this Claude Code is not running inside tmux — the bar can only act in a tmux pane`}:{kind:`pane`,hint:e}}async function O$(e,t,n){let r=D$(t);if(r.kind===`refused`)return r;let i=r.hint,a=S$(await e.read(i));if(a.kind!==`ready`)return{kind:`refused`,reason:E$[a.kind]};let o=await e.type(i,n);return o.kind===`typed`?{kind:`typed`,pane:i.pane}:o}async function k$(e,t,n,r,i){let a=await bc(e,t,n,r,i);if(a.kind===`failed`)throw Error(a.reason);return a}async function A$(e,t){let n=await k$(e,t,`claude-input.read`,[`display`,`-p`,`-t`,t.pane,`#{pane_in_mode}`,`;`,`capture-pane`,`-p`,`-t`,t.pane]);if(n.kind===`rate-limited`)throw Error(n.reason);let[r=``,...i]=n.stdout.split(`
477
+ `).join(` — `));let n=XQ(t.value,[`handlerProbes`]);if(n!==null)return o$(n);let r=[];for(let e of t.value.handlerProbes){let t=g$(e);if(t===null)return o$(`the daemon lists its probe arrivals without who delivered them, so it is from a build before the forwarder app — restart it to run the installed one`);r.push(t)}return a$({arrivals:r})}function g$(e){if(typeof e!=`object`||!e)return null;let{nonce:t,delivery:n}=e;if(typeof t!=`string`||typeof n!=`object`||!n)return null;let{kind:r,urlV:i}=n;return r===`cli`?{nonce:t,delivery:{kind:`cli`}}:r===`forwarder`&&typeof i==`number`?{nonce:t,delivery:{kind:`forwarder`,urlV:i}}:null}function _$(e,t){let{host:n,clock:r}=t;return{platform:process.platform,sockets:{own:fn(n),handler:pn()},monotonic:()=>r.monotonic(),nonce:ce,daemon:()=>h$(t),open:t=>{let n=p$(e,`doctor.open`,`/usr/bin/open`,[`-g`,t]);return n.kind===`ok`?null:n.reason},pause:()=>Le(r,100),opener:()=>{let t=p$(e,`doctor.launch-services`,`/usr/bin/osascript`,[`-l`,`JavaScript`,`-e`,m$]);if(t.kind===`failed`)return t;let n=t.value.trim();return a$(n===``?null:n)},exists:s.existsSync}}const v$=/^─{20,}/,y$=/^❯(\s|$)/,b$=/›\s*stashed$/;function x$(e){let t=e.screen.map(e=>e.trimEnd()),n=t.flatMap((e,t)=>v$.test(e)?[t]:[]).at(-2);return n===void 0||!y$.test(t[n+1]??``)?null:{hint:t[n-1]??``,prompt:t[n+1]}}function S$(e){if(e.inMode)return{kind:`in-mode`};let t=x$(e);return t===null?{kind:`no-prompt`}:b$.test(t.hint)?{kind:`stashed`}:{kind:`ready`}}function C$(e){return/^❯\s*\S/u.test(x$(e)?.prompt??``)}const w$=/^\S+\s+\S[^…]*…\s+\((\d+[hms]\s*)+/u;function T$(e){return e.screen.some(e=>w$.test(e))}const E$={"in-mode":`the Claude Code pane is in tmux copy mode — leave it (q) and click again`,stashed:`Claude Code is holding a stashed prompt (ctrl+s) — restore or send it, then click again`,"no-prompt":`Claude Code is not at its prompt (a dialog or picker is open) — close it and click again`};function D$(e){return e===void 0?{kind:`refused`,reason:`this session's statusline client reports no tmux facts (it predates this daemon) — rebuild or reinstall cc-candybar`}:e===null?{kind:`refused`,reason:`this Claude Code is not running inside tmux — the bar can only act in a tmux pane`}:{kind:`pane`,hint:e}}async function O$(e,t,n){let r=D$(t);if(r.kind===`refused`)return r;let i=r.hint,a=S$(await e.read(i));if(a.kind!==`ready`)return{kind:`refused`,reason:E$[a.kind]};let o=await e.type(i,n);return o.kind===`typed`?{kind:`typed`,pane:i.pane}:o}async function k$(e,t,n,r,i){let a=await bc(e,t,n,r,i);if(a.kind===`failed`)throw Error(a.reason);return a}async function A$(e,t){let n=await k$(e,t,`claude-input.read`,[`display`,`-p`,`-t`,t.pane,`#{pane_in_mode}`,`;`,`capture-pane`,`-p`,`-t`,t.pane]);if(n.kind===`rate-limited`)throw Error(n.reason);let[r=``,...i]=n.stdout.split(`
478
478
  `);return{inMode:r!==`0`,screen:i}}function j$(e,t,n){return[`load-buffer`,`-b`,t,`-`,`;`,...n.length===0?[]:[`send-keys`,`-t`,e,...n,`;`],`paste-buffer`,`-p`,`-d`,`-b`,t,`-t`,e,`;`,`send-keys`,`-t`,e,`Enter`]}async function M$(e,t,n){let r=await k$(e,t,`claude-input.type`,j$(t.pane,`cc-candybar-slash`,[`C-s`]),n);return r.kind===`ok`?{kind:`typed`}:{kind:`refused`,reason:`cc-candybar typed a command moments ago — click again in a second (${r.reason})`}}function N$(e){return{read:t=>A$(e,t),type:(t,n)=>M$(e,t,n)}}function P$(e){let t=typeof e==`string`?e===``?`is empty`:e===`.`||e===`..`?`is ${JSON.stringify(e)}, which names a folder, not a session`:/[/\\\0]/.test(e)?`contains a path separator or NUL: ${JSON.stringify(e)}`:Buffer.byteLength(e,`utf8`)>250?`is longer than 250 bytes`:null:`is not a string: ${JSON.stringify(e)??String(e)}`;return t===null?{ok:!0,id:e}:{ok:!1,problem:t}}function F$(e){let t=P$(e);if(!t.ok)throw Error(`session id ${t.problem}`);return t.id}const I$=e=>({gathers:!1,prepare:async t=>n=>e(t,n)});function L$(e){let t=P$(e);if(!t.ok)throw new Z(`session id ${t.problem}`);return t.id}function R$(e){return uq(()=>decodeURIComponent(e))}const z$=5e3;function B$(e,t,n){if(e.reason===`rate-limited`){n(`warn`,Ze(e));return}throw e.reason===`aborted`?new cq(t):Error(`${t} failed (${Ze(e)})`)}async function V$(e,t,n,r){let i=await e.launch({...t,timeoutMs:z$});i.ok||B$(i,n,r)}async function H$(e,t,n,r,i,a){let o=p(E.join(a,`cc-candybar-handoff-`));try{let a={stdout:`/dev/null`,stderr:E.join(o,`stderr`),status:E.join(o,`status`)},s=e.launchJobSync(t,a);if(!s.ok){B$({...s,stdout:``,stderr:``,exitCode:null,signal:null},n,r);return}s.release();let c=e.clock.monotonic()+i;for(;;){let o=e.jobGroupAlive(s.pid),l=kt(a.status);if(l!==null){if(l.kind===`exit`&&l.code===0)return;B$(l.kind===`exit`?{ok:!1,reason:`non-zero`,stdout:``,stderr:h(a.stderr,`utf8`),exitCode:l.code,signal:null}:{ok:!1,reason:`timeout`,stdout:``,stderr:``,exitCode:null,signal:null},n,r);return}if(!o)throw Error(`${n} failed (lost): the opener ended with no verdict`);if(e.clock.monotonic()>=c){r(`info`,`${t.category} handed off at ${i}ms, pid ${s.pid}`);return}await Le(e.clock,50)}}finally{_(o,{recursive:!0,force:!0,maxRetries:3})}}function U$(e,t){return t.launch({bin:`/usr/bin/pbcopy`,stdinInput:e,category:`click.pbcopy`},`pbcopy`)}const W$=(e,t)=>U$(R$(e),t),G$=new Set([`request`,`feed`]);function K$(e){if(!G$.has(e))throw new Z(`unknown renderer ${JSON.stringify(e)}`);return e}const q$=async(e,t)=>{let[n=``,r=``,i=``]=uq(()=>wa(e)),a=L$(n),o=t.diagnosticCopy(a,K$(r),i);if(o===void 0)throw new Z(`that message is no longer listed in session ${a}'s diagnostics — open the indicator beside the settings door again and copy from there`);await U$(o,t)},J$=(e,t)=>t.launch({bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,R$(e)],category:`click.open`},`open -a "Visual Studio Code"`),Y$=async(e,t)=>{let n=L$(R$(e));t.navigating.get(n,`toolbar-expanded`)?t.navigating.clear(n,`toolbar-expanded`):t.navigating.set(n,`toolbar-expanded`,`1`)},X$=async(e,t)=>{let[n=``,...r]=uq(()=>wa(e)),i=L$(n),a=t.gates.state.gateFor(u1(t,i));if(r.length===0)throw new Z(`set-state: <key>/<value> is required (have keys: ${a.listKeys().join(`, `)})`);if(r.length%2!=0)throw new Z(`set-state: expected even-count <key>/<value> pairs, got ${r.length} segment(s) after session id (have keys: ${a.listKeys().join(`, `)})`);let o=[];for(let e=0;e<r.length;e+=2){let t=r[e],n=r[e+1];if(!t)throw new Z(`set-state: empty key at pair ${e/2+1} (expected <sessionId>/<key>/<value>[/<key>/<value>...] segments)`);let i=a.validate(t,n);if(!i.ok)throw new Z(`set-state: pair ${e/2+1}: ${i.reason}`);o.push({key:t,value:i.value})}e1(t,i,`set-state`,o),t.navigating.setBatch(i,o);let s=o.map(e=>`${e.key}=${e.value}`).join(` `);t.log(`info`,`set-state: ${s} (session=${i})`)},Z$=/^-?\d+$/;function Q$(e,t,n,r){let i=e+t;return i>r?e===r?n:r:i<n?e===n?r:n:i}const $$=async(e,t)=>{let[n=``,r=``,i=``]=uq(()=>wa(e)),a=L$(n);if(!r)throw new Z(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!Z$.test(i))throw new Z(`step-state: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=u1(t,a),c=t.gates.state.gateFor(s),l=c.rangeParamsFor(r);if(!l)throw new Z(`step-state: key "${r}" is not a bounded (range) state key (have keys: ${c.listKeys().join(`, `)})`);let u=t.sessionState.get(a,r),d=u&&Z$.test(u)?t1(l,parseInt(u,10)):n1(`step-state`,r,l,YK(s,e=>t.sessionState.get(a,e),r)),f=Q$(d,o,l.min,l.max),p=c.validate(r,String(f));if(!p.ok)throw new Z(`step-state: ${p.reason}`);e1(t,a,`step-state`,[{key:r,value:p.value}]),t.navigating.set(a,r,p.value),t.log(`info`,`step-state: ${r} ${d}→${p.value} (by ${o}, session=${a})`)};function e1(e,t,n,r){let i=r.filter(e=>e.key.startsWith(IN));if(i.length===0)return;let a=RK(u1(e,t),n=>e.sessionState.get(t,n),i);if(a.length>0)throw new Z(`${n}: refused — ${a.join(`; `)}`)}function t1(e,t){return Math.max(e.min,Math.min(e.max,t))}function n1(e,t,n,r){if(r===null)return n.min;if(!Z$.test(r))throw new Z(`${e}: "${t}" shows ${JSON.stringify(r)} before any click, not an integer to step`);return t1(n,parseInt(r,10))}function r1(e,t,n){let r=t.get(n,sq);return r===null?e:{...e,target:{source:`pick`,path:r}}}function i1(e,t){return t===null?{source:`search`}:e===`argument`||e===`environment`?{source:e,path:t}:{source:`unknown`,path:t}}function a1(e){let t;try{t=JSON.parse(e)}catch{throw new Z(`render origin is not JSON: ${e}`)}if(typeof t!=`object`||!t)throw new Z(`render origin is not an object: ${e}`);let{projectDir:n,cwd:r,configFile:i,source:a}=t;if(typeof n!=`string`||typeof r!=`string`||i!==null&&typeof i!=`string`)throw new Z(`render origin has the wrong shape: ${e}`);return{projectDir:n,cwd:r,target:i1(a,i)}}function o1(e,t){let n=c1(e,t);if(n===null)throw new Z(`session ${t} has not rendered yet — no config to act on`);return n}function s1(e,t){let n=e.sessionState.get(t,aq);return n===null?null:a1(n)}function c1(e,t){let n=s1(e,t);return n===null?null:r1(n,e.sessionState,t)}function l1(e,t,n){let r=c1(e,t);if(r===null)return;let{path:i}=p1(e,r);n.some(e=>e.kind===`file`&&e.file===i)&&e.reloadConfig(r)}function u1(e,t){return e.configFor(o1(e,t))}function d1(e,t){let n=s1(e,t);if(n===null)return null;let r=()=>e.lanes.of(r1(n,e.sessionState,t),t);return{sessionId:t,before:r(),read:r}}function f1(e,t){let n=c1(e,t);return n===null?ZK:tq(e.configFor(n))}function p1(e,t){return iU(e.locations,BU(e.stateDir).read(),t.projectDir,t.cwd,t.target.path)}function m1(e,t){return{record:(n,r,i)=>e.journal.file(t,n,r,i),logger:e.log}}const h1=async(e,t)=>{let[n=``,r=``,i=``]=uq(()=>wa(e)),a=L$(n),o=o1(t,a),s=t.configFor(o),c=t.gates.config.gateFor(s);if(!r)throw new Z(`set-config: <key>/<value> is required (have keys: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new Z(`set-config: ${l.reason}`);let u=p1(t,o),d=IK(s,e=>t.sessionState.get(a,e),r);$q(m1(t,a),u,[[d.key,l.value]]),t.reloadConfig(o),t.log(`info`,`set-config: ${d.key}=${l.value} → ${u.path} (session=${a})`)},g1=async(e,t)=>{let[n=``,r=``,i=``]=uq(()=>wa(e)),a=L$(n);if(!r)throw new Z(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!Z$.test(i))throw new Z(`step-config: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=o1(t,a),c=t.configFor(s),l=t.gates.config.gateFor(c),u=l.rangeParamsFor(r);if(!u)throw new Z(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${l.listKeys().join(`, `)})`);let d=p1(t,s),f=IK(c,e=>t.sessionState.get(a,e),r),p=Qq(d.path,f.key),m=typeof p==`number`?t1(u,p):n1(`step-config`,r,u,XK(f.globals,r)),h=Q$(m,o,u.min,u.max),g=l.validate(r,String(h));if(!g.ok)throw new Z(`step-config: ${g.reason}`);$q(m1(t,a),d,[[f.key,g.value]]),t.reloadConfig(s),t.log(`info`,`step-config: ${f.key} ${m}→${g.value} (by ${o}) → ${d.path} (session=${a})`)},_1=async(e,t)=>{let[n=``]=uq(()=>wa(e)),r=L$(n),i=o1(t,r),a=t.configFor(i),o=e=>t.sessionState.get(r,e),s=PK(a,o),c=LK(a,o);if(s.length+c.length===0){t.log(`info`,`save: nothing unsaved (session=${r})`);return}let l=t.gates.state.gateFor(a),u=s.map(e=>{let t=l.validate(e.sessionKey,e.value);if(!t.ok)throw new Z(`save: ${t.reason}`);return[e.target,t.value]});y1(`save`,l,c);let d=p1(t,i);eJ(m1(t,r),d,u,c),t.reloadConfig(i);for(let e of[...s.map(e=>e.sessionKey),...c.map(e=>e.key)])t.sessionState.clear(r,e);t.log(`info`,`save: ${[...u.map(([e,t])=>`${e}=${t}`),...c.map(v1)].join(` `)} → ${d.path} (session=${r})`)},v1=e=>`${e.preset}/${e.id}.settings.${e.setting}=${$y(e.value)}`;function y1(e,t,n){for(let r of n){let n=t.validate(r.key,$y(r.value));if(!n.ok)throw new Z(`${e}: ${n.reason}`)}}const b1=async(e,t)=>{let[n=``]=uq(()=>wa(e)),r=L$(n),i=o1(t,r),a=t.configFor(i),o=VK(a,e=>t.sessionState.get(r,e)),s=t.gates.state.gateFor(a),c=o.picks.map(e=>{let t=s.validate(e.sessionKey,e.value);if(!t.ok)throw new Z(`save-preset: ${t.reason}`);return[e.configKey,t.value]});y1(`save-preset`,s,o.placements);let l=p1(t,i),u=sJ(m1(t,r),l,o.from,o.globals,c,o.placements);t.reloadConfig(i);for(let e of[...Px.map(e=>e.sessionKey),...o.placements.map(e=>e.key)])t.sessionState.clear(r,e);t.sessionState.set(r,Mx.preset.sessionKey,u),t.log(`info`,`save-preset: ${[`${u} from=${o.from}`,...c.map(([e,t])=>`${e}=${t}`),...o.placements.map(v1)].join(` `)} → ${l.path} (session=${r})`)},x1=async(e,t)=>{let[n=``]=uq(()=>wa(e)),r=L$(n),i=o1(t,r),a=UK(t.configFor(i),e=>t.sessionState.get(r,e));if(a.kind===`rule`)throw new Z(`save-theme-default: the theme is chosen by a rule (globals.palette), so there is no name to save as a theme's default — pick one in the menu first`);let o=p1(t,i);cJ(m1(t,r),o,a.theme,a.look),t.reloadConfig(i);let s=new Set(PK(t.configFor(i),e=>t.sessionState.get(r,e)).map(e=>e.sessionKey)),c=Dx.map(e=>Mx[e].sessionKey).filter(e=>!s.has(e));for(let e of c)t.sessionState.clear(r,e);t.log(`info`,`save-theme-default: ${a.theme} ${Dx.map(e=>`${e}=${a.look[e]}`).join(` `)} → ${o.path} (session=${r})`)},S1=async(e,t)=>{let[n=``,r=``]=uq(()=>wa(e)),i=L$(n);if(!r)throw new Z(`delete-preset: <name> is required (shape: <sessionId>/<name>)`);let a=o1(t,i),o=p1(t,a);lJ(m1(t,i),o,r),t.reloadConfig(a);let s=Mx.preset.sessionKey;t.sessionState.get(i,s)===r&&t.sessionState.clear(i,s),t.log(`info`,`delete-preset: ${r} ← ${o.path} (session=${i})`)},C1=async(e,t)=>{let[n=``,...r]=uq(()=>wa(e)),i=L$(n),a=o1(t,i),o=t.gates.config.gateFor(t.configFor(a)).listKeys(),s=r.length===0?[``]:r.filter(e=>!o.includes(e));if(s.length>0)throw new Z(`reset-config: unknown config key "${s.join(`", "`)}" (have: ${o.join(`, `)})`);let c=p1(t,a),l=r.map(WK),u=l.flatMap(e=>e.fileKeys),d=l.flatMap(e=>e.sessionKeys);iJ(m1(t,i),c,u),t.reloadConfig(a);for(let e of d)t.sessionState.clear(i,e);t.log(`info`,`reset-config: ${[...u,...d.map(e=>`session:${e}`)].join(` `)} ← ${c.path} (session=${i})`)};function w1(e,t){let n=(e,t)=>[...Ny(fS(e,t).node)].filter(e=>e.kind===`segment`),r=new Set(lS(t.presets).flatMap(e=>n(t,e).map(t=>LN(hM(e),ky(t)))));return lS(e.presets).flatMap(t=>n(e,t).map(e=>({member:LN(hM(t),ky(e)),node:e})).filter(({member:e})=>!r.has(e)))}function T1(e,t){return e.flatMap(({member:e,node:n})=>[...Object.values(n.drafts??{}).map(e=>e.key),...e===t?[NN]:[]])}const E1=async(e,t)=>{let[n=``,r=``,i=``]=uq(()=>wa(e)),a=L$(n),o=o1(t,a),s=t.configFor(o),c=t.gates.config.gateFor(s);if(!r)throw new Z(`apply-layout-op: <key>/<op> is required (have: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new Z(`apply-layout-op: ${l.reason}`);let u=HR(l.value);if(u===null)throw new Z(`apply-layout-op: "${l.value}" is not a layout op token`);let d=p1(t,o),f=uJ(m1(t,a),d,r,u);t.reloadConfig(o);let p=T1(w1(s,t.configFor(o)),t.sessionState.get(a,NN)).filter(e=>t.sessionState.get(a,e)!==null);for(let e of p)t.sessionState.clear(a,e);t.log(`info`,`apply-layout-op: ${r} ${l.value} → ${d.path} placed=${JSON.stringify(f)} released=${JSON.stringify(p)} (session=${a})`)},D1=async(e,t)=>{let[n=``]=uq(()=>wa(e)),r=L$(n);t.journal.commit();let i=t.history.undo(r);t.journal.wrote(),l1(t,r,i),t.log(`info`,`undo: restored ${FJ(i)} (session=${r})`)},O1=async(e,t)=>{let n=L$(R$(e)),{step:r,discarded:i}=t.navigation.back(n,t.sessionState,t.gates.state.gateFor(u1(t,n))),a=r.map(e=>`${e.key}=${e.before??`∅`}`).join(` `);t.log(`info`,`back: ${a} discarded=${i} (session=${n})`)},k1=async(e,t)=>{let n=L$(R$(e));t.journal.commit(),t.journal.wrote();let r=t.history.rewind(n);l1(t,n,r),t.log(`info`,`rewind: put back ${FJ(r)||`nothing`} as edit mode found it (session=${n})`)},A1=async(e,t)=>{let[n=``]=uq(()=>wa(e)),r=L$(n);t.journal.commit();let i=t.history.redo(r);t.journal.wrote(),l1(t,r,i),t.log(`info`,`redo: re-applied ${FJ(i)} (session=${r})`)},j1=async(e,t)=>{L$(R$(e)),await t.applyUpdate()};function M1(e,t){let n=e.sessionState.get(t,oq);if(n===null)throw new Z(`session ${t} has not rendered yet — no client facts are recorded for it`);let r;try{r=JSON.parse(n)}catch{throw new Z(`client hints record is not JSON: ${n}`)}if(typeof r!=`object`||!r)throw new Z(`client hints record is not an object: ${n}`);return zn(r)}function N1(e,t,n){let r=LF(n);e.sessionState.setBatch(t,eI(r)),e.log(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed(${1+(e.verdict.more?.length??0)})`}`).join(` `)} ${VF(n.config)} ${QF(n.nerdFont,n.marks)} ${HF(n.terminal,n.clicked)} ${UF(n.terminal,n.width)} ${WF(n.install)} ${KF(n.daemon)} ${qF(n.data)} ${ZF(n.transcripts)} ${JF(n.frames,n.claudeSettings)} ${XF(n.claudeSettings.origin.sources)} (session=${t})`)}async function P1(e,t,n,r){let i={kind:`clicked`,sessionId:t,via:e.arrival.via},a=e.clients.ofSession(t,e.now()),o;try{o=await VQ({...n,loadConfig:()=>r},M1(e,t),o1(e,t),n=>e.sessionState.get(t,n),{kind:`ok`,value:e.serving()},{kind:`ok`,value:a.map(e=>e.rateLimits)},{kind:`ok`,value:a.map(e=>e.transcript)},i,{kind:`ok`,value:nY(i,a)},BQ(t,a),pQ(e.doctorStores))}catch(e){throw e instanceof QJ?new Z(e.message):e}let s={facts:o,install:dQ(n.install,e.bundle,a.map(e=>e.client)),current:async e=>{let i=n.loadConfig(o1(e,t));return i.config===r.config&&i.error===r.error&&i.warning===r.warning?s:P1(e,t,n,i)}};return s}const F1=(e,t)=>{let n=mQ(e.doctor);return P1(e,t,n,n.loadConfig(o1(e,t)))};async function I1(e,t,n){let{facts:r,install:i}=await e.gather(n.current),a=pQ(e.doctorStores),o={...r,marks:a.marks,clicked:a.clicked,daemon:{...r.daemon,read:a.postMortemsRead}};return{...o,urlHandler:LQ(e.arrival),install:i,clicked:L1(e,o)}}function L1(e,{terminal:t,clicked:n}){let r=t.kind===`seen`?sF(t.identified):null;if(r===null||e.arrival.via!==`link`)return n;try{return e.doctorStores.clicked.update(e=>XJ(e,r))}catch(t){return e.log(`warn`,`doctor: clicked terminal not filed for ${JSON.stringify(r)}: ${t instanceof Error?t.message:String(t)}`),n}}const R1={gathers:!0,prepare:async(e,t)=>{let n=L$(R$(e)),r=await F1(t,n);return async e=>N1(e,n,await I1(e,n,r))}},z1=async(e,t)=>{let n=l$(R$(e));if(n===null)throw new Z(`doctor-probe: the value is not a probe nonce`);if(t.arrival.via!==`link`)throw new Z(`doctor-probe: a probe arrives only as a link`);let{delivery:r}=t.arrival;t.probes.arrive({nonce:n,delivery:r}),t.log(`info`,`doctor-probe: arrived nonce=${n} delivery=${r.kind}`)},B1={gathers:!0,prepare:async(e,t)=>{let[n=``,r=``]=uq(()=>wa(e)),i=L$(n),a=RF(r);if(a===void 0)throw new Z(`doctor-fix: unknown check "${r}"`);let o=await F1(t,i);return async e=>{let t=await I1(e,i,o),n=a.probe(t);if(n.ok||n.fix===void 0)throw new Z(`doctor-fix: ${a.label} — ${n.ok?`nothing to fix`:n.reason}`);let r=HQ(e.doctorStores,n.fix,t);if(r.kind===`failed`)throw new Z(`doctor-fix: ${a.label} — ${r.reason}`);e.log(`info`,`doctor-fix: ${a.name} → ${Hte(n.fix)} (session=${i})`),N1(e,i,r.value)}}},V1={gathers:!0,prepare:async(e,t)=>{let[n=``,r=``,i=``]=uq(()=>wa(e)),a=L$(n),o=RF(r);if(o===void 0)throw new Z(`doctor-mark: unknown check "${r}"`);if(!dF.includes(i))throw new Z(`doctor-mark: the mark is ${JSON.stringify(i)}, not ${dF.join(` or `)}`);let s=await F1(t,a);return async e=>{let t=await I1(e,a,s),n=o.probe(t);if(n.ok||n.sighting===void 0)throw new Z(`doctor-mark: ${o.label} — ${n.ok?`nothing to mark`:`shows nothing to look at`}`);let r=[o.name,n.sighting.id,i],c=e.doctorStores.marks.update(e=>qJ(e,...r));if(c.kind===`failed`)throw new Z(`doctor-mark: ${c.reason}`);e.log(`info`,`doctor-mark: ${o.name} ${i} on ${n.sighting.id} (session=${a})`),N1(e,a,{...t,marks:c})}}},H1=async(e,t)=>{let[n=``,r=``]=uq(()=>wa(e)),i=L$(n),a=Object.values(t.configFor(o1(t,i)).actions).filter(e=>`slash`in e),o=a.find(e=>e.slash===r);if(o===void 0)throw new Z(`${JSON.stringify(r)} is not a command this config declares (it declares: ${[...new Set(a.map(e=>e.slash))].join(`, `)||`none`})`);let s=await t.typing(M1(t,i).tmux,o.slash);if(s.kind===`refused`)throw t.log(`warn`,`slash: ${r} refused — ${s.reason} (session=${i})`),new Z(`${r} was not typed: ${s.reason}`);t.log(`info`,`slash: typed ${r} into ${s.pane} (session=${i})`)};function U1([e=``,t=``,n=``,r=``],i){let a=L$(e),o=o1(i,a),s=i.configFor(o).actions,c=Object.hasOwn(s,t)?s[t]:void 0;if(c===void 0||!(`run`in c))throw new Z(`"${t}" is not a run action this session's config declares`);let l=TS(c);if(!i.links.verify({sessionId:a,action:t,declaration:l,evaluated:n},r))throw new Z(`the link's signature does not match what it carries: it was not drawn by this daemon, or its action has been edited since it was drawn`);let u;try{u=JSON.parse(n)}catch{throw new Z(`run ${t}: what the link carries is not JSON`)}let[d,...f]=u.run;if(d===void 0||d===``)throw new Z(`run ${t}: the program evaluated to nothing`);let p=i.sourcesFor(o);return{sessionId:a,action:t,argv:[d,...f],envOverlay:{...WJ({sessionId:a,projectDir:o.projectDir,claudeConfigDir:M1(i,a).claudeConfigDir}),...u.env},cwd:c.cwd??i.locations.home,refreshes:c.refreshes.map(e=>({name:e,storage:p.get(e)}))}}const W1=new Map([[Ki,I$(W$)],[Yi,I$(async(e,t)=>{let n=e.indexOf(`/`);if(n===-1)throw new Z(`load-config: expected <sessionId>/<path> (missing separator)`);let r=L$(uq(()=>decodeURIComponent(e.slice(0,n)))),i=uq(()=>decodeURIComponent(e.slice(n+1))).trim();if(i!==``){if(!i.startsWith(`/`))throw new Z(`load-config: path must be absolute, got "${i}"`);if(!/\.(json5?|json)$/.test(i))throw new Z(`load-config: path must end with .json5 or .json, got "${i}"`)}i===``?(t.sessionState.clear(r,sq),t.log(`info`,`load-config: override cleared (session=${r})`)):(t.sessionState.set(r,sq,i),t.log(`info`,`load-config: ${i} (session=${r})`))})],[qi,I$(J$)],[Wi,I$(X$)],[Gi,I$($$)],[Xi,I$(h1)],[Zi,I$(g1)],[na,I$(C1)],[Qi,I$(_1)],[$i,I$(b1)],[ea,I$(x1)],[ta,I$(S1)],[ra,I$(E1)],[ia,I$(D1)],[aa,I$(A1)],[oa,I$(O1)],[sa,I$(k1)],[Ji,I$(Y$)],[ca,I$(j1)],[la,R1],[ua,B1],[da,V1],[fa,I$(z1)],[pa,I$(H1)],[`run`,I$(async(e,t)=>{let n={sessionId:`-`,action:`-`},r;try{let i=uq(()=>wa(e));n={sessionId:i[0]||`-`,action:i[1]||`-`},r=U1(i,t)}catch(e){throw e instanceof Z&&t.runs.refused(n.sessionId,n.action,e.message),e}t.runs.start(r)})],[ma,I$(async(e,t)=>{let[n=``,r=``,i=``,a=``]=uq(()=>wa(e)),o=L$(n),s=i;if(!t.links.verify(HU(o,r,s),a))throw new Z(`the answer's signature does not match what it carries: it was not drawn by this daemon`);let c=VU(BU(t.stateDir),r,s);if(c.kind===`failed`)throw Error(`${r} was not ${s}: ${c.reason}`);t.journal.wrote();let{superseded:l,absent:u,unchecked:d}=c.value;t.log(`info`,`repo-config: ${r} ${s} superseded=${l.join(`,`)||`-`} absent=${u.join(`,`)||`-`} unchecked=${d.length===0?`-`:JSON.stringify(d)} (session=${o})`),t.reloadConfig(o1(t,o))})],[ha,I$(q$)]]),G1=new Set([Wi,Gi,Xi,Zi,na,Qi,$i,ea,ta,ra,ia,aa,oa,sa,Ji,ca,la,ua,da,pa,`run`,ma,Yi,ha]);function K1(e,t){return q1(e===`dispatch`?Da(t):[{verb:e,value:t}])}function q1(e){let t=e.find(e=>G1.has(e.verb)),n=t===void 0?``:uq(()=>Ta(t.value));return n===``?null:P$(n)}const J1=(e,t,n)=>n.journalTurns.gathering(()=>e.prepare(t,n)).catch(e=>()=>Promise.reject(e));async function Y1(e,t,n,r){await(r??await n.gather(n=>e.prepare(t,n)))(n)}async function X1(e,t){let[n]=ka(Da(e)),r=n===void 0?void 0:W1.get(n.verb);return r?.gathers?J1(r,n.value,t):void 0}async function Z1(e,t,n){let r=[],i=!1,a=Da(e),o=q1(a);for(let[e,{verb:o,value:s}]of ka(a).entries()){let a=W1.get(o);if(!a){r.push(`unknown effect verb "${o}"`);continue}try{await Y1(a,s,t,e===0?n:void 0)}catch(e){if(e instanceof cq)throw r.length>0&&t.log(`warn`,`dispatch: ${r.join(`; `)}`),e;e instanceof Z||(i=!0),r.push(`${o}: ${e instanceof Error?e.message:String(e)}`)}}if(r.length>0){o?.ok&&Sc(t.sessionState,o.id,r.join(`
479
- `),t.now());let e=`dispatch: ${r.join(`; `)}`;throw i?Error(e):new Z(e)}}function Q1(e){if(e.length===1)throw e[0];if(e.length>1)throw Error(e.map(e=>String(e.message??e)).join(`; `))}async function $1(e,t,n,r){let i=e===null?null:d1(t,e),a=t.history.begin(),o=t.navigation.begin(a.sessionState),s=n.holds(()=>{let e=[];for(let t of[o,a])try{t.commit()}catch(t){e.push(t)}Q1(e)}),c=[],l=e=>iq(e,e=>f1(t,e),e=>t.log(`info`,e)),u={...t,sessionState:l(a.sessionState),journal:a,navigating:l(o.sessionState)},d={launch:(e,r)=>n.landed(V$(t.launcher,e,r,t.log)),typing:(e,r)=>n.landed(O$(t.claudeInput,e,r)),applyUpdate:()=>n.landed(t.applyUpdate())};try{await r({...u,...d,gather:e=>n.landed(e(u))})}catch(e){c.push(e)}let f=!0;try{f=s()}catch(e){c.push(e)}if(f&&i!==null)try{let e=i.read();t.lanes.clicked(i.sessionId,a.written()?i.before:e,e)}catch(e){c.push(e)}if(f&&e!==null)try{let n=c1(t,e);n!==null&&t.views.follow(e,n)}catch(e){c.push(e)}Q1(c)}function e0(e,t,n){return async(r,i)=>{let a=K1(e,r),o=a?.ok?a.id:null;return i.journalTurns.click(e,o,{placed:i.placeWaited,waited:i.turnWaited,gone:i.clientGone,gathered:i.gatherTook},()=>t(r,i),(e,t)=>$1(o,i,t,async t=>{try{await n(r,t,e)}finally{o!==null&&i.clickLanded(o)}}))}}const t0=new Map([...[...W1].map(([e,t])=>[e,e0(e,async(e,n)=>t.gathers?J1(t,e,n):void 0,(e,n,r)=>Y1(t,e,n,r))]),[Ui,e0(Ui,X1,Z1)],[fa,z1]]);Object.freeze([...t0.keys()]);function n0(e,t,n){return n.journalTurns.take(`menu-idle`,{waited:t=>n.log(`info`,`menu-idle: waited=${t}ms (session=${e})`),gone:()=>!1},r=>$1(e,n,r,async n=>{if(!t.stillIdle()){n.log(`info`,`menu-idle: no longer idle, kept (session=${e})`);return}t.closed();let r=rq(f1(n,e),t=>n.navigating.get(e,t));n.navigating.setBatch(e,r.map(({key:e})=>({key:e,value:gi}))),n.log(`info`,`menu-idle: closed=${r.map(({key:e})=>e).join(`,`)||`-`} idle=${t.idleS.toFixed(1)}s timeout=${t.timeoutS}s (session=${e})`)}))}function r0({projectDir:e,cwd:t,target:n}){return JSON.stringify({projectDir:e,cwd:t,configFile:n.path??null,source:n.source})}function i0(e,t){return e===void 0?!0:e.evaluate(t).map(e=>e.plain).join(``)!==`false`}const a0={kind:`hidden`},o0={kind:`shown`};function s0(e,t){try{return i0(e,t)?o0:a0}catch(e){let t=TC(e);return t===void 0?{kind:`failed`,message:e instanceof Error?e.message:String(e)}:{kind:`pending`,variable:t.variable}}}function c0(e,t){let n=K.fromFragments(e);return n.end=``,n.overflow=`ignore`,t!==void 0&&!t.isNull&&(n.style=t),n}function l0(e,t,n){e.cellLength>t?e.truncate(t,{mode:n.truncate,marker:`…`}):e.cellLength<t&&e.align(n.justify,t)}function u0({lead:e,text:t,trail:n}){return[...e===void 0?[]:[e],t,...n===void 0?[]:[n]]}function d0({text:e,placement:t,lead:n,trail:r}){return{text:f0(e),placement:t,...n!==void 0&&{lead:f0(n)},...r!==void 0&&{trail:f0(r)}}}function f0(e){let t=e.blankCopy(e.plain);t.style=hP(e.style).clearMetaAndLinks();for(let{start:n,end:r,style:i}of e.spans)t.stylize(hP(i).clearMetaAndLinks(),n,r);return t}function p0(e){let t=u0(e);if(t.length===1)return e.text;let n=c0(t);return n.style=e.text.style,n}function m0(e,t){let{width:n,justify:r,truncate:i,baseStyle:a,padding:o,placement:s,lead:c=[],trail:l=[]}=t;if(e.length===0)return[];let u=c0(e,a).pad(o),d=new K(` `.repeat(o)),f={placement:s,...c.length>0&&{lead:c0([d,...c],a)},...l.length>0&&{trail:c0([...l,d],a)}};if(n===`auto`)return[{text:u,...f}];let p={justify:r,truncate:i};return n===`fill`?[{text:u,fill:p,...f}]:(l0(u,n,p),[{text:u,...f}])}function h0(e,t,n){let r=`x`.repeat(Math.min(n,t)).replace(/x$/,` `),i=r+e,a=[],o=0;return Ste(i,t).forEach(e=>{let t=e.trimEnd(),n=i.indexOf(t,o);t!==``&&n>r.length&&a.push(n-r.length),o=n+t.length}),a}function g0(e,t){if(e.length===0)return 0;let{lines:n}=XP(e.map(({owner:e})=>e),t),r=z(BP(n[n.length-1]));return Math.max(0,r-KP(t)+qP(t))}function _0(e,t,n){if(e.cellLength<=t)return!0;let{lines:r}=XP([e],{...n,width:1/0});return z(BP(r.flat()))<=n.width}function v0(e,t,n,r){if(_0(e.owner,t,r))return[e];let i=e.owner.copy().expandTabs(),a=g0(n,r);return i.divide(h0(i.plain,t,a)).map((n,i)=>({...e,owner:n.truncate(t,{marker:``}).padLeft(i>0?r.padding:0)})).filter(({owner:e},t,{length:n})=>n===1||e.plain.trim()!==``)}function y0(e,t){let n=Math.max(2,YP(t)-KP(t)-t.padding);return b0(e,t).reduce((e,r)=>[...e,...v0(r,n,e,t)],[])}function b0(e,t){let n=()=>e.map(e=>({owner:p0(e),placement:e.placement})),r=[];if(e.forEach(({fill:e},t)=>{e!==void 0&&r.push({at:t,how:e})}),r.length===0||!Number.isFinite(t.width))return n();let i=XP(e.map(p0),t).lines;if(i.length>1)return n();let a=Math.max(0,t.width-z(BP(i.flat()))),o=Math.floor(a/r.length),s=a-o*r.length;return r.forEach(({at:t,how:n},i)=>{let a=o+(i===r.length-1?s:0),{text:c}=e[t];l0(c,c.cellLength+a,n)}),n()}function x0(e,t){let n=[],r=[],i=()=>{if(!r.length)return;let e=S0(r,t);e.plain.length>0&&n.push(e),r=[]};for(let a of e){let e={frag:a,style:hP(a.style)};if(e.style.link){i();let r=S0([e],t);r.plain.length>0&&n.push(r)}else r.push(e)}return i(),n}function S0(e,t){let n=t!==void 0&&!t.isNull?t:void 0,r=e.map(e=>C0(e.frag,n?n.add(e.style):e.style)),i=K.fromFragments(r);return i.end=``,i.overflow=`ignore`,r.length===1?i.style=r[0].style:n!==void 0&&(i.style=n),i}function C0(e,t){let n=e.copy();return n.style=t,n}function w0(e,t){if(e.bound===void 0)throw Error(`${t} ran outside a render: no render bound its store and clocks`);return e.bound}function T0(e,t){let{look:n}=w0(e,t);if(n===void 0)throw Error(`${t} read the render's look before it was resolved`);return n}function E0(e,t){let{layout:n}=w0(e,t);if(n===void 0)throw Error(`${t} read the render's rows before they were laid`);return n()}function D0(e,t){if(e.bound!==void 0)throw Error(`a render bound a compile another render holds`);return e.bound=t,{[Symbol.dispose]:()=>{e.bound=void 0}}}function O0(e,t,n,r){let i=new Map,a=Object.entries(t);for(let[t,o]of[...a.filter(([,e])=>!(`do`in e)),...a.filter(([,e])=>`do`in e)])i.set(t,k0(e,t,o,n,r,i));return i}function k0(e,t,n,r,i,a){if(`set`in n){let e=r.get(n.set)??n.set;if(`to`in n)return{kind:`set-literal`,key:n.set,value:n.to,stateVar:e};if(`from`in n){let t=xS(n.from,i);return{kind:`set-option`,key:n.set,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,labelOf:t.labelOf,library:t.library}}return`int`in n?{kind:`set-int`,key:n.set,stateVar:e}:`cycle`in n?{kind:`set-cycle`,key:n.set,stateVar:e,members:n.cycle}:{kind:`set-bounded`,key:n.set,by:n.by}}if(`persist`in n){let e=Ix.get(n.persist)??n.persist;if(`to`in n)return{kind:`persist-literal`,key:n.persist,value:n.to,stateVar:e};if(`from`in n){let t=xS(n.from,i);return{kind:`persist-option`,key:n.persist,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,labelOf:t.labelOf,library:t.library}}if(`cycle`in n)return{kind:`persist-cycle`,key:n.persist,stateVar:e,members:n.cycle};if(`removeSegment`in n)return{kind:`layout-op`,key:n.persist,op:{op:`remove`,target:n.removeSegment}};if(`insertSegment`in n)return{kind:`layout-op`,key:n.persist,op:{op:`insert`,segment:n.insertSegment,anchor:n.anchor,relation:n.relation}};if(`insertSegmentFrom`in n){let e=xS(n.insertSegmentFrom,i);return{kind:`layout-op-option`,key:n.persist,anchor:n.anchor,relation:n.relation,options:[...e.members],paletteOf:e.paletteOf,labelOf:e.labelOf,library:e.library}}return{kind:`persist-bounded`,key:n.persist,by:n.by}}if(`copy`in n)return{kind:`copy`,text:M0(e,n.copy,t)};if(`open`in n)return{kind:`open`,target:M0(e,n.open,t)};if(`reset`in n)return{kind:`reset`,key:n.reset};if(`doctor`in n)switch(n.doctor){case`run`:return{kind:`doctor-run`};case`fix`:return{kind:`doctor-fix`,check:n.check};case`mark`:return{kind:`doctor-mark`,check:n.check,mark:n.mark}}if(`slash`in n)return{kind:`slash`,line:n.slash};if(`run`in n)return{kind:`run`,name:t,declaration:TS(n),argv:n.run.map(n=>M0(e,n,t)),env:Object.entries(n.env).map(([n,r])=>[n,M0(e,r,t)])};if(`undo`in n)return{kind:`undo`};if(`redo`in n)return{kind:`redo`};if(`back`in n)return{kind:`back`};if(`rewind`in n)return{kind:`rewind`};if(`save`in n)return{kind:`save`};if(`preset`in n)return n.preset===`save`?{kind:`preset-save`}:{kind:`preset-delete`,name:M0(e,n.name,t)};if(`themeDefault`in n)return{kind:`theme-default-save`};let[o,...s]=n.do.map(e=>{let n=a.get(e);if(n===void 0)throw Error(`action "${t}" fires "${e}", which is not declared in this config`);return n});return{kind:`do`,head:o,rest:s}}function A0(e){return e.kind===`do`?A0(e.head):e}function j0(e){switch(A0(e).kind){case`set-option`:case`set-int`:case`persist-option`:case`layout-op-option`:return!0;case`set-literal`:case`set-bounded`:case`set-cycle`:case`copy`:case`open`:case`persist-literal`:case`persist-bounded`:case`persist-cycle`:case`reset`:case`layout-op`:case`undo`:case`redo`:case`back`:case`rewind`:case`save`:case`preset-save`:case`preset-delete`:case`theme-default-save`:case`doctor-run`:case`doctor-fix`:case`doctor-mark`:case`slash`:case`run`:case`do`:return!1}}function M0(e,t,n){try{return e(t)}catch(e){throw Error(`Template parse error in actions.${n}: ${e.message}`,{cause:e})}}function N0(e,t){return e.has(t)?xC(e.read(t)):``}function P0(e,t){return e.evaluate(t).map(e=>e.plain).join(``)}function F0(e,t,n,r){let i=new K(e,{style:U.combine([r,new U({link:t,bold:n})])});return i.overflow=`ignore`,i.end=``,i}function I0(e,t,n=!1){let r=new U({link:t,bold:n?!0:void 0}),i=new K(e.plain,{style:U.combine([hP(e.style),r])});for(let t of e.spans)i.stylize(U.combine([hP(t.style),r]),t.start,t.end);return i.overflow=`ignore`,i.end=``,i}function L0(e,t){return Math.max(e.members.indexOf(N0(t,e.stateVar)),0)}function R0(e,t,n,r,i,a){switch(e.kind){case`set-literal`:{let t=N0(r,e.stateVar);return{effects:[{verb:Wi,args:[i,e.key,e.value]}],active:t===e.value}}case`set-option`:{let a=n??t,o=N0(r,e.stateVar);return{effects:[{verb:Wi,args:[i,e.key,a]}],active:o===a}}case`set-int`:{let a=n??t,o=N0(r,e.stateVar);return{effects:[{verb:Wi,args:[i,e.key,a]}],active:o===a}}case`set-cycle`:{let t=e.members[(L0(e,r)+1)%e.members.length];return{effects:[{verb:Wi,args:[i,e.key,t]}],active:!1}}case`set-bounded`:return{effects:[{verb:Gi,args:[i,e.key,String(e.by)]}],active:!1};case`copy`:return{effects:[{verb:Ki,args:[P0(e.text,JA(r))]}],active:!1};case`open`:return{effects:[{verb:qi,args:[P0(e.target,JA(r))]}],active:!1};case`persist-literal`:{let t=N0(r,e.stateVar);return{effects:[{verb:Xi,args:[i,e.key,e.value]}],active:t===e.value}}case`persist-option`:{let a=n??t,o=N0(r,e.stateVar);return{effects:[{verb:Xi,args:[i,e.key,a]}],active:o===a}}case`persist-cycle`:{let t=e.members[(L0(e,r)+1)%e.members.length];return{effects:[{verb:Xi,args:[i,e.key,t]}],active:!1}}case`persist-bounded`:return{effects:[{verb:Zi,args:[i,e.key,String(e.by)]}],active:!1};case`reset`:return{effects:[{verb:na,args:[i,e.key]}],active:!1};case`undo`:return{effects:[{verb:ia,args:[i]}],active:!1};case`redo`:return{effects:[{verb:aa,args:[i]}],active:!1};case`back`:return{effects:[{verb:oa,args:[i]}],active:!1};case`rewind`:return{effects:[{verb:sa,args:[i]}],active:!1};case`save`:return{effects:[{verb:Qi,args:[i]}],active:!1};case`preset-save`:return{effects:[{verb:$i,args:[i]}],active:!1};case`theme-default-save`:return{effects:[{verb:ea,args:[i]}],active:!1};case`preset-delete`:return{effects:[{verb:ta,args:[i,P0(e.name,JA(r))]}],active:!1};case`doctor-run`:return{effects:[{verb:la,args:[i]}],active:!1};case`doctor-fix`:return{effects:[{verb:ua,args:[i,e.check]}],active:!1};case`doctor-mark`:return{effects:[{verb:da,args:[i,e.check,e.mark]}],active:!1};case`slash`:return{effects:[{verb:pa,args:[i,e.line]}],active:!1};case`run`:{let t=JA(r),n=JSON.stringify({run:e.argv.map(e=>P0(e,t)),env:Object.fromEntries(e.env.map(([e,n])=>[e,P0(n,t)]))}),o=a.sign({sessionId:i,action:e.name,declaration:e.declaration,evaluated:n});return{effects:[{verb:`run`,args:[i,e.name,n,o]}],active:!1}}case`layout-op`:return{effects:[{verb:ra,args:[i,e.key,VR(e.op)]}],active:!1};case`do`:{let o=R0(e.head,t,n,r,i,a);return{effects:[...o.effects,...e.rest.flatMap(e=>R0(e,t,void 0,r,i,a).effects)],active:o.active}}case`layout-op-option`:{let r={op:`insert`,segment:n??t,anchor:e.anchor,relation:e.relation};return{effects:[{verb:ra,args:[i,e.key,VR(r)]}],active:!1}}}}function z0(e,t,n,r){if(n.length===0)throw Error(`action "${e}" needs a display (the clickable text)`);if(t.kind===`set-cycle`||t.kind===`persist-cycle`)return{display:bi(`action "${e}"`,n,t.members.length,L0(t,r)),boundValue:void 0};if(n.length>2)throw Error(`action "${e}" takes a display and an optional bound value, got ${n.length} arguments (per-state displays are a cycle action's form)`);return{display:n[0],boundValue:n[1]?.plain}}function B0(e,t,n){let r=n.compiled.get(e);if(!r)throw Error(`action "${e}" is not declared in this config`);let i=w0(n,`action "${e}"`).store,{display:a,boundValue:o}=z0(e,A0(r),t,i),s=N0(i,`session.id`),{effects:c,active:l}=R0(r,a.plain,o,i,s,n.signer);return I0(a,Ea(c),l)}function V0(e){return{action:{fn:(t,...n)=>B0(t,n,e),argTypes:[`string`,`liftable`],arity:{kind:`variadic`},returnType:`T`}}}function H0(e,t){return F0(`✕`,Ea([{verb:Wi,args:[N0(e,`session.id`),t,gi]}]),!1)}function U0(e,t,n){return new U({bgcolor:H.fromRgba(t),color:H.fromRgba(vv(e,t,n))})}function W0({tint:e,text:t}){return new U({bgcolor:H.fromRgba(e),color:H.fromRgba(t)})}function G0(e,t,n){return new U({color:H.fromRgba(Qu(e.get(`warning`),t,_v,n))})}function K0(e,t,n){return U.combine([U0(e,t,n),G0(e,t,n)])}function q0(e,t,n){return W0(Av(e.palette,e.disclosure,t,n))}function J0(e){let t=H.fromRgba(e.get(`background`)),n=K.fromFragments(b_.map(n=>new K(`▀`,{style:new U({color:H.fromRgba(e.get(n)),bgcolor:t})})));return n.overflow=`ignore`,n.end=``,n}const Y0=(e,t)=>{let n=typeof e==`string`?new K(e,{style:t}):e;return n.overflow=`ignore`,n.end=``,n},X0=e=>new U({bold:e});function Z0(e,t,n,r,i,a){if(r===void 0)return(n,r,a,o)=>Y0(a,U.combine([q0(e,{...n,distribution:t},i),X0(o)]));let o=U0(e.palette,a,i);return(e,t,i,a)=>Q0(i,U.combine([o,X0(a)]),r(t,n))}const Q0=(e,t,n)=>Y0(K.fromFragments([Y0(e,t),Y0(` `,t),J0(n)]));function $0(e,t,n,r){return t===void 0?Y0(r):Q0(r,void 0,t(n,e))}function e2(e,t,n,r,i){let a=U0(e.palette,i,r);return(e,r,i,o)=>Y0(K.fromFragments([Y0(o?`[`:` `,a),J0(n(r,t)),Y0(o?`]`:` `,a)]))}function t2(e,t,n){let r=t.map(t=>({label:t.label,indices:e.flatMap((e,n)=>e.group===t.id?[n]:[])})).filter(e=>e.indices.length>0);if(r.reduce((e,t)=>e+t.indices.length,0)!==e.length){let n=new Set(t.map(e=>e.id)),r=e.flatMap((e,t)=>n.has(e.group)?[]:[`#${t} (group "${e.group}")`]);throw Error(`library: ${r.join(`, `)} name a group the domain does not list (${[...n].join(`, `)})`)}return n?r.flatMap(e=>n2(e.indices,8).map(t=>[{label:e.label,indices:t}])):[r]}function n2(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))}function r2(e,t){return new K(e).truncate(t,{marker:`…`}).plain}function i2(e){return{current:null,drawnAt:e}}function a2(e,t,n,r,i,a,o){let s={segName:t,placementId:n,palette:r,disclosure:i,tint:a,text:o,bg:void 0,drops:[]};return e.current=s,s}function o2(e,t,n){return c2(e,()=>n(a2(e,t.segName,t.placementId,t.palette,t.disclosure,t.tint,t.text)))}function s2(e,t){return c2(e,()=>(e.current=null,t()))}function c2(e,t){let n=e.current;try{return t()}finally{e.current=n}}function l2(e,t){let n=e.current;if(n===null)throw Error(`${t} is only available inside a segment's templates — there is no active segment here. Segment-scoped functions cannot be used in variable declarations or layout-node "when" predicates, which are evaluated outside any segment.`);return n}function u2(e){return new K(e).cellLength}function d2(e){let{width:t,chromeCols:n,padding:r}=w0(e,`a row fit`);return Math.max(1,t-n-2*r)}function f2(e){let{padding:t,seamCols:n}=w0(e,`a row fit`);return Math.max(1,d2(e)-(u2(`✕`)+2*t+n))}function p2(e,t,n){if(!Number.isFinite(t))return e.length>0?[e.map((e,t)=>t)]:[];let r=Math.max(1,t-n),i=[],a=[],o=0;for(let t=0;t<e.length;t++){let n=e[t];a.length===0?(a=[t],o=n):o+1+n<=r?(a.push(t),o+=1+n):(i.push(a),a=[t],o=n)}return a.length>0&&i.push(a),i}function m2(e,t,n){let r=u2(`←`)+1+u2(`→`)+1,i=p2(e,t,n);return(i.length>1?p2(e,t,n+r):i).map(e=>[{label:``,indices:e}])}function h2(e){let t=[];for(let n of e)t.length>0&&t.push(new K(` `)),t.push(n);let n=K.fromFragments(t);return n.overflow=`ignore`,n.end=``,n}function g2(e,t,n,r,i){let a=e.compiled.get(t);if(!a||a.kind!==n)throw Error(`${i} references action "${t}" which must be ${r}, got ${a?`a ${a.kind} action`:`no such action`}`);return a}function _2(e,t,n){let r=e.compiled.get(t),i=r&&A0(r);if(!i||i.kind!==`set-option`&&i.kind!==`persist-option`&&i.kind!==`layout-op-option`)throw Error(`${n} references action "${t}" which must be a set-option, persist-option, or layout-op-option action ({ set, from }, { persist, from }, or { persist, insertSegmentFrom, anchor, relation }), got ${i?`a ${i.kind} action`:`no such action`}`);return i}function v2(e,t,n,r,i,a,o,s,c=[]){let l=a.compiled.get(e),u=w0(a,`picker`).store,d=N0(u,`session.id`),f=`stateVar`in t?N0(u,t.stateVar):void 0,p=(e,n)=>{let r=t.options[e];return o({index:e,count:t.options.length},r,n,r===f)},m=i?r.kind===`led`?f2(a):d2(a):1/0,h=(r.kind===`led`?0:u2(`✕`)+1)+c.reduce((e,t)=>e+u2(t.glyph)+1,0),g=t.library&&{groups:t.library.groups,entries:t.options.map(t.library.entry)},_=t.labelOf??(e=>e),v=g===void 0?t.options.map((e,t)=>p(t,_(e))):[],y=g===void 0?m2(v.map(e=>e.cellLength),m,h):t2(g.entries,g.groups,i),b=parseInt(N0(u,n.stateVar),10),x=e=>Math.max(0,y.findIndex(t=>t.some(t=>t.indices.includes(e)))),S=x(f===void 0?-1:t.options.indexOf(f)),C=Number.isInteger(b)?b<0?S:Math.min(b,y.length-1):0,w=y[C]??[],T=e=>Ea([{verb:Wi,args:[d,n.key,String(e)]}]),ee=r.kind===`led`?[]:[{verb:Wi,args:[d,...r.writes.flatMap(([e,t])=>[e,t])]}],te=r.kind===`own`&&r.onPick?ee:[],E=e=>Ea([...R0(l,e,e,u,d,a.signer).effects,...te]),ne=(e,n)=>I0(e,E(t.options[n])),D=r.kind===`led`?[]:[F0(`✕`,Ea(ee),!1,s)];D.push(...c.map(({glyph:e,option:r})=>F0(e,Ea([...R0(l,r,r,u,d,a.signer).effects,{verb:Wi,args:[d,n.key,String(x(t.options.indexOf(r)))]}]),!1))),C>0&&D.push(F0(`←`,T(C-1),!1));let re=C<y.length-1?[F0(`→`,T(C+1),!1)]:[];if(g===void 0){let e=w.flatMap(e=>e.indices);return[h2([...D,...e.map(e=>ne(v[e],e)),...re])]}let ie=new U({bold:!0}),O=y.length>1?` ${C+1}/${y.length}`:``,ae=w.length===1?[new K(`${w[0].label}${O}`,{style:ie})]:[],oe=[h2([...D,...ae,...re])];for(let e of w){w.length>1&&oe.push(h2([new K(e.label,{style:ie})]));let n=Math.max(...e.indices.map(e=>u2(_(t.options[e]))));for(let r of e.indices){let e=_(t.options[r]),i=g.entries[r].description,a=i===void 0?void 0:AP(i),o=` `.repeat(n-u2(e)+2),s=a===void 0?e:`${e}${o}${a}`;oe.push(h2([ne(p(r,r2(s,m)),r)]))}}return oe}function y2(e,t){return{picker:{fn:(n,r,i,a,o,...s)=>{EA(`picker "${n}"`,[`closeOnPick`,`paged`,`inBody`],s);let c=g2(e,r,`set-int`,`an int action ({ set, int: true })`,`picker`);if(o===!0&&i===!0)throw Error(`{{ picker "${n}" … }} sets both closeOnPick and inBody; a picker in a body is closed by the body's ✕, so it has no close to fold into a pick`);let l=_2(e,n,`picker`),u=l2(t,`{{ picker }}`);if(u.bg===void 0)throw Error(`{{ picker }} is not available while segments.${u.segName}'s own "bg:" is being evaluated — a picker is drawn on that background`);let d=t.drawnAt(),f=t=>v2(n,l,{key:c.key,stateVar:c.stateVar},o===!0?{kind:`led`}:{kind:`own`,writes:[[c.key,`-1`]],onPick:i===!0},a===!0,e,Z0(u,nv(void 0),T0(e,`{{ picker }}`),l.paletteOf,d,t),G0(u.palette,t,d)),p=Ov(u.palette,u.disclosure,d),[,...m]=l.library===void 0?[]:f(p.plane);return m.length===0?f(u.bg)[0]:(u.drops.push(...m),f(p.state)[0])},argTypes:[`string`,`string`,`bool`],arity:{kind:`variadic`},returnType:`T`}}}function b2(e,t){let n=e.length,r=Math.max(e.indexOf(t),0);return e=>((r+e)%n+n)%n}function x2(e,t,n,r,i){if(!(`stateVar`in t))throw Error(`carousel references action "${e}", which inserts a segment and holds no current value to centre on — a carousel needs a { set, from } or { persist, from } action`);let a=w0(i,`carousel`).store;if(!a.has(t.stateVar))throw Error(`carousel references action "${e}", whose key "${t.stateVar}" no variable reads back, so there is no current value to centre on — declare { kind: "state", key: "${t.stateVar}" } among the variables`);let o=i.compiled.get(e),s=N0(a,`session.id`),{options:c}=t;if(c.length===0)return h2([]);let l=b2(c,N0(a,t.stateVar)),u=e=>c[l(e)],d=e=>Ea(R0(o,u(e),u(e),a,s,i.signer).effects);return h2([F0(`◀`,d(-1),!1),I0($0(T0(i,`{{ carousel }}`),t.paletteOf,u(0),r),Ea(R0(i.compiled.get(n),u(0),void 0,a,s,i.signer).effects)),F0(`▶`,d(1),!1)])}function S2(e){return{carousel:{fn:(t,n,r)=>{if(r.trim()===``)throw Error(`carousel "${t}": label is empty`);if(!e.compiled.has(n))throw Error(`carousel "${t}": open must name a declared action, got ${JSON.stringify(n)}`);if(j0(e.compiled.get(n)))throw Error(`carousel "${t}": open "${n}" writes a value the template binds, and the label binds none — name an action that writes a fixed value, a cycle, or a do of them`);return x2(t,_2(e,t,`carousel`),n,r,e)},argTypes:[`string`,`string`,`string`],arity:{kind:`exact`},returnType:`T`}}}function C2(e,t,n){let r=_2(e,t,n);if(!(`stateVar`in r))throw Error(`${n} references action "${t}", which inserts a segment and holds no current value — a ${n} needs a { set, from } or { persist, from } action`);if(r.paletteOf===void 0)throw Error(`${n} references action "${t}", whose options are not colour-valued — a swatch draws the palette an option puts in force, as the "themes", "placementThemes" and "styles" domains do`);return r}function w2(e,t,n){let r=Math.imul(e^e>>>16,73244475);return r=Math.imul(r^r>>>16,73244475),r^=r>>>16,(n+1+(r>>>0)%Math.max(t-1,1))%t}function T2(e,t,n,r){let i=C2(e,t,n),a=r??N0(w0(e,n).store,i.stateVar);if(!i.options.includes(a))throw Error(`${n} "${t}": "${a}" is not one of its options, so it has no palette to draw`);return i.paletteOf(a,T0(e,`{{ ${n} }}`))}function E2(e){return{swatch:{fn:(t,...n)=>{let[r,...i]=n;if(EA(`swatch "${t}"`,[`option`],i),r!==void 0&&typeof r!=`string`)throw Error(`swatch "${t}": option must be text, got ${JSON.stringify(r)}`);return J0(T2(e,t,`swatch`,r))},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function D2(e,t,n){return{swatches:{fn:(r,i)=>{let a=C2(e,r,`swatches`),o=g2(e,i,`set-int`,`an int action ({ set, int: true })`,`swatches`),s=l2(t,`{{ swatches }}`);if(s.bg===void 0)throw Error(`{{ swatches }} is not available while segments.${s.segName}'s own "bg:" is being evaluated — a swatch row is drawn on that background`);let c=t.drawnAt(),{options:l}=a,u=l.length,[d]=v2(r,a,{key:o.key,stateVar:o.stateVar},{kind:`led`},!0,e,e2(s,T0(e,`{{ swatches }}`),a.paletteOf,c,s.bg),G0(s.palette,s.bg,c),u===0?[]:(()=>{let t=b2(l,N0(w0(e,`swatches`).store,a.stateVar));return[{glyph:`◀`,option:l[t(-1)]},{glyph:`?`,option:l[w2(n().getTime(),u,t(0))]},{glyph:`▶`,option:l[t(1)]}]})());return d},argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`T`}}}const O2=[`~/code`,`main`,`opus`,`42%`,`5m`,`$1.20`];function k2(e,t,n,r){let i=Ov(e,n,r),a=(t,n)=>({text:t,colour:n,ink:vv(e,n,r)});return[[H_(e,t,r).map((n,i)=>{let a=gv(e,n);return{text:O2[i%O2.length],colour:a,ink:t.shade.text(e,n.hue,a,r)}})],[[a(`▾ open`,i.state),a(`menu`,i.plane)],[a(`warn`,e.get(`warning`)),a(`error`,e.get(`error`))]]]}function A2(e,t){let n=e.flatMap((e,t)=>e.map(({text:e,colour:n,ink:r},i)=>({gap:t>0&&i===0?` `:``,cell:new K(` ${e} `,{style:W0({tint:n,text:r})})}))),r=[],i=0;for(let{gap:e,cell:a}of n){if(i+=e.length+a.cellLength,i>t)break;e!==``&&r.push(new K(e)),r.push(a)}return r}function j2(e,t,n,r,i){let a=k2(e,t,n,r).map(e=>A2(e,i)),o=K.fromFragments(a.flatMap((e,t)=>t===0?e:[new K(`
479
+ `),t.now());let e=`dispatch: ${r.join(`; `)}`;throw i?Error(e):new Z(e)}}function Q1(e){if(e.length===1)throw e[0];if(e.length>1)throw Error(e.map(e=>String(e.message??e)).join(`; `))}async function $1(e,t,n,r){let i=e===null?null:d1(t,e),a=t.history.begin(),o=t.navigation.begin(a.sessionState),s=n.holds(()=>{let e=[];for(let t of[o,a])try{t.commit()}catch(t){e.push(t)}Q1(e)}),c=[],l=e=>iq(e,e=>f1(t,e),e=>t.log(`info`,e)),u={...t,sessionState:l(a.sessionState),journal:a,navigating:l(o.sessionState)},d={launch:(e,r)=>n.landed(V$(t.launcher,e,r,t.log)),typing:(e,r)=>n.landed(O$(t.claudeInput,e,r)),applyUpdate:()=>n.landed(t.applyUpdate())};try{await r({...u,...d,gather:e=>n.landed(e(u))})}catch(e){c.push(e)}let f=!0;try{f=s()}catch(e){c.push(e)}if(f&&i!==null)try{let e=i.read();t.lanes.clicked(i.sessionId,a.written()?i.before:e,e)}catch(e){c.push(e)}if(f&&e!==null)try{let n=c1(t,e);n!==null&&t.views.follow(e,n)}catch(e){c.push(e)}Q1(c)}function e0(e,t,n){return async(r,i)=>{let a=K1(e,r),o=a?.ok?a.id:null;return i.journalTurns.click(e,o,{placed:i.placeWaited,waited:i.turnWaited,gone:i.clientGone,gathered:i.gatherTook},()=>t(r,i),(e,t)=>$1(o,i,t,async t=>{try{await n(r,t,e)}finally{o!==null&&i.clickLanded(o)}}))}}const t0=new Map([...[...W1].map(([e,t])=>[e,e0(e,async(e,n)=>t.gathers?J1(t,e,n):void 0,(e,n,r)=>Y1(t,e,n,r))]),[Ui,e0(Ui,X1,Z1)],[fa,z1]]);Object.freeze([...t0.keys()]);function n0(e,t,n){return n.journalTurns.take(`menu-idle`,{waited:t=>n.log(`info`,`menu-idle: waited=${t}ms (session=${e})`),gone:()=>!1},r=>$1(e,n,r,async n=>{if(!t.stillIdle()){n.log(`info`,`menu-idle: no longer idle, kept (session=${e})`);return}t.closed();let r=rq(f1(n,e),t=>n.navigating.get(e,t));n.navigating.setBatch(e,r.map(({key:e})=>({key:e,value:gi}))),n.log(`info`,`menu-idle: closed=${r.map(({key:e})=>e).join(`,`)||`-`} idle=${t.idleS.toFixed(1)}s timeout=${t.timeoutS}s (session=${e})`)}))}function r0({projectDir:e,cwd:t,target:n}){return JSON.stringify({projectDir:e,cwd:t,configFile:n.path??null,source:n.source})}function i0(e,t){return e===void 0?!0:e.evaluate(t).map(e=>e.plain).join(``)!==`false`}const a0={kind:`hidden`},o0={kind:`shown`};function s0(e,t){try{return i0(e,t)?o0:a0}catch(e){let t=TC(e);return t===void 0?{kind:`failed`,message:e instanceof Error?e.message:String(e)}:{kind:`pending`,variable:t.variable}}}function c0(e,t){let n=K.fromFragments(e);return n.end=``,n.overflow=`ignore`,t!==void 0&&!t.isNull&&(n.style=t),n}function l0(e,t,n){e.cellLength>t?e.truncate(t,{mode:n.truncate,marker:`…`}):e.cellLength<t&&e.align(n.justify,t)}function u0({lead:e,text:t,trail:n}){return[...e===void 0?[]:[e],t,...n===void 0?[]:[n]]}function d0({text:e,placement:t,lead:n,trail:r}){return{text:f0(e),placement:t,...n!==void 0&&{lead:f0(n)},...r!==void 0&&{trail:f0(r)}}}function f0(e){let t=e.blankCopy(e.plain);t.style=hP(e.style).clearMetaAndLinks();for(let{start:n,end:r,style:i}of e.spans)t.stylize(hP(i).clearMetaAndLinks(),n,r);return t}function p0(e){let t=u0(e);if(t.length===1)return e.text;let n=c0(t);return n.style=e.text.style,n}function m0(e,t){let{width:n,justify:r,truncate:i,baseStyle:a,padding:o,placement:s,lead:c=[],trail:l=[]}=t;if(e.length===0)return[];let u=c0(e,a).pad(o),d=new K(` `.repeat(o)),f={placement:s,...c.length>0&&{lead:c0([d,...c],a)},...l.length>0&&{trail:c0([...l,d],a)}};if(n===`auto`)return[{text:u,...f}];let p={justify:r,truncate:i};return n===`fill`?[{text:u,fill:p,...f}]:(l0(u,n,p),[{text:u,...f}])}function h0(e,t,n){let r=`x`.repeat(Math.min(n,t)).replace(/x$/,` `),i=r+e,a=[],o=0;return Ste(i,t).forEach(e=>{let t=e.trimEnd(),n=i.indexOf(t,o);t!==``&&n>r.length&&a.push(n-r.length),o=n+t.length}),a}function g0(e,t){if(e.length===0)return 0;let{lines:n}=XP(e.map(({owner:e})=>e),t),r=z(BP(n[n.length-1]));return Math.max(0,r-KP(t)+qP(t))}function _0(e,t,n){if(e.cellLength<=t)return!0;let{lines:r}=XP([e],{...n,width:1/0});return z(BP(r.flat()))<=n.width}function v0(e,t,n,r){if(_0(e.owner,t,r))return[e];let i=e.owner.copy().expandTabs(),a=g0(n,r);return i.divide(h0(i.plain,t,a)).map((n,i)=>({...e,owner:n.truncate(t,{marker:``}).padLeft(i>0?r.padding:0)})).filter(({owner:e},t,{length:n})=>n===1||e.plain.trim()!==``)}function y0(e,t){let n=Math.max(2,YP(t)-KP(t)-t.padding);return b0(e,t).reduce((e,r)=>[...e,...v0(r,n,e,t)],[])}function b0(e,t){let n=()=>e.map(e=>({owner:p0(e),placement:e.placement})),r=[];if(e.forEach(({fill:e},t)=>{e!==void 0&&r.push({at:t,how:e})}),r.length===0||!Number.isFinite(t.width))return n();let i=XP(e.map(p0),t).lines;if(i.length>1)return n();let a=Math.max(0,t.width-z(BP(i.flat()))),o=Math.floor(a/r.length),s=a-o*r.length;return r.forEach(({at:t,how:n},i)=>{let a=o+(i===r.length-1?s:0),{text:c}=e[t];l0(c,c.cellLength+a,n)}),n()}function x0(e,t){let n=[],r=[],i=()=>{if(!r.length)return;let e=S0(r,t);e.plain.length>0&&n.push(e),r=[]};for(let a of e){let e={frag:a,style:hP(a.style)};if(e.style.link){i();let r=S0([e],t);r.plain.length>0&&n.push(r)}else r.push(e)}return i(),n}function S0(e,t){let n=t!==void 0&&!t.isNull?t:void 0,r=e.map(e=>C0(e.frag,n?n.add(e.style):e.style)),i=K.fromFragments(r);return i.end=``,i.overflow=`ignore`,r.length===1?i.style=r[0].style:n!==void 0&&(i.style=n),i}function C0(e,t){let n=e.copy();return n.style=t,n}function w0(e,t){if(e.bound===void 0)throw Error(`${t} ran outside a render: no render bound its store and clocks`);return e.bound}function T0(e,t){let{look:n}=w0(e,t);if(n===void 0)throw Error(`${t} read the render's look before it was resolved`);return n}function E0(e,t){let{layout:n}=w0(e,t);if(n===void 0)throw Error(`${t} read the render's rows before they were laid`);return n()}function D0(e,t){if(e.bound!==void 0)throw Error(`a render bound a compile another render holds`);return e.bound=t,{[Symbol.dispose]:()=>{e.bound=void 0}}}function O0(e,t,n,r){let i=new Map,a=Object.entries(t);for(let[t,o]of[...a.filter(([,e])=>!(`do`in e)),...a.filter(([,e])=>`do`in e)])i.set(t,k0(e,t,o,n,r,i));return i}function k0(e,t,n,r,i,a){if(`set`in n){let e=r.get(n.set)??n.set;if(`to`in n)return{kind:`set-literal`,key:n.set,value:n.to,stateVar:e};if(`from`in n){let t=xS(n.from,i);return{kind:`set-option`,key:n.set,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,labelOf:t.labelOf,library:t.library}}return`int`in n?{kind:`set-int`,key:n.set,stateVar:e}:`cycle`in n?{kind:`set-cycle`,key:n.set,stateVar:e,members:n.cycle}:{kind:`set-bounded`,key:n.set,by:n.by}}if(`persist`in n){let e=Ix.get(n.persist)??n.persist;if(`to`in n)return{kind:`persist-literal`,key:n.persist,value:n.to,stateVar:e};if(`from`in n){let t=xS(n.from,i);return{kind:`persist-option`,key:n.persist,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,labelOf:t.labelOf,library:t.library}}if(`cycle`in n)return{kind:`persist-cycle`,key:n.persist,stateVar:e,members:n.cycle};if(`removeSegment`in n)return{kind:`layout-op`,key:n.persist,op:{op:`remove`,target:n.removeSegment}};if(`insertSegment`in n)return{kind:`layout-op`,key:n.persist,op:{op:`insert`,segment:n.insertSegment,anchor:n.anchor,relation:n.relation}};if(`insertSegmentFrom`in n){let e=xS(n.insertSegmentFrom,i);return{kind:`layout-op-option`,key:n.persist,anchor:n.anchor,relation:n.relation,options:[...e.members],paletteOf:e.paletteOf,labelOf:e.labelOf,library:e.library}}return{kind:`persist-bounded`,key:n.persist,by:n.by}}if(`copy`in n)return{kind:`copy`,text:M0(e,n.copy,t)};if(`open`in n)return{kind:`open`,target:M0(e,n.open,t)};if(`reset`in n)return{kind:`reset`,key:n.reset};if(`doctor`in n)switch(n.doctor){case`run`:return{kind:`doctor-run`};case`fix`:return{kind:`doctor-fix`,check:n.check};case`mark`:return{kind:`doctor-mark`,check:n.check,mark:n.mark}}if(`slash`in n)return{kind:`slash`,line:n.slash};if(`run`in n)return{kind:`run`,name:t,declaration:TS(n),argv:n.run.map(n=>M0(e,n,t)),env:Object.entries(n.env).map(([n,r])=>[n,M0(e,r,t)])};if(`undo`in n)return{kind:`undo`};if(`redo`in n)return{kind:`redo`};if(`back`in n)return{kind:`back`};if(`rewind`in n)return{kind:`rewind`};if(`save`in n)return{kind:`save`};if(`preset`in n)return n.preset===`save`?{kind:`preset-save`}:{kind:`preset-delete`,name:M0(e,n.name,t)};if(`themeDefault`in n)return{kind:`theme-default-save`};let[o,...s]=n.do.map(e=>{let n=a.get(e);if(n===void 0)throw Error(`action "${t}" fires "${e}", which is not declared in this config`);return n});return{kind:`do`,head:o,rest:s}}function A0(e){return e.kind===`do`?A0(e.head):e}function j0(e){switch(A0(e).kind){case`set-option`:case`set-int`:case`persist-option`:case`layout-op-option`:return!0;case`set-literal`:case`set-bounded`:case`set-cycle`:case`copy`:case`open`:case`persist-literal`:case`persist-bounded`:case`persist-cycle`:case`reset`:case`layout-op`:case`undo`:case`redo`:case`back`:case`rewind`:case`save`:case`preset-save`:case`preset-delete`:case`theme-default-save`:case`doctor-run`:case`doctor-fix`:case`doctor-mark`:case`slash`:case`run`:case`do`:return!1}}function M0(e,t,n){try{return e(t)}catch(e){throw Error(`Template parse error in actions.${n}: ${e.message}`,{cause:e})}}function N0(e,t){return e.has(t)?xC(e.read(t)):``}function P0(e,t){return e.evaluate(t).map(e=>e.plain).join(``)}function F0(e,t,n,r){let i=new K(e,{style:U.combine([r,new U({link:t,bold:n})])});return i.overflow=`ignore`,i.end=``,i}function I0(e,t,n=!1){let r=new U({link:t,bold:n?!0:void 0}),i=new K(e.plain,{style:U.combine([hP(e.style),r])});for(let t of e.spans)i.stylize(U.combine([hP(t.style),r]),t.start,t.end);return i.overflow=`ignore`,i.end=``,i}function L0(e,t){return Math.max(e.members.indexOf(N0(t,e.stateVar)),0)}function R0(e,t,n,r,i,a){switch(e.kind){case`set-literal`:{let t=N0(r,e.stateVar);return{effects:[{verb:Wi,args:[i,e.key,e.value]}],active:t===e.value}}case`set-option`:{let a=n??t,o=N0(r,e.stateVar);return{effects:[{verb:Wi,args:[i,e.key,a]}],active:o===a}}case`set-int`:{let a=n??t,o=N0(r,e.stateVar);return{effects:[{verb:Wi,args:[i,e.key,a]}],active:o===a}}case`set-cycle`:{let t=e.members[(L0(e,r)+1)%e.members.length];return{effects:[{verb:Wi,args:[i,e.key,t]}],active:!1}}case`set-bounded`:return{effects:[{verb:Gi,args:[i,e.key,String(e.by)]}],active:!1};case`copy`:return{effects:[{verb:Ki,args:[P0(e.text,JA(r))]}],active:!1};case`open`:return{effects:[{verb:qi,args:[P0(e.target,JA(r))]}],active:!1};case`persist-literal`:{let t=N0(r,e.stateVar);return{effects:[{verb:Xi,args:[i,e.key,e.value]}],active:t===e.value}}case`persist-option`:{let a=n??t,o=N0(r,e.stateVar);return{effects:[{verb:Xi,args:[i,e.key,a]}],active:o===a}}case`persist-cycle`:{let t=e.members[(L0(e,r)+1)%e.members.length];return{effects:[{verb:Xi,args:[i,e.key,t]}],active:!1}}case`persist-bounded`:return{effects:[{verb:Zi,args:[i,e.key,String(e.by)]}],active:!1};case`reset`:return{effects:[{verb:na,args:[i,e.key]}],active:!1};case`undo`:return{effects:[{verb:ia,args:[i]}],active:!1};case`redo`:return{effects:[{verb:aa,args:[i]}],active:!1};case`back`:return{effects:[{verb:oa,args:[i]}],active:!1};case`rewind`:return{effects:[{verb:sa,args:[i]}],active:!1};case`save`:return{effects:[{verb:Qi,args:[i]}],active:!1};case`preset-save`:return{effects:[{verb:$i,args:[i]}],active:!1};case`theme-default-save`:return{effects:[{verb:ea,args:[i]}],active:!1};case`preset-delete`:return{effects:[{verb:ta,args:[i,P0(e.name,JA(r))]}],active:!1};case`doctor-run`:return{effects:[{verb:la,args:[i]}],active:!1};case`doctor-fix`:return{effects:[{verb:ua,args:[i,e.check]}],active:!1};case`doctor-mark`:return{effects:[{verb:da,args:[i,e.check,e.mark]}],active:!1};case`slash`:return{effects:[{verb:pa,args:[i,e.line]}],active:!1};case`run`:{let t=JA(r),n=JSON.stringify({run:e.argv.map(e=>P0(e,t)),env:Object.fromEntries(e.env.map(([e,n])=>[e,P0(n,t)]))}),o=a.sign({sessionId:i,action:e.name,declaration:e.declaration,evaluated:n});return{effects:[{verb:`run`,args:[i,e.name,n,o]}],active:!1}}case`layout-op`:return{effects:[{verb:ra,args:[i,e.key,VR(e.op)]}],active:!1};case`do`:{let o=R0(e.head,t,n,r,i,a);return{effects:[...o.effects,...e.rest.flatMap(e=>R0(e,t,void 0,r,i,a).effects)],active:o.active}}case`layout-op-option`:{let r={op:`insert`,segment:n??t,anchor:e.anchor,relation:e.relation};return{effects:[{verb:ra,args:[i,e.key,VR(r)]}],active:!1}}}}function z0(e,t,n,r){if(n.length===0)throw Error(`action "${e}" needs a display (the clickable text)`);if(t.kind===`set-cycle`||t.kind===`persist-cycle`)return{display:bi(`action "${e}"`,n,t.members.length,L0(t,r)),boundValue:void 0};if(n.length>2)throw Error(`action "${e}" takes a display and an optional bound value, got ${n.length} arguments (per-state displays are a cycle action's form)`);return{display:n[0],boundValue:n[1]?.plain}}function B0(e,t,n){let r=n.compiled.get(e);if(!r)throw Error(`action "${e}" is not declared in this config`);let i=w0(n,`action "${e}"`).store,{display:a,boundValue:o}=z0(e,A0(r),t,i),s=N0(i,`session.id`),{effects:c,active:l}=R0(r,a.plain,o,i,s,n.signer);return I0(a,Ea(c),l)}function V0(e){return{action:{fn:(t,...n)=>B0(t,n,e),argTypes:[`string`,`liftable`],arity:{kind:`variadic`},returnType:`T`}}}function H0(e,t){return F0(`✕`,Ea([{verb:Wi,args:[N0(e,`session.id`),t,gi]}]),!1)}function U0(e,t,n){return new U({bgcolor:H.fromRgba(t),color:H.fromRgba(vv(e,t,n))})}function W0({tint:e,text:t}){return new U({bgcolor:H.fromRgba(e),color:H.fromRgba(t)})}function G0(e,t,n){return new U({color:H.fromRgba(Qu(e.get(`warning`),t,_v,n))})}function K0(e,t,n){return U.combine([U0(e,t,n),G0(e,t,n)])}function q0(e,t,n){return W0(Av(e.palette,e.disclosure,t,n))}function J0(e){let t=H.fromRgba(e.get(`background`)),n=K.fromFragments(b_.map(n=>new K(`▀`,{style:new U({color:H.fromRgba(e.get(n)),bgcolor:t})})));return n.overflow=`ignore`,n.end=``,n}const Y0=(e,t)=>{let n=typeof e==`string`?new K(e,{style:t}):e;return n.overflow=`ignore`,n.end=``,n},X0=e=>new U({bold:e});function Z0(e,t,n,r,i,a){if(r===void 0)return(n,r,a,o)=>Y0(a,U.combine([q0(e,{...n,distribution:t},i),X0(o)]));let o=U0(e.palette,a,i);return(e,t,i,a)=>Q0(i,U.combine([o,X0(a)]),r(t,n))}const Q0=(e,t,n)=>Y0(K.fromFragments([Y0(e,t),Y0(` `,t),J0(n)]));function $0(e,t,n,r){return t===void 0?Y0(r):Q0(r,void 0,t(n,e))}function e2(e,t,n,r,i){let a=U0(e.palette,i,r);return(e,r,i,o)=>Y0(K.fromFragments([Y0(o?`[`:` `,a),J0(n(r,t)),Y0(o?`]`:` `,a)]))}function t2(e,t,n){let r=t.map(t=>({label:t.label,indices:e.flatMap((e,n)=>e.group===t.id?[n]:[])})).filter(e=>e.indices.length>0);if(r.reduce((e,t)=>e+t.indices.length,0)!==e.length){let n=new Set(t.map(e=>e.id)),r=e.flatMap((e,t)=>n.has(e.group)?[]:[`#${t} (group "${e.group}")`]);throw Error(`library: ${r.join(`, `)} name a group the domain does not list (${[...n].join(`, `)})`)}return n?r.flatMap(e=>n2(e.indices,8).map(t=>[{label:e.label,indices:t}])):[r]}function n2(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))}function r2(e,t){return new K(e).truncate(t,{marker:`…`}).plain}function i2(e){return{current:null,drawnAt:e}}function a2(e,t,n,r,i,a,o){let s={segName:t,placementId:n,palette:r,disclosure:i,tint:a,text:o,bg:void 0,drops:[]};return e.current=s,s}function o2(e,t,n){return c2(e,()=>n(a2(e,t.segName,t.placementId,t.palette,t.disclosure,t.tint,t.text)))}function s2(e,t){return c2(e,()=>(e.current=null,t()))}function c2(e,t){let n=e.current;try{return t()}finally{e.current=n}}function l2(e,t){let n=e.current;if(n===null)throw Error(`${t} is only available inside a segment's templates — there is no active segment here. Segment-scoped functions cannot be used in variable declarations or layout-node "when" predicates, which are evaluated outside any segment.`);return n}function u2(e){return new K(e).cellLength}function d2(e){let{width:t,chromeCols:n,padding:r}=w0(e,`a row fit`);return Math.max(1,t-n-2*r)}function f2(e){let{padding:t,seamCols:n}=w0(e,`a row fit`);return Math.max(1,d2(e)-(u2(`✕`)+2*t+n))}function p2(e,t,n){if(!Number.isFinite(t))return e.length>0?[e.map((e,t)=>t)]:[];let r=Math.max(1,t-n),i=[],a=[],o=0;for(let t=0;t<e.length;t++){let n=e[t];a.length===0?(a=[t],o=n):o+1+n<=r?(a.push(t),o+=1+n):(i.push(a),a=[t],o=n)}return a.length>0&&i.push(a),i}function m2(e,t,n){let r=u2(`←`)+1+u2(`→`)+1,i=p2(e,t,n);return(i.length>1?p2(e,t,n+r):i).map(e=>[{label:``,indices:e}])}function h2(e){let t=[];for(let n of e)t.length>0&&t.push(new K(` `)),t.push(n);let n=K.fromFragments(t);return n.overflow=`ignore`,n.end=``,n}function g2(e,t,n,r,i){let a=e.compiled.get(t);if(!a||a.kind!==n)throw Error(`${i} references action "${t}" which must be ${r}, got ${a?`a ${a.kind} action`:`no such action`}`);return a}function _2(e,t,n){let r=e.compiled.get(t),i=r&&A0(r);if(!i||i.kind!==`set-option`&&i.kind!==`persist-option`&&i.kind!==`layout-op-option`)throw Error(`${n} references action "${t}" which must be a set-option, persist-option, or layout-op-option action ({ set, from }, { persist, from }, or { persist, insertSegmentFrom, anchor, relation }), got ${i?`a ${i.kind} action`:`no such action`}`);return i}function v2(e,t,n,r,i,a,o,s,c=[]){let l=a.compiled.get(e),u=w0(a,`picker`).store,d=N0(u,`session.id`),f=`stateVar`in t?N0(u,t.stateVar):void 0,p=(e,n)=>{let r=t.options[e];return o({index:e,count:t.options.length},r,n,r===f)},m=i?r.kind===`led`?f2(a):d2(a):1/0,h=(r.kind===`led`?0:u2(`✕`)+1)+c.reduce((e,t)=>e+u2(t.glyph)+1,0),g=t.library&&{groups:t.library.groups,entries:t.options.map(t.library.entry)},_=t.labelOf??(e=>e),v=g===void 0?t.options.map((e,t)=>p(t,_(e))):[],y=g===void 0?m2(v.map(e=>e.cellLength),m,h):t2(g.entries,g.groups,i),b=parseInt(N0(u,n.stateVar),10),x=e=>Math.max(0,y.findIndex(t=>t.some(t=>t.indices.includes(e)))),S=x(f===void 0?-1:t.options.indexOf(f)),C=Number.isInteger(b)?b<0?S:Math.min(b,y.length-1):0,w=y[C]??[],T=e=>Ea([{verb:Wi,args:[d,n.key,String(e)]}]),ee=r.kind===`led`?[]:[{verb:Wi,args:[d,...r.writes.flatMap(([e,t])=>[e,t])]}],te=r.kind===`own`&&r.onPick?ee:[],E=e=>Ea([...R0(l,e,e,u,d,a.signer).effects,...te]),ne=(e,n)=>I0(e,E(t.options[n])),D=r.kind===`led`?[]:[F0(`✕`,Ea(ee),!1,s)];D.push(...c.map(({glyph:e,option:r})=>F0(e,Ea([...R0(l,r,r,u,d,a.signer).effects,{verb:Wi,args:[d,n.key,String(x(t.options.indexOf(r)))]}]),!1))),C>0&&D.push(F0(`←`,T(C-1),!1));let O=C<y.length-1?[F0(`→`,T(C+1),!1)]:[];if(g===void 0){let e=w.flatMap(e=>e.indices);return[h2([...D,...e.map(e=>ne(v[e],e)),...O])]}let re=new U({bold:!0}),k=y.length>1?` ${C+1}/${y.length}`:``,ie=w.length===1?[new K(`${w[0].label}${k}`,{style:re})]:[],ae=[h2([...D,...ie,...O])];for(let e of w){w.length>1&&ae.push(h2([new K(e.label,{style:re})]));let n=Math.max(...e.indices.map(e=>u2(_(t.options[e]))));for(let r of e.indices){let e=_(t.options[r]),i=g.entries[r].description,a=i===void 0?void 0:AP(i),o=` `.repeat(n-u2(e)+2),s=a===void 0?e:`${e}${o}${a}`;ae.push(h2([ne(p(r,r2(s,m)),r)]))}}return ae}function y2(e,t){return{picker:{fn:(n,r,i,a,o,...s)=>{EA(`picker "${n}"`,[`closeOnPick`,`paged`,`inBody`],s);let c=g2(e,r,`set-int`,`an int action ({ set, int: true })`,`picker`);if(o===!0&&i===!0)throw Error(`{{ picker "${n}" … }} sets both closeOnPick and inBody; a picker in a body is closed by the body's ✕, so it has no close to fold into a pick`);let l=_2(e,n,`picker`),u=l2(t,`{{ picker }}`);if(u.bg===void 0)throw Error(`{{ picker }} is not available while segments.${u.segName}'s own "bg:" is being evaluated — a picker is drawn on that background`);let d=t.drawnAt(),f=t=>v2(n,l,{key:c.key,stateVar:c.stateVar},o===!0?{kind:`led`}:{kind:`own`,writes:[[c.key,`-1`]],onPick:i===!0},a===!0,e,Z0(u,nv(void 0),T0(e,`{{ picker }}`),l.paletteOf,d,t),G0(u.palette,t,d)),p=Ov(u.palette,u.disclosure,d),[,...m]=l.library===void 0?[]:f(p.plane);return m.length===0?f(u.bg)[0]:(u.drops.push(...m),f(p.state)[0])},argTypes:[`string`,`string`,`bool`],arity:{kind:`variadic`},returnType:`T`}}}function b2(e,t){let n=e.length,r=Math.max(e.indexOf(t),0);return e=>((r+e)%n+n)%n}function x2(e,t,n,r,i){if(!(`stateVar`in t))throw Error(`carousel references action "${e}", which inserts a segment and holds no current value to centre on — a carousel needs a { set, from } or { persist, from } action`);let a=w0(i,`carousel`).store;if(!a.has(t.stateVar))throw Error(`carousel references action "${e}", whose key "${t.stateVar}" no variable reads back, so there is no current value to centre on — declare { kind: "state", key: "${t.stateVar}" } among the variables`);let o=i.compiled.get(e),s=N0(a,`session.id`),{options:c}=t;if(c.length===0)return h2([]);let l=b2(c,N0(a,t.stateVar)),u=e=>c[l(e)],d=e=>Ea(R0(o,u(e),u(e),a,s,i.signer).effects);return h2([F0(`◀`,d(-1),!1),I0($0(T0(i,`{{ carousel }}`),t.paletteOf,u(0),r),Ea(R0(i.compiled.get(n),u(0),void 0,a,s,i.signer).effects)),F0(`▶`,d(1),!1)])}function S2(e){return{carousel:{fn:(t,n,r)=>{if(r.trim()===``)throw Error(`carousel "${t}": label is empty`);if(!e.compiled.has(n))throw Error(`carousel "${t}": open must name a declared action, got ${JSON.stringify(n)}`);if(j0(e.compiled.get(n)))throw Error(`carousel "${t}": open "${n}" writes a value the template binds, and the label binds none — name an action that writes a fixed value, a cycle, or a do of them`);return x2(t,_2(e,t,`carousel`),n,r,e)},argTypes:[`string`,`string`,`string`],arity:{kind:`exact`},returnType:`T`}}}function C2(e,t,n){let r=_2(e,t,n);if(!(`stateVar`in r))throw Error(`${n} references action "${t}", which inserts a segment and holds no current value — a ${n} needs a { set, from } or { persist, from } action`);if(r.paletteOf===void 0)throw Error(`${n} references action "${t}", whose options are not colour-valued — a swatch draws the palette an option puts in force, as the "themes", "placementThemes" and "styles" domains do`);return r}function w2(e,t,n){let r=Math.imul(e^e>>>16,73244475);return r=Math.imul(r^r>>>16,73244475),r^=r>>>16,(n+1+(r>>>0)%Math.max(t-1,1))%t}function T2(e,t,n,r){let i=C2(e,t,n),a=r??N0(w0(e,n).store,i.stateVar);if(!i.options.includes(a))throw Error(`${n} "${t}": "${a}" is not one of its options, so it has no palette to draw`);return i.paletteOf(a,T0(e,`{{ ${n} }}`))}function E2(e){return{swatch:{fn:(t,...n)=>{let[r,...i]=n;if(EA(`swatch "${t}"`,[`option`],i),r!==void 0&&typeof r!=`string`)throw Error(`swatch "${t}": option must be text, got ${JSON.stringify(r)}`);return J0(T2(e,t,`swatch`,r))},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function D2(e,t,n){return{swatches:{fn:(r,i)=>{let a=C2(e,r,`swatches`),o=g2(e,i,`set-int`,`an int action ({ set, int: true })`,`swatches`),s=l2(t,`{{ swatches }}`);if(s.bg===void 0)throw Error(`{{ swatches }} is not available while segments.${s.segName}'s own "bg:" is being evaluated — a swatch row is drawn on that background`);let c=t.drawnAt(),{options:l}=a,u=l.length,[d]=v2(r,a,{key:o.key,stateVar:o.stateVar},{kind:`led`},!0,e,e2(s,T0(e,`{{ swatches }}`),a.paletteOf,c,s.bg),G0(s.palette,s.bg,c),u===0?[]:(()=>{let t=b2(l,N0(w0(e,`swatches`).store,a.stateVar));return[{glyph:`◀`,option:l[t(-1)]},{glyph:`?`,option:l[w2(n().getTime(),u,t(0))]},{glyph:`▶`,option:l[t(1)]}]})());return d},argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`T`}}}const O2=[`~/code`,`main`,`opus`,`42%`,`5m`,`$1.20`];function k2(e,t,n,r){let i=Ov(e,n,r),a=(t,n)=>({text:t,colour:n,ink:vv(e,n,r)});return[[H_(e,t,r).map((n,i)=>{let a=gv(e,n);return{text:O2[i%O2.length],colour:a,ink:t.shade.text(e,n.hue,a,r)}})],[[a(`▾ open`,i.state),a(`menu`,i.plane)],[a(`warn`,e.get(`warning`)),a(`error`,e.get(`error`))]]]}function A2(e,t){let n=e.flatMap((e,t)=>e.map(({text:e,colour:n,ink:r},i)=>({gap:t>0&&i===0?` `:``,cell:new K(` ${e} `,{style:W0({tint:n,text:r})})}))),r=[],i=0;for(let{gap:e,cell:a}of n){if(i+=e.length+a.cellLength,i>t)break;e!==``&&r.push(new K(e)),r.push(a)}return r}function j2(e,t,n,r,i){let a=k2(e,t,n,r).map(e=>A2(e,i)),o=K.fromFragments(a.flatMap((e,t)=>t===0?e:[new K(`
480
480
  `),...e]));return o.overflow=`ignore`,o.end=``,o}function M2(e,t){return{themePreview:{fn:(...n)=>{let[r,...i]=n;if(EA(`themePreview`,[`applyAction`],i),r!==void 0&&typeof r!=`string`)throw Error(`themePreview: applyAction must name a declared action, got ${JSON.stringify(r)}`);let{palette:a,decor:o}=T0(e,`{{ themePreview }}`);return j2(r===void 0?a:T2(e,r,`themePreview`),o,{...l2(t,`{{ themePreview }}`).disclosure,depth:0},t.drawnAt(),f2(e))},argTypes:[`value`],arity:{kind:`variadic`},returnType:`T`}}}const N2=e=>e.slice(e.lastIndexOf(`.`)+1),P2=(e,t)=>{let n=new K(N2(e));return n.truncate(t,{marker:`…`}),n.plain};function F2(e,t){let n=e.map(e=>e.map(({name:e})=>u2(N2(e)))),r=e=>n.every(n=>n.reduce((t,n)=>t+Math.min(n,e)+2,0)<=t),i=Math.max(1,...n.flat());for(;i>1&&!r(i);)--i;return i}function I2(e,t,n,r){let i=F2(e,r),a=e.map(e=>{let a=[],o=0;for(let{name:s,address:c,palette:l}of e){let e=new K(` ${P2(s,i)} `,{style:W0(Bv(l,{kind:`bar`,decor:t,address:c},n))});if(o+=e.cellLength,o>r)break;a.push(e)}return a}),o=K.fromFragments(a.flatMap((e,t)=>t===0?e:[new K(`
481
481
  `),...e]));return o.overflow=`ignore`,o.end=``,o}const L2=`layoutPreview`;function R2(e,t){return{[L2]:{fn:()=>I2(E0(e,`{{ layoutPreview }}`),T0(e,`{{ layoutPreview }}`).decor,t.drawnAt(),f2(e)),argTypes:[],arity:{kind:`exact`},returnType:`T`}}}function z2(e,t,n,r){let i=l2(r.activeSegment,`{{ menu }}`),a=r.action,o=_M(i.placementId,e,n.key),s=bM(o),c=gM(e),l=w0(a,`menu`).store,u=N0(l,o)===c,d=N0(l,`session.id`),f=u?gi:c,p=F0(bi(`{{ menu "${e}" }}`,t,2,+!!u),Ea([{verb:Wi,args:[d,o,f,s,`0`]}]),!1);return i.drops.push(...u?(()=>{let t=r.activeSegment.drawnAt(),c=Ov(i.palette,i.disclosure,t).plane,l=_2(a,e,`menu`);return v2(e,l,{key:s,stateVar:s},{kind:`own`,writes:[[o,gi],[s,`0`]],onPick:n.closeOnPick},n.paged,a,Z0(i,n.distribution,T0(a,`{{ menu }}`),l.paletteOf,t,c),G0(i.palette,c,t))})():[]),p}const B2=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function V2(e,t){let n=t[t.length-1],r=B2(n)?n:void 0,i=r===void 0?t:t.slice(0,-1),a=i.findIndex(e=>typeof e!=`string`);if(a!==-1)throw Error(`{{ menu "${e}" }} display #${a+1} is not text (${JSON.stringify(i[a])}) — a menu binds its trigger text, then an optional trailing (dict …) of options`);return{displays:i,options:wM(r??{})}}function H2(e){return{menu:{fn:(t,...n)=>{let{displays:r,options:i}=V2(t,n);return z2(t,r,i,e)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function U2(e){let{value:t,max:n,width:r,filled:i,empty:a,colourAt:o}=e,s=W2(t,n,r),c=[];for(let e=0;e<r;e++){let t=e<s,l=t&&o!==void 0?o(e*n/r):void 0;c.push(new K(t?i:a,{style:l===void 0?void 0:new U({color:l})}))}let l=K.fromFragments(c);return l.end=``,l.overflow=`ignore`,l}function W2(e,t,n){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.min(n,Math.max(0,Math.round(e/t*n)))}function G2(e){let t={fn:(()=>{let t=l2(e,`{{ bgOf }}`);if(t.bg===void 0)throw Error(`{{ bgOf }} is not available while segments.${t.segName}'s own "bg:" is being evaluated — the background is what that template computes. Reach for a palette color there instead, e.g. bg: '{{ darken (color "surface") 1 }}'.`);return t.bg.hex}),argTypes:[],arity:{kind:`exact`},returnType:`string`},n={fn:(()=>l2(e,`{{ tint }}`).tint.hex),argTypes:[],arity:{kind:`exact`},returnType:`string`},r={fn:((t,n)=>{let{palette:r}=l2(e,`{{ roleTextOn }}`);return J2(r,t,Bu(r,n)).hex}),argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`string`},i={fn:((t,n)=>{let{palette:r}=l2(e,`{{ keptOn }}`),i=Bu(r,t),a=Bu(r,n),o=El(ed(i,V.TRUECOLOR),ed(a,V.TRUECOLOR)),s=Math.min(_v,o),c=e.drawnAt(),l=$u(i,c,(e,t)=>El(e,t(a))>=s);if(l===void 0)throw Error(`keptOn: nothing drawn at ${V[c]} stands ${s.toFixed(2)}:1 off ${a.hex} (drawn ${ed(a,c).hex})`);return l.hex}),argTypes:[`string`,`string`],arity:{kind:`exact`},returnType:`string`},a=sA(()=>l2(e,`{{ color }} / {{ ramp }} / {{ gauge }}`).palette),o={fn:((e,t,n,r,i,o,...s)=>{let c=o===void 0?void 0:[o,...Y2(s)];return U2({value:e,max:t,width:n,filled:r,empty:i,colourAt:c===void 0?void 0:e=>String(a.ramp.fn(e,...c))})}),argTypes:[`float`,`float`,`int`,`string`,`string`,`string`],arity:{kind:`variadic`},returnType:`T`};return{...a,bgOf:t,tint:n,roleTextOn:r,keptOn:i,gauge:o}}const K2={"#000000":[`darken-1`,`darken-2`,`darken-3`],"#ffffff":[`lighten-1`,`lighten-2`,`lighten-3`]},q2=Object.values(K2).flat();function J2(e,t,n){let r=ed(n,V.TRUECOLOR),i=t=>{let n=Bu(e,t);return{colour:n,ratio:El(ed(n,V.TRUECOLOR),r)}},a=Zu(r).hex,o=K2[a];if(o===void 0)throw Error(`contrastFor named ${a} for ${n.hex}, which is neither pole`);let s=`text-${t}`,c=e=>`${t}-${e}`,l=new Map([s,t,...q2.map(c)].map(e=>[e,i(e)]));return([s,t,...o.map(c)].map(e=>l.get(e)).find(({ratio:e})=>e>=4.5)??[...l.values()].reduce((e,t)=>t.ratio>e.ratio?t:e)).colour}function Y2(e){return e.flatMap(e=>{let t=e.indexOf(`:`),n=t<0?NaN:Number(e.slice(0,t));if(!Number.isFinite(n))throw Error(`{{ gauge }} stop "${e}" must be "<position>:<colour>", e.g. "80:error" or "80:#ff0000"`);return[n,e.slice(t+1)]})}function X2(e,t){if(e.kind!==`shell`&&e.kind!==`file`)return[];let n=`key`in e.cache&&[...t.calls(e.cache.key)].some(e=>KA.has(e));return[...t.ofVariable(e).flatMap(({reaches:e})=>e.length===0?[null]:e),...n?[null]:[]]}const Z2={input:`view`,state:`view`,template:`view`,time:`view`,literal:`directory`,env:`directory`,dropped:`directory`,source:`view`},Q2=new WeakMap;function $2(e){let t=Q2.get(e);return t===void 0&&(t=e4(e),Q2.set(e,t)),t}function e4(e){let t=new Map(dC(e)),n=UW(e),r=new Map([...t].map(([e,t])=>[e,t.kind===`shell`||t.kind===`file`?`directory`:Z2[t.kind]])),i=new Map([...t].map(([e,t])=>[e,X2(t,n)]));for(let e=!0;e;){e=!1;for(let[t,n]of i)r.get(t)!==`view`&&n.some(e=>e===null||r.get(e)!==`directory`)&&(r.set(t,`view`),e=!0)}return r}function t4(e){let t=[],n=[];for(let r of e){if(!r.contains(`
482
482
  `)){n.push(r);continue}let e=r.split(`
483
- `);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function n4(e){let t=new Map;return e.map(e=>{let n=`${e.place}.${e.band}`,r=t.get(n)??0;return t.set(n,r+1),{line:e,row:`${n}#${r}`}})}const r4=e=>e.kind===`failed`?a0:e;function i4(e,t){return t.kind===`shown`||t.kind===`failed`&&e.kind===`pending`?e:t}function a4(e,t){let n=[],r=[],i;for(let a of t)(a.band===`own`?n:r).push(a),i??=a.cells.find(t=>t.placement.id===e)?.placement.ground;return{drawing:i===void 0?null:{own:n,opened:r.length>0,ground:i},deeper:r}}function o4(e){return{...e,cells:e.cells.map(d0)}}function s4(e,t){let n=t.flatMap(e=>e.filter(e=>e.place===`above`)),r=t.map(e=>e.filter(e=>e.place===`flow`));return[...n,...c4(e,r)]}function c4(e,t){switch(e){case`vertical`:return t.flatMap(e=>e);case`horizontal`:return t.reduce((e,t)=>Math.max(e,t.length),0)===0?[]:[{cells:t.flatMap(e=>e[0]?.cells??[]),band:`own`,place:`flow`},...t.flatMap(e=>e.slice(1))]}}function l4(e,t){let n=(e,r)=>t(e)?e.kind===`segment`?[{cells:[{name:e.name,address:r,settings:e.settings}],band:`own`,place:`flow`}]:s4(e.direction,e.children.map((t,i)=>n(t,[...r,u4(e,i)]))):[];return n(e,[]).map(e=>[...e.cells])}function u4(e,t){return e.steps[t]}function d4(e){if(e.kind===`segment`||e.unit===!0)return{width:1,reach:1};let t=f4(e);return{width:p4(t),reach:m4(t)}}function f4(e){let t=e.children.map(d4),n=n=>e.direction===`vertical`&&t.slice(0,n).some(({width:e})=>e>0);if(e.direction===`vertical`||e.unit===!0)return t.map((e,t)=>({start:0,span:e,ownLine:n(t)}));let r=0;return t.map((e,t)=>{let i=r;return r+=e.width,{start:i,span:e,ownLine:n(t)}})}const p4=e=>e.reduce((e,{span:t,ownLine:n})=>e+(n?0:t.width),0),m4=e=>e.reduce((e,{start:t,span:n})=>Math.max(e,t+n.reach),0);function h4(e,t){let n=f4(e);if(t?.axis===`cell`)return n.map(({start:e,span:n,ownLine:r})=>{let i=t.index+e;return r?{...t,index:i,lineStart:i,lineEnd:i+n.width-1}:{...t,index:i}});let r=Oy[e.direction],i=nv(e.distribution),[a,o,s]=r===`row`?[n.map((e,t)=>t),n.length,n.length-1]:[n.map(({start:e})=>e),m4(n),p4(n)-1];return a.map(e=>({index:e,count:o,distribution:i,axis:r,lineStart:0,lineEnd:s}))}const g4={compile(e,t){let n=h4(e,t.at);return{kind:`container`,direction:e.direction,when:t.when,steps:n,children:e.children.map((e,r)=>t.compileChild(e,Py(t.path,r),n[r]))}},render(e,t){return t.gate.kind===`failed`&&t.gate.report(),s4(e.direction,e.children.map((n,r)=>t.renderChild(n,r4(t.gate),u4(e,r))))}},_4={drop:e=>e.place,above:()=>`above`},v4={drop:(e,t)=>({lead:t(),stays:e}),above:e=>({lead:e.slice(0,1).flatMap(e=>e.cells),stays:e.slice(1)})},y4={compile(e,t){return{kind:`segment`,when:t.when,name:e.name,id:ky(e),settings:t.placementSettings(e),...e.opens!==void 0&&{opens:{open:t.parse(Ci(e.opens.ref),`opens`),body:t.compileChild(e.opens.body,Fy(t.path),void 0),key:e.opens.ref.key,placement:e.opens.placement}},...e.lead!==void 0&&{lead:t.parse(e.lead,`lead`)},...e.trail!==void 0&&{trail:t.parse(e.trail,`trail`)}}},render:(e,t)=>t.placed(e.id,b4(e,t))};function b4(e,t){let n=t.lookupSegment(e.name);if(n===void 0)throw Error(`Layout segment "${e.name}" has no matching segment`);if(t.gate.kind===`hidden`)return[];let r=XA(t.scope,e.settings);if(t.gate.kind===`failed`)return E4(e,r,t,t.gate.message);try{let i=t.placement(e),a=i4(t.gate,i.gate());if(a.kind===`failed`)return E4(e,r,t,a.message);if(a.kind===`hidden`)return[];let o=i.bodyGate(),s=o.kind===`failed`&&a.kind===`pending`?a:o;if(s.kind===`failed`)return E4(e,r,t,s.message);let c=Hx(e.settings.theme,t.palette),l={id:e.id,effect:e.settings.effect,ground:qN(c)},u=e=>({width:n.width??`auto`,justify:n.justify??`left`,truncate:n.truncate??`right`,baseStyle:e,padding:t.padding,placement:l}),d=s.kind===`shown`,f=a.kind===`pending`?a:s,p=f.kind===`pending`?x4(f.variable):S4(()=>i.evaluate(c,t.region)),m=p.kind===`drawn`?C4(p.segment,u):w4(e,r,t,p.variable,c,d,u);if(m===null)return[];let{styles:h,inline:g,drops:_}=m,v=e.opens,y=v===void 0?[]:t.renderBody(v.body,d?a:a0,h.disclosure).map(e=>({...e,place:_4[v.placement](e)})),b=(e,t,n)=>m0(x0([e],t),{...u(t),width:`auto`,padding:n}),x=y.findIndex(e=>e.band===`own`),{lead:S,stays:C}=v!==void 0&&x!==-1?v4[v.placement](g,()=>b(t.closeDisclosure(v.key),h.close,t.padding)):{lead:[],stays:g},w=S.flatMap(e=>b(new K(` `.repeat(T4(u0(e)))),h.trigger,0)),T=(e,t)=>e.band===`own`?t===x?S:w:[],ee=y.map((e,t)=>({cells:[...T(e,t),...e.cells],band:`deeper`,place:e.place})),te=[...C,..._];return t.perSegmentSink!==void 0&&t.perSegmentSink.set(e.id,[...te.flatMap(e=>e.cells),...y.flatMap(T)].flatMap(u0)),[...te,...ee]}catch(n){return E4(e,r,t,n.message??String(n))}}const x4=e=>({kind:`waiting`,variable:e});function S4(e){try{return{kind:`drawn`,segment:e()}}catch(e){let t=TC(e);if(t===void 0)throw e;return x4(t.variable)}}function C4(e,t){let{styles:n,fragments:r,lead:i,trail:a,drops:o,open:s}=e,c=s?n.trigger:n.closed,l=t(c);return{styles:n,inline:t4(x0(r,c)).map((e,t)=>({cells:m0(e,{...l,lead:t===0?x0(i,c):[],trail:t===0?x0(a,c):[]}),band:`own`,place:`flow`})),drops:o.map(e=>({cells:m0(x0([e],n.band),{...l,baseStyle:n.band}),band:`deeper`,place:`flow`}))}}function w4(e,t,n,r,i,a,o){n.waited(r);let s=n.lastDrawn(e.id);if(s?.kind===`hidden`)return null;let c=n.decorations(e,i),l=a?c.trigger:c.closed,u=x0(D4(e.lead,e,t,n),l),d=x0(D4(e.trail,e,t,n),l);return{styles:c,inline:(s===void 0||s.drawing.own.length===0?[[`auto`]]:s.drawing.own.map(e=>e.cells.map(e=>e.text.cellLength))).map((e,t)=>({cells:e.flatMap((e,n)=>{let r=t===0&&n===0;return m0(x0([new K(r?`…`:` `)],l),{...o(l),width:e,justify:`left`,truncate:`right`,lead:r?u:[],trail:r?d:[]})}),band:`own`,place:`flow`})),drops:[]}}function T4(e){return e.reduce((e,t)=>e+t.cellLength,0)}function E4(e,t,n,r){n.onSegmentError?.(e.id,r);let i=r.replace(/\s*\n\s*/g,` `);return[{cells:m0([new K(`⚠ ${e.id}: ${i}`,{end:``})],{width:`auto`,justify:`left`,truncate:`right`,padding:0,placement:{id:e.id,effect:`bar`,ground:qN(n.palette)},lead:D4(e.lead,e,t,n),trail:D4(e.trail,e,t,n)}),band:`own`,place:`flow`}]}function D4(e,t,n,r){if(e===void 0)return[];try{return r.evaluateOnce(t,n,r.palette,e).fragments}catch(e){let n=TC(e);return n===void 0?r.onSegmentError?.(t.id,e.message??String(e)):r.waited(n.variable),[]}}const O4={container:g4,segment:y4};function k4(e){return O4[e]}var A4=class{last=null;from(e){let{last:t}=this;return t!==null&&t.source.config===e.config&&t.source.preset===e.preset&&t.source.revision===e.revision&&t.source.width===e.width?t:null}begin(e,t){let n=new Map,r=new Map;return{placed:(e,r)=>{let{drawing:i}=t(e,r);return n.set(e,i===null?j4:{kind:`drew`,drawing:i}),r},rule:(e,t)=>r.set(e,t),commit:()=>{this.last={source:e,placements:n,rules:r}}}}};const j4={kind:`hidden`},M4={palette:`theme`,style:`style`,effect:`effect`},N4=Ix.get(`colorCompatibility`),P4={width:0,chromeCols:0,padding:0,seamCols:0,preset:``};function F4(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,error:e}}}function I4(e){if(e.ok)return e.value;throw e.error}const L4=e=>({read:()=>e}),R4=v_({basePalette:__,palette:__,decor:Nv});var z4=class{evaluated=0;memory=new A4;scope;binding;facts;look=Y.observable.box(void 0,{deep:!1,equals:(e,t)=>e!==void 0&&t!==void 0&&R4(e,t)});layout;phase={ruling:!1};gates=new Map;placements=new Map;rules=new Map;slots=new Map;view;projected=void 0;drawnSlots=new Map;constructor(e,t,n,r){this.store=e,this.registry=t,this.source=n,this.view=Y.observable.box(r,{deep:!1}),this.scope=JA(e),this.depth=e.derive(`drawn depth`,`computed`,()=>{let e=this.inputAt(N4);return e.kind===`found`&&typeof e.value==`string`&&_y(e.value)?e.value:`truecolor`});let i=(0,Y.observable)(P4,void 0,{deep:!1});this.facts=i;let a=this.look,o=this.phase,s=()=>this.layout.read();this.binding={store:e,registry:t,get width(){return i.width},get chromeCols(){return i.chromeCols},get padding(){return i.padding},get seamCols(){return i.seamCols},get look(){return o.ruling?void 0:a.get()},get layout(){return o.ruling?void 0:s}},this.layout=this.derive(`layout`,n.layoutReadsInstant,()=>{let e=n.roots.get(i.preset),t=a.get().palette;return l4(e,e=>this.shown(e)).map(e=>e.flatMap(({name:e,address:n,settings:r})=>{let i=kR(e);return i===void 0?[]:[{name:i,address:n,palette:Hx(r.theme,t)}]}))}),t.bindInputs({read:e=>this.inputAt(e),drawnAt:()=>vy(this.colorCompatibility())})}bind(e){(0,Y.runInAction)(()=>this.view.set(e))}selections(){return this.view.get().selections()}draw(e,t){this.draws++,this.projected=t,this.drawnSlots.clear(),(0,Y.runInAction)(()=>Object.assign(this.facts,e))}inputAt(e){let t=fM(e);return t===void 0?uM(e)===void 0?$j(this.view.get().payload(),e):$j(this.projected,e):Qj(this.slotName(t))}depth;colorCompatibility(){return this.depth.read()}slot(e){let t=this.slots.get(e);if(t===void 0){let n,r=()=>{let t=this.selections()[M4[e]];if(t.kind===`decided`)return H4(t.name,null,null);let r=W4(this.source,e,t.source);if(this.source.instant.has(r.template))return{kind:`per-draw`,rule:r};let i=this.rule(r.template);switch(i.kind){case`named`:{let t=null;return n=G4(this.source,e,i.name,r.where,e=>{t=e}),H4(n,t,null)}case`pending`:return H4(n??iy[e],null,i.variable);case`failed`:return n=iy[e],H4(n,ay(r.where,e,`the rule failed — ${i.error}`),null)}},i;t=this.store.derive(`slot ${e}`,`computed`,()=>{let e=r();return(i===void 0||!U4(i,e))&&(i=e),i}),this.slots.set(e,t)}return t.read()}slotName(e){let t=this.slot(e);return t.kind===`settled`?t.name:this.drawnSlots.get(e)??iy[e]}drawnSlot(e,t){this.drawnSlots.set(e,t)}draws=0;publishLook(e){(0,Y.runInAction)(()=>this.look.set(e))}gate(e){let{when:t}=e;if(t===void 0)return s0(t,this.scope);let n=this.gates.get(e);return n===void 0&&(n=this.derive(`when`,this.readsInstant(t),()=>s2(this.source.activeSegment,()=>s0(t,this.scope))),this.gates.set(e,n)),n.read()}placement(e){let t=this.placements.get(e);return t===void 0&&(t=new K4(this,e),this.placements.set(e,t)),t}rule(e){let t=this.rules.get(e);return t===void 0&&(t=this.derive(`rule`,this.readsInstant(e),()=>{this.phase.ruling=!0;let t=this.source.runtime.bound===this.binding?null:D0(this.source.runtime,this.binding);try{return{kind:`named`,name:e.evaluate(this.scope).map(e=>e.plain).join(``)}}catch(e){let t=TC(e);return t===void 0?{kind:`failed`,error:e instanceof Error?e.message:String(e)}:{kind:`pending`,variable:t.variable}}finally{t?.[Symbol.dispose](),this.phase.ruling=!1}}),this.rules.set(e,t)),t.read()}readsInstant(...e){return e.some(e=>e!==void 0&&this.source.instant.has(e))}derive(e,t,n){let r=()=>(this.evaluated++,n());return this.store.derive(`part ${e}`,t?`projection`:`computed`,t?this.oncePerDraw(r):r)}oncePerDraw(e){let t=null;return()=>(t?.draw!==this.draws&&(t={draw:this.draws,answer:F4(e)}),I4(t.answer))}shown(e){let t=this.gate(e);return e.kind===`container`?t.kind===`shown`||t.kind===`pending`:kR(e.name)===void 0||t.kind===`hidden`?!1:t.kind===`failed`?!0:this.placement(e).gate().kind!==`hidden`}};function B4(e,t,n,r){let i=e.views.get(t);if(i!==void 0)return i.bind(r),i;let a=new z4(t,n,e,r);return e.views.set(t,a),a}function V4(e,t){let n=e.views.get(t);if(n===void 0)throw Error(`a store was drawn before its view was bound (bindView): its inputs have no source`);return n}const H4=(e,t,n)=>({kind:`settled`,name:e,warning:t,waited:n}),U4=(e,t)=>e.kind===`settled`?t.kind===`settled`&&e.name===t.name&&e.warning===t.warning&&e.waited===t.waited:t.kind===`per-draw`&&e.rule===t.rule;function W4(e,t,n){let r=e.globalExpressions.get(t)?.get(n);if(r===void 0)throw Error(`the ${t} rule ${JSON.stringify(n)} reached the view but no compiled template exists — the compile and the resolution disagree about isExpression`);return r}function G4(e,t,n,r,i){switch(t){case`palette`:return Kx(n,r,i).name;case`style`:return ty(n,e.styles).name;case`effect`:return dy(n).name}}var K4=class{where=q4(v_({palette:__,region:jv}));ground=q4(v_({colours:Y4,bodyOpen:__}));opened=q4(v_({colours:Y4,open:__}));ownGate;open;colours;body;affixes;constructor(e,t){let n=e.source.segments[t.name],r=e.source.activeSegment,i=XA(e.scope,t.settings),{when:a,bg:o,fg:s,template:c}=n,{lead:l,trail:u}=t,d=t.opens?.open;this.ownGate=a===void 0?L4(o0):e.derive(`${t.id} when`,e.readsInstant(a),()=>s2(r,()=>s0(a,i))),this.open=d===void 0?L4(a0):e.derive(`${t.id} body gate`,e.readsInstant(d),()=>s2(r,()=>s0(d,e.scope))),this.colours=e.derive(`${t.id} colours`,e.readsInstant(o,s),()=>{let{palette:n,region:a}=this.where.get();return Q4(r,t,n,a,e.registry.drawnAt(),o,s,i)}),this.body=e.derive(`${t.id} body`,e.readsInstant(c),()=>{let{colours:e,bodyOpen:n}=this.ground.get();return $4(r,t,e,c,n,i)}),this.affixes=l===void 0&&u===void 0?L4(t3):e.derive(`${t.id} affixes`,e.readsInstant(l,u),()=>{let{colours:e,open:n}=this.opened.get();return e3(r,t,e,n,l,u,i)})}gate(){return this.ownGate.read()}bodyGate(){return this.open.read()}evaluate(e,t){this.where.set({palette:e,region:t});let n=this.colours.read();this.ground.set({colours:n,bodyOpen:this.open.read().kind===`shown`});let r=this.body.read();return this.opened.set({colours:n,open:r.open}),r3(n,r,this.affixes.read())}};function q4(e){let t=Y.observable.box(void 0,{deep:!1,equals:(t,n)=>t!==void 0&&n!==void 0&&e(t,n)});return{set:e=>(0,Y.runInAction)(()=>t.set(e)),get:()=>t.get()}}const J4=(e,t)=>e.hex===t.hex,Y4=v_({palette:__,drawnAt:__,tint:J4,text:J4,bg:J4,disclosure:Pv});function X4(e,t){return{segName:e.name,placementId:e.id,palette:t.palette,disclosure:t.disclosure,tint:t.tint,text:t.text}}const Z4=e=>Ov(e.palette,e.disclosure,e.drawnAt);function Q4(e,t,n,r,i,a,o,s){let c={palette:n,drawnAt:i,...Bv(n,r,i)};return o2(e,X4(t,c),e=>{let t=YN(e,i,a,o,s);return{...c,bg:e.bg,style:t}})}function $4(e,t,n,r,i,a){return o2(e,X4(t,n),e=>(e.bg=i?Z4(n).state:n.bg,{fragments:r.evaluate(a),drops:e.drops,open:e.drops.length>0||i}))}function e3(e,t,n,r,i,a,o){return o2(e,X4(t,n),e=>(e.bg=r?Z4(n).state:n.bg,{lead:i?.evaluate(o)??[],trail:a?.evaluate(o)??[],drops:e.drops}))}const t3={lead:[],trail:[],drops:[]};function n3(e){let{palette:t,drawnAt:n,disclosure:r}=e;return{closed:e.style,get trigger(){return U0(t,Z4(e).state,n)},get band(){return U0(t,Z4(e).plane,n)},get close(){return K0(t,Z4(e).state,n)},disclosure:r}}function r3(e,t,n){return{styles:n3(e),fragments:t.fragments,lead:n.lead,trail:n.trail,drops:[...t.drops,...n.drops],open:t.open}}function i3(e,t,n,r,i,a,o){let s=Q4(e,t,n,r,i,void 0,void 0,o);return r3(s,$4(e,t,s,a,!1,o),t3)}function a3(e,t,n,r,i){return n3(Q4(e,t,n,r,i,void 0,void 0,{}))}function o3(e,t){return{payload:()=>e,selections:()=>t}}function s3(e){if(`ttl`in e)return{kind:`ttl`,durationMs:Jj(e.ttl)};if(`watch_file`in e)return{kind:`watch_file`,path:e.watch_file};if(`depends_on`in e)return{kind:`depends_on`,varNames:e.depends_on};if(`key`in e)return{kind:`key`,template:e.key};if(`never`in e)return{kind:`never`};throw Error(`Unknown CacheDecl discriminator — loader invariant violated: ${JSON.stringify(e)}`)}function c3(e,t){switch(Ry(e)){case`json`:return{kind:`json`,default:t};case`regex`:return{kind:`regex`,regex:new RegExp(e.regex),default:t};case`text`:return{kind:`text`,default:t}}}function l3(e,t,n,r,i){switch(n.kind){case`literal`:e.declareLiteral(t,n.value);break;case`dropped`:e.declareFailedDocument(t,n.reason);break;case`source`:e.declareSourceDocument(t);break;case`input`:e.declareInput(t,n.path,n.type??`string`,n.default,i);break;case`env`:e.declareEnv(t,n.name,n.default);break;case`file`:e.declareFile(t,n.path,{readMode:n.readMode,cache:s3(n.cache),parse:c3(n.parse,n.default)});break;case`shell`:e.declareShell(t,n.command,{cwd:r,cache:s3(n.cache),parse:c3(n.parse,n.default)});break;case`template`:e.declareTemplate(t,n.template,{type:n.type??`string`,varDefault:n.default,derivation:i});break;case`time`:e.declareTime(t,{format:n.layout,varDefault:n.default});break;case`state`:e.declareState(t,{key:n.key,...n.default!==void 0&&{varDefault:n.default}});break}}function u3(e,t,n,r=pw.EMPTY){let i=r;for(let[r,a]of Object.entries(t))try{i=e.parse(`{{ define "${r}" }}${a}{{ end }}`,i).defines()}catch(e){throw Error(`Template parse error in ${n}.${r}: ${e.message}`,{cause:e})}return i}function d3(e,t,n){let{compiled:r,loadWarnings:i}=p3(e,t,n.cwd,f3(n.signer),_3);return{...r,loadWarnings:i}}const f3=e=>(t,n)=>v3(n,e);function p3(e,t,n,r,i=_3){let a=m3(e),o=h3(a);return{compiled:r(o,a),compileKey:o,loadWarnings:g3(e,t,n,i)}}function m3(e){let{variables:t,...n}=e,r=new Map;for(let[e,n]of Lx)n in t&&r.set(e,n);for(let[t,n]of Gy(e))r.has(n.key)||r.set(n.key,t);return{config:n,stateReads:[...r].sort(([e],[t])=>e<t?-1:1),projections:[...qW(e)].sort(([e],[t])=>e<t?-1:1)}}function h3(e){return oe(`sha256`).update(JSON.stringify(e)).digest(`hex`)}function g3(e,t,n,r){let i=$2(e),a=qW(e),o=[];for(let[s,c]of dC(e))if(r.has(i.get(s)))try{l3(t,s,c,n,a.has(s)?`projection`:`computed`)}catch(e){o.push(`Variable "${s}": ${e.message??String(e)}`)}return o}const _3=new Set([`directory`,`view`]);function v3({config:e,stateReads:t,projections:n},r){let i={bound:void 0,compiled:new Map,signer:r},a=()=>w0(i,`drawnAt`).registry.drawnAt(),o=i2(a),s={action:i,activeSegment:o},c=Object.keys(e.styles),l=lS(e.presets),u=vR(e),d=[e=>D2(i,o,e.now)],f=qA({extraFuncs:{...V0(i),...E2(i),...y2(i,o),...S2(i),...M2(i,o),...R2(i,o),...H2(s),...G2(o),styles:{fn:()=>c,argTypes:[],arity:{kind:`exact`}},presets:{fn:()=>l,argTypes:[],arity:{kind:`exact`}}},clockFuncs:d,drawnAt:a}),p=u3(f,e.helpers,`helpers`),m=new Map,h=e=>{let t=f.parse(e,p);return m.set(t,e),t},g=new Map,_=e=>{let t=g.get(e);if(t!==void 0)return t;let n=h(e);return g.set(e,n),n},v=new Map(t);i.compiled=O0(h,e.actions,v,u);let y=Object.create(null);for(let[t,n]of Object.entries(e.segments)){let e=n.partials===void 0?p:u3(f,n.partials,`segments.${t}.partials`,p),r=t=>{let n=f.parse(t,e);return m.set(n,t),n},i=(e,i,a=n.partials===void 0?_:r)=>{try{return a(e)}catch(e){throw Error(`Template parse error in segments.${t}.${i}: ${e.message}`,{cause:e})}};y[t]={when:n.when===void 0?void 0:i(n.when,`when`),template:i(n.template,`template`,r),bg:n.bg===void 0?void 0:i(n.bg,`bg`,r),fg:n.fg===void 0?void 0:i(n.fg,`fg`,r)}}let b=(e,t,n)=>{try{return _(e)}catch(e){throw Error(`Template parse error in ${t}.${n}: ${e.message}`,{cause:e})}},x=t=>{let n=Yy(e.segments[t.name]),r=Object.create(null);for(let[e,a]of Object.entries(n))Object.defineProperty(r,e,{enumerable:!0,get:()=>tb(t,e,a,t=>String(w0(i,`setting ${e}`).store.read(t.variable)))});return Object.freeze(r)},S=(e,t,n)=>{let r={path:t,at:n,when:e.when===void 0?void 0:b(e.when,t,`when`),parse:(e,n)=>b(e,t,n),compileChild:S,placementSettings:x};return k4(e.kind).compile(e,r)},C=new Map;for(let t of l){let{node:n,path:r}=fS(e,t);C.set(t,S(n,r,void 0))}let w=new Map(Xv.map(e=>[e,new Map]));for(let{at:t,slot:n,rule:r}of YW(e)){let e=t.join(`.`),i=w.get(n),a=i.get(r);i.set(r,a===void 0?{where:e,template:x3(h,e,r)}:{where:`${a.where}, ${e}`,template:a.template})}let T=new Set(n.map(([e])=>e)),ee={reads:BW({names:T,helpers:e.helpers,actions:e.actions}),projections:new Map(n),clock:WA(d)},te=QW(ee),E=[...C.values()].flatMap(b3(y)).some(e=>te(m.get(e))),ne=E?new Set([...ee.clock,L2]):ee.clock,D=QW({...ee,clock:ne}),re=new Set([...m].flatMap(([e,t])=>D(t)?[e]:[]));for(let[t,n]of Object.entries(e.segments)){if(n.partials===void 0)continue;let r=QW({reads:BW({names:T,helpers:{...e.helpers,...n.partials},actions:e.actions}),projections:ee.projections,clock:ne});for(let e of sH){let n=y[t][e];n!==void 0&&r(m.get(n))&&re.add(n)}}return{segments:y,roots:C,activeSegment:o,menuRuntime:s,globalExpressions:w,instant:re,layoutReadsInstant:E,styles:e.styles,runtime:i,views:new WeakMap}}function y3(e){return Object.entries(e.segments).flatMap(([t,n])=>[n.when,n.bg,n.fg,n.template].some(t=>t!==void 0&&e.instant.has(t))?[t]:[])}const b3=e=>t=>{let n=[];return l4(t,e=>(n.push(e),!0)),n.flatMap(t=>[...t.when===void 0?[]:[t.when],...t.kind===`segment`&&e[t.name].when!==void 0?[e[t.name].when]:[]])};function x3(e,t,n){try{return e(n)}catch(e){throw Error(`${t} is not a valid template: ${e instanceof Error?e.message:String(e)}`)}}const S3=e=>{throw Error(`a slot settled on a name its domain refuses: ${e}`)};function C3(e,t,n,r,i){let a=w3(e,t,n.rule(t.template),r,i);return i.settled(e,a),a}function w3(e,t,n,r,i){switch(n.kind){case`named`:return n.name;case`pending`:return i.waited(n.variable),i.held(e)??iy[e];case`failed`:return r({kind:`rule`,slot:e,message:ay(t.where,e,`the rule failed — ${n.error}`)}),iy[e]}}function T3(e){return E3(e).filter(e=>!e.name.startsWith(Pi)).map(e=>e.id)}function E3(e){return e.kind===`container`?e.children.flatMap(E3):[e,...e.opens===void 0?[]:E3(e.opens.body)]}function D3(e,t,n,r,i,a){let o={...r,term:{cols:i.width},colorCompatibility:{effective:i.colorCompatibility}};return B4(e,t,n,o3(o,a)),o}function O3(e,t,n,r,i,a,o,s,c){try{var l=No();let{perSegmentSink:u,onSegmentError:d,onRenderWarning:f}=s??{},p=e=>f?.(e),m=c.effects??new DP(``),h=m.clockAt(a,sy[c.animationSpeed]),g=l.u(PA(a,h.timeline)),_=V4(t,n),v={...o,colorCompatibility:_.colorCompatibility()};_.draw({width:v.width,chromeCols:KP(v),padding:v.padding,seamCols:qP(v),preset:c.preset},i);let y=_.evaluated;l.u(D0(t.menuRuntime.action,_.binding));let{preset:b,transitions:x}=c,S={variation:B_[c.variation],shade:j_[c.shade]},C={config:e,preset:b,revision:r.stateRevision(),width:v.width},w=_.memory.begin(C,a4),T=_.memory.from(C),ee=new Set,te={held:e=>T?.rules.get(e),waited:e=>ee.add(e),settled:w.rule},E=new Map,ne=e=>{let n=_.slot(e);if(E.set(e,n.kind===`settled`?`kept`:`per-draw`),n.kind===`settled`)return n.warning!==null&&p({kind:`rule`,slot:e,message:n.warning}),n.waited!==null&&ee.add(n.waited),n.name;let r=G4(t,e,C3(e,n.rule,_,p,te),n.rule.where,t=>p({kind:`rule`,slot:e,message:t}));return _.drawnSlot(e,r),r},{theme:D,style:re,effect:ie}=_.selections(),O=D.kind===`decided`?D:Kx(ne(`palette`),``,S3),ae=re.kind===`decided`?re:ty(ne(`style`),e.styles),oe=ie.kind===`decided`?ie:dy(ne(`effect`)),se=O.value,ce=Wx(se,ae.value);_.publishLook({basePalette:se,palette:ce,decor:S});let le=ce.get(`warning`),ue=c.idleSince===void 0?null:{idleSince:c.idleSince,timeoutS:c.menuTimeout,fill:le,text:vv(ce,le,r.drawnAt())},de=m.motion(oe.value,h,{transitions:x,source:C,last:T,returned:a4,hold:o4},ue);u?.clear();let fe=t=>e.segments[t],pe=(e,i,a)=>{let o=i.kind===`hidden`?i:i4(i,_.gate(e)),s=o.kind===`failed`?{...o,report:()=>{let t=`when over ${T3(e).join(`, `)||`no placement`}`;p({kind:`when`,where:t,error:o.message,message:`${t}: ${o.message} — what it gates is hidden`})}}:o,c={scope:_.scope,palette:ce,gate:s,padding:v.padding,region:a,perSegmentSink:u,onSegmentError:d,placement:e=>_.placement(e),evaluateOnce:(e,n,i,o)=>i3(t.activeSegment,e,i,a,r.drawnAt(),o,n),lookupSegment:fe,renderChild:(e,t,n)=>pe(e,t,Rv(a,n)),renderBody:(e,t,n)=>pe(e,t,zv(n)),closeDisclosure:e=>H0(n,e),placed:(e,t)=>w.placed(e,de.placed(e,t)),lastDrawn:e=>T?.placements.get(e),waited:e=>ee.add(e),decorations:(e,n)=>a3(t.activeSegment,e,n,a,r.drawnAt())};return k4(e.kind).render(e,c)},me=t.roots.get(b);if(me===void 0)throw Error(`Preset "${b}" has no compiled layout — registerDslConfig compiles one per declared preset and effectivePresetName collapses unknown names to "${sS}"; a miss here is merge/policy drift (have: ${[...t.roots.keys()].join(`, `)})`);let he=n4(pe(me,o0,Lv(S))).map(({line:e,row:t})=>{let n=y0(e.cells,v),r=e.band===`deeper`?`menu`:`bar`;return{kind:r,cellBreaks:n.length-e.cells.length,...XP(n.map(e=>e.owner),v,de.row(t,r,n))}});de.drawn(),w.commit();let ge=()=>he.some(e=>e.kind===`menu`)||_.selections().effect.kind===`expression`||x||E3(me).some(({settings:e})=>e.effect!==`bar`&&e.effect!==`none`),_e=Math.min(g.heard(),...he.map(e=>e.nextChange)),ve=Number.isFinite(_e)?`moves`:ge()?`can-move`:`still`;for(let[e,t]of r.cachePolicyFaults())p({kind:`refresh`,variable:e,error:t.message,message:`variable "${e}" cannot refresh: ${t.message}`});return{frame:{depth:v.colorCompatibility,rows:he.flatMap(({kind:e,lines:t})=>t.map(t=>({kind:e,runs:t}))),nextChange:_e,motion:ve,pending:[...ee].sort()},evaluated:_.evaluated-y,cellBreaks:he.reduce((e,t)=>e+t.cellBreaks,0),rules:E}}catch(e){l.e=e}finally{l.d()}}const k3={moving:1e3/30,still:1e3},A3=[`data`,`state`,`reload`,`visibility`];function j3(e){return Zb.filter(t=>e[t].subscribers>0).map(t=>{let{subscribers:n,fps:r,shown:i}=e[t];return`${t}:${n}sub/${r}fps/${i?`shown`:`offscreen`}`}).join(`,`)||`-`}function M3(e,t){let n=e.filter(e=>e>t-1&&e<=t);e.splice(0,e.length,...n,t)}const N3=(e,t)=>Xb[t].handsOff?e.resp:e.statusline,P3=e=>Math.round(1e3/e);var F3=class{requests=new Map;feeds=new Map;stopWatching=null;drawn=0;pushed=0;refused=0;lookups=0;found=0;constructor(e){this.deps=e}note(e,t,n){let r=this.requests.get(e);if(r!==void 0&&r.order>n)return;this.requests.delete(e),this.requests.set(e,{req:t,order:n});for(let e of this.requests.keys()){if(this.requests.size<=256)break;this.feeds.has(e)||this.requests.delete(e)}let i=this.feeds.get(e);i!==void 0&&i.noted++}subscribe(e,t){let n=this.deps.lanes(e);if(n!==null&&!n[t.lane])return this.refuse(e,t),()=>{};let r=this.feeds.get(e),i=r??this.open(e);return i.followers.set(t,null),i.rates.has(t.lane)||i.rates.set(t.lane,[]),r!==void 0&&this.send(i,t),this.hasten(i),this.deps.log(`info`,`feed sid=${JSON.stringify(e)} subscribed lane=${t.lane} subscribers=${i.followers.size} view=${n===null?`N`:`Y`}`),()=>this.unsubscribe(i,t)}feedOpen(e){return this.feeds.has(e)}following(e){return new Set([...this.feeds.get(e)?.followers.keys()??[]].filter(e=>e.drawing()).map(e=>e.lane))}wake(e,t){let n=this.feeds.get(e);n!==void 0&&(n.woke[t]++,this.hasten(n)||n.coalesced++)}wakeWhere(e,t){for(let{sessionId:n,req:r}of this.watched())t(r)&&this.wake(n,e)}newestWhere(e){let t=null;for(let[n,{req:r,order:i}]of this.requests)e(r)&&(t===null||i>t.order)&&(t={sessionId:n,order:i});return this.lookups++,t!==null&&this.found++,t?.sessionId??null}latest(e){return this.requests.get(e)?.req??null}watched(){return[...this.feeds.keys()].flatMap(e=>{let t=this.requests.get(e);return t===void 0?[]:[{sessionId:e,req:t.req}]})}feedsOf(e,t){let n=this.feeds.get(e);if(n===void 0)return ix;let r=t-1,i=this.shown(n);return rx(e=>{let a=n.rates.get(e);if(a===void 0)return tx;let o=0;for(let t of n.followers.keys())t.lane===e&&o++;let s=0;for(let e of a)e>r&&e<=t&&s++;return{subscribers:o,fps:s,shown:i}})}getStats(){let e=0;for(let t of this.feeds.values())e+=t.followers.size;return{feeds:this.feeds.size,subscribers:e,drawn:this.drawn,pushed:this.pushed,refused:this.refused,lookups:this.lookups,found:this.found}}open(e){let t=this.deps.clock.monotonic(),n={sessionId:e,followers:new Map,rates:new Map,unwatch:this.deps.watch(e,()=>this.wake(e,`state`)),unpin:this.deps.pin(e),phase:{kind:`waiting`},lastStart:-1/0,last:null,since:t,drawn:0,noted:0,noView:0,moving:0,unseen:0,failed:0,pushed:0,drawMs:0,evaluated:0,cellBreaks:0,woke:{data:0,state:0,reload:0,visibility:0},coalesced:0,summarizedAt:t,refreshesAtOpen:this.deps.refreshes()};return this.feeds.set(e,n),this.stopWatching??=this.deps.watching(),n}close(){for(let e of[...this.feeds.values()])for(let t of[...e.followers.keys()])this.unsubscribe(e,t)}unsubscribe(e,t){if(e.followers.delete(t)){if([...e.followers.keys()].some(e=>e.lane===t.lane)||e.rates.delete(t.lane),e.followers.size>0){this.hasten(e);return}e.phase.kind===`due`&&e.phase.clear(),e.unwatch(),e.unpin(),this.feeds.delete(e.sessionId),this.feeds.size===0&&(this.stopWatching?.(),this.stopWatching=null),this.summarize(e,`closed`)}}draw(e,t){e.phase={kind:`drawing`};let n=this.deps.clock.monotonic(),r=this.deps.instant(),i=Math.min(Math.max(t,r),r+.002),a=n+(i-r)*1e3;try{this.step(e,n,a,i)}catch(t){if(e.lastStart=a,this.deps.log(`error`,`feed sid=${JSON.stringify(e.sessionId)} threw: ${x(t)}`),this.feeds.get(e.sessionId)!==e)return;this.schedule(e,null,i)}}step(e,t,n,r){let i=this.deps.render(e.sessionId,P3(this.spacingOf(e)),r);if(i===null){e.noView++,e.phase={kind:`waiting`};return}e.lastStart=n;let a=this.deps.clock.monotonic();this.drawn++,e.drawn++,e.drawMs+=a-t,e.evaluated+=i.evaluated,e.cellBreaks+=i.cellBreaks,this.feeds.get(e.sessionId)===e&&(this.countFailure(e,i),this.push(e,i,r),this.feeds.get(e.sessionId)===e&&(a-e.summarizedAt>=6e4&&this.summarize(e,`running`),this.schedule(e,i,r)))}schedule(e,t,n){let{moving:r,still:i}=this.deps.periods,a=((t?.bar.nextChange??1/0)-n)*1e3,o=Math.min(Math.max(a,r),i),s=this.shown(e);o<i&&s&&e.moving++,o<i&&!s&&e.unseen++;let c=s?o:i;this.arm(e,n+c/1e3,this.deps.instant())}spacingOf(e){return this.shown(e)?this.deps.periods.moving:this.deps.periods.still}hasten(e){let{phase:t}=e;if(t.kind===`drawing`)return!1;let n=this.deps.clock.monotonic(),r=Math.max(n,e.lastStart+this.spacingOf(e));if(t.kind===`due`&&t.at<=r)return!1;let i=this.deps.instant();return this.arm(e,i+(r-n)/1e3,i),!0}arm(e,t,n){let r=Math.max(0,(t-n)*1e3);this.setTimer(e,t,this.deps.clock.monotonic()+r,r)}setTimer(e,t,n,r){e.phase.kind===`due`&&e.phase.clear(),e.phase={kind:`due`,at:n,clear:this.deps.clock.after(r,()=>this.fire(e,t,n))}}fire(e,t,n){let r=n-this.deps.clock.monotonic();r>0?this.setTimer(e,t,n,r):this.draw(e,t)}shown(e){let t=this.requests.get(e.sessionId);return t===void 0||this.deps.shown(t.req)}countFailure(e,t){t.failure!==null&&e.failed++}push(e,t,n){let r=this.deps.lanes(e.sessionId);if(r!==null)for(let t of[...e.followers.keys()])r[t.lane]||(this.unsubscribe(e,t),this.refuse(e.sessionId,t));if(e.followers.size===0)return;t.delivered();let i={resp:JSON.stringify(t.resp),statusline:JSON.stringify(t.statusline)};if(e.last?.answers.resp===i.resp&&e.last.answers.statusline===i.statusline)return;let a=e.last?.answers??null;e.last={bar:t.bar,answers:i},this.pushed++,e.pushed++,t.failure!==null&&this.deps.log(t.failure.level,t.failure.line);for(let[t,r]of e.rates)(a===null||N3(a,t)!==N3(i,t))&&M3(r,n);for(let t of e.followers.keys())this.send(e,t)}send(e,t){if(e.last===null)return;let n=N3(e.last.answers,t.lane);e.followers.get(t)!==n&&(t.frame(e.last.bar,n),e.followers.set(t,n))}refuse(e,t){this.refused++,this.deps.log(`info`,`feed sid=${JSON.stringify(e)} refused lane=${t.lane} switched-off`),t.refused({ok:!1,error:HM(t.lane),code:`SWITCHED_OFF`,daemonV:3})}summarize(e,t){let n=this.deps.clock.monotonic(),r=this.deps.refreshes(),i=(n-e.since)/1e3,a=i===0?`-`:`${(e.drawn/i).toFixed(1)}fps`,o=Ej.map(t=>`${t}:${r[t]-e.refreshesAtOpen[t]}`).join(`,`);this.deps.log(`info`,`feed sid=${JSON.stringify(e.sessionId)} ${t} subscribers=${e.followers.size} lanes=${[...e.followers.keys()].map(e=>e.lane).join(`,`)||`-`} for=${Math.round(i)}s drawn=${e.drawn} noted=${e.noted} noView=${e.noView} moving=${e.moving} unseen=${e.unseen} failed=${e.failed} pushed=${e.pushed} ceiling=${P3(this.spacingOf(e))}fps achieved=${a} evaluated=${e.evaluated} cellBreaks=${e.cellBreaks} woke=${A3.map(t=>`${t}:${e.woke[t]}`).join(`,`)} coalesced=${e.coalesced} daemonRefreshed=${o} meanDraw=${e.drawn===0?`-`:(e.drawMs/e.drawn).toFixed(2)}ms`),e.summarizedAt=n}};function I3(e,t){return Zb.filter(n=>e[n]&&Xb[n].handsOff&&t.has(n))}function L3(e,t){return{severity:mU,lines:[[gU(`[⟲ claude]`,Ea([{verb:na,args:[e,...t.map(e=>Xb[e].switch.setting)]}]))]]}}function R3(e,t){for(let n of Object.entries(t))e.push(n)}const z3={ok:`info`,"bad-request":`warn`,threw:`error`,closing:`info`,abandoned:`info`};function B3(e){switch(e.kind){case`ok`:return[];case`bad-request`:return[[`problems`,e.problems.join(`; `)]];case`threw`:return[[`error`,x(e.error)]];case`closing`:return[[`closing`,e.error.message]];case`abandoned`:return[[`abandoned`,`1`]]}}function V3(e,t,n,r){let i=[...t,[`took`,`${r}ms`],[`outcome`,n.kind],...B3(n)];return{level:z3[n.kind],line:Oc(e,i)}}const H3=()=>{},U3=e=>({ok:!1,error:e instanceof Error?e.message:x(e),code:`RENDER_FAILED`,daemonV:3}),W3={ansi:e=>({ok:!0,output:gte(e)}),frame:e=>({ok:!0,frame:e})};function G3(e,t,n,r){let{clock:i,frameFeeds:a}=e,o=i.monotonic(),s=[];try{try{var c=No();let i=c.u(e6(e,t,r,s));if(i===null)return null;let{drawn:o,evaluated:l,cellBreaks:u,delivered:d,lanes:f}=n6(e,i,{by:`feed`,fps:n}),p=W3.ansi(o.body),m=l6(t,o,I3(f,a.following(t)));return{bar:o.body,resp:p,statusline:m===o.body?p:W3.ansi(m),evaluated:l,cellBreaks:u,delivered:d,failure:null}}catch(e){c.e=e}finally{c.d()}}catch(e){let{level:t,line:n}=V3(`render`,s,{kind:`threw`,error:e},A(i,o)),r=U3(e);return{bar:ute(r.error),resp:r,statusline:r,evaluated:0,cellBreaks:0,delivered:H3,failure:{level:t,line:`frame ${n}`}}}}function K3(e,t,n){let{sessionState:r}=e;return CK(n.config,e=>r.get(t,e),e=>n.authoredRoots.has(e))}function q3(e,t){try{var n=No();let{renderCache:r}=e,i=n.u(r.holdView(t));return i===null?null:bK(i.view.source.effective(),Nc(i.view.facts().hints.tmux))}catch(e){n.e=e}finally{n.d()}}function J3(e,t,n){try{var r=No();let{renderCache:i,frameFeeds:a}=e,o=r.u(i.hold(t.projectDir,t.cwd,t.target.path)),s=a.latest(n);return bK(K3(e,n,o.state),s===null||Nc(s.hints.tmux))}catch(e){r.e=e}finally{r.d()}}function Y3(e,t,n){R3(n,{sid:e.sessionId,at:t.toFixed(3)});let{hints:r}=e;R3(n,{termCols:String(r.termCols??`?`),termRows:String(r.termRows??`?`),refused:Bn(e,r).map(e=>e.hint).join(`,`)||`-`,badArgs:e.refusedArgs.map(e=>`${e.arg}:${e.why}`).join(`,`)||`-`,client:r.client?.kind??`unreported`,rateLimits:e.rateLimits})}const X3=e=>Vn(Bn(e,e.hints));function Z3(e,t,n,r,i){Y3(t,r,i),R3(i,{encoding:t.encoding}),(0,Y.runInAction)(()=>{r6(e,t),e.worldStates.take(n),Q3(e,t)[Symbol.dispose]()})}function Q3(e,t){let n=r1(t.requested,e.sessionState,t.sessionId);return e.renderCache.holdSession(n.projectDir,n.cwd,n.target.path,t)}function $3(e,t,n,r){let i=X3(t);return t6(e,Q3(e,t),t,i,n,r)}function e6(e,t,n,r){let{renderCache:i}=e,a=i.holdView(t);if(a===null){let e=i.openFailure(t);if(e!==null)throw e.error;return null}let o=a.view.facts(),s;try{Y3(o,n,r),s=X3(o)}catch(e){throw a[Symbol.dispose](),e}return t6(e,a,o,s,n,r)}function t6(e,t,n,r,i,a){let{payloadProviders:o}=e;try{let{entry:e,state:s,view:c}=t,{sessionId:l,hints:u}=n;return{req:n,at:i,facts:a,sessionId:l,entry:e,state:s,view:c,hintsError:r,payloadInputs:{hookData:n.hookData,deps:o,cwd:n.cwd,hints:u},[Symbol.dispose]:()=>t[Symbol.dispose]()}}catch(e){throw t[Symbol.dispose](),e}}function n6(e,t,n){let{sessionState:r,frameFeeds:i,renderCache:a,updateWatch:o,linkSigner:s,fileEvents:c,renderWarnings:l,payloadProviders:u,effectSessions:d,menuIdle:f,launcher:p}=e,{req:m,at:h,facts:g,sessionId:_,entry:v,state:y,view:b,hintsError:x}=t,S=b.source.payload(),C=b.source.effective(),w=b.source.failure(),T=bK(C,S.tmux!==void 0);R3(g,{lanes:Zb.filter(e=>T[e]).join(`,`)||`-`});let ee=b.source.hints(),te=S.term.cols;R3(g,{width:String(te)});let E=Tc(r,_,h,n.by),ne=E.kind===`held`||E.kind===`owed`?E.error:null,D=o.notice({sessionId:_,dismissed:r.get(_,yz),enabled:C.updateNotice}),re=UU(v.repos,_,s),ie=(e,t)=>({about:e,text:t,copy:t}),O=e=>ie(e??``,e),ae=[O(Un(m.refusedArgs)),O(x),ie(`load`,v.lastError),ie(`update-act`,o.error()),...y.dropped.map(e=>({about:`dropped\0${e.file}`,text:e.message,copy:e.prompt})),O(ne?.text)].flatMap(({about:e,text:t,copy:n})=>e&&t&&n?[{about:e,text:t,copy:n}]:[]),oe=v.watch===null?null:rj(`config watch`,v.watch,null),se=p.launcherWarnings(h,n.by),ce=se.find(e=>e.kind===`launch-pipes`),le=ce?.event??null,ue=[...Jc(c.delivery()),...se,...oe===null?[]:[{kind:`config-watch`,message:oe}],...v.lastWarning===null?[]:[{kind:`load`,message:v.lastWarning}],...w===null?[]:[{kind:`facts`,message:`the bar is drawn from the last facts that were read; the next could not be stamped: ${w}`}]],de={config:y.config},fe=_U(_,n.by,ae,[...D.offer,...re],[...D.failure,...ue.map(e=>({about:e.kind,text:e.message,copy:e.message})),...l.ofSession(_,n.by,de).map(e=>({about:`${e.kind}\0${e.message}`,text:e.message,copy:e.message}))]),pe=b.source.facts(),me={diagnostics:DU(fe),drawing:n,feeds:i.feedsOf(_,h),today:aZ(pe.builtins.today,h)},he=jo(S.metrics)?void 0:S.metrics;R3(g,tZ([...b.state.sources.keys()],pe)),R3(g,{prompts:String(he?.messageCount??`-`),nonPrompts:String(he?.nonPrompts??`-`),pr:PX(S.git),feeds:j3(me.feeds)});let ge=[],_e=jX(C,te),ve=d.of(_),ye=f.since(_,h),{frame:be,evaluated:xe,cellBreaks:Se,rules:Ce}=O3(y.config,y.compiled,b.store,b.registry,me,h,_e,{perSegmentSink:b.lastRenderCellsBySegment,onRenderWarning:e=>ge.push(e)},{...C,effects:ve,idleSince:ye}),we=yU(fe),Te=new Map(fe.map((e,t)=>[we[t],e.copy])),Ee=()=>a.delivered(_,n.by,Te);f.observe(_,h,be.rows.some(e=>e.kind===`menu`),C.menuTimeout);let De=f.since(_,h);R3(g,{menuIdle:De===void 0?`-`:`${(h-De).toFixed(1)}s/${C.menuTimeout}s`});let Oe=l.drawn(_,n.by,de,ge),ke={width:te,rows:kU(ee.termRows,n.by===`feed`?Zb.flatMap(e=>{let t=Xb[e].rows;return T[e]&&t!==null?[t]:[]}):[]),colorCompatibility:be.depth},Ae=OU(r.get(_,Bi),fe),je=Ae===null?be:NP(be,AU(fe,Ae,_,n.by,ke)),Me=u.gitProvider.getStats(),k=u.usageStore.getStats(),Ne=ve.lastFrame(),Pe=Ne.own.map(e=>`${e.placement}:${e.effect}@${e.t.toFixed(3)}`).join(`,`)||`-`,Fe=e=>e.map(e=>`${e.placement}@${e.t.toFixed(3)}`).join(`,`)||`-`,A=e=>{switch(e.kind){case`rule`:return`rule:${e.slot}`;case`refresh`:return`refresh:${e.variable}`;case`file-events`:return`${e.kind}:${e.state}`;case`load`:case`facts`:case`config-watch`:case`lifeline`:case`launch-pipes`:case`when`:return e.kind}},Ie=[...D.failure.map(()=>`update-failed`),...[...ue,...ge].map(A)].join(`,`)||`-`;return R3(g,{git:`${Me.size}/${Me.hits}h/${Me.misses}m`,usage:`${k.size}/${k.hits}h/${k.misses}m`,effect:Ne.effect,effectT:Ne.t.toFixed(3),speed:`${Ne.speed}x`,effectRows:`${Ne.made}made/${Ne.reused}reused`,effectOwn:Pe,fadeBasis:Ne.basis,stateRev:String(Ne.revision),fades:Fe(Ne.fades),leaves:Fe(Ne.leaves),motion:je.motion,evaluated:String(xe),cellBreaks:String(Se),pending:je.pending.join(`,`)||`-`,rules:[...Ce].map(([e,t])=>`${e}:${t}`).join(`,`)||`-`,err:ae.length>0?`Y`:`N`,clickError:E.kind===`none`?`-`:E.kind,pipeEvent:ce?.hold??`-`,upd:String(D.offer.length),ask:String(re.length),warn:Ie,diag:String(fe.length),warnRecord:Oe?`new`:`kept`,viewer:Ae===null?`-`:`${Ae.index}/${fe.length}p${Ae.page+1}`}),{drawn:{body:je,viewerOpen:Ae!==null,diagnostics:fe,geometry:ke},evaluated:xe,cellBreaks:Se,clickShown:ne,pipeShown:le,delivered:Ee,lanes:T}}function r6(e,t){let{sessionState:n}=e,r=t.sessionId,{client:i,...a}=t.hints,o=JSON.stringify(a);n.get(r,`client-hints`)!==o&&n.set(r,oq,o);let s=r0(t.requested);n.get(r,`render-origin`)!==s&&n.set(r,aq,s)}function i6(e,t,n){let{laneSetups:r,tmuxStatusLines:i}=e;r.noted(a6(e,t),n),i.observe(t.hookData.session_id,t.hints.tmux,n.tmuxStatus)}function a6(e,t){let{sessionState:n}=e,r=t.hookData.session_id;return{sessionId:r,hints:t.hints,origin:r1(t.requested,n,r),transcript:t.hookData.transcript_path,answered:ZP(t.hookData)}}function o6(e,t,n,r){let{frameFeeds:i,laneSetups:a,tmuxStatusLines:o}=e,s=i.latest(t);a.clicked(t,s===null?null:a6(e,s),n,r),s!==null&&n.tmuxStatus!==r.tmuxStatus&&o.observe(t,s.hints.tmux,r.tmuxStatus)}async function s6(e,t,n,r,i){try{var a=No();let{clock:o,frameFeeds:s,log:c}=e,l=a.u($3(e,t,n,i));i6(e,t,bK(l.view.source.effective(),Nc(t.hints.tmux)));let u=o.monotonic(),d=r-u;R3(i,{deadline:`${t.deadline.kind}:${Math.round(d)}ms`});let f=new Map,p=await yj(t=>Promise.all([XX(l.payloadInputs,n,f,()=>e.worldStates.of(l.sessionId),t),l.view.registry.inFlight(t)]),d,e=>c(`error`,`render wait failed after its deadline sid=${JSON.stringify(l.sessionId)}: ${x(e)}`),o.after),m=o.monotonic();R3(i,{waited:`${Math.round(m-u)}ms`,ended:p,refreshed:HX(f)});let{drawn:h,clickShown:g,pipeShown:_,delivered:v,lanes:y}=n6(e,l,$b),b=t.sessionId,S=I3(y,s.following(b)),C=QP(t.hints.client??null)===`statusline`,w=C?l6(b,h,S):h.body;return R3(i,{handoff:(C?S:[]).join(`,`)||`-`,drew:`${A(o,m)}ms`}),{frame:w,delivered:c6(e,b,v,g,_)}}catch(e){a.e=e}finally{a.d()}}function c6(e,t,n,r,i){return()=>{n(),r!==null&&Cc(e.sessionState,t,r),i!==null&&e.launcher.answeredPipeEvent(i)}}function l6(e,t,n){let[r,...i]=n;return r===void 0||t.viewerOpen?t.body:NP(t.body,jU(L3(e,[r,...i]),t.diagnostics,e,t.geometry))}const u6=e=>{};function d6(e,t,n=``){let r=U3(t);return{outcome:{kind:`threw`,error:t},resp:{...r,error:`renderer ${e.name}: ${n}${r.error}`},seen:`failed`,settled:u6}}function f6(e){let t=e.hookData.workspace?.current_dir??e.cwd;return{...e,hookData:{...e.hookData,...t!==void 0&&E.isAbsolute(t)&&{location:zH(t)}}}}function p6(e,t){e.push(...t.kind===`answered`?t.output.record:t.record)}async function m6(e,t,n,r,i,a,o,s){let c=f6(r),l=(t,r)=>void e.deliver({kind:`event`,at:Ve(new Date(n.now())),event:{kind:`effect-done`,of:t.id,outcome:r===null?{kind:`ok`}:{kind:`failed`,reason:r}}},[[`sid`,c.sessionId],[`effect`,String(t.id)]]),u=await e.answer({kind:`event`,at:a,event:{kind:`config`,context:c,worldState:t.requested(c)}});if(p6(s,u),u.kind===`threw`)return R3(s,{renderer:e.name}),d6(e,u.error,`its config turn: `);for(let e of u.output.effects)l(e,`a config turn answers no request`);let d=await e.answer({kind:`event`,at:a,event:{kind:`request`,id:i,context:c,waitEndsAt:o}});if(p6(s,d),d.kind===`threw`)return R3(s,{renderer:e.name}),d6(e,d.error);let{effects:f}=d.output;R3(s,{renderer:e.name,effects:f.map(e=>`${e.kind}:${e.surface}`).join(`,`)||`-`});let p=null;for(let e of f)switch(e.kind){case`present`:e.request===i?p===null?p=e:l(e,`a second statusline frame for request ${i}`):l(e,`presents request ${e.request}, not this turn's ${i}`);break}if(p===null)return d6(e,Error(`presented no statusline frame for request ${i}`));let m=p,h=n.monotonic(),g;try{g=W3[c.encoding](m.frame)}catch(t){return l(m,`encoding its frame threw: ${U3(t).error}`),d6(e,t,`its frame could not be encoded: `)}return R3(s,{encoded:`${A(n,h)}ms`}),{outcome:{kind:`ok`},resp:g,seen:m.frame.motion,settled:e=>l(m,e?null:`the client did not take the answer`)}}const h6=new Set([`hook_event_name`,`session_id`,`session_name`,`transcript_path`,`cwd`,`model`,`workspace`,`version`,`output_style`,`cost`,`context_window`,`exceeds_200k_tokens`,`effort`,`thinking`,`rate_limits`,`vim`,`agent`,`worktree`]),g6=[[`session_id`,`string`],[`transcript_path`,`string`],[`cwd`,`string`],[`model`,`object`],[`model.id`,`string`],[`model.display_name`,`string`],[`workspace`,`object`],[`workspace.current_dir`,`string`],[`workspace.project_dir`,`string`]],_6=[[`workspace.added_dirs`,`string-list`]];function v6(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of g6){let i=x6(n,e);if(i==null)t.missingRequired.push(e);else{let n=y6(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of _6){let i=x6(n,e),a=i===void 0?r:b6(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))h6.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function y6(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function b6(e){return Array.isArray(e)&&e.every(e=>y6(e)===`string`)?`string-list`:y6(e)}function x6(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=n[e]}return n}function S6(e,t,n){let{tokens:r}=S({args:e.slice(1),options:{config:{type:`string`}},strict:!1,tokens:!0,allowPositionals:!0}),i=(r??[]).filter(e=>e.kind===`option`&&e.name===`config`).at(-1),a=(r??[]).flatMap(e=>{switch(e.kind){case`option`:return e.name===`config`?e===i&&e.value===void 0?[{arg:e.rawName,why:`no-value`}]:[]:[{arg:e.rawName,why:`unknown`}];case`positional`:return[{arg:e.value,why:`positional`}];case`option-terminator`:return[]}});return{configFile:cP(t,i?.value,n),refusedArgs:a.filter((e,t)=>a.findIndex(t=>t.arg===e.arg&&t.why===e.why)===t)}}function C6(e){if(e===void 0)return{ok:!0,encoding:`ansi`};let t=Ln.find(t=>t===e);return t===void 0?{ok:!1,problem:`request 'encoding' is not one of ${Ln.join(`, `)}: ${JSON.stringify(e)}`}:{ok:!0,encoding:t}}function w6(e,t,n,r){let{report:i}=v6(e.hookData),a=[];for(let e of i.missingRequired)a.push(`missing required field '${e}'`);for(let{path:e,expected:t,got:n}of i.typeMismatches)a.push(`field '${e}' expected ${t}, got ${n}`);let o=P$(e.hookData?.session_id);o.ok||a.push(`field 'session_id' ${o.problem}`),(typeof e.cwd!=`string`||!re(e.cwd))&&a.push(`request 'cwd' is not an absolute path: ${JSON.stringify(e.cwd)}`),(!Array.isArray(e.args)||!e.args.every(e=>typeof e==`string`))&&a.push(`request 'args' is not a list of strings: ${JSON.stringify(e.args)}`);let s=C6(e.encoding);s.ok||a.push(s.problem);let c=pr(e.deadline);if(c.kind===`refused`)return{ok:!1,problems:[...a,c.problem]};if(a.length>0||!o.ok||!s.ok)return{ok:!1,problems:a};for(let e of i.unknownTopLevelFields)t.firstSightOfUnknownHookField(e)&&n(`info`,`schema: unknown field ${JSON.stringify(e)} — Anthropic may have added it`);let l=zn(e),{configFile:u,refusedArgs:d}=S6(e.args,e.cwd,r);return{ok:!0,req:{...e,deadline:c,encoding:s.encoding,sessionId:o.id,hints:l,rateLimits:Dte(e.hookData),requested:{projectDir:e.hookData.workspace.project_dir,cwd:e.cwd,target:dP(u,l.configEnv)},refusedArgs:d}}}function T6(e,t){switch(e){case`vars`:return{what:e,vars:E6(t)};case`segments`:return{what:e,segments:j6(t)};case`config`:return{what:e,config:F6(t)}}}function E6(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=k6(r),a=t.names().sort(),o=[];for(let e of a){let r=t.getNode(e),a=D6(r),s=n.getLastError(e);o.push({name:e,source:i.get(e)??null,...a,lastError:s===void 0?null:{timestampMs:s.timestamp,message:s.message},ageMs:O6(r.lastUpdatedMs(),t.clock)})}return o}function D6(e){if(e.kind===`projection`)return{type:e.type,value:`(read at each frame's instant)`};if(e.kind!==`document`)try{return{type:e.type,value:e.read()}}catch(t){return{type:e.type,value:t instanceof Error?t.message:String(t)}}let t=e.read();switch(t.kind){case`ok`:return{type:`document`,value:JSON.stringify(t.value)};case`pending`:return{type:`document`,value:`(not yet scanned)`};case`absent`:return{type:`document`,value:`(nothing to read, and no default)`};case`failed`:return{type:`document`,value:t.reason}}}function O6(e,t){return e===null?null:Math.max(0,t.now()-e)}function k6(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,A6(r));for(let[n,r]of Object.entries(e.segments))if(r.vars)for(let[e,i]of Object.entries(r.vars))t.set(`${n}.${e}`,A6(i));return t}function A6(e){return e.kind}function j6(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=N6(n),o=M6(n),s=[];for(let e of a){let t=n.segments[e];t&&s.push({name:e,description:t.description??null,template:t.template,referencedVars:P6(t.template,n.helpers,i),placements:(o.get(e)??[]).map(e=>({id:e,lastRender:r.get(e)??null}))})}return s}function M6(e){let t=new Map;for(let n of lS(e.presets))for(let r of Ny(fS(e,n).node)){if(r.kind!==`segment`)continue;let e=t.get(r.name)??[],n=ky(r);e.includes(n)||t.set(r.name,[...e,n])}return t}function N6(e){let t=[],n=new Set;for(let r of Ny(Qx(e.root)))r.kind===`segment`&&e.segments[r.name]&&!n.has(r.name)&&(t.push(r.name),n.add(r.name));for(let r of Object.keys(e.segments))n.has(r)||(t.push(r),n.add(r));return t}function P6(e,t,n){let r=new Set([...XS(e,t).keys()].flatMap(e=>fC(e,n)));return Array.from(r).sort()}function F6(e){return e===null?null:e.config}const I6=[`vars`,`segments`,`config`];function L6(e){return typeof e==`string`&&I6.includes(e)}const R6=e=>({resp:e,exitAfterFlush:null,settled:u6}),z6=e=>({kind:`reply`,...e}),B6={render:!0,"pane-session":!0,shutdown:!0,stats:!0,click:!0,debug:!0},V6=(e,t)=>z6(R6({ok:!1,error:t,code:e,daemonV:3}));function H6(e){let t=P$(e.sessionId);if(!t.ok)return V6(`BAD_REQUEST`,`subscribe's sessionId ${t.problem}`);if(e.lane===void 0)return V6(`VERSION_MISMATCH`,`this client's subscribe names no lane (${Zb.join(`, `)}): it predates the lane toggles — update it`);let n=ax(e.lane);return n===null?V6(`BAD_REQUEST`,`subscribe needs a lane, one of ${Zb.join(`, `)}: got ${JSON.stringify(e.lane)}`):{kind:`subscribe`,sessionId:t.id,lane:n}}async function U6(e,t,n,r,i){if(t.kind===`url`)return z6(R6(await Z6(e,t.frame,n,r,i)));let a=t.req;return!a||typeof a!=`object`||typeof a.v!=`number`?V6(`BAD_REQUEST`,`malformed request`):a.v===3?a.kind===`subscribe`?H6(a):typeof a.kind!=`string`||!Object.hasOwn(B6,a.kind)?V6(`BAD_REQUEST`,`unknown kind`):z6(await W6(e,a,n,r,i)):(a.v>3?e.log(`info`,`version mismatch: client=${a.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):e.log(`info`,`version mismatch: client=${a.v} < daemon=3; client is stale — staying up`),{kind:`reply`,resp:{ok:!1,error:`protocol v${a.v} not supported (daemon at v3)`,code:`VERSION_MISMATCH`,daemonV:3},exitAfterFlush:a.v>3?0:null,settled:u6})}async function W6(e,t,n,r,i){let{stats:a,clock:o,frameFeeds:s,renderCache:c,payloadProviders:{gitProvider:l,usageStore:u},fileEvents:d,runs:f,sourceRuns:p,effectSessions:m,menuIdle:h,journalTurns:g,sessionState:_,tmuxStatusLines:v,watcherRegistry:y,limits:b,handlerProbes:S,renderSightings:C,bundle:w,sourceDigest:T,doctorStores:ee}=e;if(t.kind===`shutdown`)return{resp:{ok:!0,output:``},exitAfterFlush:0,settled:u6};if(t.kind===`pane-session`){let{socket:e,pane:n}=t;return R6(typeof e!=`string`||typeof n!=`string`?{ok:!1,error:`pane-session needs a string socket and pane`,code:`BAD_REQUEST`,daemonV:3}:{ok:!0,paneSession:s.newestWhere(({hints:{tmux:t}})=>t!=null&&t.socket===e&&t.pane===n)})}if(t.kind===`stats`)return R6({ok:!0,stats:a.snapshot({gitCache:l.getStats(),usageCache:u.getStats(),sources:G6(e),fileEvents:d.stats(),sourceRuns:p.stats(),runs:f.stats(),transcriptReads:Vo(),renderCache:c.stats,collector:e.collector.stats(),effectCache:m.getStats(),menuIdle:h.getStats(),journalTurns:g.getStats(),sessionState:{sessions:_.size(),observers:_.observers(),revision:_.latestRevision()},frameFeeds:s.getStats(),tmuxStatus:v.stats(),watchersActive:y.size(),dirWatchesActive:y.dirWatches(),nextRestartReason:b.describeNextRestart(),handlerProbes:S.list(),clients:C.list(Ve(new Date(o.now()))),bundle:w,sourceDigest:T,daemon:b.serving(),doctorStores:pQ(ee)})});if(t.kind===`render`){let c=new Date(o.now()),l=Ve(c),u=o.monotonic(),d=Fe(r,u),f=[],p=++a.requestsTotal,m=w6(t,a,e.log,e.home),h=(t,n)=>C.see(t.sessionId,{client:t.hints.client??null,termCols:t.hints.termCols??null,rateLimits:t.rateLimits,claudeConfigDir:Zo(t.hints.claudeConfigDir,e.home),projectDir:t.requested.projectDir,transcript:Ote(t.hookData),frame:n},l,p);m.ok&&(h(m.req,`drawing`),s.note(m.req.sessionId,m.req,p));let g=t=>{t.outcome.kind!==`ok`&&a.requestsErrored++,R3(f,{timedOut:n()?`Y`:`N`,clientLeft:i()?`Y`:`N`,queued:`${d}ms`});let{level:r,line:s}=V3(`render`,f,t.outcome,A(o,u));return e.log(r,s),{resp:t.resp,exitAfterFlush:null,settled:t.settled}};if(!m.ok)return g(r8(m.problems));let _=await m6(e.renderer,e.collector,o,m.req,p,l,u+mr(m.req.deadline,r,{epochMs:c.getTime(),monoMs:u}),f).catch(e=>({outcome:{kind:`threw`,error:e},resp:U3(e),seen:`failed`,settled:u6}));try{return h(m.req,_.seen),g(_)}catch(e){throw _.settled(!1),e}}if(t.kind===`click`)return R6(await Y6(e,r,n,i,(n,r)=>X6(e,t,n,r)));if(t.kind===`debug`){if(!L6(t.what))return R6({ok:!1,error:`unknown debug 'what': ${String(t.what)} (have: ${I6.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let e=c.latestView(),n=e===null?null:{store:e.store,registry:e.registry,config:e.state.config,compiled:e.state.compiled,lastRenderBySegment:t.what===`segments`?J6(e.lastRenderCellsBySegment,e.state.config.globals.colorCompatibility??kx(`colorCompatibility`)):q6};return R6({ok:!0,debug:T6(t.what,n)})}throw Error(`no reply for request ${x(t)}`)}function G6(e){let{payloadProviders:{gitProvider:t,tmuxService:n,usageStore:r,managedStorage:i,hostService:a},renderCache:o,refreshLedger:s}=e,c=t.getStats(),l=n.getStats(),u=r.scanStats(),d=i.stats(),f=o.stats;return{records:s.snapshot(),homes:{daemon:1,configDir:u.entries,repo:c.size,directory:f.size,session:r.getStats().size,view:f.views,pane:l.entries},held:{git:c.held,tmux:l.held,host:a.held(),today:u.held,pluginStorage:d.held},pluginStorage:{folders:d.folders,faults:d.faults,lost:d.lost}}}const K6={endcaps:kx(`endcaps`),colorCompatibility:kx(`colorCompatibility`),wrap:kx(`autoWrap`),padding:kx(`padding`),width:1/0},q6=new Map;function J6(e,t){let n=new Map;for(let[r,i]of e)n.set(r,Cte(i,{...K6,colorCompatibility:t}));return n}async function Y6(e,t,n,r,i){let{clock:a}=e,o=a.monotonic(),s=[[`queued`,`${Fe(t,o)}ms`]],c=await i(s,()=>n()||r());R3(s,{timedOut:n()?`Y`:`N`,clientLeft:r()?`Y`:`N`});let{level:l,line:u}=V3(`click`,s,c,A(a,o));return e.log(l,u),t8(c)}async function X6(e,t,n,r){let i={via:`link`,delivery:{kind:`cli`}};R3(n,{via:`cli`});let{verb:a,value:o}=t;return typeof a!=`string`||typeof o!=`string`?{kind:`bad-request`,problems:[`a click's verb and value are strings, got ${typeof a} and ${typeof o}`]}:Q6(()=>e8(e,a,o,i,n,r))}async function Z6(e,t,n,r,i){return Y6(e,r,n,i,async(n,r)=>{let{urlV:i,url:a}=t;if(R3(n,{via:`forwarder`,urlV:String(i)}),typeof i!=`number`||!Xn.has(i))return{kind:`bad-request`,problems:[`the URL handler's frame version ${x(i)} is not one this daemon speaks (${[...Xn].join(`, `)})`]};if(typeof a!=`string`)return{kind:`bad-request`,problems:[`the URL handler's frame carries no url string`]};let o=Ma(a);if(!o.ok)return{kind:`bad-request`,problems:[o.problem]};let s={via:`link`,delivery:{kind:`forwarder`,urlV:i}};return Q6(()=>e8(e,o.verb,o.value,s,n,r))})}async function Q6(e){try{return await e()}catch(e){return e instanceof Z?{kind:`bad-request`,problems:[e.message]}:e instanceof cq?{kind:`closing`,error:e}:e instanceof lq?{kind:`abandoned`,error:e}:{kind:`threw`,error:e}}}const $6={link:`verb`,"tmux-status":`linkVerb`};async function e8(e,t,n,r,i,a){let{menuIdle:o,verbCtx:s}=e;if(t===`tmux-status-click`)return R3(i,{verb:t}),n8(e,n,i,a);let c=t0.get(t);if(!c)return{kind:`bad-request`,problems:[`unknown click verb: ${t}`]};R3(i,{[$6[r.via]]:t});let l=K1(t,n),u=l?.ok?l.id:null;l===null?R3(i,{sid:`-`}):u!==null&&(R3(i,{sid:u}),o.clickArrived(u));try{await c(n,{...s,arrival:r,placeWaited:e=>R3(i,{placeWait:`${e}ms`}),gatherTook:e=>R3(i,{gather:`${e}ms`}),turnWaited:e=>R3(i,{turnWait:`${e}ms`}),clientGone:a})}finally{u!==null&&o.clickSettled(u)}return{kind:`ok`}}function t8(e){switch(e.kind){case`ok`:return{ok:!0,output:``};case`bad-request`:return{ok:!1,error:e.problems.join(`; `),code:`BAD_REQUEST`,daemonV:3};case`threw`:case`closing`:case`abandoned`:return U3(e.error)}}async function n8(e,n,r,i){let{tmuxStatusLines:a}=e,o=e=>({kind:`bad-request`,problems:[e]}),s=a.linkAt(n);if(s.kind===`refused`)return o(s.reason);if(R3(r,{link:s.url}),s.url.startsWith(`cc-candybar://`)){let t=Ma(s.url);return t.ok?t.verb===`tmux-status-click`?o(`a status-line link names another status-line click`):e8(e,t.verb,t.value,{via:`tmux-status`},r,i):o(t.problem)}return await H$(e.launcher,{bin:t.platform===`darwin`?`/usr/bin/open`:`xdg-open`,args:[s.url],category:`click.open`},`opening ${s.url}`,e.log,z$,e.tmp),{kind:`ok`}}const r8=e=>({outcome:{kind:`bad-request`,problems:e},resp:{ok:!1,error:`malformed hookData: ${e.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3},settled:u6});function i8(e,t){let n=oe(`sha256`).update(t).digest(`hex`).slice(0,16);return E.join(e,`update-act`,n)}const a8={kind:`idle`};function o8(e){if(e===null)return a8;let{act:t,record:n,alive:r,end:i,lastLine:a}=e;if(r)return{kind:`running`,act:t};if(i===null)return{kind:`failed`,act:t,identity:n.identity,reason:`lost: the act ended without a verdict`};if(i.kind===`exit`&&i.code===0)return{kind:`succeeded`,act:t};let o=i.kind===`timeout`?`timeout`:`non-zero (exit ${i.code}): ${a??`no output`}`;return{kind:`failed`,act:t,identity:n.identity,reason:o}}const s8=e=>({stdout:E.join(e,`stdout`),stderr:E.join(e,`stderr`),status:E.join(e,`status`)}),c8=e=>E.join(e,`record.json`);function l8(e){let t;try{t=s.readdirSync(e)}catch(e){if(e.code===`ENOENT`)return[];throw e}return t.filter(e=>/^\d+$/.test(e)).map(Number).sort((e,t)=>e-t)}function u8(e){let t=Jo(e,4096);switch(t.kind){case`absent`:return null;case`failed`:throw Error(`${e}: ${t.reason}`);case`ok`:return t.value.buf.toString(`utf8`).split(/\r?\n/).map(e=>e.trim()).filter(e=>e!==``).at(-1)??null}}function d8(e,t){let n=E.join(e,`.removed-${t}-${process.pid}`);try{s.renameSync(E.join(e,String(t)),n)}catch(e){if(e.code===`ENOENT`)return;throw e}s.rmSync(n,{recursive:!0,force:!0})}const f8=e=>e.now()-o.uptime()*1e3;async function p8(e,t,n,r){if(e.started<=r||!n.jobGroupAlive(e.pid))return!1;let i=await t(e.pid);return e.startTime===null||i.kind===`unavailable`||i.token===e.startTime}function m8(e){try{return JSON.parse(s.readFileSync(c8(e),`utf8`))}catch(e){if(e.code===`ENOENT`)return null;throw e}}const h8=(e,t)=>e.pid===t.pid&&e.startTime===t.startTime;function g8(e,t,n,r){let i=null;async function a(a){let o=E.join(e,String(a)),c=m8(o);if(c===null)return null;if((i===null||!h8(i.record,c))&&(i={record:c,ours:await p8(c,t,n,f8(r)),final:null}),i.final!==null)return i.final;i.ours=i.ours&&n.jobGroupAlive(c.pid);let l=s8(o),u=kt(l.status),d=u===null?null:u8(l.stderr)??u8(l.stdout);if(!s.existsSync(o))return null;let f={act:a,record:c,alive:i.ours,end:u,lastLine:d};return f.alive||(i.final=f),f}return{async read(){let t=null;for(;;){let n=l8(e).at(-1);if(n===void 0)return null;if(n===t)throw Error(`${E.join(e,String(n))}: an act with no record`);let r=await a(n);if(r!==null)return r;t=n}}}}function _8(e,t,n){s.mkdirSync(e,{recursive:!0});let r=s.mkdtempSync(E.join(e,`.claim-`));try{return s.writeFileSync(c8(r),JSON.stringify(n)),s.renameSync(r,t),!0}catch(e){let t=e.code;if(t===`ENOTEMPTY`||t===`EEXIST`)return!1;throw e}finally{s.rmSync(r,{recursive:!0,force:!0})}}async function v8(e,t,n,r,i,a,o,s){let c=(n??0)+1,l=E.join(t,String(c)),u=e.launchJobSync(i,s8(l));if(!u.ok)throw Error(`apply-update: ${u.error}`);let d=!1;try{let e=await s(u.pid);if(!_8(t,l,{identity:r,pid:u.pid,startTime:e.kind===`start`?e.token:null,started:o,deadline:o+a}))return y8;if(l8(t).some(e=>e>c))return d8(t,c),y8;d=!0}finally{d?u.release():u.withdraw()}for(let e of l8(t).filter(e=>e<c))d8(t,e);return{ok:!0,act:c}}const y8={ok:!1,reason:`another act claimed this bundle first`};function b8(e,t,n){let r=s8(E.join(e,String(t.act))).status;return n.endJob(t.record.pid,r,{kind:`timeout`})}function x8(e,t,n){if(t.kind===`pending`)return Ao(t.why);if(e!==void 0&&e.kind!==`pending`){let{at:n,...r}=e;if((0,Y.compareStructural)(r,t))return e}return{...t,at:n}}var S8=class{waiting=new Map;run(e,t){return new Promise((n,r)=>{let i=async()=>{try{n(await t())}catch(e){r(e)}},a=this.waiting.get(e);if(a!==void 0){a.push(i);return}let o=[];this.waiting.set(e,o);let s=t=>void t().then(()=>{let t=o.shift();t===void 0?this.waiting.delete(e):s(t)});s(i)})}};function C8(e){return e.kind===`source`?e.newer.digest:ps(e.newer)}const w8=e=>`${e.version} [${en(e.digest)}]`;function T8(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:w8(e.newer),running:w8(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:ps(e.newer),running:ps(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${hs}@${ps(e.newer)}`,`install`]}}}}const E8={offer:[],failure:[]};function D8(e,t,n){if(e===null)return E8;let r=C8(e);if(!n.enabled||n.dismissed===r)return E8;let i=T8(e),a=`${i.headline}: ${i.newer}. You're on ${i.running}.`,o=t.kind===`failed`&&t.identity===r?[(e=>({about:`update-failed\0${r}`,text:e,copy:e}))(`${i.act} failed: ${t.reason}`)]:[],s=t.kind===`running`?gU(`[${i.busy}]`,null):gU(`[${i.act}]`,Ea([{verb:ca,args:[n.sessionId]}])),c=[gU(a,null),s,gU(`[dismiss]`,Ea([{verb:Wi,args:[n.sessionId,yz,r]}])),gU(`[disable]`,Ea([{verb:Xi,args:[n.sessionId,bz,`false`]},{verb:Wi,args:[n.sessionId,xz,`false`]}]))];return{offer:[{severity:fU,about:`update\0${r}`,message:a,copy:a,lines:[c]}],failure:o}}function O8(e,t){if(e.kind===`pending`)return e;let n=e.value;switch(n.kind){case`stale`:return F({kind:`source`,root:n.root,newer:n.source,running:n.running});case`current`:return I;case`unchecked`:return L(`build: unchecked: ${n.reason}`,`read`);case`not-source-checkout`:return k8(t)}}function k8(e){if(e.kind===`pending`)return e;let t=e.value;switch(t.kind){case`stale`:return F({kind:`release`,newer:t.latest,running:t.installed});case`current`:case`ahead`:return I;case`unchecked`:return L(`release: unchecked: ${t.reason}`,`read`)}}function A8(e){switch(e.kind){case`current`:return[`info`,`build: current ${w8(e.stamp)}`];case`stale`:return[`info`,`build: stale — source ${w8(e.source)}, running ${w8(e.running)}`];case`not-source-checkout`:return[`info`,`build: not a source checkout`];case`unchecked`:return[`warn`,`build: unchecked: ${e.reason}`]}}function j8(e){switch(e.kind){case`current`:return[`info`,`release: current ${ps(e.installed)}`];case`stale`:return[`info`,`release: stale — latest ${ps(e.latest)}, running ${ps(e.installed)}`];case`ahead`:return[`info`,`release: ahead — running ${ps(e.installed)}, latest ${ps(e.latest)}`];case`unchecked`:return[`warn`,`release: unchecked: ${e.reason}`]}}function M8(e){let{fact:t,clock:n,launcher:r,probe:i,entryUrl:a,digest:o,actsDir:s,intervalMs:c,releaseIntervalMs:l,registryUrl:u,fetchImpl:d,gates:f,onApplied:p,log:m}=e,h=Ao(`unread`),g=Ao(`unread`),_=async e=>{let t=await i.startTime(e);if(T)throw new cq(`apply-update`);return t},v=g8(s,_,r,n),y=null,b=null,x=Ne(m),S=Ne(m),C=new S8,w=e=>C.run(`acts`,e),T=!1,ee=[],te=(e,t)=>{ee.push(n.every(t,e,{unref:!0}))},E=()=>{let e=t.get();return e.kind===`ok`?e.value:null};function ne(){let e=E(),t=e===null?null:C8(e);(b===null?null:b.identity)!==t&&(b?.dispose(),b=t===null?null:{identity:t,dispose:f.state.register(yz,[t])})}function D(){let e=T?I:O8(h,g),r=x8(t.get(),e,Ue(n));(0,Y.runInAction)(()=>t.set(r)),ne()}function re(){let e=sn(a,()=>rn(o));return h=F(e),x(A8(e)),D(),e}async function ie(){let e=_s(tn,await gs(hs,d,u,n));g=F(e),S(j8(e)),D()}let O=null,ae=Ne(m);async function oe(e){try{let t=await e();return O=null,{ok:!0,value:t}}catch(e){return e instanceof cq?{ok:!1,error:e.message}:(O=`update act files (${s}): ${e.message}`,ae([`error`,O]),{ok:!1,error:O})}}function se(e){if(!e?.alive||n.now()<=e.record.deadline)return;let{stands:t,signalled:i}=b8(s,e,r),a=t?`timed out`:`outlived its verdict`,o=i?`ending it`:`its group took no signal`;m(`error`,`apply-update: act ${e.act} ${a}; ${o}`)}async function ce(){let e=await oe(async()=>{let e=await v.read();return T||se(e),e});if(T||!e.ok)return;let t=o8(e.value);y===null&&t.kind===`running`&&m(`info`,`apply-update: act ${t.act} is running; watching it`),y?.kind===`running`&&t.kind!==`running`&&(t.kind===`succeeded`&&(m(`info`,`apply-update: act ${t.act} succeeded`),re(),p()),t.kind===`failed`&&m(`error`,`apply-update: act ${t.act} failed: ${t.reason}`)),y=t}let le;async function ue(){await w(ce),!T&&(le=n.after(2e3,()=>void ue(),{unref:!0}))}return{arm(){let e=re();te(re,c),ee.push(()=>le?.()),ue(),e.kind===`not-source-checkout`&&(ie(),te(()=>void ie(),l))},close(){T=!0,D(),ee.forEach(e=>e())},notice:e=>D8(E(),y??a8,e),running:()=>w(async()=>{let e=await oe(()=>v.read());return e.ok&&o8(e.value).kind===`running`}),error:()=>O,act:()=>w(async()=>{if(T)throw new cq(`apply-update`);let e=await oe(()=>v.read());if(T)throw new cq(`apply-update`);if(!e.ok)throw new Z(`apply-update: ${e.error}`);let t=E();if(t===null)throw new Z(`apply-update: nothing newer is known to apply`);let i=T8(t),a=e.value;if(o8(a).kind===`running`)throw new Z(`apply-update: already ${i.busy}`);let o=await v8(r,s,a===null?null:a.act,C8(t),{...i.command,category:`update.apply`},6e5,n.now(),_);if(!o.ok)throw new Z(`apply-update: ${o.reason}`);m(`info`,`apply-update: act ${o.act}: ${i.act} — ${i.command.bin} ${i.command.args?.join(` `)??``}`),y={kind:`running`,act:o.act}})}}function N8(){return Y.observable.box(Ao(`unread`),{deep:!1})}function P8(e,t){try{return F(t(e).mtimeMs)}catch(e){let t=e.code;return t===`ENOENT`||t===`ENOTDIR`?I:L(e.message,`read`)}}function F8(e,t){return e.kind===`ok`&&t.kind===`ok`?e.value===t.value:e.kind===t.kind}function I8(e){let{targets:t,intervalMs:n,stat:r,held:i,exit:a,log:o,clock:s}=e,c=Ne(o),l=t.map(e=>({path:e,stamp:P8(e,r)})),u=l.filter(({stamp:e})=>e.kind!==`failed`),d=null,f=!1,p=()=>{f=!0,d?.()},m=async()=>{if(!f)for(let{path:e,stamp:t}of u){let n=P8(e,r);if(n.kind===`failed`){o(`warn`,`binary stat failed (${e}): ${n.reason}`);continue}if(!F8(t,n)){let t=`binary ${n.kind===`absent`?`gone`:`changed`} (${e})`,r=await i();if(f)return;if(r){c([`info`,`${t}; the restart waits for the running update`]);return}o(`info`,`${t}; shutting down`),p(),a();return}}},h=()=>m().catch(e=>{o(`error`,`binary check failed: ${e.message}`)});return{arm(){for(let{path:e,stamp:t}of l)t.kind===`failed`&&o(`warn`,`binary stat failed at boot (${e}): ${t.reason}; not watched`);d=s.every(n,()=>void h(),{unref:!0})},checkNow:h,close:p}}var L8=class{running=new Map;again=new Set;run(e,t){return this.again.add(e),this.running.has(e)?{kind:`queued`}:{kind:`started`,done:this.start(e,t)}}share(e,t){let n=this.running.get(e);return n===void 0?(this.again.add(e),this.start(e,t)):n}start(e,t){let n=this.loop(e,t);return this.running.set(e,n),n}async loop(e,t){try{do this.again.delete(e),await t();while(this.again.has(e))}finally{this.running.delete(e),this.again.delete(e)}}clear(){this.running.clear(),this.again.clear()}get size(){return this.running.size}};const R8=`pass`,z8={okMs:5*6e4,failedMs:45e3},B8=z8.okMs;function V8({failures:e}){return dj(z8,e,B8)}function H8(e){return e.includes(`first`)?`first`:e.length===0?`period`:`change`}function U8(e){return`git:${e}`}function W8(e,t,n){let r=[{path:t,filenames:[`HEAD`,`index`]},{path:E.join(n,`refs`,`heads`),recursive:!0}],i=r.map(e=>Rc(e.path));return{key:`git:${e}:${r.map((e,t)=>`${e.path}@${zc(i[t])}`).join(`|`)}`,targets:{dirs:r},unbound:i.some(e=>typeof e==`string`||`unreadable`in e)}}function G8(e){return e.kind===`ok`?e.value.branch:void 0}function K8(e){e.missed=!0,gj(e,`unread`)}function q8(e,t){return e.missed&&e.reading.get().kind===`pending`&&hj(e,t.size>0?L([...t].join(`; `),`read`):I),`unkeyed`}function J8({value:e,pr:t}){let n=vj(e);return n.kind===`ok`?F({...n.value,pullRequest:vj(t)}):n}const Y8=L(`git cache closed`,`read`);function X8(e){return t=>L(`${e} threw: ${String(t)}`,`read`)}var Z8=class{repos=new Map;resolutions=new Map;closed=!1;hits=0;misses=0;changes=0;gitRefreshes;prRefreshes;inner;periodMs;maxRepos;forgeLookups;watchers;ownsWatchers;logger;clock;constructor(e){this.inner=e.inner,this.clock=e.clock,this.periodMs=e.periodMs??3e4,this.maxRepos=e.maxRepos??64,this.forgeLookups=new Mo(e.maxPrLookups??2),this.logger=e.logger??Pe;let t=e.ledger??new Dj(this.logger);this.gitRefreshes=t.declare({name:`git`,scope:`repo`,refresh:[`first`,`period`,`change`]}),this.prRefreshes=t.declare({name:`pr`,scope:`repo`,refresh:[`first`,`period`]}),e.watchers?(this.watchers=e.watchers,this.ownsWatchers=!1):(this.watchers=new lj({clock:this.clock,logger:this.logger}),this.ownsWatchers=!0)}getWatcherRegistry(){return this.watchers}getStats(){let e=0;for(let t of this.repos.values())t.holders>0&&e++;return{size:this.repos.size,held:e,hits:this.hits,misses:this.misses,changes:this.changes,watchers:this.watchers.size()}}resolution(e,t){let n=`${e}|${t??``}`,r=this.clock.monotonic(),i=this.resolutions.get(n);if(i&&r-i.computedAt<3e4)return this.resolutions.delete(n),this.resolutions.set(n,i),i.known;let a;try{a=this.inner.resolveEffectiveGitDir(e,t)}catch(e){a=L(`resolver threw: ${String(e)}`,`read`)}for(this.resolutions.set(n,{known:a,computedAt:r}),a.kind===`failed`&&this.logger(`warn`,`git resolve failed (${e}): ${a.reason}`);this.resolutions.size>this.maxRepos;){let e=this.resolutions.keys().next().value;if(e===void 0)break;this.resolutions.delete(e)}return a}declare(e,t,n){let r=this.asked(e,t,n);if(r.kind===`settled`)return bj(r.outcome);let{state:i}=r;return i.value.reading.get().kind===`pending`?this.misses++:this.hits++,{current:()=>J8(i)}}asked(e,t,n){if(this.closed)return{kind:`settled`,outcome:Y8};let r=this.resolution(t,n);return r.kind===`ok`?{kind:`asked`,state:this.ask(r.value,e)}:{kind:`settled`,outcome:r}}changed(e){let t=this.repos.get(e);if(t){if(this.changes++,t.holders===0){t.value.missed=!0;return}this.changedPass(t,`watch`)}}touch(e){this.repos.get(e.root)===e&&(this.repos.delete(e.root),this.repos.set(e.root,e))}built(e){let t={period:new fj(()=>{this.readPr(n,t,`period`)},this.clock),seen:new Map,missed:!0,key:``,remote:I,reading:pj(),inFlight:null},n={root:e,refresh:new L8,watch:this.followWatch(e,null).watch,period:new fj(()=>{n.refresh.share(R8,()=>this.refreshPass(n))},this.clock),value:{reading:pj(),missed:!1},pr:t,holders:0,asked:new Set};return this.repos.set(e,n),n}followWatch(e,t){let n=this.inner.resolveGitDir(e),r=W8(e,n,this.inner.resolveCommonGitDir(n)),i=this.watchers.follow(t,r,()=>this.changed(e));return i.move===`rebound`&&this.logger(`info`,`git watch bound root=${e} dirs=${r.targets.dirs.map(e=>e.path).join(`,`)} deaf=${i.watch.handle.deaf.length}`),i}changedPass(e,t){e.asked.add(t),e.refresh.run(R8,()=>this.refreshPass(e))}async refreshPass(e){try{await this.pass(e)}catch(t){this.logger(`error`,`git refresh threw (${e.root}): ${String(t)}`)}finally{e.period.landed(this.periodMs)}}hold(e){return e.holders++,e.value.missed&&(K8(e.pr),e.asked.add(`resume`)),e.pr.missed&&e.pr.key!==``&&e.asked.add(`owed`),this.held(e),this.evict(),()=>{e.holders--,this.held(e)}}queue(e,t){e.asked.size>t&&e.refresh.run(R8,()=>this.refreshPass(e))}held(e){e.period.hold(e.holders>0),e.pr.period.hold(e.holders>0&&!e.pr.missed)}ask(e,t){let n=this.repos.get(e);n!==void 0&&this.touch(n);let r=n??this.built(e),i=r.asked.size;return n===void 0&&r.asked.add(`first`),t.take(U8(e),()=>this.hold(r)),this.queue(r,i),r}async pass(e){if(this.repos.get(e.root)!==e)return;let t=this.clock.monotonic(),n=[...e.asked];e.asked.clear();let r=this.followWatch(e.root,e.watch);e.watch=r.watch;let[i,a]=await Promise.all([this.inner.getGitInfo(e.root).catch(X8(`git fetch`)),this.remoteOf(e)]);if(this.repos.get(e.root)!==e)return;let o=new Set;if(e.value.missed=!1,hj(e.value,i),i.kind===`failed`&&o.add(i.reason),i.kind===`ok`)for(let e of dY(i.value))o.add(e);let s=G8(i),c=s===void 0?q8(e.pr,o):this.movePr(e,s,a);this.held(e),this.gitRefreshes.recorded(`${e.root} asked=${n.join(`,`)||`-`} pr=${c} watch=${r.move}`,H8(n),o.size===0?F(null):L([...o].join(`; `),`read`),A(this.clock,t))}remoteOf(e){return this.inner.getRepoRemoteUrl(e.root).catch(X8(`git remote`))}movePr(e,t,n){let{pr:r}=e,i=`${t}|${n.kind===`ok`?n.value:n.kind}`;if(i===r.key&&!r.missed)return`kept`;r.key=i,r.remote=n;let a=r.seen.get(i);return a===void 0?e.holders===0?(K8(r),`owed`):(gj(r,`unread`),r.missed=!1,this.readPr(e,r,`first`),`looked-up`):(r.seen.delete(i),r.seen.set(i,a),r.missed=!1,hj(r,a.outcome),r.period.landed(V8(a),a.at),`recalled`)}readPr(e,t,n){let r=t.key;if(t.inFlight?.key===r)return t.inFlight.done;let i=t.remote,a=this.clock.monotonic(),o=(i.kind===`ok`?this.forgeLookups.run(()=>(a=this.clock.monotonic(),this.inner.resolvePullRequest(e.root,i.value))).catch(X8(`PR lookup`)):Promise.resolve(i.kind===`failed`?i:I)).then(i=>{if(t.inFlight?.key===r&&(t.inFlight=null),this.repos.get(e.root)!==e)return;this.prRefreshes.recorded(`${e.root} key=${R(r)}`,n,i,A(this.clock,a));let o=this.clock.monotonic(),s={outcome:i,at:o,failures:i.kind===`failed`?(t.seen.get(r)?.failures??0)+1:0};t.seen.delete(r),t.seen.set(r,s);for(let e of t.seen.keys()){if(t.seen.size<=16)break;t.seen.delete(e)}t.key!==r||t.missed||(hj(t,i),t.period.landed(V8(s),o))});return t.inFlight={key:r,done:o},o}drop(e){let t=L(`git state dropped: ${e.root}`,`read`);_j(e.value,t),_j(e.pr,t),this.repos.delete(e.root),e.refresh.clear(),e.watch.handle.release(),e.period.dispose(),e.pr.period.dispose()}evict(){for(let e of this.repos.values()){if(this.repos.size<=this.maxRepos)return;e.holders>0||(this.drop(e),this.logger(`info`,`gitCache evict ${e.root}`))}}close(){this.closed=!0;for(let e of this.repos.values())this.drop(e);this.repos.clear(),this.resolutions.clear(),this.ownsWatchers&&this.watchers.closeAll()}},Q8=class{static usageDir(e){return E.join(e,`usage`)}static locksDir(e){return E.join(e,`locks`)}static isLocked(e,t){let n=E.join(this.locksDir(e),t);if(!s.existsSync(n))return!1;try{let e=s.readFileSync(n,`utf-8`),r=parseInt(e.trim(),10);if(isNaN(r))return k(`Invalid PID in lock file ${t}, removing stale lock`),s.unlinkSync(n),!1;try{return process.kill(r,0),!0}catch(e){return e.code===`ESRCH`?(k(`Removing stale lock file ${t} for dead process ${r}`),s.unlinkSync(n),!1):(k(`Error checking process ${r} for lock ${t}:`,e),!0)}}catch(e){return k(`Error reading lock file ${t}:`,e),!0}}static async acquireLock(e,t,n,r=5e3){await this.ensureCacheDirectories(e);let i=E.join(this.locksDir(e),n),a=t.monotonic(),o=String(process.pid);for(;t.monotonic()-a<r;)try{return await s.promises.writeFile(i,o,{flag:`wx`}),k(`Lock acquired for ${n}`),!0}catch(e){if(e.code===`EEXIST`)await Le(t,50);else throw e}return k(`Failed to acquire lock for ${n} within ${r}ms`),!1}static async releaseLock(e,t){let n=E.join(this.locksDir(e),t);try{await s.promises.unlink(n),k(`Lock released for ${t}`)}catch(e){e.code!==`ENOENT`&&k(`Error releasing lock for ${t}:`,e)}}static async ensureCacheDirectories(e){try{await Promise.all([s.promises.mkdir(e,{recursive:!0}),s.promises.mkdir(this.usageDir(e),{recursive:!0}),s.promises.mkdir(this.locksDir(e),{recursive:!0})])}catch(e){k(`Failed to create cache directories:`,e)}}static createProjectHash(e){return oe(`md5`).update(e).digest(`hex`).substring(0,8)}static async getUsageCache(e,t,n,r){await this.ensureCacheDirectories(e);let i=E.join(this.usageDir(e),`${n}.json`),a=`${n}.usage.lock`;for(let o=0;o<3;o++){if(this.isLocked(e,a)){k(`Cache for ${n} is locked, waiting...`),await Le(t,75);continue}try{let e=await s.promises.readFile(i,`utf-8`),t=JSON.parse(e);return!r||t.timestamp>=r?(k(`[CACHE-HIT] ${n} disk cache: found`),this.deserializeDates(t.data)):(k(`${n} cache outdated: cache=${t.timestamp}, latest=${r}`),null)}catch(e){if(e.code===`ENOENT`)return k(`No shared ${n} usage cache found`),null;k(`Attempt ${o+1} failed to read ${n} cache: ${e.message}. Retrying...`),await Le(t,75)}}return k(`Failed to read ${n} cache after 3 attempts.`),null}static deserializeDates(e){return Array.isArray(e)?e.map(e=>({...e,timestamp:new Date(e.timestamp)})):e}static async setUsageCache(e,t,n,r,i){let a=`${n}.usage.lock`;if(!await this.acquireLock(e,t,a)){k(`Could not acquire lock to set usage cache for ${n}`);return}try{await this.ensureCacheDirectories(e);let a=E.join(this.usageDir(e),`${n}.json`),o={data:r,timestamp:i||t.now()},c=JSON.stringify(o);await s.promises.writeFile(a,c,`utf-8`),k(`[CACHE-SET] ${n} disk cache stored`)}catch(e){k(`Failed to save ${n} usage cache:`,e)}finally{await this.releaseLock(e,a)}}};const $8={"claude-haiku-4-5-20251001":{name:`Claude Haiku 4.5`,input:1,output:5,cache_write_5m:1.25,cache_write_1h:2,cache_read:.1},"claude-haiku-4-5":{name:`Claude Haiku 4.5`,input:1,output:5,cache_write_5m:1.25,cache_write_1h:2,cache_read:.1},"claude-opus-4-20250514":{name:`Claude Opus 4`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-opus-4-1":{name:`Claude Opus 4.1`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-opus-4-1-20250805":{name:`Claude Opus 4.1`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-sonnet-4-20250514":{name:`Claude Sonnet 4`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-4-opus-20250514":{name:`Claude 4 Opus`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-4-sonnet-20250514":{name:`Claude 4 Sonnet`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-sonnet-4-5":{name:`Claude Sonnet 4.5`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-sonnet-4-5-20250929":{name:`Claude Sonnet 4.5`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-opus-4-5":{name:`Claude Opus 4.5`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-5-20251101":{name:`Claude Opus 4.5`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-6":{name:`Claude Opus 4.6`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-6-20260205":{name:`Claude Opus 4.6`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-sonnet-4-6":{name:`Claude Sonnet 4.6`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3}};var e5=class{static executionCache=null;static modelPricingCache=new Map;static GITHUB_PRICING_URL=`https://raw.githubusercontent.com/promptctl/cc-candybar/main/pricing.json`;static async loadDiskCache(e,t){let n=t.now()-1440*60*1e3;return await Q8.getUsageCache(e,t,`pricing`,n)}static async saveDiskCache(e,t,n){await Q8.setUsageCache(e,t,`pricing`,n)}static async fetchPricingData(){return new Promise(e=>{let t=new n(this.GITHUB_PRICING_URL),r=_e({hostname:t.hostname,path:t.pathname,headers:{"User-Agent":`cc-candybar`,"Cache-Control":`no-cache`},timeout:5e3},t=>{if(t.statusCode!==200){k(`HTTP ${t.statusCode}: ${t.statusMessage}`),e(null);return}let n=``,i=0;t.setEncoding(`utf8`),t.on(`data`,t=>{if(i+=Buffer.byteLength(t),i>1048576){k(`Response too large`),r.destroy(),e(null);return}n+=t}),t.on(`end`,()=>{try{let t=JSON.parse(n),r=t._meta,i={};for(let[e,n]of Object.entries(t))e!==`_meta`&&(i[e]=n);this.validatePricingData(i)?(k(`Fetched fresh pricing from GitHub for ${Object.keys(i).length} models`),k(`Pricing last updated: ${r?.updated||`unknown`}`),e(i)):(k(`Invalid pricing data structure`),e(null))}catch(t){k(`Failed to parse JSON:`,t),e(null)}}),t.on(`error`,t=>{k(`Response error:`,t),e(null)})});r.on(`error`,t=>{k(`Request error:`,t),e(null)}),r.on(`timeout`,()=>{k(`Request timeout`),r.destroy(),e(null)}),r.end()})}static async getCurrentPricing(e,t){if(this.executionCache!==null)return k(`[CACHE-HIT] Pricing execution cache: ${Object.keys(this.executionCache).length} models`),this.executionCache;let n=await this.loadDiskCache(e,t);if(n)return k(`[CACHE-HIT] Pricing disk cache: ${Object.keys(n).length} models`),this.executionCache=n,k(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(n).length} models`),n;let r=await this.fetchPricingData();return r?(await this.saveDiskCache(e,t,r),k(`[CACHE-SET] Pricing disk cache stored: ${Object.keys(r).length} models`),this.executionCache=r,k(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(r).length} models`),r):(k(`[CACHE-FALLBACK] Using offline pricing data: ${Object.keys($8).length} models`),this.executionCache=$8,k(`[CACHE-SET] Pricing execution cache stored: ${Object.keys($8).length} models`),$8)}static validatePricingData(e){if(!e||typeof e!=`object`)return!1;for(let[,t]of Object.entries(e)){if(!t||typeof t!=`object`)return!1;let e=t;if(typeof e.input!=`number`||typeof e.output!=`number`||typeof e.cache_read!=`number`)return!1}return!0}static async getModelPricing(e,t,n){if(this.modelPricingCache.has(e))return k(`[CACHE-HIT] Model pricing cache: ${e}`),this.modelPricingCache.get(e);let r=await this.getCurrentPricing(t,n),i;return i=r[e]?r[e]:this.fuzzyMatchModel(e,r),this.modelPricingCache.set(e,i),k(`[CACHE-SET] Model pricing cache: ${e}`),i}static fuzzyMatchModel(e,t){let n=e.toLowerCase();for(let[e,r]of Object.entries(t))if(e.toLowerCase()===n)return r;for(let{pattern:e,fallback:r}of[{pattern:[`opus-4-6`,`claude-opus-4-6`],fallback:`claude-opus-4-6-20260205`},{pattern:[`opus-4-5`,`claude-opus-4-5`],fallback:`claude-opus-4-5-20251101`},{pattern:[`opus-4-1`,`claude-opus-4-1`],fallback:`claude-opus-4-1-20250805`},{pattern:[`opus-4`,`claude-opus-4`],fallback:`claude-opus-4-20250514`},{pattern:[`sonnet-4-6`,`sonnet-4.6`,`claude-sonnet-4-6`],fallback:`claude-sonnet-4-6`},{pattern:[`sonnet-4.5`,`4-5-sonnet`,`sonnet-4-5`],fallback:`claude-sonnet-4-5-20250929`},{pattern:[`sonnet-4`,`claude-sonnet-4`],fallback:`claude-sonnet-4-20250514`},{pattern:[`haiku-4.5`,`4-5-haiku`,`haiku-4-5`],fallback:`claude-haiku-4-5-20251001`},{pattern:[`haiku`],fallback:`claude-haiku-4-5-20251001`},{pattern:[`opus`],fallback:`claude-opus-4-20250514`},{pattern:[`sonnet`],fallback:`claude-sonnet-4-5-20250929`}])if(e.some(e=>n.includes(e))&&t[r])return t[r];return t[`claude-sonnet-4-5-20250929`]||{name:`${e} (Unknown Model)`,input:3,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3,output:15}}static async calculateCostForEntry(e,t,n){let r=e.message?.usage;if(!r)return 0;let i=this.extractModelId(e),a=await this.getModelPricing(i,t,n),o=r.input_tokens||0,s=r.output_tokens||0,c=r.cache_creation_input_tokens||0,l=r.cache_read_input_tokens||0,u=o/1e6*a.input,d=s/1e6*a.output,f=l/1e6*a.cache_read,p=c/1e6*a.cache_write_5m;return u+d+p+f}static extractModelId(e){if(e.model&&typeof e.model==`string`)return e.model;let t=e.message;if(t?.model){let e=t.model;if(typeof e==`string`)return e;let n=e;return(typeof n?.id==`string`?n.id:null)||`claude-sonnet-4-5-20250929`}return e.model_id&&typeof e.model_id==`string`?e.model_id:`claude-sonnet-4-5-20250929`}},t5=class{inflight=new Map;run(e,t){return this.inflight.get(e)??this.start(e,t)}start(e,t){let n=t();this.inflight.set(e,n);let r=()=>{this.inflight.get(e)===n&&this.inflight.delete(e)};return n.then(r,r),n}get size(){return this.inflight.size}};function n5(e,t){let n=e?e.input+e.cacheCreation+e.cacheRead:0,r=e?e.output:0;return{input:n,output:r,total:n+r,atMs:t}}const r5={okMs:60*1e3,failedMs:10*1e3},i5={calculatedCost:null,tokens:null,tokenBreakdown:null};function a5(e){let t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-1),t.getTime()}function o5(){return{input:0,output:0,cacheCreation:0,cacheRead:0}}const s5={entries:0,cost:0,breakdown:o5(),days:new Map};async function c5(e,t,n,r){let i=UY(new Date(a5(r.now()))),a=e.entries,o=e.cost,s={...e.breakdown},c=new Map;for(let[t,n]of e.days)t>=i&&c.set(t,{...n});for(let e of t){let t=e.message?.usage;if(!t)continue;a++;let l=e.costUSD??await e5.calculateCostForEntry(e.raw,n,r);o+=l,s.input+=t.input_tokens||0,s.output+=t.output_tokens||0,s.cacheCreation+=t.cache_creation_input_tokens||0,s.cacheRead+=t.cache_read_input_tokens||0;let u=UY(new Date(e.timestamp));if(u<i)continue;let d=c.get(u)??{...VY};d.cost+=l,d.input+=t.input_tokens||0,d.output+=t.output_tokens||0,d.cacheCreation+=t.cache_creation_input_tokens||0,d.cacheRead+=t.cache_read_input_tokens||0,c.set(u,d)}return{entries:a,cost:o,breakdown:s,days:c}}function l5(e){let t=0,n=0,r=o5(),i=new Map;for(let{value:a}of e.values()){t+=a.entries,n+=a.cost,r.input+=a.breakdown.input,r.output+=a.breakdown.output,r.cacheCreation+=a.breakdown.cacheCreation,r.cacheRead+=a.breakdown.cacheRead;for(let[e,t]of a.days){let n=i.get(e)??{...VY};HY(n,t),i.set(e,n)}}if(t===0)return{usage:i5,days:i};let a=r.input+r.output+r.cacheCreation+r.cacheRead;return{usage:{calculatedCost:n,tokens:a,tokenBreakdown:r},days:i}}function u5(e,t){return e!==void 0&&t.some(t=>e.startsWith(t))}function d5(e,t){let n=new Map;for(let{record:r}of e)if(!(r===void 0||!u5(r.transcriptPath,t)))for(let[e,t]of r.days){let r=n.get(e)??{...VY};HY(r,t),n.set(e,r)}return Object.fromEntries(n)}async function f5(e,t,n){let r=0,i=async()=>{for(;r<e.length;){let t=e[r++];await n(t)}},a=Math.min(t,e.length);await Promise.all(Array.from({length:a},i))}function p5(e,t){(0,Y.runInAction)(()=>e.set(t))}var m5=class{sessions=Y.observable.map(void 0,{deep:!1});flight=new t5;scans;daySets=new Map;speedFlight=new t5;requestFlight=new t5;staleAgeMs;host;log;renderTally={hits:0,misses:0};ledger;usage;sweeps=0;stopSweep=null;closed=!1;clock;constructor(e){this.host=e.host,this.clock=e.clock,this.log=e.logger??Pe,this.ledger=e.ledger??new Dj(this.log),this.usage=this.ledger.declare({name:`usage`,scope:`session`,refresh:[`request`]}),this.staleAgeMs=e.staleAgeMs??864e5,this.scans=new Sj({name:`today`,scope:`configDir`,keyOf:e=>e.join(`\0`),fields:e=>`dirs=${R(e.join(`,`))}`,read:e=>this.scan(e),every:()=>e.rescan??r5,watch:xj,maxEntries:8,logger:this.log,ledger:this.ledger,clock:this.clock});let t=e.sweepIntervalMs??3e5;t>0&&(this.stopSweep=this.clock.every(t,()=>this.sweepStale(),{unref:!0}))}getStats(){return{size:this.sessions.size,hits:this.renderTally.hits,misses:this.renderTally.misses,sweeps:this.sweeps}}scanStats(){return this.scans.stats()}request(e,t){let n=null,r=()=>{if(n!==null)return n;let r=Po(t);return n={stamp:r,record:this.refreshed(e,t,r)},n};return{usage:async()=>{let e=await r().record;return e.kind===`failed`?e:F(e.kind===`ok`?e.value.usage:i5)},speed:t=>this.observed(e,r,t),today:async()=>{await r().record}}}usageOf(e){let t=this.sessions.get(e);if(t===void 0)return Ao(`unread`);let n=t.failure.get();return n===null?F(t.record?.usage??i5):L(n,`read`)}refreshed(e,t,n){return this.requestFlight.run(`${e}:${n}`,async()=>{let r={hits:0,misses:0},i=this.clock.monotonic(),a=await this.ingest(e,t,r,n);return this.renderTally.hits+=r.hits,this.renderTally.misses+=r.misses,r.misses>0&&this.usage.recorded(`sid=${R(e)}`,`request`,a,A(this.clock,i)),p5(this.hold(e).failure,a.kind===`failed`?a.reason:null),a})}refreshToday(e){return this.request(e?.session_id??``,e?.transcript_path).today()}declareToday(e,t){if(this.closed)return bj(L(`usage store closed`,`read`));let n=ZY(t,this.host.home),r=this.scans.declare(e,n),i=this.daySet(n);return{current:()=>{let e=r.current();return e.kind===`ok`?F({roots:i.roots,sums:i.sums.read()}):e}}}daysOutside(e,t){let n=this.sessions.get(e);if(n===void 0)return I;let r=n.failure.get();if(r!==null)return L(r,`read`);let i=n.record;return i===void 0||u5(i.transcriptPath,t)?I:F(Object.fromEntries(i.days))}observeSpeed(e,t,n){return this.request(e,t).speed(n)}async observed(e,t,n){if(!e)return I;let{stamp:r,record:i}=t();return this.speedFlight.run(`${e}:${r}`,async()=>{let t=await i;if(t.kind===`failed`)return p5(this.hold(e).speed,t),t;let r=n5(t.kind===`ok`?t.value.usage.tokenBreakdown:null,n),{ring:a}=this.hold(e),o;for(let e of a)e.atMs<r.atMs&&(o===void 0||e.atMs>o.atMs)&&(o=e);a.push(r),a.sort((e,t)=>e.atMs-t.atMs),a.length>64&&a.shift();let s=F({...o!==void 0&&{prev:o},cur:r,samples:[...a]});return p5(this.hold(e).speed,s),s})}speedOf(e){return e?this.sessions.get(e)?.speed.get()??Ao(`unread`):I}async ingest(e,t,n,r){if(!e)return I;let i=this.see(e)?.record;if(i&&r!==``&&i.transcriptStamp===r)return n.hits++,F(i);if(!t)return i?F(i):I;n.misses++;let a;try{a=await this.flight.run(`${e}:${r}`,async()=>{let n=this.sessions.get(e)?.record;return{prior:n,outcome:await this.refold(e,t,n)}})}catch(t){return L(`usage refold (${e}): ${t instanceof Error?t.message:String(t)}`,`read`)}let{prior:o,outcome:s}=a;if(s.kind!==`ok`)return s;let c={files:s.value.files,usage:s.value.usage,days:s.value.days,transcriptStamp:s.value.mainStamp,transcriptPath:t},l=this.sessions.get(e)?.record;return l===o?(this.stored(e,c),F(c)):l===void 0?F(c):this.ingest(e,t,n,r)}stored(e,t){let n=this.hold(e);(0,Y.runInAction)(()=>this.sessions.set(e,{...n,record:t}))}see(e){let t=this.sessions.get(e);return t&&(t.lastSeenAt=this.clock.now()),t}hold(e){let t=this.see(e);if(t)return t;let n={lastSeenAt:this.clock.now(),record:void 0,ring:[],failure:Y.observable.box(null),speed:Y.observable.box(void 0,{deep:!1})};return(0,Y.runInAction)(()=>this.sessions.set(e,n)),n}daySet(e){let t=e.join(`\0`),n=this.daySets.get(t);if(n!==void 0)return n;let r=e.map(e=>ie(e,`projects`)+O),i={roots:r,sums:new OC(`today over ${e.join(`,`)}`,()=>d5(this.sessions.values(),r))};return this.daySets.set(t,i),i}async refold(e,t,n){let r=await eX(e,D(t),n===void 0?void 0:new Set(n.files.keys()));for(let e of lX(r.longLines))this.log(`info`,e);let i=new Map,a=``;for(let e of[t,...r.paths]){let r=n?.files.get(e),o=await uX(e,r,s5,(e,t)=>c5(e,t,un(this.host),this.clock));if(o.kind===`failed`)return o;if(o.kind===`absent`){r&&i.set(e,r);continue}let{folded:s,longLines:c}=o.value;for(let e of lX(c))this.log(`info`,e);i.set(e,s),e===t&&(a=s.cursor.stamp)}return F({files:i,...l5(i),mainStamp:a})}async scan(e){try{let t=a5(this.clock.now()),n=await QY(e),r=[];for(let e of n){let n=await $Y(Ro(e));for(let i of n??[]){if(!i.endsWith(`.jsonl`))continue;let n=ie(e,i),a=await $Y(zo(n));a===void 0||a.mtimeMs<t||r.push({sessionId:i.slice(0,-6),path:n,stamp:Fo(a)})}}let i=[],a={hits:0,misses:0};return await f5(r,8,async e=>{let t=await this.ingest(e.sessionId,e.path,a,e.stamp);t.kind===`failed`&&(i.push(t.reason),this.log(`warn`,`usageStore scan: ${t.reason}`))}),this.log(`info`,`usageStore scan dirs=${R(e.join(`,`))} sessions=${r.length} read=${a.misses} failed=${i.length}`),i.length>0?L(`usage scan: ${i.length} of ${r.length} sessions could not be read — ${i[0]}`,`read`):F({sessions:r.length,read:a.misses})}catch(e){return L(`usage scan: ${e instanceof Error?e.message:String(e)}`,`read`)}}sweepStale(){let e=this.clock.now(),t=UY(new Date(e)),n=0,r=0,i=0;return(0,Y.runInAction)(()=>{for(let[a,{lastSeenAt:o,record:s}]of[...this.sessions])if(!(e-o<=this.staleAgeMs)){if(s?.days.has(t)){r++;continue}this.sessions.delete(a),n++,s===void 0&&i++}}),n>0&&this.sweeps++,(n>0||r>0)&&this.log(`info`,`usageStore sweep dropped=${n} noRecord=${i} held=${r}`),n}close(){this.closed=!0,this.stopSweep?.(),this.stopSweep=null,this.scans.close(),(0,Y.runInAction)(()=>{for(let{sums:e}of this.daySets.values())e.release();this.sessions.clear()}),this.daySets.clear()}};const h5={command:null,todos:[],pending:[],done:[]};function g5(e,t){let n=e.findIndex(e=>e.name===t);return n<0?[...e,{name:t,count:1}]:e.map((e,t)=>t===n?{name:e.name,count:e.count+1}:e)}function _5(e,t){switch(t.userEntry){case`prompt`:return{...e,command:t.activity?.command??null,pending:[],done:[]};case`interrupt`:return{...e,pending:[]};case`turn`:case`tool-result`:case`claude-code`:case void 0:return e}}function v5(e,t){if(t.isSidechain)return e;let n=_5(e,t),r=t.activity;if(r===void 0)return n;let i=n.pending,a=n.done;r.started!==void 0&&(i=[...i,...r.started]);for(let e of r.finished??[]){let t=i.findIndex(t=>t.id===e);t<0||(a=g5(a,i[t].name),i=[...i.slice(0,t),...i.slice(t+1)])}return{...n,pending:i,done:a,todos:r.todos??n.todos}}function y5(e){return{command:e.command,todos:e.todos,running:e.pending.reduce((e,t)=>g5(e,t.name),[]),done:e.done}}var b5=class{fold;constructor(e){let t=e.logger??Pe;this.fold=new fX(h5,v5,(e.ledger??new Dj(t)).declare({name:`activity`,scope:`session`,refresh:[`request`]}),e.clock,t)}async getActivityInfo(e,t){return x5(e,await this.fold.read(e,t.transcript_path))}activityOf(e){let t=this.fold.answer(e);return t.kind===`pending`?t:x5(e,t)}};function x5(e,t){return t.kind===`failed`?L(`activity (${e}): ${t.reason}`,t.failedAt):F(y5(t.value))}const S5=3e4;var C5=class{names;constructor(e){let t=e.logger??Pe;this.names=new Sj({name:`tmux`,scope:`pane`,keyOf:e=>`${e.socket}\n${e.pane}`,fields:e=>`pane=${R(e.pane)} socket=${R(e.socket)}`,read:t=>w5(e.launcher,t),every:()=>({okMs:S5,failedMs:S5}),watch:xj,maxEntries:64,logger:t,ledger:e.ledger??new Dj(t),clock:e.clock})}declare(e,t){return this.names.declare(e,t)}getStats(){return this.names.stats()}close(){this.names.close()}};async function w5(e,t){let n=await bc(e,t,`tmux`,[`display-message`,`-p`,`-t`,t.pane,`#S`]);if(n.kind!==`ok`)return L(n.reason,`read`);let r=n.stdout.trim();return r?F(r):I}const T5=6e4,E5={okMs:T5,failedMs:T5};function D5(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}function O5(e,t){try{let e=t();return Promise.resolve(e===``?I:F(e))}catch(t){return Promise.resolve(L(`host.${e}: ${String(t)}`,`read`))}}var k5=class{name;user;constructor(e){let t=e.logger??Pe,n={scope:`daemon`,keyOf:()=>``,fields:()=>`-`,every:()=>E5,watch:xj,maxEntries:1,logger:t,ledger:e.ledger??new Dj(t),clock:e.clock};this.name=new Sj({...n,name:`host.name`,read:()=>O5(`name`,()=>D5(o.hostname()))}),this.user=new Sj({...n,name:`host.user`,read:()=>O5(`user`,()=>o.userInfo().username)})}declareName(e){return this.name.declare(e,null)}declareUser(e){return this.user.declare(e,null)}held(){return this.name.stats().held+this.user.stats().held}close(){this.name.close(),this.user.close()}},A5=class{known=new dX(64);refreshes;constructor(e,t=Pe,n=new Dj(t)){this.clock=e,this.refreshes=n.declare({name:`autocompact`,scope:`configDir`,refresh:[`request`]})}window(e){let t=j5(e),n=this.known.get(e);if(n!==void 0&&n.stamp===t)return this.known.touch(e),n.outcome;let r=this.clock.monotonic(),i=vI(e);return this.refreshes.recorded(`path=${R(e)} stamp=${R(t)}`,`request`,i,A(this.clock,r)),this.known.set(e,{stamp:t,outcome:i}),i}stored(e){return this.known.get(e)?.outcome??Ao(`unread`)}getStats(){let{refreshes:e,failures:t,abandoned:n,lastMs:r}=this.refreshes.record();return{entries:this.known.size,refreshes:e,failures:t,abandoned:n,lastMs:r}}};function j5(e){try{let t=s.statSync(e,{throwIfNoEntry:!1});return t===void 0?`absent`:Fo(t)}catch(e){return`unread:${e.code??`error`}`}}const M5=/"(?:cache_read_input_tokens|cache_creation_input_tokens)":[1-9]/;function N5(e){let t;try{t=JSON.parse(e)}catch{return null}let n=t.message?.usage;if(!((n?.cache_read_input_tokens??0)>0||(n?.cache_creation_input_tokens??0)>0))return null;let r=t.timestamp==null?NaN:Date.parse(t.timestamp);return Number.isNaN(r)?null:r}var P5=class{known=new dX(256);refreshes;constructor(e,t=Pe,n=new Dj(t)){this.clock=e,this.refreshes=n.declare({name:`cache`,scope:`session`,refresh:[`request`]})}async refresh(e,t){let n=Po(t),r=this.known.get(e);if(r!==void 0&&n!==``&&r.stamp===n&&r.outcome.kind!==`failed`)return this.known.touch(e),r.outcome;let i=await this.read(e,t,n);return this.known.set(e,{stamp:n,outcome:i}),i}expiryOf(e){return this.known.get(e)?.outcome??Ao(`unread`)}getStats(){let{refreshes:e,failures:t,abandoned:n,lastMs:r}=this.refreshes.record();return{entries:this.known.size,refreshes:e,failures:t,abandoned:n,lastMs:r}}async read(e,t,n){let r=this.clock.monotonic(),i=await F5(t);return this.refreshes.recorded(`sid=${R(e)} stamp=${R(n)}`,`request`,i,A(this.clock,r)),i}};async function F5(e){let t=await I5(e);return t.kind===`ok`?F(Math.floor((t.value+36e5)/1e3)):t}async function I5(e){for(let t of[65536,1048576]){let n=await qo(e,t);if(n.kind!==`ok`)return n;let r=L5(n.value.buf,n.value.fromStart);if(r!=null)return F(r);if(n.value.fromStart)return I}return I}function L5(e,t){let n=e.toString(`utf8`).split(`
484
- `),r=+!t;for(let e=n.length-1;e>=r;e--){let t=n[e];if(!t||!M5.test(t))continue;let r=N5(t);if(r!=null)return r}return null}const R5=e=>GV(e),z5=e=>E.join(e.storage.folder,R5(e.sessionId)),B5=e=>JSON.stringify([e.folder,e.generation]),V5=(e,t)=>e.folder===t.folder&&e.generation===t.generation;var H5=class{sessions;folders=new Map;watched=new Map;faultCounts={unusable:0,refused:0,error:0};lost=0;watchers;logger;identityOf;fileEvents;clock;unsubscribe;constructor(e){this.watchers=e.watchers,this.logger=e.logger,this.identityOf=e.identityOf??Fc,this.fileEvents=e.fileEvents,this.clock=e.clock,this.unsubscribe=e.fileEvents.subscribe(e=>this.noticed(e)),this.sessions=new Sj({name:`plugin storage`,scope:`session`,keyOf:e=>JSON.stringify([e.storage.folder,e.storage.generation,e.sessionId]),fields:e=>`file=${R(z5(e))} generation=${e.storage.generation}`,read:e=>this.read(e),every:()=>null,watch:xj,maxEntries:256,logger:e.logger,ledger:e.ledger??new Dj(e.logger),clock:e.clock})}keyFor(e){let t=this.folders.get(e)??this.recorded(e),n=`gone`;t.unusable=null;try{s.mkdirSync(e,{recursive:!0}),n=this.identityOf(e)}catch(e){t.unusable=`could not be created or read: ${e.message}`}return(t.lost||t.identity!==null&&(n===`gone`||!Ic(n,t.identity)))&&(t.generation++,t.lost=!1,t.identity=n===`gone`?null:n,this.logger(`info`,`plugin storage generation folder=${R(e)} generation=${t.generation}`)),{folder:e,generation:t.generation}}watch(e){let t=this.watched.get(B5(e))??this.opened(e);t.holders++;let n=!1;return()=>{n||(n=!0,t.holders--,t.holders===0&&this.closed(t))}}declare(e,t,n){return this.sessions.declare(e,{storage:t,sessionId:n})}supersede(e,t){return this.sessions.supersede({storage:e,sessionId:t})}stats(){return{...this.sessions.stats(),folders:this.watched.size,faults:{...this.faultCounts},lost:this.lost}}close(){this.unsubscribe(),this.sessions.close();for(let e of[...this.watched.values()])this.closed(e)}recorded(e){let t={generation:0,identity:null,lost:!1,unusable:null};return this.folders.set(e,t),t}opened(e){let t=this.folders.get(e.folder);if(t===void 0)throw Error(`plugin storage: no key was asked for ${e.folder}`);let n=e.generation===t.generation?t.unusable:null,r=n===null?this.identityOf(e.folder):`gone`;e.generation===t.generation&&(t.identity=r===`gone`?null:r);let i={key:e,folder:t,identity:r,holders:0,handle:this.watchers.acquire(`plugin-storage:${B5(e)}`,{dirs:[{path:e.folder}]},e=>this.invalidated(i,e)),stopSweep:this.clock.every(864e5,()=>void this.sweep(e),{unref:!0}),health:{kind:`watching`}};this.watched.set(B5(e),i),n!==null&&this.faulted(i,`unusable`,n);for(let e of i.handle.deaf)this.faulted(i,`refused`,e.reason);return this.sweep(e),i}closed(e){let t=B5(e.key);this.watched.delete(t),e.health={kind:`closed`},e.stopSweep(),e.handle.release()}invalidated(e,t){let{key:n}=e,r=e=>V5(e.storage,n);switch(t.kind){case`unknown`:this.judged(e,()=>this.sessions.changed(r));return;case`changed`:{let{paths:i}=t;i.has(E.join(n.folder,E.basename(n.folder)))?this.judged(e,()=>this.sessions.changed(r)):this.sessions.changed(e=>r(e)&&i.has(z5(e)));return}case`failed`:this.judged(e,()=>this.faulted(e,`error`,t.reason));return}}judged(e,t){let{health:n}=e;if(n.kind!==`watching`)return;let{key:r,folder:i}=e,a;try{a=this.identityOf(r.folder)}catch(t){this.faulted(e,`error`,`stat failed: ${t.message}`);return}let o=e.identity;if(a!==`gone`&&o!==`gone`&&Ic(a,o)){t();return}e.health={kind:`lost`},r.generation===i.generation&&(i.lost=!0,this.lost++,this.logger(`info`,`plugin storage lost folder=${R(r.folder)} generation=${r.generation} now=${a===`gone`?`gone`:`replaced`}`),this.sessions.changed(e=>V5(e.storage,r)))}faulted(e,t,n){let{key:r,folder:i}=e;e.health.kind===`watching`&&(e.health={kind:`faulted`,reason:n},this.faultCounts[t]++,r.generation===i.generation&&(i.lost=!0),this.logger(`warn`,`plugin storage fault folder=${R(r.folder)} generation=${r.generation} cause=${t} reason=${JSON.stringify(n)}`),this.sessions.changed(e=>V5(e.storage,r)))}noticed(e){switch(e.kind){case`period`:for(let e of[...this.watched.values()])this.judged(e,()=>{});return;case`moved`:case`caught-up`:this.sessions.changed(()=>!0);return}}standing(e){let t=this.watched.get(B5(e));if(t===void 0)return null;let{health:n}=t;switch(n.kind){case`faulted`:return`cannot refresh: ${e.folder} ${n.reason}; reload the config or restart the daemon`;case`watching`:case`lost`:{let t=qc(this.fileEvents.delivery());return t===null?null:`cannot refresh: ${e.folder}: ${t}`}case`closed`:return null}}async read(e){let t=this.standing(e.storage);if(t!==null)return L(t,`read`);let n=z5(e),r;try{r=await s.promises.readFile(n,`utf8`)}catch(e){let t=e;return t.code===`ENOENT`?I:L(`${n}: ${t.message}`,`read`)}if(r.trim()===``)return I;let i=Fj(r);return i.kind===`failed`?L(`${n}: ${i.reason}`,i.failedAt):i}async sweep(e){let t=this.clock.monotonic(),n=this.clock.now()-2592e6,r=0,i=0,a=()=>`plugin storage sweep folder=${R(e.folder)} scanned=${r} removed=${i} took=${A(this.clock,t)}ms`;try{let t=await s.promises.readdir(e.folder,{withFileTypes:!0});for(let a of t){if(!a.isFile()||!a.name.endsWith(`.json`))continue;r++;let t=E.join(e.folder,a.name);try{let{mtimeMs:r}=await s.promises.stat(t),o=this.sessions.isHeld(t=>t.storage.folder===e.folder&&R5(t.sessionId)===a.name);if(r>=n||o)continue;await s.promises.unlink(t),i++}catch(e){if(e.code!==`ENOENT`)throw e}}this.logger(`info`,a())}catch(e){this.logger(`warn`,`${a()} outcome=failed reason=${JSON.stringify(e.message)}`)}}};function U5(e){let{launcher:t,clock:n,logger:r,ledger:i}=e;return{home:e.host.home,hostService:new k5({clock:n,logger:r,ledger:i}),gitProvider:new Z8({inner:new zY(t),watchers:e.watchers,clock:n,logger:r,ledger:i}),usageStore:new m5({host:e.host,clock:n,logger:r,ledger:i}),contextProvider:new mX({clock:n,logger:r,ledger:i}),metricsProvider:new wX({clock:n,logger:r,ledger:i}),activityProvider:new b5({clock:n,logger:r,ledger:i}),tmuxService:new C5({launcher:t,clock:n,logger:r,ledger:i}),autoCompact:new A5(n,r,i),cacheExpiry:new P5(n,r,i),managedStorage:new H5({watchers:e.watchers,fileEvents:e.fileEvents,clock:n,logger:r,ledger:i}),faults:new AX,log:e.logger,clock:n}}function*W5(e){yield*Object.entries(e.variables??{});for(let[t,n]of Object.entries(e.segments??{}))for(let[e,r]of Object.entries(n.vars??{}))yield[`${t}.${e}`,r]}function*G5(e){for(let t of Object.values(e.segments)){for(let e of[t.template,t.bg,t.fg,t.when])e!==void 0&&(yield e);yield*Object.values(t.partials??{})}for(let t of lS(e.presets)){for(let n of Ny(fS(e,t).node))n.when!==void 0&&(yield n.when);let n=hS(e,t);for(let e of Xv){let t=n[e];Zv(t)&&(yield t)}}for(let[,t]of W5(e))for(let[,e]of Hy(t))yield e;for(let t of Object.values(e.actions))for(let[,e]of ES(t))yield e}function une(e,t,n){let r=UW(t),i=new Set,a=new Set,o=new Set;for(let e of G5(t)){for(let{reaches:t}of r.ofTemplate(e))for(let e of t)i.add(e);for(let{name:n}of eC(e,t.helpers))a.add(n);for(let n of oC(e,t.helpers))o.add(n)}for(let[,e]of W5(t))for(let{reaches:t}of r.ofVariable(e))for(let e of t)i.add(e);let s=new Set(a);for(let e of a){let n=t.actions[e];if(n!==void 0&&`do`in n)for(let e of n.do)s.add(e)}let c=new Set,l=new Set(n);for(let e of s){let n=t.actions[e];if(n!==void 0&&(`set`in n&&c.add(n.set),`insertSegment`in n&&l.add(n.insertSegment),`insertSegmentFrom`in n&&Array.isArray(n.insertSegmentFrom)))for(let e of n.insertSegmentFrom)l.add(e)}for(let e of lS(t.presets))for(let n of Ny(fS(t,e).node))n.kind===`segment`&&l.add(n.name);let u=(e,t)=>i.has(e)||t.kind===`state`&&c.has(t.key),d=e=>[...e].filter(e=>!Ii(e)),f=(e,t,n)=>d(t).filter(e=>!n(e)).map(t=>({kind:e,name:t})),p=new Map(W5(e));return[...f(`variable`,p.keys(),e=>u(e,p.get(e))),...f(`action`,Object.keys(e.actions??{}),e=>s.has(e)),...f(`helper`,Object.keys(e.helpers??{}),e=>o.has(e)),...f(`segment`,Object.keys(e.segments??{}),e=>l.has(e))]}function dne(e){return Math.floor(Math.max(e/4,e*Br-67108864))}const fne={keyFor:e=>({folder:e,generation:0}),watch:()=>()=>{}};function K5(e,{plugins:t,config:n,compiled:r},i){let{checkout:a,loaded:o,dropped:s,unreached:c}=t,l=a===null?`-`:`${a.git?`git`:`dir`}:${a.root}`,u=e=>{let t=e.name===void 0?void 0:n.variables[WV(AS(e))];return t?.kind===`file`?t.path:`none`},d=o.flatMap(e=>e.name===void 0?[]:[AS(e)]).flatMap(e=>Object.entries(n.variables).filter(([t])=>jS(e)(t)&&t!==WV(e))),f=d.filter(([,e])=>e.kind===`source`).length,p=d.length-f;return`config load ${pP(e,`<default>`)}: projections=${[...qW(n).keys()].join(`,`)||`-`} instantSegments=${y3(r).join(`,`)||`-`} instantTemplates=${r.instant.size} plugins loaded=${o.length} sources=${f} pluginVariables=${p} dropped=${s.length} unplaced=${c.length} checkout=${l} ms=${i}`+o.map(e=>` +${e.path} data=${u(e)}`).join(``)+s.map(e=>` -${e.path} (${e.reason})`).join(``)+c.map(e=>` ~${e.path} (${e.reason})`).join(``)}const pne=e=>{switch(e.kind){case`changed`:return[...e.paths].join(`,`);case`unknown`:return`unknown`;case`failed`:return`failed:${e.reason}`}},q5=e=>{switch(e.kind){case`open`:case`write`:case`doctor`:return e.kind;case`config-watch`:case`answers-watch`:return`${e.kind}:${pne(e.heard)}`;case`events-resumed`:return`${e.kind}:${new Date(e.since).toISOString()}`}};function mne(e,t,n){let r=e=>R(e.join(`,`)||`-`);return`config loaded projectDir=${R(e.projectDir)} cwd=${R(e.cwd)} cause=${R(q5(t))} state=${n} files=${R(pP(e.configLayers,`<bundled default>`))} awaiting=${r(e.repos.awaiting)} declined=${r(e.repos.declined)} unproven=${e.repos.unproven.length===0?`-`:JSON.stringify(e.repos.unproven)} error=${e.lastError===null?`none`:JSON.stringify(e.lastError)} warning=${e.lastWarning===null?`none`:JSON.stringify(e.lastWarning)}`}function hne(e,t){return`config disposed reason=${e.reason} released=${t} held=${e.held}`}function J5(e,t,n){return e+`\0`+t+`\0`+(n??``)}function gne(e,t){return new Set(lS(e.presets).filter(n=>fS(e,n).path===`root`?t.root!==void 0:t.presets?.[n]?.root!==void 0))}function _ne(e,t){let{loaded:n,dropped:r,unreached:i}=e.state.plugins,a=[...new Set([...e.state.plugins.roots,E.join(e.projectDir,wH)])];return nj({named:[...XH(t,e.projectDir,e.cwd,e.configFile),...a,...n.map(e=>e.path),...[...r,...i].map(e=>e.path),...new Set([...e.state.sources.values()].map(e=>e.folder))],whole:a})}function vne(e){return e.filter(Boolean).join(`
485
- `)||null}const Y5=e=>e instanceof Error?e.message:String(e);function X5(e){return{loaded:e.loaded,dropped:e.dropped,reached:[...e.reached].sort(),rendering:[...e.rendering].sort(([e],[t])=>e.localeCompare(t))}}function yne(e){let{loaded:t,chain:n}=e;return Aj({cwd:e.cwd,chain:{layers:n.layers,home:n.home,repo:n.repo,locs:n.locs},loaded:{layers:t.layers.map(e=>({path:e.path,raw:e.raw,config:e.config,plugins:X5(e.plugins),source:null,warnings:null})),base:t.base,installed:{...X5(t.installed),checkout:t.installed.checkout,roots:t.installed.roots,unreached:t.installed.unreached},config:t.config,dropped:t.dropped.map(e=>e.message),placed:null},sources:[...e.sources].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,t.folder,t.generation])})}function bne(e,t){let n=new Map,r=new Map;for(let[i,a]of Object.entries(e.variables)){if(a.kind!==`source`)continue;let e=n.get(a.storage)??t.keyFor(a.storage);n.set(a.storage,e),r.set(i,e)}return r}function Z5(e,t,n){let r=[];try{let i=HG(t.locs,t.layers,mK,{warned:e=>r.push(...e)},{repo:t.repo,cwd:e}),a={cwd:e,chain:t,loaded:i,sources:bne(i.config,n)};return{kind:`resolved`,...a,key:yne(a),warnings:r}}catch(e){return e instanceof ab&&r.push(...e.warnings),{kind:`failed`,cause:e,warnings:r}}}function Q5(e,t){let{cwd:n,chain:r,loaded:i}=e,{layers:a,config:o,installed:s,dropped:c}=i,l=a.at(-1)?.config??mK,u=a.find(e=>e.path===r.home)?.raw??{},d=a.flatMap(e=>(e.raw.insert??[]).map(e=>e.seg)),f=[],p=new RC(t.clock),m=new rM(t.runs,p,o.globals.default_empty_value??``,t.sessionState,null,t.env),h;try{h=p3(o,m,n,t.compile??f3(t.signer),Sne),f.push(...h.loadWarnings);let r=m.view();f.push(...g3(o,r,n,n7)),r.dispose(),t.gates.state.gateFor(o),t.gates.config.gateFor(o);for(let n of new Set(e.sources.values()))m.own(t.storage.watch(n))}catch(e){return m.dispose(),e instanceof ab&&f.push(...e.warnings),{kind:`failed`,cause:e,warnings:f}}return{kind:`built`,state:{config:o,dropped:c,compileKey:h.compileKey,loadKey:e.key,buildWarnings:f,store:p,registry:m,compiled:h.compiled,authoredRoots:gne(l,u),fileHeldSettings:GK(u),configPath:r.layers.some(e=>e.path===r.home)?r.home:null,unused:[...new Map(a.flatMap(e=>une(e.raw,i.placed,d)).map(e=>[`${e.kind}:${e.name}`,e])).values()],plugins:{checkout:s.checkout,roots:s.roots,loaded:[...s.rendering.values()],dropped:[...s.dropped,...a.flatMap(e=>e.plugins.dropped)],unreached:s.unreached,reached:s.reached,rendering:s.rendering},sources:e.sources}}}function $5(e,t,n,r,i){let a={layers:t.layers.map(e=>e.path),home:t.home,repos:e.repos,ms:A(i,e.started)},o=t=>vne([...e.advisories,...n,...t]);switch(r.kind){case`built`:case`kept`:return{...a,kind:r.kind,warning:o(r.state.buildWarnings),state:r.state,error:null};case`failed`:return{...a,kind:`failed`,warning:o(r.warnings),state:null,error:Y5(r.cause),cause:r.cause}}}function xne(e,t,n,r,i=null){let a=Z5(t,n,r.storage);if(a.kind===`failed`)return $5(e,n,[],a,r.clock);let o=i?.loadKey===a.key?{kind:`kept`,state:i}:Q5(a,r);return $5(e,n,a.warnings,o,r.clock)}function e7(e,t,n,r,i=null){let a=r.clock.monotonic(),o=eU(r.locations,BU(r.stateDir).read(),e,t,n),{repos:s}=o,c={layers:o.kind===`chain`?o.layers:[],home:o.home,repo:s.plugins,locs:r.locations};return xne({repos:s,advisories:[sU(r.locations,e,t),aU(o),qH(s)],started:a},t,c,r,i)}function t7(e,t,n){let r=Z5(e,{layers:[],home:``,repo:t,locs:n.locations},n.storage),i=r.kind===`failed`?r:Q5(r,n);if(i.kind===`failed`)throw Error(`bundled default failed to load: ${Y5(i.cause)}`,{cause:i.cause});return i.state}const Sne=new Set([`directory`]),n7=new Set([`view`]);function Cne(e,t,n,{source:r,changed:i,log:a}){let{sessionId:o}=n,s=e.registry.view();g3(e.config,s,t,n7);let c=Y.observable.box(n,{deep:!1}),l;try{l=r({sessionId:o,state:e,store:s.variableStore,requested:()=>c.get()})}catch(e){throw s.dispose(),e}B4(e.compiled,s.variableStore,s,l);let u=(0,Y.reaction)(()=>[l.payload(),l.selections(),s.published(),e.registry.published()],()=>i(o),{equals:Y.compareShallow,fireImmediately:!0,onError:e=>a(`error`,`session view change threw sid=${JSON.stringify(o)}: ${String(e)}`)});return{sessionId:o,state:e,store:s.variableStore,registry:s,source:l,requested:e=>{e!==c.get()&&(0,Y.runInAction)(()=>c.set(e))},facts:()=>c.get(),lastRenderCellsBySegment:new Map,retire:u,dispose:()=>(u(),s.dispose())}}const wne=({sources:e})=>[...e].map(([e,t])=>({kind:`plugin`,source:e,storage:t}));var Tne=class{entries=new Map;answersWatch;closed=!1;due=new Map;walk=null;holds=new Map;views=new Map;copies=new Map;viewHolds=new Map;pins=new Map;openFailures=new Map;compiles=new Map;deps;log;budgetBytes;maxEntries;observers;constructor(e,t){this.deps={...e,compile:(e,t)=>this.compileOf(e,t)},this.log=e.log??Pe,this.budgetBytes=t.budgetBytes,this.maxEntries=t.maxEntries??256,this.observers=t.observers??{},s.mkdirSync(RU(e.stateDir),{recursive:!0});let{dir:n,name:r}=$A(zU(e.stateDir));this.answersWatch=e.watchers.acquire(`repo-configs:${n}/${r}`,{dirs:[{path:n,filenames:[r]}]},e=>this.reloadEvery({kind:`answers-watch`,heard:e}))}compileOf(e,t){return this.compiles.get(e)??v3(t,this.deps.signer)}accountedBytes(){let e=new Set([...this.entries.values()].map(e=>e.state.compileKey));return this.entries.size*3145728+e.size*10485760+this.views.size*2621440}getOrCreate(e,t,n){let r=J5(e,t,n),i=this.entries.get(r);if(i)return this.entries.delete(r),this.entries.set(r,i),i;let a=this.load(e,t,n,null);a.state!==null&&this.log(`info`,K5(a.layers,a.state,a.ms));let o={projectDir:e,cwd:t,configFile:n,configLayers:[],configHome:``,repos:a.repos,lastError:a.error,lastWarning:a.warning,state:a.state??t7(t,a.repos.plugins,this.deps),watch:null};return this.serve(o.state),this.entries.set(r,o),this.fit(o),this.log(`info`,`render-cache entry projectDir=${e} cwd=${t} compile=${o.state.compileKey.slice(0,12)} entries=${this.entries.size} compiles=${this.compiles.size} accounted=${Fr(this.accountedBytes())}/${Fr(this.budgetBytes())}MB`),this.refreshWatcher(o,a),this.observers.onReload?.(o,[],{kind:`open`},a.kind),o}hold(e,t,n){let r=this.getOrCreate(e,t,n);return this.holdState(r,r.state)}holdState(e,t){let n=this.holdOf(t);n.holders++;let r=!1;return{entry:e,state:t,[Symbol.dispose]:()=>{if(r)throw Error(`render-cache hold released twice`);r=!0,n.holders--,this.reclaim(t,n)}}}holdSession(e,t,n,r){let i=this.hold(e,t,n),a,o;try{a=this.viewOf(i.entry,i.state,r,`request`),o=this.leaseOf(a)}catch(e){throw i[Symbol.dispose](),e}return this.holdViewOf(i,a,o)}holdView(e){let t=this.views.get(e);if(t===void 0)return null;let n=this.leaseOf(t);return this.holdViewOf(this.holdState(n.entry,t.state),t,n)}holdViewOf(e,t,n){n.holders++;let r=!1;return{entry:e.entry,state:e.state,view:t,[Symbol.dispose]:()=>{if(r)throw Error(`render-cache view hold released twice`);r=!0,n.holders--,this.reclaimView(t,n),e[Symbol.dispose]()}}}openFailure(e){return this.openFailures.get(e)??null}follow(e,t,n,r){try{var i=No();let a=this.views.get(e),o=a?.facts()??this.openFailures.get(e)?.facts;if(o===void 0)return;let s=this.entries.get(J5(t,n,r));if(a!==void 0&&s?.state===a.state)return;let c=i.u(this.hold(t,n,r));this.viewOf(c.entry,c.state,o,`click`)}catch(e){i.e=e}finally{i.d()}}pin(e){this.pins.set(e,(this.pins.get(e)??0)+1);let t=!1;return()=>{if(t)throw Error(`render-cache pin released twice`);t=!0;let n=(this.pins.get(e)??0)-1;n>0?this.pins.set(e,n):this.pins.delete(e)}}viewOf(e,t,n,r){let{sessionId:i}=n,a=this.views.get(i);if(a?.state===t)return this.views.delete(i),this.views.set(i,a),a.requested(n),a;this.views.delete(i);let o;try{o=this.opened(e,t,n,r)}finally{a!==void 0&&this.retireView(a,`moved`)}return this.fit(e),o}opened(e,t,n,r){let{sessionId:i}=n,a;try{a=Cne(t,e.cwd,n,{source:this.deps.source,changed:e=>this.observers.onViewChanged?.(e),log:this.log})}catch(e){throw this.openFailures.set(i,{error:e,facts:n}),e}return this.openFailures.delete(i),this.views.set(i,a),this.viewHolds.set(a,{entry:e,holders:0,retired:null}),this.log(`info`,`session view opened sid=${JSON.stringify(i)} by=${r} cwd=${e.cwd} views=${this.views.size}`),a}leaseOf(e){let t=this.viewHolds.get(e);if(t===void 0)throw Error(`render-cache view never served`);return t}retireView(e,t){this.views.get(e.sessionId)===e&&this.views.delete(e.sessionId),this.views.has(e.sessionId)||this.copies.delete(e.sessionId),e.retire();let n=this.leaseOf(e);n.retired={reason:t,held:n.holders},this.reclaimView(e,n)}reclaimView(e,t){t.retired===null||t.holders>0||(this.viewHolds.delete(e),this.log(`info`,`session view closed sid=${JSON.stringify(e.sessionId)} reason=${t.retired.reason} released=${e.dispose()} held=${t.retired.held} views=${this.views.size}`))}retireSession(e){let t=this.views.get(e);t!==void 0&&this.retireView(t,`idle`),this.openFailures.delete(e)}subscriptions(){return{sources:Object.fromEntries([...this.views].map(([e,t])=>[e,wne(t.state)]))}}close(){if(this.closed)return;this.closed=!0,this.walk?.(),this.walk=null,this.answersWatch.release();let e=this.entries.size;for(let[e,t]of this.entries)this.drop(e,t,`close`);this.log(`info`,`render-cache closed entries=${e} deferred=${this.stats.retired}`)}load(e,t,n,r){if(this.closed)throw Error(`render cache used after close`);return e7(e,t,n,this.deps,r)}drop(e,t,n){t.watch?.held.handle.release(),this.entries.delete(e),this.due.delete(t),this.retire(t.state,n,null)}get stats(){let e=0,t=0;for(let n of this.holds.values())n.holders>0&&e++,n.retired!==null&&t++;let n=0;for(let e of this.viewHolds.values())e.retired!==null&&n++;return{size:this.entries.size,held:e,retired:t,compiles:this.compiles.size,views:this.views.size,pinned:this.pins.size,due:this.due.size,retiredViews:n,accountedBytes:this.accountedBytes(),budgetBytes:this.budgetBytes()}}fit(e){let t=()=>this.entries.size<=this.maxEntries&&this.accountedBytes()<=this.budgetBytes(),n=new Set([...this.pins.keys()].flatMap(e=>{let t=this.views.get(e);return t===void 0?[]:[t.state]}));for(let[r,i]of this.entries){if(t())return;i===e||n.has(i.state)||this.drop(r,i,`evict`)}t()||this.log(`warn`,`render-cache over budget entries=${this.entries.size} views=${this.views.size} pinned=${n.size} accounted=${Fr(this.accountedBytes())}/${Fr(this.budgetBytes())}MB`)}serve(e){let t=this.compiles.get(e.compileKey);if(t!==void 0&&t!==e.compiled)throw Error(`render cache: a second compile for key ${e.compileKey.slice(0,12)}`);this.holds.set(e,{holders:0,retired:null}),this.compiles.set(e.compileKey,e.compiled),t===void 0&&this.log(`info`,`render-cache compile built key=${e.compileKey.slice(0,12)} compiles=${this.compiles.size}`)}holdOf(e){let t=this.holds.get(e);if(t===void 0)throw Error(`render-cache state never served`);return t}retire(e,t,n){for(let r of[...this.views.values()])if(r.state===e){if(n!==null)try{this.opened(n.entry,n.state,r.facts(),`reload`)}catch(e){this.log(`error`,`session view reopen failed sid=${JSON.stringify(r.sessionId)}: ${String(e)}`)}this.retireView(r,t)}let r=this.holdOf(e);r.retired={reason:t,held:r.holders},this.reclaim(e,r)}reclaim(e,t){t.retired===null||t.holders>0||(this.holds.delete(e),this.log(`info`,hne(t.retired,e.registry.dispose())),[...this.holds.keys()].some(t=>t.compileKey===e.compileKey)||this.compiles.delete(e.compileKey))}sessionsOn(e){return[...this.views.values()].filter(t=>t.state===e.state).map(e=>e.sessionId)}reload(e,t,n,r){this.reloadInto(this.getOrCreate(e,t,n),r)}reloadInto(e,t){this.due.delete(e);let n=this.sessionsOn(e),r=e.state,i=this.load(e.projectDir,e.cwd,e.configFile,r);e.lastWarning=i.warning,e.lastError=i.error,i.state!==null&&this.log(`info`,K5(i.layers,i.state,i.ms)),i.kind===`built`&&(e.state=i.state,this.serve(i.state),this.retire(r,`reload`,{entry:e,state:i.state})),this.fit(e),this.refreshWatcher(e,i),this.observers.onReload?.(e,n,t,i.kind)}reloadEvery(e){for(let t of this.entries.values())this.due.set(t,e);this.armWalk()}armWalk(){this.walk!==null||this.due.size===0||(this.walk=this.deps.clock.defer(()=>this.walkOne()))}walkOne(){this.walk=null;let e=null;for(let t of this.entries.values()){let n=this.due.get(t);n!==void 0&&(e=[t,n])}if(e===null)return;let[t,n]=e;try{this.reloadInto(t,n)}catch(e){this.log(`error`,`every-entry reload threw projectDir=${R(t.projectDir)} cwd=${R(t.cwd)} configFile=${R(t.configFile??`-`)} cause=${R(q5(n))}: ${x(e)}`)}finally{this.armWalk()}}refreshWatcher(e,t){e.configLayers=t.layers,e.configHome=t.home,e.repos=t.repos;let n=_ne(e,this.deps.locations),{targets:r,unresolved:i}=n,a=`config:${e.projectDir}:${e.cwd}:${e.configFile??``}:${n.key}`,{watch:o,move:s}=this.deps.watchers.follow(e.watch?.held??null,{...n,key:a},t=>this.reloadInto(e,{kind:`config-watch`,heard:t}));if(e.watch={derived:{...n,key:a},held:o},s!==`kept`){this.log(`info`,`config watch bound projectDir=${e.projectDir} cwd=${e.cwd} dirs=${r.dirs.map(e=>e.path).join(`,`)} deaf=${o.handle.deaf.length}`);for(let{path:t,reason:n}of i)this.log(`warn`,`config watch unresolved projectDir=${e.projectDir} path=${t} reason=${n}`)}}get size(){return this.entries.size}latestView(){return[...this.views.values()].at(-1)??null}delivered(e,t,n){if(!this.views.has(e))return;let r=this.copies.get(e)??new Map;this.copies.set(e,r.set(t,n))}drawnCopy(e,t,n){return this.copies.get(e)?.get(t)?.get(n)}stopDrawing(e,t){this.copies.get(e)?.delete(t)}};const Ene=e=>!_J(e)&&!oI(e)&&e!==`update.dismissed`&&e!==Bi;var Dne=class{past=Y.observable.map(void 0,{deep:!1});depth(e,t,n){return this.restorable(e,t,n).length}restorable(e,t,n){let r=new Map,i=n=>r.has(n)?r.get(n):t.get(e,n),a=[];for(let t of[...this.past.get(e)??[]].reverse())if(t.every(e=>i(e.key)===e.after&&(e.before===null||n.validate(e.key,e.before).ok))){a.unshift(t);for(let e of t)r.set(e.key,e.before)}return a}begin(e){let t=new Map;return{sessionState:fJ(e,Ene,(e,n,r,i)=>{let a=t.get(e)??new Map,o=a.get(n);a.set(n,{key:n,before:o?o.before:r,after:i}),t.set(e,a)}),commit:()=>{for(let[e,n]of t){let t=[...n.values()].filter(e=>e.before!==e.after);t.length>0&&this.push(e,t)}t.clear()}}}back(e,t,n){let r=this.past.get(e)??[],i=this.restorable(e,t,n),a=i.at(-1),o=r.length-i.length;if(a===void 0)throw this.put(e,i),new Z(`back: nothing to go back to${o>0?` (${o} step(s) over a view since gone, discarded)`:``}`);return(0,Y.runInAction)(()=>{let n=a.flatMap(({key:e,before:t})=>t===null?[]:[{key:e,value:t}]);n.length>0&&t.setBatch(e,n);for(let{key:n,before:r}of a)r===null&&t.clear(e,n)}),this.put(e,i.slice(0,-1)),{step:a,discarded:o}}push(e,t){let n=this.past.get(e)??[];this.put(e,[...n,t].slice(-20))}put(e,t){(0,Y.runInAction)(()=>{for(this.past.delete(e),t.length>0&&this.past.set(e,t);this.past.size>32;)this.past.delete(this.past.keys().next().value)})}};const r7=(e,t)=>e.kind===`ok`?F(t(e.value)):e;function One(e){switch(e.kind){case`pending`:case`failed`:return e;case`absent`:return I;case`ok`:return e.value.pullRequest}}const i7=(e,t)=>{let n=Object.entries(e);return n.length===Object.keys(t).length&&n.every(([e,n])=>Object.is(n,Reflect.get(t,e)))};function kne({pullRequest:e,...t}){return t}function a7(e,t,n,r,i){let{lanes:a}=n,o=(e,t)=>x8(e,t,i),s=e?.builtins,c={session:o(s?.session,a.usage),today:o(s?.today,n.today),speed:o(s?.speed,a.speed),context:o(s?.context,a.context),metrics:o(s?.metrics,a.metrics),activity:o(s?.activity,a.activity),cache:o(s?.cache,a.cache),autocompact:o(s?.autocompact,a.autoCompact),git:o(s?.git,r7(a.git,kne)),pr:o(s?.pr,One(a.git)),tmux:o(s?.tmux,r7(a.tmuxSession,e=>({session:e}))),hostName:o(s?.hostName,a.hostName),hostUser:o(s?.hostUser,a.hostUser)},l=Object.fromEntries([...a.sources].map(([t,n])=>[t,o(e?.sources[t],n)])),u={builtins:c,sources:l,update:r,diagnostics:n.faults};return e!==void 0&&i7(c,e.builtins)&&i7(l,e.sources)&&(0,Y.compareStructural)({update:r,diagnostics:n.faults},{update:e.update,diagnostics:e.diagnostics})?e:{v:1,session:t,seq:e===void 0?1:e.seq+1,...u}}function o7(e,t){return e.diagnostics.find(e=>e.kind===`stamp`)?.reason===t?e:{...e,seq:e.seq+1,diagnostics:[...e.diagnostics.filter(e=>e.kind!==`stamp`),{kind:`stamp`,reason:t}]}}function s7(e){return e.diagnostics.find(e=>e.kind===`stamp`)?.reason??null}const Ane=e=>({hookData:e.hookData,cwd:e.cwd,hints:e.hints,sessionId:e.sessionId}),jne=e=>new Map(e.map(e=>[e.source,e.storage])),Mne=(e,t)=>e.size===t.size&&[...e].every(([e,n])=>{let r=t.get(e);return r!==void 0&&V5(n,r)});function c7({stop:e,holds:t}){e(),t.close()}var Nne=class{records=new Map;stopSweep=null;constructor(e){this.deps=e}requested(e){let t=Ane(e),n=(0,Y.runInAction)(()=>{let n=this.records.get(e.sessionId);if(n===void 0){let n=this.open(e.sessionId,t);return this.records.set(e.sessionId,n),n.stamped.document}n.requested=!0;let{phase:r}=n;r.kind===`live`&&r.declared.set(this.declared({...n,locator:t},r.holds));let i=r.kind===`live`?r:this.live(n,t);return n.phase=i,this.stamp(n,i.inputs.get()),n.stamped.document});return this.armSweep(),n}subscribed({sources:e}){for(let t of Object.keys(e))this.records.has(t)||this.deps.log(`error`,`subscriptions name session ${JSON.stringify(t)}, which the collector has no record of`);(0,Y.runInAction)(()=>{for(let t of this.records.values()){let n=jne(e[t.session]??[]);if(Mne(n,t.subscriptions))continue;t.subscriptions=n;let{phase:r}=t;r.kind===`live`&&r.declared.set(this.declared({...t,locator:r.declared.get().locator},r.holds))}})}sweep(){for(let e of this.records.values())e.phase.kind===`live`&&(e.requested?e.requested=!1:this.deps.watched(e.session)||this.retire(e,e.phase))}stats(){let e=[...this.records.values()];return{sessions:e.length,retiring:e.filter(e=>e.phase.kind===`retiring`).length}}close(){this.disarmSweep();for(let{phase:e}of this.records.values())e.kind===`live`&&c7(e);this.records.clear()}open(e,t){let n=new Map,r=this.reader({session:e,locator:t,subscriptions:n}),i=r.inputs.get(),a;try{if(i.kind===`failed`)throw Error(i.reason);a=a7(void 0,e,i.readings,i.update,Ue(this.deps.clock))}catch(e){throw r.holds.close(),e}let o={document:a,from:i};return{session:e,stamped:o,subscriptions:n,requested:!0,phase:this.watch(e,o,r)}}live(e,t){return this.watch(e.session,e.stamped,this.reader({...e,locator:t}))}reader(e){let t=new QA,n=Y.observable.box(this.declared(e,t),{deep:!1});return{holds:t,declared:n,inputs:(0,Y.computed)(()=>this.read(n.get()))}}watch(e,t,n){let r=(0,Y.reaction)(()=>n.inputs.get(),n=>(0,Y.runInAction)(()=>{n!==t.from&&this.stamp({session:e,stamped:t},n)&&this.deps.deliver({kind:`world-state`,worldState:t.document})}),{onError:t=>this.deps.log(`error`,`world state stamp threw sid=${JSON.stringify(e)}: ${x(t)}`)});return{kind:`live`,...n,stop:r}}declared({session:e,locator:t,subscriptions:n},r){let i=JSON.stringify(e);try{let{result:{lanes:e,faults:a},acquired:o,released:s}=r.declare(()=>KX(this.deps.owners,r,t,n));for(let e of a)this.deps.log(`error`,`session declaration threw sid=${i} ${e}`);return o+s>0&&this.deps.log(`info`,`session declared sid=${i} acquired=${o} released=${s} held=${r.size}`),{locator:t,lanes:e}}catch(e){return this.deps.log(`error`,`session declaration threw sid=${i}: ${x(e)}`),{locator:t,lanes:WX(L(`session declaration threw: ${String(e)}`,`read`),[...n.keys()])}}}inputsOf(e){return{...e,deps:this.deps.owners}}read({locator:e,lanes:t}){try{return{kind:`read`,readings:qX(this.inputsOf(e),t),update:this.deps.update()}}catch(e){return{kind:`failed`,reason:`reading the owners: ${String(e)}`}}}stamp({session:e,stamped:t},n){let r=t.document,i=n.kind===`failed`?o7(r,n.reason):this.assembled(r,n,Ue(this.deps.clock)),a=i===r?null:s7(i);return a!==null&&this.deps.log(`error`,`world state sid=${JSON.stringify(e)}: ${a}`),t.document=i,t.from=n,i!==r}assembled(e,t,n){try{return a7(e,e.session,t.readings,t.update,n)}catch(t){return o7(e,`stamping the world state: ${String(t)}`)}}retire(e,t){c7(t),e.phase={kind:`retiring`},this.deps.log(`info`,`session retired sid=${JSON.stringify(e.session)}`),this.deps.deliver({kind:`retire`,session:e.session}).then(({kind:t})=>{t===`answered`&&e.phase.kind===`retiring`&&this.records.get(e.session)===e&&this.records.delete(e.session),this.records.size===0&&this.disarmSweep()})}armSweep(){this.stopSweep===null&&(this.stopSweep=this.deps.clock.every(15e4,()=>this.sweep(),{unref:!0}))}disarmSweep(){this.stopSweep?.(),this.stopSweep=null}},Pne=class{documents=Y.observable.map(void 0,{deep:!1});take(e){let t=this.documents.get(e.session);if(t!==void 0&&e.seq<=t.seq){if(e.seq===t.seq&&(0,Y.compareStructural)(e,t))return;throw Error(`world state seq ${e.seq} for session ${JSON.stringify(e.session)} does not follow the held seq ${t.seq}`)}(0,Y.runInAction)(()=>this.documents.set(e.session,e))}of(e){let t=this.documents.get(e);if(t===void 0)throw Error(`no world state for session ${JSON.stringify(e)}: the host hands one in with the config ahead of every request`);return t}drop(e){(0,Y.runInAction)(()=>this.documents.delete(e))}};function Fne(e){return({sessionId:t,state:n,store:r,requested:i})=>{let a=n=>e.sessionState.get(t,n),o=r.derive(`session.effective`,`computed`,()=>CK(n.config,a,e=>n.authoredRoots.has(e))),s=r.derive(`session.compose`,`computed`,()=>{let{hookData:t,hints:n}=i();return{hookData:t,hints:n,home:e.home}}),c=r.derive(`session.draw`,`computed`,()=>({sources:[...n.sources.keys()],effective:o.read(),configFacts:{...KK(n.config,n.fileHeldSettings,a),configPath:n.configPath},history:e.history(t),back:e.navigation(t,n.config)})),l=()=>e.worldStates.of(t),u=r.derive(`session.payload`,`computed`,()=>$X(l(),s.read(),c.read()));return{payload:()=>u.read(),effective:()=>c.read().effective,facts:l,hints:()=>s.read().hints,failure:()=>s7(l()),selections:()=>c.read().effective}}}const l7=`#{pane_id} #{session_id} #{session_attached} #{window_active} #{window_zoomed_flag} #{pane_active}`,u7=`#{session_id} #{client_control_mode} #{pane_id}`;function d7(e){let t=new Set;for(let n of e.split(`
483
+ `);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function n4(e){let t=new Map;return e.map(e=>{let n=`${e.place}.${e.band}`,r=t.get(n)??0;return t.set(n,r+1),{line:e,row:`${n}#${r}`}})}const r4=e=>e.kind===`failed`?a0:e;function i4(e,t){return t.kind===`shown`||t.kind===`failed`&&e.kind===`pending`?e:t}function a4(e,t){let n=[],r=[],i;for(let a of t)(a.band===`own`?n:r).push(a),i??=a.cells.find(t=>t.placement.id===e)?.placement.ground;return{drawing:i===void 0?null:{own:n,opened:r.length>0,ground:i},deeper:r}}function o4(e){return{...e,cells:e.cells.map(d0)}}function s4(e,t){let n=t.flatMap(e=>e.filter(e=>e.place===`above`)),r=t.map(e=>e.filter(e=>e.place===`flow`));return[...n,...c4(e,r)]}function c4(e,t){switch(e){case`vertical`:return t.flatMap(e=>e);case`horizontal`:return t.reduce((e,t)=>Math.max(e,t.length),0)===0?[]:[{cells:t.flatMap(e=>e[0]?.cells??[]),band:`own`,place:`flow`},...t.flatMap(e=>e.slice(1))]}}function l4(e,t){let n=(e,r)=>t(e)?e.kind===`segment`?[{cells:[{name:e.name,address:r,settings:e.settings}],band:`own`,place:`flow`}]:s4(e.direction,e.children.map((t,i)=>n(t,[...r,u4(e,i)]))):[];return n(e,[]).map(e=>[...e.cells])}function u4(e,t){return e.steps[t]}function d4(e){if(e.kind===`segment`||e.unit===!0)return{width:1,reach:1};let t=f4(e);return{width:p4(t),reach:m4(t)}}function f4(e){let t=e.children.map(d4),n=n=>e.direction===`vertical`&&t.slice(0,n).some(({width:e})=>e>0);if(e.direction===`vertical`||e.unit===!0)return t.map((e,t)=>({start:0,span:e,ownLine:n(t)}));let r=0;return t.map((e,t)=>{let i=r;return r+=e.width,{start:i,span:e,ownLine:n(t)}})}const p4=e=>e.reduce((e,{span:t,ownLine:n})=>e+(n?0:t.width),0),m4=e=>e.reduce((e,{start:t,span:n})=>Math.max(e,t+n.reach),0);function h4(e,t){let n=f4(e);if(t?.axis===`cell`)return n.map(({start:e,span:n,ownLine:r})=>{let i=t.index+e;return r?{...t,index:i,lineStart:i,lineEnd:i+n.width-1}:{...t,index:i}});let r=Oy[e.direction],i=nv(e.distribution),[a,o,s]=r===`row`?[n.map((e,t)=>t),n.length,n.length-1]:[n.map(({start:e})=>e),m4(n),p4(n)-1];return a.map(e=>({index:e,count:o,distribution:i,axis:r,lineStart:0,lineEnd:s}))}const g4={compile(e,t){let n=h4(e,t.at);return{kind:`container`,direction:e.direction,when:t.when,steps:n,children:e.children.map((e,r)=>t.compileChild(e,Py(t.path,r),n[r]))}},render(e,t){return t.gate.kind===`failed`&&t.gate.report(),s4(e.direction,e.children.map((n,r)=>t.renderChild(n,r4(t.gate),u4(e,r))))}},_4={drop:e=>e.place,above:()=>`above`},v4={drop:(e,t)=>({lead:t(),stays:e}),above:e=>({lead:e.slice(0,1).flatMap(e=>e.cells),stays:e.slice(1)})},y4={compile(e,t){return{kind:`segment`,when:t.when,name:e.name,id:ky(e),settings:t.placementSettings(e),...e.opens!==void 0&&{opens:{open:t.parse(Ci(e.opens.ref),`opens`),body:t.compileChild(e.opens.body,Fy(t.path),void 0),key:e.opens.ref.key,placement:e.opens.placement}},...e.lead!==void 0&&{lead:t.parse(e.lead,`lead`)},...e.trail!==void 0&&{trail:t.parse(e.trail,`trail`)}}},render:(e,t)=>t.placed(e.id,b4(e,t))};function b4(e,t){let n=t.lookupSegment(e.name);if(n===void 0)throw Error(`Layout segment "${e.name}" has no matching segment`);if(t.gate.kind===`hidden`)return[];let r=XA(t.scope,e.settings);if(t.gate.kind===`failed`)return E4(e,r,t,t.gate.message);try{let i=t.placement(e),a=i4(t.gate,i.gate());if(a.kind===`failed`)return E4(e,r,t,a.message);if(a.kind===`hidden`)return[];let o=i.bodyGate(),s=o.kind===`failed`&&a.kind===`pending`?a:o;if(s.kind===`failed`)return E4(e,r,t,s.message);let c=Hx(e.settings.theme,t.palette),l={id:e.id,effect:e.settings.effect,ground:qN(c)},u=e=>({width:n.width??`auto`,justify:n.justify??`left`,truncate:n.truncate??`right`,baseStyle:e,padding:t.padding,placement:l}),d=s.kind===`shown`,f=a.kind===`pending`?a:s,p=f.kind===`pending`?x4(f.variable):S4(()=>i.evaluate(c,t.region)),m=p.kind===`drawn`?C4(p.segment,u):w4(e,r,t,p.variable,c,d,u);if(m===null)return[];let{styles:h,inline:g,drops:_}=m,v=e.opens,y=v===void 0?[]:t.renderBody(v.body,d?a:a0,h.disclosure).map(e=>({...e,place:_4[v.placement](e)})),b=(e,t,n)=>m0(x0([e],t),{...u(t),width:`auto`,padding:n}),x=y.findIndex(e=>e.band===`own`),{lead:S,stays:C}=v!==void 0&&x!==-1?v4[v.placement](g,()=>b(t.closeDisclosure(v.key),h.close,t.padding)):{lead:[],stays:g},w=S.flatMap(e=>b(new K(` `.repeat(T4(u0(e)))),h.trigger,0)),T=(e,t)=>e.band===`own`?t===x?S:w:[],ee=y.map((e,t)=>({cells:[...T(e,t),...e.cells],band:`deeper`,place:e.place})),te=[...C,..._];return t.perSegmentSink!==void 0&&t.perSegmentSink.set(e.id,[...te.flatMap(e=>e.cells),...y.flatMap(T)].flatMap(u0)),[...te,...ee]}catch(n){return E4(e,r,t,n.message??String(n))}}const x4=e=>({kind:`waiting`,variable:e});function S4(e){try{return{kind:`drawn`,segment:e()}}catch(e){let t=TC(e);if(t===void 0)throw e;return x4(t.variable)}}function C4(e,t){let{styles:n,fragments:r,lead:i,trail:a,drops:o,open:s}=e,c=s?n.trigger:n.closed,l=t(c);return{styles:n,inline:t4(x0(r,c)).map((e,t)=>({cells:m0(e,{...l,lead:t===0?x0(i,c):[],trail:t===0?x0(a,c):[]}),band:`own`,place:`flow`})),drops:o.map(e=>({cells:m0(x0([e],n.band),{...l,baseStyle:n.band}),band:`deeper`,place:`flow`}))}}function w4(e,t,n,r,i,a,o){n.waited(r);let s=n.lastDrawn(e.id);if(s?.kind===`hidden`)return null;let c=n.decorations(e,i),l=a?c.trigger:c.closed,u=x0(D4(e.lead,e,t,n),l),d=x0(D4(e.trail,e,t,n),l);return{styles:c,inline:(s===void 0||s.drawing.own.length===0?[[`auto`]]:s.drawing.own.map(e=>e.cells.map(e=>e.text.cellLength))).map((e,t)=>({cells:e.flatMap((e,n)=>{let r=t===0&&n===0;return m0(x0([new K(r?`…`:` `)],l),{...o(l),width:e,justify:`left`,truncate:`right`,lead:r?u:[],trail:r?d:[]})}),band:`own`,place:`flow`})),drops:[]}}function T4(e){return e.reduce((e,t)=>e+t.cellLength,0)}function E4(e,t,n,r){n.onSegmentError?.(e.id,r);let i=r.replace(/\s*\n\s*/g,` `);return[{cells:m0([new K(`⚠ ${e.id}: ${i}`,{end:``})],{width:`auto`,justify:`left`,truncate:`right`,padding:0,placement:{id:e.id,effect:`bar`,ground:qN(n.palette)},lead:D4(e.lead,e,t,n),trail:D4(e.trail,e,t,n)}),band:`own`,place:`flow`}]}function D4(e,t,n,r){if(e===void 0)return[];try{return r.evaluateOnce(t,n,r.palette,e).fragments}catch(e){let n=TC(e);return n===void 0?r.onSegmentError?.(t.id,e.message??String(e)):r.waited(n.variable),[]}}const O4={container:g4,segment:y4};function k4(e){return O4[e]}var A4=class{last=null;from(e){let{last:t}=this;return t!==null&&t.source.config===e.config&&t.source.preset===e.preset&&t.source.revision===e.revision&&t.source.width===e.width?t:null}begin(e,t){let n=new Map,r=new Map;return{placed:(e,r)=>{let{drawing:i}=t(e,r);return n.set(e,i===null?j4:{kind:`drew`,drawing:i}),r},rule:(e,t)=>r.set(e,t),commit:()=>{this.last={source:e,placements:n,rules:r}}}}};const j4={kind:`hidden`},M4={palette:`theme`,style:`style`,effect:`effect`},N4=Ix.get(`colorCompatibility`),P4={width:0,chromeCols:0,padding:0,seamCols:0,preset:``};function F4(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,error:e}}}function I4(e){if(e.ok)return e.value;throw e.error}const L4=e=>({read:()=>e}),R4=v_({basePalette:__,palette:__,decor:Nv});var z4=class{evaluated=0;memory=new A4;scope;binding;facts;look=Y.observable.box(void 0,{deep:!1,equals:(e,t)=>e!==void 0&&t!==void 0&&R4(e,t)});layout;phase={ruling:!1};gates=new Map;placements=new Map;rules=new Map;slots=new Map;view;projected=void 0;drawnSlots=new Map;constructor(e,t,n,r){this.store=e,this.registry=t,this.source=n,this.view=Y.observable.box(r,{deep:!1}),this.scope=JA(e),this.depth=e.derive(`drawn depth`,`computed`,()=>{let e=this.inputAt(N4);return e.kind===`found`&&typeof e.value==`string`&&_y(e.value)?e.value:`truecolor`});let i=(0,Y.observable)(P4,void 0,{deep:!1});this.facts=i;let a=this.look,o=this.phase,s=()=>this.layout.read();this.binding={store:e,registry:t,get width(){return i.width},get chromeCols(){return i.chromeCols},get padding(){return i.padding},get seamCols(){return i.seamCols},get look(){return o.ruling?void 0:a.get()},get layout(){return o.ruling?void 0:s}},this.layout=this.derive(`layout`,n.layoutReadsInstant,()=>{let e=n.roots.get(i.preset),t=a.get().palette;return l4(e,e=>this.shown(e)).map(e=>e.flatMap(({name:e,address:n,settings:r})=>{let i=kR(e);return i===void 0?[]:[{name:i,address:n,palette:Hx(r.theme,t)}]}))}),t.bindInputs({read:e=>this.inputAt(e),drawnAt:()=>vy(this.colorCompatibility())})}bind(e){(0,Y.runInAction)(()=>this.view.set(e))}selections(){return this.view.get().selections()}draw(e,t){this.draws++,this.projected=t,this.drawnSlots.clear(),(0,Y.runInAction)(()=>Object.assign(this.facts,e))}inputAt(e){let t=fM(e);return t===void 0?uM(e)===void 0?$j(this.view.get().payload(),e):$j(this.projected,e):Qj(this.slotName(t))}depth;colorCompatibility(){return this.depth.read()}slot(e){let t=this.slots.get(e);if(t===void 0){let n,r=()=>{let t=this.selections()[M4[e]];if(t.kind===`decided`)return H4(t.name,null,null);let r=W4(this.source,e,t.source);if(this.source.instant.has(r.template))return{kind:`per-draw`,rule:r};let i=this.rule(r.template);switch(i.kind){case`named`:{let t=null;return n=G4(this.source,e,i.name,r.where,e=>{t=e}),H4(n,t,null)}case`pending`:return H4(n??iy[e],null,i.variable);case`failed`:return n=iy[e],H4(n,ay(r.where,e,`the rule failed — ${i.error}`),null)}},i;t=this.store.derive(`slot ${e}`,`computed`,()=>{let e=r();return(i===void 0||!U4(i,e))&&(i=e),i}),this.slots.set(e,t)}return t.read()}slotName(e){let t=this.slot(e);return t.kind===`settled`?t.name:this.drawnSlots.get(e)??iy[e]}drawnSlot(e,t){this.drawnSlots.set(e,t)}draws=0;publishLook(e){(0,Y.runInAction)(()=>this.look.set(e))}gate(e){let{when:t}=e;if(t===void 0)return s0(t,this.scope);let n=this.gates.get(e);return n===void 0&&(n=this.derive(`when`,this.readsInstant(t),()=>s2(this.source.activeSegment,()=>s0(t,this.scope))),this.gates.set(e,n)),n.read()}placement(e){let t=this.placements.get(e);return t===void 0&&(t=new K4(this,e),this.placements.set(e,t)),t}rule(e){let t=this.rules.get(e);return t===void 0&&(t=this.derive(`rule`,this.readsInstant(e),()=>{this.phase.ruling=!0;let t=this.source.runtime.bound===this.binding?null:D0(this.source.runtime,this.binding);try{return{kind:`named`,name:e.evaluate(this.scope).map(e=>e.plain).join(``)}}catch(e){let t=TC(e);return t===void 0?{kind:`failed`,error:e instanceof Error?e.message:String(e)}:{kind:`pending`,variable:t.variable}}finally{t?.[Symbol.dispose](),this.phase.ruling=!1}}),this.rules.set(e,t)),t.read()}readsInstant(...e){return e.some(e=>e!==void 0&&this.source.instant.has(e))}derive(e,t,n){let r=()=>(this.evaluated++,n());return this.store.derive(`part ${e}`,t?`projection`:`computed`,t?this.oncePerDraw(r):r)}oncePerDraw(e){let t=null;return()=>(t?.draw!==this.draws&&(t={draw:this.draws,answer:F4(e)}),I4(t.answer))}shown(e){let t=this.gate(e);return e.kind===`container`?t.kind===`shown`||t.kind===`pending`:kR(e.name)===void 0||t.kind===`hidden`?!1:t.kind===`failed`?!0:this.placement(e).gate().kind!==`hidden`}};function B4(e,t,n,r){let i=e.views.get(t);if(i!==void 0)return i.bind(r),i;let a=new z4(t,n,e,r);return e.views.set(t,a),a}function V4(e,t){let n=e.views.get(t);if(n===void 0)throw Error(`a store was drawn before its view was bound (bindView): its inputs have no source`);return n}const H4=(e,t,n)=>({kind:`settled`,name:e,warning:t,waited:n}),U4=(e,t)=>e.kind===`settled`?t.kind===`settled`&&e.name===t.name&&e.warning===t.warning&&e.waited===t.waited:t.kind===`per-draw`&&e.rule===t.rule;function W4(e,t,n){let r=e.globalExpressions.get(t)?.get(n);if(r===void 0)throw Error(`the ${t} rule ${JSON.stringify(n)} reached the view but no compiled template exists — the compile and the resolution disagree about isExpression`);return r}function G4(e,t,n,r,i){switch(t){case`palette`:return Kx(n,r,i).name;case`style`:return ty(n,e.styles).name;case`effect`:return dy(n).name}}var K4=class{where=q4(v_({palette:__,region:jv}));ground=q4(v_({colours:Y4,bodyOpen:__}));opened=q4(v_({colours:Y4,open:__}));ownGate;open;colours;body;affixes;constructor(e,t){let n=e.source.segments[t.name],r=e.source.activeSegment,i=XA(e.scope,t.settings),{when:a,bg:o,fg:s,template:c}=n,{lead:l,trail:u}=t,d=t.opens?.open;this.ownGate=a===void 0?L4(o0):e.derive(`${t.id} when`,e.readsInstant(a),()=>s2(r,()=>s0(a,i))),this.open=d===void 0?L4(a0):e.derive(`${t.id} body gate`,e.readsInstant(d),()=>s2(r,()=>s0(d,e.scope))),this.colours=e.derive(`${t.id} colours`,e.readsInstant(o,s),()=>{let{palette:n,region:a}=this.where.get();return Q4(r,t,n,a,e.registry.drawnAt(),o,s,i)}),this.body=e.derive(`${t.id} body`,e.readsInstant(c),()=>{let{colours:e,bodyOpen:n}=this.ground.get();return $4(r,t,e,c,n,i)}),this.affixes=l===void 0&&u===void 0?L4(t3):e.derive(`${t.id} affixes`,e.readsInstant(l,u),()=>{let{colours:e,open:n}=this.opened.get();return e3(r,t,e,n,l,u,i)})}gate(){return this.ownGate.read()}bodyGate(){return this.open.read()}evaluate(e,t){this.where.set({palette:e,region:t});let n=this.colours.read();this.ground.set({colours:n,bodyOpen:this.open.read().kind===`shown`});let r=this.body.read();return this.opened.set({colours:n,open:r.open}),r3(n,r,this.affixes.read())}};function q4(e){let t=Y.observable.box(void 0,{deep:!1,equals:(t,n)=>t!==void 0&&n!==void 0&&e(t,n)});return{set:e=>(0,Y.runInAction)(()=>t.set(e)),get:()=>t.get()}}const J4=(e,t)=>e.hex===t.hex,Y4=v_({palette:__,drawnAt:__,tint:J4,text:J4,bg:J4,disclosure:Pv});function X4(e,t){return{segName:e.name,placementId:e.id,palette:t.palette,disclosure:t.disclosure,tint:t.tint,text:t.text}}const Z4=e=>Ov(e.palette,e.disclosure,e.drawnAt);function Q4(e,t,n,r,i,a,o,s){let c={palette:n,drawnAt:i,...Bv(n,r,i)};return o2(e,X4(t,c),e=>{let t=YN(e,i,a,o,s);return{...c,bg:e.bg,style:t}})}function $4(e,t,n,r,i,a){return o2(e,X4(t,n),e=>(e.bg=i?Z4(n).state:n.bg,{fragments:r.evaluate(a),drops:e.drops,open:e.drops.length>0||i}))}function e3(e,t,n,r,i,a,o){return o2(e,X4(t,n),e=>(e.bg=r?Z4(n).state:n.bg,{lead:i?.evaluate(o)??[],trail:a?.evaluate(o)??[],drops:e.drops}))}const t3={lead:[],trail:[],drops:[]};function n3(e){let{palette:t,drawnAt:n,disclosure:r}=e;return{closed:e.style,get trigger(){return U0(t,Z4(e).state,n)},get band(){return U0(t,Z4(e).plane,n)},get close(){return K0(t,Z4(e).state,n)},disclosure:r}}function r3(e,t,n){return{styles:n3(e),fragments:t.fragments,lead:n.lead,trail:n.trail,drops:[...t.drops,...n.drops],open:t.open}}function i3(e,t,n,r,i,a,o){let s=Q4(e,t,n,r,i,void 0,void 0,o);return r3(s,$4(e,t,s,a,!1,o),t3)}function a3(e,t,n,r,i){return n3(Q4(e,t,n,r,i,void 0,void 0,{}))}function o3(e,t){return{payload:()=>e,selections:()=>t}}function s3(e){if(`ttl`in e)return{kind:`ttl`,durationMs:Jj(e.ttl)};if(`watch_file`in e)return{kind:`watch_file`,path:e.watch_file};if(`depends_on`in e)return{kind:`depends_on`,varNames:e.depends_on};if(`key`in e)return{kind:`key`,template:e.key};if(`never`in e)return{kind:`never`};throw Error(`Unknown CacheDecl discriminator — loader invariant violated: ${JSON.stringify(e)}`)}function c3(e,t){switch(Ry(e)){case`json`:return{kind:`json`,default:t};case`regex`:return{kind:`regex`,regex:new RegExp(e.regex),default:t};case`text`:return{kind:`text`,default:t}}}function l3(e,t,n,r,i){switch(n.kind){case`literal`:e.declareLiteral(t,n.value);break;case`dropped`:e.declareFailedDocument(t,n.reason);break;case`source`:e.declareSourceDocument(t);break;case`input`:e.declareInput(t,n.path,n.type??`string`,n.default,i);break;case`env`:e.declareEnv(t,n.name,n.default);break;case`file`:e.declareFile(t,n.path,{readMode:n.readMode,cache:s3(n.cache),parse:c3(n.parse,n.default)});break;case`shell`:e.declareShell(t,n.command,{cwd:r,cache:s3(n.cache),parse:c3(n.parse,n.default)});break;case`template`:e.declareTemplate(t,n.template,{type:n.type??`string`,varDefault:n.default,derivation:i});break;case`time`:e.declareTime(t,{format:n.layout,varDefault:n.default});break;case`state`:e.declareState(t,{key:n.key,...n.default!==void 0&&{varDefault:n.default}});break}}function u3(e,t,n,r=pw.EMPTY){let i=r;for(let[r,a]of Object.entries(t))try{i=e.parse(`{{ define "${r}" }}${a}{{ end }}`,i).defines()}catch(e){throw Error(`Template parse error in ${n}.${r}: ${e.message}`,{cause:e})}return i}function d3(e,t,n){let{compiled:r,loadWarnings:i}=p3(e,t,n.cwd,f3(n.signer),_3);return{...r,loadWarnings:i}}const f3=e=>(t,n)=>v3(n,e);function p3(e,t,n,r,i=_3){let a=m3(e),o=h3(a);return{compiled:r(o,a),compileKey:o,loadWarnings:g3(e,t,n,i)}}function m3(e){let{variables:t,...n}=e,r=new Map;for(let[e,n]of Lx)n in t&&r.set(e,n);for(let[t,n]of Gy(e))r.has(n.key)||r.set(n.key,t);return{config:n,stateReads:[...r].sort(([e],[t])=>e<t?-1:1),projections:[...qW(e)].sort(([e],[t])=>e<t?-1:1)}}function h3(e){return ae(`sha256`).update(JSON.stringify(e)).digest(`hex`)}function g3(e,t,n,r){let i=$2(e),a=qW(e),o=[];for(let[s,c]of dC(e))if(r.has(i.get(s)))try{l3(t,s,c,n,a.has(s)?`projection`:`computed`)}catch(e){o.push(`Variable "${s}": ${e.message??String(e)}`)}return o}const _3=new Set([`directory`,`view`]);function v3({config:e,stateReads:t,projections:n},r){let i={bound:void 0,compiled:new Map,signer:r},a=()=>w0(i,`drawnAt`).registry.drawnAt(),o=i2(a),s={action:i,activeSegment:o},c=Object.keys(e.styles),l=lS(e.presets),u=vR(e),d=[e=>D2(i,o,e.now)],f=qA({extraFuncs:{...V0(i),...E2(i),...y2(i,o),...S2(i),...M2(i,o),...R2(i,o),...H2(s),...G2(o),styles:{fn:()=>c,argTypes:[],arity:{kind:`exact`}},presets:{fn:()=>l,argTypes:[],arity:{kind:`exact`}}},clockFuncs:d,drawnAt:a}),p=u3(f,e.helpers,`helpers`),m=new Map,h=e=>{let t=f.parse(e,p);return m.set(t,e),t},g=new Map,_=e=>{let t=g.get(e);if(t!==void 0)return t;let n=h(e);return g.set(e,n),n},v=new Map(t);i.compiled=O0(h,e.actions,v,u);let y=Object.create(null);for(let[t,n]of Object.entries(e.segments)){let e=n.partials===void 0?p:u3(f,n.partials,`segments.${t}.partials`,p),r=t=>{let n=f.parse(t,e);return m.set(n,t),n},i=(e,i,a=n.partials===void 0?_:r)=>{try{return a(e)}catch(e){throw Error(`Template parse error in segments.${t}.${i}: ${e.message}`,{cause:e})}};y[t]={when:n.when===void 0?void 0:i(n.when,`when`),template:i(n.template,`template`,r),bg:n.bg===void 0?void 0:i(n.bg,`bg`,r),fg:n.fg===void 0?void 0:i(n.fg,`fg`,r)}}let b=(e,t,n)=>{try{return _(e)}catch(e){throw Error(`Template parse error in ${t}.${n}: ${e.message}`,{cause:e})}},x=t=>{let n=Yy(e.segments[t.name]),r=Object.create(null);for(let[e,a]of Object.entries(n))Object.defineProperty(r,e,{enumerable:!0,get:()=>tb(t,e,a,t=>String(w0(i,`setting ${e}`).store.read(t.variable)))});return Object.freeze(r)},S=(e,t,n)=>{let r={path:t,at:n,when:e.when===void 0?void 0:b(e.when,t,`when`),parse:(e,n)=>b(e,t,n),compileChild:S,placementSettings:x};return k4(e.kind).compile(e,r)},C=new Map;for(let t of l){let{node:n,path:r}=fS(e,t);C.set(t,S(n,r,void 0))}let w=new Map(Xv.map(e=>[e,new Map]));for(let{at:t,slot:n,rule:r}of YW(e)){let e=t.join(`.`),i=w.get(n),a=i.get(r);i.set(r,a===void 0?{where:e,template:x3(h,e,r)}:{where:`${a.where}, ${e}`,template:a.template})}let T=new Set(n.map(([e])=>e)),ee={reads:BW({names:T,helpers:e.helpers,actions:e.actions}),projections:new Map(n),clock:WA(d)},te=QW(ee),E=[...C.values()].flatMap(b3(y)).some(e=>te(m.get(e))),ne=E?new Set([...ee.clock,L2]):ee.clock,D=QW({...ee,clock:ne}),O=new Set([...m].flatMap(([e,t])=>D(t)?[e]:[]));for(let[t,n]of Object.entries(e.segments)){if(n.partials===void 0)continue;let r=QW({reads:BW({names:T,helpers:{...e.helpers,...n.partials},actions:e.actions}),projections:ee.projections,clock:ne});for(let e of sH){let n=y[t][e];n!==void 0&&r(m.get(n))&&O.add(n)}}return{segments:y,roots:C,activeSegment:o,menuRuntime:s,globalExpressions:w,instant:O,layoutReadsInstant:E,styles:e.styles,runtime:i,views:new WeakMap}}function y3(e){return Object.entries(e.segments).flatMap(([t,n])=>[n.when,n.bg,n.fg,n.template].some(t=>t!==void 0&&e.instant.has(t))?[t]:[])}const b3=e=>t=>{let n=[];return l4(t,e=>(n.push(e),!0)),n.flatMap(t=>[...t.when===void 0?[]:[t.when],...t.kind===`segment`&&e[t.name].when!==void 0?[e[t.name].when]:[]])};function x3(e,t,n){try{return e(n)}catch(e){throw Error(`${t} is not a valid template: ${e instanceof Error?e.message:String(e)}`)}}const S3=e=>{throw Error(`a slot settled on a name its domain refuses: ${e}`)};function C3(e,t,n,r,i){let a=w3(e,t,n.rule(t.template),r,i);return i.settled(e,a),a}function w3(e,t,n,r,i){switch(n.kind){case`named`:return n.name;case`pending`:return i.waited(n.variable),i.held(e)??iy[e];case`failed`:return r({kind:`rule`,slot:e,message:ay(t.where,e,`the rule failed — ${n.error}`)}),iy[e]}}function T3(e){return E3(e).filter(e=>!e.name.startsWith(Pi)).map(e=>e.id)}function E3(e){return e.kind===`container`?e.children.flatMap(E3):[e,...e.opens===void 0?[]:E3(e.opens.body)]}function D3(e,t,n,r,i,a){let o={...r,term:{cols:i.width},colorCompatibility:{effective:i.colorCompatibility}};return B4(e,t,n,o3(o,a)),o}function O3(e,t,n,r,i,a,o,s,c){try{var l=No();let{perSegmentSink:u,onSegmentError:d,onRenderWarning:f}=s??{},p=e=>f?.(e),m=c.effects??new DP(``),h=m.clockAt(a,sy[c.animationSpeed]),g=l.u(PA(a,h.timeline)),_=V4(t,n),v={...o,colorCompatibility:_.colorCompatibility()};_.draw({width:v.width,chromeCols:KP(v),padding:v.padding,seamCols:qP(v),preset:c.preset},i);let y=_.evaluated;l.u(D0(t.menuRuntime.action,_.binding));let{preset:b,transitions:x}=c,S={variation:B_[c.variation],shade:j_[c.shade]},C={config:e,preset:b,revision:r.stateRevision(),width:v.width},w=_.memory.begin(C,a4),T=_.memory.from(C),ee=new Set,te={held:e=>T?.rules.get(e),waited:e=>ee.add(e),settled:w.rule},E=new Map,ne=e=>{let n=_.slot(e);if(E.set(e,n.kind===`settled`?`kept`:`per-draw`),n.kind===`settled`)return n.warning!==null&&p({kind:`rule`,slot:e,message:n.warning}),n.waited!==null&&ee.add(n.waited),n.name;let r=G4(t,e,C3(e,n.rule,_,p,te),n.rule.where,t=>p({kind:`rule`,slot:e,message:t}));return _.drawnSlot(e,r),r},{theme:D,style:O,effect:re}=_.selections(),k=D.kind===`decided`?D:Kx(ne(`palette`),``,S3),ie=O.kind===`decided`?O:ty(ne(`style`),e.styles),ae=re.kind===`decided`?re:dy(ne(`effect`)),oe=k.value,se=Wx(oe,ie.value);_.publishLook({basePalette:oe,palette:se,decor:S});let ce=se.get(`warning`),le=c.idleSince===void 0?null:{idleSince:c.idleSince,timeoutS:c.menuTimeout,fill:ce,text:vv(se,ce,r.drawnAt())},ue=m.motion(ae.value,h,{transitions:x,source:C,last:T,returned:a4,hold:o4},le);u?.clear();let de=t=>e.segments[t],fe=(e,i,a)=>{let o=i.kind===`hidden`?i:i4(i,_.gate(e)),s=o.kind===`failed`?{...o,report:()=>{let t=`when over ${T3(e).join(`, `)||`no placement`}`;p({kind:`when`,where:t,error:o.message,message:`${t}: ${o.message} — what it gates is hidden`})}}:o,c={scope:_.scope,palette:se,gate:s,padding:v.padding,region:a,perSegmentSink:u,onSegmentError:d,placement:e=>_.placement(e),evaluateOnce:(e,n,i,o)=>i3(t.activeSegment,e,i,a,r.drawnAt(),o,n),lookupSegment:de,renderChild:(e,t,n)=>fe(e,t,Rv(a,n)),renderBody:(e,t,n)=>fe(e,t,zv(n)),closeDisclosure:e=>H0(n,e),placed:(e,t)=>w.placed(e,ue.placed(e,t)),lastDrawn:e=>T?.placements.get(e),waited:e=>ee.add(e),decorations:(e,n)=>a3(t.activeSegment,e,n,a,r.drawnAt())};return k4(e.kind).render(e,c)},pe=t.roots.get(b);if(pe===void 0)throw Error(`Preset "${b}" has no compiled layout — registerDslConfig compiles one per declared preset and effectivePresetName collapses unknown names to "${sS}"; a miss here is merge/policy drift (have: ${[...t.roots.keys()].join(`, `)})`);let me=n4(fe(pe,o0,Lv(S))).map(({line:e,row:t})=>{let n=y0(e.cells,v),r=e.band===`deeper`?`menu`:`bar`;return{kind:r,cellBreaks:n.length-e.cells.length,...XP(n.map(e=>e.owner),v,ue.row(t,r,n))}});ue.drawn(),w.commit();let he=()=>me.some(e=>e.kind===`menu`)||_.selections().effect.kind===`expression`||x||E3(pe).some(({settings:e})=>e.effect!==`bar`&&e.effect!==`none`),ge=Math.min(g.heard(),...me.map(e=>e.nextChange)),_e=Number.isFinite(ge)?`moves`:he()?`can-move`:`still`;for(let[e,t]of r.cachePolicyFaults())p({kind:`refresh`,variable:e,error:t.message,message:`variable "${e}" cannot refresh: ${t.message}`});return{frame:{depth:v.colorCompatibility,rows:me.flatMap(({kind:e,lines:t})=>t.map(t=>({kind:e,runs:t}))),nextChange:ge,motion:_e,pending:[...ee].sort()},evaluated:_.evaluated-y,cellBreaks:me.reduce((e,t)=>e+t.cellBreaks,0),rules:E}}catch(e){l.e=e}finally{l.d()}}const k3={moving:1e3/30,still:1e3},A3=[`data`,`state`,`reload`,`visibility`];function j3(e){return Zb.filter(t=>e[t].subscribers>0).map(t=>{let{subscribers:n,fps:r,shown:i}=e[t];return`${t}:${n}sub/${r}fps/${i?`shown`:`offscreen`}`}).join(`,`)||`-`}function M3(e,t){let n=e.filter(e=>e>t-1&&e<=t);e.splice(0,e.length,...n,t)}const N3=(e,t)=>Xb[t].handsOff?e.resp:e.statusline,P3=e=>Math.round(1e3/e);var F3=class{requests=new Map;feeds=new Map;stopWatching=null;drawn=0;pushed=0;refused=0;lookups=0;found=0;constructor(e){this.deps=e}note(e,t,n){let r=this.requests.get(e);if(r!==void 0&&r.order>n)return;this.requests.delete(e),this.requests.set(e,{req:t,order:n});for(let e of this.requests.keys()){if(this.requests.size<=256)break;this.feeds.has(e)||this.requests.delete(e)}let i=this.feeds.get(e);i!==void 0&&i.noted++}subscribe(e,t){let n=this.deps.lanes(e);if(n!==null&&!n[t.lane])return this.refuse(e,t),()=>{};let r=this.feeds.get(e),i=r??this.open(e);return i.followers.set(t,null),i.rates.has(t.lane)||i.rates.set(t.lane,[]),r!==void 0&&this.send(i,t),this.hasten(i),this.deps.log(`info`,`feed sid=${JSON.stringify(e)} subscribed lane=${t.lane} subscribers=${i.followers.size} view=${n===null?`N`:`Y`}`),()=>this.unsubscribe(i,t)}feedOpen(e){return this.feeds.has(e)}following(e){return new Set([...this.feeds.get(e)?.followers.keys()??[]].filter(e=>e.drawing()).map(e=>e.lane))}wake(e,t){let n=this.feeds.get(e);n!==void 0&&(n.woke[t]++,this.hasten(n)||n.coalesced++)}wakeWhere(e,t){for(let{sessionId:n,req:r}of this.watched())t(r)&&this.wake(n,e)}newestWhere(e){let t=null;for(let[n,{req:r,order:i}]of this.requests)e(r)&&(t===null||i>t.order)&&(t={sessionId:n,order:i});return this.lookups++,t!==null&&this.found++,t?.sessionId??null}latest(e){return this.requests.get(e)?.req??null}watched(){return[...this.feeds.keys()].flatMap(e=>{let t=this.requests.get(e);return t===void 0?[]:[{sessionId:e,req:t.req}]})}feedsOf(e,t){let n=this.feeds.get(e);if(n===void 0)return ix;let r=t-1,i=this.shown(n);return rx(e=>{let a=n.rates.get(e);if(a===void 0)return tx;let o=0;for(let t of n.followers.keys())t.lane===e&&o++;let s=0;for(let e of a)e>r&&e<=t&&s++;return{subscribers:o,fps:s,shown:i}})}getStats(){let e=0;for(let t of this.feeds.values())e+=t.followers.size;return{feeds:this.feeds.size,subscribers:e,drawn:this.drawn,pushed:this.pushed,refused:this.refused,lookups:this.lookups,found:this.found}}open(e){let t=this.deps.clock.monotonic(),n={sessionId:e,followers:new Map,rates:new Map,unwatch:this.deps.watch(e,()=>this.wake(e,`state`)),unpin:this.deps.pin(e),phase:{kind:`waiting`},lastStart:-1/0,last:null,since:t,drawn:0,noted:0,noView:0,moving:0,unseen:0,failed:0,pushed:0,drawMs:0,evaluated:0,cellBreaks:0,woke:{data:0,state:0,reload:0,visibility:0},coalesced:0,summarizedAt:t,refreshesAtOpen:this.deps.refreshes()};return this.feeds.set(e,n),this.stopWatching??=this.deps.watching(),n}close(){for(let e of[...this.feeds.values()])for(let t of[...e.followers.keys()])this.unsubscribe(e,t)}unsubscribe(e,t){if(e.followers.delete(t)){if([...e.followers.keys()].some(e=>e.lane===t.lane)||e.rates.delete(t.lane),e.followers.size>0){this.hasten(e);return}e.phase.kind===`due`&&e.phase.clear(),e.unwatch(),e.unpin(),this.feeds.delete(e.sessionId),this.feeds.size===0&&(this.stopWatching?.(),this.stopWatching=null),this.summarize(e,`closed`)}}draw(e,t){e.phase={kind:`drawing`};let n=this.deps.clock.monotonic(),r=this.deps.instant(),i=Math.min(Math.max(t,r),r+.002),a=n+(i-r)*1e3;try{this.step(e,n,a,i)}catch(t){if(e.lastStart=a,this.deps.log(`error`,`feed sid=${JSON.stringify(e.sessionId)} threw: ${x(t)}`),this.feeds.get(e.sessionId)!==e)return;this.schedule(e,null,i)}}step(e,t,n,r){let i=this.deps.render(e.sessionId,P3(this.spacingOf(e)),r);if(i===null){e.noView++,e.phase={kind:`waiting`};return}e.lastStart=n;let a=this.deps.clock.monotonic();this.drawn++,e.drawn++,e.drawMs+=a-t,e.evaluated+=i.evaluated,e.cellBreaks+=i.cellBreaks,this.feeds.get(e.sessionId)===e&&(this.countFailure(e,i),this.push(e,i,r),this.feeds.get(e.sessionId)===e&&(a-e.summarizedAt>=6e4&&this.summarize(e,`running`),this.schedule(e,i,r)))}schedule(e,t,n){let{moving:r,still:i}=this.deps.periods,a=((t?.bar.nextChange??1/0)-n)*1e3,o=Math.min(Math.max(a,r),i),s=this.shown(e);o<i&&s&&e.moving++,o<i&&!s&&e.unseen++;let c=s?o:i;this.arm(e,n+c/1e3,this.deps.instant())}spacingOf(e){return this.shown(e)?this.deps.periods.moving:this.deps.periods.still}hasten(e){let{phase:t}=e;if(t.kind===`drawing`)return!1;let n=this.deps.clock.monotonic(),r=Math.max(n,e.lastStart+this.spacingOf(e));if(t.kind===`due`&&t.at<=r)return!1;let i=this.deps.instant();return this.arm(e,i+(r-n)/1e3,i),!0}arm(e,t,n){let r=Math.max(0,(t-n)*1e3);this.setTimer(e,t,this.deps.clock.monotonic()+r,r)}setTimer(e,t,n,r){e.phase.kind===`due`&&e.phase.clear(),e.phase={kind:`due`,at:n,clear:this.deps.clock.after(r,()=>this.fire(e,t,n))}}fire(e,t,n){let r=n-this.deps.clock.monotonic();r>0?this.setTimer(e,t,n,r):this.draw(e,t)}shown(e){let t=this.requests.get(e.sessionId);return t===void 0||this.deps.shown(t.req)}countFailure(e,t){t.failure!==null&&e.failed++}push(e,t,n){let r=this.deps.lanes(e.sessionId);if(r!==null)for(let t of[...e.followers.keys()])r[t.lane]||(this.unsubscribe(e,t),this.refuse(e.sessionId,t));if(e.followers.size===0)return;t.delivered();let i={resp:JSON.stringify(t.resp),statusline:JSON.stringify(t.statusline)};if(e.last?.answers.resp===i.resp&&e.last.answers.statusline===i.statusline)return;let a=e.last?.answers??null;e.last={bar:t.bar,answers:i},this.pushed++,e.pushed++,t.failure!==null&&this.deps.log(t.failure.level,t.failure.line);for(let[t,r]of e.rates)(a===null||N3(a,t)!==N3(i,t))&&M3(r,n);for(let t of e.followers.keys())this.send(e,t)}send(e,t){if(e.last===null)return;let n=N3(e.last.answers,t.lane);e.followers.get(t)!==n&&(t.frame(e.last.bar,n),e.followers.set(t,n))}refuse(e,t){this.refused++,this.deps.log(`info`,`feed sid=${JSON.stringify(e)} refused lane=${t.lane} switched-off`),t.refused({ok:!1,error:HM(t.lane),code:`SWITCHED_OFF`,daemonV:3})}summarize(e,t){let n=this.deps.clock.monotonic(),r=this.deps.refreshes(),i=(n-e.since)/1e3,a=i===0?`-`:`${(e.drawn/i).toFixed(1)}fps`,o=Ej.map(t=>`${t}:${r[t]-e.refreshesAtOpen[t]}`).join(`,`);this.deps.log(`info`,`feed sid=${JSON.stringify(e.sessionId)} ${t} subscribers=${e.followers.size} lanes=${[...e.followers.keys()].map(e=>e.lane).join(`,`)||`-`} for=${Math.round(i)}s drawn=${e.drawn} noted=${e.noted} noView=${e.noView} moving=${e.moving} unseen=${e.unseen} failed=${e.failed} pushed=${e.pushed} ceiling=${P3(this.spacingOf(e))}fps achieved=${a} evaluated=${e.evaluated} cellBreaks=${e.cellBreaks} woke=${A3.map(t=>`${t}:${e.woke[t]}`).join(`,`)} coalesced=${e.coalesced} daemonRefreshed=${o} meanDraw=${e.drawn===0?`-`:(e.drawMs/e.drawn).toFixed(2)}ms`),e.summarizedAt=n}};function I3(e,t){return Zb.filter(n=>e[n]&&Xb[n].handsOff&&t.has(n))}function L3(e,t){return{severity:mU,lines:[[gU(`[⟲ claude]`,Ea([{verb:na,args:[e,...t.map(e=>Xb[e].switch.setting)]}]))]]}}function R3(e,t){for(let n of Object.entries(t))e.push(n)}const z3={ok:`info`,"bad-request":`warn`,threw:`error`,closing:`info`,abandoned:`info`};function B3(e){switch(e.kind){case`ok`:return[];case`bad-request`:return[[`problems`,e.problems.join(`; `)]];case`threw`:return[[`error`,x(e.error)]];case`closing`:return[[`closing`,e.error.message]];case`abandoned`:return[[`abandoned`,`1`]]}}function V3(e,t,n,r){let i=[...t,[`took`,`${r}ms`],[`outcome`,n.kind],...B3(n)];return{level:z3[n.kind],line:Oc(e,i)}}const H3=()=>{},U3=e=>({ok:!1,error:e instanceof Error?e.message:x(e),code:`RENDER_FAILED`,daemonV:3}),W3={ansi:e=>({ok:!0,output:gte(e)}),frame:e=>({ok:!0,frame:e})};function G3(e,t,n,r){let{clock:i,frameFeeds:a}=e,o=i.monotonic(),s=[];try{try{var c=No();let i=c.u(t6(e,t,r,s));if(i===null)return null;let{drawn:o,evaluated:l,cellBreaks:u,delivered:d,lanes:f}=r6(e,i,{by:`feed`,fps:n}),p=W3.ansi(o.body),m=u6(t,o,I3(f,a.following(t)));return{bar:o.body,resp:p,statusline:m===o.body?p:W3.ansi(m),evaluated:l,cellBreaks:u,delivered:d,failure:null}}catch(e){c.e=e}finally{c.d()}}catch(e){let{level:t,line:n}=V3(`render`,s,{kind:`threw`,error:e},Fe(i,o)),r=U3(e);return{bar:ute(r.error),resp:r,statusline:r,evaluated:0,cellBreaks:0,delivered:H3,failure:{level:t,line:`frame ${n}`}}}}function K3(e,t,n){let{sessionState:r}=e;return CK(n.config,e=>r.get(t,e),e=>n.authoredRoots.has(e))}function q3(e,t){try{var n=No();let{renderCache:r}=e,i=n.u(r.holdView(t));return i===null?null:bK(i.view.source.effective(),Nc(i.view.facts().hints.tmux))}catch(e){n.e=e}finally{n.d()}}function J3(e,t,n){try{var r=No();let{renderCache:i,frameFeeds:a}=e,o=r.u(i.hold(t.projectDir,t.cwd,t.target.path)),s=a.latest(n);return bK(K3(e,n,o.state),s===null||Nc(s.hints.tmux))}catch(e){r.e=e}finally{r.d()}}function Y3(e,t,n){R3(n,{sid:e.sessionId,at:t.toFixed(3)});let{hints:r}=e;R3(n,{termCols:String(r.termCols??`?`),termRows:String(r.termRows??`?`),refused:Bn(e,r).map(e=>e.hint).join(`,`)||`-`,badArgs:e.refusedArgs.map(e=>`${e.arg}:${e.why}`).join(`,`)||`-`,client:r.client?.kind??`unreported`,rateLimits:e.rateLimits})}const X3=e=>Vn(Bn(e,e.hints));function Z3(e,t,n,r,i){Y3(t,r,i),R3(i,{encoding:t.encoding}),(0,Y.runInAction)(()=>{i6(e,t),e.worldStates.take(n),$3(e,t)[Symbol.dispose]()})}function Q3(e,t){(0,Y.runInAction)(()=>{e.worldStates.drop(t),e.renderCache.retireSession(t)})}function $3(e,t){let n=r1(t.requested,e.sessionState,t.sessionId);return e.renderCache.holdSession(n.projectDir,n.cwd,n.target.path,t)}function e6(e,t,n,r){let i=X3(t);return n6(e,$3(e,t),t,i,n,r)}function t6(e,t,n,r){let{renderCache:i}=e,a=i.holdView(t);if(a===null){let e=i.openFailure(t);if(e!==null)throw e.error;return null}let o=a.view.facts(),s;try{Y3(o,n,r),s=X3(o)}catch(e){throw a[Symbol.dispose](),e}return n6(e,a,o,s,n,r)}function n6(e,t,n,r,i,a){let{payloadProviders:o}=e;try{let{entry:e,state:s,view:c}=t,{sessionId:l,hints:u}=n;return{req:n,at:i,facts:a,sessionId:l,entry:e,state:s,view:c,hintsError:r,payloadInputs:{hookData:n.hookData,deps:o,cwd:n.cwd,hints:u},[Symbol.dispose]:()=>t[Symbol.dispose]()}}catch(e){throw t[Symbol.dispose](),e}}function r6(e,t,n){let{sessionState:r,frameFeeds:i,renderCache:a,updateWatch:o,linkSigner:s,fileEvents:c,renderWarnings:l,payloadProviders:u,effectSessions:d,menuIdle:f,launcher:p}=e,{req:m,at:h,facts:g,sessionId:_,entry:v,state:y,view:b,hintsError:x}=t,S=b.source.payload(),C=b.source.effective(),w=b.source.failure(),T=bK(C,S.tmux!==void 0);R3(g,{lanes:Zb.filter(e=>T[e]).join(`,`)||`-`});let ee=b.source.hints(),te=S.term.cols;R3(g,{width:String(te)});let E=Tc(r,_,h,n.by),ne=E.kind===`held`||E.kind===`owed`?E.error:null,D=o.notice({sessionId:_,dismissed:r.get(_,yz),enabled:C.updateNotice}),O=UU(v.repos,_,s),re=(e,t)=>({about:e,text:t,copy:t}),k=e=>re(e??``,e),ie=[k(Un(m.refusedArgs)),k(x),re(`load`,v.lastError),re(`update-act`,o.error()),...y.dropped.map(e=>({about:`dropped\0${e.file}`,text:e.message,copy:e.prompt})),k(ne?.text)].flatMap(({about:e,text:t,copy:n})=>e&&t&&n?[{about:e,text:t,copy:n}]:[]),ae=v.watch===null?null:rj(`config watch`,v.watch,null),oe=p.launcherWarnings(h,n.by),se=oe.find(e=>e.kind===`launch-pipes`),ce=se?.event??null,le=[...Jc(c.delivery()),...oe,...ae===null?[]:[{kind:`config-watch`,message:ae}],...v.lastWarning===null?[]:[{kind:`load`,message:v.lastWarning}],...w===null?[]:[{kind:`facts`,message:`the bar is drawn from the last facts that were read; the next could not be stamped: ${w}`}]],ue={config:y.config},de=_U(_,n.by,ie,[...D.offer,...O],[...D.failure,...le.map(e=>({about:e.kind,text:e.message,copy:e.message})),...l.ofSession(_,n.by,ue).map(e=>({about:`${e.kind}\0${e.message}`,text:e.message,copy:e.message}))]),fe=b.source.facts(),pe={diagnostics:DU(de),drawing:n,feeds:i.feedsOf(_,h),today:aZ(fe.builtins.today,h)},me=jo(S.metrics)?void 0:S.metrics;R3(g,tZ([...b.state.sources.keys()],fe)),R3(g,{prompts:String(me?.messageCount??`-`),nonPrompts:String(me?.nonPrompts??`-`),pr:PX(S.git),feeds:j3(pe.feeds)});let he=[],ge=jX(C,te),_e=d.of(_),ve=f.since(_,h),{frame:ye,evaluated:be,cellBreaks:xe,rules:Se}=O3(y.config,y.compiled,b.store,b.registry,pe,h,ge,{perSegmentSink:b.lastRenderCellsBySegment,onRenderWarning:e=>he.push(e)},{...C,effects:_e,idleSince:ve}),Ce=yU(de),we=new Map(de.map((e,t)=>[Ce[t],e.copy])),Te=()=>a.delivered(_,n.by,we);f.observe(_,h,ye.rows.some(e=>e.kind===`menu`),C.menuTimeout);let Ee=f.since(_,h);R3(g,{menuIdle:Ee===void 0?`-`:`${(h-Ee).toFixed(1)}s/${C.menuTimeout}s`});let De=l.drawn(_,n.by,ue,he),Oe={width:te,rows:kU(ee.termRows,n.by===`feed`?Zb.flatMap(e=>{let t=Xb[e].rows;return T[e]&&t!==null?[t]:[]}):[]),colorCompatibility:ye.depth},ke=OU(r.get(_,Bi),de),Ae=ke===null?ye:NP(ye,AU(de,ke,_,n.by,Oe)),je=u.gitProvider.getStats(),A=u.usageStore.getStats(),Me=_e.lastFrame(),Ne=Me.own.map(e=>`${e.placement}:${e.effect}@${e.t.toFixed(3)}`).join(`,`)||`-`,Pe=e=>e.map(e=>`${e.placement}@${e.t.toFixed(3)}`).join(`,`)||`-`,Fe=e=>{switch(e.kind){case`rule`:return`rule:${e.slot}`;case`refresh`:return`refresh:${e.variable}`;case`file-events`:return`${e.kind}:${e.state}`;case`load`:case`facts`:case`config-watch`:case`lifeline`:case`launch-pipes`:case`when`:return e.kind}},Ie=[...D.failure.map(()=>`update-failed`),...[...le,...he].map(Fe)].join(`,`)||`-`;return R3(g,{git:`${je.size}/${je.hits}h/${je.misses}m`,usage:`${A.size}/${A.hits}h/${A.misses}m`,effect:Me.effect,effectT:Me.t.toFixed(3),speed:`${Me.speed}x`,effectRows:`${Me.made}made/${Me.reused}reused`,effectOwn:Ne,fadeBasis:Me.basis,stateRev:String(Me.revision),fades:Pe(Me.fades),leaves:Pe(Me.leaves),motion:Ae.motion,evaluated:String(be),cellBreaks:String(xe),pending:Ae.pending.join(`,`)||`-`,rules:[...Se].map(([e,t])=>`${e}:${t}`).join(`,`)||`-`,err:ie.length>0?`Y`:`N`,clickError:E.kind===`none`?`-`:E.kind,pipeEvent:se?.hold??`-`,upd:String(D.offer.length),ask:String(O.length),warn:Ie,diag:String(de.length),warnRecord:De?`new`:`kept`,viewer:ke===null?`-`:`${ke.index}/${de.length}p${ke.page+1}`}),{drawn:{body:Ae,viewerOpen:ke!==null,diagnostics:de,geometry:Oe},evaluated:be,cellBreaks:xe,clickShown:ne,pipeShown:ce,delivered:Te,lanes:T}}function i6(e,t){let{sessionState:n}=e,r=t.sessionId,{client:i,...a}=t.hints,o=JSON.stringify(a);n.get(r,`client-hints`)!==o&&n.set(r,oq,o);let s=r0(t.requested);n.get(r,`render-origin`)!==s&&n.set(r,aq,s)}function a6(e,t,n){let{laneSetups:r,tmuxStatusLines:i}=e;r.noted(o6(e,t),n),i.observe(t.hookData.session_id,t.hints.tmux,n.tmuxStatus)}function o6(e,t){let{sessionState:n}=e,r=t.hookData.session_id;return{sessionId:r,hints:t.hints,origin:r1(t.requested,n,r),transcript:t.hookData.transcript_path,answered:ZP(t.hookData)}}function s6(e,t,n,r){let{frameFeeds:i,laneSetups:a,tmuxStatusLines:o}=e,s=i.latest(t);a.clicked(t,s===null?null:o6(e,s),n,r),s!==null&&n.tmuxStatus!==r.tmuxStatus&&o.observe(t,s.hints.tmux,r.tmuxStatus)}async function c6(e,t,n,r,i){try{var a=No();let{clock:o,frameFeeds:s,log:c}=e,l=a.u(e6(e,t,n,i));a6(e,t,bK(l.view.source.effective(),Nc(t.hints.tmux)));let u=o.monotonic(),d=r-u;R3(i,{deadline:`${t.deadline.kind}:${Math.round(d)}ms`});let f=new Map,p=await yj(t=>Promise.all([XX(l.payloadInputs,n,f,()=>e.worldStates.of(l.sessionId),t),l.view.registry.inFlight(t)]),d,e=>c(`error`,`render wait failed after its deadline sid=${JSON.stringify(l.sessionId)}: ${x(e)}`),o.after),m=o.monotonic();R3(i,{waited:`${Math.round(m-u)}ms`,ended:p,refreshed:HX(f)});let{drawn:h,clickShown:g,pipeShown:_,delivered:v,lanes:y}=r6(e,l,$b),b=t.sessionId,S=I3(y,s.following(b)),C=QP(t.hints.client??null)===`statusline`,w=C?u6(b,h,S):h.body;return R3(i,{handoff:(C?S:[]).join(`,`)||`-`,drew:`${Fe(o,m)}ms`}),{frame:w,delivered:l6(e,b,v,g,_)}}catch(e){a.e=e}finally{a.d()}}function l6(e,t,n,r,i){return()=>{n(),r!==null&&Cc(e.sessionState,t,r),i!==null&&e.launcher.answeredPipeEvent(i)}}function u6(e,t,n){let[r,...i]=n;return r===void 0||t.viewerOpen?t.body:NP(t.body,jU(L3(e,[r,...i]),t.diagnostics,e,t.geometry))}const d6=e=>{};function f6(e,t,n=``){let r=U3(t);return{outcome:{kind:`threw`,error:t},resp:{...r,error:`renderer ${e.name}: ${n}${r.error}`},seen:`failed`,settled:d6}}function p6(e){let t=e.hookData.workspace?.current_dir??e.cwd;return{...e,hookData:{...e.hookData,...t!==void 0&&E.isAbsolute(t)&&{location:zH(t)}}}}function m6(e,t){e.push(...t.kind===`answered`?t.output.record:t.record)}async function h6(e,t,n,r,i,a,o,s){let c=p6(r),l=(t,r)=>void e.deliver({kind:`event`,at:Ue(n),event:{kind:`effect-done`,of:t.id,outcome:r===null?{kind:`ok`}:{kind:`failed`,reason:r}}},[[`sid`,c.sessionId],[`effect`,String(t.id)]]),u=await e.answer({kind:`event`,at:a,event:{kind:`config`,context:c,worldState:t.requested(c)}});if(m6(s,u),u.kind===`threw`)return R3(s,{renderer:e.name}),f6(e,u.error,`its config turn: `);let d=await e.answer({kind:`event`,at:a,event:{kind:`request`,id:i,context:c,waitEndsAt:o}});if(m6(s,d),d.kind===`threw`)return R3(s,{renderer:e.name}),f6(e,d.error);let{effects:f}=d.output;R3(s,{renderer:e.name,effects:f.map(e=>`${e.kind}:${e.surface}`).join(`,`)||`-`});let p=null;for(let e of f)switch(e.kind){case`present`:e.request===i?p===null?p=e:l(e,`a second statusline frame for request ${i}`):l(e,`presents request ${e.request}, not this turn's ${i}`);break}if(p===null)return f6(e,Error(`presented no statusline frame for request ${i}`));let m=p,h=n.monotonic(),g;try{g=W3[c.encoding](m.frame)}catch(t){return l(m,`encoding its frame threw: ${U3(t).error}`),f6(e,t,`its frame could not be encoded: `)}return R3(s,{encoded:`${Fe(n,h)}ms`}),{outcome:{kind:`ok`},resp:g,seen:m.frame.motion,settled:e=>l(m,e?null:`the client did not take the answer`)}}const g6=new Set([`hook_event_name`,`session_id`,`session_name`,`transcript_path`,`cwd`,`model`,`workspace`,`version`,`output_style`,`cost`,`context_window`,`exceeds_200k_tokens`,`effort`,`thinking`,`rate_limits`,`vim`,`agent`,`worktree`]),_6=[[`session_id`,`string`],[`transcript_path`,`string`],[`cwd`,`string`],[`model`,`object`],[`model.id`,`string`],[`model.display_name`,`string`],[`workspace`,`object`],[`workspace.current_dir`,`string`],[`workspace.project_dir`,`string`]],v6=[[`workspace.added_dirs`,`string-list`]];function y6(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of _6){let i=S6(n,e);if(i==null)t.missingRequired.push(e);else{let n=b6(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of v6){let i=S6(n,e),a=i===void 0?r:x6(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))g6.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function b6(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function x6(e){return Array.isArray(e)&&e.every(e=>b6(e)===`string`)?`string-list`:b6(e)}function S6(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=n[e]}return n}function C6(e,t,n){let{tokens:r}=S({args:e.slice(1),options:{config:{type:`string`}},strict:!1,tokens:!0,allowPositionals:!0}),i=(r??[]).filter(e=>e.kind===`option`&&e.name===`config`).at(-1),a=(r??[]).flatMap(e=>{switch(e.kind){case`option`:return e.name===`config`?e===i&&e.value===void 0?[{arg:e.rawName,why:`no-value`}]:[]:[{arg:e.rawName,why:`unknown`}];case`positional`:return[{arg:e.value,why:`positional`}];case`option-terminator`:return[]}});return{configFile:cP(t,i?.value,n),refusedArgs:a.filter((e,t)=>a.findIndex(t=>t.arg===e.arg&&t.why===e.why)===t)}}function w6(e){if(e===void 0)return{ok:!0,encoding:`ansi`};let t=Ln.find(t=>t===e);return t===void 0?{ok:!1,problem:`request 'encoding' is not one of ${Ln.join(`, `)}: ${JSON.stringify(e)}`}:{ok:!0,encoding:t}}function T6(e,t,n,r){let{report:i}=y6(e.hookData),a=[];for(let e of i.missingRequired)a.push(`missing required field '${e}'`);for(let{path:e,expected:t,got:n}of i.typeMismatches)a.push(`field '${e}' expected ${t}, got ${n}`);let o=P$(e.hookData?.session_id);o.ok||a.push(`field 'session_id' ${o.problem}`),(typeof e.cwd!=`string`||!O(e.cwd))&&a.push(`request 'cwd' is not an absolute path: ${JSON.stringify(e.cwd)}`),(!Array.isArray(e.args)||!e.args.every(e=>typeof e==`string`))&&a.push(`request 'args' is not a list of strings: ${JSON.stringify(e.args)}`);let s=w6(e.encoding);s.ok||a.push(s.problem);let c=pr(e.deadline);if(c.kind===`refused`)return{ok:!1,problems:[...a,c.problem]};if(a.length>0||!o.ok||!s.ok)return{ok:!1,problems:a};for(let e of i.unknownTopLevelFields)t.firstSightOfUnknownHookField(e)&&n(`info`,`schema: unknown field ${JSON.stringify(e)} — Anthropic may have added it`);let l=zn(e),{configFile:u,refusedArgs:d}=C6(e.args,e.cwd,r);return{ok:!0,req:{...e,deadline:c,encoding:s.encoding,sessionId:o.id,hints:l,rateLimits:Dte(e.hookData),requested:{projectDir:e.hookData.workspace.project_dir,cwd:e.cwd,target:dP(u,l.configEnv)},refusedArgs:d}}}function E6(e,t){switch(e){case`vars`:return{what:e,vars:D6(t)};case`segments`:return{what:e,segments:M6(t)};case`config`:return{what:e,config:I6(t)}}}function D6(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=A6(r),a=t.names().sort(),o=[];for(let e of a){let r=t.getNode(e),a=O6(r),s=n.getLastError(e);o.push({name:e,source:i.get(e)??null,...a,lastError:s===void 0?null:{timestampMs:s.timestamp,message:s.message},ageMs:k6(r.lastUpdatedMs(),t.clock)})}return o}function O6(e){if(e.kind===`projection`)return{type:e.type,value:`(read at each frame's instant)`};if(e.kind!==`document`)try{return{type:e.type,value:e.read()}}catch(t){return{type:e.type,value:t instanceof Error?t.message:String(t)}}let t=e.read();switch(t.kind){case`ok`:return{type:`document`,value:JSON.stringify(t.value)};case`pending`:return{type:`document`,value:`(not yet scanned)`};case`absent`:return{type:`document`,value:`(nothing to read, and no default)`};case`failed`:return{type:`document`,value:t.reason}}}function k6(e,t){return e===null?null:Math.max(0,t.now()-e)}function A6(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,j6(r));for(let[n,r]of Object.entries(e.segments))if(r.vars)for(let[e,i]of Object.entries(r.vars))t.set(`${n}.${e}`,j6(i));return t}function j6(e){return e.kind}function M6(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=P6(n),o=N6(n),s=[];for(let e of a){let t=n.segments[e];t&&s.push({name:e,description:t.description??null,template:t.template,referencedVars:F6(t.template,n.helpers,i),placements:(o.get(e)??[]).map(e=>({id:e,lastRender:r.get(e)??null}))})}return s}function N6(e){let t=new Map;for(let n of lS(e.presets))for(let r of Ny(fS(e,n).node)){if(r.kind!==`segment`)continue;let e=t.get(r.name)??[],n=ky(r);e.includes(n)||t.set(r.name,[...e,n])}return t}function P6(e){let t=[],n=new Set;for(let r of Ny(Qx(e.root)))r.kind===`segment`&&e.segments[r.name]&&!n.has(r.name)&&(t.push(r.name),n.add(r.name));for(let r of Object.keys(e.segments))n.has(r)||(t.push(r),n.add(r));return t}function F6(e,t,n){let r=new Set([...XS(e,t).keys()].flatMap(e=>fC(e,n)));return Array.from(r).sort()}function I6(e){return e===null?null:e.config}const L6=[`vars`,`segments`,`config`];function R6(e){return typeof e==`string`&&L6.includes(e)}const z6=e=>({resp:e,exitAfterFlush:null,settled:d6}),B6=e=>({kind:`reply`,...e}),V6={render:!0,"pane-session":!0,shutdown:!0,stats:!0,click:!0,debug:!0},H6=(e,t)=>B6(z6({ok:!1,error:t,code:e,daemonV:3}));function U6(e){let t=P$(e.sessionId);if(!t.ok)return H6(`BAD_REQUEST`,`subscribe's sessionId ${t.problem}`);if(e.lane===void 0)return H6(`VERSION_MISMATCH`,`this client's subscribe names no lane (${Zb.join(`, `)}): it predates the lane toggles — update it`);let n=ax(e.lane);return n===null?H6(`BAD_REQUEST`,`subscribe needs a lane, one of ${Zb.join(`, `)}: got ${JSON.stringify(e.lane)}`):{kind:`subscribe`,sessionId:t.id,lane:n}}async function W6(e,t,n,r,i){if(t.kind===`url`)return B6(z6(await Q6(e,t.frame,n,r,i)));let a=t.req;return!a||typeof a!=`object`||typeof a.v!=`number`?H6(`BAD_REQUEST`,`malformed request`):a.v===3?a.kind===`subscribe`?U6(a):typeof a.kind!=`string`||!Object.hasOwn(V6,a.kind)?H6(`BAD_REQUEST`,`unknown kind`):B6(await G6(e,a,n,r,i)):(a.v>3?e.log(`info`,`version mismatch: client=${a.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):e.log(`info`,`version mismatch: client=${a.v} < daemon=3; client is stale — staying up`),{kind:`reply`,resp:{ok:!1,error:`protocol v${a.v} not supported (daemon at v3)`,code:`VERSION_MISMATCH`,daemonV:3},exitAfterFlush:a.v>3?0:null,settled:d6})}async function G6(e,t,n,r,i){let{stats:a,clock:o,frameFeeds:s,renderCache:c,payloadProviders:{gitProvider:l,usageStore:u},fileEvents:d,runs:f,sourceRuns:p,effectSessions:m,menuIdle:h,journalTurns:g,sessionState:_,tmuxStatusLines:v,watcherRegistry:y,limits:b,handlerProbes:S,renderSightings:C,bundle:w,sourceDigest:T,doctorStores:ee}=e;if(t.kind===`shutdown`)return{resp:{ok:!0,output:``},exitAfterFlush:0,settled:d6};if(t.kind===`pane-session`){let{socket:e,pane:n}=t;return z6(typeof e!=`string`||typeof n!=`string`?{ok:!1,error:`pane-session needs a string socket and pane`,code:`BAD_REQUEST`,daemonV:3}:{ok:!0,paneSession:s.newestWhere(({hints:{tmux:t}})=>t!=null&&t.socket===e&&t.pane===n)})}if(t.kind===`stats`)return z6({ok:!0,stats:a.snapshot({gitCache:l.getStats(),usageCache:u.getStats(),sources:K6(e),fileEvents:d.stats(),sourceRuns:p.stats(),runs:f.stats(),transcriptReads:Vo(),renderCache:c.stats,collector:e.collector.stats(),effectCache:m.getStats(),menuIdle:h.getStats(),journalTurns:g.getStats(),sessionState:{sessions:_.size(),observers:_.observers(),revision:_.latestRevision()},frameFeeds:s.getStats(),tmuxStatus:v.stats(),watchersActive:y.size(),dirWatchesActive:y.dirWatches(),nextRestartReason:b.describeNextRestart(),handlerProbes:S.list(),clients:C.list(Ve(new Date(o.now()))),bundle:w,sourceDigest:T,daemon:b.serving(),doctorStores:pQ(ee)})});if(t.kind===`render`){let c=new Date(o.now()),l=Ve(c),u=o.monotonic(),d=Pe(r,u),f=[],p=++a.requestsTotal,m=T6(t,a,e.log,e.home),h=(t,n)=>C.see(t.sessionId,{client:t.hints.client??null,termCols:t.hints.termCols??null,rateLimits:t.rateLimits,claudeConfigDir:Zo(t.hints.claudeConfigDir,e.home),projectDir:t.requested.projectDir,transcript:Ote(t.hookData),frame:n},l,p);m.ok&&(h(m.req,`drawing`),s.note(m.req.sessionId,m.req,p));let g=t=>{t.outcome.kind!==`ok`&&a.requestsErrored++,R3(f,{timedOut:n()?`Y`:`N`,clientLeft:i()?`Y`:`N`,queued:`${d}ms`});let{level:r,line:s}=V3(`render`,f,t.outcome,Fe(o,u));return e.log(r,s),{resp:t.resp,exitAfterFlush:null,settled:t.settled}};if(!m.ok)return g(i8(m.problems));let _=await h6(e.renderer,e.collector,o,m.req,p,l,u+mr(m.req.deadline,r,{epochMs:c.getTime(),monoMs:u}),f).catch(e=>({outcome:{kind:`threw`,error:e},resp:U3(e),seen:`failed`,settled:d6}));try{return h(m.req,_.seen),g(_)}catch(e){throw _.settled(!1),e}}if(t.kind===`click`)return z6(await X6(e,r,n,i,(n,r)=>Z6(e,t,n,r)));if(t.kind===`debug`){if(!R6(t.what))return z6({ok:!1,error:`unknown debug 'what': ${String(t.what)} (have: ${L6.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let e=c.latestView(),n=e===null?null:{store:e.store,registry:e.registry,config:e.state.config,compiled:e.state.compiled,lastRenderBySegment:t.what===`segments`?Y6(e.lastRenderCellsBySegment,e.state.config.globals.colorCompatibility??kx(`colorCompatibility`)):J6};return z6({ok:!0,debug:E6(t.what,n)})}throw Error(`no reply for request ${x(t)}`)}function K6(e){let{payloadProviders:{gitProvider:t,tmuxService:n,usageStore:r,managedStorage:i,hostService:a},renderCache:o,refreshLedger:s}=e,c=t.getStats(),l=n.getStats(),u=r.scanStats(),d=i.stats(),f=o.stats;return{records:s.snapshot(),homes:{daemon:1,configDir:u.entries,repo:c.size,directory:f.size,session:r.getStats().size,view:f.views,pane:l.entries},held:{git:c.held,tmux:l.held,host:a.held(),today:u.held,pluginStorage:d.held},pluginStorage:{folders:d.folders,faults:d.faults,lost:d.lost}}}const q6={endcaps:kx(`endcaps`),colorCompatibility:kx(`colorCompatibility`),wrap:kx(`autoWrap`),padding:kx(`padding`),width:1/0},J6=new Map;function Y6(e,t){let n=new Map;for(let[r,i]of e)n.set(r,Cte(i,{...q6,colorCompatibility:t}));return n}async function X6(e,t,n,r,i){let{clock:a}=e,o=a.monotonic(),s=[[`queued`,`${Pe(t,o)}ms`]],c=await i(s,()=>n()||r());R3(s,{timedOut:n()?`Y`:`N`,clientLeft:r()?`Y`:`N`});let{level:l,line:u}=V3(`click`,s,c,Fe(a,o));return e.log(l,u),n8(c)}async function Z6(e,t,n,r){let i={via:`link`,delivery:{kind:`cli`}};R3(n,{via:`cli`});let{verb:a,value:o}=t;return typeof a!=`string`||typeof o!=`string`?{kind:`bad-request`,problems:[`a click's verb and value are strings, got ${typeof a} and ${typeof o}`]}:$6(()=>t8(e,a,o,i,n,r))}async function Q6(e,t,n,r,i){return X6(e,r,n,i,async(n,r)=>{let{urlV:i,url:a}=t;if(R3(n,{via:`forwarder`,urlV:String(i)}),typeof i!=`number`||!Xn.has(i))return{kind:`bad-request`,problems:[`the URL handler's frame version ${x(i)} is not one this daemon speaks (${[...Xn].join(`, `)})`]};if(typeof a!=`string`)return{kind:`bad-request`,problems:[`the URL handler's frame carries no url string`]};let o=Ma(a);if(!o.ok)return{kind:`bad-request`,problems:[o.problem]};let s={via:`link`,delivery:{kind:`forwarder`,urlV:i}};return $6(()=>t8(e,o.verb,o.value,s,n,r))})}async function $6(e){try{return await e()}catch(e){return e instanceof Z?{kind:`bad-request`,problems:[e.message]}:e instanceof cq?{kind:`closing`,error:e}:e instanceof lq?{kind:`abandoned`,error:e}:{kind:`threw`,error:e}}}const e8={link:`verb`,"tmux-status":`linkVerb`};async function t8(e,t,n,r,i,a){if(t===`tmux-status-click`)return R3(i,{verb:t}),r8(e,n,i,a);R3(i,{[e8[r.via]]:t});let o=K1(t,n);o===null?R3(i,{sid:`-`}):o.ok&&R3(i,{sid:o.id});let s=o?.ok?e.collector.holding(o.id):()=>{};try{let s=await e.renderer.answer({kind:`event`,at:Ue(e.clock),event:{kind:`click`,verb:t,value:n,session:o,arrival:r,gone:a}});switch(s.kind){case`answered`:return i.push(...s.output.record),{kind:`ok`};case`threw`:throw i.push(...s.record),s.error}}finally{s()}}function n8(e){switch(e.kind){case`ok`:return{ok:!0,output:``};case`bad-request`:return{ok:!1,error:e.problems.join(`; `),code:`BAD_REQUEST`,daemonV:3};case`threw`:case`closing`:case`abandoned`:return U3(e.error)}}async function r8(e,n,r,i){let{tmuxStatusLines:a}=e,o=e=>({kind:`bad-request`,problems:[e]}),s=a.linkAt(n);if(s.kind===`refused`)return o(s.reason);if(R3(r,{link:s.url}),s.url.startsWith(`cc-candybar://`)){let t=Ma(s.url);return t.ok?t.verb===`tmux-status-click`?o(`a status-line link names another status-line click`):t8(e,t.verb,t.value,{via:`tmux-status`},r,i):o(t.problem)}return await H$(e.launcher,{bin:t.platform===`darwin`?`/usr/bin/open`:`xdg-open`,args:[s.url],category:`click.open`},`opening ${s.url}`,e.log,z$,e.tmp),{kind:`ok`}}const i8=e=>({outcome:{kind:`bad-request`,problems:e},resp:{ok:!1,error:`malformed hookData: ${e.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3},settled:d6});function a8(e,t){let n=ae(`sha256`).update(t).digest(`hex`).slice(0,16);return E.join(e,`update-act`,n)}const o8={kind:`idle`};function s8(e){if(e===null)return o8;let{act:t,record:n,alive:r,end:i,lastLine:a}=e;if(r)return{kind:`running`,act:t};if(i===null)return{kind:`failed`,act:t,identity:n.identity,reason:`lost: the act ended without a verdict`};if(i.kind===`exit`&&i.code===0)return{kind:`succeeded`,act:t};let o=i.kind===`timeout`?`timeout`:`non-zero (exit ${i.code}): ${a??`no output`}`;return{kind:`failed`,act:t,identity:n.identity,reason:o}}const c8=e=>({stdout:E.join(e,`stdout`),stderr:E.join(e,`stderr`),status:E.join(e,`status`)}),l8=e=>E.join(e,`record.json`);function u8(e){let t;try{t=s.readdirSync(e)}catch(e){if(e.code===`ENOENT`)return[];throw e}return t.filter(e=>/^\d+$/.test(e)).map(Number).sort((e,t)=>e-t)}function d8(e){let t=Jo(e,4096);switch(t.kind){case`absent`:return null;case`failed`:throw Error(`${e}: ${t.reason}`);case`ok`:return t.value.buf.toString(`utf8`).split(/\r?\n/).map(e=>e.trim()).filter(e=>e!==``).at(-1)??null}}function f8(e,t){let n=E.join(e,`.removed-${t}-${process.pid}`);try{s.renameSync(E.join(e,String(t)),n)}catch(e){if(e.code===`ENOENT`)return;throw e}s.rmSync(n,{recursive:!0,force:!0})}const p8=e=>e.now()-o.uptime()*1e3;async function m8(e,t,n,r){if(e.started<=r||!n.jobGroupAlive(e.pid))return!1;let i=await t(e.pid);return e.startTime===null||i.kind===`unavailable`||i.token===e.startTime}function h8(e){try{return JSON.parse(s.readFileSync(l8(e),`utf8`))}catch(e){if(e.code===`ENOENT`)return null;throw e}}const g8=(e,t)=>e.pid===t.pid&&e.startTime===t.startTime;function _8(e,t,n,r){let i=null;async function a(a){let o=E.join(e,String(a)),c=h8(o);if(c===null)return null;if((i===null||!g8(i.record,c))&&(i={record:c,ours:await m8(c,t,n,p8(r)),final:null}),i.final!==null)return i.final;i.ours=i.ours&&n.jobGroupAlive(c.pid);let l=c8(o),u=kt(l.status),d=u===null?null:d8(l.stderr)??d8(l.stdout);if(!s.existsSync(o))return null;let f={act:a,record:c,alive:i.ours,end:u,lastLine:d};return f.alive||(i.final=f),f}return{async read(){let t=null;for(;;){let n=u8(e).at(-1);if(n===void 0)return null;if(n===t)throw Error(`${E.join(e,String(n))}: an act with no record`);let r=await a(n);if(r!==null)return r;t=n}}}}function v8(e,t,n){s.mkdirSync(e,{recursive:!0});let r=s.mkdtempSync(E.join(e,`.claim-`));try{return s.writeFileSync(l8(r),JSON.stringify(n)),s.renameSync(r,t),!0}catch(e){let t=e.code;if(t===`ENOTEMPTY`||t===`EEXIST`)return!1;throw e}finally{s.rmSync(r,{recursive:!0,force:!0})}}async function y8(e,t,n,r,i,a,o,s){let c=(n??0)+1,l=E.join(t,String(c)),u=e.launchJobSync(i,c8(l));if(!u.ok)throw Error(`apply-update: ${u.error}`);let d=!1;try{let e=await s(u.pid);if(!v8(t,l,{identity:r,pid:u.pid,startTime:e.kind===`start`?e.token:null,started:o,deadline:o+a}))return b8;if(u8(t).some(e=>e>c))return f8(t,c),b8;d=!0}finally{d?u.release():u.withdraw()}for(let e of u8(t).filter(e=>e<c))f8(t,e);return{ok:!0,act:c}}const b8={ok:!1,reason:`another act claimed this bundle first`};function x8(e,t,n){let r=c8(E.join(e,String(t.act))).status;return n.endJob(t.record.pid,r,{kind:`timeout`})}function S8(e,t,n){if(t.kind===`pending`)return Ao(t.why);if(e!==void 0&&e.kind!==`pending`){let{at:n,...r}=e;if((0,Y.compareStructural)(r,t))return e}return{...t,at:n}}var C8=class{waiting=new Map;run(e,t){return new Promise((n,r)=>{let i=async()=>{try{n(await t())}catch(e){r(e)}},a=this.waiting.get(e);if(a!==void 0){a.push(i);return}let o=[];this.waiting.set(e,o);let s=t=>void t().then(()=>{let t=o.shift();t===void 0?this.waiting.delete(e):s(t)});s(i)})}};function w8(e){return e.kind===`source`?e.newer.digest:ps(e.newer)}const T8=e=>`${e.version} [${en(e.digest)}]`;function E8(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:T8(e.newer),running:T8(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:ps(e.newer),running:ps(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${hs}@${ps(e.newer)}`,`install`]}}}}const D8={offer:[],failure:[]};function O8(e,t,n){if(e===null)return D8;let r=w8(e);if(!n.enabled||n.dismissed===r)return D8;let i=E8(e),a=`${i.headline}: ${i.newer}. You're on ${i.running}.`,o=t.kind===`failed`&&t.identity===r?[(e=>({about:`update-failed\0${r}`,text:e,copy:e}))(`${i.act} failed: ${t.reason}`)]:[],s=t.kind===`running`?gU(`[${i.busy}]`,null):gU(`[${i.act}]`,Ea([{verb:ca,args:[n.sessionId]}])),c=[gU(a,null),s,gU(`[dismiss]`,Ea([{verb:Wi,args:[n.sessionId,yz,r]}])),gU(`[disable]`,Ea([{verb:Xi,args:[n.sessionId,bz,`false`]},{verb:Wi,args:[n.sessionId,xz,`false`]}]))];return{offer:[{severity:fU,about:`update\0${r}`,message:a,copy:a,lines:[c]}],failure:o}}function k8(e,t){if(e.kind===`pending`)return e;let n=e.value;switch(n.kind){case`stale`:return F({kind:`source`,root:n.root,newer:n.source,running:n.running});case`current`:return I;case`unchecked`:return L(`build: unchecked: ${n.reason}`,`read`);case`not-source-checkout`:return A8(t)}}function A8(e){if(e.kind===`pending`)return e;let t=e.value;switch(t.kind){case`stale`:return F({kind:`release`,newer:t.latest,running:t.installed});case`current`:case`ahead`:return I;case`unchecked`:return L(`release: unchecked: ${t.reason}`,`read`)}}function j8(e){switch(e.kind){case`current`:return[`info`,`build: current ${T8(e.stamp)}`];case`stale`:return[`info`,`build: stale — source ${T8(e.source)}, running ${T8(e.running)}`];case`not-source-checkout`:return[`info`,`build: not a source checkout`];case`unchecked`:return[`warn`,`build: unchecked: ${e.reason}`]}}function M8(e){switch(e.kind){case`current`:return[`info`,`release: current ${ps(e.installed)}`];case`stale`:return[`info`,`release: stale — latest ${ps(e.latest)}, running ${ps(e.installed)}`];case`ahead`:return[`info`,`release: ahead — running ${ps(e.installed)}, latest ${ps(e.latest)}`];case`unchecked`:return[`warn`,`release: unchecked: ${e.reason}`]}}function N8(e){let{fact:t,clock:n,launcher:r,probe:i,entryUrl:a,digest:o,actsDir:s,intervalMs:c,releaseIntervalMs:l,registryUrl:u,fetchImpl:d,gates:f,onApplied:p,log:m}=e,h=Ao(`unread`),g=Ao(`unread`),_=async e=>{let t=await i.startTime(e);if(T)throw new cq(`apply-update`);return t},v=_8(s,_,r,n),y=null,b=null,x=Me(m),S=Me(m),C=new C8,w=e=>C.run(`acts`,e),T=!1,ee=[],te=(e,t)=>{ee.push(n.every(t,e,{unref:!0}))},E=()=>{let e=t.get();return e.kind===`ok`?e.value:null};function ne(){let e=E(),t=e===null?null:w8(e);(b===null?null:b.identity)!==t&&(b?.dispose(),b=t===null?null:{identity:t,dispose:f.state.register(yz,[t])})}function D(){let e=T?I:k8(h,g),r=S8(t.get(),e,Ue(n));(0,Y.runInAction)(()=>t.set(r)),ne()}function O(){let e=sn(a,()=>rn(o));return h=F(e),x(j8(e)),D(),e}async function re(){let e=_s(tn,await gs(hs,d,u,n));g=F(e),S(M8(e)),D()}let k=null,ie=Me(m);async function ae(e){try{let t=await e();return k=null,{ok:!0,value:t}}catch(e){return e instanceof cq?{ok:!1,error:e.message}:(k=`update act files (${s}): ${e.message}`,ie([`error`,k]),{ok:!1,error:k})}}function oe(e){if(!e?.alive||n.now()<=e.record.deadline)return;let{stands:t,signalled:i}=x8(s,e,r),a=t?`timed out`:`outlived its verdict`,o=i?`ending it`:`its group took no signal`;m(`error`,`apply-update: act ${e.act} ${a}; ${o}`)}async function se(){let e=await ae(async()=>{let e=await v.read();return T||oe(e),e});if(T||!e.ok)return;let t=s8(e.value);y===null&&t.kind===`running`&&m(`info`,`apply-update: act ${t.act} is running; watching it`),y?.kind===`running`&&t.kind!==`running`&&(t.kind===`succeeded`&&(m(`info`,`apply-update: act ${t.act} succeeded`),O(),p()),t.kind===`failed`&&m(`error`,`apply-update: act ${t.act} failed: ${t.reason}`)),y=t}let ce;async function le(){await w(se),!T&&(ce=n.after(2e3,()=>void le(),{unref:!0}))}return{arm(){let e=O();te(O,c),ee.push(()=>ce?.()),le(),e.kind===`not-source-checkout`&&(re(),te(()=>void re(),l))},close(){T=!0,D(),ee.forEach(e=>e())},notice:e=>O8(E(),y??o8,e),running:()=>w(async()=>{let e=await ae(()=>v.read());return e.ok&&s8(e.value).kind===`running`}),error:()=>k,act:()=>w(async()=>{if(T)throw new cq(`apply-update`);let e=await ae(()=>v.read());if(T)throw new cq(`apply-update`);if(!e.ok)throw new Z(`apply-update: ${e.error}`);let t=E();if(t===null)throw new Z(`apply-update: nothing newer is known to apply`);let i=E8(t),a=e.value;if(s8(a).kind===`running`)throw new Z(`apply-update: already ${i.busy}`);let o=await y8(r,s,a===null?null:a.act,w8(t),{...i.command,category:`update.apply`},6e5,n.now(),_);if(!o.ok)throw new Z(`apply-update: ${o.reason}`);m(`info`,`apply-update: act ${o.act}: ${i.act} — ${i.command.bin} ${i.command.args?.join(` `)??``}`),y={kind:`running`,act:o.act}})}}function P8(){return Y.observable.box(Ao(`unread`),{deep:!1})}function F8(e,t){try{return F(t(e).mtimeMs)}catch(e){let t=e.code;return t===`ENOENT`||t===`ENOTDIR`?I:L(e.message,`read`)}}function I8(e,t){return e.kind===`ok`&&t.kind===`ok`?e.value===t.value:e.kind===t.kind}function L8(e){let{targets:t,intervalMs:n,stat:r,held:i,exit:a,log:o,clock:s}=e,c=Me(o),l=t.map(e=>({path:e,stamp:F8(e,r)})),u=l.filter(({stamp:e})=>e.kind!==`failed`),d=null,f=!1,p=()=>{f=!0,d?.()},m=async()=>{if(!f)for(let{path:e,stamp:t}of u){let n=F8(e,r);if(n.kind===`failed`){o(`warn`,`binary stat failed (${e}): ${n.reason}`);continue}if(!I8(t,n)){let t=`binary ${n.kind===`absent`?`gone`:`changed`} (${e})`,r=await i();if(f)return;if(r){c([`info`,`${t}; the restart waits for the running update`]);return}o(`info`,`${t}; shutting down`),p(),a();return}}},h=()=>m().catch(e=>{o(`error`,`binary check failed: ${e.message}`)});return{arm(){for(let{path:e,stamp:t}of l)t.kind===`failed`&&o(`warn`,`binary stat failed at boot (${e}): ${t.reason}; not watched`);d=s.every(n,()=>void h(),{unref:!0})},checkNow:h,close:p}}var R8=class{running=new Map;again=new Set;run(e,t){return this.again.add(e),this.running.has(e)?{kind:`queued`}:{kind:`started`,done:this.start(e,t)}}share(e,t){let n=this.running.get(e);return n===void 0?(this.again.add(e),this.start(e,t)):n}start(e,t){let n=this.loop(e,t);return this.running.set(e,n),n}async loop(e,t){try{do this.again.delete(e),await t();while(this.again.has(e))}finally{this.running.delete(e),this.again.delete(e)}}clear(){this.running.clear(),this.again.clear()}get size(){return this.running.size}};const z8=`pass`,B8={okMs:5*6e4,failedMs:45e3},V8=B8.okMs;function H8({failures:e}){return dj(B8,e,V8)}function U8(e){return e.includes(`first`)?`first`:e.length===0?`period`:`change`}function W8(e){return`git:${e}`}function G8(e,t,n){let r=[{path:t,filenames:[`HEAD`,`index`]},{path:E.join(n,`refs`,`heads`),recursive:!0}],i=r.map(e=>Rc(e.path));return{key:`git:${e}:${r.map((e,t)=>`${e.path}@${zc(i[t])}`).join(`|`)}`,targets:{dirs:r},unbound:i.some(e=>typeof e==`string`||`unreadable`in e)}}function K8(e){return e.kind===`ok`?e.value.branch:void 0}function q8(e){e.missed=!0,gj(e,`unread`)}function J8(e,t){return e.missed&&e.reading.get().kind===`pending`&&hj(e,t.size>0?L([...t].join(`; `),`read`):I),`unkeyed`}function Y8({value:e,pr:t}){let n=vj(e);return n.kind===`ok`?F({...n.value,pullRequest:vj(t)}):n}const X8=L(`git cache closed`,`read`);function Z8(e){return t=>L(`${e} threw: ${String(t)}`,`read`)}var Q8=class{repos=new Map;resolutions=new Map;closed=!1;hits=0;misses=0;changes=0;gitRefreshes;prRefreshes;inner;periodMs;maxRepos;forgeLookups;watchers;ownsWatchers;logger;clock;constructor(e){this.inner=e.inner,this.clock=e.clock,this.periodMs=e.periodMs??3e4,this.maxRepos=e.maxRepos??64,this.forgeLookups=new Mo(e.maxPrLookups??2),this.logger=e.logger??Ne;let t=e.ledger??new Dj(this.logger);this.gitRefreshes=t.declare({name:`git`,scope:`repo`,refresh:[`first`,`period`,`change`]}),this.prRefreshes=t.declare({name:`pr`,scope:`repo`,refresh:[`first`,`period`]}),e.watchers?(this.watchers=e.watchers,this.ownsWatchers=!1):(this.watchers=new lj({clock:this.clock,logger:this.logger}),this.ownsWatchers=!0)}getWatcherRegistry(){return this.watchers}getStats(){let e=0;for(let t of this.repos.values())t.holders>0&&e++;return{size:this.repos.size,held:e,hits:this.hits,misses:this.misses,changes:this.changes,watchers:this.watchers.size()}}resolution(e,t){let n=`${e}|${t??``}`,r=this.clock.monotonic(),i=this.resolutions.get(n);if(i&&r-i.computedAt<3e4)return this.resolutions.delete(n),this.resolutions.set(n,i),i.known;let a;try{a=this.inner.resolveEffectiveGitDir(e,t)}catch(e){a=L(`resolver threw: ${String(e)}`,`read`)}for(this.resolutions.set(n,{known:a,computedAt:r}),a.kind===`failed`&&this.logger(`warn`,`git resolve failed (${e}): ${a.reason}`);this.resolutions.size>this.maxRepos;){let e=this.resolutions.keys().next().value;if(e===void 0)break;this.resolutions.delete(e)}return a}declare(e,t,n){let r=this.asked(e,t,n);if(r.kind===`settled`)return bj(r.outcome);let{state:i}=r;return i.value.reading.get().kind===`pending`?this.misses++:this.hits++,{current:()=>Y8(i)}}asked(e,t,n){if(this.closed)return{kind:`settled`,outcome:X8};let r=this.resolution(t,n);return r.kind===`ok`?{kind:`asked`,state:this.ask(r.value,e)}:{kind:`settled`,outcome:r}}changed(e){let t=this.repos.get(e);if(t){if(this.changes++,t.holders===0){t.value.missed=!0;return}this.changedPass(t,`watch`)}}touch(e){this.repos.get(e.root)===e&&(this.repos.delete(e.root),this.repos.set(e.root,e))}built(e){let t={period:new fj(()=>{this.readPr(n,t,`period`)},this.clock),seen:new Map,missed:!0,key:``,remote:I,reading:pj(),inFlight:null},n={root:e,refresh:new R8,watch:this.followWatch(e,null).watch,period:new fj(()=>{n.refresh.share(z8,()=>this.refreshPass(n))},this.clock),value:{reading:pj(),missed:!1},pr:t,holders:0,asked:new Set};return this.repos.set(e,n),n}followWatch(e,t){let n=this.inner.resolveGitDir(e),r=G8(e,n,this.inner.resolveCommonGitDir(n)),i=this.watchers.follow(t,r,()=>this.changed(e));return i.move===`rebound`&&this.logger(`info`,`git watch bound root=${e} dirs=${r.targets.dirs.map(e=>e.path).join(`,`)} deaf=${i.watch.handle.deaf.length}`),i}changedPass(e,t){e.asked.add(t),e.refresh.run(z8,()=>this.refreshPass(e))}async refreshPass(e){try{await this.pass(e)}catch(t){this.logger(`error`,`git refresh threw (${e.root}): ${String(t)}`)}finally{e.period.landed(this.periodMs)}}hold(e){return e.holders++,e.value.missed&&(q8(e.pr),e.asked.add(`resume`)),e.pr.missed&&e.pr.key!==``&&e.asked.add(`owed`),this.held(e),this.evict(),()=>{e.holders--,this.held(e)}}queue(e,t){e.asked.size>t&&e.refresh.run(z8,()=>this.refreshPass(e))}held(e){e.period.hold(e.holders>0),e.pr.period.hold(e.holders>0&&!e.pr.missed)}ask(e,t){let n=this.repos.get(e);n!==void 0&&this.touch(n);let r=n??this.built(e),i=r.asked.size;return n===void 0&&r.asked.add(`first`),t.take(W8(e),()=>this.hold(r)),this.queue(r,i),r}async pass(e){if(this.repos.get(e.root)!==e)return;let t=this.clock.monotonic(),n=[...e.asked];e.asked.clear();let r=this.followWatch(e.root,e.watch);e.watch=r.watch;let[i,a]=await Promise.all([this.inner.getGitInfo(e.root).catch(Z8(`git fetch`)),this.remoteOf(e)]);if(this.repos.get(e.root)!==e)return;let o=new Set;if(e.value.missed=!1,hj(e.value,i),i.kind===`failed`&&o.add(i.reason),i.kind===`ok`)for(let e of dY(i.value))o.add(e);let s=K8(i),c=s===void 0?J8(e.pr,o):this.movePr(e,s,a);this.held(e),this.gitRefreshes.recorded(`${e.root} asked=${n.join(`,`)||`-`} pr=${c} watch=${r.move}`,U8(n),o.size===0?F(null):L([...o].join(`; `),`read`),Fe(this.clock,t))}remoteOf(e){return this.inner.getRepoRemoteUrl(e.root).catch(Z8(`git remote`))}movePr(e,t,n){let{pr:r}=e,i=`${t}|${n.kind===`ok`?n.value:n.kind}`;if(i===r.key&&!r.missed)return`kept`;r.key=i,r.remote=n;let a=r.seen.get(i);return a===void 0?e.holders===0?(q8(r),`owed`):(gj(r,`unread`),r.missed=!1,this.readPr(e,r,`first`),`looked-up`):(r.seen.delete(i),r.seen.set(i,a),r.missed=!1,hj(r,a.outcome),r.period.landed(H8(a),a.at),`recalled`)}readPr(e,t,n){let r=t.key;if(t.inFlight?.key===r)return t.inFlight.done;let i=t.remote,a=this.clock.monotonic(),o=(i.kind===`ok`?this.forgeLookups.run(()=>(a=this.clock.monotonic(),this.inner.resolvePullRequest(e.root,i.value))).catch(Z8(`PR lookup`)):Promise.resolve(i.kind===`failed`?i:I)).then(i=>{if(t.inFlight?.key===r&&(t.inFlight=null),this.repos.get(e.root)!==e)return;this.prRefreshes.recorded(`${e.root} key=${R(r)}`,n,i,Fe(this.clock,a));let o=this.clock.monotonic(),s={outcome:i,at:o,failures:i.kind===`failed`?(t.seen.get(r)?.failures??0)+1:0};t.seen.delete(r),t.seen.set(r,s);for(let e of t.seen.keys()){if(t.seen.size<=16)break;t.seen.delete(e)}t.key!==r||t.missed||(hj(t,i),t.period.landed(H8(s),o))});return t.inFlight={key:r,done:o},o}drop(e){let t=L(`git state dropped: ${e.root}`,`read`);_j(e.value,t),_j(e.pr,t),this.repos.delete(e.root),e.refresh.clear(),e.watch.handle.release(),e.period.dispose(),e.pr.period.dispose()}evict(){for(let e of this.repos.values()){if(this.repos.size<=this.maxRepos)return;e.holders>0||(this.drop(e),this.logger(`info`,`gitCache evict ${e.root}`))}}close(){this.closed=!0;for(let e of this.repos.values())this.drop(e);this.repos.clear(),this.resolutions.clear(),this.ownsWatchers&&this.watchers.closeAll()}},$8=class{static usageDir(e){return E.join(e,`usage`)}static locksDir(e){return E.join(e,`locks`)}static isLocked(e,t){let n=E.join(this.locksDir(e),t);if(!s.existsSync(n))return!1;try{let e=s.readFileSync(n,`utf-8`),r=parseInt(e.trim(),10);if(isNaN(r))return A(`Invalid PID in lock file ${t}, removing stale lock`),s.unlinkSync(n),!1;try{return process.kill(r,0),!0}catch(e){return e.code===`ESRCH`?(A(`Removing stale lock file ${t} for dead process ${r}`),s.unlinkSync(n),!1):(A(`Error checking process ${r} for lock ${t}:`,e),!0)}}catch(e){return A(`Error reading lock file ${t}:`,e),!0}}static async acquireLock(e,t,n,r=5e3){await this.ensureCacheDirectories(e);let i=E.join(this.locksDir(e),n),a=t.monotonic(),o=String(process.pid);for(;t.monotonic()-a<r;)try{return await s.promises.writeFile(i,o,{flag:`wx`}),A(`Lock acquired for ${n}`),!0}catch(e){if(e.code===`EEXIST`)await Le(t,50);else throw e}return A(`Failed to acquire lock for ${n} within ${r}ms`),!1}static async releaseLock(e,t){let n=E.join(this.locksDir(e),t);try{await s.promises.unlink(n),A(`Lock released for ${t}`)}catch(e){e.code!==`ENOENT`&&A(`Error releasing lock for ${t}:`,e)}}static async ensureCacheDirectories(e){try{await Promise.all([s.promises.mkdir(e,{recursive:!0}),s.promises.mkdir(this.usageDir(e),{recursive:!0}),s.promises.mkdir(this.locksDir(e),{recursive:!0})])}catch(e){A(`Failed to create cache directories:`,e)}}static createProjectHash(e){return ae(`md5`).update(e).digest(`hex`).substring(0,8)}static async getUsageCache(e,t,n,r){await this.ensureCacheDirectories(e);let i=E.join(this.usageDir(e),`${n}.json`),a=`${n}.usage.lock`;for(let o=0;o<3;o++){if(this.isLocked(e,a)){A(`Cache for ${n} is locked, waiting...`),await Le(t,75);continue}try{let e=await s.promises.readFile(i,`utf-8`),t=JSON.parse(e);return!r||t.timestamp>=r?(A(`[CACHE-HIT] ${n} disk cache: found`),this.deserializeDates(t.data)):(A(`${n} cache outdated: cache=${t.timestamp}, latest=${r}`),null)}catch(e){if(e.code===`ENOENT`)return A(`No shared ${n} usage cache found`),null;A(`Attempt ${o+1} failed to read ${n} cache: ${e.message}. Retrying...`),await Le(t,75)}}return A(`Failed to read ${n} cache after 3 attempts.`),null}static deserializeDates(e){return Array.isArray(e)?e.map(e=>({...e,timestamp:new Date(e.timestamp)})):e}static async setUsageCache(e,t,n,r,i){let a=`${n}.usage.lock`;if(!await this.acquireLock(e,t,a)){A(`Could not acquire lock to set usage cache for ${n}`);return}try{await this.ensureCacheDirectories(e);let a=E.join(this.usageDir(e),`${n}.json`),o={data:r,timestamp:i||t.now()},c=JSON.stringify(o);await s.promises.writeFile(a,c,`utf-8`),A(`[CACHE-SET] ${n} disk cache stored`)}catch(e){A(`Failed to save ${n} usage cache:`,e)}finally{await this.releaseLock(e,a)}}};const e5={"claude-haiku-4-5-20251001":{name:`Claude Haiku 4.5`,input:1,output:5,cache_write_5m:1.25,cache_write_1h:2,cache_read:.1},"claude-haiku-4-5":{name:`Claude Haiku 4.5`,input:1,output:5,cache_write_5m:1.25,cache_write_1h:2,cache_read:.1},"claude-opus-4-20250514":{name:`Claude Opus 4`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-opus-4-1":{name:`Claude Opus 4.1`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-opus-4-1-20250805":{name:`Claude Opus 4.1`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-sonnet-4-20250514":{name:`Claude Sonnet 4`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-4-opus-20250514":{name:`Claude 4 Opus`,input:15,output:75,cache_write_5m:18.75,cache_write_1h:30,cache_read:1.5},"claude-4-sonnet-20250514":{name:`Claude 4 Sonnet`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-sonnet-4-5":{name:`Claude Sonnet 4.5`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-sonnet-4-5-20250929":{name:`Claude Sonnet 4.5`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3},"claude-opus-4-5":{name:`Claude Opus 4.5`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-5-20251101":{name:`Claude Opus 4.5`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-6":{name:`Claude Opus 4.6`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-opus-4-6-20260205":{name:`Claude Opus 4.6`,input:5,output:25,cache_write_5m:6.25,cache_write_1h:10,cache_read:.5},"claude-sonnet-4-6":{name:`Claude Sonnet 4.6`,input:3,output:15,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3}};var t5=class{static executionCache=null;static modelPricingCache=new Map;static GITHUB_PRICING_URL=`https://raw.githubusercontent.com/promptctl/cc-candybar/main/pricing.json`;static async loadDiskCache(e,t){let n=t.now()-1440*60*1e3;return await $8.getUsageCache(e,t,`pricing`,n)}static async saveDiskCache(e,t,n){await $8.setUsageCache(e,t,`pricing`,n)}static async fetchPricingData(){return new Promise(e=>{let t=new n(this.GITHUB_PRICING_URL),r=ge({hostname:t.hostname,path:t.pathname,headers:{"User-Agent":`cc-candybar`,"Cache-Control":`no-cache`},timeout:5e3},t=>{if(t.statusCode!==200){A(`HTTP ${t.statusCode}: ${t.statusMessage}`),e(null);return}let n=``,i=0;t.setEncoding(`utf8`),t.on(`data`,t=>{if(i+=Buffer.byteLength(t),i>1048576){A(`Response too large`),r.destroy(),e(null);return}n+=t}),t.on(`end`,()=>{try{let t=JSON.parse(n),r=t._meta,i={};for(let[e,n]of Object.entries(t))e!==`_meta`&&(i[e]=n);this.validatePricingData(i)?(A(`Fetched fresh pricing from GitHub for ${Object.keys(i).length} models`),A(`Pricing last updated: ${r?.updated||`unknown`}`),e(i)):(A(`Invalid pricing data structure`),e(null))}catch(t){A(`Failed to parse JSON:`,t),e(null)}}),t.on(`error`,t=>{A(`Response error:`,t),e(null)})});r.on(`error`,t=>{A(`Request error:`,t),e(null)}),r.on(`timeout`,()=>{A(`Request timeout`),r.destroy(),e(null)}),r.end()})}static async getCurrentPricing(e,t){if(this.executionCache!==null)return A(`[CACHE-HIT] Pricing execution cache: ${Object.keys(this.executionCache).length} models`),this.executionCache;let n=await this.loadDiskCache(e,t);if(n)return A(`[CACHE-HIT] Pricing disk cache: ${Object.keys(n).length} models`),this.executionCache=n,A(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(n).length} models`),n;let r=await this.fetchPricingData();return r?(await this.saveDiskCache(e,t,r),A(`[CACHE-SET] Pricing disk cache stored: ${Object.keys(r).length} models`),this.executionCache=r,A(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(r).length} models`),r):(A(`[CACHE-FALLBACK] Using offline pricing data: ${Object.keys(e5).length} models`),this.executionCache=e5,A(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(e5).length} models`),e5)}static validatePricingData(e){if(!e||typeof e!=`object`)return!1;for(let[,t]of Object.entries(e)){if(!t||typeof t!=`object`)return!1;let e=t;if(typeof e.input!=`number`||typeof e.output!=`number`||typeof e.cache_read!=`number`)return!1}return!0}static async getModelPricing(e,t,n){if(this.modelPricingCache.has(e))return A(`[CACHE-HIT] Model pricing cache: ${e}`),this.modelPricingCache.get(e);let r=await this.getCurrentPricing(t,n),i;return i=r[e]?r[e]:this.fuzzyMatchModel(e,r),this.modelPricingCache.set(e,i),A(`[CACHE-SET] Model pricing cache: ${e}`),i}static fuzzyMatchModel(e,t){let n=e.toLowerCase();for(let[e,r]of Object.entries(t))if(e.toLowerCase()===n)return r;for(let{pattern:e,fallback:r}of[{pattern:[`opus-4-6`,`claude-opus-4-6`],fallback:`claude-opus-4-6-20260205`},{pattern:[`opus-4-5`,`claude-opus-4-5`],fallback:`claude-opus-4-5-20251101`},{pattern:[`opus-4-1`,`claude-opus-4-1`],fallback:`claude-opus-4-1-20250805`},{pattern:[`opus-4`,`claude-opus-4`],fallback:`claude-opus-4-20250514`},{pattern:[`sonnet-4-6`,`sonnet-4.6`,`claude-sonnet-4-6`],fallback:`claude-sonnet-4-6`},{pattern:[`sonnet-4.5`,`4-5-sonnet`,`sonnet-4-5`],fallback:`claude-sonnet-4-5-20250929`},{pattern:[`sonnet-4`,`claude-sonnet-4`],fallback:`claude-sonnet-4-20250514`},{pattern:[`haiku-4.5`,`4-5-haiku`,`haiku-4-5`],fallback:`claude-haiku-4-5-20251001`},{pattern:[`haiku`],fallback:`claude-haiku-4-5-20251001`},{pattern:[`opus`],fallback:`claude-opus-4-20250514`},{pattern:[`sonnet`],fallback:`claude-sonnet-4-5-20250929`}])if(e.some(e=>n.includes(e))&&t[r])return t[r];return t[`claude-sonnet-4-5-20250929`]||{name:`${e} (Unknown Model)`,input:3,cache_write_5m:3.75,cache_write_1h:6,cache_read:.3,output:15}}static async calculateCostForEntry(e,t,n){let r=e.message?.usage;if(!r)return 0;let i=this.extractModelId(e),a=await this.getModelPricing(i,t,n),o=r.input_tokens||0,s=r.output_tokens||0,c=r.cache_creation_input_tokens||0,l=r.cache_read_input_tokens||0,u=o/1e6*a.input,d=s/1e6*a.output,f=l/1e6*a.cache_read,p=c/1e6*a.cache_write_5m;return u+d+p+f}static extractModelId(e){if(e.model&&typeof e.model==`string`)return e.model;let t=e.message;if(t?.model){let e=t.model;if(typeof e==`string`)return e;let n=e;return(typeof n?.id==`string`?n.id:null)||`claude-sonnet-4-5-20250929`}return e.model_id&&typeof e.model_id==`string`?e.model_id:`claude-sonnet-4-5-20250929`}},n5=class{inflight=new Map;run(e,t){return this.inflight.get(e)??this.start(e,t)}start(e,t){let n=t();this.inflight.set(e,n);let r=()=>{this.inflight.get(e)===n&&this.inflight.delete(e)};return n.then(r,r),n}get size(){return this.inflight.size}};function r5(e,t){let n=e?e.input+e.cacheCreation+e.cacheRead:0,r=e?e.output:0;return{input:n,output:r,total:n+r,atMs:t}}const i5={okMs:60*1e3,failedMs:10*1e3},a5={calculatedCost:null,tokens:null,tokenBreakdown:null};function o5(e){let t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-1),t.getTime()}function s5(){return{input:0,output:0,cacheCreation:0,cacheRead:0}}const c5={entries:0,cost:0,breakdown:s5(),days:new Map};async function l5(e,t,n,r){let i=UY(new Date(o5(r.now()))),a=e.entries,o=e.cost,s={...e.breakdown},c=new Map;for(let[t,n]of e.days)t>=i&&c.set(t,{...n});for(let e of t){let t=e.message?.usage;if(!t)continue;a++;let l=e.costUSD??await t5.calculateCostForEntry(e.raw,n,r);o+=l,s.input+=t.input_tokens||0,s.output+=t.output_tokens||0,s.cacheCreation+=t.cache_creation_input_tokens||0,s.cacheRead+=t.cache_read_input_tokens||0;let u=UY(new Date(e.timestamp));if(u<i)continue;let d=c.get(u)??{...VY};d.cost+=l,d.input+=t.input_tokens||0,d.output+=t.output_tokens||0,d.cacheCreation+=t.cache_creation_input_tokens||0,d.cacheRead+=t.cache_read_input_tokens||0,c.set(u,d)}return{entries:a,cost:o,breakdown:s,days:c}}function u5(e){let t=0,n=0,r=s5(),i=new Map;for(let{value:a}of e.values()){t+=a.entries,n+=a.cost,r.input+=a.breakdown.input,r.output+=a.breakdown.output,r.cacheCreation+=a.breakdown.cacheCreation,r.cacheRead+=a.breakdown.cacheRead;for(let[e,t]of a.days){let n=i.get(e)??{...VY};HY(n,t),i.set(e,n)}}if(t===0)return{usage:a5,days:i};let a=r.input+r.output+r.cacheCreation+r.cacheRead;return{usage:{calculatedCost:n,tokens:a,tokenBreakdown:r},days:i}}function d5(e,t){return e!==void 0&&t.some(t=>e.startsWith(t))}function f5(e,t){let n=new Map;for(let{record:r}of e)if(!(r===void 0||!d5(r.transcriptPath,t)))for(let[e,t]of r.days){let r=n.get(e)??{...VY};HY(r,t),n.set(e,r)}return Object.fromEntries(n)}async function p5(e,t,n){let r=0,i=async()=>{for(;r<e.length;){let t=e[r++];await n(t)}},a=Math.min(t,e.length);await Promise.all(Array.from({length:a},i))}function m5(e,t){(0,Y.runInAction)(()=>e.set(t))}var h5=class{sessions=Y.observable.map(void 0,{deep:!1});flight=new n5;scans;daySets=new Map;speedFlight=new n5;requestFlight=new n5;staleAgeMs;host;log;renderTally={hits:0,misses:0};ledger;usage;sweeps=0;stopSweep=null;closed=!1;clock;constructor(e){this.host=e.host,this.clock=e.clock,this.log=e.logger??Ne,this.ledger=e.ledger??new Dj(this.log),this.usage=this.ledger.declare({name:`usage`,scope:`session`,refresh:[`request`]}),this.staleAgeMs=e.staleAgeMs??864e5,this.scans=new Sj({name:`today`,scope:`configDir`,keyOf:e=>e.join(`\0`),fields:e=>`dirs=${R(e.join(`,`))}`,read:e=>this.scan(e),every:()=>e.rescan??i5,watch:xj,maxEntries:8,logger:this.log,ledger:this.ledger,clock:this.clock});let t=e.sweepIntervalMs??3e5;t>0&&(this.stopSweep=this.clock.every(t,()=>this.sweepStale(),{unref:!0}))}getStats(){return{size:this.sessions.size,hits:this.renderTally.hits,misses:this.renderTally.misses,sweeps:this.sweeps}}scanStats(){return this.scans.stats()}request(e,t){let n=null,r=()=>{if(n!==null)return n;let r=Po(t);return n={stamp:r,record:this.refreshed(e,t,r)},n};return{usage:async()=>{let e=await r().record;return e.kind===`failed`?e:F(e.kind===`ok`?e.value.usage:a5)},speed:t=>this.observed(e,r,t),today:async()=>{await r().record}}}usageOf(e){let t=this.sessions.get(e);if(t===void 0)return Ao(`unread`);let n=t.failure.get();return n===null?F(t.record?.usage??a5):L(n,`read`)}refreshed(e,t,n){return this.requestFlight.run(`${e}:${n}`,async()=>{let r={hits:0,misses:0},i=this.clock.monotonic(),a=await this.ingest(e,t,r,n);return this.renderTally.hits+=r.hits,this.renderTally.misses+=r.misses,r.misses>0&&this.usage.recorded(`sid=${R(e)}`,`request`,a,Fe(this.clock,i)),m5(this.hold(e).failure,a.kind===`failed`?a.reason:null),a})}refreshToday(e){return this.request(e?.session_id??``,e?.transcript_path).today()}declareToday(e,t){if(this.closed)return bj(L(`usage store closed`,`read`));let n=ZY(t,this.host.home),r=this.scans.declare(e,n),i=this.daySet(n);return{current:()=>{let e=r.current();return e.kind===`ok`?F({roots:i.roots,sums:i.sums.read()}):e}}}daysOutside(e,t){let n=this.sessions.get(e);if(n===void 0)return I;let r=n.failure.get();if(r!==null)return L(r,`read`);let i=n.record;return i===void 0||d5(i.transcriptPath,t)?I:F(Object.fromEntries(i.days))}observeSpeed(e,t,n){return this.request(e,t).speed(n)}async observed(e,t,n){if(!e)return I;let{stamp:r,record:i}=t();return this.speedFlight.run(`${e}:${r}`,async()=>{let t=await i;if(t.kind===`failed`)return m5(this.hold(e).speed,t),t;let r=r5(t.kind===`ok`?t.value.usage.tokenBreakdown:null,n),{ring:a}=this.hold(e),o;for(let e of a)e.atMs<r.atMs&&(o===void 0||e.atMs>o.atMs)&&(o=e);a.push(r),a.sort((e,t)=>e.atMs-t.atMs),a.length>64&&a.shift();let s=F({...o!==void 0&&{prev:o},cur:r,samples:[...a]});return m5(this.hold(e).speed,s),s})}speedOf(e){return e?this.sessions.get(e)?.speed.get()??Ao(`unread`):I}async ingest(e,t,n,r){if(!e)return I;let i=this.see(e)?.record;if(i&&r!==``&&i.transcriptStamp===r)return n.hits++,F(i);if(!t)return i?F(i):I;n.misses++;let a;try{a=await this.flight.run(`${e}:${r}`,async()=>{let n=this.sessions.get(e)?.record;return{prior:n,outcome:await this.refold(e,t,n)}})}catch(t){return L(`usage refold (${e}): ${t instanceof Error?t.message:String(t)}`,`read`)}let{prior:o,outcome:s}=a;if(s.kind!==`ok`)return s;let c={files:s.value.files,usage:s.value.usage,days:s.value.days,transcriptStamp:s.value.mainStamp,transcriptPath:t},l=this.sessions.get(e)?.record;return l===o?(this.stored(e,c),F(c)):l===void 0?F(c):this.ingest(e,t,n,r)}stored(e,t){let n=this.hold(e);(0,Y.runInAction)(()=>this.sessions.set(e,{...n,record:t}))}see(e){let t=this.sessions.get(e);return t&&(t.lastSeenAt=this.clock.now()),t}hold(e){let t=this.see(e);if(t)return t;let n={lastSeenAt:this.clock.now(),record:void 0,ring:[],failure:Y.observable.box(null),speed:Y.observable.box(void 0,{deep:!1})};return(0,Y.runInAction)(()=>this.sessions.set(e,n)),n}daySet(e){let t=e.join(`\0`),n=this.daySets.get(t);if(n!==void 0)return n;let r=e.map(e=>re(e,`projects`)+k),i={roots:r,sums:new OC(`today over ${e.join(`,`)}`,()=>f5(this.sessions.values(),r))};return this.daySets.set(t,i),i}async refold(e,t,n){let r=await eX(e,D(t),n===void 0?void 0:new Set(n.files.keys()));for(let e of lX(r.longLines))this.log(`info`,e);let i=new Map,a=``;for(let e of[t,...r.paths]){let r=n?.files.get(e),o=await uX(e,r,c5,(e,t)=>l5(e,t,un(this.host),this.clock));if(o.kind===`failed`)return o;if(o.kind===`absent`){r&&i.set(e,r);continue}let{folded:s,longLines:c}=o.value;for(let e of lX(c))this.log(`info`,e);i.set(e,s),e===t&&(a=s.cursor.stamp)}return F({files:i,...u5(i),mainStamp:a})}async scan(e){try{let t=o5(this.clock.now()),n=await QY(e),r=[];for(let e of n){let n=await $Y(Ro(e));for(let i of n??[]){if(!i.endsWith(`.jsonl`))continue;let n=re(e,i),a=await $Y(zo(n));a===void 0||a.mtimeMs<t||r.push({sessionId:i.slice(0,-6),path:n,stamp:Fo(a)})}}let i=[],a={hits:0,misses:0};return await p5(r,8,async e=>{let t=await this.ingest(e.sessionId,e.path,a,e.stamp);t.kind===`failed`&&(i.push(t.reason),this.log(`warn`,`usageStore scan: ${t.reason}`))}),this.log(`info`,`usageStore scan dirs=${R(e.join(`,`))} sessions=${r.length} read=${a.misses} failed=${i.length}`),i.length>0?L(`usage scan: ${i.length} of ${r.length} sessions could not be read — ${i[0]}`,`read`):F({sessions:r.length,read:a.misses})}catch(e){return L(`usage scan: ${e instanceof Error?e.message:String(e)}`,`read`)}}sweepStale(){let e=this.clock.now(),t=UY(new Date(e)),n=0,r=0,i=0;return(0,Y.runInAction)(()=>{for(let[a,{lastSeenAt:o,record:s}]of[...this.sessions])if(!(e-o<=this.staleAgeMs)){if(s?.days.has(t)){r++;continue}this.sessions.delete(a),n++,s===void 0&&i++}}),n>0&&this.sweeps++,(n>0||r>0)&&this.log(`info`,`usageStore sweep dropped=${n} noRecord=${i} held=${r}`),n}close(){this.closed=!0,this.stopSweep?.(),this.stopSweep=null,this.scans.close(),(0,Y.runInAction)(()=>{for(let{sums:e}of this.daySets.values())e.release();this.sessions.clear()}),this.daySets.clear()}};const g5={command:null,todos:[],pending:[],done:[]};function _5(e,t){let n=e.findIndex(e=>e.name===t);return n<0?[...e,{name:t,count:1}]:e.map((e,t)=>t===n?{name:e.name,count:e.count+1}:e)}function v5(e,t){switch(t.userEntry){case`prompt`:return{...e,command:t.activity?.command??null,pending:[],done:[]};case`interrupt`:return{...e,pending:[]};case`turn`:case`tool-result`:case`claude-code`:case void 0:return e}}function y5(e,t){if(t.isSidechain)return e;let n=v5(e,t),r=t.activity;if(r===void 0)return n;let i=n.pending,a=n.done;r.started!==void 0&&(i=[...i,...r.started]);for(let e of r.finished??[]){let t=i.findIndex(t=>t.id===e);t<0||(a=_5(a,i[t].name),i=[...i.slice(0,t),...i.slice(t+1)])}return{...n,pending:i,done:a,todos:r.todos??n.todos}}function b5(e){return{command:e.command,todos:e.todos,running:e.pending.reduce((e,t)=>_5(e,t.name),[]),done:e.done}}var x5=class{fold;constructor(e){let t=e.logger??Ne;this.fold=new fX(g5,y5,(e.ledger??new Dj(t)).declare({name:`activity`,scope:`session`,refresh:[`request`]}),e.clock,t)}async getActivityInfo(e,t){return S5(e,await this.fold.read(e,t.transcript_path))}activityOf(e){let t=this.fold.answer(e);return t.kind===`pending`?t:S5(e,t)}};function S5(e,t){return t.kind===`failed`?L(`activity (${e}): ${t.reason}`,t.failedAt):F(b5(t.value))}const C5=3e4;var w5=class{names;constructor(e){let t=e.logger??Ne;this.names=new Sj({name:`tmux`,scope:`pane`,keyOf:e=>`${e.socket}\n${e.pane}`,fields:e=>`pane=${R(e.pane)} socket=${R(e.socket)}`,read:t=>T5(e.launcher,t),every:()=>({okMs:C5,failedMs:C5}),watch:xj,maxEntries:64,logger:t,ledger:e.ledger??new Dj(t),clock:e.clock})}declare(e,t){return this.names.declare(e,t)}getStats(){return this.names.stats()}close(){this.names.close()}};async function T5(e,t){let n=await bc(e,t,`tmux`,[`display-message`,`-p`,`-t`,t.pane,`#S`]);if(n.kind!==`ok`)return L(n.reason,`read`);let r=n.stdout.trim();return r?F(r):I}const E5=6e4,D5={okMs:E5,failedMs:E5};function O5(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}function k5(e,t){try{let e=t();return Promise.resolve(e===``?I:F(e))}catch(t){return Promise.resolve(L(`host.${e}: ${String(t)}`,`read`))}}var A5=class{name;user;constructor(e){let t=e.logger??Ne,n={scope:`daemon`,keyOf:()=>``,fields:()=>`-`,every:()=>D5,watch:xj,maxEntries:1,logger:t,ledger:e.ledger??new Dj(t),clock:e.clock};this.name=new Sj({...n,name:`host.name`,read:()=>k5(`name`,()=>O5(o.hostname()))}),this.user=new Sj({...n,name:`host.user`,read:()=>k5(`user`,()=>o.userInfo().username)})}declareName(e){return this.name.declare(e,null)}declareUser(e){return this.user.declare(e,null)}held(){return this.name.stats().held+this.user.stats().held}close(){this.name.close(),this.user.close()}},j5=class{known=new dX(64);refreshes;constructor(e,t=Ne,n=new Dj(t)){this.clock=e,this.refreshes=n.declare({name:`autocompact`,scope:`configDir`,refresh:[`request`]})}window(e){let t=M5(e),n=this.known.get(e);if(n!==void 0&&n.stamp===t)return this.known.touch(e),n.outcome;let r=this.clock.monotonic(),i=vI(e);return this.refreshes.recorded(`path=${R(e)} stamp=${R(t)}`,`request`,i,Fe(this.clock,r)),this.known.set(e,{stamp:t,outcome:i}),i}stored(e){return this.known.get(e)?.outcome??Ao(`unread`)}getStats(){let{refreshes:e,failures:t,abandoned:n,lastMs:r}=this.refreshes.record();return{entries:this.known.size,refreshes:e,failures:t,abandoned:n,lastMs:r}}};function M5(e){try{let t=s.statSync(e,{throwIfNoEntry:!1});return t===void 0?`absent`:Fo(t)}catch(e){return`unread:${e.code??`error`}`}}const N5=/"(?:cache_read_input_tokens|cache_creation_input_tokens)":[1-9]/;function P5(e){let t;try{t=JSON.parse(e)}catch{return null}let n=t.message?.usage;if(!((n?.cache_read_input_tokens??0)>0||(n?.cache_creation_input_tokens??0)>0))return null;let r=t.timestamp==null?NaN:Date.parse(t.timestamp);return Number.isNaN(r)?null:r}var F5=class{known=new dX(256);refreshes;constructor(e,t=Ne,n=new Dj(t)){this.clock=e,this.refreshes=n.declare({name:`cache`,scope:`session`,refresh:[`request`]})}async refresh(e,t){let n=Po(t),r=this.known.get(e);if(r!==void 0&&n!==``&&r.stamp===n&&r.outcome.kind!==`failed`)return this.known.touch(e),r.outcome;let i=await this.read(e,t,n);return this.known.set(e,{stamp:n,outcome:i}),i}expiryOf(e){return this.known.get(e)?.outcome??Ao(`unread`)}getStats(){let{refreshes:e,failures:t,abandoned:n,lastMs:r}=this.refreshes.record();return{entries:this.known.size,refreshes:e,failures:t,abandoned:n,lastMs:r}}async read(e,t,n){let r=this.clock.monotonic(),i=await I5(t);return this.refreshes.recorded(`sid=${R(e)} stamp=${R(n)}`,`request`,i,Fe(this.clock,r)),i}};async function I5(e){let t=await L5(e);return t.kind===`ok`?F(Math.floor((t.value+36e5)/1e3)):t}async function L5(e){for(let t of[65536,1048576]){let n=await qo(e,t);if(n.kind!==`ok`)return n;let r=R5(n.value.buf,n.value.fromStart);if(r!=null)return F(r);if(n.value.fromStart)return I}return I}function R5(e,t){let n=e.toString(`utf8`).split(`
484
+ `),r=+!t;for(let e=n.length-1;e>=r;e--){let t=n[e];if(!t||!N5.test(t))continue;let r=P5(t);if(r!=null)return r}return null}const z5=e=>GV(e),B5=e=>E.join(e.storage.folder,z5(e.sessionId)),V5=e=>JSON.stringify([e.folder,e.generation]),H5=(e,t)=>e.folder===t.folder&&e.generation===t.generation;var U5=class{sessions;folders=new Map;watched=new Map;faultCounts={unusable:0,refused:0,error:0};lost=0;watchers;logger;identityOf;fileEvents;clock;unsubscribe;constructor(e){this.watchers=e.watchers,this.logger=e.logger,this.identityOf=e.identityOf??Fc,this.fileEvents=e.fileEvents,this.clock=e.clock,this.unsubscribe=e.fileEvents.subscribe(e=>this.noticed(e)),this.sessions=new Sj({name:`plugin storage`,scope:`session`,keyOf:e=>JSON.stringify([e.storage.folder,e.storage.generation,e.sessionId]),fields:e=>`file=${R(B5(e))} generation=${e.storage.generation}`,read:e=>this.read(e),every:()=>null,watch:xj,maxEntries:256,logger:e.logger,ledger:e.ledger??new Dj(e.logger),clock:e.clock})}keyFor(e){let t=this.folders.get(e)??this.recorded(e),n=`gone`;t.unusable=null;try{s.mkdirSync(e,{recursive:!0}),n=this.identityOf(e)}catch(e){t.unusable=`could not be created or read: ${e.message}`}return(t.lost||t.identity!==null&&(n===`gone`||!Ic(n,t.identity)))&&(t.generation++,t.lost=!1,t.identity=n===`gone`?null:n,this.logger(`info`,`plugin storage generation folder=${R(e)} generation=${t.generation}`)),{folder:e,generation:t.generation}}watch(e){let t=this.watched.get(V5(e))??this.opened(e);t.holders++;let n=!1;return()=>{n||(n=!0,t.holders--,t.holders===0&&this.closed(t))}}declare(e,t,n){return this.sessions.declare(e,{storage:t,sessionId:n})}supersede(e,t){return this.sessions.supersede({storage:e,sessionId:t})}stats(){return{...this.sessions.stats(),folders:this.watched.size,faults:{...this.faultCounts},lost:this.lost}}close(){this.unsubscribe(),this.sessions.close();for(let e of[...this.watched.values()])this.closed(e)}recorded(e){let t={generation:0,identity:null,lost:!1,unusable:null};return this.folders.set(e,t),t}opened(e){let t=this.folders.get(e.folder);if(t===void 0)throw Error(`plugin storage: no key was asked for ${e.folder}`);let n=e.generation===t.generation?t.unusable:null,r=n===null?this.identityOf(e.folder):`gone`;e.generation===t.generation&&(t.identity=r===`gone`?null:r);let i={key:e,folder:t,identity:r,holders:0,handle:this.watchers.acquire(`plugin-storage:${V5(e)}`,{dirs:[{path:e.folder}]},e=>this.invalidated(i,e)),stopSweep:this.clock.every(864e5,()=>void this.sweep(e),{unref:!0}),health:{kind:`watching`}};this.watched.set(V5(e),i),n!==null&&this.faulted(i,`unusable`,n);for(let e of i.handle.deaf)this.faulted(i,`refused`,e.reason);return this.sweep(e),i}closed(e){let t=V5(e.key);this.watched.delete(t),e.health={kind:`closed`},e.stopSweep(),e.handle.release()}invalidated(e,t){let{key:n}=e,r=e=>H5(e.storage,n);switch(t.kind){case`unknown`:this.judged(e,()=>this.sessions.changed(r));return;case`changed`:{let{paths:i}=t;i.has(E.join(n.folder,E.basename(n.folder)))?this.judged(e,()=>this.sessions.changed(r)):this.sessions.changed(e=>r(e)&&i.has(B5(e)));return}case`failed`:this.judged(e,()=>this.faulted(e,`error`,t.reason));return}}judged(e,t){let{health:n}=e;if(n.kind!==`watching`)return;let{key:r,folder:i}=e,a;try{a=this.identityOf(r.folder)}catch(t){this.faulted(e,`error`,`stat failed: ${t.message}`);return}let o=e.identity;if(a!==`gone`&&o!==`gone`&&Ic(a,o)){t();return}e.health={kind:`lost`},r.generation===i.generation&&(i.lost=!0,this.lost++,this.logger(`info`,`plugin storage lost folder=${R(r.folder)} generation=${r.generation} now=${a===`gone`?`gone`:`replaced`}`),this.sessions.changed(e=>H5(e.storage,r)))}faulted(e,t,n){let{key:r,folder:i}=e;e.health.kind===`watching`&&(e.health={kind:`faulted`,reason:n},this.faultCounts[t]++,r.generation===i.generation&&(i.lost=!0),this.logger(`warn`,`plugin storage fault folder=${R(r.folder)} generation=${r.generation} cause=${t} reason=${JSON.stringify(n)}`),this.sessions.changed(e=>H5(e.storage,r)))}noticed(e){switch(e.kind){case`period`:for(let e of[...this.watched.values()])this.judged(e,()=>{});return;case`moved`:case`caught-up`:this.sessions.changed(()=>!0);return}}standing(e){let t=this.watched.get(V5(e));if(t===void 0)return null;let{health:n}=t;switch(n.kind){case`faulted`:return`cannot refresh: ${e.folder} ${n.reason}; reload the config or restart the daemon`;case`watching`:case`lost`:{let t=qc(this.fileEvents.delivery());return t===null?null:`cannot refresh: ${e.folder}: ${t}`}case`closed`:return null}}async read(e){let t=this.standing(e.storage);if(t!==null)return L(t,`read`);let n=B5(e),r;try{r=await s.promises.readFile(n,`utf8`)}catch(e){let t=e;return t.code===`ENOENT`?I:L(`${n}: ${t.message}`,`read`)}if(r.trim()===``)return I;let i=Fj(r);return i.kind===`failed`?L(`${n}: ${i.reason}`,i.failedAt):i}async sweep(e){let t=this.clock.monotonic(),n=this.clock.now()-2592e6,r=0,i=0,a=()=>`plugin storage sweep folder=${R(e.folder)} scanned=${r} removed=${i} took=${Fe(this.clock,t)}ms`;try{let t=await s.promises.readdir(e.folder,{withFileTypes:!0});for(let a of t){if(!a.isFile()||!a.name.endsWith(`.json`))continue;r++;let t=E.join(e.folder,a.name);try{let{mtimeMs:r}=await s.promises.stat(t),o=this.sessions.isHeld(t=>t.storage.folder===e.folder&&z5(t.sessionId)===a.name);if(r>=n||o)continue;await s.promises.unlink(t),i++}catch(e){if(e.code!==`ENOENT`)throw e}}this.logger(`info`,a())}catch(e){this.logger(`warn`,`${a()} outcome=failed reason=${JSON.stringify(e.message)}`)}}};function W5(e){let{launcher:t,clock:n,logger:r,ledger:i}=e;return{home:e.host.home,hostService:new A5({clock:n,logger:r,ledger:i}),gitProvider:new Q8({inner:new zY(t),watchers:e.watchers,clock:n,logger:r,ledger:i}),usageStore:new h5({host:e.host,clock:n,logger:r,ledger:i}),contextProvider:new mX({clock:n,logger:r,ledger:i}),metricsProvider:new wX({clock:n,logger:r,ledger:i}),activityProvider:new x5({clock:n,logger:r,ledger:i}),tmuxService:new w5({launcher:t,clock:n,logger:r,ledger:i}),autoCompact:new j5(n,r,i),cacheExpiry:new F5(n,r,i),managedStorage:new U5({watchers:e.watchers,fileEvents:e.fileEvents,clock:n,logger:r,ledger:i}),faults:new AX,log:e.logger,clock:n}}function*G5(e){yield*Object.entries(e.variables??{});for(let[t,n]of Object.entries(e.segments??{}))for(let[e,r]of Object.entries(n.vars??{}))yield[`${t}.${e}`,r]}function*une(e){for(let t of Object.values(e.segments)){for(let e of[t.template,t.bg,t.fg,t.when])e!==void 0&&(yield e);yield*Object.values(t.partials??{})}for(let t of lS(e.presets)){for(let n of Ny(fS(e,t).node))n.when!==void 0&&(yield n.when);let n=hS(e,t);for(let e of Xv){let t=n[e];Zv(t)&&(yield t)}}for(let[,t]of G5(e))for(let[,e]of Hy(t))yield e;for(let t of Object.values(e.actions))for(let[,e]of ES(t))yield e}function dne(e,t,n){let r=UW(t),i=new Set,a=new Set,o=new Set;for(let e of une(t)){for(let{reaches:t}of r.ofTemplate(e))for(let e of t)i.add(e);for(let{name:n}of eC(e,t.helpers))a.add(n);for(let n of oC(e,t.helpers))o.add(n)}for(let[,e]of G5(t))for(let{reaches:t}of r.ofVariable(e))for(let e of t)i.add(e);let s=new Set(a);for(let e of a){let n=t.actions[e];if(n!==void 0&&`do`in n)for(let e of n.do)s.add(e)}let c=new Set,l=new Set(n);for(let e of s){let n=t.actions[e];if(n!==void 0&&(`set`in n&&c.add(n.set),`insertSegment`in n&&l.add(n.insertSegment),`insertSegmentFrom`in n&&Array.isArray(n.insertSegmentFrom)))for(let e of n.insertSegmentFrom)l.add(e)}for(let e of lS(t.presets))for(let n of Ny(fS(t,e).node))n.kind===`segment`&&l.add(n.name);let u=(e,t)=>i.has(e)||t.kind===`state`&&c.has(t.key),d=e=>[...e].filter(e=>!Ii(e)),f=(e,t,n)=>d(t).filter(e=>!n(e)).map(t=>({kind:e,name:t})),p=new Map(G5(e));return[...f(`variable`,p.keys(),e=>u(e,p.get(e))),...f(`action`,Object.keys(e.actions??{}),e=>s.has(e)),...f(`helper`,Object.keys(e.helpers??{}),e=>o.has(e)),...f(`segment`,Object.keys(e.segments??{}),e=>l.has(e))]}function fne(e){return Math.floor(Math.max(e/4,e*Br-67108864))}const pne={keyFor:e=>({folder:e,generation:0}),watch:()=>()=>{}};function K5(e,{plugins:t,config:n,compiled:r},i){let{checkout:a,loaded:o,dropped:s,unreached:c}=t,l=a===null?`-`:`${a.git?`git`:`dir`}:${a.root}`,u=e=>{let t=e.name===void 0?void 0:n.variables[WV(AS(e))];return t?.kind===`file`?t.path:`none`},d=o.flatMap(e=>e.name===void 0?[]:[AS(e)]).flatMap(e=>Object.entries(n.variables).filter(([t])=>jS(e)(t)&&t!==WV(e))),f=d.filter(([,e])=>e.kind===`source`).length,p=d.length-f;return`config load ${pP(e,`<default>`)}: projections=${[...qW(n).keys()].join(`,`)||`-`} instantSegments=${y3(r).join(`,`)||`-`} instantTemplates=${r.instant.size} plugins loaded=${o.length} sources=${f} pluginVariables=${p} dropped=${s.length} unplaced=${c.length} checkout=${l} ms=${i}`+o.map(e=>` +${e.path} data=${u(e)}`).join(``)+s.map(e=>` -${e.path} (${e.reason})`).join(``)+c.map(e=>` ~${e.path} (${e.reason})`).join(``)}const mne=e=>{switch(e.kind){case`changed`:return[...e.paths].join(`,`);case`unknown`:return`unknown`;case`failed`:return`failed:${e.reason}`}},q5=e=>{switch(e.kind){case`open`:case`write`:case`doctor`:return e.kind;case`config-watch`:case`answers-watch`:return`${e.kind}:${mne(e.heard)}`;case`events-resumed`:return`${e.kind}:${new Date(e.since).toISOString()}`}};function hne(e,t,n){let r=e=>R(e.join(`,`)||`-`);return`config loaded projectDir=${R(e.projectDir)} cwd=${R(e.cwd)} cause=${R(q5(t))} state=${n} files=${R(pP(e.configLayers,`<bundled default>`))} awaiting=${r(e.repos.awaiting)} declined=${r(e.repos.declined)} unproven=${e.repos.unproven.length===0?`-`:JSON.stringify(e.repos.unproven)} error=${e.lastError===null?`none`:JSON.stringify(e.lastError)} warning=${e.lastWarning===null?`none`:JSON.stringify(e.lastWarning)}`}function gne(e,t){return`config disposed reason=${e.reason} released=${t} held=${e.held}`}function J5(e,t,n){return e+`\0`+t+`\0`+(n??``)}function _ne(e,t){return new Set(lS(e.presets).filter(n=>fS(e,n).path===`root`?t.root!==void 0:t.presets?.[n]?.root!==void 0))}function vne(e,t){let{loaded:n,dropped:r,unreached:i}=e.state.plugins,a=[...new Set([...e.state.plugins.roots,E.join(e.projectDir,wH)])];return nj({named:[...XH(t,e.projectDir,e.cwd,e.configFile),...a,...n.map(e=>e.path),...[...r,...i].map(e=>e.path),...new Set([...e.state.sources.values()].map(e=>e.folder))],whole:a})}function yne(e){return e.filter(Boolean).join(`
485
+ `)||null}const Y5=e=>e instanceof Error?e.message:String(e);function X5(e){return{loaded:e.loaded,dropped:e.dropped,reached:[...e.reached].sort(),rendering:[...e.rendering].sort(([e],[t])=>e.localeCompare(t))}}function bne(e){let{loaded:t,chain:n}=e;return Aj({cwd:e.cwd,chain:{layers:n.layers,home:n.home,repo:n.repo,locs:n.locs},loaded:{layers:t.layers.map(e=>({path:e.path,raw:e.raw,config:e.config,plugins:X5(e.plugins),source:null,warnings:null})),base:t.base,installed:{...X5(t.installed),checkout:t.installed.checkout,roots:t.installed.roots,unreached:t.installed.unreached},config:t.config,dropped:t.dropped.map(e=>e.message),placed:null},sources:[...e.sources].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,t.folder,t.generation])})}function xne(e,t){let n=new Map,r=new Map;for(let[i,a]of Object.entries(e.variables)){if(a.kind!==`source`)continue;let e=n.get(a.storage)??t.keyFor(a.storage);n.set(a.storage,e),r.set(i,e)}return r}function Z5(e,t,n){let r=[];try{let i=HG(t.locs,t.layers,mK,{warned:e=>r.push(...e)},{repo:t.repo,cwd:e}),a={cwd:e,chain:t,loaded:i,sources:xne(i.config,n)};return{kind:`resolved`,...a,key:bne(a),warnings:r}}catch(e){return e instanceof ab&&r.push(...e.warnings),{kind:`failed`,cause:e,warnings:r}}}function Q5(e,t){let{cwd:n,chain:r,loaded:i}=e,{layers:a,config:o,installed:s,dropped:c}=i,l=a.at(-1)?.config??mK,u=a.find(e=>e.path===r.home)?.raw??{},d=a.flatMap(e=>(e.raw.insert??[]).map(e=>e.seg)),f=[],p=new RC(t.clock),m=new rM(t.runs,p,o.globals.default_empty_value??``,t.sessionState,null,t.env),h;try{h=p3(o,m,n,t.compile??f3(t.signer),Cne),f.push(...h.loadWarnings);let r=m.view();f.push(...g3(o,r,n,n7)),r.dispose(),t.gates.state.gateFor(o),t.gates.config.gateFor(o);for(let n of new Set(e.sources.values()))m.own(t.storage.watch(n))}catch(e){return m.dispose(),e instanceof ab&&f.push(...e.warnings),{kind:`failed`,cause:e,warnings:f}}return{kind:`built`,state:{config:o,dropped:c,compileKey:h.compileKey,loadKey:e.key,buildWarnings:f,store:p,registry:m,compiled:h.compiled,authoredRoots:_ne(l,u),fileHeldSettings:GK(u),configPath:r.layers.some(e=>e.path===r.home)?r.home:null,unused:[...new Map(a.flatMap(e=>dne(e.raw,i.placed,d)).map(e=>[`${e.kind}:${e.name}`,e])).values()],plugins:{checkout:s.checkout,roots:s.roots,loaded:[...s.rendering.values()],dropped:[...s.dropped,...a.flatMap(e=>e.plugins.dropped)],unreached:s.unreached,reached:s.reached,rendering:s.rendering},sources:e.sources}}}function $5(e,t,n,r,i){let a={layers:t.layers.map(e=>e.path),home:t.home,repos:e.repos,ms:Fe(i,e.started)},o=t=>yne([...e.advisories,...n,...t]);switch(r.kind){case`built`:case`kept`:return{...a,kind:r.kind,warning:o(r.state.buildWarnings),state:r.state,error:null};case`failed`:return{...a,kind:`failed`,warning:o(r.warnings),state:null,error:Y5(r.cause),cause:r.cause}}}function Sne(e,t,n,r,i=null){let a=Z5(t,n,r.storage);if(a.kind===`failed`)return $5(e,n,[],a,r.clock);let o=i?.loadKey===a.key?{kind:`kept`,state:i}:Q5(a,r);return $5(e,n,a.warnings,o,r.clock)}function e7(e,t,n,r,i=null){let a=r.clock.monotonic(),o=eU(r.locations,BU(r.stateDir).read(),e,t,n),{repos:s}=o,c={layers:o.kind===`chain`?o.layers:[],home:o.home,repo:s.plugins,locs:r.locations};return Sne({repos:s,advisories:[sU(r.locations,e,t),aU(o),qH(s)],started:a},t,c,r,i)}function t7(e,t,n){let r=Z5(e,{layers:[],home:``,repo:t,locs:n.locations},n.storage),i=r.kind===`failed`?r:Q5(r,n);if(i.kind===`failed`)throw Error(`bundled default failed to load: ${Y5(i.cause)}`,{cause:i.cause});return i.state}const Cne=new Set([`directory`]),n7=new Set([`view`]);function wne(e,t,n,{source:r,changed:i,log:a}){let{sessionId:o}=n,s=e.registry.view();g3(e.config,s,t,n7);let c=Y.observable.box(n,{deep:!1}),l;try{l=r({sessionId:o,state:e,store:s.variableStore,requested:()=>c.get()})}catch(e){throw s.dispose(),e}B4(e.compiled,s.variableStore,s,l);let u=(0,Y.reaction)(()=>[l.payload(),l.selections(),s.published(),e.registry.published()],()=>i(o),{equals:Y.compareShallow,fireImmediately:!0,onError:e=>a(`error`,`session view change threw sid=${JSON.stringify(o)}: ${String(e)}`)});return{sessionId:o,state:e,store:s.variableStore,registry:s,source:l,requested:e=>{e!==c.get()&&(0,Y.runInAction)(()=>c.set(e))},facts:()=>c.get(),lastRenderCellsBySegment:new Map,retire:u,dispose:()=>(u(),s.dispose())}}const Tne=({sources:e})=>[...e].map(([e,t])=>({kind:`plugin`,source:e,storage:t}));var Ene=class{entries=new Map;answersWatch;closed=!1;due=new Map;walk=null;holds=new Map;views=new Map;copies=new Map;viewHolds=new Map;pins=new Map;openFailures=new Map;compiles=new Map;deps;log;budgetBytes;maxEntries;observers;constructor(e,t){this.deps={...e,compile:(e,t)=>this.compileOf(e,t)},this.log=e.log??Ne,this.budgetBytes=t.budgetBytes,this.maxEntries=t.maxEntries??256,this.observers=t.observers??{},s.mkdirSync(RU(e.stateDir),{recursive:!0});let{dir:n,name:r}=ej(zU(e.stateDir));this.answersWatch=e.watchers.acquire(`repo-configs:${n}/${r}`,{dirs:[{path:n,filenames:[r]}]},e=>this.reloadEvery({kind:`answers-watch`,heard:e}))}compileOf(e,t){return this.compiles.get(e)??v3(t,this.deps.signer)}accountedBytes(){let e=new Set([...this.entries.values()].map(e=>e.state.compileKey));return this.entries.size*3145728+e.size*10485760+this.views.size*2621440}getOrCreate(e,t,n){let r=J5(e,t,n),i=this.entries.get(r);if(i)return this.entries.delete(r),this.entries.set(r,i),i;let a=this.load(e,t,n,null);a.state!==null&&this.log(`info`,K5(a.layers,a.state,a.ms));let o={projectDir:e,cwd:t,configFile:n,configLayers:[],configHome:``,repos:a.repos,lastError:a.error,lastWarning:a.warning,state:a.state??t7(t,a.repos.plugins,this.deps),watch:null};return this.serve(o.state),this.entries.set(r,o),this.fit(o),this.log(`info`,`render-cache entry projectDir=${e} cwd=${t} compile=${o.state.compileKey.slice(0,12)} entries=${this.entries.size} compiles=${this.compiles.size} accounted=${Fr(this.accountedBytes())}/${Fr(this.budgetBytes())}MB`),this.refreshWatcher(o,a),this.observers.onReload?.(o,[],{kind:`open`},a.kind),o}hold(e,t,n){let r=this.getOrCreate(e,t,n);return this.holdState(r,r.state)}holdState(e,t){let n=this.holdOf(t);n.holders++;let r=!1;return{entry:e,state:t,[Symbol.dispose]:()=>{if(r)throw Error(`render-cache hold released twice`);r=!0,n.holders--,this.reclaim(t,n)}}}holdSession(e,t,n,r){let i=this.hold(e,t,n),a,o;try{a=this.viewOf(i.entry,i.state,r,`request`),o=this.leaseOf(a)}catch(e){throw i[Symbol.dispose](),e}return this.holdViewOf(i,a,o)}holdView(e){let t=this.views.get(e);if(t===void 0)return null;let n=this.leaseOf(t);return this.holdViewOf(this.holdState(n.entry,t.state),t,n)}holdViewOf(e,t,n){n.holders++;let r=!1;return{entry:e.entry,state:e.state,view:t,[Symbol.dispose]:()=>{if(r)throw Error(`render-cache view hold released twice`);r=!0,n.holders--,this.reclaimView(t,n),e[Symbol.dispose]()}}}openFailure(e){return this.openFailures.get(e)??null}follow(e,t,n,r){try{var i=No();let a=this.views.get(e),o=a?.facts()??this.openFailures.get(e)?.facts;if(o===void 0)return;let s=this.entries.get(J5(t,n,r));if(a!==void 0&&s?.state===a.state)return;let c=i.u(this.hold(t,n,r));this.viewOf(c.entry,c.state,o,`click`)}catch(e){i.e=e}finally{i.d()}}pin(e){this.pins.set(e,(this.pins.get(e)??0)+1);let t=!1;return()=>{if(t)throw Error(`render-cache pin released twice`);t=!0;let n=(this.pins.get(e)??0)-1;n>0?this.pins.set(e,n):this.pins.delete(e)}}viewOf(e,t,n,r){let{sessionId:i}=n,a=this.views.get(i);if(a?.state===t)return this.views.delete(i),this.views.set(i,a),a.requested(n),a;this.views.delete(i);let o;try{o=this.opened(e,t,n,r)}finally{a!==void 0&&this.retireView(a,`moved`)}return this.fit(e),o}opened(e,t,n,r){let{sessionId:i}=n,a;try{a=wne(t,e.cwd,n,{source:this.deps.source,changed:e=>this.observers.onViewChanged?.(e),log:this.log})}catch(e){throw this.openFailures.set(i,{error:e,facts:n}),e}return this.openFailures.delete(i),this.views.set(i,a),this.viewHolds.set(a,{entry:e,holders:0,retired:null}),this.log(`info`,`session view opened sid=${JSON.stringify(i)} by=${r} cwd=${e.cwd} views=${this.views.size}`),a}leaseOf(e){let t=this.viewHolds.get(e);if(t===void 0)throw Error(`render-cache view never served`);return t}retireView(e,t){this.views.get(e.sessionId)===e&&this.views.delete(e.sessionId),this.views.has(e.sessionId)||this.copies.delete(e.sessionId),e.retire();let n=this.leaseOf(e);n.retired={reason:t,held:n.holders},this.reclaimView(e,n)}reclaimView(e,t){t.retired===null||t.holders>0||(this.viewHolds.delete(e),this.log(`info`,`session view closed sid=${JSON.stringify(e.sessionId)} reason=${t.retired.reason} released=${e.dispose()} held=${t.retired.held} views=${this.views.size}`))}retireSession(e){this.openFailures.delete(e);let t=this.views.get(e);t!==void 0&&this.retireView(t,`idle`)}subscriptions(){return{sources:Object.fromEntries([...this.views].map(([e,t])=>[e,Tne(t.state)]))}}close(){if(this.closed)return;this.closed=!0,this.walk?.(),this.walk=null,this.answersWatch.release();let e=this.entries.size;for(let[e,t]of this.entries)this.drop(e,t,`close`);this.log(`info`,`render-cache closed entries=${e} deferred=${this.stats.retired}`)}load(e,t,n,r){if(this.closed)throw Error(`render cache used after close`);return e7(e,t,n,this.deps,r)}drop(e,t,n){t.watch?.held.handle.release(),this.entries.delete(e),this.due.delete(t),this.retire(t.state,n,null)}get stats(){let e=0,t=0;for(let n of this.holds.values())n.holders>0&&e++,n.retired!==null&&t++;let n=0;for(let e of this.viewHolds.values())e.retired!==null&&n++;return{size:this.entries.size,held:e,retired:t,compiles:this.compiles.size,views:this.views.size,pinned:this.pins.size,due:this.due.size,retiredViews:n,accountedBytes:this.accountedBytes(),budgetBytes:this.budgetBytes()}}fit(e){let t=()=>this.entries.size<=this.maxEntries&&this.accountedBytes()<=this.budgetBytes(),n=new Set([...this.pins.keys()].flatMap(e=>{let t=this.views.get(e);return t===void 0?[]:[t.state]}));for(let[r,i]of this.entries){if(t())return;i===e||n.has(i.state)||this.drop(r,i,`evict`)}t()||this.log(`warn`,`render-cache over budget entries=${this.entries.size} views=${this.views.size} pinned=${n.size} accounted=${Fr(this.accountedBytes())}/${Fr(this.budgetBytes())}MB`)}serve(e){let t=this.compiles.get(e.compileKey);if(t!==void 0&&t!==e.compiled)throw Error(`render cache: a second compile for key ${e.compileKey.slice(0,12)}`);this.holds.set(e,{holders:0,retired:null}),this.compiles.set(e.compileKey,e.compiled),t===void 0&&this.log(`info`,`render-cache compile built key=${e.compileKey.slice(0,12)} compiles=${this.compiles.size}`)}holdOf(e){let t=this.holds.get(e);if(t===void 0)throw Error(`render-cache state never served`);return t}retire(e,t,n){for(let r of[...this.views.values()])if(r.state===e){if(n!==null)try{this.opened(n.entry,n.state,r.facts(),`reload`)}catch(e){this.log(`error`,`session view reopen failed sid=${JSON.stringify(r.sessionId)}: ${String(e)}`)}this.retireView(r,t)}let r=this.holdOf(e);r.retired={reason:t,held:r.holders},this.reclaim(e,r)}reclaim(e,t){t.retired===null||t.holders>0||(this.holds.delete(e),this.log(`info`,gne(t.retired,e.registry.dispose())),[...this.holds.keys()].some(t=>t.compileKey===e.compileKey)||this.compiles.delete(e.compileKey))}sessionsOn(e){return[...this.views.values()].filter(t=>t.state===e.state).map(e=>e.sessionId)}reload(e,t,n,r){this.reloadInto(this.getOrCreate(e,t,n),r)}reloadInto(e,t){this.due.delete(e);let n=this.sessionsOn(e),r=e.state,i=this.load(e.projectDir,e.cwd,e.configFile,r);e.lastWarning=i.warning,e.lastError=i.error,i.state!==null&&this.log(`info`,K5(i.layers,i.state,i.ms)),i.kind===`built`&&(e.state=i.state,this.serve(i.state),this.retire(r,`reload`,{entry:e,state:i.state})),this.fit(e),this.refreshWatcher(e,i),this.observers.onReload?.(e,n,t,i.kind)}reloadEvery(e){for(let t of this.entries.values())this.due.set(t,e);this.armWalk()}armWalk(){this.walk!==null||this.due.size===0||(this.walk=this.deps.clock.defer(()=>this.walkOne()))}walkOne(){this.walk=null;let e=null;for(let t of this.entries.values()){let n=this.due.get(t);n!==void 0&&(e=[t,n])}if(e===null)return;let[t,n]=e;try{this.reloadInto(t,n)}catch(e){this.log(`error`,`every-entry reload threw projectDir=${R(t.projectDir)} cwd=${R(t.cwd)} configFile=${R(t.configFile??`-`)} cause=${R(q5(n))}: ${x(e)}`)}finally{this.armWalk()}}refreshWatcher(e,t){e.configLayers=t.layers,e.configHome=t.home,e.repos=t.repos;let n=vne(e,this.deps.locations),{targets:r,unresolved:i}=n,a=`config:${e.projectDir}:${e.cwd}:${e.configFile??``}:${n.key}`,{watch:o,move:s}=this.deps.watchers.follow(e.watch?.held??null,{...n,key:a},t=>this.reloadInto(e,{kind:`config-watch`,heard:t}));if(e.watch={derived:{...n,key:a},held:o},s!==`kept`){this.log(`info`,`config watch bound projectDir=${e.projectDir} cwd=${e.cwd} dirs=${r.dirs.map(e=>e.path).join(`,`)} deaf=${o.handle.deaf.length}`);for(let{path:t,reason:n}of i)this.log(`warn`,`config watch unresolved projectDir=${e.projectDir} path=${t} reason=${n}`)}}get size(){return this.entries.size}latestView(){return[...this.views.values()].at(-1)??null}delivered(e,t,n){if(!this.views.has(e))return;let r=this.copies.get(e)??new Map;this.copies.set(e,r.set(t,n))}drawnCopy(e,t,n){return this.copies.get(e)?.get(t)?.get(n)}stopDrawing(e,t){this.copies.get(e)?.delete(t)}};const Dne=e=>!_J(e)&&!oI(e)&&e!==`update.dismissed`&&e!==Bi;var One=class{past=Y.observable.map(void 0,{deep:!1});depth(e,t,n){return this.restorable(e,t,n).length}restorable(e,t,n){let r=new Map,i=n=>r.has(n)?r.get(n):t.get(e,n),a=[];for(let t of[...this.past.get(e)??[]].reverse())if(t.every(e=>i(e.key)===e.after&&(e.before===null||n.validate(e.key,e.before).ok))){a.unshift(t);for(let e of t)r.set(e.key,e.before)}return a}begin(e){let t=new Map;return{sessionState:fJ(e,Dne,(e,n,r,i)=>{let a=t.get(e)??new Map,o=a.get(n);a.set(n,{key:n,before:o?o.before:r,after:i}),t.set(e,a)}),commit:()=>{for(let[e,n]of t){let t=[...n.values()].filter(e=>e.before!==e.after);t.length>0&&this.push(e,t)}t.clear()}}}back(e,t,n){let r=this.past.get(e)??[],i=this.restorable(e,t,n),a=i.at(-1),o=r.length-i.length;if(a===void 0)throw this.put(e,i),new Z(`back: nothing to go back to${o>0?` (${o} step(s) over a view since gone, discarded)`:``}`);return(0,Y.runInAction)(()=>{let n=a.flatMap(({key:e,before:t})=>t===null?[]:[{key:e,value:t}]);n.length>0&&t.setBatch(e,n);for(let{key:n,before:r}of a)r===null&&t.clear(e,n)}),this.put(e,i.slice(0,-1)),{step:a,discarded:o}}push(e,t){let n=this.past.get(e)??[];this.put(e,[...n,t].slice(-20))}put(e,t){(0,Y.runInAction)(()=>{for(this.past.delete(e),t.length>0&&this.past.set(e,t);this.past.size>32;)this.past.delete(this.past.keys().next().value)})}};const r7=(e,t)=>e.kind===`ok`?F(t(e.value)):e;function kne(e){switch(e.kind){case`pending`:case`failed`:return e;case`absent`:return I;case`ok`:return e.value.pullRequest}}const i7=(e,t)=>{let n=Object.entries(e);return n.length===Object.keys(t).length&&n.every(([e,n])=>Object.is(n,Reflect.get(t,e)))};function Ane({pullRequest:e,...t}){return t}function a7(e,t,n,r,i){let{lanes:a}=n,o=(e,t)=>S8(e,t,i),s=e?.builtins,c={session:o(s?.session,a.usage),today:o(s?.today,n.today),speed:o(s?.speed,a.speed),context:o(s?.context,a.context),metrics:o(s?.metrics,a.metrics),activity:o(s?.activity,a.activity),cache:o(s?.cache,a.cache),autocompact:o(s?.autocompact,a.autoCompact),git:o(s?.git,r7(a.git,Ane)),pr:o(s?.pr,kne(a.git)),tmux:o(s?.tmux,r7(a.tmuxSession,e=>({session:e}))),hostName:o(s?.hostName,a.hostName),hostUser:o(s?.hostUser,a.hostUser)},l=Object.fromEntries([...a.sources].map(([t,n])=>[t,o(e?.sources[t],n)])),u={builtins:c,sources:l,update:r,diagnostics:n.faults};return e!==void 0&&i7(c,e.builtins)&&i7(l,e.sources)&&(0,Y.compareStructural)({update:r,diagnostics:n.faults},{update:e.update,diagnostics:e.diagnostics})?e:{v:1,session:t,seq:e===void 0?1:e.seq+1,...u}}function o7(e,t){return e.diagnostics.find(e=>e.kind===`stamp`)?.reason===t?e:{...e,seq:e.seq+1,diagnostics:[...e.diagnostics.filter(e=>e.kind!==`stamp`),{kind:`stamp`,reason:t}]}}function s7(e){return e.diagnostics.find(e=>e.kind===`stamp`)?.reason??null}const jne=e=>({hookData:e.hookData,cwd:e.cwd,hints:e.hints,sessionId:e.sessionId}),Mne=e=>new Map(e.map(e=>[e.source,e.storage])),Nne=(e,t)=>e.size===t.size&&[...e].every(([e,n])=>{let r=t.get(e);return r!==void 0&&H5(n,r)});function c7({stop:e,holds:t}){e(),t.close()}var Pne=class{records=new Map;stopSweep=null;constructor(e){this.deps=e}requested(e){let t=jne(e),n=(0,Y.runInAction)(()=>{let n=this.records.get(e.sessionId);if(n===void 0){let n=this.open(e.sessionId,t);return this.records.set(e.sessionId,n),n.stamped.document}n.active=!0;let{phase:r}=n;r.kind===`live`&&r.declared.set(this.declared({...n,locator:t},r.holds));let i=r.kind===`live`?r:this.live(n,t);return n.phase=i,this.stamp(n,i.inputs.get()),n.stamped.document});return this.armSweep(),n}subscribed({sources:e}){for(let t of Object.keys(e))this.records.has(t)||this.deps.log(`error`,`subscriptions name session ${JSON.stringify(t)}, which the collector has no record of`);(0,Y.runInAction)(()=>{for(let t of this.records.values()){let n=Mne(e[t.session]??[]);if(Nne(n,t.subscriptions))continue;t.subscriptions=n;let{phase:r}=t;r.kind===`live`&&r.declared.set(this.declared({...t,locator:r.declared.get().locator},r.holds))}})}holding(e){let t=this.records.get(e);return t?.phase.kind===`live`?(t.clicks++,()=>{t.clicks--,t.active=!0}):()=>{}}sweep(){for(let e of this.records.values())e.phase.kind===`live`&&(e.active?e.active=!1:e.clicks===0&&!this.deps.watched(e.session)&&this.retire(e,e.phase))}stats(){let e=[...this.records.values()];return{sessions:e.length,retiring:e.filter(e=>e.phase.kind===`retiring`).length}}close(){this.disarmSweep();for(let{phase:e}of this.records.values())e.kind===`live`&&c7(e);this.records.clear()}open(e,t){let n=new Map,r=this.reader({session:e,locator:t,subscriptions:n}),i=r.inputs.get(),a;try{if(i.kind===`failed`)throw Error(i.reason);a=a7(void 0,e,i.readings,i.update,Ue(this.deps.clock))}catch(e){throw r.holds.close(),e}let o={document:a,from:i};return{session:e,stamped:o,subscriptions:n,active:!0,clicks:0,phase:this.watch(e,o,r)}}live(e,t){return this.watch(e.session,e.stamped,this.reader({...e,locator:t}))}reader(e){let t=new $A,n=Y.observable.box(this.declared(e,t),{deep:!1});return{holds:t,declared:n,inputs:(0,Y.computed)(()=>this.read(n.get()))}}watch(e,t,n){let r=(0,Y.reaction)(()=>n.inputs.get(),n=>(0,Y.runInAction)(()=>{n!==t.from&&this.stamp({session:e,stamped:t},n)&&this.deps.deliver({kind:`world-state`,worldState:t.document})}),{onError:t=>this.deps.log(`error`,`world state stamp threw sid=${JSON.stringify(e)}: ${x(t)}`)});return{kind:`live`,...n,stop:r}}declared({session:e,locator:t,subscriptions:n},r){let i=JSON.stringify(e);try{let{result:{lanes:e,faults:a},acquired:o,released:s}=r.declare(()=>KX(this.deps.owners,r,t,n));for(let e of a)this.deps.log(`error`,`session declaration threw sid=${i} ${e}`);return o+s>0&&this.deps.log(`info`,`session declared sid=${i} acquired=${o} released=${s} held=${r.size}`),{locator:t,lanes:e}}catch(e){return this.deps.log(`error`,`session declaration threw sid=${i}: ${x(e)}`),{locator:t,lanes:WX(L(`session declaration threw: ${String(e)}`,`read`),[...n.keys()])}}}inputsOf(e){return{...e,deps:this.deps.owners}}read({locator:e,lanes:t}){try{return{kind:`read`,readings:qX(this.inputsOf(e),t),update:this.deps.update()}}catch(e){return{kind:`failed`,reason:`reading the owners: ${String(e)}`}}}stamp({session:e,stamped:t},n){let r=t.document,i=n.kind===`failed`?o7(r,n.reason):this.assembled(r,n,Ue(this.deps.clock)),a=i===r?null:s7(i);return a!==null&&this.deps.log(`error`,`world state sid=${JSON.stringify(e)}: ${a}`),t.document=i,t.from=n,i!==r}assembled(e,t,n){try{return a7(e,e.session,t.readings,t.update,n)}catch(t){return o7(e,`stamping the world state: ${String(t)}`)}}retire(e,t){c7(t);let n={kind:`retiring`};e.phase=n,this.deps.log(`info`,`session retired sid=${JSON.stringify(e.session)}`),this.deps.deliver({kind:`retire`,session:e.session}).then(()=>{e.phase===n&&this.records.get(e.session)===e&&this.records.delete(e.session),this.records.size===0&&this.disarmSweep()})}armSweep(){this.stopSweep===null&&(this.stopSweep=this.deps.clock.every(15e4,()=>this.sweep(),{unref:!0}))}disarmSweep(){this.stopSweep?.(),this.stopSweep=null}},Fne=class{documents=Y.observable.map(void 0,{deep:!1});take(e){let t=this.documents.get(e.session);if(t!==void 0&&e.seq<=t.seq){if(e.seq===t.seq&&(0,Y.compareStructural)(e,t))return;throw Error(`world state seq ${e.seq} for session ${JSON.stringify(e.session)} does not follow the held seq ${t.seq}`)}(0,Y.runInAction)(()=>this.documents.set(e.session,e))}of(e){let t=this.documents.get(e);if(t===void 0)throw Error(`no world state for session ${JSON.stringify(e)}: the host hands one in with the config ahead of every request`);return t}drop(e){(0,Y.runInAction)(()=>this.documents.delete(e))}};function Ine(e){return({sessionId:t,state:n,store:r,requested:i})=>{let a=n=>e.sessionState.get(t,n),o=r.derive(`session.effective`,`computed`,()=>CK(n.config,a,e=>n.authoredRoots.has(e))),s=r.derive(`session.compose`,`computed`,()=>{let{hookData:t,hints:n}=i();return{hookData:t,hints:n,home:e.home}}),c=r.derive(`session.draw`,`computed`,()=>({sources:[...n.sources.keys()],effective:o.read(),configFacts:{...KK(n.config,n.fileHeldSettings,a),configPath:n.configPath},history:e.history(t),back:e.navigation(t,n.config)})),l=()=>e.worldStates.of(t),u=r.derive(`session.payload`,`computed`,()=>$X(l(),s.read(),c.read()));return{payload:()=>u.read(),effective:()=>c.read().effective,facts:l,hints:()=>s.read().hints,failure:()=>s7(l()),selections:()=>c.read().effective}}}const l7=`#{pane_id} #{session_id} #{session_attached} #{window_active} #{window_zoomed_flag} #{pane_active}`,u7=`#{session_id} #{client_control_mode} #{pane_id}`;function d7(e){let t=new Set;for(let n of e.split(`
486
486
  `)){let[e,r]=n.trim().split(` `);e!==void 0&&r===`1`&&t.add(e)}return t}function f7(e,t){let n=new Set;for(let r of e.split(`
487
- `)){let[e,i,a,o,s,c]=r.trim().split(` `);e===void 0||e===``||i===void 0||Number(a)>0&&(o===`1`||t.has(i))&&(s!==`1`||c===`1`)&&n.add(e)}return n}function Ine(e,t){let n=new Map;for(let t of e.split(`
487
+ `)){let[e,i,a,o,s,c]=r.trim().split(` `);e===void 0||e===``||i===void 0||Number(a)>0&&(o===`1`||t.has(i))&&(s!==`1`||c===`1`)&&n.add(e)}return n}function Lne(e,t){let n=new Map;for(let t of e.split(`
488
488
  `)){let[e,r]=t.trim().split(` `);e!==void 0&&e!==``&&r!==void 0&&n.set(e,r)}let r=new Map;for(let e of t.split(`
489
- `)){let[t,n,i]=e.trim().split(` `);t!==void 0&&n===`0`&&i!==void 0&&r.set(t,i)}return{sessionOf:n,shownBy:r}}var Lne=class{servers=new Map;loop={kind:`idle`};constructor(e){this.deps=e}follow(){switch(this.loop.kind){case`idle`:this.deps.log(`info`,`visibility following`),this.ask();break;case`asking`:this.loop.following=!0;break;case`due`:break}return()=>this.stop()}stop(){switch(this.loop.kind){case`due`:this.loop.clear(),this.end();return;case`asking`:this.loop.following=!1;return;case`idle`:return}}ask(){let e={kind:`asking`,following:!0};this.loop=e,Promise.resolve().then(()=>this.refresh(this.deps.sockets())).catch(e=>this.deps.log(`error`,`visibility refresh threw: ${x(e)}`)).then(()=>{if(e.following){this.loop={kind:`due`,clear:this.deps.clock.after(this.deps.intervalMs,()=>this.ask(),{unref:!0})};return}this.end()})}end(){this.deps.log(`info`,`visibility stopped forgot=${this.servers.size}`),this.loop={kind:`idle`},this.servers.clear()}shown(e){if(e==null)return!0;let t=this.servers.get(e.socket);return t?.kind!==`asked`||t.shown.has(e.pane)}async refresh(e){for(let t of this.servers.keys())e.has(t)||this.servers.delete(t);let t=await Promise.all([...e].map(async e=>{let[t,n]=await Promise.all([this.deps.listPanes(e),this.deps.listClients(e)]);return[e,t.kind===`ok`?n.kind===`ok`?{kind:`asked`,shown:f7(t.stdout,d7(n.stdout)),status:Ine(t.stdout,n.stdout)}:{kind:`unasked`,reason:n.reason}:{kind:`unasked`,reason:t.reason}]})),n=new Set;for(let[e,r]of t){let t=this.servers.get(e);this.servers.set(e,r),!Rne(t,r)&&(n.add(e),this.deps.log(r.kind===`asked`?`info`:`warn`,r.kind===`asked`?`visibility socket=${JSON.stringify(e)} shown=${[...r.shown].join(`,`)||`-`}`:`visibility socket=${JSON.stringify(e)} unasked: ${r.reason} — its panes count as shown`))}for(let[e,n]of t)n.kind===`asked`&&this.deps.onAnswer(e,n.status);n.size>0&&this.deps.onChange(n)}};function Rne(e,t){return e===void 0||e.kind!==t.kind?!1:e.kind===`unasked`||t.kind===`unasked`?!0:e.shown.size===t.shown.size&&[...e.shown].every(e=>t.shown.has(e))}function zne(e){return`ccb`+oe(`sha256`).update(e).digest(`hex`).slice(0,12)}const Bne=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightblack`,`brightred`,`brightgreen`,`brightyellow`,`brightblue`,`brightmagenta`,`brightcyan`,`brightwhite`];function p7(e){if(e===void 0)return`terminal`;let t=H.parse(e);if(t.isDefault)return`terminal`;switch(t.type){case V.STANDARD:{let e=t.number===void 0?void 0:Bne[t.number];if(e!==void 0)return e;break}case V.EIGHT_BIT:if(t.number!==void 0)return`colour${t.number}`;break;case V.TRUECOLOR:{let e=t.fixedValue;if(e!==void 0)return e.hex;break}case V.DEFAULT:case V.WINDOWS:break}throw Error(`frames: no tmux colour for ${t.name}`)}const Vne={bold:`bold`,dim:`dim`,italic:`italics`,underline:`underscore`,strike:`strikethrough`,reverse:`reverse`,blink:`blink`,conceal:`hidden`,underline2:`double-underscore`,overline:`overline`,blink2:null,frame:null,encircle:null};function Hne(e){return e.replaceAll(`#`,`##`)}function Une({fg:e,bg:t,attrs:n=[]}){let r=n.map(e=>{let t=Vne[e];if(t===null)throw Error(`frames: a tmux status line cannot draw ${e} text`);return t});return`#[${[`none`,`fg=${p7(e)}`,`bg=${p7(t)}`,...r].join(`,`)}]`}function Wne(e){let t={},n=e=>{let n=Une(e)+Hne(e.text);if(e.link===void 0)return n;let r=zne(e.link);return t[r]=e.link,`#[range=user|${r}]${n}#[norange]`};return{rows:e.rows.map(e=>zP(e).map(n).join(``)),links:t}}function m7(e){return FP(Wne,e)}const h7=Xb.tmuxStatus.rows,g7=`@cc-candybar-status-prior`,_7=`@cc-candybar-status-wrote`,v7=`@cc-candybar-binding-prior`,y7=[`-T`,`root`,`MouseDown1Status`],b7=Array.from({length:h7},(e,t)=>t),x7=e=>`@cc-candybar-row-${e}`,Gne=e=>`#[fill=terminal]#{${x7(e)}}`,S7=e=>`status-format[${e}]`;function Kne(e){return e===0?`off`:e===1?`on`:String(e)}function C7(e){let t=e===`off`?0:e===`on`?1:/^[2-5]$/.test(e)?+e:NaN;if(Number.isNaN(t))throw Error(`tmux status is ${JSON.stringify(e)}`);return t}function qne(e,t){if(e===null)return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[Number(n)]===t[Number(n)])}function w7(e){return e.endsWith(`;`)?`${e.slice(0,-1)}\\;`:e}function T7(e){return e.flatMap((e,t)=>[...t===0?[]:[`;`],...e])}function E7(e){return`"${e.replace(/[\\"$]/g,e=>`\\${e}`)}"`}function Jne(e){return e.map(e=>e.map(E7).join(` `)).join(` ; `)}const D7=`ccb:separator`;function O7(e){return T7(e.flatMap((e,t)=>t===0?[e]:[[`display-message`,`-p`,D7],e]))}function k7(e,t){let n=e.split(`${D7}\n`);return n.length===t?n.map(e=>e.replace(/\n$/,``)):null}const A7=(e,t)=>[`show-options`,`-q`,`-v`,`-t`,e,t],j7=e=>[`show-options`,`-g`,`-q`,`-v`,e],M7=e=>[[`show-options`,`-t`,e],A7(e,`status`),...b7.map(t=>A7(e,S7(t)))];function N7(e){let[t=``,n=``,...r]=e,i=t.split(`
490
- `).map(e=>e.split(` `)[0]??``),a={};for(let e of b7)i.includes(S7(e))&&(a[e]=r[e]??``);let o=i.includes(`status-format`)||Object.keys(a).length>0;return{status:i.includes(`status`)?n:null,formats:o?a:null}}function P7(e,t){return[[`set-option`,`-u`,`-t`,e,`status-format`],...Object.entries(t??{}).map(([t,n])=>[`set-option`,`-t`,e,S7(Number(t)),w7(n)])]}const Yne=e=>[[`display-message`,`-p`,`-t`,e,`#{status}`],...M7(e),...b7.map(e=>j7(S7(e))),A7(e,g7),A7(e,_7)];function F7(e,t,n){let r,i;try{r=JSON.parse(e),i=t===``?r.base:C7(t)}catch(e){return{kind:`theirs`,why:`${g7} does not read (${String(e)})`}}return r.owner===n?{kind:`ours`,prior:r,status:i}:{kind:`theirs`,why:`the daemon at ${JSON.stringify(r.owner)} draws it`}}function Xne(e,t,n){let[r=``,...i]=t,a=N7(i.slice(0,2+h7)),o=i.slice(2+h7,2+2*h7),[s=``,c=``]=i.slice(2+2*h7);if(s!==``)return F7(s,c,n);let l=C7(r),u={};for(let e=0;e<l;e++){let t=a.formats===null?o[e]:a.formats[e];t!==void 0&&t!==``&&(u[e]=t)}let d={...u,...Object.fromEntries(Array.from({length:h7-l},(e,t)=>[l+t,Gne(t)]))},f={owner:n,base:l,status:a.status,formats:a.formats,wrote:d};return{kind:`lay-out`,prior:f,commands:[[`set-option`,`-t`,e,g7,JSON.stringify(f)],...P7(e,d)]}}const I7=e=>[...M7(e),A7(e,_7)];function L7(e,t,n){let r=N7(n.slice(0,2+h7)),i=n[2+h7]??``,a=[],o=[];if(qne(r.formats,t.wrote))a.push(...P7(e,t.formats));else{o.push(`status-format`);for(let[n,i]of Object.entries(r.formats??{}))Number(n)>=t.base&&i===t.wrote[Number(n)]&&a.push([`set-option`,`-u`,`-t`,e,S7(+n)])}return i!==``&&(r.status===i?a.push(t.status===null?[`set-option`,`-u`,`-t`,e,`status`]:[`set-option`,`-t`,e,`status`,w7(t.status)]):o.push(`status`)),a.push(...b7.map(t=>[`set-option`,`-q`,`-u`,`-t`,e,x7(t)]),[`set-option`,`-q`,`-u`,`-t`,e,g7],[`set-option`,`-q`,`-u`,`-t`,e,_7]),{commands:a,kept:o}}const Zne=/^bind-key\s+(?:-r\s+)?(?:-N\s+(?:"(?:[^"\\]|\\.)*"|\S+)\s+)?-T\s+root\s+MouseDown1Status\s+(.+)$/m,R7=[[`list-keys`,`-T`,`root`]];function z7(e){let t=Zne.exec(e);return t===null?null:{line:t[0],command:t[1]}}const B7=`cc-candybar://tmux-status-click/`,Qne=e=>`${B7}${Ca([e])}/#{s/%//:pane_id}/#{q:mouse_status_range}`,V7=e=>e?.command.includes(B7)??!1;function H7(e,t){let n={command:[`set-option`,`-g`,`-q`,`-u`,v7]};return V7(z7(t))?{steps:[e===null?{command:[`unbind-key`,...y7]}:{command:[`source-file`,`-`],stdin:`${e.line}\n`},n],said:`restored MouseDown1Status to ${e===null?`unbound`:JSON.stringify(e.line)}`}:{steps:[n],said:`left MouseDown1Status as it is: bound again since`}}var $ne=class{held=new Map;servers=new Map;closed=!1;writes=0;failedWrites=0;constructor(e){this.deps=e}observe(e,t,n){if(this.closed)return;let r=this.held.get(e),i=n&&t!=null?t:null;if(r!==void 0&&(i===null||r.socket!==i.socket||r.pane!==i.pane)&&this.release(r,`switched off or moved`),i===null||this.held.has(e))return;let a={sessionId:e,socket:i.socket,pane:i.pane,unsubscribe:null,frame:null};this.held.set(e,a),this.serverOf(i.socket),this.deps.log(`info`,`tmux-status: holding sid=${JSON.stringify(e)} pane=${i.pane} socket=${JSON.stringify(i.socket)}`),a.unsubscribe=this.deps.subscribe(e,{lane:`tmuxStatus`,frame:e=>{a.frame=m7(e),this.reconcile(a.socket)},refused:t=>{this.held.get(e)===a&&this.release(a,`refused: ${t.error}`)},drawing:()=>this.draws(a)})}answered(e,t){if(this.closed)return;let n=this.serverOf(e);n.view=t;for(let n of[...this.held.values()])if(n.socket===e)if(!t.sessionOf.has(n.pane))this.release(n,`pane gone`);else{let t=this.deps.sessionInPane(e,n.pane);t!==null&&t!==n.sessionId&&this.release(n,`pane taken by sid=${JSON.stringify(t)}`)}this.reconcile(e)}draws(e){let t=this.servers.get(e.socket),n=t?.view?.sessionOf.get(e.pane);return n!==void 0&&t.layouts.has(n)&&t.view.shownBy.get(n)===e.pane}restoreAll(e){this.closed=!0;for(let e of this.held.values())e.unsubscribe?.();this.held.clear();for(let[t,n]of this.servers){for(let[r,i]of[...n.layouts]){n.layouts.delete(r);let a=this.askSync(e,t,I7(r));if(a===null)continue;let o=L7(r,i.prior,a);this.writeSync(e,t,o.commands),this.saidRestored(t,r,o.kept)}let r=n.binding;if(n.binding={kind:`none`},r.kind===`ours`||r.kind===`adopted`){let n=this.askSync(e,t,R7);if(n===null)continue;this.writeBindingRestoreSync(e,t,r.prior,n[0]??``)}}}linkAt(e){let t=ere(e),[n,r,i,...a]=t??[];if(t===null||n===void 0||r===void 0||i===void 0||a.length>0)return{kind:`refused`,reason:`tmux-status-click needs <socket>/<pane>/<range>, got ${JSON.stringify(e)}`};let o=[...this.held.values()].find(e=>e.socket===n&&e.pane===`%${r}`)?.frame?.links[i];return o===void 0?{kind:`refused`,reason:`pane %${r}'s status line draws no link ${i} now`}:{kind:`link`,url:o}}stats(){return{sessions:this.held.size,layouts:[...this.servers.values()].reduce((e,t)=>e+t.layouts.size,0),writes:this.writes,failedWrites:this.failedWrites}}async settled(){for(let e of this.servers.values())await e.running}serverOf(e){let t=this.servers.get(e);if(t!==void 0)return t;let n={view:null,adopted:!1,layouts:new Map,left:new Map,binding:{kind:`none`},running:null,again:!1,lastFailure:null};return this.servers.set(e,n),n}release(e,t){e.unsubscribe?.(),this.held.delete(e.sessionId),this.deps.log(`info`,`tmux-status: released sid=${JSON.stringify(e.sessionId)} pane=${e.pane} — ${t}`),this.reconcile(e.socket)}reconcile(e){let t=this.servers.get(e);if(!(t===void 0||this.closed)){if(t.running!==null){t.again=!0;return}t.running=(async()=>{try{do t.again=!1,await this.step(e,t);while(t.again&&!this.closed)}catch(t){this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} reconcile threw: ${String(t)}`)}finally{t.running=null}})()}}async step(e,t){let n=t.view;if(n===null)return;t.adopted||(t.adopted=!0,await this.adopt(e,t));let r=new Map;for(let t of this.held.values()){if(t.socket!==e)continue;let i=n.sessionOf.get(t.pane);i!==void 0&&r.set(i,[...r.get(i)??[],t])}for(let i of new Set([...t.layouts.keys(),...t.left.keys(),...r.keys()])){if(this.closed)return;let a=r.get(i)??[],o=t.layouts.get(i);if(a.length===0){t.left.delete(i),o!==void 0&&await this.restore(e,t,i);continue}if(t.left.has(i))continue;let s=o??await this.install(e,t,i);if(s===null)continue;let c=a.find(e=>e.pane===n.shownBy.get(i))?.frame?.rows.slice(0,h7-s.prior.base)??[];await this.draw(e,i,s,c)}this.closed||(t.layouts.size>0?await this.installBinding(e,t):await this.restoreBinding(e,t))}async adopt(e,t){let n=await this.run(e,[`list-sessions`,`-F`,`#{session_id}\t#{${g7}}\t#{${_7}}`]);if(n.kind===`ok`)for(let r of n.stdout.split(`
491
- `)){let[n,i,a=``]=r.split(` `);if(n===void 0||i===void 0||i===``)continue;let o=F7(i,a,this.deps.owner);o.kind===`ours`?t.layouts.set(n,{prior:o.prior,rows:[],status:o.status}):this.leave(e,t,n,o.why)}let r=(await this.ask(e,[j7(`@cc-candybar-binding-prior`)]))?.[0]??``;if(r!==``)try{let e=JSON.parse(r);e.owner===this.deps.owner&&(t.binding={kind:`adopted`,prior:e.prior})}catch(t){this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${v7} does not read (${String(t)}), left as it is`)}(t.layouts.size>0||t.binding.kind===`adopted`)&&this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} took over layouts=${[...t.layouts.keys()].join(`,`)||`-`} binding=${t.binding.kind}`)}leave(e,t,n,r){t.left.set(n,r),this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} session ${n} left as it is: ${r}`)}async install(e,t,n){let r=await this.ask(e,Yne(n));if(r===null||this.closed)return null;let i=Xne(n,r,this.deps.owner);if(i.kind===`theirs`)return this.leave(e,t,n,i.why),null;let a={prior:i.prior,rows:[],status:i.kind===`ours`?i.status:i.prior.base};return t.layouts.set(n,a),i.kind===`lay-out`&&await this.write(e,i.commands),this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} ${i.kind===`ours`?`took over`:`laid out`} session ${n} base=${i.prior.base} own=${[i.prior.status===null?[]:[`status`],i.prior.formats===null?[]:[`status-format`]].flat().join(`,`)||`-`}`),a}async draw(e,t,n,r){let i=n.prior.base+r.length,a=[];if(r.forEach((e,r)=>{n.rows[r]!==e&&a.push([`set-option`,`-t`,t,x7(r),e])}),i!==n.status){let e=Kne(i);a.push([`set-option`,`-t`,t,`status`,e],[`set-option`,`-t`,t,_7,e])}(a.length===0||await this.write(e,[[`if-shell`,`-F`,`-t`,t,`#{@cc-candybar-status-prior}`,Jne(a)]]))&&(n.rows=r,n.status=i)}async restore(e,t,n){let r=t.layouts.get(n);if(r===void 0)return;t.layouts.delete(n);let i=await this.ask(e,I7(n));if(i===null)return;let a=L7(n,r.prior,i);await this.write(e,a.commands),this.saidRestored(e,n,a.kept)}saidRestored(e,t,n){this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} restored session ${t} kept=${n.join(`,`)||`-`}`)}async installBinding(e,t){let n=t.binding;if(n.kind===`ours`||n.kind===`left`)return;let r=await this.ask(e,R7);if(r===null||this.closed)return;let i=z7(r[0]??``);if(n.kind===`none`&&V7(i)){t.binding={kind:`left`,why:`another cc-candybar daemon's status-line clicks are bound to MouseDown1Status; left as it is, so this daemon's are off`},this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${t.binding.why}`);return}let a=n.kind===`adopted`&&V7(i)?n.prior:i,o={owner:this.deps.owner,prior:a};if(t.binding={kind:`ours`,prior:a},!await this.write(e,[[`bind-key`,...y7,`if-shell`,`-F`,`#{m:ccb*,#{mouse_status_range}}`,`run-shell -b ${E7(`${this.deps.handler} ${Qne(e)}`)}`,...a===null?[]:[a.command]],[`set-option`,`-g`,`@cc-candybar-binding-prior`,JSON.stringify(o)]])){t.binding=n;return}this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} bound MouseDown1Status (was ${a===null?`unbound`:JSON.stringify(a.line)})`)}async restoreBinding(e,t){let n=t.binding;if(t.binding={kind:`none`},n.kind!==`ours`&&n.kind!==`adopted`)return;let r=await this.ask(e,R7);if(r===null)return;let i=H7(n.prior,r[0]??``);for(let t of i.steps)await this.write(e,[t.command],t.stdin);this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} ${i.said}`)}writeBindingRestoreSync(e,t,n,r){let i=H7(n,r);for(let n of i.steps)this.writeSync(e,t,[n.command],n.stdin);this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(t)} ${i.said}`)}counted(e,t){let n=this.serverOf(e);return t.kind===`ok`?(n.lastFailure=null,t):(this.failedWrites++,n.lastFailure!==t.reason&&this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${t.reason}`),n.lastFailure=t.reason,t)}async run(e,t,n){return this.counted(e,await this.deps.edge.run(e,t,n))}async ask(e,t){let n=await this.run(e,O7(t));return n.kind===`ok`?k7(n.stdout,t.length):null}askSync(e,t,n){let r=this.counted(t,e(t,O7(n)));return r.kind===`ok`?k7(r.stdout,n.length):null}async write(e,t,n){return t.length===0?!0:(this.writes++,(await this.run(e,T7(t),n)).kind===`ok`)}writeSync(e,t,n,r){n.length!==0&&(this.writes++,this.counted(t,e(t,T7(n),r)))}};function ere(e){try{return wa(e)}catch(e){if(e instanceof URIError)return null;throw e}}const $=e=>({arity:e,keep:!0}),U7=e=>({arity:e,keep:!1}),tre={"--add-dir":$(`variadic`),"--agent":$(`one`),"--agents":$(`one`),"--allow-dangerously-skip-permissions":$(`none`),"--allowedTools":$(`variadic`),"--allowed-tools":$(`variadic`),"--append-system-prompt":$(`one`),"--autocompact":$(`one`),"--ax-screen-reader":$(`none`),"--bg":U7(`none`),"--background":U7(`none`),"--bare":$(`none`),"--betas":$(`variadic`),"--brief":$(`none`),"--chrome":$(`none`),"--cloud":U7(`optional`),"-c":U7(`none`),"--continue":U7(`none`),"--dangerously-skip-permissions":$(`none`),"-d":$(`optional`),"--debug":$(`optional`),"--debug-file":$(`one`),"--desktop":U7(`none`),"--disable-slash-commands":$(`none`),"--disallowedTools":$(`variadic`),"--disallowed-tools":$(`variadic`),"--effort":$(`one`),"--environment":U7(`one`),"--exclude-dynamic-system-prompt-sections":$(`none`),"--fallback-model":$(`one`),"--file":$(`variadic`),"--fork-session":U7(`none`),"--forward-subagent-text":$(`none`),"--from-pr":U7(`optional`),"-h":U7(`none`),"--help":U7(`none`),"--ide":$(`none`),"--include-hook-events":$(`none`),"--include-partial-messages":$(`none`),"--input-format":$(`one`),"--json-schema":$(`one`),"--max-budget-usd":$(`one`),"--mcp-config":$(`variadic`),"--model":$(`one`),"-n":$(`one`),"--name":$(`one`),"--no-chrome":$(`none`),"--no-session-persistence":$(`none`),"--output-format":$(`one`),"--permission-mode":$(`one`),"--permission-prompts":$(`one`),"--plugin-dir":$(`one`),"--plugin-url":$(`one`),"-p":U7(`none`),"--print":U7(`none`),"--prompt-suggestions":$(`optional`),"--remote-control":$(`optional`),"--remote-control-session-name-prefix":$(`one`),"--replay-user-messages":$(`none`),"--restricted":$(`none`),"-r":U7(`optional`),"--resume":U7(`optional`),"--safe-mode":$(`none`),"--session-id":U7(`one`),"--setting-sources":$(`one`),"--settings":$(`one`),"--strict-mcp-config":$(`none`),"--system-prompt":$(`one`),"--system-prompt-snapshot":$(`one`),"--teleport":U7(`optional`),"--tmux":U7(`none`),"--tools":$(`variadic`),"--verbose":$(`none`),"-v":U7(`none`),"--version":U7(`none`),"-w":U7(`optional`),"--worktree":U7(`optional`)},nre={resume:`--resume`,fresh:`--session-id`};function rre(e){return[nre[e.kind],e.sessionId]}const W7=e=>e.startsWith(`-`)&&e!==`-`;function G7(e,t){let n=K7(t);return n===null?{dir:e??t,args:[]}:e!==null&&ire(e,n.top)?{dir:e,args:[]}:{dir:e===null||K7(e)!==null?n.repo:e,args:[`--worktree`,n.name]}}const ire=(e,t)=>e===t||e.startsWith(t+E.sep);function are(e){let t=[],n=e.slice(1),r=0;for(;r<n.length;){let e=n[r];if(r+=1,e===`--`)break;if(!W7(e))continue;let i=e.indexOf(`=`),a=i===-1?e:e.slice(0,i),o=tre[a];if(o===void 0)return{kind:`refused`,reason:`Claude Code was started with ${a}, which cc-candybar does not know how to carry to a restart`};let s=i===-1?o.arity===`one`?n.slice(r,r+1):o.arity===`optional`?n.slice(r,r+1).filter(e=>!W7(e)):o.arity===`variadic`?ore(n.slice(r),e=>!W7(e)):[]:[];if(o.arity===`one`&&i===-1&&s.length===0)return{kind:`refused`,reason:`Claude Code was started with ${a} and no value after it`};r+=s.length,o.keep&&t.push(e,...s)}return{kind:`args`,args:t}}function K7(e){let t=e.split(E.sep),n=t.findLastIndex((e,n)=>e===`worktrees`&&t[n-1]===`.claude`&&n+1<t.length);return n===-1?null:{name:t[n+1].replaceAll(`+`,`/`),top:t.slice(0,n+2).join(E.sep),repo:t.slice(0,n-1).join(E.sep)||E.sep}}function ore(e,t){let n=e.findIndex(e=>!t(e));return n===-1?[...e]:e.slice(0,n)}const q7=`candybar-band@cc-candybar`,sre=E.join(`bin`,`cc-candybar-native`),cre=dI(`/reload-plugins`),J7=e=>({kind:`done`,said:e});function Y7(e){let t=D$(e.hints.tmux);if(t.kind===`refused`)throw new Z(t.reason);return t.hint}const lre={band:{on:async(e,t,n)=>{let r=nn(t.bundle);if(r===null)throw new Z(`${Xb.band.label} runs the band mod from a cc-candybar source checkout, and this daemon runs ${t.bundle} — run the daemon from a checkout (mod/README.md)`);let i=E.join(r,sre);if(!n.fileExists(i))throw new Z(`the band mod starts ${i}, which is not built — run \`just install-rust\` in ${r}`);return{kind:`underway`,said:`installing ${q7} from ${r}`,finished:ure(e,r,n)}},off:async()=>J7(`nothing to stop: the band mod draws nothing while the lane is off`)},statusline:{on:async(e,t,n)=>{let r=Y7(e),i=j(t.preload),a=[t.preload,i].find(e=>!n.fileExists(e));if(a!==void 0)throw new Z(`${Xb.statusline.label} restarts Claude Code under the attach launcher, and ${a} is not there — run \`cc-candybar install\` (in a checkout, \`pnpm build\`)`);return{kind:`underway`,said:`restarting Claude Code in ${r.pane} under the attach launcher`,finished:pre(e,r,{node:t.node[0],launcher:i,preload:t.preload},n)}},off:async()=>J7(`nothing to stop: the attached statusline draws its command's output while the lane is off`)},pane:{on:async(e,t,n)=>{let r=Y7(e),i=await n.barPanes(r);return i.length>0?J7(`bar pane ${i.join(`, `)} already draws ${r.pane}'s bar`):J7(`opened bar pane ${await n.openBarPane(r,[...t.node,t.bundle,`bar-pane`,r.pane],{CC_CANDYBAR_SOCKET:t.socket})} under ${r.pane}`)},off:async(e,t,n)=>{let r=D$(e.hints.tmux);if(r.kind===`refused`)return J7(`no bar pane to close: ${r.reason}`);let i=r.hint,a=await n.barPanes(i);for(let e of a)await n.closePane(i,e);return J7(a.length===0?`no bar pane draws ${i.pane}'s bar`:`closed bar pane ${a.join(`, `)}`)}},tmuxStatus:{on:async e=>J7(`the daemon draws ${Y7(e).pane}'s bar in its status line`),off:async()=>J7(`nothing to stop: the daemon puts the status line back once the lane is off`)}};async function ure(e,t,n){let r={sessionId:e.sessionId,projectDir:e.origin.projectDir,claudeConfigDir:e.hints.claudeConfigDir};await n.claude([`plugin`,`marketplace`,`add`,t],r),await n.claude([`plugin`,`install`,q7],r);let i=await O$(n.claudeInput,e.hints.tmux,cre);if(i.kind===`refused`)throw Error(`the band mod is installed, but /reload-plugins was not typed: ${i.reason} — or type /reload-plugins yourself`);return`installed ${q7} from ${t} and typed /reload-plugins into ${i.pane}`}const dre=new Set([Yo,lP]);function fre(e){return new Map(e.flatMap(e=>{let t=e.indexOf(`=`);return t>0?[[e.slice(0,t),e.slice(t+1)]]:[]}))}async function pre(e,t,n,r){let i=await r.paneClaude(t);if(i.attached)return`left Claude Code in ${t.pane} running: it already runs under the attach launcher`;if(!i.fromShell)throw Error(`Claude Code is the first process of pane ${t.pane}, so nothing would be left in the pane to start it again under the attach launcher — start Claude Code from a shell in the pane`);let a=await r.moduleGraph(n.node,Wt(n.launcher),i.executable);if(!a.ok)throw Error(`Claude Code in ${t.pane} runs ${i.executable}, which the attach launcher cannot start (${a.reason}) — ${Xb.statusline.label} needs the native Claude Code install (\`claude install\`), so it was left running`);if((await r.paneClaude(t)).pid!==i.pid)throw Error(`Claude Code in ${t.pane} is no longer the process the restart read (pid ${i.pid}), so it was not restarted under the attach launcher`);let o=vre(await r.claudeInput.read(t));if(o!==null)throw Error(`Claude Code in ${t.pane} was left running: ${o} — then turn ${Xb.statusline.label} off and on again`);let s=mre(e,r.presence(e.transcript));if(s!==null)throw Error(`Claude Code in ${t.pane} was left running: ${s}`);let c=are(i.argv);if(c.kind===`refused`)throw Error(`${c.reason} — restart it with that flag removed`);let l=fre(i.env),u=l.get(`PATH`),d=r.launcherNode(u);if(d.kind===`refused`)throw Error(`Claude Code in ${t.pane} was left running, under the PATH it was started with: ${d.why}`);let f=r.onPath(`claude`,u)===i.executable?`claude`:i.executable,p=[...l].filter(([e])=>dre.has(e)),m=(e,t)=>qt(n.preload,{dir:e.dir,env:p,program:f,args:[...e.args,...c.args,...rre(t)]});if(r.terminate(i.pid),!await r.exited(i.pid,15e3))throw Error(`Claude Code in ${t.pane} did not exit within ${15e3/1e3} s of SIGTERM, so it was not restarted under the attach launcher`);let h=(e,n)=>Error(`Claude Code in ${t.pane} exited, but ${e}, so it was not started again — start it with \`${n}\``),g=hre(e,r.presence(e.transcript)),_=g.kind===`unchecked`?{kind:`resume`,sessionId:e.sessionId}:g,v;try{v=await r.paneDir(t,i.parent)}catch(e){throw h(`the directory it was started in could not be read (${e.message})`,m(G7(null,i.cwd),_))}let y=m(G7(v,i.cwd),_);if(g.kind===`unchecked`)throw h(`whether session ${e.sessionId} has a conversation could not be seen (${g.error})`,y);try{await r.typeShellLine(t,y)}catch(e){throw h(`the line could not be typed into its pane (${e.message})`,y)}if(!await r.followed(e.sessionId,`statusline`,3e4))throw Error(`Claude Code in ${t.pane} did not come back attached within ${3e4/1e3} s of \`${y}\` — the pane says why`);return`restarted Claude Code in ${t.pane} under the attach launcher with \`${y}\`, ${gre[g.kind](e.sessionId)}, and its statusline follows lane B`}function mre(e,t){return typeof t==`object`?`whether session ${e.sessionId} has a conversation could not be seen (${t.error})`:t===`present`||e.answered===`no`?null:e.answered===`yes`?`session ${e.sessionId} has a conversation but no transcript to resume it from (is session persistence off?), so a restart would lose it`:`this Claude Code does not say whether session ${e.sessionId} has a conversation, and it has no transcript to resume one from`}function hre(e,t){return typeof t==`object`?{kind:`unchecked`,error:t.error}:{kind:t===`present`?`resume`:`fresh`,sessionId:e.sessionId}}const gre={resume:e=>`resuming ${e}`,fresh:e=>`starting ${e} afresh, since it had no conversation yet`},_re={"in-mode":`its pane is in tmux copy mode — leave it (q)`,stashed:`it holds a stashed prompt (ctrl+s), which ending it would lose — restore or send it`,"no-prompt":`it is not at its prompt (a dialog or picker is open) — close it`};function vre(e){let t=S$(e);return t.kind===`ready`?T$(e)?`it is in the middle of a turn, which ending it would end — wait until it is idle`:C$(e)?`its prompt holds a draft, which ending it would lose — send or clear it`:null:_re[t.kind]}var yre=class{owed=new Map;setups=new S8;constructor(e){this.deps=e}clicked(e,t,n,r){let i=Zb.filter(e=>n[e]!==r[e]),a=this.take(e);for(let e of i)a.has(e)||a.set(e,n[e]);let o=e=>i.includes(e)?`click`:`owed`;if(t!==null){this.settle(t,a,r,o);return}for(let[e,t]of a)t===r[e]&&a.delete(e);if(i.length>0){let t=[...a.keys()].map(e=>`${e} ${r[e]?`on`:`off`}`);this.deps.log(`info`,`lane: owed ${t.join(`,`)||`nothing`} (session=${e})`)}a.size>0&&this.owed.set(e,a);for(let[e,t]of this.owed){if(this.owed.size<=1024)break;this.owed.delete(e),this.deps.log(`warn`,`lane: owed dropped sid=${JSON.stringify(e)} lanes=${[...t.keys()].join(`,`)}`)}}noted(e,t){this.settle(e,this.take(e.sessionId),t,()=>`owed`)}take(e){let t=this.owed.get(e)??new Map;return this.owed.delete(e),t}settle(e,t,n,r){for(let[i,a]of t)n[i]===a?this.deps.log(`info`,`lane: ${i} ${a?`on`:`off`} — nothing owed: its switch is back where the lane is by=${r(i)} (session=${e.sessionId})`):this.start(e,i,n[i],r(i))}start(e,t,n,r){this.deps.defer(()=>void this.setups.run(e.sessionId,()=>this.sync(e,t,n,r)))}async sync(e,t,n,r){let i=`by=${r} (session=${e.sessionId})`,a=r=>{let a=`lane: ${t} ${n?`on`:`off`}: ${r instanceof Error?r.message:String(r)}`;this.deps.log(`warn`,`${a} ${i}`),Sc(this.deps.state,e.sessionId,a,this.deps.now())},o;try{o=await lre[t][n?`on`:`off`](e,this.deps.host,this.deps.edge)}catch(e){a(e);return}this.deps.log(`info`,`lane: ${t} ${n?`on`:`off`} — ${o.said} ${i}`),o.kind===`underway`&&await o.finished.then(e=>this.deps.log(`info`,`lane: ${t} ${e} ${i}`),a)}};const bre=[`request`,`feed`],X7=new WeakMap;let xre=0;const Z7=e=>{let t=X7.get(e);if(t!==void 0)return t;let n=xre++;return X7.set(e,n),n};var Sre=class{records=new Map;constructor(e=512){this.maxRecords=e}of(e,t){return this.records.get(Q7(e,t))?.warnings??[]}ofSession(e,t,n){let r=Z7(n.config),i=[];for(let n of bre){let a=this.records.get(Q7(e,n)),o=n===t?this.of(e,t):a?.generation===r?a.warnings:[],s=i.map(e=>JSON.stringify(e));for(let e of o){let t=s.indexOf(JSON.stringify(e));t===-1?i.push(e):s.splice(t,1)}}return i}drawn(e,t,n,r){let i=this.of(e,t),a=Q7(e,t);this.records.delete(a),this.records.set(a,{generation:Z7(n.config),warnings:r});for(let e of this.records.keys()){if(this.records.size<=this.maxRecords)break;this.records.delete(e)}return JSON.stringify(i)!==JSON.stringify(r)}};const Q7=(e,t)=>`${t}\0${e}`;var Cre=class{queue=new S8;sessions=new S8;gathers=new S8;open=!0;inFlight=null;holder=null;queued=0;gathersInFlight=0;constructor(e){this.deps=e}take(e,{waited:t,gone:n},r){let i=this.deps.monotonic();return this.queued++,this.queue.run(`journals`,async()=>{if(this.queued--,this.refuseClosed(e),n())throw new lq(e);let a=this.deps.monotonic();t(Fe(i,a)),this.holder={verb:e,since:a};try{return await r({holds:t=>{let n={verb:e,commit:t};return this.inFlight=n,()=>this.commit(n)},landed:t=>t.finally(()=>this.refuseClosed(e))})}finally{this.holder=null}})}click(e,t,{placed:n,waited:r,gone:i,gathered:a},o,s){let c=this.deps.monotonic(),l=async()=>{if(n(A(this.deps,c)),this.refuseClosed(e),i())throw new lq(e);let t=this.deps.monotonic(),l=await o();a(A(this.deps,t));let u=i();return this.take(e,{waited:r,gone:()=>!u&&i()},e=>s(l,e))};return t===null?l():this.sessions.run(t,l)}async gathering(e){this.gathersInFlight++;try{return await this.gathers.run(`gathers`,e)}finally{this.gathersInFlight--}}getStats(){let{holder:e,queued:t}=this;return{holder:e?.verb??null,heldMs:e===null?0:A(this.deps,e.since),queued:t,gathers:this.gathersInFlight}}close(){this.open=!1,this.inFlight!==null&&(this.deps.log(`warn`,`journal: ${this.inFlight.verb} cut off by close, committing what landed`),this.commit(this.inFlight))}refuseClosed(e){if(!this.open)throw new cq(e)}commit(e){return this.inFlight===e?(this.inFlight=null,e.commit(),!0):!1}},$7=class extends Error{constructor(e,t){super(t instanceof Error?t.message:String(t)),this.record=e,this.thrown=t,this.name=`TurnThrew`}};function wre(e,t,n,r){let i=async e=>{try{let n=await t.answer(e);return r(n.subscriptions),{kind:`answered`,output:n}}catch(e){return e instanceof $7?{kind:`threw`,error:e.thrown,record:e.record}:{kind:`threw`,error:e,record:[]}}},a=(t,r,i)=>{let a=[[`renderer`,e],[`input`,t.event.kind],...r];switch(i.kind){case`answered`:i.output.record.length>0&&n(`info`,Oc(`turn`,[...a,...i.output.record]));return;case`threw`:n(`error`,Oc(`turn`,[...a,...i.record,[`error`,x(i.error)]]))}};return{name:e,answer:i,deliver:async(e,t)=>{let n=await i(e);return a(e,t,n),n}}}function Tre(e){let t=new Map,n=0,r=(t,n)=>({effects:t,subscriptions:e.renderCache.subscriptions(),record:n}),i=async(i,a,o)=>{switch(i.kind){case`config`:return Z3(e,i.context,i.worldState,a,o),r([],o);case`request`:{let{frame:s,delivered:c}=await s6(e,i.context,a,i.waitEndsAt,o),l=++n;return t.set(l,c),r([{kind:`present`,id:l,session:i.context.sessionId,surface:`statusline`,request:i.id,frame:s}],o)}case`world-state`:return e.worldStates.take(i.worldState),r([],o);case`retire`:return e.renderCache.retireSession(i.session),e.worldStates.drop(i.session),r([],o);case`effect-done`:{let e=t.get(i.of);if(e===void 0)throw Error(`effect-done for effect ${i.of}, which is not a present on its way`);return t.delete(i.of),i.outcome.kind===`ok`&&e(),r([],o)}}};return{answer:async({event:e,at:t})=>{let n=[];try{return await i(e,t,n)}catch(e){throw new $7(n,e)}}}}var Ere=class{sessions=new Map;pending=new Map;disposed=!1;constructor(e){this.deps=e}clicked(e,t){let n=this.record(e,t);n.since=t,this.settle(e)}clickArrived(e){this.pending.set(e,(this.pending.get(e)??0)+1),this.sessions.has(e)&&this.settle(e)}clickSettled(e){let t=this.pending.get(e)-1;t===0?this.pending.delete(e):this.pending.set(e,t),this.sessions.has(e)&&this.settle(e)}since(e,t){let n=this.record(e,t);return n.shown&&!this.pending.has(e)?n.since:void 0}observe(e,t,n,r){let i=this.record(e,t);t<i.drawnAt||(i.drawnAt=t,n&&!i.shown&&t>i.since&&(i.since=t),i.shown=n,i.timeoutS=r,this.settle(e))}getStats(){let e=0;for(let t of this.sessions.values())t.timer!==null&&e++;let t=0;for(let e of this.pending.values())t+=e;return{sessions:this.sessions.size,armed:e,pending:t}}dispose(){this.disposed=!0;for(let e of this.sessions.values())this.disarm(e);this.sessions.clear()}record(e,t){let n=this.sessions.get(e)??{since:t,timeoutS:0,shown:!1,drawnAt:t,timer:null,closing:!1};this.sessions.delete(e),this.sessions.set(e,n);for(let[e,t]of this.sessions){if(this.sessions.size<=256)break;this.disarm(t),this.sessions.delete(e)}return n}settle(e){let t=this.sessions.get(e),n=t.shown&&!t.closing&&!this.disposed&&!this.pending.has(e)?ux(t.since,t.timeoutS):null;t.timer?.at!==n&&(this.disarm(t),n!==null&&(t.timer={at:n,clear:this.deps.clock.after(Math.max(0,(n-this.deps.now())*1e3),()=>this.fire(e),{unref:!0})}))}disarm(e){e.timer?.clear(),e.timer=null}fire(e){let t=this.sessions.get(e);t.timer=null;let n=this.deps.now(),r={idleS:n-t.since,timeoutS:t.timeoutS,stillIdle:()=>this.sessions.get(e)===t&&!this.pending.has(e),closed:()=>{t.since=n,t.shown=!1}};t.closing=!0,this.deps.close(e,r).catch(t=>{r.closed(),this.deps.failed(e,t)}).finally(()=>{t.closing=!1,this.sessions.get(e)===t&&this.settle(e)})}};function Dre(e){let{bundle:t,memoryLimitBytes:n,registryUrl:r,clock:i,exit:a,paths:o,gates:s,host:c}=e,l=En(c),u=()=>Ve(new Date(i.now())),d=new AbortController,f=!1,p=(t,n)=>e.daemonLog.log(t,f?`after close: ${n}`:n),m=new GQ(i),h=e.launcher({inherited:c.env,stats:m.launchStats,signal:d.signal,now:u,observeWarnings:e=>{e.kind===`launch-pipes`?p(`warn`,e.text):p(e.fault===null?`info`:`warn`,e.fault===null?`launch lifeline running again`:`launch lifeline ${e.fault}; the next launch starts another`),pe.wakeWhere(`data`,()=>!0)}}),g=e.probe(h),_=e.storage(p),v=new mJ(_.session),y=new xJ(v,p,_.history),b=Wr({...e.limits({startedAtMs:m.startedAt.getTime(),exit:a,launcher:h,log:p}),limitBytes:n}),S=new s$,C=new kte,w=e.doctorStores,T=new lj({clock:i,counters:m,logger:p}),ee=new Dj(p),te=new Gc({watchers:T,logger:p,clock:i}),E=new Kj({launcher:h,clock:i,logger:p,ledger:ee,watchers:T,fileEvents:te}),ne=U5({launcher:h,host:c,watchers:T,fileEvents:te,clock:i,logger:p,ledger:ee}),{gitProvider:D,usageStore:re,tmuxService:ie,hostService:O,managedStorage:ae}=ne,oe=new Dne,se=new ete,ce=new Ere({clock:i,now:u,close:(e,t)=>n0(e,t,we),failed:(e,t)=>p(t instanceof cq?`info`:`error`,`menu-idle: close failed (session=${e}): ${x(t)}`)}),le=e.linkSigner,ue=new jc({supersede:(e,t)=>ae.supersede(e,t),launch:h.launch,state:v,log:p,now:u,clock:i}),de=new yre({edge:e.laneEdge(h,e=>pe.following(e),d.signal,g),host:{bundle:t.path,node:t.node,socket:o.socket,preload:ks(t.path,c)},state:v,log:p,now:u,defer:e=>void i.defer(e)}),fe=new $ne({edge:{run:(e,t,n)=>bc(h,{socket:e},`tmux-status`,t,n)},subscribe:(e,t)=>pe.subscribe(e,t),sessionInPane:(e,t)=>pe.newestWhere(({hints:{tmux:n}})=>n!=null&&n.socket===e&&n.pane===t),handler:[`CC_CANDYBAR_SOCKET=${Vt(o.socket)}`,...[...t.node,t.path].map(Vt),`url-handle`].join(` `),owner:o.socket,log:p}),pe=new F3({render:(e,t,n)=>G3(Ee,e,t,n),watch:(e,t)=>(0,Y.reaction)(()=>v.revision(e),t),lanes:e=>q3(Ee,e),pin:e=>{let t=ye.pin(e);return()=>{ye.stopDrawing(e,`feed`),t()}},shown:e=>me.shown(e.hints.tmux),watching:()=>me.follow(),refreshes:()=>ee.totals(),periods:k3,clock:i,instant:u,log:p}),me=new Lne({clock:i,listPanes:e=>bc(h,{socket:e},`frames.visibility`,[`list-panes`,`-a`,`-F`,l7]),listClients:e=>bc(h,{socket:e},`frames.visibility`,[`list-clients`,`-F`,u7]),sockets:()=>new Set(pe.watched().flatMap(({req:e})=>he(e))),onAnswer:(e,t)=>fe.answered(e,t),onChange:e=>pe.wakeWhere(`visibility`,t=>he(t).some(t=>e.has(t))),intervalMs:1e3,log:p});function he({hints:{tmux:e}}){return e==null?[]:[e.socket]}let ge=new Sre,_e=N8(),ve=new Pne,ye=new Tne({clock:i,runs:E,stateDir:o.state,locations:l,env:c.env,sessionState:v,watchers:T,log:p,storage:ae,signer:le,gates:s,source:Fne({sessionState:v,worldStates:ve,home:c.home,history:e=>y.depth(e),navigation:(e,t)=>oe.depth(e,v,s.state.gateFor(t))})},{budgetBytes:()=>dne(n),observers:{onReload:(e,t,n,r)=>{p(`info`,mne(e,n,r));for(let e of t)pe.wake(e,`reload`)},onViewChanged:e=>pe.wake(e,`data`)}});te.subscribe(e=>{switch(e.kind){case`period`:T.judge();return;case`caught-up`:ye.reloadEvery({kind:`events-resumed`,since:e.since}),pe.wakeWhere(`data`,()=>!0);return;case`moved`:pe.wakeWhere(`data`,()=>!0);return}});let be=60*1e3,xe=I8({clock:i,targets:t.targets,intervalMs:be,stat:e.stat,held:()=>Se.running(),exit:()=>a(0),log:p}),Se=M8({fact:_e,clock:i,launcher:h,probe:g,entryUrl:t.entryUrl,digest:t.digest,actsDir:i8(o.state,t.path),intervalMs:be,releaseIntervalMs:216e5,registryUrl:r,fetchImpl:e.fetch,gates:s,onApplied:()=>xe.checkNow(),log:p}),Ce=new Cre({log:p,monotonic:()=>i.monotonic()}),we={gates:s,sessionState:v,stateDir:o.state,locations:l,journalTurns:Ce,clickLanded:e=>ce.clicked(e,u()),log:p,launcher:h,now:u,applyUpdate:()=>Se.act(),doctor:e.doctorEdge(h,e=>{let t=[e.projectDir,e.cwd,e.target.path];ye.reload(...t,{kind:`doctor`});let n=ye.getOrCreate(...t);return{layers:n.configLayers,error:n.lastError,warning:n.lastWarning,unused:n.state.unused,config:n.state.config}},c),doctorStores:w,probes:S,clients:C,bundle:t.path,serving:()=>b.serving(),claudeInput:e.claudeInput(h),history:y,navigation:oe,configFor:e=>ye.getOrCreate(e.projectDir,e.cwd,e.target.path).state.config,reloadConfig:e=>ye.reload(e.projectDir,e.cwd,e.target.path,{kind:`write`}),sourcesFor:e=>ye.getOrCreate(e.projectDir,e.cwd,e.target.path).state.sources,links:le,runs:ue,lanes:{of:(e,t)=>J3(Ee,e,t),clicked:(e,t,n)=>o6(Ee,e,t,n)},views:{follow:(e,t)=>ye.follow(e,t.projectDir,t.cwd,t.target.path)},diagnosticCopy:(e,t,n)=>ye.drawnCopy(e,t,n)},Te=new Nne({owners:ne,update:()=>_e.get(),clock:i,watched:e=>pe.feedOpen(e),deliver:e=>Ee.renderer.deliver({kind:`event`,event:e,at:u()},[[`sid`,e.kind===`world-state`?e.worldState.session:e.session]]),log:p}),Ee={home:c.home,tmp:c.tmp,launcher:h,log:p,clock:i,bundle:t.path,sourceDigest:t.digest,doctorStores:w,stats:m,handlerProbes:S,renderSightings:C,watcherRegistry:T,refreshLedger:ee,fileEvents:te,payloadProviders:ne,sessionState:v,effectSessions:se,menuIdle:ce,journalTurns:Ce,linkSigner:le,runs:ue,sourceRuns:E,laneSetups:de,tmuxStatusLines:fe,frameFeeds:pe,renderWarnings:ge,renderCache:ye,updateWatch:Se,limits:b,verbCtx:we,collector:Te,worldStates:ve,renderer:wre(`main`,Tre({clock:i,log:p,sessionState:v,renderCache:ye,payloadProviders:ne,worldStates:ve,linkSigner:le,renderWarnings:ge,effectSessions:se,frameFeeds:pe,updateWatch:Se,fileEvents:te,menuIdle:ce,launcher:h,laneSetups:de,tmuxStatusLines:fe}),p,e=>Te.subscribed(e))};return{stats:m,launcher:h,log:p,memoryLimitBytes:n,clock:i,exit:a,handle:async(e,t,n,r)=>(d.signal.throwIfAborted(),U6(Ee,e,t,n,r)),reply:async(e,t,n,r)=>(d.signal.throwIfAborted(),W6(Ee,e,t,n,r)),subscribe:(e,t)=>(d.signal.throwIfAborted(),pe.subscribe(e,t)),reloadConfig:e=>{d.signal.throwIfAborted(),we.reloadConfig(e)},arm(){d.signal.throwIfAborted(),te.start(o.watchProbe),xe.arm(),Se.arm(),b.arm()},close(e){let t=[[`journalTurns close`,()=>Ce.close()],[`tmuxStatusLines restore`,()=>fe.restoreAll(e)],[`launches abort`,()=>d.abort(Error(`the daemon closed`))],[`frameFeeds close`,()=>pe.close()],[`menuIdle dispose`,()=>ce.dispose()],[`updateWatch close`,()=>Se.close()],[`binaryWatch close`,()=>xe.close()],[`limits disarm`,()=>b.disarm()],[`collector close`,()=>Te.close()],[`renderCache close`,()=>ye.close()],[`gitService close`,()=>D.close()],[`usageStore close`,()=>re.close()],[`tmuxService close`,()=>ie.close()],[`hostService close`,()=>O.close()],[`runs close`,()=>ue.close()],[`sourceRuns close`,()=>E.close()],[`managedStorage close`,()=>ae.close()],[`fileEvents close`,()=>te.close()],[`watcherRegistry close`,()=>T.closeAll()],[`sessionState close`,()=>v.close()]];for(let[e,n]of t)try{n()}catch(t){p(`warn`,`${e} failed: ${t.message}`)}return f=!0,h.settled()}}}function Ore(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;for(let t of Object.values(e)){if(typeof t!=`object`||!t||Array.isArray(t))return!1;for(let e of Object.values(t))if(typeof e!=`string`)return!1}return!0}var kre=class{clearTimer=null;pending=null;writing=!1;generation=0;writingPath;constructor(e,t,n=500,r=Pe){this.filePath=e,this.clock=t,this.debounceMs=n,this.logger=r,this.writingPath=`${e}.writing`}load(){let e;try{e=s.readFileSync(this.filePath,`utf8`)}catch(e){let t=e.code;return t!==`ENOENT`&&this.logger(`warn`,`session-state read failed (${t}); starting empty`),{}}try{let t=JSON.parse(e);return Ore(t)?t:(this.logger(`warn`,`session-state load: unexpected shape, starting empty`),{})}catch{return this.logger(`warn`,`session-state load: corrupt JSON, starting empty`),{}}}save(e){this.pending=e,this.schedule()}schedule(){this.clearTimer!==null||this.writing||(this.clearTimer=this.clock.after(this.debounceMs,()=>{this.clearTimer=null,this.write()},{unref:!0}))}async write(){let e=this.pending;if(e===null)return;let t=this.generation,n=this.clock.monotonic(),r=JSON.stringify(e),i=this.writingPath;this.writing=!0;let a=A(this.clock,n);try{await s.promises.mkdir(E.dirname(this.filePath),{recursive:!0});let o=await s.promises.open(i,`w`,384);try{await o.writeFile(r),await o.chmod(384),await o.datasync()}finally{await o.close()}let c=!1;if(t===this.generation)try{await s.promises.rename(i,this.filePath),c=!0}catch(e){if(e.code!==`ENOENT`||t===this.generation)throw e}if(t!==this.generation){c||await s.promises.rm(i,{force:!0}),this.logger(`info`,`session-state write superseded by a flush landed=${c} took=${A(this.clock,n)}ms held=${a}ms`);return}this.saved(r,e,n,a),this.pending===e&&(this.pending=null)}catch(e){this.logger(`warn`,`session-state save failed: ${e.message}`)}finally{this.writing=!1,this.pending!==null&&this.pending!==e&&this.schedule()}}flush(){if(this.clearTimer?.(),this.clearTimer=null,this.pending===null)return;let e=this.pending,t=this.clock.monotonic();try{s.mkdirSync(E.dirname(this.filePath),{recursive:!0});let n=`${this.filePath}.tmp`,r=JSON.stringify(e);s.writeFileSync(n,r,{mode:384}),s.chmodSync(n,384),s.rmSync(this.writingPath,{force:!0}),s.renameSync(n,this.filePath),this.generation++,this.saved(r,e,t,A(this.clock,t)),this.pending=null}catch(e){this.logger(`warn`,`session-state save failed: ${e.message}`)}}saved(e,t,n,r){this.logger(`info`,`session-state saved bytes=${Buffer.byteLength(e)} sessions=${Object.keys(t).length} took=${A(this.clock,n)}ms held=${r}ms`)}};function Are(e,t,n){return{session:new kre(e.sessionState,n,500,t),history:HJ(e.settingsHistory,t)}}function e9(e,t,n){for(let r of(t??``).split(E.delimiter)){if(!E.isAbsolute(r))continue;let t=E.join(r,e);if(n(t))return t}return null}function t9(e,t){try{return s.accessSync(e,t),s.statSync(e).isFile()}catch{return!1}}function jre(e){try{return s.realpathSync(e)}catch{return E.resolve(e)}}function Mre(e,t,n){let r=e9(`node`,e,t);return r===null?{kind:`refused`,why:"no `node` on PATH to run the attach launcher"}:E.basename(n(r))===`bun`?{kind:`refused`,why:`the \`node\` on PATH (${r}) is Bun; the attach launcher runs under Node`}:{kind:`node`,file:r}}const n9=2e3;async function r9(e,t,n,r){let i=await bc(e,t,`lane.tmux`,n,r);if(i.kind!==`ok`)throw Error(i.reason);return i.stdout}function i9(e,t){if(t.ok)return t.stdout;let n=Xe(t,t.stdout);throw Error(`${e} failed (${Ze(t)}${n===``?``:`: ${n}`})`)}function Nre(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`ok`in t&&t.ok===!1&&`reason`in t&&typeof t.reason==`string`)return`detail`in t&&typeof t.detail==`string`?`${t.reason}: ${t.detail}`:t.reason}catch{}return null}const Pre=/(?:^|\s)bar-pane\s+["'\\]*(%\d+)["']*\s*$/;function Fre(e,t){return e.split(`
492
- `).flatMap(e=>{let[n,...r]=e.trim().split(` `);return Pre.exec(r.join(` `))?.[1]===t?[n]:[]})}const Ire=/(^|\/)(cc-attach|bun-attach\.js)(\s|$)/;function Lre(e,t,n){for(let r of iY(rY(e),t)){if(r.command.split(` `).some(e=>Ire.test(e)))return!0;if(r.pid===n)return!1}return!1}const Rre=[`import ctypes, json, struct, sys`,`libc = ctypes.CDLL(None)`,`mib = (ctypes.c_int * 3)(1, 49, int(sys.argv[1]))`,`size = ctypes.c_size_t(0)`,`if libc.sysctl(mib, 3, None, ctypes.byref(size), None, 0) != 0: sys.exit('sysctl KERN_PROCARGS2 refused')`,`buf = ctypes.create_string_buffer(size.value)`,`if libc.sysctl(mib, 3, buf, ctypes.byref(size), None, 0) != 0: sys.exit('sysctl KERN_PROCARGS2 refused')`,`raw = buf.raw[:size.value]`,`argc = struct.unpack_from('i', raw)[0]`,`rest = raw[4:]`,`end = rest.index(b'\\0')`,`exe = rest[:end].decode('utf-8', 'surrogateescape')`,`rest = rest[end:].lstrip(b'\\0')`,`words = [w.decode('utf-8', 'surrogateescape') for w in rest.split(b'\\0')]`,`end = words.index('', argc) if '' in words[argc:] else len(words)`,`print(json.dumps({'executable': exe, 'argv': words[:argc], 'env': words[argc:end]}))`].join(`
493
- `);async function zre(e,t){if(process.platform===`linux`)return{executable:await s.promises.readlink(`/proc/${t}/exe`),argv:(await s.promises.readFile(`/proc/${t}/cmdline`,`utf8`)).split(`\0`).slice(0,-1),env:(await s.promises.readFile(`/proc/${t}/environ`,`utf8`)).split(`\0`).slice(0,-1)};let n=i9(`reading process ${t}'s arguments`,await e.launch({bin:`python3`,args:[`-c`,Rre,String(t)],timeoutMs:5e3,category:`lane.process`}));return JSON.parse(n)}async function a9(e,t,n){return i9(t,await e.launch({bin:`ps`,args:n,timeoutMs:2e3,category:`lane.process`}))}async function o9(e,t){let n=await bc(e,t,`lane.tmux`,[`display`,`-p`,`-t`,t.pane,`#{pane_pid} #{pane_current_path}`]);if(n.kind!==`ok`)throw Error(n.reason);let[r=``,i=``]=n.stdout.trimEnd().split(` `),a=(await a9(e,`asking pane ${t.pane}'s foreground job`,[`-o`,`tpgid=`,`-p`,r])).trim();return{panePid:Number(r),cwd:i,foreground:Number(a)}}async function Bre(e,t){let{panePid:n,cwd:r,foreground:i}=await o9(e,t),a=await a9(e,`listing processes`,[`-A`,`-o`,`pid=,ppid=,args=`]),o=await zre(e,i),c=rY(a).get(i)?.ppid;if(c===void 0)throw Error(`pane ${t.pane}'s foreground job ${i} is gone`);return{pid:i,executable:await s.promises.realpath(o.executable),argv:o.argv,env:o.env,cwd:r,parent:c,fromShell:i!==n,attached:Lre(a,i,n)}}function Vre(e,t,n,r,i){let a=e=>Le(r,e,n);return{claudeInput:N$(e),barPanes:async t=>Fre(await r9(e,t,[`list-panes`,`-a`,`-F`,`#{pane_id} #{pane_start_command}`]),t.pane),openBarPane:async(t,n,r)=>(await r9(e,t,[`split-window`,`-d`,`-v`,`-l`,`1`,`-t`,t.pane,`-P`,`-F`,`#{pane_id}`,...Object.entries(r).flatMap(([e,t])=>[`-e`,`${e}=${t}`]),...n])).trim(),closePane:async(t,n)=>void await r9(e,t,[`kill-pane`,`-t`,n]),claude:async(t,n)=>void i9(`claude ${t.join(` `)}`,await e.launch({bin:`claude`,args:[...t],envOverlay:WJ(n),timeoutMs:3e4,category:`lane.claude`})),fileExists:e=>s.existsSync(e),presence:Cz,paneClaude:t=>Bre(e,t),paneDir:async(t,n)=>{let i=r.monotonic()+n9;for(;;){let o=await o9(e,t);if(o.foreground===n){if(o.cwd===``)throw Error(`tmux read no directory for pane ${t.pane}`);return o.cwd}if(r.monotonic()>i)throw Error(`the shell in pane ${t.pane} (pid ${n}) did not take its terminal back within ${n9/1e3} s`);await a(100)}},launcherNode:e=>Mre(e,e=>t9(e,s.constants.X_OK),jre),onPath:(e,t)=>{let n=e9(e,t,e=>t9(e,s.constants.X_OK));return n===null?null:s.realpathSync(n)},followed:async(e,n,i)=>{let o=r.monotonic()+i;for(;!t(e).has(n);){if(r.monotonic()>o)return!1;await a(200)}return!0},moduleGraph:async(t,n,r)=>{let i=await e.launch({bin:t,args:[n,r],timeoutMs:2e4,category:`lane.process`}),a=!i.ok&&i.reason===`non-zero`?Nre(i.stdout):null;return a===null?(i9(`reading ${r}'s module graph`,i),{ok:!0}):{ok:!1,reason:a}},terminate:e=>{n.throwIfAborted();try{process.kill(e,`SIGTERM`)}catch(t){throw Error(`Claude Code (pid ${e}) could not be sent SIGTERM: ${t instanceof Error?t.message:String(t)}`)}},exited:async(e,t)=>{let n=r.monotonic()+t;for(;i.alive(e);){if(r.monotonic()>n)return!1;await a(100)}return!0},typeShellLine:async(t,n)=>void await r9(e,t,j$(t.pane,`cc-candybar-lane`,[]),n)}}const Hre=/^[0-9a-f]{64}$/;function s9(e,t){return se(`sha256`,e).update(JSON.stringify([t.sessionId,t.action,t.declaration,t.evaluated])).digest()}function Ure(e){if(e.length!==32)throw Error(`a link key is 32 bytes, got ${e.length}`);return{sign:t=>s9(e,t).toString(`hex`),verify:(t,n)=>Hre.test(n)?ue(Buffer.from(n,`hex`),s9(e,t)):!1}}function c9(e){return E.join(e,`link.key`)}function l9(e){let t,n=()=>t??=Wre(e);return{sign:e=>n().sign(e),verify:(e,t)=>n().verify(e,t)}}function Wre(e){let t;try{t=s.readFileSync(e)}catch(n){if(n.code!==`ENOENT`)throw n;Gre(e),t=s.readFileSync(e)}if(t.length!==32)throw Error(`link key ${e} holds ${t.length} bytes, not 32: remove it and a new one is made (links drawn before then stop working)`);return Ure(t)}function Gre(e){s.mkdirSync(E.dirname(e),{recursive:!0});let t=`${e}.${process.pid}.${ce(6).toString(`hex`)}`;s.writeFileSync(t,ce(32),{mode:384,flag:`wx`});try{s.linkSync(t,e)}catch(e){if(e.code!==`EEXIST`)throw e}finally{s.unlinkSync(t)}}function Kre(e,t,n){return{daemonLog:t,launcher:e=>It(e,n),storage:t=>Are(e,t,n),doctorStores:fQ(e.state),doctorEdge:wQ,claudeInput:N$,probe:Qs,laneEdge:(e,t,r,i)=>Vre(e,t,r,n,i),linkSigner:l9(c9(e.state)),limits:({startedAtMs:r,exit:i,launcher:a,log:o})=>Xr(r,i,{launcher:a,log:o,clock:n,snapshotDir:e.state,writeLogNow:()=>t.writeNow()}),fetch,stat:s.statSync}}const qre=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`blackBright`,`redBright`,`greenBright`,`yellowBright`,`blueBright`,`magentaBright`,`cyanBright`,`whiteBright`];function u9(e){if(e===void 0)return;let t=H.parse(e);if(t.isDefault)return;let n=t.fixedValue;if(n!==void 0)return n.hex;let r=t.type===V.STANDARD&&t.number!==void 0?qre[t.number]:void 0;if(r===void 0)throw Error(`frames: no band colour for ${t.name}`);return r}const Jre={bold:`bold`,dim:`dimColor`,italic:`italic`,underline:`underline`,strike:`strikethrough`,reverse:`inverse`,blink:null,blink2:null,conceal:null,underline2:null,frame:null,encircle:null,overline:null};function Yre({text:e,fg:t,bg:n,attrs:r=[],link:i}){let a=u9(t),o=u9(n),s={};for(let e of r){let t=Jre[e];if(t===null)throw Error(`frames: the band cannot draw ${e} text`);s[t]=!0}return{text:e,...a!==void 0&&{color:a},...o!==void 0&&{backgroundColor:o},...s,...i!==void 0&&{href:i}}}function Xre(e){return{ok:!0,band:e.rows.map(e=>zP(e).map(Yre))}}function Zre(e){return FP(Xre,e)}const Qre={band:e=>JSON.stringify(Zre(e)),statusline:(e,t)=>t,pane:(e,t)=>t,tmuxStatus:e=>JSON.stringify({ok:!0,tmuxStatus:m7(e)})};function d9(e){let t=null;return e.on(`drain`,()=>{let n=t;t=null,n!==null&&e.write(n)}),n=>{if(e.writable){if(e.writableNeedDrain){t=n;return}e.write(n)}}}function $re(e,t){t.allowHalfOpen=!1;let n=e.clock.monotonic();e.stats.inFlight++;let r=!1,i=!0,a=()=>{i&&(i=!1,e.stats.inFlight--)},o=(n,i,a)=>{if(r){i!==null&&e.log(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`),a(!1);return}r=!0,l();let o=i===null?void 0:()=>e.exit(i);try{t.end(er(n),e=>{a(e==null),o?.()})}catch(t){e.log(`warn`,`response write failed: ${t.message}`),a(!1),o?.()}},s=!1,c=!0,l=e.clock.after(200,()=>{s=!0,e.stats.requestsTimedOut++,c&&o({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null,u6)}),u=nr(r=>{let i=Zn(r);c=i.kind===`request`,e.handle(i,()=>s,n,()=>c&&t.destroyed).then(e=>{if(!c){e.kind===`reply`&&e.settled(!1);return}e.kind===`reply`?o(e.resp,e.exitAfterFlush,e.settled):d(e.sessionId,e.lane)}).catch(t=>{e.log(`error`,`handler threw: ${x(t)}`),c&&o(U3(t),null,u6)}).finally(()=>{c||(l(),a())})},t=>{e.log(`warn`,`frame parse failed: ${t.message}`),o({ok:!1,error:t.message,code:`BAD_REQUEST`,daemonV:3},null,u6)}),d=(n,i)=>{if(r||t.destroyed)return;l(),a(),t.off(`data`,u);let o=d9(t),s=e.subscribe(n,{lane:i,frame:(e,t)=>o(tr(Qre[i](e,t))),refused:e=>t.end(er(e)),drawing:()=>!0});r=!0,t.on(`close`,s)};t.on(`data`,u),t.on(`error`,t=>{e.log(`warn`,`socket error: ${t.message}`)}),t.on(`close`,()=>{c&&(l(),a())})}const f9=`CC_CANDYBAR_PARENT_PID`;function eie(e){let t=e[f9];if(t===void 0)return{kind:`outlives-nobody`};let n=Number.parseInt(t,10);if(!Number.isInteger(n)||n<=0)throw Error(`${f9} must be a positive integer pid, got ${JSON.stringify(t)}`);return{kind:`anchored`,pid:n}}function tie(e){if(e.anchor.kind===`outlives-nobody`)return{disarm:()=>{}};let{pid:t}=e.anchor;return{disarm:e.clock.every(e.intervalMs??250,()=>{e.probe.alive(t)||e.onOrphaned(`spawner pid ${t} gone`)},{unref:!0})}}let p9=null,m9=null,h9=null,g9=null;function _9(){if(g9===null)throw Error(`runDaemon has not started`);return g9}function v9(e,t){_9().log.log(e,t)}function nie(){let e=i(import.meta.url);return{entryUrl:import.meta.url,digest:an(),path:e,node:[t.execPath,...t.execArgv],targets:[...new Set([e,...t.argv[1]?[t.argv[1]]:[]])]}}function rie(e){let n=N(e.host);g9={world:e,paths:n,log:new gc(n.log,e.clock)},t.on(`uncaughtException`,e=>{v9(`error`,`uncaughtException: ${e.stack||e.message}`),S9(1)}),t.on(`unhandledRejection`,e=>{v9(`error`,`unhandledRejection: ${String(e)}`),S9(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{v9(`info`,`received ${e}, shutting down`),S9(0)});iie().catch(y9)}function y9(e){v9(`error`,`refusing to boot: ${x(e)}`),S9(1)}async function iie(){let{world:e,paths:n,log:r}=_9(),{host:i}=e,a=Ir(i.env);p9=await ec(t.pid,Qs(e.launcher).startTime);let o=await oc(cc(e,p9,n.registry));if(!o.decision.allow){v9(`warn`,`fork-bomb breaker: ${o.decision.reason}; refusing to boot`),S9(1);return}m9=o.registryPath,s.mkdirSync(n.state,{recursive:!0}),hn(n.socket);let c=Dre({...Kre(n,r,e.clock),bundle:nie(),host:i,paths:n,memoryLimitBytes:a,registryUrl:i.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,clock:e.clock,gates:Sz(),exit:S9});h9=c,tie({clock:e.clock,anchor:eie(i.env),probe:Qs(e.launcher),onOrphaned:e=>{v9(`info`,`parent watchdog: ${e}; shutting down`),S9(0)}}),b9(c,de.createServer(e=>$re(c,e)),n.socket,!1)}function b9(e,n,r,i){n.removeAllListeners(`error`),n.removeAllListeners(`listening`),n.once(`error`,a=>{if(a.code!==`EADDRINUSE`){v9(`error`,`server error: ${a.message}`),S9(1);return}if(i){v9(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}aie(e,n,r).catch(y9)}),n.listen(r,()=>oie(e,r))}async function aie(e,n,r){let i=await Us(Ws(gn(r)),(t,n)=>$s(t,n,Qs(e.launcher)));if(i.kind===`attach-and-exit`){v9(`info`,`EADDRINUSE: ${i.reason} — exiting`),t.exit(0);return}v9(`warn`,`EADDRINUSE: ${i.reason} — unlinking stale socket and rebinding`);try{s.unlinkSync(r)}catch(e){if(e.code!==`ENOENT`){v9(`error`,`cannot unlink stale socket ${r}: ${e.message}`),S9(1);return}}b9(e,n,r,!0)}function oie(e,n){let r=qs(n);if(r.kind!==`present`){v9(`warn`,`no ownable socket at bind callback (${r.kind}); exiting`),S9(0);return}cie(n);try{s.chmodSync(n,384)}catch(e){v9(`warn`,`chmod socket failed: ${e.message}`)}v9(`info`,`daemon up: pid=${t.pid} v=3 sock=${n} heapCap=${Fr(fe.getHeapStatistics().heap_size_limit)}MB memoryLimit=${Fr(e.memoryLimitBytes)}MB`),ai(_9().paths.spawnBackoff),e.arm(),sie(n,r.identity)}function sie(e,n){Xs({bound:n,myPid:t.pid,readIdentity:()=>qs(e),readLease:()=>Ws(gn(e)),shutdown:e=>S9(e),log:v9,clock:_9().world.clock}).arm()}function cie(e){let n=Gs(gn(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:p9});n!==null&&v9(`warn`,`lease write failed: ${n}`)}const lie=e=>(t,n,r)=>yc(e,{socket:t},`tmux-status`,n,r);let x9=!1;function S9(e){x9||(x9=!0,_9().world.clock.after(500,()=>t.kill(t.pid,`SIGKILL`)),h9?.close(lie(_9().world.launcher)),Ks(_9().paths.lease,t.pid),m9!==null&&sc(m9,t.pid,ic,e=>s.unlinkSync(e)),t.exit(e))}const uie={connectMs:200,budgetMs:500};async function die(e,t,n){return fie(t,await pie(e,t),n.includes(`--json`))}function fie(e,t,n){return t.kind===`ok`?{stdout:n?JSON.stringify(t.value,null,2)+`
494
- `:mie(t.value),stderr:``,code:0}:{stdout:``,stderr:`${e}: ${fr(t)}\n`,code:1}}function pie(e,t){return ar(e,()=>({kind:`debug`,what:t}),uie,e=>`debug`in e?e.debug:void 0)}function mie(e){switch(e.what){case`vars`:return hie(e.vars);case`segments`:return gie(e.segments);case`config`:return _ie(e.config);default:return e}}function hie(e){if(e.length===0)return`no variables (DSL not active)
495
- `;let t=[`variables (${e.length})`,``],n=e.reduce((e,t)=>Math.max(e,t.name.length),4),r=e.reduce((e,t)=>Math.max(e,(t.source??`—`).length),6),i=e.reduce((e,t)=>Math.max(e,t.type.length),4);for(let a of e){let e=a.ageMs===null?``:` ${yie(a.ageMs)}`,o=a.lastError?` ✗ ${a.lastError.message}`:``;t.push(` ${a.name.padEnd(n)} ${(a.source??`—`).padEnd(r)} ${a.type.padEnd(i)} ${vie(a.value)}${e}${o}`)}return t.join(`
489
+ `)){let[t,n,i]=e.trim().split(` `);t!==void 0&&n===`0`&&i!==void 0&&r.set(t,i)}return{sessionOf:n,shownBy:r}}var Rne=class{servers=new Map;loop={kind:`idle`};constructor(e){this.deps=e}follow(){switch(this.loop.kind){case`idle`:this.deps.log(`info`,`visibility following`),this.ask();break;case`asking`:this.loop.following=!0;break;case`due`:break}return()=>this.stop()}stop(){switch(this.loop.kind){case`due`:this.loop.clear(),this.end();return;case`asking`:this.loop.following=!1;return;case`idle`:return}}ask(){let e={kind:`asking`,following:!0};this.loop=e,Promise.resolve().then(()=>this.refresh(this.deps.sockets())).catch(e=>this.deps.log(`error`,`visibility refresh threw: ${x(e)}`)).then(()=>{if(e.following){this.loop={kind:`due`,clear:this.deps.clock.after(this.deps.intervalMs,()=>this.ask(),{unref:!0})};return}this.end()})}end(){this.deps.log(`info`,`visibility stopped forgot=${this.servers.size}`),this.loop={kind:`idle`},this.servers.clear()}shown(e){if(e==null)return!0;let t=this.servers.get(e.socket);return t?.kind!==`asked`||t.shown.has(e.pane)}async refresh(e){for(let t of this.servers.keys())e.has(t)||this.servers.delete(t);let t=await Promise.all([...e].map(async e=>{let[t,n]=await Promise.all([this.deps.listPanes(e),this.deps.listClients(e)]);return[e,t.kind===`ok`?n.kind===`ok`?{kind:`asked`,shown:f7(t.stdout,d7(n.stdout)),status:Lne(t.stdout,n.stdout)}:{kind:`unasked`,reason:n.reason}:{kind:`unasked`,reason:t.reason}]})),n=new Set;for(let[e,r]of t){let t=this.servers.get(e);this.servers.set(e,r),!zne(t,r)&&(n.add(e),this.deps.log(r.kind===`asked`?`info`:`warn`,r.kind===`asked`?`visibility socket=${JSON.stringify(e)} shown=${[...r.shown].join(`,`)||`-`}`:`visibility socket=${JSON.stringify(e)} unasked: ${r.reason} — its panes count as shown`))}for(let[e,n]of t)n.kind===`asked`&&this.deps.onAnswer(e,n.status);n.size>0&&this.deps.onChange(n)}};function zne(e,t){return e===void 0||e.kind!==t.kind?!1:e.kind===`unasked`||t.kind===`unasked`?!0:e.shown.size===t.shown.size&&[...e.shown].every(e=>t.shown.has(e))}function Bne(e){return`ccb`+ae(`sha256`).update(e).digest(`hex`).slice(0,12)}const Vne=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightblack`,`brightred`,`brightgreen`,`brightyellow`,`brightblue`,`brightmagenta`,`brightcyan`,`brightwhite`];function p7(e){if(e===void 0)return`terminal`;let t=H.parse(e);if(t.isDefault)return`terminal`;switch(t.type){case V.STANDARD:{let e=t.number===void 0?void 0:Vne[t.number];if(e!==void 0)return e;break}case V.EIGHT_BIT:if(t.number!==void 0)return`colour${t.number}`;break;case V.TRUECOLOR:{let e=t.fixedValue;if(e!==void 0)return e.hex;break}case V.DEFAULT:case V.WINDOWS:break}throw Error(`frames: no tmux colour for ${t.name}`)}const Hne={bold:`bold`,dim:`dim`,italic:`italics`,underline:`underscore`,strike:`strikethrough`,reverse:`reverse`,blink:`blink`,conceal:`hidden`,underline2:`double-underscore`,overline:`overline`,blink2:null,frame:null,encircle:null};function Une(e){return e.replaceAll(`#`,`##`)}function Wne({fg:e,bg:t,attrs:n=[]}){let r=n.map(e=>{let t=Hne[e];if(t===null)throw Error(`frames: a tmux status line cannot draw ${e} text`);return t});return`#[${[`none`,`fg=${p7(e)}`,`bg=${p7(t)}`,...r].join(`,`)}]`}function Gne(e){let t={},n=e=>{let n=Wne(e)+Une(e.text);if(e.link===void 0)return n;let r=Bne(e.link);return t[r]=e.link,`#[range=user|${r}]${n}#[norange]`};return{rows:e.rows.map(e=>zP(e).map(n).join(``)),links:t}}function m7(e){return FP(Gne,e)}const h7=Xb.tmuxStatus.rows,g7=`@cc-candybar-status-prior`,_7=`@cc-candybar-status-wrote`,v7=`@cc-candybar-binding-prior`,y7=[`-T`,`root`,`MouseDown1Status`],b7=Array.from({length:h7},(e,t)=>t),x7=e=>`@cc-candybar-row-${e}`,Kne=e=>`#[fill=terminal]#{${x7(e)}}`,S7=e=>`status-format[${e}]`;function qne(e){return e===0?`off`:e===1?`on`:String(e)}function C7(e){let t=e===`off`?0:e===`on`?1:/^[2-5]$/.test(e)?+e:NaN;if(Number.isNaN(t))throw Error(`tmux status is ${JSON.stringify(e)}`);return t}function Jne(e,t){if(e===null)return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[Number(n)]===t[Number(n)])}function w7(e){return e.endsWith(`;`)?`${e.slice(0,-1)}\\;`:e}function T7(e){return e.flatMap((e,t)=>[...t===0?[]:[`;`],...e])}function E7(e){return`"${e.replace(/[\\"$]/g,e=>`\\${e}`)}"`}function Yne(e){return e.map(e=>e.map(E7).join(` `)).join(` ; `)}const D7=`ccb:separator`;function O7(e){return T7(e.flatMap((e,t)=>t===0?[e]:[[`display-message`,`-p`,D7],e]))}function k7(e,t){let n=e.split(`${D7}\n`);return n.length===t?n.map(e=>e.replace(/\n$/,``)):null}const A7=(e,t)=>[`show-options`,`-q`,`-v`,`-t`,e,t],j7=e=>[`show-options`,`-g`,`-q`,`-v`,e],M7=e=>[[`show-options`,`-t`,e],A7(e,`status`),...b7.map(t=>A7(e,S7(t)))];function N7(e){let[t=``,n=``,...r]=e,i=t.split(`
490
+ `).map(e=>e.split(` `)[0]??``),a={};for(let e of b7)i.includes(S7(e))&&(a[e]=r[e]??``);let o=i.includes(`status-format`)||Object.keys(a).length>0;return{status:i.includes(`status`)?n:null,formats:o?a:null}}function P7(e,t){return[[`set-option`,`-u`,`-t`,e,`status-format`],...Object.entries(t??{}).map(([t,n])=>[`set-option`,`-t`,e,S7(Number(t)),w7(n)])]}const Xne=e=>[[`display-message`,`-p`,`-t`,e,`#{status}`],...M7(e),...b7.map(e=>j7(S7(e))),A7(e,g7),A7(e,_7)];function F7(e,t,n){let r,i;try{r=JSON.parse(e),i=t===``?r.base:C7(t)}catch(e){return{kind:`theirs`,why:`${g7} does not read (${String(e)})`}}return r.owner===n?{kind:`ours`,prior:r,status:i}:{kind:`theirs`,why:`the daemon at ${JSON.stringify(r.owner)} draws it`}}function Zne(e,t,n){let[r=``,...i]=t,a=N7(i.slice(0,2+h7)),o=i.slice(2+h7,2+2*h7),[s=``,c=``]=i.slice(2+2*h7);if(s!==``)return F7(s,c,n);let l=C7(r),u={};for(let e=0;e<l;e++){let t=a.formats===null?o[e]:a.formats[e];t!==void 0&&t!==``&&(u[e]=t)}let d={...u,...Object.fromEntries(Array.from({length:h7-l},(e,t)=>[l+t,Kne(t)]))},f={owner:n,base:l,status:a.status,formats:a.formats,wrote:d};return{kind:`lay-out`,prior:f,commands:[[`set-option`,`-t`,e,g7,JSON.stringify(f)],...P7(e,d)]}}const I7=e=>[...M7(e),A7(e,_7)];function L7(e,t,n){let r=N7(n.slice(0,2+h7)),i=n[2+h7]??``,a=[],o=[];if(Jne(r.formats,t.wrote))a.push(...P7(e,t.formats));else{o.push(`status-format`);for(let[n,i]of Object.entries(r.formats??{}))Number(n)>=t.base&&i===t.wrote[Number(n)]&&a.push([`set-option`,`-u`,`-t`,e,S7(+n)])}return i!==``&&(r.status===i?a.push(t.status===null?[`set-option`,`-u`,`-t`,e,`status`]:[`set-option`,`-t`,e,`status`,w7(t.status)]):o.push(`status`)),a.push(...b7.map(t=>[`set-option`,`-q`,`-u`,`-t`,e,x7(t)]),[`set-option`,`-q`,`-u`,`-t`,e,g7],[`set-option`,`-q`,`-u`,`-t`,e,_7]),{commands:a,kept:o}}const Qne=/^bind-key\s+(?:-r\s+)?(?:-N\s+(?:"(?:[^"\\]|\\.)*"|\S+)\s+)?-T\s+root\s+MouseDown1Status\s+(.+)$/m,R7=[[`list-keys`,`-T`,`root`]];function z7(e){let t=Qne.exec(e);return t===null?null:{line:t[0],command:t[1]}}const B7=`cc-candybar://tmux-status-click/`,$ne=e=>`${B7}${Ca([e])}/#{s/%//:pane_id}/#{q:mouse_status_range}`,V7=e=>e?.command.includes(B7)??!1;function H7(e,t){let n={command:[`set-option`,`-g`,`-q`,`-u`,v7]};return V7(z7(t))?{steps:[e===null?{command:[`unbind-key`,...y7]}:{command:[`source-file`,`-`],stdin:`${e.line}\n`},n],said:`restored MouseDown1Status to ${e===null?`unbound`:JSON.stringify(e.line)}`}:{steps:[n],said:`left MouseDown1Status as it is: bound again since`}}var ere=class{held=new Map;servers=new Map;closed=!1;writes=0;failedWrites=0;constructor(e){this.deps=e}observe(e,t,n){if(this.closed)return;let r=this.held.get(e),i=n&&t!=null?t:null;if(r!==void 0&&(i===null||r.socket!==i.socket||r.pane!==i.pane)&&this.release(r,`switched off or moved`),i===null||this.held.has(e))return;let a={sessionId:e,socket:i.socket,pane:i.pane,unsubscribe:null,frame:null};this.held.set(e,a),this.serverOf(i.socket),this.deps.log(`info`,`tmux-status: holding sid=${JSON.stringify(e)} pane=${i.pane} socket=${JSON.stringify(i.socket)}`),a.unsubscribe=this.deps.subscribe(e,{lane:`tmuxStatus`,frame:e=>{a.frame=m7(e),this.reconcile(a.socket)},refused:t=>{this.held.get(e)===a&&this.release(a,`refused: ${t.error}`)},drawing:()=>this.draws(a)})}answered(e,t){if(this.closed)return;let n=this.serverOf(e);n.view=t;for(let n of[...this.held.values()])if(n.socket===e)if(!t.sessionOf.has(n.pane))this.release(n,`pane gone`);else{let t=this.deps.sessionInPane(e,n.pane);t!==null&&t!==n.sessionId&&this.release(n,`pane taken by sid=${JSON.stringify(t)}`)}this.reconcile(e)}draws(e){let t=this.servers.get(e.socket),n=t?.view?.sessionOf.get(e.pane);return n!==void 0&&t.layouts.has(n)&&t.view.shownBy.get(n)===e.pane}restoreAll(e){this.closed=!0;for(let e of this.held.values())e.unsubscribe?.();this.held.clear();for(let[t,n]of this.servers){for(let[r,i]of[...n.layouts]){n.layouts.delete(r);let a=this.askSync(e,t,I7(r));if(a===null)continue;let o=L7(r,i.prior,a);this.writeSync(e,t,o.commands),this.saidRestored(t,r,o.kept)}let r=n.binding;if(n.binding={kind:`none`},r.kind===`ours`||r.kind===`adopted`){let n=this.askSync(e,t,R7);if(n===null)continue;this.writeBindingRestoreSync(e,t,r.prior,n[0]??``)}}}linkAt(e){let t=tre(e),[n,r,i,...a]=t??[];if(t===null||n===void 0||r===void 0||i===void 0||a.length>0)return{kind:`refused`,reason:`tmux-status-click needs <socket>/<pane>/<range>, got ${JSON.stringify(e)}`};let o=[...this.held.values()].find(e=>e.socket===n&&e.pane===`%${r}`)?.frame?.links[i];return o===void 0?{kind:`refused`,reason:`pane %${r}'s status line draws no link ${i} now`}:{kind:`link`,url:o}}stats(){return{sessions:this.held.size,layouts:[...this.servers.values()].reduce((e,t)=>e+t.layouts.size,0),writes:this.writes,failedWrites:this.failedWrites}}async settled(){for(let e of this.servers.values())await e.running}serverOf(e){let t=this.servers.get(e);if(t!==void 0)return t;let n={view:null,adopted:!1,layouts:new Map,left:new Map,binding:{kind:`none`},running:null,again:!1,lastFailure:null};return this.servers.set(e,n),n}release(e,t){e.unsubscribe?.(),this.held.delete(e.sessionId),this.deps.log(`info`,`tmux-status: released sid=${JSON.stringify(e.sessionId)} pane=${e.pane} — ${t}`),this.reconcile(e.socket)}reconcile(e){let t=this.servers.get(e);if(!(t===void 0||this.closed)){if(t.running!==null){t.again=!0;return}t.running=(async()=>{try{do t.again=!1,await this.step(e,t);while(t.again&&!this.closed)}catch(t){this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} reconcile threw: ${String(t)}`)}finally{t.running=null}})()}}async step(e,t){let n=t.view;if(n===null)return;t.adopted||(t.adopted=!0,await this.adopt(e,t));let r=new Map;for(let t of this.held.values()){if(t.socket!==e)continue;let i=n.sessionOf.get(t.pane);i!==void 0&&r.set(i,[...r.get(i)??[],t])}for(let i of new Set([...t.layouts.keys(),...t.left.keys(),...r.keys()])){if(this.closed)return;let a=r.get(i)??[],o=t.layouts.get(i);if(a.length===0){t.left.delete(i),o!==void 0&&await this.restore(e,t,i);continue}if(t.left.has(i))continue;let s=o??await this.install(e,t,i);if(s===null)continue;let c=a.find(e=>e.pane===n.shownBy.get(i))?.frame?.rows.slice(0,h7-s.prior.base)??[];await this.draw(e,i,s,c)}this.closed||(t.layouts.size>0?await this.installBinding(e,t):await this.restoreBinding(e,t))}async adopt(e,t){let n=await this.run(e,[`list-sessions`,`-F`,`#{session_id}\t#{${g7}}\t#{${_7}}`]);if(n.kind===`ok`)for(let r of n.stdout.split(`
491
+ `)){let[n,i,a=``]=r.split(` `);if(n===void 0||i===void 0||i===``)continue;let o=F7(i,a,this.deps.owner);o.kind===`ours`?t.layouts.set(n,{prior:o.prior,rows:[],status:o.status}):this.leave(e,t,n,o.why)}let r=(await this.ask(e,[j7(`@cc-candybar-binding-prior`)]))?.[0]??``;if(r!==``)try{let e=JSON.parse(r);e.owner===this.deps.owner&&(t.binding={kind:`adopted`,prior:e.prior})}catch(t){this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${v7} does not read (${String(t)}), left as it is`)}(t.layouts.size>0||t.binding.kind===`adopted`)&&this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} took over layouts=${[...t.layouts.keys()].join(`,`)||`-`} binding=${t.binding.kind}`)}leave(e,t,n,r){t.left.set(n,r),this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} session ${n} left as it is: ${r}`)}async install(e,t,n){let r=await this.ask(e,Xne(n));if(r===null||this.closed)return null;let i=Zne(n,r,this.deps.owner);if(i.kind===`theirs`)return this.leave(e,t,n,i.why),null;let a={prior:i.prior,rows:[],status:i.kind===`ours`?i.status:i.prior.base};return t.layouts.set(n,a),i.kind===`lay-out`&&await this.write(e,i.commands),this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} ${i.kind===`ours`?`took over`:`laid out`} session ${n} base=${i.prior.base} own=${[i.prior.status===null?[]:[`status`],i.prior.formats===null?[]:[`status-format`]].flat().join(`,`)||`-`}`),a}async draw(e,t,n,r){let i=n.prior.base+r.length,a=[];if(r.forEach((e,r)=>{n.rows[r]!==e&&a.push([`set-option`,`-t`,t,x7(r),e])}),i!==n.status){let e=qne(i);a.push([`set-option`,`-t`,t,`status`,e],[`set-option`,`-t`,t,_7,e])}(a.length===0||await this.write(e,[[`if-shell`,`-F`,`-t`,t,`#{@cc-candybar-status-prior}`,Yne(a)]]))&&(n.rows=r,n.status=i)}async restore(e,t,n){let r=t.layouts.get(n);if(r===void 0)return;t.layouts.delete(n);let i=await this.ask(e,I7(n));if(i===null)return;let a=L7(n,r.prior,i);await this.write(e,a.commands),this.saidRestored(e,n,a.kept)}saidRestored(e,t,n){this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} restored session ${t} kept=${n.join(`,`)||`-`}`)}async installBinding(e,t){let n=t.binding;if(n.kind===`ours`||n.kind===`left`)return;let r=await this.ask(e,R7);if(r===null||this.closed)return;let i=z7(r[0]??``);if(n.kind===`none`&&V7(i)){t.binding={kind:`left`,why:`another cc-candybar daemon's status-line clicks are bound to MouseDown1Status; left as it is, so this daemon's are off`},this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${t.binding.why}`);return}let a=n.kind===`adopted`&&V7(i)?n.prior:i,o={owner:this.deps.owner,prior:a};if(t.binding={kind:`ours`,prior:a},!await this.write(e,[[`bind-key`,...y7,`if-shell`,`-F`,`#{m:ccb*,#{mouse_status_range}}`,`run-shell -b ${E7(`${this.deps.handler} ${$ne(e)}`)}`,...a===null?[]:[a.command]],[`set-option`,`-g`,`@cc-candybar-binding-prior`,JSON.stringify(o)]])){t.binding=n;return}this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} bound MouseDown1Status (was ${a===null?`unbound`:JSON.stringify(a.line)})`)}async restoreBinding(e,t){let n=t.binding;if(t.binding={kind:`none`},n.kind!==`ours`&&n.kind!==`adopted`)return;let r=await this.ask(e,R7);if(r===null)return;let i=H7(n.prior,r[0]??``);for(let t of i.steps)await this.write(e,[t.command],t.stdin);this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(e)} ${i.said}`)}writeBindingRestoreSync(e,t,n,r){let i=H7(n,r);for(let n of i.steps)this.writeSync(e,t,[n.command],n.stdin);this.deps.log(`info`,`tmux-status: socket=${JSON.stringify(t)} ${i.said}`)}counted(e,t){let n=this.serverOf(e);return t.kind===`ok`?(n.lastFailure=null,t):(this.failedWrites++,n.lastFailure!==t.reason&&this.deps.log(`warn`,`tmux-status: socket=${JSON.stringify(e)} ${t.reason}`),n.lastFailure=t.reason,t)}async run(e,t,n){return this.counted(e,await this.deps.edge.run(e,t,n))}async ask(e,t){let n=await this.run(e,O7(t));return n.kind===`ok`?k7(n.stdout,t.length):null}askSync(e,t,n){let r=this.counted(t,e(t,O7(n)));return r.kind===`ok`?k7(r.stdout,n.length):null}async write(e,t,n){return t.length===0?!0:(this.writes++,(await this.run(e,T7(t),n)).kind===`ok`)}writeSync(e,t,n,r){n.length!==0&&(this.writes++,this.counted(t,e(t,T7(n),r)))}};function tre(e){try{return wa(e)}catch(e){if(e instanceof URIError)return null;throw e}}const $=e=>({arity:e,keep:!0}),U7=e=>({arity:e,keep:!1}),nre={"--add-dir":$(`variadic`),"--agent":$(`one`),"--agents":$(`one`),"--allow-dangerously-skip-permissions":$(`none`),"--allowedTools":$(`variadic`),"--allowed-tools":$(`variadic`),"--append-system-prompt":$(`one`),"--autocompact":$(`one`),"--ax-screen-reader":$(`none`),"--bg":U7(`none`),"--background":U7(`none`),"--bare":$(`none`),"--betas":$(`variadic`),"--brief":$(`none`),"--chrome":$(`none`),"--cloud":U7(`optional`),"-c":U7(`none`),"--continue":U7(`none`),"--dangerously-skip-permissions":$(`none`),"-d":$(`optional`),"--debug":$(`optional`),"--debug-file":$(`one`),"--desktop":U7(`none`),"--disable-slash-commands":$(`none`),"--disallowedTools":$(`variadic`),"--disallowed-tools":$(`variadic`),"--effort":$(`one`),"--environment":U7(`one`),"--exclude-dynamic-system-prompt-sections":$(`none`),"--fallback-model":$(`one`),"--file":$(`variadic`),"--fork-session":U7(`none`),"--forward-subagent-text":$(`none`),"--from-pr":U7(`optional`),"-h":U7(`none`),"--help":U7(`none`),"--ide":$(`none`),"--include-hook-events":$(`none`),"--include-partial-messages":$(`none`),"--input-format":$(`one`),"--json-schema":$(`one`),"--max-budget-usd":$(`one`),"--mcp-config":$(`variadic`),"--model":$(`one`),"-n":$(`one`),"--name":$(`one`),"--no-chrome":$(`none`),"--no-session-persistence":$(`none`),"--output-format":$(`one`),"--permission-mode":$(`one`),"--permission-prompts":$(`one`),"--plugin-dir":$(`one`),"--plugin-url":$(`one`),"-p":U7(`none`),"--print":U7(`none`),"--prompt-suggestions":$(`optional`),"--remote-control":$(`optional`),"--remote-control-session-name-prefix":$(`one`),"--replay-user-messages":$(`none`),"--restricted":$(`none`),"-r":U7(`optional`),"--resume":U7(`optional`),"--safe-mode":$(`none`),"--session-id":U7(`one`),"--setting-sources":$(`one`),"--settings":$(`one`),"--strict-mcp-config":$(`none`),"--system-prompt":$(`one`),"--system-prompt-snapshot":$(`one`),"--teleport":U7(`optional`),"--tmux":U7(`none`),"--tools":$(`variadic`),"--verbose":$(`none`),"-v":U7(`none`),"--version":U7(`none`),"-w":U7(`optional`),"--worktree":U7(`optional`)},rre={resume:`--resume`,fresh:`--session-id`};function ire(e){return[rre[e.kind],e.sessionId]}const W7=e=>e.startsWith(`-`)&&e!==`-`;function G7(e,t){let n=K7(t);return n===null?{dir:e??t,args:[]}:e!==null&&are(e,n.top)?{dir:e,args:[]}:{dir:e===null||K7(e)!==null?n.repo:e,args:[`--worktree`,n.name]}}const are=(e,t)=>e===t||e.startsWith(t+E.sep);function ore(e){let t=[],n=e.slice(1),r=0;for(;r<n.length;){let e=n[r];if(r+=1,e===`--`)break;if(!W7(e))continue;let i=e.indexOf(`=`),a=i===-1?e:e.slice(0,i),o=nre[a];if(o===void 0)return{kind:`refused`,reason:`Claude Code was started with ${a}, which cc-candybar does not know how to carry to a restart`};let s=i===-1?o.arity===`one`?n.slice(r,r+1):o.arity===`optional`?n.slice(r,r+1).filter(e=>!W7(e)):o.arity===`variadic`?sre(n.slice(r),e=>!W7(e)):[]:[];if(o.arity===`one`&&i===-1&&s.length===0)return{kind:`refused`,reason:`Claude Code was started with ${a} and no value after it`};r+=s.length,o.keep&&t.push(e,...s)}return{kind:`args`,args:t}}function K7(e){let t=e.split(E.sep),n=t.findLastIndex((e,n)=>e===`worktrees`&&t[n-1]===`.claude`&&n+1<t.length);return n===-1?null:{name:t[n+1].replaceAll(`+`,`/`),top:t.slice(0,n+2).join(E.sep),repo:t.slice(0,n-1).join(E.sep)||E.sep}}function sre(e,t){let n=e.findIndex(e=>!t(e));return n===-1?[...e]:e.slice(0,n)}const q7=`candybar-band@cc-candybar`,J7=E.join(`bin`,`cc-candybar-native`),cre=dI(`/reload-plugins`),Y7=e=>({kind:`done`,said:e});function X7(e){let t=D$(e.hints.tmux);if(t.kind===`refused`)throw new Z(t.reason);return t.hint}const lre={band:{on:async(e,t,n)=>{let r=nn(t.bundle);if(r===null)throw new Z(`${Xb.band.label} runs the band mod from a cc-candybar source checkout, and this daemon runs ${t.bundle} — run the daemon from a checkout (mod/README.md)`);let i=E.join(r,J7);if(!n.fileExists(i))throw new Z(`the band mod starts ${i}, which is not built — run \`just install-rust\` in ${r}`);return{kind:`underway`,said:`installing ${q7} from ${r}`,finished:ure(e,r,n)}},off:async()=>Y7(`nothing to stop: the band mod draws nothing while the lane is off`)},statusline:{on:async(e,t,n)=>{let r=X7(e),i=j(t.preload),a=[t.preload,i].find(e=>!n.fileExists(e));if(a!==void 0)throw new Z(`${Xb.statusline.label} restarts Claude Code under the attach launcher, and ${a} is not there — run \`cc-candybar install\` (in a checkout, \`pnpm build\`)`);return{kind:`underway`,said:`restarting Claude Code in ${r.pane} under the attach launcher`,finished:pre(e,r,{node:t.node[0],launcher:i,preload:t.preload},n)}},off:async()=>Y7(`nothing to stop: the attached statusline draws its command's output while the lane is off`)},pane:{on:async(e,t,n)=>{let r=X7(e),i=await n.barPanes(r);return i.length>0?Y7(`bar pane ${i.join(`, `)} already draws ${r.pane}'s bar`):Y7(`opened bar pane ${await n.openBarPane(r,[...t.node,t.bundle,`bar-pane`,r.pane],{CC_CANDYBAR_SOCKET:t.socket})} under ${r.pane}`)},off:async(e,t,n)=>{let r=D$(e.hints.tmux);if(r.kind===`refused`)return Y7(`no bar pane to close: ${r.reason}`);let i=r.hint,a=await n.barPanes(i);for(let e of a)await n.closePane(i,e);return Y7(a.length===0?`no bar pane draws ${i.pane}'s bar`:`closed bar pane ${a.join(`, `)}`)}},tmuxStatus:{on:async e=>Y7(`the daemon draws ${X7(e).pane}'s bar in its status line`),off:async()=>Y7(`nothing to stop: the daemon puts the status line back once the lane is off`)}};async function ure(e,t,n){let r={sessionId:e.sessionId,projectDir:e.origin.projectDir,claudeConfigDir:e.hints.claudeConfigDir};await n.claude([`plugin`,`marketplace`,`add`,t],r),await n.claude([`plugin`,`install`,q7],r);let i=await O$(n.claudeInput,e.hints.tmux,cre);if(i.kind===`refused`)throw Error(`the band mod is installed, but /reload-plugins was not typed: ${i.reason} — or type /reload-plugins yourself`);return`installed ${q7} from ${t} and typed /reload-plugins into ${i.pane}`}const dre=new Set([Yo,lP]);function fre(e){return new Map(e.flatMap(e=>{let t=e.indexOf(`=`);return t>0?[[e.slice(0,t),e.slice(t+1)]]:[]}))}async function pre(e,t,n,r){let i=await r.paneClaude(t);if(i.attached)return`left Claude Code in ${t.pane} running: it already runs under the attach launcher`;if(!i.fromShell)throw Error(`Claude Code is the first process of pane ${t.pane}, so nothing would be left in the pane to start it again under the attach launcher — start Claude Code from a shell in the pane`);let a=await r.moduleGraph(n.node,Wt(n.launcher),i.executable);if(!a.ok)throw Error(`Claude Code in ${t.pane} runs ${i.executable}, which the attach launcher cannot start (${a.reason}) — ${Xb.statusline.label} needs the native Claude Code install (\`claude install\`), so it was left running`);if((await r.paneClaude(t)).pid!==i.pid)throw Error(`Claude Code in ${t.pane} is no longer the process the restart read (pid ${i.pid}), so it was not restarted under the attach launcher`);let o=vre(await r.claudeInput.read(t));if(o!==null)throw Error(`Claude Code in ${t.pane} was left running: ${o} — then turn ${Xb.statusline.label} off and on again`);let s=mre(e,r.presence(e.transcript));if(s!==null)throw Error(`Claude Code in ${t.pane} was left running: ${s}`);let c=ore(i.argv);if(c.kind===`refused`)throw Error(`${c.reason} — restart it with that flag removed`);let l=fre(i.env),u=l.get(`PATH`),d=r.launcherNode(u);if(d.kind===`refused`)throw Error(`Claude Code in ${t.pane} was left running, under the PATH it was started with: ${d.why}`);let f=r.onPath(`claude`,u)===i.executable?`claude`:i.executable,p=[...l].filter(([e])=>dre.has(e)),m=(e,t)=>qt(n.preload,{dir:e.dir,env:p,program:f,args:[...e.args,...c.args,...ire(t)]});if(r.terminate(i.pid),!await r.exited(i.pid,15e3))throw Error(`Claude Code in ${t.pane} did not exit within ${15e3/1e3} s of SIGTERM, so it was not restarted under the attach launcher`);let h=(e,n)=>Error(`Claude Code in ${t.pane} exited, but ${e}, so it was not started again — start it with \`${n}\``),g=hre(e,r.presence(e.transcript)),_=g.kind===`unchecked`?{kind:`resume`,sessionId:e.sessionId}:g,v;try{v=await r.paneDir(t,i.parent)}catch(e){throw h(`the directory it was started in could not be read (${e.message})`,m(G7(null,i.cwd),_))}let y=m(G7(v,i.cwd),_);if(g.kind===`unchecked`)throw h(`whether session ${e.sessionId} has a conversation could not be seen (${g.error})`,y);try{await r.typeShellLine(t,y)}catch(e){throw h(`the line could not be typed into its pane (${e.message})`,y)}if(!await r.followed(e.sessionId,`statusline`,3e4))throw Error(`Claude Code in ${t.pane} did not come back attached within ${3e4/1e3} s of \`${y}\` — the pane says why`);return`restarted Claude Code in ${t.pane} under the attach launcher with \`${y}\`, ${gre[g.kind](e.sessionId)}, and its statusline follows lane B`}function mre(e,t){return typeof t==`object`?`whether session ${e.sessionId} has a conversation could not be seen (${t.error})`:t===`present`||e.answered===`no`?null:e.answered===`yes`?`session ${e.sessionId} has a conversation but no transcript to resume it from (is session persistence off?), so a restart would lose it`:`this Claude Code does not say whether session ${e.sessionId} has a conversation, and it has no transcript to resume one from`}function hre(e,t){return typeof t==`object`?{kind:`unchecked`,error:t.error}:{kind:t===`present`?`resume`:`fresh`,sessionId:e.sessionId}}const gre={resume:e=>`resuming ${e}`,fresh:e=>`starting ${e} afresh, since it had no conversation yet`},_re={"in-mode":`its pane is in tmux copy mode — leave it (q)`,stashed:`it holds a stashed prompt (ctrl+s), which ending it would lose — restore or send it`,"no-prompt":`it is not at its prompt (a dialog or picker is open) — close it`};function vre(e){let t=S$(e);return t.kind===`ready`?T$(e)?`it is in the middle of a turn, which ending it would end — wait until it is idle`:C$(e)?`its prompt holds a draft, which ending it would lose — send or clear it`:null:_re[t.kind]}var yre=class{owed=new Map;setups=new C8;constructor(e){this.deps=e}clicked(e,t,n,r){let i=Zb.filter(e=>n[e]!==r[e]),a=this.take(e);for(let e of i)a.has(e)||a.set(e,n[e]);let o=e=>i.includes(e)?`click`:`owed`;if(t!==null){this.settle(t,a,r,o);return}for(let[e,t]of a)t===r[e]&&a.delete(e);if(i.length>0){let t=[...a.keys()].map(e=>`${e} ${r[e]?`on`:`off`}`);this.deps.log(`info`,`lane: owed ${t.join(`,`)||`nothing`} (session=${e})`)}a.size>0&&this.owed.set(e,a);for(let[e,t]of this.owed){if(this.owed.size<=1024)break;this.owed.delete(e),this.deps.log(`warn`,`lane: owed dropped sid=${JSON.stringify(e)} lanes=${[...t.keys()].join(`,`)}`)}}noted(e,t){this.settle(e,this.take(e.sessionId),t,()=>`owed`)}take(e){let t=this.owed.get(e)??new Map;return this.owed.delete(e),t}settle(e,t,n,r){for(let[i,a]of t)n[i]===a?this.deps.log(`info`,`lane: ${i} ${a?`on`:`off`} — nothing owed: its switch is back where the lane is by=${r(i)} (session=${e.sessionId})`):this.start(e,i,n[i],r(i))}start(e,t,n,r){this.deps.defer(()=>void this.setups.run(e.sessionId,()=>this.sync(e,t,n,r)))}async sync(e,t,n,r){let i=`by=${r} (session=${e.sessionId})`,a=r=>{let a=`lane: ${t} ${n?`on`:`off`}: ${r instanceof Error?r.message:String(r)}`;this.deps.log(`warn`,`${a} ${i}`),Sc(this.deps.state,e.sessionId,a,this.deps.now())},o;try{o=await lre[t][n?`on`:`off`](e,this.deps.host,this.deps.edge)}catch(e){a(e);return}this.deps.log(`info`,`lane: ${t} ${n?`on`:`off`} — ${o.said} ${i}`),o.kind===`underway`&&await o.finished.then(e=>this.deps.log(`info`,`lane: ${t} ${e} ${i}`),a)}};const bre=[`request`,`feed`],Z7=new WeakMap;let xre=0;const Q7=e=>{let t=Z7.get(e);if(t!==void 0)return t;let n=xre++;return Z7.set(e,n),n};var Sre=class{records=new Map;constructor(e=512){this.maxRecords=e}of(e,t){return this.records.get($7(e,t))?.warnings??[]}ofSession(e,t,n){let r=Q7(n.config),i=[];for(let n of bre){let a=this.records.get($7(e,n)),o=n===t?this.of(e,t):a?.generation===r?a.warnings:[],s=i.map(e=>JSON.stringify(e));for(let e of o){let t=s.indexOf(JSON.stringify(e));t===-1?i.push(e):s.splice(t,1)}}return i}drawn(e,t,n,r){let i=this.of(e,t),a=$7(e,t);this.records.delete(a),this.records.set(a,{generation:Q7(n.config),warnings:r});for(let e of this.records.keys()){if(this.records.size<=this.maxRecords)break;this.records.delete(e)}return JSON.stringify(i)!==JSON.stringify(r)}};const $7=(e,t)=>`${t}\0${e}`;var Cre=class{queue=new C8;sessions=new C8;gathers=new C8;open=!0;inFlight=null;holder=null;queued=0;gathersInFlight=0;constructor(e){this.deps=e}take(e,{waited:t,gone:n},r){let i=this.deps.monotonic();return this.queued++,this.queue.run(`journals`,async()=>{if(this.queued--,this.refuseClosed(e),n())throw new lq(e);let a=this.deps.monotonic();t(Pe(i,a)),this.holder={verb:e,since:a};try{return await r({holds:t=>{let n={verb:e,commit:t};return this.inFlight=n,()=>this.commit(n)},landed:t=>t.finally(()=>this.refuseClosed(e))})}finally{this.holder=null}})}click(e,t,{placed:n,waited:r,gone:i,gathered:a},o,s){let c=this.deps.monotonic(),l=async()=>{if(n(Fe(this.deps,c)),this.refuseClosed(e),i())throw new lq(e);let t=this.deps.monotonic(),l=await o();a(Fe(this.deps,t));let u=i();return this.take(e,{waited:r,gone:()=>!u&&i()},e=>s(l,e))};return t===null?l():this.sessions.run(t,l)}async gathering(e){this.gathersInFlight++;try{return await this.gathers.run(`gathers`,e)}finally{this.gathersInFlight--}}getStats(){let{holder:e,queued:t}=this;return{holder:e?.verb??null,heldMs:e===null?0:Fe(this.deps,e.since),queued:t,gathers:this.gathersInFlight}}close(){this.open=!1,this.inFlight!==null&&(this.deps.log(`warn`,`journal: ${this.inFlight.verb} cut off by close, committing what landed`),this.commit(this.inFlight))}refuseClosed(e){if(!this.open)throw new cq(e)}commit(e){return this.inFlight===e?(this.inFlight=null,e.commit(),!0):!1}},e9=class extends Error{constructor(e,t,n){super(t instanceof Error?t.message:String(t)),this.record=e,this.thrown=t,this.subscriptions=n,this.name=`TurnThrew`}};function wre(e,t,n,r,i){let a=async e=>{try{let t=await n.answer(e);if(i(t.subscriptions),e.event.kind!==`request`)for(let n of t.effects)o(n,`a ${e.event.kind} turn answers no request`);return{kind:`answered`,output:t}}catch(e){return e instanceof e9?(i(e.subscriptions),{kind:`threw`,error:e.thrown,record:e.record}):{kind:`threw`,error:e,record:[]}}},o=(e,n)=>void c({kind:`event`,at:Ue(t),event:{kind:`effect-done`,of:e.id,outcome:{kind:`failed`,reason:n}}},[[`sid`,e.session],[`effect`,String(e.id)]]),s=(t,n,i)=>{let a=[[`renderer`,e],[`input`,t.event.kind],...n];switch(i.kind){case`answered`:i.output.record.length>0&&r(`info`,Oc(`turn`,[...a,...i.output.record]));return;case`threw`:r(`error`,Oc(`turn`,[...a,...i.record,[`error`,x(i.error)]]))}},c=async(e,t)=>{let n=await a(e);return s(e,t,n),n};return{name:e,answer:a,deliver:c}}async function Tre({verbs:e,menuIdle:t},{verb:n,value:r,session:i,arrival:a,gone:o},s){let c=e.handler(n);if(c===void 0)throw new Z(`unknown click verb: ${n}`);let l=i?.ok?i.id:null;l!==null&&t.clickArrived(l);try{await c(r,{arrival:a,placeWaited:e=>R3(s,{placeWait:`${e}ms`}),gatherTook:e=>R3(s,{gather:`${e}ms`}),turnWaited:e=>R3(s,{turnWait:`${e}ms`}),clientGone:o})}finally{l!==null&&t.clickSettled(l)}}function Ere(e){let t=new Map,n=0,r=(t,n)=>({effects:t,subscriptions:e.renderCache.subscriptions(),record:n}),i=async(i,a,o)=>{switch(i.kind){case`config`:return Z3(e,i.context,i.worldState,a,o),r([],o);case`request`:{let{frame:s,delivered:c}=await c6(e,i.context,a,i.waitEndsAt,o),l=++n;return t.set(l,c),r([{kind:`present`,id:l,session:i.context.sessionId,surface:`statusline`,request:i.id,frame:s}],o)}case`world-state`:return e.worldStates.take(i.worldState),r([],o);case`retire`:return Q3(e,i.session),r([],o);case`effect-done`:{let e=t.get(i.of);if(e===void 0)throw Error(`effect-done for effect ${i.of}, which is not a present on its way`);return t.delete(i.of),i.outcome.kind===`ok`&&e(),r([],o)}case`click`:return await Tre(e,i,o),r([],o);case`menu-idle`:return await e.verbs.closeIdle(i.session,i.idle),r([],o)}};return{answer:async({event:t,at:n})=>{let r=[];try{return await i(t,n,r)}catch(t){throw new e9(r,t,e.renderCache.subscriptions())}}}}function Dre(e){return{handler:t=>{let n=t0.get(t);return n&&((t,r)=>n(t,{...e,...r}))},closeIdle:(t,n)=>n0(t,n,e)}}async function Ore(e,t,n,r){let i=await e.answer({kind:`event`,at:t(),event:{kind:`menu-idle`,session:n,idle:r}});if(i.kind===`threw`)throw i.error}var kre=class{sessions=new Map;pending=new Map;disposed=!1;constructor(e){this.deps=e}clicked(e,t){let n=this.record(e,t);n.since=t,this.settle(e)}clickArrived(e){this.pending.set(e,(this.pending.get(e)??0)+1),this.sessions.has(e)&&this.settle(e)}clickSettled(e){let t=this.pending.get(e)-1;t===0?this.pending.delete(e):this.pending.set(e,t),this.sessions.has(e)&&this.settle(e)}since(e,t){let n=this.record(e,t);return n.shown&&!this.pending.has(e)?n.since:void 0}observe(e,t,n,r){let i=this.record(e,t);t<i.drawnAt||(i.drawnAt=t,n&&!i.shown&&t>i.since&&(i.since=t),i.shown=n,i.timeoutS=r,this.settle(e))}getStats(){let e=0;for(let t of this.sessions.values())t.timer!==null&&e++;let t=0;for(let e of this.pending.values())t+=e;return{sessions:this.sessions.size,armed:e,pending:t}}dispose(){this.disposed=!0;for(let e of this.sessions.values())this.disarm(e);this.sessions.clear()}record(e,t){let n=this.sessions.get(e)??{since:t,timeoutS:0,shown:!1,drawnAt:t,timer:null,closing:!1};this.sessions.delete(e),this.sessions.set(e,n);for(let[e,t]of this.sessions){if(this.sessions.size<=256)break;this.disarm(t),this.sessions.delete(e)}return n}settle(e){let t=this.sessions.get(e),n=t.shown&&!t.closing&&!this.disposed&&!this.pending.has(e)?ux(t.since,t.timeoutS):null;t.timer?.at!==n&&(this.disarm(t),n!==null&&(t.timer={at:n,clear:this.deps.clock.after(Math.max(0,(n-this.deps.now())*1e3),()=>this.fire(e),{unref:!0})}))}disarm(e){e.timer?.clear(),e.timer=null}fire(e){let t=this.sessions.get(e);t.timer=null;let n=this.deps.now(),r={idleS:n-t.since,timeoutS:t.timeoutS,stillIdle:()=>this.sessions.get(e)===t&&!this.pending.has(e),closed:()=>{t.since=n,t.shown=!1}};t.closing=!0,this.deps.close(e,r).catch(t=>{r.closed(),this.deps.failed(e,t)}).finally(()=>{t.closing=!1,this.sessions.get(e)===t&&this.settle(e)})}};function Are(e){let{bundle:t,memoryLimitBytes:n,registryUrl:r,clock:i,exit:a,paths:o,gates:s,host:c}=e,l=En(c),u=()=>Ve(new Date(i.now())),d=new AbortController,f=!1,p=(t,n)=>e.daemonLog.log(t,f?`after close: ${n}`:n),m=new GQ(i),h=e.launcher({inherited:c.env,stats:m.launchStats,signal:d.signal,now:u,observeWarnings:e=>{e.kind===`launch-pipes`?p(`warn`,e.text):p(e.fault===null?`info`:`warn`,e.fault===null?`launch lifeline running again`:`launch lifeline ${e.fault}; the next launch starts another`),fe.wakeWhere(`data`,()=>!0)}}),g=e.probe(h),_=e.storage(p),v=new mJ(_.session),y=new xJ(v,p,_.history),b=Wr({...e.limits({startedAtMs:m.startedAt.getTime(),exit:a,launcher:h,log:p}),limitBytes:n}),S=new s$,C=new kte,w=e.doctorStores,T=new lj({clock:i,counters:m,logger:p}),ee=new Dj(p),te=new Gc({watchers:T,logger:p,clock:i}),E=new Kj({launcher:h,clock:i,logger:p,ledger:ee,watchers:T,fileEvents:te}),ne=W5({launcher:h,host:c,watchers:T,fileEvents:te,clock:i,logger:p,ledger:ee}),{gitProvider:D,usageStore:O,tmuxService:re,hostService:k,managedStorage:ie}=ne,ae=new One,oe=new ete,se=new kre({clock:i,now:u,close:(e,t)=>Ore(Te.renderer,u,e,t),failed:(e,t)=>p(t instanceof cq?`info`:`error`,`menu-idle: close failed (session=${e}): ${x(t)}`)}),ce=e.linkSigner,le=new jc({supersede:(e,t)=>ie.supersede(e,t),launch:h.launch,state:v,log:p,now:u,clock:i}),ue=new yre({edge:e.laneEdge(h,e=>fe.following(e),d.signal,g),host:{bundle:t.path,node:t.node,socket:o.socket,preload:ks(t.path,c)},state:v,log:p,now:u,defer:e=>void i.defer(e)}),de=new ere({edge:{run:(e,t,n)=>bc(h,{socket:e},`tmux-status`,t,n)},subscribe:(e,t)=>fe.subscribe(e,t),sessionInPane:(e,t)=>fe.newestWhere(({hints:{tmux:n}})=>n!=null&&n.socket===e&&n.pane===t),handler:[`CC_CANDYBAR_SOCKET=${Vt(o.socket)}`,...[...t.node,t.path].map(Vt),`url-handle`].join(` `),owner:o.socket,log:p}),fe=new F3({render:(e,t,n)=>G3(Te,e,t,n),watch:(e,t)=>(0,Y.reaction)(()=>v.revision(e),t),lanes:e=>q3(Te,e),pin:e=>{let t=ve.pin(e);return()=>{ve.stopDrawing(e,`feed`),t()}},shown:e=>pe.shown(e.hints.tmux),watching:()=>pe.follow(),refreshes:()=>ee.totals(),periods:k3,clock:i,instant:u,log:p}),pe=new Rne({clock:i,listPanes:e=>bc(h,{socket:e},`frames.visibility`,[`list-panes`,`-a`,`-F`,l7]),listClients:e=>bc(h,{socket:e},`frames.visibility`,[`list-clients`,`-F`,u7]),sockets:()=>new Set(fe.watched().flatMap(({req:e})=>me(e))),onAnswer:(e,t)=>de.answered(e,t),onChange:e=>fe.wakeWhere(`visibility`,t=>me(t).some(t=>e.has(t))),intervalMs:1e3,log:p});function me({hints:{tmux:e}}){return e==null?[]:[e.socket]}let he=new Sre,ge=P8(),_e=new Fne,ve=new Ene({clock:i,runs:E,stateDir:o.state,locations:l,env:c.env,sessionState:v,watchers:T,log:p,storage:ie,signer:ce,gates:s,source:Ine({sessionState:v,worldStates:_e,home:c.home,history:e=>y.depth(e),navigation:(e,t)=>ae.depth(e,v,s.state.gateFor(t))})},{budgetBytes:()=>fne(n),observers:{onReload:(e,t,n,r)=>{p(`info`,hne(e,n,r));for(let e of t)fe.wake(e,`reload`)},onViewChanged:e=>fe.wake(e,`data`)}});te.subscribe(e=>{switch(e.kind){case`period`:T.judge();return;case`caught-up`:ve.reloadEvery({kind:`events-resumed`,since:e.since}),fe.wakeWhere(`data`,()=>!0);return;case`moved`:fe.wakeWhere(`data`,()=>!0);return}});let ye=60*1e3,be=L8({clock:i,targets:t.targets,intervalMs:ye,stat:e.stat,held:()=>xe.running(),exit:()=>a(0),log:p}),xe=N8({fact:ge,clock:i,launcher:h,probe:g,entryUrl:t.entryUrl,digest:t.digest,actsDir:a8(o.state,t.path),intervalMs:ye,releaseIntervalMs:216e5,registryUrl:r,fetchImpl:e.fetch,gates:s,onApplied:()=>be.checkNow(),log:p}),Se=new Cre({log:p,monotonic:()=>i.monotonic()}),Ce={gates:s,sessionState:v,stateDir:o.state,locations:l,journalTurns:Se,clickLanded:e=>se.clicked(e,u()),log:p,launcher:h,now:u,applyUpdate:()=>xe.act(),doctor:e.doctorEdge(h,e=>{let t=[e.projectDir,e.cwd,e.target.path];ve.reload(...t,{kind:`doctor`});let n=ve.getOrCreate(...t);return{layers:n.configLayers,error:n.lastError,warning:n.lastWarning,unused:n.state.unused,config:n.state.config}},c),doctorStores:w,probes:S,clients:C,bundle:t.path,serving:()=>b.serving(),claudeInput:e.claudeInput(h),history:y,navigation:ae,configFor:e=>ve.getOrCreate(e.projectDir,e.cwd,e.target.path).state.config,reloadConfig:e=>ve.reload(e.projectDir,e.cwd,e.target.path,{kind:`write`}),sourcesFor:e=>ve.getOrCreate(e.projectDir,e.cwd,e.target.path).state.sources,links:ce,runs:le,lanes:{of:(e,t)=>J3(Te,e,t),clicked:(e,t,n)=>s6(Te,e,t,n)},views:{follow:(e,t)=>ve.follow(e,t.projectDir,t.cwd,t.target.path)},diagnosticCopy:(e,t,n)=>ve.drawnCopy(e,t,n)},we=new Pne({owners:ne,update:()=>ge.get(),clock:i,watched:e=>fe.feedOpen(e),deliver:e=>Te.renderer.deliver({kind:`event`,event:e,at:u()},[[`sid`,e.kind===`world-state`?e.worldState.session:e.session]]),log:p}),Te={home:c.home,tmp:c.tmp,launcher:h,log:p,clock:i,bundle:t.path,sourceDigest:t.digest,doctorStores:w,stats:m,handlerProbes:S,renderSightings:C,watcherRegistry:T,refreshLedger:ee,fileEvents:te,payloadProviders:ne,sessionState:v,effectSessions:oe,menuIdle:se,journalTurns:Se,linkSigner:ce,runs:le,sourceRuns:E,laneSetups:ue,tmuxStatusLines:de,frameFeeds:fe,renderWarnings:he,renderCache:ve,updateWatch:xe,limits:b,collector:we,worldStates:_e,renderer:wre(`main`,i,Ere({clock:i,log:p,sessionState:v,renderCache:ve,payloadProviders:ne,worldStates:_e,linkSigner:ce,renderWarnings:he,effectSessions:oe,frameFeeds:fe,updateWatch:xe,fileEvents:te,menuIdle:se,launcher:h,laneSetups:ue,tmuxStatusLines:de,verbs:Dre(Ce)}),p,e=>we.subscribed(e))};return{stats:m,launcher:h,log:p,memoryLimitBytes:n,clock:i,exit:a,handle:async(e,t,n,r)=>(d.signal.throwIfAborted(),W6(Te,e,t,n,r)),reply:async(e,t,n,r)=>(d.signal.throwIfAborted(),G6(Te,e,t,n,r)),subscribe:(e,t)=>(d.signal.throwIfAborted(),fe.subscribe(e,t)),reloadConfig:e=>{d.signal.throwIfAborted(),Ce.reloadConfig(e)},arm(){d.signal.throwIfAborted(),te.start(o.watchProbe),be.arm(),xe.arm(),b.arm()},close(e){let t=[[`journalTurns close`,()=>Se.close()],[`tmuxStatusLines restore`,()=>de.restoreAll(e)],[`launches abort`,()=>d.abort(Error(`the daemon closed`))],[`frameFeeds close`,()=>fe.close()],[`menuIdle dispose`,()=>se.dispose()],[`updateWatch close`,()=>xe.close()],[`binaryWatch close`,()=>be.close()],[`limits disarm`,()=>b.disarm()],[`collector close`,()=>we.close()],[`renderCache close`,()=>ve.close()],[`gitService close`,()=>D.close()],[`usageStore close`,()=>O.close()],[`tmuxService close`,()=>re.close()],[`hostService close`,()=>k.close()],[`runs close`,()=>le.close()],[`sourceRuns close`,()=>E.close()],[`managedStorage close`,()=>ie.close()],[`fileEvents close`,()=>te.close()],[`watcherRegistry close`,()=>T.closeAll()],[`sessionState close`,()=>v.close()]];for(let[e,n]of t)try{n()}catch(t){p(`warn`,`${e} failed: ${t.message}`)}return f=!0,h.settled()}}}function jre(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;for(let t of Object.values(e)){if(typeof t!=`object`||!t||Array.isArray(t))return!1;for(let e of Object.values(t))if(typeof e!=`string`)return!1}return!0}var Mre=class{clearTimer=null;pending=null;writing=!1;generation=0;writingPath;constructor(e,t,n=500,r=Ne){this.filePath=e,this.clock=t,this.debounceMs=n,this.logger=r,this.writingPath=`${e}.writing`}load(){let e;try{e=s.readFileSync(this.filePath,`utf8`)}catch(e){let t=e.code;return t!==`ENOENT`&&this.logger(`warn`,`session-state read failed (${t}); starting empty`),{}}try{let t=JSON.parse(e);return jre(t)?t:(this.logger(`warn`,`session-state load: unexpected shape, starting empty`),{})}catch{return this.logger(`warn`,`session-state load: corrupt JSON, starting empty`),{}}}save(e){this.pending=e,this.schedule()}schedule(){this.clearTimer!==null||this.writing||(this.clearTimer=this.clock.after(this.debounceMs,()=>{this.clearTimer=null,this.write()},{unref:!0}))}async write(){let e=this.pending;if(e===null)return;let t=this.generation,n=this.clock.monotonic(),r=JSON.stringify(e),i=this.writingPath;this.writing=!0;let a=Fe(this.clock,n);try{await s.promises.mkdir(E.dirname(this.filePath),{recursive:!0});let o=await s.promises.open(i,`w`,384);try{await o.writeFile(r),await o.chmod(384),await o.datasync()}finally{await o.close()}let c=!1;if(t===this.generation)try{await s.promises.rename(i,this.filePath),c=!0}catch(e){if(e.code!==`ENOENT`||t===this.generation)throw e}if(t!==this.generation){c||await s.promises.rm(i,{force:!0}),this.logger(`info`,`session-state write superseded by a flush landed=${c} took=${Fe(this.clock,n)}ms held=${a}ms`);return}this.saved(r,e,n,a),this.pending===e&&(this.pending=null)}catch(e){this.logger(`warn`,`session-state save failed: ${e.message}`)}finally{this.writing=!1,this.pending!==null&&this.pending!==e&&this.schedule()}}flush(){if(this.clearTimer?.(),this.clearTimer=null,this.pending===null)return;let e=this.pending,t=this.clock.monotonic();try{s.mkdirSync(E.dirname(this.filePath),{recursive:!0});let n=`${this.filePath}.tmp`,r=JSON.stringify(e);s.writeFileSync(n,r,{mode:384}),s.chmodSync(n,384),s.rmSync(this.writingPath,{force:!0}),s.renameSync(n,this.filePath),this.generation++,this.saved(r,e,t,Fe(this.clock,t)),this.pending=null}catch(e){this.logger(`warn`,`session-state save failed: ${e.message}`)}}saved(e,t,n,r){this.logger(`info`,`session-state saved bytes=${Buffer.byteLength(e)} sessions=${Object.keys(t).length} took=${Fe(this.clock,n)}ms held=${r}ms`)}};function Nre(e,t,n){return{session:new Mre(e.sessionState,n,500,t),history:HJ(e.settingsHistory,t)}}function t9(e,t,n){for(let r of(t??``).split(E.delimiter)){if(!E.isAbsolute(r))continue;let t=E.join(r,e);if(n(t))return t}return null}function n9(e,t){try{return s.accessSync(e,t),s.statSync(e).isFile()}catch{return!1}}function Pre(e){try{return s.realpathSync(e)}catch{return E.resolve(e)}}function Fre(e,t,n){let r=t9(`node`,e,t);return r===null?{kind:`refused`,why:"no `node` on PATH to run the attach launcher"}:E.basename(n(r))===`bun`?{kind:`refused`,why:`the \`node\` on PATH (${r}) is Bun; the attach launcher runs under Node`}:{kind:`node`,file:r}}const r9=2e3;async function i9(e,t,n,r){let i=await bc(e,t,`lane.tmux`,n,r);if(i.kind!==`ok`)throw Error(i.reason);return i.stdout}function a9(e,t){if(t.ok)return t.stdout;let n=Xe(t,t.stdout);throw Error(`${e} failed (${Ze(t)}${n===``?``:`: ${n}`})`)}function Ire(e){try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`ok`in t&&t.ok===!1&&`reason`in t&&typeof t.reason==`string`)return`detail`in t&&typeof t.detail==`string`?`${t.reason}: ${t.detail}`:t.reason}catch{}return null}const Lre=/(?:^|\s)bar-pane\s+["'\\]*(%\d+)["']*\s*$/;function Rre(e,t){return e.split(`
492
+ `).flatMap(e=>{let[n,...r]=e.trim().split(` `);return Lre.exec(r.join(` `))?.[1]===t?[n]:[]})}const zre=/(^|\/)(cc-attach|bun-attach\.js)(\s|$)/;function Bre(e,t,n){for(let r of iY(rY(e),t)){if(r.command.split(` `).some(e=>zre.test(e)))return!0;if(r.pid===n)return!1}return!1}const Vre=[`import ctypes, json, struct, sys`,`libc = ctypes.CDLL(None)`,`mib = (ctypes.c_int * 3)(1, 49, int(sys.argv[1]))`,`size = ctypes.c_size_t(0)`,`if libc.sysctl(mib, 3, None, ctypes.byref(size), None, 0) != 0: sys.exit('sysctl KERN_PROCARGS2 refused')`,`buf = ctypes.create_string_buffer(size.value)`,`if libc.sysctl(mib, 3, buf, ctypes.byref(size), None, 0) != 0: sys.exit('sysctl KERN_PROCARGS2 refused')`,`raw = buf.raw[:size.value]`,`argc = struct.unpack_from('i', raw)[0]`,`rest = raw[4:]`,`end = rest.index(b'\\0')`,`exe = rest[:end].decode('utf-8', 'surrogateescape')`,`rest = rest[end:].lstrip(b'\\0')`,`words = [w.decode('utf-8', 'surrogateescape') for w in rest.split(b'\\0')]`,`end = words.index('', argc) if '' in words[argc:] else len(words)`,`print(json.dumps({'executable': exe, 'argv': words[:argc], 'env': words[argc:end]}))`].join(`
493
+ `);async function Hre(e,t){if(process.platform===`linux`)return{executable:await s.promises.readlink(`/proc/${t}/exe`),argv:(await s.promises.readFile(`/proc/${t}/cmdline`,`utf8`)).split(`\0`).slice(0,-1),env:(await s.promises.readFile(`/proc/${t}/environ`,`utf8`)).split(`\0`).slice(0,-1)};let n=a9(`reading process ${t}'s arguments`,await e.launch({bin:`python3`,args:[`-c`,Vre,String(t)],timeoutMs:5e3,category:`lane.process`}));return JSON.parse(n)}async function o9(e,t,n){return a9(t,await e.launch({bin:`ps`,args:n,timeoutMs:2e3,category:`lane.process`}))}async function s9(e,t){let n=await bc(e,t,`lane.tmux`,[`display`,`-p`,`-t`,t.pane,`#{pane_pid} #{pane_current_path}`]);if(n.kind!==`ok`)throw Error(n.reason);let[r=``,i=``]=n.stdout.trimEnd().split(` `),a=(await o9(e,`asking pane ${t.pane}'s foreground job`,[`-o`,`tpgid=`,`-p`,r])).trim();return{panePid:Number(r),cwd:i,foreground:Number(a)}}async function Ure(e,t){let{panePid:n,cwd:r,foreground:i}=await s9(e,t),a=await o9(e,`listing processes`,[`-A`,`-o`,`pid=,ppid=,args=`]),o=await Hre(e,i),c=rY(a).get(i)?.ppid;if(c===void 0)throw Error(`pane ${t.pane}'s foreground job ${i} is gone`);return{pid:i,executable:await s.promises.realpath(o.executable),argv:o.argv,env:o.env,cwd:r,parent:c,fromShell:i!==n,attached:Bre(a,i,n)}}function Wre(e,t,n,r,i){let a=e=>Le(r,e,n);return{claudeInput:N$(e),barPanes:async t=>Rre(await i9(e,t,[`list-panes`,`-a`,`-F`,`#{pane_id} #{pane_start_command}`]),t.pane),openBarPane:async(t,n,r)=>(await i9(e,t,[`split-window`,`-d`,`-v`,`-l`,`1`,`-t`,t.pane,`-P`,`-F`,`#{pane_id}`,...Object.entries(r).flatMap(([e,t])=>[`-e`,`${e}=${t}`]),...n])).trim(),closePane:async(t,n)=>void await i9(e,t,[`kill-pane`,`-t`,n]),claude:async(t,n)=>void a9(`claude ${t.join(` `)}`,await e.launch({bin:`claude`,args:[...t],envOverlay:WJ(n),timeoutMs:3e4,category:`lane.claude`})),fileExists:e=>s.existsSync(e),presence:Cz,paneClaude:t=>Ure(e,t),paneDir:async(t,n)=>{let i=r.monotonic()+r9;for(;;){let o=await s9(e,t);if(o.foreground===n){if(o.cwd===``)throw Error(`tmux read no directory for pane ${t.pane}`);return o.cwd}if(r.monotonic()>i)throw Error(`the shell in pane ${t.pane} (pid ${n}) did not take its terminal back within ${r9/1e3} s`);await a(100)}},launcherNode:e=>Fre(e,e=>n9(e,s.constants.X_OK),Pre),onPath:(e,t)=>{let n=t9(e,t,e=>n9(e,s.constants.X_OK));return n===null?null:s.realpathSync(n)},followed:async(e,n,i)=>{let o=r.monotonic()+i;for(;!t(e).has(n);){if(r.monotonic()>o)return!1;await a(200)}return!0},moduleGraph:async(t,n,r)=>{let i=await e.launch({bin:t,args:[n,r],timeoutMs:2e4,category:`lane.process`}),a=!i.ok&&i.reason===`non-zero`?Ire(i.stdout):null;return a===null?(a9(`reading ${r}'s module graph`,i),{ok:!0}):{ok:!1,reason:a}},terminate:e=>{n.throwIfAborted();try{process.kill(e,`SIGTERM`)}catch(t){throw Error(`Claude Code (pid ${e}) could not be sent SIGTERM: ${t instanceof Error?t.message:String(t)}`)}},exited:async(e,t)=>{let n=r.monotonic()+t;for(;i.alive(e);){if(r.monotonic()>n)return!1;await a(100)}return!0},typeShellLine:async(t,n)=>void await i9(e,t,j$(t.pane,`cc-candybar-lane`,[]),n)}}const Gre=/^[0-9a-f]{64}$/;function c9(e,t){return oe(`sha256`,e).update(JSON.stringify([t.sessionId,t.action,t.declaration,t.evaluated])).digest()}function Kre(e){if(e.length!==32)throw Error(`a link key is 32 bytes, got ${e.length}`);return{sign:t=>c9(e,t).toString(`hex`),verify:(t,n)=>Gre.test(n)?le(Buffer.from(n,`hex`),c9(e,t)):!1}}function l9(e){return E.join(e,`link.key`)}function u9(e){let t,n=()=>t??=qre(e);return{sign:e=>n().sign(e),verify:(e,t)=>n().verify(e,t)}}function qre(e){let t;try{t=s.readFileSync(e)}catch(n){if(n.code!==`ENOENT`)throw n;Jre(e),t=s.readFileSync(e)}if(t.length!==32)throw Error(`link key ${e} holds ${t.length} bytes, not 32: remove it and a new one is made (links drawn before then stop working)`);return Kre(t)}function Jre(e){s.mkdirSync(E.dirname(e),{recursive:!0});let t=`${e}.${process.pid}.${se(6).toString(`hex`)}`;s.writeFileSync(t,se(32),{mode:384,flag:`wx`});try{s.linkSync(t,e)}catch(e){if(e.code!==`EEXIST`)throw e}finally{s.unlinkSync(t)}}function Yre(e,t,n){return{daemonLog:t,launcher:e=>It(e,n),storage:t=>Nre(e,t,n),doctorStores:fQ(e.state),doctorEdge:wQ,claudeInput:N$,probe:Qs,laneEdge:(e,t,r,i)=>Wre(e,t,r,n,i),linkSigner:u9(l9(e.state)),limits:({startedAtMs:r,exit:i,launcher:a,log:o})=>Xr(r,i,{launcher:a,log:o,clock:n,snapshotDir:e.state,writeLogNow:()=>t.writeNow()}),fetch,stat:s.statSync}}const Xre=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`blackBright`,`redBright`,`greenBright`,`yellowBright`,`blueBright`,`magentaBright`,`cyanBright`,`whiteBright`];function d9(e){if(e===void 0)return;let t=H.parse(e);if(t.isDefault)return;let n=t.fixedValue;if(n!==void 0)return n.hex;let r=t.type===V.STANDARD&&t.number!==void 0?Xre[t.number]:void 0;if(r===void 0)throw Error(`frames: no band colour for ${t.name}`);return r}const Zre={bold:`bold`,dim:`dimColor`,italic:`italic`,underline:`underline`,strike:`strikethrough`,reverse:`inverse`,blink:null,blink2:null,conceal:null,underline2:null,frame:null,encircle:null,overline:null};function Qre({text:e,fg:t,bg:n,attrs:r=[],link:i}){let a=d9(t),o=d9(n),s={};for(let e of r){let t=Zre[e];if(t===null)throw Error(`frames: the band cannot draw ${e} text`);s[t]=!0}return{text:e,...a!==void 0&&{color:a},...o!==void 0&&{backgroundColor:o},...s,...i!==void 0&&{href:i}}}function $re(e){return{ok:!0,band:e.rows.map(e=>zP(e).map(Qre))}}function eie(e){return FP($re,e)}const tie={band:e=>JSON.stringify(eie(e)),statusline:(e,t)=>t,pane:(e,t)=>t,tmuxStatus:e=>JSON.stringify({ok:!0,tmuxStatus:m7(e)})};function f9(e){let t=null;return e.on(`drain`,()=>{let n=t;t=null,n!==null&&e.write(n)}),n=>{if(e.writable){if(e.writableNeedDrain){t=n;return}e.write(n)}}}function nie(e,t){t.allowHalfOpen=!1;let n=e.clock.monotonic();e.stats.inFlight++;let r=!1,i=!0,a=()=>{i&&(i=!1,e.stats.inFlight--)},o=(n,i,a)=>{if(r){i!==null&&e.log(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`),a(!1);return}r=!0,l();let o=i===null?void 0:()=>e.exit(i);try{t.end(er(n),e=>{a(e==null),o?.()})}catch(t){e.log(`warn`,`response write failed: ${t.message}`),a(!1),o?.()}},s=!1,c=!0,l=e.clock.after(200,()=>{s=!0,e.stats.requestsTimedOut++,c&&o({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null,d6)}),u=nr(r=>{let i=Zn(r);c=i.kind===`request`,e.handle(i,()=>s,n,()=>c&&t.destroyed).then(e=>{if(!c){e.kind===`reply`&&e.settled(!1);return}e.kind===`reply`?o(e.resp,e.exitAfterFlush,e.settled):d(e.sessionId,e.lane)}).catch(t=>{e.log(`error`,`handler threw: ${x(t)}`),c&&o(U3(t),null,d6)}).finally(()=>{c||(l(),a())})},t=>{e.log(`warn`,`frame parse failed: ${t.message}`),o({ok:!1,error:t.message,code:`BAD_REQUEST`,daemonV:3},null,d6)}),d=(n,i)=>{if(r||t.destroyed)return;l(),a(),t.off(`data`,u);let o=f9(t),s=e.subscribe(n,{lane:i,frame:(e,t)=>o(tr(tie[i](e,t))),refused:e=>t.end(er(e)),drawing:()=>!0});r=!0,t.on(`close`,s)};t.on(`data`,u),t.on(`error`,t=>{e.log(`warn`,`socket error: ${t.message}`)}),t.on(`close`,()=>{c&&(l(),a())})}const p9=`CC_CANDYBAR_PARENT_PID`;function rie(e){let t=e[p9];if(t===void 0)return{kind:`outlives-nobody`};let n=Number.parseInt(t,10);if(!Number.isInteger(n)||n<=0)throw Error(`${p9} must be a positive integer pid, got ${JSON.stringify(t)}`);return{kind:`anchored`,pid:n}}function iie(e){if(e.anchor.kind===`outlives-nobody`)return{disarm:()=>{}};let{pid:t}=e.anchor;return{disarm:e.clock.every(e.intervalMs??250,()=>{e.probe.alive(t)||e.onOrphaned(`spawner pid ${t} gone`)},{unref:!0})}}let m9=null,h9=null,g9=null,_9=null;function v9(){if(_9===null)throw Error(`runDaemon has not started`);return _9}function y9(e,t){v9().log.log(e,t)}function aie(){let e=i(import.meta.url);return{entryUrl:import.meta.url,digest:an(),path:e,node:[t.execPath,...t.execArgv],targets:[...new Set([e,...t.argv[1]?[t.argv[1]]:[]])]}}function oie(e){let n=N(e.host);_9={world:e,paths:n,log:new gc(n.log,e.clock)},t.on(`uncaughtException`,e=>{y9(`error`,`uncaughtException: ${e.stack||e.message}`),C9(1)}),t.on(`unhandledRejection`,e=>{y9(`error`,`unhandledRejection: ${String(e)}`),C9(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{y9(`info`,`received ${e}, shutting down`),C9(0)});sie().catch(b9)}function b9(e){y9(`error`,`refusing to boot: ${x(e)}`),C9(1)}async function sie(){let{world:e,paths:n,log:r}=v9(),{host:i}=e,a=Ir(i.env);m9=await ec(t.pid,Qs(e.launcher).startTime);let o=await oc(cc(e,m9,n.registry));if(!o.decision.allow){y9(`warn`,`fork-bomb breaker: ${o.decision.reason}; refusing to boot`),C9(1);return}h9=o.registryPath,s.mkdirSync(n.state,{recursive:!0}),hn(n.socket);let c=Are({...Yre(n,r,e.clock),bundle:aie(),host:i,paths:n,memoryLimitBytes:a,registryUrl:i.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,clock:e.clock,gates:Sz(),exit:C9});g9=c,iie({clock:e.clock,anchor:rie(i.env),probe:Qs(e.launcher),onOrphaned:e=>{y9(`info`,`parent watchdog: ${e}; shutting down`),C9(0)}}),x9(c,ue.createServer(e=>nie(c,e)),n.socket,!1)}function x9(e,n,r,i){n.removeAllListeners(`error`),n.removeAllListeners(`listening`),n.once(`error`,a=>{if(a.code!==`EADDRINUSE`){y9(`error`,`server error: ${a.message}`),C9(1);return}if(i){y9(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}cie(e,n,r).catch(b9)}),n.listen(r,()=>lie(e,r))}async function cie(e,n,r){let i=await Us(Ws(gn(r)),(t,n)=>$s(t,n,Qs(e.launcher)));if(i.kind===`attach-and-exit`){y9(`info`,`EADDRINUSE: ${i.reason} — exiting`),t.exit(0);return}y9(`warn`,`EADDRINUSE: ${i.reason} — unlinking stale socket and rebinding`);try{s.unlinkSync(r)}catch(e){if(e.code!==`ENOENT`){y9(`error`,`cannot unlink stale socket ${r}: ${e.message}`),C9(1);return}}x9(e,n,r,!0)}function lie(e,n){let r=qs(n);if(r.kind!==`present`){y9(`warn`,`no ownable socket at bind callback (${r.kind}); exiting`),C9(0);return}die(n);try{s.chmodSync(n,384)}catch(e){y9(`warn`,`chmod socket failed: ${e.message}`)}y9(`info`,`daemon up: pid=${t.pid} v=3 sock=${n} heapCap=${Fr(de.getHeapStatistics().heap_size_limit)}MB memoryLimit=${Fr(e.memoryLimitBytes)}MB`),ai(v9().paths.spawnBackoff),e.arm(),uie(n,r.identity)}function uie(e,n){Xs({bound:n,myPid:t.pid,readIdentity:()=>qs(e),readLease:()=>Ws(gn(e)),shutdown:e=>C9(e),log:y9,clock:v9().world.clock}).arm()}function die(e){let n=Gs(gn(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:m9});n!==null&&y9(`warn`,`lease write failed: ${n}`)}const fie=e=>(t,n,r)=>yc(e,{socket:t},`tmux-status`,n,r);let S9=!1;function C9(e){S9||(S9=!0,v9().world.clock.after(500,()=>t.kill(t.pid,`SIGKILL`)),g9?.close(fie(v9().world.launcher)),Ks(v9().paths.lease,t.pid),h9!==null&&sc(h9,t.pid,ic,e=>s.unlinkSync(e)),t.exit(e))}const pie={connectMs:200,budgetMs:500};async function mie(e,t,n){return hie(t,await gie(e,t),n.includes(`--json`))}function hie(e,t,n){return t.kind===`ok`?{stdout:n?JSON.stringify(t.value,null,2)+`
494
+ `:_ie(t.value),stderr:``,code:0}:{stdout:``,stderr:`${e}: ${fr(t)}\n`,code:1}}function gie(e,t){return ar(e,()=>({kind:`debug`,what:t}),pie,e=>`debug`in e?e.debug:void 0)}function _ie(e){switch(e.what){case`vars`:return vie(e.vars);case`segments`:return yie(e.segments);case`config`:return bie(e.config);default:return e}}function vie(e){if(e.length===0)return`no variables (DSL not active)
495
+ `;let t=[`variables (${e.length})`,``],n=e.reduce((e,t)=>Math.max(e,t.name.length),4),r=e.reduce((e,t)=>Math.max(e,(t.source??`—`).length),6),i=e.reduce((e,t)=>Math.max(e,t.type.length),4);for(let a of e){let e=a.ageMs===null?``:` ${Sie(a.ageMs)}`,o=a.lastError?` ✗ ${a.lastError.message}`:``;t.push(` ${a.name.padEnd(n)} ${(a.source??`—`).padEnd(r)} ${a.type.padEnd(i)} ${xie(a.value)}${e}${o}`)}return t.join(`
496
496
  `)+`
497
- `}function gie(e){if(e.length===0)return`no segments (DSL not active)
497
+ `}function yie(e){if(e.length===0)return`no segments (DSL not active)
498
498
  `;let t=[`segments (${e.length})`,``];for(let n of e){t.push(` ${n.name}`),n.description!==null&&t.push(` shows ${n.description}`),t.push(` template ${n.template}`),n.referencedVars.length>0&&t.push(` vars ${n.referencedVars.join(`, `)}`);for(let{id:e,lastRender:r}of n.placements)r!==null&&t.push(` last ${e}: ${r}`)}return t.join(`
499
499
  `)+`
500
- `}function _ie(e){return e===null?`config: DSL not active
500
+ `}function bie(e){return e===null?`config: DSL not active
501
501
  `:JSON.stringify(e,null,2)+`
502
- `}function vie(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function yie(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function bie(){let e=Sie();return e===null?null:s.readFileSync(e,`utf-8`)}function xie(){let e;try{e=bie()}catch(e){return{stdout:``,stderr:`schema: cannot read bundled schema: ${e instanceof Error?e.message:String(e)}\n`,code:2}}return e===null?{stdout:``,stderr:"schema: bundled schema not found (expected schema/cc-candybar.schema.json). Run `pnpm gen:schema` from a source checkout.\n",code:2}:{stdout:e,stderr:``,code:0}}function Sie(){let e=E.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let r=E.dirname(E.resolve(n));for(;;){let t=E.join(r,e);if(s.existsSync(t))return t;let n=E.dirname(r);if(n===r)return null;r=n}}const C9=5e3;function Cie(e,t){return{ms:t,signal:Re(e,t)}}function wie(e,t){return t.length===0?[]:[`source${t.length===1?``:`s`} still running after ${e.ms} ms, drawn as pending: ${t.join(`, `)}`]}function w9({layers:e,config:t,compiled:n,store:r,registry:i},a,o,s){let c=jX(a,o);return{drawn:D3(n,r,i,Oie(t,a,e.at(-1)??null,s),c,a),opts:c}}const T9=`/home/tester`,E9=F$(`test0a1b-2c3d-4e5f-6a7b-8c9d0e1f2a3b`),Tie={tmux:{socket:`/tmp/tmux.sock`,pane:`%0`,truecolor:null},ssh:!0};function Eie(e){let t=Math.floor(e);return{hook_event_name:`Status`,session_id:E9,version:`1.15.0`,cwd:`${T9}/code/cc-candybar/src`,transcript_path:`${T9}/.claude/projects/x/test.jsonl`,model:{id:`claude-opus-4-8`,display_name:`Opus 4.8`},effort:{level:`xhigh`},workspace:{current_dir:`${T9}/code/cc-candybar/src`,project_dir:`${T9}/code/cc-candybar`,added_dirs:[]},cost:{total_cost_usd:.39,total_duration_ms:93e4,total_api_duration_ms:4200,total_lines_added:512,total_lines_removed:88},context_window:{total_input_tokens:241400,total_output_tokens:0,context_window_size:1e6,used_percentage:76,remaining_percentage:24,current_usage:{input_tokens:48487,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}},rate_limits:{five_hour:{used_percentage:63,resets_at:t+2*3600},seven_day:{used_percentage:21,resets_at:t+5*86400}}}}function Die(e,t){let n=Math.floor(t),r=Object.entries(e.variables).flatMap(([e,t])=>t.kind===`source`?[e]:[]);return{lanes:{git:F({branch:`main`,status:`dirty`,aheadBehind:F({ahead:2,behind:1}),head:F(`abc1234def5678`),workingTree:{staged:3,unstaged:2,untracked:1,conflicts:0},sha:F(`abc1234`),operation:F(`rebase`),committedAt:F(n-780),stashCount:F(1),upstream:F(`origin/main`),repoName:F(`cc-candybar`),repoUrl:F(`https://github.com/promptctl/cc-candybar`),pullRequest:I}),usage:F({calculatedCost:.39,tokens:241400,tokenBreakdown:null}),context:F(48487),metrics:F({lastResponseTime:8.2,messageCount:8,nonPrompts:0}),activity:I,tmuxSession:F(`work`),hostName:F(`tester-box`),hostUser:F(`tester`),cache:F(n+900),speed:I,autoCompact:F(4e5),sources:new Map(r.map(e=>[e,I]))},today:F({sums:WY(t,12.5,34e5),own:{}}),faults:[]}}function Oie(e,t,n,r){let i=Eie(r),a=a7(void 0,E9,Die(e,r),{...I,at:r},r),{term:o,...s}=$X(a,{hookData:i,hints:Tie,home:T9},{sources:Object.keys(a.sources),effective:t,configFacts:{unsaved:1,resettable:Rx(()=>!0),themeDefault:t.theme.kind===`decided`?{differs:!0,theme:t.theme.name}:{differs:!1},configPath:n??`${T9}/.config/cc-candybar/config.json5`},history:{undo:1,redo:1,sinceEdit:1},back:1});return{...s,today:aZ(a.builtins.today,r)}}function kie(e,t){let n=aU(e);return n!==null&&t.push(n),e.kind===`chain`?e.layers:[]}async function Aie(e,n,r,i=t.cwd(),a=C9){let o=[],c=cP(i,r,e.host.home)??null,l=En(e.host),u=eU(l,BU(ln(e.host)).read(),i,i,c??void 0);o.push(...JH(u.repos));let d=c===null?kie(u,o):[$H(c)];if(c!==null){let e;try{e=s.statSync(c,{throwIfNoEntry:!1})}catch(e){return{kind:`unreadable`,path:c,message:e instanceof Error?e.message:String(e)}}if(e!==void 0&&!e.isFile())return{kind:`unreadable`,path:c,message:`not a file`}}let f=sU(l,i,i);f!==null&&o.push(f);try{return{kind:`clean`,layers:d,warnings:o,rendered:await Nie(e,n,d,{repo:u.repos.plugins},i,o,a)}}catch(e){let t=e;return typeof t==`object`&&t&&typeof t.code==`string`&&typeof t.path==`string`&&d.some(e=>e.path===t.path)&&typeof t.message==`string`?{kind:`unreadable`,path:t.path,message:t.message}:(e instanceof ab&&o.push(...e.warnings),{kind:`fatal`,layers:d,message:e instanceof ab||e instanceof Error?e.message:String(e),warnings:o})}}async function jie(e,t,n,r,i,a,o=C9){let s=t.map(e=>e.path),c=HG(En(e.host),t,mK,{warned:e=>i.push(...e)},{...n,cwd:r});YG(c.dropped);let{config:l}=c,u=new RC(e.clock),d=new Kj({launcher:e.launcher,clock:e.clock}),f=new rM(d,u,l.globals.default_empty_value??``,new mJ,null,e.host.env);try{let t=d3(l,f,{cwd:r,signer:l9(c9(ln(e.host)))});i.push(...t.loadWarnings);let n=CK(l,()=>null,()=>!1),p=Cie(e.clock,o);return w9({layers:s,config:l,compiled:t,store:u,registry:f},n,200,a),await f.inFlight(p.signal),{settle:p,layers:s,droppedPlugins:[...c.installed.dropped,...c.layers.flatMap(e=>e.plugins.dropped)],config:l,compiled:t,store:u,registry:f,runs:d}}catch(e){throw f.dispose(),d.close(),e}}async function Mie(e,t,n,r){let i=new Map,a=new Set,o=e=>{switch(e.kind){case`rule`:i.set(`${e.slot} rule`,e.message);return;case`when`:i.set(e.where,e.error);return;case`refresh`:i.set(`variable "${e.variable}"`,`cannot refresh: ${e.error}`);return;default:}},{config:s,compiled:c,store:l,registry:u,settle:d}=e,{drawn:f,opts:p}=w9(e,t,n,r);for(let e of wie(d,await u.inFlight(d.signal)))a.add(e);let{frame:m}=O3(s,c,l,u,f,r,p,{onSegmentError:(e,t)=>i.set(`segment "${e}"`,t),onRenderWarning:o},t);return{rendered:m,failures:i,advisories:a}}async function Nie(e,t,n,r,i,a,o){let s=Ve(new Date(e.clock.now())),c=await jie(e,n,r,i,a,s,o),{config:l}=c;try{t.state.gateFor(l),t.config.gateFor(l);let e=uS(null,l.globals.preset,l.presets),n=async(e,t)=>{let n=CK(l,t=>t===`preset`?e:null,()=>t),r;try{r=await Mie(c,n,200,s)}catch(e){r={failures:new Map([[`render`,e instanceof Error?e.message:String(e)]]),advisories:new Set}}return{preset:e,customized:t,...r}},r=await n(e,!1),i=[r,await n(e,!0)];for(let t of lS(l.presets))t!==e&&i.push(await n(t,!1),await n(t,!0));let o=t=>{let n=new Map;for(let e of i)for(let r of t(e)){let t=n.get(r)??new Map;t.set(e.preset,(t.get(e.preset)??new Set).add(e.customized)),n.set(r,t)}return[...n].map(([t,n])=>n.get(e)?.has(!1)?t:`${t} (under ${[...n].map(([t,n])=>[...t===e?[]:[`preset "${t}"`],...n.has(!1)?[]:[`.preset.customized = true`]].join(`, `)).join(`; `)})`)};a.push(...o(e=>e.advisories));let u=o(e=>[...e.failures].map(([e,t])=>`${e}: ${t}`)),d=r.rendered,f=c.droppedPlugins.length,p=[...f>0?[`${f} plugin${f===1?``:`s`} did not load (named in the warnings)`]:[],...u.length>0||d===void 0?[`config renders with ${u.length} render error${u.length===1?``:`s`} (the daemon would show them on the bar):\n`+u.map(e=>` ${e}`).join(`
502
+ `}function xie(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function Sie(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function Cie(){let e=Tie();return e===null?null:s.readFileSync(e,`utf-8`)}function wie(){let e;try{e=Cie()}catch(e){return{stdout:``,stderr:`schema: cannot read bundled schema: ${e instanceof Error?e.message:String(e)}\n`,code:2}}return e===null?{stdout:``,stderr:"schema: bundled schema not found (expected schema/cc-candybar.schema.json). Run `pnpm gen:schema` from a source checkout.\n",code:2}:{stdout:e,stderr:``,code:0}}function Tie(){let e=E.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let r=E.dirname(E.resolve(n));for(;;){let t=E.join(r,e);if(s.existsSync(t))return t;let n=E.dirname(r);if(n===r)return null;r=n}}const w9=5e3;function Eie(e,t){return{ms:t,signal:Re(e,t)}}function Die(e,t){return t.length===0?[]:[`source${t.length===1?``:`s`} still running after ${e.ms} ms, drawn as pending: ${t.join(`, `)}`]}function T9({layers:e,config:t,compiled:n,store:r,registry:i},a,o,s){let c=jX(a,o);return{drawn:D3(n,r,i,jie(t,a,e.at(-1)??null,s),c,a),opts:c}}const E9=`/home/tester`,D9=F$(`test0a1b-2c3d-4e5f-6a7b-8c9d0e1f2a3b`),Oie={tmux:{socket:`/tmp/tmux.sock`,pane:`%0`,truecolor:null},ssh:!0};function kie(e){let t=Math.floor(e);return{hook_event_name:`Status`,session_id:D9,version:`1.15.0`,cwd:`${E9}/code/cc-candybar/src`,transcript_path:`${E9}/.claude/projects/x/test.jsonl`,model:{id:`claude-opus-4-8`,display_name:`Opus 4.8`},effort:{level:`xhigh`},workspace:{current_dir:`${E9}/code/cc-candybar/src`,project_dir:`${E9}/code/cc-candybar`,added_dirs:[]},cost:{total_cost_usd:.39,total_duration_ms:93e4,total_api_duration_ms:4200,total_lines_added:512,total_lines_removed:88},context_window:{total_input_tokens:241400,total_output_tokens:0,context_window_size:1e6,used_percentage:76,remaining_percentage:24,current_usage:{input_tokens:48487,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}},rate_limits:{five_hour:{used_percentage:63,resets_at:t+2*3600},seven_day:{used_percentage:21,resets_at:t+5*86400}}}}function Aie(e,t){let n=Math.floor(t),r=Object.entries(e.variables).flatMap(([e,t])=>t.kind===`source`?[e]:[]);return{lanes:{git:F({branch:`main`,status:`dirty`,aheadBehind:F({ahead:2,behind:1}),head:F(`abc1234def5678`),workingTree:{staged:3,unstaged:2,untracked:1,conflicts:0},sha:F(`abc1234`),operation:F(`rebase`),committedAt:F(n-780),stashCount:F(1),upstream:F(`origin/main`),repoName:F(`cc-candybar`),repoUrl:F(`https://github.com/promptctl/cc-candybar`),pullRequest:I}),usage:F({calculatedCost:.39,tokens:241400,tokenBreakdown:null}),context:F(48487),metrics:F({lastResponseTime:8.2,messageCount:8,nonPrompts:0}),activity:I,tmuxSession:F(`work`),hostName:F(`tester-box`),hostUser:F(`tester`),cache:F(n+900),speed:I,autoCompact:F(4e5),sources:new Map(r.map(e=>[e,I]))},today:F({sums:WY(t,12.5,34e5),own:{}}),faults:[]}}function jie(e,t,n,r){let i=kie(r),a=a7(void 0,D9,Aie(e,r),{...I,at:r},r),{term:o,...s}=$X(a,{hookData:i,hints:Oie,home:E9},{sources:Object.keys(a.sources),effective:t,configFacts:{unsaved:1,resettable:Rx(()=>!0),themeDefault:t.theme.kind===`decided`?{differs:!0,theme:t.theme.name}:{differs:!1},configPath:n??`${E9}/.config/cc-candybar/config.json5`},history:{undo:1,redo:1,sinceEdit:1},back:1});return{...s,today:aZ(a.builtins.today,r)}}function Mie(e,t){let n=aU(e);return n!==null&&t.push(n),e.kind===`chain`?e.layers:[]}async function Nie(e,n,r,i=t.cwd(),a=w9){let o=[],c=cP(i,r,e.host.home)??null,l=En(e.host),u=eU(l,BU(ln(e.host)).read(),i,i,c??void 0);o.push(...JH(u.repos));let d=c===null?Mie(u,o):[$H(c)];if(c!==null){let e;try{e=s.statSync(c,{throwIfNoEntry:!1})}catch(e){return{kind:`unreadable`,path:c,message:e instanceof Error?e.message:String(e)}}if(e!==void 0&&!e.isFile())return{kind:`unreadable`,path:c,message:`not a file`}}let f=sU(l,i,i);f!==null&&o.push(f);try{return{kind:`clean`,layers:d,warnings:o,rendered:await Iie(e,n,d,{repo:u.repos.plugins},i,o,a)}}catch(e){let t=e;return typeof t==`object`&&t&&typeof t.code==`string`&&typeof t.path==`string`&&d.some(e=>e.path===t.path)&&typeof t.message==`string`?{kind:`unreadable`,path:t.path,message:t.message}:(e instanceof ab&&o.push(...e.warnings),{kind:`fatal`,layers:d,message:e instanceof ab||e instanceof Error?e.message:String(e),warnings:o})}}async function Pie(e,t,n,r,i,a,o=w9){let s=t.map(e=>e.path),c=HG(En(e.host),t,mK,{warned:e=>i.push(...e)},{...n,cwd:r});YG(c.dropped);let{config:l}=c,u=new RC(e.clock),d=new Kj({launcher:e.launcher,clock:e.clock}),f=new rM(d,u,l.globals.default_empty_value??``,new mJ,null,e.host.env);try{let t=d3(l,f,{cwd:r,signer:u9(l9(ln(e.host)))});i.push(...t.loadWarnings);let n=CK(l,()=>null,()=>!1),p=Eie(e.clock,o);return T9({layers:s,config:l,compiled:t,store:u,registry:f},n,200,a),await f.inFlight(p.signal),{settle:p,layers:s,droppedPlugins:[...c.installed.dropped,...c.layers.flatMap(e=>e.plugins.dropped)],config:l,compiled:t,store:u,registry:f,runs:d}}catch(e){throw f.dispose(),d.close(),e}}async function Fie(e,t,n,r){let i=new Map,a=new Set,o=e=>{switch(e.kind){case`rule`:i.set(`${e.slot} rule`,e.message);return;case`when`:i.set(e.where,e.error);return;case`refresh`:i.set(`variable "${e.variable}"`,`cannot refresh: ${e.error}`);return;default:}},{config:s,compiled:c,store:l,registry:u,settle:d}=e,{drawn:f,opts:p}=T9(e,t,n,r);for(let e of Die(d,await u.inFlight(d.signal)))a.add(e);let{frame:m}=O3(s,c,l,u,f,r,p,{onSegmentError:(e,t)=>i.set(`segment "${e}"`,t),onRenderWarning:o},t);return{rendered:m,failures:i,advisories:a}}async function Iie(e,t,n,r,i,a,o){let s=Ve(new Date(e.clock.now())),c=await Pie(e,n,r,i,a,s,o),{config:l}=c;try{t.state.gateFor(l),t.config.gateFor(l);let e=uS(null,l.globals.preset,l.presets),n=async(e,t)=>{let n=CK(l,t=>t===`preset`?e:null,()=>t),r;try{r=await Fie(c,n,200,s)}catch(e){r={failures:new Map([[`render`,e instanceof Error?e.message:String(e)]]),advisories:new Set}}return{preset:e,customized:t,...r}},r=await n(e,!1),i=[r,await n(e,!0)];for(let t of lS(l.presets))t!==e&&i.push(await n(t,!1),await n(t,!0));let o=t=>{let n=new Map;for(let e of i)for(let r of t(e)){let t=n.get(r)??new Map;t.set(e.preset,(t.get(e.preset)??new Set).add(e.customized)),n.set(r,t)}return[...n].map(([t,n])=>n.get(e)?.has(!1)?t:`${t} (under ${[...n].map(([t,n])=>[...t===e?[]:[`preset "${t}"`],...n.has(!1)?[]:[`.preset.customized = true`]].join(`, `)).join(`; `)})`)};a.push(...o(e=>e.advisories));let u=o(e=>[...e.failures].map(([e,t])=>`${e}: ${t}`)),d=r.rendered,f=c.droppedPlugins.length,p=[...f>0?[`${f} plugin${f===1?``:`s`} did not load (named in the warnings)`]:[],...u.length>0||d===void 0?[`config renders with ${u.length} render error${u.length===1?``:`s`} (the daemon would show them on the bar):\n`+u.map(e=>` ${e}`).join(`
503
503
  `)]:[]];if(p.length>0||d===void 0)throw Error(p.join(`
504
- `));return d}finally{c.registry.dispose(),c.runs.close()}}function D9(e){return e.map(e=>`warning: ${e}\n`).join(``)}function Pie(e,t=!1){switch(e.kind){case`clean`:return{stdout:`✓ ${pP(e.layers.map(e=>e.path))}: config OK${e.warnings.length>0?` (${e.warnings.length} warning${e.warnings.length===1?``:`s`})`:``}\n`+(t?`${RP(e.rendered)}\n`:``),stderr:D9(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:D9(e.warnings)+`✗ ${pP(e.layers.map(e=>e.path),`<default>`)}\n${e.message}\n`,code:1};case`unreadable`:return{stdout:``,stderr:`check: cannot read ${e.path}: ${e.message}\n`,code:2}}}const O9=`--render`,k9=`Usage: cc-candybar check [${O9}] [config-file]\n`;function Fie(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`)),r=t.filter(e=>e!==O9);return r.length>0?{kind:`usage`,message:`check: unknown option ${r.join(` `)}\n${k9}`}:n.length>1?{kind:`usage`,message:`check: expected at most one path\n${k9}`}:{kind:`run`,target:n[0],render:t.includes(O9)}}async function A9(e,n){let r=Fie(e),i=t.cwd();return r.kind===`usage`?{stdout:``,stderr:r.message,code:2}:Pie(await Aie(n,Sz(),fP(r.target,n.host,i).path,i),r.render)}const Iie=/^[a-z][a-z0-9+.-]*:\/\//i,Lie=/^[^@\s/]+@[^:\s/]+:/,Rie=/^([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/;function zie(e){if(!URL.canParse(e))return e;let t=new URL(e);return t.password===``?e:(t.password=`***`,t.href)}function Bie(e,t,n,r){let i=sP(t,e,n);if(r(i))return{kind:`path`,dir:i};if(Iie.test(e)||Lie.test(e))return{kind:`git`,url:e,shown:zie(e)};let a=Rie.exec(e);if(a){let e=`https://github.com/${a[1]}.git`;return{kind:`git`,url:e,shown:e}}return{error:`"${e}" is not a directory, a GitHub repo slug (owner/repo) or a git URL`}}function Vie(e,t){let n=E.join(e,wH),r=EH(n);if(`error`in r)throw Error(`${t}: could not list ${wH}: ${r.error}`);if(r.folders.length===0)throw Error(`${t} has no plugins: none at ${wH}/<name>/${VV}`);return r.folders.map(e=>E.join(n,e,VV))}function Hie(e,t,n,r){let i=(r,...i)=>{let a=e.launchSync({bin:`git`,args:i,envOverlay:r,category:`plugin.git`});if(!a.ok)throw Error(`git ${i.map(e=>e===t?n:e).join(` `)} failed (${Ze(a)})`);return a.stdout},a={GIT_TERMINAL_PROMPT:`0`};for(let e of i(a,`rev-parse`,`--local-env-vars`).split(`
505
- `))a[e]=void 0;i(a,`clone`,`--quiet`,`--depth`,`1`,`--filter=blob:none`,`--sparse`,`--`,t,r),i(a,`-C`,r,`sparse-checkout`,`set`,`--no-cone`,`/${wH}/`)}function Uie({host:e,launcher:t},n,r){switch(n.kind){case`path`:return r(n.dir);case`git`:{let i=s.mkdtempSync(E.join(e.tmp,`cc-candybar-plugin-`));try{return Hie(t,n.url,n.shown,E.join(i,`repo`)),r(E.join(i,`repo`))}finally{s.rmSync(i,{recursive:!0,force:!0})}}}}function Wie(e){let t;try{t=s.lstatSync(e)}catch(e){if(e.code===`ENOENT`)return`installed`;throw e}if(t.isDirectory())return`updated`;if(t.isSymbolicLink())return`replaced`;throw Error(`${e} is a file, not a plugin folder: move it, then install again`)}function Gie(e,t,n,r){switch(r){case`updated`:s.renameSync(E.join(e,VV),E.join(t,VV));return;case`replaced`:s.renameSync(t,n),s.renameSync(e,t);return;case`installed`:s.renameSync(e,t);return}}function Kie(e,t,n,r){let i=Vie(e,n);s.mkdirSync(t,{recursive:!0});let a=s.mkdtempSync(E.join(t,`.install-`));try{let o=i.map(e=>{let t=E.join(a,E.basename(E.dirname(e)));s.mkdirSync(t);try{s.copyFileSync(e,E.join(t,VV))}catch(e){if(e.code!==`ENOENT`)throw e}return t}),c=BG(o.map(e=>UV(E.join(e,VV),`plugins`)),mK,{root:e,git:!1},r);if(c.length>0)throw Error(c.map(e=>`${n}: ${E.join(wH,E.relative(a,e.path))} would not load: ${e.reason.split(a).join(E.join(n,wH))}`).join(`
506
- `));let l=o.map(e=>{let n=E.basename(e),r=E.join(t,n);return{folder:e,name:n,target:r,placed:Wie(r)}}),u=[];try{for(let{folder:e,name:t,target:n,placed:r}of l)Gie(e,n,E.join(a,`.replaced-${t}`),r),u.push(t)}catch(e){throw Error(`${e.message} (placed before it: ${u.join(`, `)||`none`})`)}return l.map(({target:e,placed:t})=>({path:E.join(e,VV),placed:t}))}finally{s.rmSync(a,{recursive:!0,force:!0})}}function qie(e,t){let[n,r,...i]=e;if(n!==`install`||r===void 0||i.length>0)return console.error(`Usage: cc-candybar plugin install <path | owner/repo | git URL>`),2;let a=Bie(r,process.cwd(),t.host.home,e=>ej(e)!==null);if(`error`in a)return console.error(`plugin install: ${a.error}`),2;try{let e=a.kind===`path`?a.dir:a.shown,n=Uie(t,a,n=>Kie(n,CH(En(t.host)),e,t.host.home));for(let{path:t,placed:r}of n)console.log(`${r} plugin ${E.basename(E.dirname(t))} → ${t} (from ${e})`);return 0}catch(e){return console.error(`plugin install: ${e.message}`),1}}function j9(e){switch(e.kind){case`ok`:return{output:e.value,kick:!1,debug:null};case`transient`:return{output:`
504
+ `));return d}finally{c.registry.dispose(),c.runs.close()}}function O9(e){return e.map(e=>`warning: ${e}\n`).join(``)}function Lie(e,t=!1){switch(e.kind){case`clean`:return{stdout:`✓ ${pP(e.layers.map(e=>e.path))}: config OK${e.warnings.length>0?` (${e.warnings.length} warning${e.warnings.length===1?``:`s`})`:``}\n`+(t?`${RP(e.rendered)}\n`:``),stderr:O9(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:O9(e.warnings)+`✗ ${pP(e.layers.map(e=>e.path),`<default>`)}\n${e.message}\n`,code:1};case`unreadable`:return{stdout:``,stderr:`check: cannot read ${e.path}: ${e.message}\n`,code:2}}}const k9=`--render`,A9=`Usage: cc-candybar check [${k9}] [config-file]\n`;function Rie(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`)),r=t.filter(e=>e!==k9);return r.length>0?{kind:`usage`,message:`check: unknown option ${r.join(` `)}\n${A9}`}:n.length>1?{kind:`usage`,message:`check: expected at most one path\n${A9}`}:{kind:`run`,target:n[0],render:t.includes(k9)}}async function j9(e,n){let r=Rie(e),i=t.cwd();return r.kind===`usage`?{stdout:``,stderr:r.message,code:2}:Lie(await Nie(n,Sz(),fP(r.target,n.host,i).path,i),r.render)}const zie=/^[a-z][a-z0-9+.-]*:\/\//i,Bie=/^[^@\s/]+@[^:\s/]+:/,Vie=/^([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/;function Hie(e){if(!URL.canParse(e))return e;let t=new URL(e);return t.password===``?e:(t.password=`***`,t.href)}function Uie(e,t,n,r){let i=sP(t,e,n);if(r(i))return{kind:`path`,dir:i};if(zie.test(e)||Bie.test(e))return{kind:`git`,url:e,shown:Hie(e)};let a=Vie.exec(e);if(a){let e=`https://github.com/${a[1]}.git`;return{kind:`git`,url:e,shown:e}}return{error:`"${e}" is not a directory, a GitHub repo slug (owner/repo) or a git URL`}}function Wie(e,t){let n=E.join(e,wH),r=EH(n);if(`error`in r)throw Error(`${t}: could not list ${wH}: ${r.error}`);if(r.folders.length===0)throw Error(`${t} has no plugins: none at ${wH}/<name>/${VV}`);return r.folders.map(e=>E.join(n,e,VV))}function Gie(e,t,n,r){let i=(r,...i)=>{let a=e.launchSync({bin:`git`,args:i,envOverlay:r,category:`plugin.git`});if(!a.ok)throw Error(`git ${i.map(e=>e===t?n:e).join(` `)} failed (${Ze(a)})`);return a.stdout},a={GIT_TERMINAL_PROMPT:`0`};for(let e of i(a,`rev-parse`,`--local-env-vars`).split(`
505
+ `))a[e]=void 0;i(a,`clone`,`--quiet`,`--depth`,`1`,`--filter=blob:none`,`--sparse`,`--`,t,r),i(a,`-C`,r,`sparse-checkout`,`set`,`--no-cone`,`/${wH}/`)}function Kie({host:e,launcher:t},n,r){switch(n.kind){case`path`:return r(n.dir);case`git`:{let i=s.mkdtempSync(E.join(e.tmp,`cc-candybar-plugin-`));try{return Gie(t,n.url,n.shown,E.join(i,`repo`)),r(E.join(i,`repo`))}finally{s.rmSync(i,{recursive:!0,force:!0})}}}}function qie(e){let t;try{t=s.lstatSync(e)}catch(e){if(e.code===`ENOENT`)return`installed`;throw e}if(t.isDirectory())return`updated`;if(t.isSymbolicLink())return`replaced`;throw Error(`${e} is a file, not a plugin folder: move it, then install again`)}function Jie(e,t,n,r){switch(r){case`updated`:s.renameSync(E.join(e,VV),E.join(t,VV));return;case`replaced`:s.renameSync(t,n),s.renameSync(e,t);return;case`installed`:s.renameSync(e,t);return}}function Yie(e,t,n,r){let i=Wie(e,n);s.mkdirSync(t,{recursive:!0});let a=s.mkdtempSync(E.join(t,`.install-`));try{let o=i.map(e=>{let t=E.join(a,E.basename(E.dirname(e)));s.mkdirSync(t);try{s.copyFileSync(e,E.join(t,VV))}catch(e){if(e.code!==`ENOENT`)throw e}return t}),c=BG(o.map(e=>UV(E.join(e,VV),`plugins`)),mK,{root:e,git:!1},r);if(c.length>0)throw Error(c.map(e=>`${n}: ${E.join(wH,E.relative(a,e.path))} would not load: ${e.reason.split(a).join(E.join(n,wH))}`).join(`
506
+ `));let l=o.map(e=>{let n=E.basename(e),r=E.join(t,n);return{folder:e,name:n,target:r,placed:qie(r)}}),u=[];try{for(let{folder:e,name:t,target:n,placed:r}of l)Jie(e,n,E.join(a,`.replaced-${t}`),r),u.push(t)}catch(e){throw Error(`${e.message} (placed before it: ${u.join(`, `)||`none`})`)}return l.map(({target:e,placed:t})=>({path:E.join(e,VV),placed:t}))}finally{s.rmSync(a,{recursive:!0,force:!0})}}function Xie(e,t){let[n,r,...i]=e;if(n!==`install`||r===void 0||i.length>0)return console.error(`Usage: cc-candybar plugin install <path | owner/repo | git URL>`),2;let a=Uie(r,process.cwd(),t.host.home,e=>tj(e)!==null);if(`error`in a)return console.error(`plugin install: ${a.error}`),2;try{let e=a.kind===`path`?a.dir:a.shown,n=Kie(t,a,n=>Yie(n,CH(En(t.host)),e,t.host.home));for(let{path:t,placed:r}of n)console.log(`${r} plugin ${E.basename(E.dirname(t))} → ${t} (from ${e})`);return 0}catch(e){return console.error(`plugin install: ${e.message}`),1}}function M9(e){switch(e.kind){case`ok`:return{output:e.value,kick:!1,debug:null};case`transient`:return{output:`
507
507
  `,kick:!0,debug:`daemon unavailable (transient: ${e.cause}: ${e.message}) — kicking daemon`};case`busy`:return{output:`
508
- `,kick:!1,debug:`daemon busy (${e.message}) — not kicking`};case`permanent`:return{output:cte(e),kick:!1,debug:`daemon refused request (permanent: ${e.cause}) — not kicking`}}}function M9(e,t){if(e!==void 0&&/^\+?\d+$/.test(e)){let t=Number(e);if(t>0&&t<=4294967295)return t}if(t&&t>0)return t}const Jie=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`];function N9(e,t,n){let{env:r}=e;return{termCols:M9(r.COLUMNS,n.columns),termRows:M9(r.LINES,n.rows),ssh:Jie.some(e=>(r[e]??``)!==``),tmux:Pc(r),configEnv:uP(e,t),claudeConfigDir:Xo(r,t),terminalEnv:Pn(r)}}function P9(e){return e.clients.map(e=>typeof e==`object`&&e?e:{})}function Yie(e){let t=XQ(e,[`bundle`,`clients`]);if(t!==null)return{kind:`failed`,reason:t};if(typeof e.bundle!=`string`)return{kind:`failed`,reason:`the running daemon (${e.version}) reported its bundle as ${JSON.stringify(e.bundle)}`};let n=P9(e);return n.every(e=>typeof e.ago==`number`&&typeof e.sessionId==`string`)?{kind:`ok`,value:{bundle:e.bundle,clients:n.map(e=>({client:ir(e.client)??null,sessionId:e.sessionId,ago:e.ago}))}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported clients without their age or session: ${JSON.stringify(e.clients)}`}}const Xie=e=>{let{identity:t,artifacts:n}=e??{};return typeof t==`string`&&typeof n==`object`&&!!n&&Object.values(n).every(e=>typeof e==`string`)},Zie=e=>{let t=e??{};if(t.kind===`unmeasured`)return!0;let n=t.charge;return t.kind===`measured`&&typeof t.rss==`number`&&typeof t.heapTotal==`number`&&typeof n?.bytes==`number`&&(n.kind===`charged`&&(n.measure===`phys_footprint`||n.measure===`rss`)||n.kind===`stand-in`&&typeof n.unread==`string`&&Number.isFinite(n.gap))};function F9(e,t){let n=e;if(n?.kind===`failed`&&typeof n.reason==`string`)return{kind:`failed`,reason:n.reason};if(n?.kind!==`ok`)return{kind:`misshapen`,reason:`is not an answer`};let r=t(n.value);return r.kind===`ok`?r:{kind:`misshapen`,reason:r.reason}}function Qie(e){let t=XQ(e,[`daemon`]);if(t!==null)return{kind:`failed`,reason:t};let n=e.daemon,r=F9(n?.postMortems,e=>Array.isArray(e)&&e.every(Xie)?{kind:`ok`,value:e}:{kind:`failed`,reason:`is not a list of post-mortems`});return typeof n?.pid==`number`&&Zie(n.memory)&&typeof n.limit==`number`&&r.kind!==`misshapen`?{kind:`ok`,value:{...n,postMortems:r}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported itself as ${JSON.stringify(e.daemon)}`}}function I9(e,t,n){let r=XQ(e,[`clients`]);if(r!==null)return{kind:`failed`,reason:r};let i=P9(e);return i.every(t)?{kind:`ok`,value:i}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without ${n} — restart it on this build: ${JSON.stringify(e.clients)}`}}const L9=e=>Tte.includes(e.role),$ie=e=>I9(e,e=>typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof e.claudeConfigDir==`string`&&Ete.includes(e.rateLimits),`the rate-limit windows they carried`),eae=e=>I9(e,e=>{let t=e.transcript;return typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof t?.path==`string`&&typeof t.answered==`boolean`},`their transcripts`),tae=e=>I9(e,e=>typeof e.ago==`number`&&typeof e.claudeConfigDir==`string`&&typeof e.projectDir==`string`&&typeof e.sessionId==`string`&&L9(e)&&$P.includes(e.frame),`what they drew and from which project`),nae=e=>I9(e,e=>typeof e.sessionId==`string`&&typeof e.ago==`number`&&L9(e)&&(e.termCols===null||typeof e.termCols==`number`),`whose they were or the width they measured`);function R9(e,t,n){let r=e.doctorStores?.[t],i=F9(r,n);return i.kind===`misshapen`?{kind:`failed`,reason:`the running daemon (${e.version}) reported its ${t} as ${JSON.stringify(r)}, which ${i.reason}`}:i}function rae(e){let t=XQ(e,[`doctorStores`]);if(t!==null){let e={kind:`failed`,reason:t};return{marks:e,clicked:e,postMortemsRead:e}}return{marks:R9(e,`marks`,KJ),clicked:R9(e,`clicked`,YJ),postMortemsRead:R9(e,`postMortemsRead`,sQ)}}async function z9(e){let t=await YQ(e);if(t.kind!==`ok`){let e={kind:`failed`,reason:fr(t).split(`
509
- `).join(` — `)};return{clients:e,rateLimits:e,transcripts:e,frames:e,widths:e,serving:e,stores:{marks:e,clicked:e,postMortemsRead:e}}}return{clients:Yie(t.value),rateLimits:$ie(t.value),transcripts:eae(t.value),frames:tae(t.value),widths:nae(t.value),serving:Qie(t.value),stores:rae(t.value)}}const iae=` (fix: click the settings menu (${vi} by default) › 🧰 tools › 🩺 doctor, then [fix] on the bar)`,aae=`mark them ✓ shapes or ✗ boxes in the bar's doctor, and this command reads your mark: the settings menu (${vi} by default) › 🧰 tools › 🩺 doctor`;function oae({check:e,verdict:t}){return t.ok?`✓ ${e.label}${t.note===void 0?``:` — ${t.note}`}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:iae}\n`+(t.more??[]).map(e=>` ${e}\n`).join(``)+(t.sighting===void 0?``:` look: ${t.sighting.glyphs} — ${aae}\n`)}function sae({host:e,launcher:t,clock:n},r){let i={clock:n,runs:new Kj({launcher:t,clock:n}),locations:En(e),env:e.env,sessionState:new mJ,storage:fne,signer:l9(c9(ln(e))),gates:Sz(),stateDir:ln(e)},a=e7(r.projectDir,r.cwd,r.target.path,i),o=a.state??t7(r.cwd,a.repos.plugins,i);return o.registry.dispose(),i.runs.close(),{layers:a.layers,error:a.error??(o.dropped.map(e=>e.message).join(`
510
- `)||null),warning:a.warning,unused:o.unused,config:o.config}}function cae(e,t,n){return n.kind===`failed`?n:dQ(e,n.value.bundle,eY(t,n.value.clients).map(({client:e})=>e))}function lae(e,t,n){return t.kind===`failed`?t:{kind:`ok`,value:eY(e,t.value).filter(e=>e.claudeConfigDir===n).map(e=>e.rateLimits)}}function uae(e,t){return t.kind===`failed`?t:{kind:`ok`,value:eY(e,t.value).map(e=>e.transcript)}}function dae(e,t){return t.kind===`failed`?t:{kind:`ok`,value:nY(e,t.value)}}function fae(e,t,n){return e.kind===`recent`?{kind:`ok`,value:{columns:n,of:{kind:`command`}}}:t.kind===`failed`?t:BQ(e.sessionId,eY(e,t.value))}async function pae(e,t,n,r,i,a,o=void 0){let s;try{let c=await n(),l=N9({env:r,home:e.home},i,a()),u=$J(r.CLAUDE_CODE_SESSION_ID);s={...await VQ(e,l,{projectDir:tY(u,c.frames.kind===`ok`?c.frames.value:[],i),cwd:i,target:fP(o,{env:r,home:e.home},i)},()=>null,c.serving,lae(u,c.rateLimits,Zo(l.claudeConfigDir,e.home)),uae(u,c.transcripts),u,dae(u,c.frames),fae(u,c.widths,l.termCols??null),c.stores),urlHandler:await f$(t),install:cae(e.install,u,c.clients)}}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let c=LF(s);return{stdout:c.map(oae).join(``),stderr:``,code:+!c.every(e=>e.verdict.ok)}}function mae(){if(t.stderr.isTTY)return t.stderr;let e;try{e=m(`/dev/tty`,`r+`)}catch{return{}}let n=new ve(e),{columns:r}=n;return n.destroy(),{columns:r}}const B9=`Usage: cc-candybar doctor [config-file]
511
- `;function hae(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`));return t.length>0?{kind:`usage`,message:`doctor: unknown option ${t.join(` `)}\n${B9}`}:n.length>1?{kind:`usage`,message:`doctor: expected at most one config file\n${B9}`}:{kind:`run`,configFile:n[0]}}async function gae(e,n){let r=hae(e);return r.kind===`usage`?{stdout:``,stderr:r.message,code:2}:await pae(wQ(n.launcher,e=>sae(n,e),n.host),_$(n.launcher,n),()=>z9(n),n.host.env,t.cwd(),mae,r.configFile)}function _ae(e){return!e.ok&&e.code!==`RENDER_FAILED`}function vae(e,t,n,r,i){let a=null,o=e=>{a===null&&(a=e,s.destroy(),i(e))},s=de.createConnection({path:e}),c={v:3,kind:`subscribe`,sessionId:t,lane:n};return s.once(`connect`,()=>s.write(er(c))),s.on(`data`,nr(e=>{let t=e;_ae(t)?o({kind:`refused`,resp:t}):r(t)},e=>o({kind:`failed`,error:e}))),s.on(`error`,e=>o({kind:`failed`,error:e})),s.on(`close`,()=>o({kind:`closed-there`})),{close:()=>o({kind:`closed-here`})}}function V9(e,t){switch(t){case`frame-ok`:return 250;case`frame-failed`:return e;case`fault`:return Math.min(2e3,e*2)}}function yae(e){switch(e.kind){case`failed`:return{kind:`reconnect`,reason:`stream failed (${e.error.message})`,kick:!0};case`closed-there`:return{kind:`reconnect`,reason:`daemon closed the stream`,kick:!1};case`refused`:return e.resp.code===`SWITCHED_OFF`?{kind:`off`,resp:e.resp}:e.resp.code===`TIMEOUT`?{kind:`reconnect`,reason:`the daemon was too busy to open the stream (${e.resp.error})`,kick:!1}:e.resp.code===`BAD_REQUEST`?{kind:`reconnect`,reason:`the daemon does not take subscribe (${e.resp.error}); it restarts on the new build`,kick:!1}:e.resp.code===`VERSION_MISMATCH`&&e.resp.daemonV!==void 0&&e.resp.daemonV<3?{kind:`reconnect`,reason:`the daemon is older than this client (${e.resp.error})`,kick:!0}:{kind:`exit`,reason:`the daemon refused the stream: ${e.resp.code}: ${e.resp.error}`}}}function H9(e,t,n,r,i){let a=null,o=null,s=!1,c=250,l=(t,n)=>{o=e.clock.after(t,()=>{o=null,((n?i.beforeReconnect?.():void 0)??Promise.resolve()).then(()=>{s||u()})})},u=()=>{a=vae(t,n,r,e=>{c=V9(c,e.ok?`frame-ok`:`frame-failed`),i.frame(e)},t=>{if(t.kind===`closed-here`||s)return;let n=yae(t);switch(n.kind){case`exit`:i.exit(n.reason);return;case`off`:i.off(n.resp),l(5e3,!1);return;case`reconnect`:{i.fault(n.reason,c),n.kick&&Zr(e);let t=c;c=V9(c,`fault`),l(t,!0);return}}})};return u(),{close:()=>{s=!0,o?.(),a?.close()}}}function bae(e,t){return t.kind===`frame`||t.kind!==e.kind?!0:t.kind===`fault`&&e.kind===`fault`&&t.reason!==e.reason}async function xae(e,n,r){let{values:i,tokens:a}=S({args:e.slice(3),options:{config:{type:`string`},lane:{type:`string`}},strict:!0,tokens:!0}),o=[e[1],...a.flatMap(e=>e.kind===`option`&&e.name===`config`?[e.rawName,e.value]:[])],s=t.cwd(),c=e=>{t.stderr.write(`cc-candybar frames: ${e}\n`)},l=ax(i.lane);l===null&&(c(`--lane needs one of ${Zb.join(`, `)}`),t.exit(2)),t.stdout.on(`error`,()=>t.exit(0));let u=d9(t.stdout),d=null,f=null,p=null,m={kind:`none`},h=(e,t)=>{bae(m,e)&&t(),m=e},g=async e=>{let i=await yr(r,e,o,s,{...N9(r.host,s,t.stderr),client:In(`frames`,n)});i.kind!==`ok`&&(c(fr(i)),j9(i).kick&&Zr(r))},_=e=>{p?.close(),p=H9(r,fn(r.host),e,l,{frame:e=>h({kind:`frame`},()=>u(`${JSON.stringify(e)}\n`)),off:e=>h({kind:`off`},()=>u(`${JSON.stringify(e)}\n`)),fault:(e,t)=>h({kind:`fault`,reason:e},()=>c(`${e}; reconnecting in ${t}ms`)),exit:e=>{c(e),t.exit(1)},beforeReconnect:()=>f===null?Promise.resolve():g(f)})};for await(let e of ye({input:t.stdin})){if(e.trim()===``)continue;let t;try{t=JSON.parse(e)}catch(e){c(`stdin line is not JSON: ${e.message}`);continue}if(typeof t.session_id!=`string`||t.session_id===``){c(`stdin line carries no session_id`);continue}f=t,await g(t),t.session_id!==d&&(d=t.session_id,_(d))}t.exit(0)}function Sae(e){let t=e.replace(/\n+$/,``).split(`
512
- `);return{bytes:`\x1B[?2026h`+t.map((e,t)=>`\x1b[${t+1}H${e}`).join(``)+`\x1B[J\x1B[?2026l`,rows:t.length}}const U9=5e3,W9=`usage: cc-candybar bar-pane <claude-code-pane-id, e.g. %3>`;function Cae(e,t,n,r){let i=e.split(`
513
- `).map(e=>e.trim().split(` `));return i.some(([e])=>e===n)?f7(e,d7(t)).has(r)?{kind:`shown`,zoomed:i.some(([e,,,,t])=>e===r&&t===`1`)}:{kind:`hidden`}:{kind:`gone`}}async function G9(e,t,n){let[r,i]=await Promise.all([bc(e.launcher,t,`bar-pane.tmux`,[`list-panes`,`-a`,`-f`,`#{||:#{==:#{pane_id},${n}},#{==:#{pane_id},${t.pane}}}`,`-F`,l7]),bc(e.launcher,t,`bar-pane.tmux`,[`list-clients`,`-F`,u7])]);return r.kind===`ok`?i.kind===`ok`?{kind:`ok`,placement:Cae(r.stdout,i.stdout,n,t.pane)}:i:r}function K9(e){let t=e.monotonic();return n=>{if(n.kind===`ok`)t=e.monotonic();else if(e.monotonic()-t>U9)throw Error(`tmux has not answered for ${U9/1e3} s: ${n.reason}`)}}function wae(e){let{positionals:t}=(()=>{try{return S({args:[...e],allowPositionals:!0})}catch(e){throw Error(`${e.message}\n${W9}`)}})(),[n,...r]=t;if(n===void 0||r.length>0||!/^%\d+$/.test(n))throw Error(W9);return{pane:n}}async function Tae(e,n){try{return await Eae(e,n),0}catch(e){return t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),1}}async function Eae(e,n){let{pane:r}=wae(e),i=Pc(n.host.env);if(i===null)throw Error(`cc-candybar bar-pane runs in a tmux pane`);if(!t.stdout.isTTY)throw Error(`cc-candybar bar-pane draws on its pane's terminal`);let a=await G9(n,i,r);if(a.kind!==`ok`)throw Error(a.reason);let o=a.placement;if(o.kind===`gone`)throw Error(`no pane ${r} on this tmux server (${i.socket})`);t.stdout.write(`\x1B[?25l\x1B[?7l`),t.on(`exit`,()=>t.stdout.write(`\x1B[?25h\x1B[?7h`));for(let[e,n]of[[`SIGINT`,130],[`SIGTERM`,143],[`SIGHUP`,129]])t.once(e,()=>t.exit(n));let s=e=>{t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),t.exit(1)},c=null,l=`waiting for pane ${r}'s bar`,u=()=>c?.said.latest??l,d=``,f=K9(n.clock),p=async()=>{if(o.kind!==`shown`)return;let e=Sae(u());e.rows!==t.stdout.rows&&!o.zoomed&&f(await bc(n.launcher,i,`bar-pane.tmux`,[`resize-pane`,`-t`,i.pane,`-y`,String(e.rows)])),e.bytes!==d&&t.stdout.write(e.bytes),d=e.bytes},m=null,h=!1,g=()=>{h=!0,m??=(async()=>{try{for(;h;)h=!1,await p()}finally{m=null}})(),m.catch(s)};t.stdout.on(`resize`,()=>{d=``,g()});let _=e=>{if(c?.sessionId===e)return;if(c?.follower.close(),e===null){c=null;return}let t={latest:null},r=e=>{t.latest=e,g()};c={sessionId:e,said:t,follower:H9(n,fn(n.host),e,`pane`,{frame:e=>r(j9(vr(e)).output),off:e=>r(e.error),fault:r,exit:e=>s(Error(e))})}},v=K9(n.clock);for(;o.kind!==`gone`;){if(o.kind===`hidden`)_(null);else{let e=await br(n,i.socket,r);e.kind===`ok`?(_(e.value),l=e.value===null?`waiting for pane ${r}'s statusline to render on ${fn(n.host)}`:`waiting for pane ${r}'s bar`):(e.kind===`transient`&&(Zr(n),d=``),l=fr(e))}g(),await Le(n.clock,500);let e=await G9(n,i,r);v(e),e.kind===`ok`&&(o=e.placement)}_(null),t.stderr.write(`cc-candybar bar-pane: pane ${r} closed\n`)}const Dae=(e,t)=>new Promise((n,r)=>{let i=t=>{t?t.code===`EPIPE`?n():r(t):(e.off(`error`,i),n())};e.once(`error`,i),e.write(t,i)});async function q9(e){let n=Me(()=>`delivered stdout=${Buffer.byteLength(e.stdout)} stderr=${Buffer.byteLength(e.stderr)} code=${e.code}`),r=[];for(let[i,a]of[[t.stdout,e.stdout],[t.stderr,e.stderr+n]])await Dae(i,a).catch(e=>r.push(e));if(r.length>0)throw r[0];t.exit(e.code)}const J9=i(import.meta.url),Y9=Rt(),{host:X9}=Y9;je(!!X9.env.CC_CANDYBAR_DEBUG);const Z9=e=>e.some(e=>t.argv.includes(e));function Q9(){console.log(iP);let e=ks(J9,X9),t=s.existsSync(e)?``:" (nothing is there yet: run `cc-candybar install` first — in a checkout, `pnpm build`)\n";console.log(`Starting Claude Code on ${Xb.statusline.label} yourself (a Bun-compiled Claude Code):\n ${qt(e,{dir:void 0,env:[],program:`claude`,args:[]})}\n${t}`)}const $9={install:async e=>{await Vs(e,J9,Y9),t.exit(0)},"install-url-handler":async()=>{aee(J9,Y9),t.exit(0)},"url-handle":async e=>{await Ls(e[0],Y9)},daemon:async()=>{rie(Y9)},"daemon-stats":async e=>{await q9(await qQ(Y9,e))},frames:async()=>{await xae(t.argv,J9,Y9)},check:async e=>{await q9(await A9(e,Y9))},lint:async e=>{await q9(await A9(e,Y9))},plugin:async e=>{t.exit(qie(e,Y9))},schema:async()=>{await q9(xie())},doctor:async e=>{await q9(await gae(e,Y9))},"bar-pane":async e=>{t.exit(await Tae(e,Y9))},...Object.fromEntries(I6.map(e=>[e,async t=>{await q9(await die(Y9,e,t))}]))};async function Oae(){let e=t.argv[2],n=e!==void 0&&!e.startsWith(`-`)?e:null;try{if(n!==null&&!Object.hasOwn($9,n)&&(console.error(`cc-candybar: unknown subcommand ${JSON.stringify(n)} — see --help`),t.exit(2)),Z9($N.help)&&(Q9(),t.exit(0)),Z9($N.version)&&(console.log(`cc-candybar ${tn}`),t.exit(0)),n!==null){await $9[n](t.argv.slice(3));return}t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
508
+ `,kick:!1,debug:`daemon busy (${e.message}) — not kicking`};case`permanent`:return{output:cte(e),kick:!1,debug:`daemon refused request (permanent: ${e.cause}) — not kicking`}}}function N9(e,t){if(e!==void 0&&/^\+?\d+$/.test(e)){let t=Number(e);if(t>0&&t<=4294967295)return t}if(t&&t>0)return t}const Zie=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`];function P9(e,t,n){let{env:r}=e;return{termCols:N9(r.COLUMNS,n.columns),termRows:N9(r.LINES,n.rows),ssh:Zie.some(e=>(r[e]??``)!==``),tmux:Pc(r),configEnv:uP(e,t),claudeConfigDir:Xo(r,t),terminalEnv:Pn(r)}}function F9(e){return e.clients.map(e=>typeof e==`object`&&e?e:{})}function Qie(e){let t=XQ(e,[`bundle`,`clients`]);if(t!==null)return{kind:`failed`,reason:t};if(typeof e.bundle!=`string`)return{kind:`failed`,reason:`the running daemon (${e.version}) reported its bundle as ${JSON.stringify(e.bundle)}`};let n=F9(e);return n.every(e=>typeof e.ago==`number`&&typeof e.sessionId==`string`)?{kind:`ok`,value:{bundle:e.bundle,clients:n.map(e=>({client:ir(e.client)??null,sessionId:e.sessionId,ago:e.ago}))}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported clients without their age or session: ${JSON.stringify(e.clients)}`}}const $ie=e=>{let{identity:t,artifacts:n}=e??{};return typeof t==`string`&&typeof n==`object`&&!!n&&Object.values(n).every(e=>typeof e==`string`)},eae=e=>{let t=e??{};if(t.kind===`unmeasured`)return!0;let n=t.charge;return t.kind===`measured`&&typeof t.rss==`number`&&typeof t.heapTotal==`number`&&typeof n?.bytes==`number`&&(n.kind===`charged`&&(n.measure===`phys_footprint`||n.measure===`rss`)||n.kind===`stand-in`&&typeof n.unread==`string`&&Number.isFinite(n.gap))};function I9(e,t){let n=e;if(n?.kind===`failed`&&typeof n.reason==`string`)return{kind:`failed`,reason:n.reason};if(n?.kind!==`ok`)return{kind:`misshapen`,reason:`is not an answer`};let r=t(n.value);return r.kind===`ok`?r:{kind:`misshapen`,reason:r.reason}}function tae(e){let t=XQ(e,[`daemon`]);if(t!==null)return{kind:`failed`,reason:t};let n=e.daemon,r=I9(n?.postMortems,e=>Array.isArray(e)&&e.every($ie)?{kind:`ok`,value:e}:{kind:`failed`,reason:`is not a list of post-mortems`});return typeof n?.pid==`number`&&eae(n.memory)&&typeof n.limit==`number`&&r.kind!==`misshapen`?{kind:`ok`,value:{...n,postMortems:r}}:{kind:`failed`,reason:`the running daemon (${e.version}) reported itself as ${JSON.stringify(e.daemon)}`}}function L9(e,t,n){let r=XQ(e,[`clients`]);if(r!==null)return{kind:`failed`,reason:r};let i=F9(e);return i.every(t)?{kind:`ok`,value:i}:{kind:`failed`,reason:`the running daemon (${e.version}) reported its renders without ${n} — restart it on this build: ${JSON.stringify(e.clients)}`}}const R9=e=>Tte.includes(e.role),nae=e=>L9(e,e=>typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof e.claudeConfigDir==`string`&&Ete.includes(e.rateLimits),`the rate-limit windows they carried`),rae=e=>L9(e,e=>{let t=e.transcript;return typeof e.ago==`number`&&typeof e.sessionId==`string`&&typeof t?.path==`string`&&typeof t.answered==`boolean`},`their transcripts`),iae=e=>L9(e,e=>typeof e.ago==`number`&&typeof e.claudeConfigDir==`string`&&typeof e.projectDir==`string`&&typeof e.sessionId==`string`&&R9(e)&&$P.includes(e.frame),`what they drew and from which project`),aae=e=>L9(e,e=>typeof e.sessionId==`string`&&typeof e.ago==`number`&&R9(e)&&(e.termCols===null||typeof e.termCols==`number`),`whose they were or the width they measured`);function z9(e,t,n){let r=e.doctorStores?.[t],i=I9(r,n);return i.kind===`misshapen`?{kind:`failed`,reason:`the running daemon (${e.version}) reported its ${t} as ${JSON.stringify(r)}, which ${i.reason}`}:i}function oae(e){let t=XQ(e,[`doctorStores`]);if(t!==null){let e={kind:`failed`,reason:t};return{marks:e,clicked:e,postMortemsRead:e}}return{marks:z9(e,`marks`,KJ),clicked:z9(e,`clicked`,YJ),postMortemsRead:z9(e,`postMortemsRead`,sQ)}}async function sae(e){let t=await YQ(e);if(t.kind!==`ok`){let e={kind:`failed`,reason:fr(t).split(`
509
+ `).join(` — `)};return{clients:e,rateLimits:e,transcripts:e,frames:e,widths:e,serving:e,stores:{marks:e,clicked:e,postMortemsRead:e}}}return{clients:Qie(t.value),rateLimits:nae(t.value),transcripts:rae(t.value),frames:iae(t.value),widths:aae(t.value),serving:tae(t.value),stores:oae(t.value)}}const cae=` (fix: click the settings menu (${vi} by default) › 🧰 tools › 🩺 doctor, then [fix] on the bar)`,lae=`mark them ✓ shapes or ✗ boxes in the bar's doctor, and this command reads your mark: the settings menu (${vi} by default) › 🧰 tools › 🩺 doctor`;function uae({check:e,verdict:t}){return t.ok?`✓ ${e.label}${t.note===void 0?``:` — ${t.note}`}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:cae}\n`+(t.more??[]).map(e=>` ${e}\n`).join(``)+(t.sighting===void 0?``:` look: ${t.sighting.glyphs} — ${lae}\n`)}function dae({host:e,launcher:t,clock:n},r){let i={clock:n,runs:new Kj({launcher:t,clock:n}),locations:En(e),env:e.env,sessionState:new mJ,storage:pne,signer:u9(l9(ln(e))),gates:Sz(),stateDir:ln(e)},a=e7(r.projectDir,r.cwd,r.target.path,i),o=a.state??t7(r.cwd,a.repos.plugins,i);return o.registry.dispose(),i.runs.close(),{layers:a.layers,error:a.error??(o.dropped.map(e=>e.message).join(`
510
+ `)||null),warning:a.warning,unused:o.unused,config:o.config}}function fae(e,t,n){return n.kind===`failed`?n:dQ(e,n.value.bundle,eY(t,n.value.clients).map(({client:e})=>e))}function pae(e,t,n){return t.kind===`failed`?t:{kind:`ok`,value:eY(e,t.value).filter(e=>e.claudeConfigDir===n).map(e=>e.rateLimits)}}function mae(e,t){return t.kind===`failed`?t:{kind:`ok`,value:eY(e,t.value).map(e=>e.transcript)}}function hae(e,t){return t.kind===`failed`?t:{kind:`ok`,value:nY(e,t.value)}}function gae(e,t,n){return e.kind===`recent`?{kind:`ok`,value:{columns:n,of:{kind:`command`}}}:t.kind===`failed`?t:BQ(e.sessionId,eY(e,t.value))}async function _ae(e,t,n,r,i,a,o=void 0){let s;try{let c=await n(),l=P9({env:r,home:e.home},i,a()),u=$J(r.CLAUDE_CODE_SESSION_ID);s={...await VQ(e,l,{projectDir:tY(u,c.frames.kind===`ok`?c.frames.value:[],i),cwd:i,target:fP(o,{env:r,home:e.home},i)},()=>null,c.serving,pae(u,c.rateLimits,Zo(l.claudeConfigDir,e.home)),mae(u,c.transcripts),u,hae(u,c.frames),gae(u,c.widths,l.termCols??null),c.stores),urlHandler:await f$(t),install:fae(e.install,u,c.clients)}}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let c=LF(s);return{stdout:c.map(uae).join(``),stderr:``,code:+!c.every(e=>e.verdict.ok)}}function vae(){if(t.stderr.isTTY)return t.stderr;let e;try{e=m(`/dev/tty`,`r+`)}catch{return{}}let n=new _e(e),{columns:r}=n;return n.destroy(),{columns:r}}const B9=`Usage: cc-candybar doctor [config-file]
511
+ `;function yae(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`));return t.length>0?{kind:`usage`,message:`doctor: unknown option ${t.join(` `)}\n${B9}`}:n.length>1?{kind:`usage`,message:`doctor: expected at most one config file\n${B9}`}:{kind:`run`,configFile:n[0]}}async function bae(e,n){let r=yae(e);return r.kind===`usage`?{stdout:``,stderr:r.message,code:2}:await _ae(wQ(n.launcher,e=>dae(n,e),n.host),_$(n.launcher,n),()=>sae(n),n.host.env,t.cwd(),vae,r.configFile)}function xae(e){return!e.ok&&e.code!==`RENDER_FAILED`}function Sae(e,t,n,r,i){let a=null,o=e=>{a===null&&(a=e,s.destroy(),i(e))},s=ue.createConnection({path:e}),c={v:3,kind:`subscribe`,sessionId:t,lane:n};return s.once(`connect`,()=>s.write(er(c))),s.on(`data`,nr(e=>{let t=e;xae(t)?o({kind:`refused`,resp:t}):r(t)},e=>o({kind:`failed`,error:e}))),s.on(`error`,e=>o({kind:`failed`,error:e})),s.on(`close`,()=>o({kind:`closed-there`})),{close:()=>o({kind:`closed-here`})}}function V9(e,t){switch(t){case`frame-ok`:return 250;case`frame-failed`:return e;case`fault`:return Math.min(2e3,e*2)}}function Cae(e){switch(e.kind){case`failed`:return{kind:`reconnect`,reason:`stream failed (${e.error.message})`,kick:!0};case`closed-there`:return{kind:`reconnect`,reason:`daemon closed the stream`,kick:!1};case`refused`:return e.resp.code===`SWITCHED_OFF`?{kind:`off`,resp:e.resp}:e.resp.code===`TIMEOUT`?{kind:`reconnect`,reason:`the daemon was too busy to open the stream (${e.resp.error})`,kick:!1}:e.resp.code===`BAD_REQUEST`?{kind:`reconnect`,reason:`the daemon does not take subscribe (${e.resp.error}); it restarts on the new build`,kick:!1}:e.resp.code===`VERSION_MISMATCH`&&e.resp.daemonV!==void 0&&e.resp.daemonV<3?{kind:`reconnect`,reason:`the daemon is older than this client (${e.resp.error})`,kick:!0}:{kind:`exit`,reason:`the daemon refused the stream: ${e.resp.code}: ${e.resp.error}`}}}function H9(e,t,n,r,i){let a=null,o=null,s=!1,c=250,l=(t,n)=>{o=e.clock.after(t,()=>{o=null,((n?i.beforeReconnect?.():void 0)??Promise.resolve()).then(()=>{s||u()})})},u=()=>{a=Sae(t,n,r,e=>{c=V9(c,e.ok?`frame-ok`:`frame-failed`),i.frame(e)},t=>{if(t.kind===`closed-here`||s)return;let n=Cae(t);switch(n.kind){case`exit`:i.exit(n.reason);return;case`off`:i.off(n.resp),l(5e3,!1);return;case`reconnect`:{i.fault(n.reason,c),n.kick&&Zr(e);let t=c;c=V9(c,`fault`),l(t,!0);return}}})};return u(),{close:()=>{s=!0,o?.(),a?.close()}}}function wae(e,t){return t.kind===`frame`||t.kind!==e.kind?!0:t.kind===`fault`&&e.kind===`fault`&&t.reason!==e.reason}async function Tae(e,n,r){let{values:i,tokens:a}=S({args:e.slice(3),options:{config:{type:`string`},lane:{type:`string`}},strict:!0,tokens:!0}),o=[e[1],...a.flatMap(e=>e.kind===`option`&&e.name===`config`?[e.rawName,e.value]:[])],s=t.cwd(),c=e=>{t.stderr.write(`cc-candybar frames: ${e}\n`)},l=ax(i.lane);l===null&&(c(`--lane needs one of ${Zb.join(`, `)}`),t.exit(2)),t.stdout.on(`error`,()=>t.exit(0));let u=f9(t.stdout),d=null,f=null,p=null,m={kind:`none`},h=(e,t)=>{wae(m,e)&&t(),m=e},g=async e=>{let i=await yr(r,e,o,s,{...P9(r.host,s,t.stderr),client:In(`frames`,n)});i.kind!==`ok`&&(c(fr(i)),M9(i).kick&&Zr(r))},_=e=>{p?.close(),p=H9(r,fn(r.host),e,l,{frame:e=>h({kind:`frame`},()=>u(`${JSON.stringify(e)}\n`)),off:e=>h({kind:`off`},()=>u(`${JSON.stringify(e)}\n`)),fault:(e,t)=>h({kind:`fault`,reason:e},()=>c(`${e}; reconnecting in ${t}ms`)),exit:e=>{c(e),t.exit(1)},beforeReconnect:()=>f===null?Promise.resolve():g(f)})};for await(let e of ve({input:t.stdin})){if(e.trim()===``)continue;let t;try{t=JSON.parse(e)}catch(e){c(`stdin line is not JSON: ${e.message}`);continue}if(typeof t.session_id!=`string`||t.session_id===``){c(`stdin line carries no session_id`);continue}f=t,await g(t),t.session_id!==d&&(d=t.session_id,_(d))}t.exit(0)}function Eae(e){let t=e.replace(/\n+$/,``).split(`
512
+ `);return{bytes:`\x1B[?2026h`+t.map((e,t)=>`\x1b[${t+1}H${e}`).join(``)+`\x1B[J\x1B[?2026l`,rows:t.length}}const U9=5e3,W9=`usage: cc-candybar bar-pane <claude-code-pane-id, e.g. %3>`;function Dae(e,t,n,r){let i=e.split(`
513
+ `).map(e=>e.trim().split(` `));return i.some(([e])=>e===n)?f7(e,d7(t)).has(r)?{kind:`shown`,zoomed:i.some(([e,,,,t])=>e===r&&t===`1`)}:{kind:`hidden`}:{kind:`gone`}}async function G9(e,t,n){let[r,i]=await Promise.all([bc(e.launcher,t,`bar-pane.tmux`,[`list-panes`,`-a`,`-f`,`#{||:#{==:#{pane_id},${n}},#{==:#{pane_id},${t.pane}}}`,`-F`,l7]),bc(e.launcher,t,`bar-pane.tmux`,[`list-clients`,`-F`,u7])]);return r.kind===`ok`?i.kind===`ok`?{kind:`ok`,placement:Dae(r.stdout,i.stdout,n,t.pane)}:i:r}function K9(e){let t=e.monotonic();return n=>{if(n.kind===`ok`)t=e.monotonic();else if(e.monotonic()-t>U9)throw Error(`tmux has not answered for ${U9/1e3} s: ${n.reason}`)}}function Oae(e){let{positionals:t}=(()=>{try{return S({args:[...e],allowPositionals:!0})}catch(e){throw Error(`${e.message}\n${W9}`)}})(),[n,...r]=t;if(n===void 0||r.length>0||!/^%\d+$/.test(n))throw Error(W9);return{pane:n}}async function kae(e,n){try{return await Aae(e,n),0}catch(e){return t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),1}}async function Aae(e,n){let{pane:r}=Oae(e),i=Pc(n.host.env);if(i===null)throw Error(`cc-candybar bar-pane runs in a tmux pane`);if(!t.stdout.isTTY)throw Error(`cc-candybar bar-pane draws on its pane's terminal`);let a=await G9(n,i,r);if(a.kind!==`ok`)throw Error(a.reason);let o=a.placement;if(o.kind===`gone`)throw Error(`no pane ${r} on this tmux server (${i.socket})`);t.stdout.write(`\x1B[?25l\x1B[?7l`),t.on(`exit`,()=>t.stdout.write(`\x1B[?25h\x1B[?7h`));for(let[e,n]of[[`SIGINT`,130],[`SIGTERM`,143],[`SIGHUP`,129]])t.once(e,()=>t.exit(n));let s=e=>{t.stderr.write(`cc-candybar bar-pane: ${e.message}\n`),t.exit(1)},c=null,l=`waiting for pane ${r}'s bar`,u=()=>c?.said.latest??l,d=``,f=K9(n.clock),p=async()=>{if(o.kind!==`shown`)return;let e=Eae(u());e.rows!==t.stdout.rows&&!o.zoomed&&f(await bc(n.launcher,i,`bar-pane.tmux`,[`resize-pane`,`-t`,i.pane,`-y`,String(e.rows)])),e.bytes!==d&&t.stdout.write(e.bytes),d=e.bytes},m=null,h=!1,g=()=>{h=!0,m??=(async()=>{try{for(;h;)h=!1,await p()}finally{m=null}})(),m.catch(s)};t.stdout.on(`resize`,()=>{d=``,g()});let _=e=>{if(c?.sessionId===e)return;if(c?.follower.close(),e===null){c=null;return}let t={latest:null},r=e=>{t.latest=e,g()};c={sessionId:e,said:t,follower:H9(n,fn(n.host),e,`pane`,{frame:e=>r(M9(vr(e)).output),off:e=>r(e.error),fault:r,exit:e=>s(Error(e))})}},v=K9(n.clock);for(;o.kind!==`gone`;){if(o.kind===`hidden`)_(null);else{let e=await br(n,i.socket,r);e.kind===`ok`?(_(e.value),l=e.value===null?`waiting for pane ${r}'s statusline to render on ${fn(n.host)}`:`waiting for pane ${r}'s bar`):(e.kind===`transient`&&(Zr(n),d=``),l=fr(e))}g(),await Le(n.clock,500);let e=await G9(n,i,r);v(e),e.kind===`ok`&&(o=e.placement)}_(null),t.stderr.write(`cc-candybar bar-pane: pane ${r} closed\n`)}const jae=(e,t)=>new Promise((n,r)=>{let i=t=>{t?t.code===`EPIPE`?n():r(t):(e.off(`error`,i),n())};e.once(`error`,i),e.write(t,i)});async function q9(e){let n=je(()=>`delivered stdout=${Buffer.byteLength(e.stdout)} stderr=${Buffer.byteLength(e.stderr)} code=${e.code}`),r=[];for(let[i,a]of[[t.stdout,e.stdout],[t.stderr,e.stderr+n]])await jae(i,a).catch(e=>r.push(e));if(r.length>0)throw r[0];t.exit(e.code)}const J9=i(import.meta.url),Y9=Rt(),{host:X9}=Y9;Ae(!!X9.env.CC_CANDYBAR_DEBUG);const Z9=e=>e.some(e=>t.argv.includes(e));function Q9(){console.log(iP);let e=ks(J9,X9),t=s.existsSync(e)?``:" (nothing is there yet: run `cc-candybar install` first — in a checkout, `pnpm build`)\n";console.log(`Starting Claude Code on ${Xb.statusline.label} yourself (a Bun-compiled Claude Code):\n ${qt(e,{dir:void 0,env:[],program:`claude`,args:[]})}\n${t}`)}const $9={install:async e=>{await Vs(e,J9,Y9),t.exit(0)},"install-url-handler":async()=>{aee(J9,Y9),t.exit(0)},"url-handle":async e=>{await Ls(e[0],Y9)},daemon:async()=>{oie(Y9)},"daemon-stats":async e=>{await q9(await qQ(Y9,e))},frames:async()=>{await Tae(t.argv,J9,Y9)},check:async e=>{await q9(await j9(e,Y9))},lint:async e=>{await q9(await j9(e,Y9))},plugin:async e=>{t.exit(Xie(e,Y9))},schema:async()=>{await q9(wie())},doctor:async e=>{await q9(await bae(e,Y9))},"bar-pane":async e=>{t.exit(await kae(e,Y9))},...Object.fromEntries(L6.map(e=>[e,async t=>{await q9(await mie(Y9,e,t))}]))};async function Mae(){let e=t.argv[2],n=e!==void 0&&!e.startsWith(`-`)?e:null;try{if(n!==null&&!Object.hasOwn($9,n)&&(console.error(`cc-candybar: unknown subcommand ${JSON.stringify(n)} — see --help`),t.exit(2)),Z9($N.help)&&(Q9(),t.exit(0)),Z9($N.version)&&(console.log(`cc-candybar ${tn}`),t.exit(0)),n!==null){await $9[n](t.argv.slice(3));return}t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
514
514
 
515
515
  cc-candybar is designed to be used as a Claude Code statusLine command.
516
516
  It reads hook data from stdin and outputs formatted statusline.
@@ -526,4 +526,4 @@ Add to ~/.claude/settings.json:
526
526
  Run with --help for more options.
527
527
 
528
528
  To test output manually:
529
- echo '{"session_id":"test-session","workspace":{"project_dir":"/path/to/project"},"model":{"id":"claude-sonnet-4-5","display_name":"Claude"}}' | cc-candybar`),t.exit(1)),k(`Working directory: ${t.cwd()}`),k(`Process args:`,t.argv);let e=await a(t.stdin);k(`Received hook data:`,JSON.stringify(e,null,2)),e||(console.error(`Error: No input data received from stdin`),Q9(),t.exit(1));let r=j9(await yr(Y9,e,t.argv.slice(1),t.cwd(),{...N9(X9,t.cwd(),t.stderr),client:In(`node`,J9)}));r.debug!==null&&k(r.debug),r.kick&&Zr(Y9),await q9({stdout:r.output,stderr:``,code:0})}catch(e){let t=e instanceof Error?e.message:String(e);await q9({stdout:``,stderr:`cc-candybar ${n??`statusline`}: ${t}\n`,code:1})}}Oae();export{};
529
+ echo '{"session_id":"test-session","workspace":{"project_dir":"/path/to/project"},"model":{"id":"claude-sonnet-4-5","display_name":"Claude"}}' | cc-candybar`),t.exit(1)),A(`Working directory: ${t.cwd()}`),A(`Process args:`,t.argv);let e=await a(t.stdin);A(`Received hook data:`,JSON.stringify(e,null,2)),e||(console.error(`Error: No input data received from stdin`),Q9(),t.exit(1));let r=M9(await yr(Y9,e,t.argv.slice(1),t.cwd(),{...P9(X9,t.cwd(),t.stderr),client:In(`node`,J9)}));r.debug!==null&&A(r.debug),r.kick&&Zr(Y9),await q9({stdout:r.output,stderr:``,code:0})}catch(e){let t=e instanceof Error?e.message:String(e);await q9({stdout:``,stderr:`cc-candybar ${n??`statusline`}: ${t}\n`,code:1})}}Mae();export{};