@promptctl/cc-candybar 1.114.0 → 1.115.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"node:module";import t from"node:process";import{json as n}from"node:stream/consumers";import r,{createReadStream as i,existsSync as a,statSync as o,watch as s}from"node:fs";import c,{basename as l,dirname as u,isAbsolute as d,join as f,sep as p}from"node:path";import m,{homedir as h}from"node:os";import{spawn as g,spawnSync as _}from"node:child_process";import{parseArgs as v,types as y}from"node:util";import b from"node:net";import{open as x,readFile as S,readdir as C,stat as w}from"node:fs/promises";import{clearInterval as ee,setInterval as te}from"node:timers";import ne from"node:v8";import{URL as T,URLSearchParams as re,fileURLToPath as E,pathToFileURL as D}from"node:url";import ie,{createHash as ae}from"node:crypto";import{get as oe}from"node:https";import{setTimeout as se}from"node:timers/promises";import{createInterface as ce}from"node:readline";var le=Object.create,ue=Object.defineProperty,de=Object.getOwnPropertyDescriptor,fe=Object.getOwnPropertyNames,pe=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty,he=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),ge=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=fe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!me.call(e,s)&&s!==n&&ue(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=de(t,s))||r.enumerable});return e},_e=(e,t,n)=>(n=e==null?{}:le(pe(e)),ge(t||!e||!e.__esModule?ue(n,`default`,{value:e,enumerable:!0}):n,e));function O(e,...t){process.env.CC_CANDYBAR_DEBUG&&console.error(`[DEBUG] ${e}`,...t)}function ve(e,t){return y.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!a(t)?`working directory does not exist: ${t}`:e.message:String(e)}const ye={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"claude-input.type":1e3},be=new Map;function xe(e){let t=ye[e];if(t===void 0)return{allowed:!0};let n=be.get(e);if(n===void 0)return{allowed:!0};let r=Date.now()-n;return r>=t?{allowed:!0}:{allowed:!1,minIntervalMs:t,sinceLastMs:r}}function Se(e){be.set(e,Date.now())}function Ce(e){return e.env??process.env}function we(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 ${n}ms ago`}}let Te=null;function Ee(e){Te=e}function De(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function Oe(e){if(e.signal?.aborted)return{ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null};let t=xe(e.category);if(!t.allowed)return we(e.category,t.minIntervalMs,t.sinceLastMs);Se(e.category);let n=Date.now();return Te?.onStart(e.category),new Promise(t=>{let r;try{r=g(e.bin,e.args??[],{cwd:e.cwd,env:Ce(e),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(r){Te?.onEnd(e.category,Date.now()-n),t({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:ve(r,e.cwd)});return}let i=``,a=``,o=!1,s=null,c=null,l=null,u=()=>m(`aborted`),d=t=>{o||(o=!0,s&&clearTimeout(s),c&&clearTimeout(c),e.signal?.removeEventListener(`abort`,u),Te?.onEnd(e.category,Date.now()-n),t())},f=e=>d(()=>t(e)),p=(e,t)=>{try{De(e,t)}catch(e){f({ok:!1,reason:`signal-refused`,stdout:i,stderr:a,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)})}},m=t=>{l=t,s&&clearTimeout(s),e.signal?.removeEventListener(`abort`,u);let n=r.pid;n!==void 0&&(c=setTimeout(()=>p(n,`SIGKILL`),250),p(n,`SIGTERM`))};r.stdout?.on(`data`,e=>{i+=e.toString(`utf8`)}),r.stderr?.on(`data`,e=>{a+=e.toString(`utf8`)}),r.on(`error`,t=>{f({ok:!1,reason:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:null,error:ve(t,e.cwd)})}),r.on(`close`,(e,t)=>{if(l!==null){f({ok:!1,reason:l,stdout:i,stderr:a,exitCode:e,signal:t});return}if(e===0){f({ok:!0,stdout:i,stderr:a,exitCode:e});return}f({ok:!1,reason:t?`signal`:`non-zero`,stdout:i,stderr:a,exitCode:e,signal:t})}),e.timeoutMs&&e.timeoutMs>0&&(s=setTimeout(()=>m(`timeout`),e.timeoutMs)),e.signal?.addEventListener(`abort`,u,{once:!0}),e.stdinInput!==void 0&&r.stdin?r.stdin.end(e.stdinInput):r.stdin&&r.stdin.end()})}function ke(e){let t=xe(e.category);if(!t.allowed)return we(e.category,t.minIntervalMs,t.sinceLastMs);Se(e.category);let n=Date.now();Te?.onStart(e.category);let r=[`pipe`,`pipe`,`pipe`];try{let t=_(e.bin,e.args??[],{cwd:e.cwd,env:Ce(e),input:e.stdinInput,timeout:e.timeoutMs&&e.timeoutMs>0?e.timeoutMs:void 0,stdio:r,encoding:`utf8`});Te?.onEnd(e.category,Date.now()-n);let i=typeof t.stdout==`string`?t.stdout:``,a=typeof t.stderr==`string`?t.stderr:``;if(t.error)return{ok:!1,reason:t.error.code===`ETIMEDOUT`?`timeout`:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:t.signal??null,error:ve(t.error,e.cwd)};if(t.status===0)return{ok:!0,stdout:i,stderr:a,exitCode:t.status};let o=e.timeoutMs!==void 0&&e.timeoutMs>0;return{ok:!1,reason:t.signal?o&&t.signal===`SIGTERM`?`timeout`:`signal`:`non-zero`,stdout:i,stderr:a,exitCode:t.status,signal:t.signal??null}}catch(t){return Te?.onEnd(e.category,Date.now()-n),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:ve(t,e.cwd)}}}function Ae(e){let t=xe(e.category);if(!t.allowed)return we(e.category,t.minIntervalMs,t.sinceLastMs);Se(e.category);let n=Date.now();Te?.onStart(e.category);let r=k(e);return Te?.onEnd(e.category,Date.now()-n),r}function k(e){let t;try{t=g(e.bin,e.args??[],{cwd:e.cwd,env:Ce(e),detached:!0,stdio:`ignore`})}catch(t){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:ve(t,e.cwd)}}return t.once(`error`,()=>{}),t.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${e.bin}): no pid (binary not found or unexecutable)`}:(t.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}function je(e,t,n){let i=`${e}.tmp`,a=n??r.statSync(e,{throwIfNoEntry:!1})?.mode;try{r.writeFileSync(i,t,a===void 0?{}:{mode:a}),r.renameSync(i,e)}catch(e){throw r.rmSync(i,{force:!0}),e}}function Me(e,t){let n=e[t];return n&&n.length>0?n:void 0}function Ne(e=process.env){let t=Me(e,`XDG_STATE_HOME`)??c.join(m.homedir(),`.local`,`state`);return c.join(t,`cc-candybar`)}function Pe(){let e=Me(process.env,`XDG_CACHE_HOME`)??c.join(m.homedir(),`.cache`);return c.join(e,`cc-candybar`)}function Fe(){return Ne()}function Ie(){let e=process.env.CC_CANDYBAR_SOCKET;if(e)return e;let t=m.userInfo().uid;return c.join(`/tmp`,`cc-candybar-${t}`,`socket`)}function Le(e){r.mkdirSync(e,{recursive:!0,mode:448});let t=r.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=m.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 Re(e){Le(c.dirname(e));for(let t of[e,ze(e)])try{if(r.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function ze(e){return`${e}.lease`}function Be(){return ze(Ie())}function Ve(){return c.join(Ne(),`session-state.json`)}function He(){return c.join(Ne(),`settings-history.json`)}function Ue(){let e=process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(e)return e;let t=m.userInfo().uid;return c.join(`/tmp`,`cc-candybar-${t}`,`daemons`)}function We(){return c.join(Ne(),`spawn.lock`)}function Ge(){return c.join(Ne(),`spawn.cooldown`)}function Ke(){return c.join(Ne(),`spawn.backoff`)}function qe(){return c.join(Ne(),`diagnostics`)}function Je(e=process.env){return c.join(Ne(e),`daemon.log`)}const Ye=[`MEMENTO_CONFIG_HOME`,`XDG_CONFIG_HOME`];function Xe(e,t){return Object.fromEntries(Ye.flatMap(n=>{let r=e[n]??``;return r===``?[]:[[n,c.resolve(t,r)]]}))}var Ze=he(((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]/})),Qe=he(((e,t)=>{let n=Ze();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)}}})),$e=he(((e,t)=>{let n=Qe(),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(),ne[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{json as n}from"node:stream/consumers";import r,{createReadStream as i,existsSync as a,statSync as o,watch as s}from"node:fs";import c,{basename as l,dirname as u,isAbsolute as d,join as f,sep as p}from"node:path";import m,{homedir as h}from"node:os";import{spawn as g,spawnSync as _}from"node:child_process";import{parseArgs as v,types as y}from"node:util";import b from"node:net";import{open as x,readFile as S,readdir as C,stat as w}from"node:fs/promises";import{clearInterval as T,setInterval as ee}from"node:timers";import te from"node:v8";import{URL as ne,URLSearchParams as re,fileURLToPath as E,pathToFileURL as D}from"node:url";import ie,{createHash as ae}from"node:crypto";import{get as oe}from"node:https";import{setTimeout as se}from"node:timers/promises";import{createInterface as ce}from"node:readline";var le=Object.create,ue=Object.defineProperty,de=Object.getOwnPropertyDescriptor,fe=Object.getOwnPropertyNames,pe=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty,he=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),ge=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=fe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!me.call(e,s)&&s!==n&&ue(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=de(t,s))||r.enumerable});return e},_e=(e,t,n)=>(n=e==null?{}:le(pe(e)),ge(t||!e||!e.__esModule?ue(n,`default`,{value:e,enumerable:!0}):n,e));function O(e,...t){process.env.CC_CANDYBAR_DEBUG&&console.error(`[DEBUG] ${e}`,...t)}function ve(e,t){return y.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!a(t)?`working directory does not exist: ${t}`:e.message:String(e)}const ye={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"claude-input.type":1e3},be=new Map;function xe(e){let t=ye[e];if(t===void 0)return{allowed:!0};let n=be.get(e);if(n===void 0)return{allowed:!0};let r=Date.now()-n;return r>=t?{allowed:!0}:{allowed:!1,minIntervalMs:t,sinceLastMs:r}}function Se(e){be.set(e,Date.now())}function Ce(e){return e.env??process.env}function we(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 ${n}ms ago`}}let Te=null;function Ee(e){Te=e}function De(e,t){try{process.kill(-e,t)}catch(e){if(e.code!==`ESRCH`)throw e}}async function Oe(e){if(e.signal?.aborted)return{ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null};let t=xe(e.category);if(!t.allowed)return we(e.category,t.minIntervalMs,t.sinceLastMs);Se(e.category);let n=Date.now();return Te?.onStart(e.category),new Promise(t=>{let r;try{r=g(e.bin,e.args??[],{cwd:e.cwd,env:Ce(e),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(r){Te?.onEnd(e.category,Date.now()-n),t({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:ve(r,e.cwd)});return}let i=``,a=``,o=!1,s=null,c=null,l=null,u=()=>m(`aborted`),d=t=>{o||(o=!0,s&&clearTimeout(s),c&&clearTimeout(c),e.signal?.removeEventListener(`abort`,u),Te?.onEnd(e.category,Date.now()-n),t())},f=e=>d(()=>t(e)),p=(e,t)=>{try{De(e,t)}catch(e){f({ok:!1,reason:`signal-refused`,stdout:i,stderr:a,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)})}},m=t=>{l=t,s&&clearTimeout(s),e.signal?.removeEventListener(`abort`,u);let n=r.pid;n!==void 0&&(c=setTimeout(()=>p(n,`SIGKILL`),250),p(n,`SIGTERM`))};r.stdout?.on(`data`,e=>{i+=e.toString(`utf8`)}),r.stderr?.on(`data`,e=>{a+=e.toString(`utf8`)}),r.on(`error`,t=>{f({ok:!1,reason:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:null,error:ve(t,e.cwd)})}),r.on(`close`,(e,t)=>{if(l!==null){f({ok:!1,reason:l,stdout:i,stderr:a,exitCode:e,signal:t});return}if(e===0){f({ok:!0,stdout:i,stderr:a,exitCode:e});return}f({ok:!1,reason:t?`signal`:`non-zero`,stdout:i,stderr:a,exitCode:e,signal:t})}),e.timeoutMs&&e.timeoutMs>0&&(s=setTimeout(()=>m(`timeout`),e.timeoutMs)),e.signal?.addEventListener(`abort`,u,{once:!0}),e.stdinInput!==void 0&&r.stdin?r.stdin.end(e.stdinInput):r.stdin&&r.stdin.end()})}function ke(e){let t=xe(e.category);if(!t.allowed)return we(e.category,t.minIntervalMs,t.sinceLastMs);Se(e.category);let n=Date.now();Te?.onStart(e.category);let r=[`pipe`,`pipe`,`pipe`];try{let t=_(e.bin,e.args??[],{cwd:e.cwd,env:Ce(e),input:e.stdinInput,timeout:e.timeoutMs&&e.timeoutMs>0?e.timeoutMs:void 0,stdio:r,encoding:`utf8`});Te?.onEnd(e.category,Date.now()-n);let i=typeof t.stdout==`string`?t.stdout:``,a=typeof t.stderr==`string`?t.stderr:``;if(t.error)return{ok:!1,reason:t.error.code===`ETIMEDOUT`?`timeout`:`spawn-error`,stdout:i,stderr:a,exitCode:null,signal:t.signal??null,error:ve(t.error,e.cwd)};if(t.status===0)return{ok:!0,stdout:i,stderr:a,exitCode:t.status};let o=e.timeoutMs!==void 0&&e.timeoutMs>0;return{ok:!1,reason:t.signal?o&&t.signal===`SIGTERM`?`timeout`:`signal`:`non-zero`,stdout:i,stderr:a,exitCode:t.status,signal:t.signal??null}}catch(t){return Te?.onEnd(e.category,Date.now()-n),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:ve(t,e.cwd)}}}function Ae(e){let t=xe(e.category);if(!t.allowed)return we(e.category,t.minIntervalMs,t.sinceLastMs);Se(e.category);let n=Date.now();Te?.onStart(e.category);let r=k(e);return Te?.onEnd(e.category,Date.now()-n),r}function k(e){let t;try{t=g(e.bin,e.args??[],{cwd:e.cwd,env:Ce(e),detached:!0,stdio:`ignore`})}catch(t){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:ve(t,e.cwd)}}return t.once(`error`,()=>{}),t.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${e.bin}): no pid (binary not found or unexecutable)`}:(t.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}function je(e,t,n){let i=`${e}.tmp`,a=n??r.statSync(e,{throwIfNoEntry:!1})?.mode;try{r.writeFileSync(i,t,a===void 0?{}:{mode:a}),r.renameSync(i,e)}catch(e){throw r.rmSync(i,{force:!0}),e}}function Me(e,t){let n=e[t];return n&&n.length>0?n:void 0}function Ne(e=process.env){let t=Me(e,`XDG_STATE_HOME`)??c.join(m.homedir(),`.local`,`state`);return c.join(t,`cc-candybar`)}function Pe(){let e=Me(process.env,`XDG_CACHE_HOME`)??c.join(m.homedir(),`.cache`);return c.join(e,`cc-candybar`)}function Fe(){return Ne()}function Ie(){let e=process.env.CC_CANDYBAR_SOCKET;if(e)return e;let t=m.userInfo().uid;return c.join(`/tmp`,`cc-candybar-${t}`,`socket`)}function Le(e){r.mkdirSync(e,{recursive:!0,mode:448});let t=r.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=m.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 Re(e){Le(c.dirname(e));for(let t of[e,ze(e)])try{if(r.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function ze(e){return`${e}.lease`}function Be(){return ze(Ie())}function Ve(){return c.join(Ne(),`session-state.json`)}function He(){return c.join(Ne(),`settings-history.json`)}function Ue(){let e=process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(e)return e;let t=m.userInfo().uid;return c.join(`/tmp`,`cc-candybar-${t}`,`daemons`)}function We(){return c.join(Ne(),`spawn.lock`)}function Ge(){return c.join(Ne(),`spawn.cooldown`)}function Ke(){return c.join(Ne(),`spawn.backoff`)}function qe(){return c.join(Ne(),`diagnostics`)}function Je(e=process.env){return c.join(Ne(e),`daemon.log`)}const Ye=[`MEMENTO_CONFIG_HOME`,`XDG_CONFIG_HOME`];function Xe(e,t){return Object.fromEntries(Ye.flatMap(n=>{let r=e[n]??``;return r===``?[]:[[n,c.resolve(t,r)]]}))}var Ze=he(((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]/})),Qe=he(((e,t)=>{let n=Ze();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)}}})),$e=he(((e,t)=>{let n=Qe(),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===`
3
3
  `?(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`
4
4
  `: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 E(b())},multiLineComment(){switch(_){case`*`:b(),p=`multiLineCommentAsterisk`;return;case void 0:throw E(b())}b()},multiLineCommentAsterisk(){switch(_){case`*`:b();return;case`/`:b(),p=`default`;return;case void 0:throw E(b())}b(),p=`multiLineComment`},singleLineComment(){switch(_){case`
5
- `: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 E(b())},identifierNameStartEscape(){if(_!==`u`)throw E(b());b();let e=te();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 E(b());b();let e=te();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 E(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 E(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 E(b())},decimalExponentSign(){if(n.isDigit(_)){m+=b(),p=`decimalExponentInteger`;return}throw E(b())},decimalExponentInteger(){if(n.isDigit(_)){m+=b();return}return S(`numeric`,g*Number(m))},hexadecimal(){if(n.isHexDigit(_)){m+=b(),p=`hexadecimalInteger`;return}throw E(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`
5
+ `: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 E(b())},identifierNameStartEscape(){if(_!==`u`)throw E(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 E(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 E(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 E(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 E(b())},decimalExponentSign(){if(n.isDigit(_)){m+=b(),p=`decimalExponentInteger`;return}throw E(b())},decimalExponentInteger(){if(n.isDigit(_)){m+=b();return}return S(`numeric`,g*Number(m))},hexadecimal(){if(n.isHexDigit(_)){m+=b(),p=`hexadecimalInteger`;return}throw E(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`
6
6
  `:case`\r`:throw E(b());case`\u2028`:case`\u2029`:ae(_);break;case void 0:throw E(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 E(b())},afterPropertyName(){if(_===`:`)return S(`punctuator`,b());throw E(b())},beforePropertyValue(){p=`value`},afterPropertyValue(){switch(_){case`,`:case`}`:return S(`punctuator`,b())}throw E(b())},beforeArrayValue(){if(_===`]`)return S(`punctuator`,b());p=`value`},afterArrayValue(){switch(_){case`,`:case`]`:return S(`punctuator`,b())}throw E(b())},end(){throw E(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 E(b());b()}}function w(){switch(y()){case`b`:return b(),`\b`;case`f`:return b(),`\f`;case`n`:return b(),`
7
- `;case`r`:return b(),`\r`;case`t`:return b(),` `;case`v`:return b(),`\v`;case`0`:if(b(),n.isDigit(y()))throw E(b());return`\0`;case`x`:return b(),ee();case`u`:return b(),te();case`
7
+ `;case`r`:return b(),`\r`;case`t`:return b(),` `;case`v`:return b(),`\v`;case`0`:if(b(),n.isDigit(y()))throw E(b());return`\0`;case`x`:return b(),T();case`u`:return b(),ee();case`
8
8
  `:case`\u2028`:case`\u2029`:return b(),``;case`\r`:return b(),y()===`
9
- `&&b(),``;case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:throw E(b());case void 0:throw E(b())}return b()}function ee(){let e=``,t=y();if(!n.isHexDigit(t)||(e+=b(),t=y(),!n.isHexDigit(t)))throw E(b());return e+=b(),String.fromCodePoint(parseInt(e,16))}function te(){let e=``,t=4;for(;t-- >0;){let t=y();if(!n.isHexDigit(t))throw E(b());e+=b()}return String.fromCodePoint(parseInt(e,16))}let ne={start(){if(l.type===`eof`)throw D();T()},beforePropertyName(){switch(l.type){case`identifier`:case`string`:u=l.value,i=`afterPropertyName`;return;case`punctuator`:re();return;case`eof`:throw D()}},afterPropertyName(){if(l.type===`eof`)throw D();i=`beforePropertyValue`},beforePropertyValue(){if(l.type===`eof`)throw D();T()},beforeArrayValue(){if(l.type===`eof`)throw D();if(l.type===`punctuator`&&l.value===`]`){re();return}T()},afterPropertyValue(){if(l.type===`eof`)throw D();switch(l.value){case`,`:i=`beforePropertyName`;return;case`}`:re()}},afterArrayValue(){if(l.type===`eof`)throw D();switch(l.value){case`,`:i=`beforeArrayValue`;return;case`]`:re()}},end(){}};function T(){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 re(){a.pop();let e=a[a.length-1];i=e==null?`end`:Array.isArray(e)?`afterArrayValue`:`afterPropertyValue`}function E(e){return se(e===void 0?`JSON5: invalid end of input at ${s}:${c}`:`JSON5: invalid character '${oe(e)}' at ${s}:${c}`)}function D(){return se(`JSON5: invalid end of input at ${s}:${c}`)}function ie(){return c-=5,se(`JSON5: invalid identifier character at ${s}:${c}`)}function ae(e){console.warn(`JSON5: '${oe(e)}' in strings is not valid ECMAScript; consider escaping`)}function oe(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 se(e){let t=SyntaxError(e);return t.lineNumber=s,t.columnNumber=c,t}})),et=he(((e,t)=>{let n=Qe();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=`,
9
+ `&&b(),``;case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:throw E(b());case void 0:throw E(b())}return b()}function T(){let e=``,t=y();if(!n.isHexDigit(t)||(e+=b(),t=y(),!n.isHexDigit(t)))throw E(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 E(b());e+=b()}return String.fromCodePoint(parseInt(e,16))}let te={start(){if(l.type===`eof`)throw D();ne()},beforePropertyName(){switch(l.type){case`identifier`:case`string`:u=l.value,i=`afterPropertyName`;return;case`punctuator`:re();return;case`eof`:throw D()}},afterPropertyName(){if(l.type===`eof`)throw D();i=`beforePropertyValue`},beforePropertyValue(){if(l.type===`eof`)throw D();ne()},beforeArrayValue(){if(l.type===`eof`)throw D();if(l.type===`punctuator`&&l.value===`]`){re();return}ne()},afterPropertyValue(){if(l.type===`eof`)throw D();switch(l.value){case`,`:i=`beforePropertyName`;return;case`}`:re()}},afterArrayValue(){if(l.type===`eof`)throw D();switch(l.value){case`,`:i=`beforeArrayValue`;return;case`]`:re()}},end(){}};function ne(){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 re(){a.pop();let e=a[a.length-1];i=e==null?`end`:Array.isArray(e)?`afterArrayValue`:`afterPropertyValue`}function E(e){return se(e===void 0?`JSON5: invalid end of input at ${s}:${c}`:`JSON5: invalid character '${oe(e)}' at ${s}:${c}`)}function D(){return se(`JSON5: invalid end of input at ${s}:${c}`)}function ie(){return c-=5,se(`JSON5: invalid identifier character at ${s}:${c}`)}function ae(e){console.warn(`JSON5: '${oe(e)}' in strings is not valid ECMAScript; consider escaping`)}function oe(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 se(e){let t=SyntaxError(e);return t.lineNumber=s,t.columnNumber=c,t}})),et=he(((e,t)=>{let n=Qe();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=`,
10
10
  `+a;e=r.join(n),s=`{
11
11
  `+a+e+`,
12
12
  `+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=`,
@@ -51,19 +51,19 @@ import{createRequire as e}from"node:module";import t from"node:process";import{j
51
51
  `).map(e=>n+e).join(`
52
52
  `)}function Ig(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 Lg(e,t){let n=[];for(let e of t){if(typeof e==`object`&&e)throw Th(`join`,2,`list of strings/primitives`,`list element of type ${Rg(e)}`);n.push(String(e))}return n.join(e)}function Rg(e){return Array.isArray(e)?`array`:e instanceof Map?`Map`:e instanceof Set?`Set`:`object`}function zg(e){return Og(e,`-`)}function Bg(e){return e.toLowerCase()}function Vg(e,t){return`\n${Fg(e,t)}`}function Hg(e){return e.replace(/\s+/g,``)}function Ug(e,t,n){return n===1?e:t}function Wg(...e){return e.map(e=>`"${e}"`).join(` `)}function Gg(e){return e.replace(/[\\.+*?()|[\]{}^$]/g,`\\$&`)}function Kg(e,t){return t.repeat(Math.max(0,e))}function qg(e,t,n){return pg(e,n).join(t)}function Jg(e){return Og(e,`_`)}function Yg(e,t){let n=pg(e,t),r={};for(let e=0;e<n.length;e++)r[`_${e}`]=n[e];return r}function Xg(e,t){return pg(e,t)}function Zg(e,t,n){let r=Qg(n,e,t),i={};for(let e=0;e<r.length;e++)i[`_${e}`]=r[e]??``;return i}function Qg(e,t,n){if(n===0)return[];let r=pg(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 $g(...e){return e.map(e=>`'${e}'`).join(` `)}function e_(e,t,n){let r=fg(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 t_(e){let t=``;for(let n of e)n_(n)?t+=n.toLowerCase():r_(n)?t+=n.toUpperCase():t+=n;return t}function n_(e){return e!==e.toLowerCase()&&e===e.toUpperCase()}function r_(e){return e!==e.toUpperCase()&&e===e.toLowerCase()}function i_(e){return e.replace(/\b([a-zA-Z])/g,e=>e.toUpperCase())}function a_(e){return e.trim()}function o_(e,t){if(e.length===0)return t;let n=new Set(fg(e)),r=fg(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 s_(e,t){return t.startsWith(e)?t.slice(e.length):t}function c_(e,t){return t.endsWith(e)?t.slice(0,t.length-e.length):t}function l_(e,t){let n=fg(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 u_(e){return e.replace(/\b([A-Z])/g,e=>e.toLowerCase())}function d_(e){return e.toUpperCase()}function f_(e,t){return p_(e,`
53
53
  `,t)}function p_(e,t,n){if(e<=0)return n;let r=[];for(let t of n.split(`
54
- `)){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 m_(e,t,n){return p_(e,t,n)}function h_(){return{abbrev:{fn:(e,t)=>mg(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},abbrevboth:{fn:(e,t,n)=>hg(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},camelcase:{fn:e=>Ag(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},cat:{fn:(...e)=>jg(...e),argTypes:[`string`],arity:{kind:`variadic`}},contains:{fn:(e,t)=>Mg(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasPrefix:{fn:(e,t)=>Ng(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasSuffix:{fn:(e,t)=>Pg(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},indent:{fn:(e,t)=>Fg(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},initials:{fn:e=>Ig(e),argTypes:[`string`],arity:{kind:`exact`}},join:{fn:(e,t)=>Lg(e,t),argTypes:[`string`,`list`],arity:{kind:`exact`}},kebabcase:{fn:e=>zg(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},lower:{fn:e=>Bg(e),argTypes:[`string`],arity:{kind:`exact`}},nindent:{fn:(e,t)=>Vg(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},nospace:{fn:e=>Hg(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},plural:{fn:(e,t,n)=>Ug(e,t,n),argTypes:[`string`,`string`,`int`],arity:{kind:`exact`},returnType:`string`},quote:{fn:(...e)=>Wg(...e),argTypes:[`string`],arity:{kind:`variadic`}},regexQuoteMeta:{fn:e=>Gg(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},repeat:{fn:(e,t)=>Kg(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},replace:{fn:(e,t,n)=>qg(e,t,n),argTypes:[`string`,`string`,`string`],arity:{kind:`exact`}},snakecase:{fn:e=>Jg(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},split:{fn:(e,t)=>Yg(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitList:{fn:(e,t)=>Xg(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitn:{fn:(e,t,n)=>Zg(e,t,n),argTypes:[`string`,`int`,`string`],arity:{kind:`exact`},returnType:`dict`},squote:{fn:(...e)=>$g(...e),argTypes:[`string`],arity:{kind:`variadic`}},substr:{fn:(e,t,n)=>e_(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},swapcase:{fn:e=>t_(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},title:{fn:e=>i_(e),argTypes:[`string`],arity:{kind:`exact`}},trim:{fn:e=>a_(e),argTypes:[`string`],arity:{kind:`exact`}},trimAll:{fn:(e,t)=>o_(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimPrefix:{fn:(e,t)=>s_(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimSuffix:{fn:(e,t)=>c_(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trunc:{fn:(e,t)=>l_(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},untitle:{fn:e=>u_(e),argTypes:[`string`],arity:{kind:`exact`}},upper:{fn:e=>d_(e),argTypes:[`string`],arity:{kind:`exact`}},wrap:{fn:(e,t)=>f_(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},wrapWith:{fn:(e,t,n)=>m_(e,t,n),argTypes:[`int`,`string`,`string`],arity:{kind:`exact`}}}}function g_(e){return e}function __(e,t,n){return n===void 0?xu+yu(e)+`.`+yu(t):v_(n)}function v_(e){return xu+yu(e)}function y_(e,t){return e+`.`+t}function b_(e){return e+`.page`}const x_=[`closeOnPick`,`paged`,`key`,`distribution`],S_=e=>x_.includes(e),C_=`"closeOnPick" (bool, default false), "paged" (bool, default true), "key" (string, accordion grouping), "distribution" (one of ${ua.map(e=>`"${e}"`).join(`, `)}; default "van-der-corput")`;function w_(e){for(let t of Object.keys(e))if(!S_(t))throw Error(`unknown {{ menu }} option "${t}" — the options dict takes ${C_}`);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&&!da(r))throw Error(`{{ menu }} option "distribution" must be one of: ${ua.join(`, `)}; got ${JSON.stringify(r)}`);return{closeOnPick:t(`closeOnPick`,!1),paged:t(`paged`,!0),key:n,distribution:pa(r)}}const T_=`default`,E_={};function D_(e){return[...new Set([T_,...Object.keys(e)])]}function O_(e,t,n){return no(void 0,e,t,T_,n)}function k_(e,t){let n={[T_]:E_,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${T_}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function A_(e,t){let n=k_(e.presets,t).root??jc;return{node:Fc(Rc(n,e.root)),path:zc(n)?`presets.${t}.root`:`root`}}function j_(e,t){return{...e.globals,...k_(e.presets,t).globals}}const M_=`menu`,N_=`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`,P_=e=>e.kind===`call`&&e.name===`dict`,F_=e=>e.kind===`literal`&&typeof e.value!=`object`,I_=e=>Kc(``,e,2)===void 0;function L_(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&&P_(i)?i:void 0,o=a===void 0?r:r.slice(0,-1);if(o.some(P_))return t(`whose options (dict …) is not its last argument — ${N_}`);if(i!==void 0&&a===void 0&&!F_(i)&&I_(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=Kc(`whose trigger`,o.length,2);if(s!==void 0)return t(`${s} — ${N_}`);let c=a===void 0?{}:ah(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=w_(c)}catch(e){return t(`with invalid options — ${e.message}`)}let u=l.key;if(u!==void 0){let e=Tu(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 "${v_(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 R_(e){let t=mp({fromString:e=>e});try{return t.parse(e).referencedCalls().filter(e=>e.name===M_).map(L_)}catch{return`parse-failed`}}function z_(e){let t=mp({fromString:e=>e});try{return t.parse(e).referencedFunctions().has(M_)}catch{return!1}}function B_(e,t,n){e.issues.push({path:t,message:n,line:W(e.source,[`root`])})}function V_(e,t){Eu(e,t,xu,`{{ menu }} helpers`);for(let[n,r]of Object.entries(t.helpers??{}))z_(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:W(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`&&z_(i)&&B_(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.`)}if(t.root!==void 0)for(let n of Ms(Ic(t.root)))typeof n.when==`string`&&z_(n.when)&&B_(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||!z_(r))continue;let n=R_(r);if(n!==`parse-failed`)for(let r of n){let n=r.kind===`issue`?r.message:H_(r.apply);n!==void 0&&B_(e,`segments.${t}`,`segment "${t}" has a {{ menu }} ${n}.`)}}}function H_(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(g_(e)===`closed`)return`whose apply action is named "${Wc}", which collides with the menu's closed-state sentinel and leaves it unopenable. Rename the action`}function U_(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 D_(e.presets)){let a=new Map,s=new Map;for(let c of Ms(A_(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,R_(t.template));let l=i.get(c.name);if(l===`parse-failed`)continue;let u=Os(c);for(let[e,t]of l.entries()){if(t.kind===`issue`||H_(t.apply)!==void 0)continue;let{apply:i,options:l}=t,d=g_(i),f=__(u,i,l.key),p=b_(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=y_(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]=nl(f,d),n[f]=tl(f,Wc),n[p]={kind:`state`,key:p,default:`0`},r[p]={set:p,int:!0}}}}return{...e,variables:{...e.variables,...n},actions:{...e.actions,...r}}}const W_=mp({fromString:e=>e}),G_=`edit.mode`,K_=`edit.configure`,q_=`edit.toggle`,J_=`edit.unconfigure`,Y_=[q_,J_],X_=`arrange`,Z_=`${Su}draft.`;function Q_(e,t){return`${e}:${t}`}const $_={variable:G_,key:G_,member:X_},ev=Xc($_);function tv(e){try{return W_.parse(e).referencedCalls().some(e=>e.name===`action`&&e.args[0]===`edit.toggle`)}catch{return!1}}function nv(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??{}))for(let e of[t.template,t.bg,t.fg])if(typeof e==`string`&&tv(e))return!0;return!1}function rv(e,t){if(Eu(e,t,Su,`edit mode`),!nv(t))return;let{variables:n,actions:r}=iv();t.variables={...t.variables??{},...n},t.actions={...t.actions??{},...r}}function iv(){return{variables:{[G_]:tl(G_,Wc),[K_]:tl(K_,Wc)},actions:{[q_]:nl(G_,X_),[J_]:{set:K_,to:Wc}}}}const av=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*ov(e){let t=e.indexOf(`{{`);for(;t!==-1;){let n=``,r=t+2;for(;r<e.length&&!e.startsWith(`}}`,r);){if(e.startsWith(`/*`,r)){let t=e.indexOf(`*/`,r+2);r=t===-1?e.length:t+2;continue}let t=r,i=e[r];if(r+=1,i===`"`||i===`'`||i==="`"){for(;r<e.length&&e[r]!==i;)r+=e[r]===`\\`&&i!=="`"?2:1;r+=1}n+=e.slice(t,r)}if(r>=e.length)return;yield n,t=e.indexOf(`{{`,r+2)}}const sv=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,cv=RegExp(`^(?:(\\$)(?:\\.(${sv}))?|\\.(${sv})?)(?=[\\s)]|$)`);function lv(e,t,n){let r=cv.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 uv=/^(\w+)\b\s*([\s\S]*)$/;function*dv(e,t){let n=[t];for(let r of ov(e)){let e=r.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=uv.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};let r=/^with\b([\s\S]*)$/.exec(a);n[n.length-1]=r===null?s:lv(r[1],s,t);continue}yield{code:e,dot:o},i===`if`&&n.push(o),i===`with`&&n.push(lv(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const fv=/(?<![.$])\btemplate\s+$/;function*pv(e,t,n){let r=0;for(let i of[...e.matchAll(av)]){let a=i.index+i[0].length;fv.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:lv(e.slice(a),t,n)}),r=a}}function*mv(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...dv(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...pv(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)}const hv=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${sv})`,`g`);function*gv({code:e,dot:t,root:n}){let r=e.replace(av,``);for(let e of[...r.matchAll(hv)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function _v(e,t){let n=new Map;for(let r of mv(e,t))for(let e of gv(r))n.has(e)||n.set(e,r.via);return n}const vv=/(?<![.$])\b(action|picker|menu|carousel)\s+$/,yv={action:1,picker:2,menu:1,carousel:1};function*bv(e){let t=0,n=0,r=`action`;for(let i of[...e.matchAll(av)]){let a=vv.exec(e.slice(t,i.index));a!==null&&(n=yv[a[1]],r=a[1]===`action`?`action`:`options`),n>0&&(yield{name:i[0].slice(1,-1),site:r},n--),t=i.index+i[0].length}}function xv(e,t){let n=new Map;for(let{code:r,via:i}of mv(e,t))for(let{name:e,site:t}of bv(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}function Sv(e,t){if(t.names.has(e))return!0;let n=`${e}.`;for(let e of t.names)if(e.startsWith(n))return!0;for(let n of t.documents)if(e.startsWith(`${n}.`))return!0;return!1}function Cv(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),wv(r)&&n.add(e)};for(let[t,n]of Object.entries(e.variables))r(t,n);for(let[t,n]of Object.entries(e.segments))for(let[e,i]of Object.entries(n.vars??{}))r(`${t}.${e}`,i);return{names:t,documents:n,helpers:e.helpers}}function wv(e){return(e.kind===`shell`||e.kind===`file`)&&Ls(e.parse)===`json`}var Tv=he((e=>{function t(e){var t=[...arguments].slice(1);throw Error(typeof e==`number`?`[MobX] minified error nr: `+e+(t.length?` `+t.map(String).join(`,`):``)+`. Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts`:`[MobX] `+e)}function n(){return typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:tn}function r(){cn||t(`Proxy not available`)}function i(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}function a(e){return typeof e==`function`}function o(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function s(e){return typeof e==`object`&&!!e}function c(e){if(!s(e))return!1;var t=Object.getPrototypeOf(e);if(t==null)return!0;var n=Object.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===ln}function l(e){var t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function u(e,t,n){rn(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function d(e,t,n){rn(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function f(e,t){var n=`isMobX`+e;return t.prototype[n]=!0,function(e){return s(e)&&!0===e[n]}}function p(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function m(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function h(e){return e===null?null:typeof e==`object`?``+e:e}function g(e,t){return an.hasOwnProperty.call(e,t)}function _(e,t){return!!(e&t)}function v(e,t,n){return n?e|=t:e&=~t,e}function y(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t,n){if(ne())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&T(i,n.prototype),i}function x(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,re(r.key),r)}}function S(e,t,n){return t&&x(e.prototype,t),n&&x(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function C(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if(typeof e==`string`)return y(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
55
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function w(){return(w=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}function ee(e){return(ee=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function te(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,T(e,t)}function ne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch{}return(ne=function(){return!!e})()}function T(e,t){return(T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function re(e){var t=function(e){if(typeof e!=`object`||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,`string`);if(typeof n!=`object`)return n;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}(e);return typeof t==`symbol`?t:t+``}function E(e){var t=typeof Map==`function`?new Map:void 0;return(E=function(e){function n(){return b(e,arguments,ee(this).constructor)}if(e===null||!function(e){try{return Function.toString.call(e).indexOf(`[native code]`)!==-1}catch{return typeof e==`function`}}(e))return e;if(typeof e!=`function`)throw TypeError(`Super expression must either be null or a function`);if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,n)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),T(n,e)})(e)}function D(e){return Object.assign((function(t,n){if(ae(n))return e.t(t,n);ie(t,n,e)}),e)}function ie(e,t,n){g(e,pn)||u(e,pn,w({},e[pn])),function(e){return e.i===`override`}(n)||(e[pn][t]=n)}function ae(e){return typeof e==`object`&&typeof e.kind==`string`}function oe(e,t,n){t===void 0&&(t=F),n===void 0&&(n=F);var r=new mn(e);return t!==F&&ut(r,t),n!==F&&dt(r,n),r}function se(e,t,n){return bt(e)?e:Array.isArray(e)?Tn.array(e,{name:n}):c(e)?Tn.object(e,void 0,{name:n}):p(e)?Tn.map(e,{name:n}):m(e)?Tn.set(e,{name:n}):typeof e!=`function`||st(e)||_t(e)?e:l(e)?rr(e):Zn(n,e)}function ce(e){return e}function le(e,t){return{i:e,u:t,o:ue,s:de,t:fe}}function ue(e,t,n,r){var i;return(i=this.u)!=null&&i.bound?this.s(e,t,n,!1)===null?0:1:r===e.h?this.s(e,t,n,!1)===null?0:2:st(n.value)?1:(rn(r,t,pe(e,this,t,n,!1)),2)}function de(e,t,n,r){var i=pe(e,this,t,n);return e.l(t,i,r)}function fe(e,n){var r,i=n.kind,a=n.name,o=n.addInitializer,s=this,c=function(e){var t;return Me(s.u?.name??a.toString(),e,(t=s.u?.autoAction)!=null&&t)};return i==`field`?function(e){var t,n=e;return st(n)||(n=c(n)),(t=s.u)!=null&&t.bound&&((n=n.bind(this)).isMobxAction=!0),n}:i==`method`?(st(e)||(e=c(e)),(r=this.u)!=null&&r.bound&&o((function(){var e=this[a].bind(this);e.isMobxAction=!0,this[a]=e})),e):void t(`Cannot apply '`+s.i+`' to '`+String(a)+`' (kind: `+i+`):
56
- '`+s.i+`' can only be used on properties with a function value.`)}function pe(e,t,n,r,i){var a,o,s;i===void 0&&(i=z.safeDescriptors);var c=r.value;return(a=t.u)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:Me(t.u?.name??n.toString(),c,(o=t.u?.autoAction)!=null&&o,(s=t.u)!=null&&s.bound?e.v??e.h:void 0),configurable:!i||e.p,enumerable:!1,writable:!i}}function me(e,t){return{i:e,u:t,o:he,s:ge,t:_e}}function he(e,t,n,r){var i;return r===e.h?this.s(e,t,n,!1)===null?0:2:(i=this.u)!=null&&i.bound&&(!g(e.h,t)||!_t(e.h[t]))&&this.s(e,t,n,!1)===null?0:_t(n.value)?1:(rn(r,t,O(e,0,0,n,!1,!1)),2)}function ge(e,t,n,r){var i=O(e,0,0,n,this.u?.bound);return e.l(t,i,r)}function _e(e,t){var n,r=t.name,i=t.addInitializer;return _t(e)||(e=rr(e)),(n=this.u)!=null&&n.bound&&i((function(){var e=this[r].bind(this);e.isMobXFlow=!0,this[r]=e})),e}function O(e,t,n,r,i,a){a===void 0&&(a=z.safeDescriptors);var o=r.value;return _t(o)||(o=rr(o)),i&&((o=o.bind(e.v??e.h)).isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function ve(e,t){return{i:e,u:t,o:ye,s:be,t:xe}}function ye(e,t,n){return this.s(e,t,n,!1)===null?0:1}function be(e,t,n,r){return e.m(t,w({},this.u,{get:n.get,set:n.set}),r)}function xe(e,t){var n=this,r=t.name;return(0,t.addInitializer)((function(){var t=Bt(this)[I],i=w({},n.u,{get:e,context:this});i.name||=`ObservableObject.`+r.toString(),t.j.set(r,new Fn(i))})),function(){return this[I].O(r)}}function Se(e,t){return{i:e,u:t,o:Ce,s:we,t:Te}}function Ce(e,t,n){return this.s(e,t,n,!1)===null?0:1}function we(e,t,n,r){return e.g(t,n.value,this.u?.enhancer??se,r)}function Te(e,t){function n(e,t){var n=Bt(e)[I],i=new Nn(t,r.u?.enhancer??se,`ObservableObject.`+a.toString(),!1);n.j.set(a,i),o.add(e)}var r=this,i=t.kind,a=t.name,o=new WeakSet;if(i==`accessor`)return{get:function(){return o.has(this)||n(this,e.get.call(this)),this[I].O(a)},set:function(e){return o.has(this)||n(this,e),this[I].S(a,e)},init:function(e){return o.has(this)||n(this,e),e}}}function Ee(e){return{i:`true`,u:e,o:De,s:Oe,t:ke}}function De(e,t,n,r){var i,a,o;if(n.get)return On.o(e,t,n,r);if(n.set){var s=st(n.set)?n.set:Me(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!z.safeDescriptors||e.p,set:s})===null?0:2:(rn(r,t,{configurable:!0,set:s}),2)}if(r!==e.h&&typeof n.value==`function`)return l(n.value)?((o=this.u)!=null&&o.autoBind?rr.bound:rr).o(e,t,n,r):((a=this.u)!=null&&a.autoBind?Zn.bound:Zn).o(e,t,n,r);var c=!1===this.u?.deep?Tn.ref:Tn;return typeof n.value==`function`&&(i=this.u)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),c.o(e,t,n,r)}function Oe(e,t,n,r){var i;return n.get?On.s(e,t,n,r):n.set?e.l(t,{configurable:!z.safeDescriptors||e.p,set:Me(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.u)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),(!1===this.u?.deep?Tn.ref:Tn).s(e,t,n,r))}function ke(){t(`'`+this.i+`' cannot be used as a decorator`)}function Ae(e){return e||yn}function k(e){return!0===e.deep?se:!1===e.deep?ce:(t=e.defaultDecorator)&&(n=(r=t.u)?.enhancer)!=null?n:se;var t,n,r}function je(e,t,n){return ae(t)?bn.t(e,t):o(t)?void ie(e,t,bn):bt(e)?e:c(e)?Tn.object(e,t,n):Array.isArray(e)?Tn.array(e,t):p(e)?Tn.map(e,t):m(e)?Tn.set(e,t):typeof e==`object`&&e?e:Tn.box(e,t)}function Me(e,t,n,r){function i(){return Ne(0,n,t,r||this,arguments)}return n===void 0&&(n=!1),i.isMobxAction=!0,i.toString=function(){return t.toString()},jn&&(Mn.value=e,rn(i,`name`,Mn)),i}function Ne(e,t,n,r,i){var a=Pe(0,t);try{return n.apply(r,i)}catch(e){throw a._=e,e}finally{Fe(a)}}function Pe(e,t){var n=z.trackingDerivation,r=!t||!n;Qe();var i=z.allowStateChanges;r&&(We(),i=Le(!0));var a={A:r,k:n,M:i,V:Ke(!0),R:!1,N:0,T:An++,C:kn};return kn=a.T,a}function Fe(e){kn!==e.T&&t(30),kn=e.C,e._!==void 0&&(z.suppressReactionErrors=!0),Re(e.M),qe(e.V),$e(),e.A&&Ge(e.k),z.suppressReactionErrors=!1}function Ie(e,t){var n=Le(e);try{return t()}finally{Re(n)}}function Le(e){var t=z.allowStateChanges;return z.allowStateChanges=e,t}function Re(e){z.allowStateChanges=e}function ze(e){return e instanceof Rn}function Be(e){switch(e.I){case R.L:return!1;case R.P:case R.K:return!0;case R.B:for(var t=Ke(!0),n=We(),r=e.D,i=r.length,a=0;a<i;a++){var o=r[a];if(Ln(o)){if(z.disableErrorBoundaries)o.get();else try{o.get()}catch{return Ge(n),qe(t),!0}if(e.I===R.K)return Ge(n),qe(t),!0}}return Je(e),Ge(n),qe(t),!1}}function Ve(e,t,n){var r=Ke(!0);Je(e),e.W=Array(e.q===0?100:e.D.length),e.G=0,e.q=++z.runId;var i,a=z.trackingDerivation;if(z.trackingDerivation=e,z.inBatch++,!0===z.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new Rn(e)}return z.inBatch--,z.trackingDerivation=a,function(e){for(var t=e.D,n=e.D=e.W,r=R.L,i=0,a=e.G,o=0;o<a;o++){var s=n[o];s.diffValue===0&&(s.diffValue=1,i!==o&&(n[i]=s),i++),s.I>r&&(r=s.I)}for(n.length=i,e.W=null,a=t.length;a--;){var c=t[a];c.diffValue===0&&Xe(c,e),c.diffValue=0}for(;i--;){var l=n[i];l.diffValue===1&&(l.diffValue=0,Ye(l,e))}r!==R.L&&(e.I=r,e.H())}(e),qe(r),i}function He(e){var t=e.D;e.D=[];for(var n=t.length;n--;)Xe(t[n],e);e.I=R.P}function Ue(e){var t=We();try{return e()}finally{Ge(t)}}function We(){var e=z.trackingDerivation;return z.trackingDerivation=null,e}function Ge(e){z.trackingDerivation=e}function Ke(e){var t=z.allowStateReads;return z.allowStateReads=e,t}function qe(e){z.allowStateReads=e}function Je(e){if(e.I!==R.L){e.I=R.L;for(var t=e.D,n=t.length;n--;)t[n].U=R.L}}function Ye(e,t){e.F.add(t),e.U>t.I&&(e.U=t.I)}function Xe(e,t){e.F.delete(t),e.F.size===0&&Ze(e)}function Ze(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,z.pendingUnobservations.push(e))}function Qe(){z.inBatch++}function $e(){if(--z.inBatch==0){nt();for(var e=z.pendingUnobservations,t=0;t<e.length;t++){var n=e[t];n.isPendingUnobservation=!1,n.F.size===0&&(n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof Fn&&n.X())}z.pendingUnobservations=[]}}function et(e){var t=z.trackingDerivation;return t===null?(e.F.size===0&&z.inBatch>0&&Ze(e),!1):(t.q!==e.$&&(e.$=t.q,t.W[t.G++]=e,!e.isBeingObserved&&z.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function tt(e){e.U!==R.K&&(e.U=R.K,e.F.forEach((function(e){e.I===R.L&&e.H(),e.I=R.K})))}function nt(){z.inBatch>0||z.isRunningReactions||Wn(rt)}function rt(){z.isRunningReactions=!0;for(var e=z.pendingReactions,t=0;e.length>0;){++t==100&&(console.error(`[mobx] cycle in reaction: `+e[0]),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r<i;r++)n[r].J()}z.isRunningReactions=!1}function it(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}}function at(e){return function(t,n){return a(t)?Me(t.name||`<unnamed action>`,t,e):a(n)?Me(t,n,e):ae(n)?(e?Jn:Kn).t(t,n):o(n)?ie(t,n,e?Jn:Kn):o(t)?D(le(e?`autoAction`:`action`,{name:t,autoAction:e})):void 0}}function ot(e){return Ne(0,!1,e,this,void 0)}function st(e){return a(e)&&!0===e.isMobxAction}function ct(e,t){function n(){e(i)}var r;t===void 0&&(t=sn);var i,a=t?.name??`Autorun`;if(t.scheduler||t.delay){var o=lt(t),s=!1;i=new Un(a,(function(){s||(s=!0,o((function(){s=!1,i.isDisposed||i.track(n)})))}),t.onError,t.requiresObservable)}else i=new Un(a,(function(){this.track(n)}),t.onError,t.requiresObservable);return(r=t)!=null&&(r=r.signal)!=null&&r.aborted||i.Y(),i.Z(t?.signal)}function lt(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:Qn}function ut(e,t,n){return ft(`onBO`,e,t,n)}function dt(e,t,n){return ft(`onBUO`,e,t,n)}function ft(e,t,n,r){var i=typeof r==`function`?qt(t,n):qt(t),o=a(r)?r:n,s=e+`L`;return i[s]?i[s].add(o):i[s]=new Set([o]),function(){var e=i[s];e&&(e.delete(o),e.size===0&&delete i[s])}}function pt(e,t,n,r){var i=fn(t);return Xt((function(){var t=Bt(e,r)[I];dn(i).forEach((function(e){t.s(e,i[e],!n||!(e in n)||n[e])}))})),e}function mt(e){var t,n={name:e.tt};return e.D&&e.D.length>0&&(n.dependencies=(t=e.D,Array.from(new Set(t))).map(mt)),n}function ht(e){var t={name:e.tt};return function(e){return e.F&&e.F.size>0}(e)&&(t.observers=Array.from(function(e){return e.F}(e)).map(ht)),t}function gt(e){a(e.cancel)&&e.cancel()}function _t(e){return!0===e?.isMobXFlow}function vt(e,t){return t===void 0?Ln(e):!1===N(e)||!e[I].j.has(t)?!1:Ln(qt(e,t))}function yt(e,t){return!!e&&(t===void 0?N(e)||!!e[I]||hn(e)||Gn(e)||Ln(e):!!N(e)&&e[I].j.has(t))}function bt(e){return yt(e)}function xt(e){return N(e)?e[I].nt():gr(e)||yr(e)?Array.from(e.keys()):Rt(e)?e.map((function(e,t){return t})):void t(5)}function St(e,n){return N(e)?e[I].it(n):gr(e)||yr(e)?e.has(n):Rt(e)?n>=0&&n<e.length:void t(10)}function Ct(e){if(N(e))return e[I].rt();t(38)}function wt(e,t,n){return e.set(t,n),n}function Tt(e,t){t===void 0&&(t=void 0),Qe();try{return e.apply(t)}finally{$e()}}function Et(e,t,n){var r;if(typeof n.timeout==`number`){var i=Error(`WHEN_TIMEOUT`);r=setTimeout((function(){if(!o[I].isDisposed){if(o(),!n.onError)throw i;n.onError(i)}}),n.timeout)}n.name=`When`;var a=Me(`When-effect`,t),o=ct((function(t){Ie(!1,e)&&(t.dispose(),r&&clearTimeout(r),a())}),n);return o}function Dt(e,t){var n,r,i;if(t!=null&&(n=t.signal)!=null&&n.aborted)return Object.assign(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:function(){return null}});var a=new Promise((function(n,a){var o,s=Et(e,n,w({},t,{onError:a}));r=function(){s(),a(Error(`WHEN_CANCELLED`))},i=function(){s(),a(Error(`WHEN_ABORTED`))},t==null||(o=t.signal)==null||o.addEventListener==null||o.addEventListener(`abort`,i)})).finally((function(){var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,i)}));return a.cancel=r,a}function Ot(e){return e[I]}function kt(e){return e.et!==void 0&&e.et.length>0}function At(e,t){var n=e.et||=[];return n.push(t),i((function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)}))}function jt(e,n){var r=We();try{for(var i=[].concat(e.et||[]),a=0,o=i.length;a<o&&((n=i[a](n))&&!n.type&&t(14),n);a++);return n}finally{Ge(r)}}function Mt(e){return e.ut!==void 0&&e.ut.length>0}function Nt(e,t){var n=e.ut||=[];return n.push(t),i((function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)}))}function Pt(e,t){var n=We(),r=e.ut;if(r){for(var i=0,a=(r=r.slice()).length;i<a;i++)r[i](t);Ge(n)}}function Ft(e,t,n,i){return n===void 0&&(n=`ObservableArray`),i===void 0&&(i=!1),r(),Xt((function(){var r=new cr(n,t,i,!1);d(r.j,I,r);var a=new Proxy(r.j,sr);return r.v=a,e&&e.length&&r.ot(0,0,e),a}))}function A(e,t){typeof Array.prototype[e]==`function`&&(lr[e]=t(e))}function It(e){return function(){var t=this[I];t.st.reportObserved();var n=t.ft(t.j);return n[e].apply(n,arguments)}}function j(e){return function(t,n){var r=this,i=this[I];return i.st.reportObserved(),i.ft(i.j)[e]((function(e,i){return t.call(n,e,i,r)}))}}function Lt(e){return function(){var t=this,n=this[I];n.st.reportObserved();var r=n.ft(n.j),i=arguments[0];return arguments[0]=function(e,n,r){return i(e,n,r,t)},r[e].apply(r,arguments)}}function Rt(e){return s(e)&&fr(e[I])}function zt(e){return e[Symbol.toStringTag]=`MapIterator`,$t(e)}function M(e){return e[Symbol.toStringTag]=`SetIterator`,$t(e)}function Bt(e,t){if(g(e,I))return e;var n=t?.name??`ObservableObject`;return u(e,I,new xr(e,new Map,String(n),function(e){return e?e.defaultDecorator??Ee(e):void 0}(t))),e}function Vt(e){return br[e]||(br[e]={get:function(){return this[I].O(e)},set:function(t){return this[I].S(e,t)}})}function N(e){return!!s(e)&&Sr(e[I])}function Ht(e,t,n){var r;(r=e.h[pn])==null||delete r[n]}function Ut(e){return{enumerable:!1,configurable:!0,get:function(){return this[I].ct(e)},set:function(t){this[I].ht(e,t)}}}function Wt(e){rn(Dr.prototype,``+e,Ut(e))}function Gt(e){if(e>Tr){for(var t=Tr;t<e+100;t++)Wt(t);Tr=e}}function Kt(e,t,n){return new Dr(e,t,n)}function qt(e,n){if(typeof e==`object`&&e){if(Rt(e))return n!==void 0&&t(23),e[I].st;if(yr(e))return e.st;if(gr(e)){if(n===void 0)return e.lt;var r=e.vt.get(n)||e.dt.get(n);return r||t(25,n,Yt(e)),r}if(N(e)){if(!n)return t(26);var i=e[I].j.get(n);return i||t(27,n,Yt(e)),i}if(hn(e)||Ln(e)||Gn(e))return e}else if(a(e)&&Gn(e[I]))return e[I];t(28)}function Jt(e,n){return e||t(29),n===void 0?hn(e)||Ln(e)||Gn(e)||gr(e)||yr(e)?e:e[I]?e[I]:void t(24,e):Jt(qt(e,n))}function Yt(e,t){var n;if(t!==void 0)n=qt(e,t);else{if(st(e))return e.name;n=N(e)||gr(e)||yr(e)?Jt(e):qt(e)}return n.tt}function Xt(e){var t=We(),n=Le(!0);Qe();try{return e()}finally{$e(),Re(n),Ge(t)}}function Zt(e,t,n){return n===void 0&&(n=-1),function e(t,n,r,i,o){if(t===n)return t!==0||1/t==1/n;if(t==null||n==null)return!1;if(t!=t)return n!=n;var s=typeof t;if(s!==`function`&&s!==`object`&&typeof n!=`object`)return!1;var c=Or.call(t);if(c!==Or.call(n))return!1;switch(c){case`[object RegExp]`:case`[object String]`:return``+t==``+n;case`[object Number]`:return+t==+t?+t==0?1/t==1/n:+t==+n:+n!=+n;case`[object Date]`:case`[object Boolean]`:return+t==+n;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(t)===Symbol.valueOf.call(n);case`[object Map]`:case`[object Set]`:r>=0&&r++}t=Qt(t),n=Qt(n);var l=c===`[object Array]`;if(!l){if(typeof t!=`object`||typeof n!=`object`)return!1;var u=t.constructor,d=n.constructor;if(u!==d&&!(a(u)&&u instanceof u&&a(d)&&d instanceof d)&&`constructor`in t&&`constructor`in n)return!1}if(r===0)return!1;r<0&&(r=-1),o||=[];for(var f=(i||=[]).length;f--;)if(i[f]===t)return o[f]===n;if(i.push(t),o.push(n),l){if((f=t.length)!==n.length)return!1;for(;f--;)if(!e(t[f],n[f],r-1,i,o))return!1}else{var p=Object.keys(t),m=p.length;if(Object.keys(n).length!==m)return!1;for(var h=0;h<m;h++){var _=p[h];if(!g(n,_)||!e(t[_],n[_],r-1,i,o))return!1}}return i.pop(),o.pop(),!0}(e,t,n)}function Qt(e){return Rt(e)?e.slice():p(e)||gr(e)||m(e)||yr(e)?Array.from(e.entries()):e}function $t(e){return e[Symbol.iterator]=en,Object.assign(Object.create(kr),e)}function en(){return this}Object.defineProperty(e,`__esModule`,{value:!0});var tn={},P=Object.assign,nn=Object.getOwnPropertyDescriptor,rn=Object.defineProperty,an=Object.prototype,on=[];Object.freeze(on);var sn={};Object.freeze(sn);var cn=typeof Proxy<`u`,ln=Object.toString(),F=function(){},un=Object.getOwnPropertySymbols!==void 0,dn=typeof Reflect<`u`&&Reflect.ownKeys?Reflect.ownKeys:un?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,fn=Object.getOwnPropertyDescriptors||function(e){var t={};return dn(e).forEach((function(n){t[n]=nn(e,n)})),t},pn=Symbol(`mobx-stored-annotations`),I=Symbol(`mobx administration`),mn=function(){function e(e){e===void 0&&(e=`Atom`),this.tt=void 0,this.bt=0,this.F=new Set,this.$=0,this.U=R.P,this.onBOL=void 0,this.onBUOL=void 0,this.tt=e}var t=e.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach((function(e){return e()}))},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach((function(e){return e()}))},t.reportObserved=function(){return et(this)},t.reportChanged=function(){Qe(),tt(this),$e()},t.toString=function(){return this.tt},S(e,[{key:`isBeingObserved`,get:function(){return _(this.bt,e.pt)},set:function(t){this.bt=v(this.bt,e.pt,t)}},{key:`isPendingUnobservation`,get:function(){return _(this.bt,e.yt)},set:function(t){this.bt=v(this.bt,e.yt,t)}},{key:`diffValue`,get:function(){return+!!_(this.bt,e.wt)},set:function(t){this.bt=v(this.bt,e.wt,t===1)}}])}();mn.pt=1,mn.yt=2,mn.wt=4;var hn=f(`Atom`,mn),gn={identity:function(e,t){return e===t},structural:function(e,t){return Zt(e,t)},default:function(e,t){return Object.is?Object.is(e,t):e===t?e!==0||1/e==1/t:e!=e&&t!=t},shallow:function(e,t){return Zt(e,t,1)}},_n=D({i:`override`,o:function(){return 0},s:function(){t(`'`+this.i+`' can only be used with 'makeObservable'`)},t:function(){console.warn(`'`+this.i+`' cannot be used with decorators - this is a no-op`)}}),vn=Ee(),yn={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(yn);var bn=Se(`observable`),xn=Se(`observable.ref`,{enhancer:ce}),L=Se(`observable.shallow`,{enhancer:function(e,t,n){return e==null||N(e)||Rt(e)||gr(e)||yr(e)?e:Array.isArray(e)?Tn.array(e,{name:n,deep:!1}):c(e)?Tn.object(e,void 0,{name:n,deep:!1}):p(e)?Tn.map(e,{name:n,deep:!1}):m(e)?Tn.set(e,{name:n,deep:!1}):void 0}}),Sn=Se(`observable.struct`,{enhancer:function(e,t){return Zt(e,t)?t:e}}),Cn=D(bn);P(je,Cn);var wn,Tn=P(je,{box:function(e,t){var n=Ae(t);return new Nn(e,k(n),n.name,!0,n.equals)},array:function(e,t){var n=Ae(t);return(!1===z.useProxies||!1===n.proxy?Kt:Ft)(e,k(n),n.name)},map:function(e,t){var n=Ae(t);return new hr(e,k(n),n.name)},set:function(e,t){var n=Ae(t);return new vr(e,k(n),n.name)},object:function(e,t,n){return Xt((function(){return pt(!1===z.useProxies||!1===n?.proxy?Bt({},n):function(e,t){var n;return r(),(n=(e=Bt(e,t))[I]).v??(n.v=new Proxy(e,ir))}({},n),e,t)}))},ref:D(xn),shallow:D(L),deep:Cn,struct:D(Sn)}),En=ve(`computed`),Dn=ve(`computed.struct`,{equals:gn.structural}),On=function(e,t){if(ae(t))return En.t(e,t);if(o(t))return ie(e,t,En);if(c(e))return D(ve(`computed`,e));var n=c(t)?t:{};return n.get=e,n.name||=e.name||``,new Fn(n)};Object.assign(On,En),On.struct=D(Dn);var kn=0,An=1,jn=(wn=nn((function(){}),`name`)?.configurable)!=null&&wn,Mn={value:`action`,configurable:!0,writable:!1,enumerable:!1},Nn=function(e){function t(t,n,r,i,a){var o;return r===void 0&&(r=`ObservableValue`),a===void 0&&(a=gn.default),(o=e.call(this,r)||this).enhancer=void 0,o.tt=void 0,o.equals=void 0,o.jt=!1,o.et=void 0,o.ut=void 0,o.Ot=void 0,o.dehancer=void 0,o.enhancer=n,o.tt=r,o.equals=a,o.Ot=n(t,void 0,r),o}te(t,e);var n=t.prototype;return n.dehanceValue=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.set=function(e){(e=this.xt(e))!==z.UNCHANGED&&this.gt(e)},n.xt=function(e){if(kt(this)){var t=jt(this,{object:this,type:or,newValue:e});if(!t)return z.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.Ot,this.tt),this.equals(this.Ot,e)?z.UNCHANGED:e},n.gt=function(e){var t=this.Ot;this.Ot=e,this.reportChanged(),Mt(this)&&Pt(this,{type:or,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.Ot)},n.St=function(e){return At(this,e)},n._t=function(e,t){return t&&e({observableKind:`value`,debugObjectName:this.tt,object:this,type:or,newValue:this.Ot,oldValue:void 0}),Nt(this,e)},n.raw=function(){return this.Ot},n.toJSON=function(){return this.get()},n.toString=function(){return this.tt+`[`+this.Ot+`]`},n.valueOf=function(){return h(this.get())},n[Symbol.toPrimitive]=function(){return this.valueOf()},t}(mn),Pn=f(`ObservableValue`,Nn),Fn=function(){function e(e){this.I=R.P,this.D=[],this.W=null,this.F=new Set,this.q=0,this.$=0,this.U=R.L,this.G=0,this.Ot=new Rn(null),this.tt=void 0,this.At=void 0,this.bt=0,this.derivation=void 0,this.kt=void 0,this.Mt=In.NONE,this.Et=void 0,this.Vt=void 0,this.Rt=void 0,this.Nt=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.kt=Me(`ComputedValue-setter`,e.set)),this.Vt=e.equals||(e.compareStructural||e.struct?gn.structural:gn.default),this.Et=e.context,this.Rt=e.requiresReaction,this.Nt=!!e.keepAlive}var n=e.prototype;return n.H=function(){(function(e){e.U===R.L&&(e.U=R.B,e.F.forEach((function(e){e.I===R.L&&(e.I=R.B,e.H())})))})(this)},n.onBO=function(){this.onBOL&&this.onBOL.forEach((function(e){return e()}))},n.onBUO=function(){this.onBUOL&&this.onBUOL.forEach((function(e){return e()}))},n.get=function(){if(this.isComputing&&t(32,this.tt,this.derivation),z.inBatch!==0||this.F.size!==0||this.Nt){if(et(this),Be(this)){var e=z.trackingContext;this.Nt&&!e&&(z.trackingContext=this),this.trackAndCompute()&&function(e){e.U!==R.K&&(e.U=R.K,e.F.forEach((function(t){t.I===R.B?t.I=R.K:t.I===R.L&&(e.U=R.L)})))}(this),z.trackingContext=e}}else Be(this)&&(this.Tt(),Qe(),this.Ot=this.Ct(!1),$e());var n=this.Ot;if(ze(n))throw n.cause;return n},n.set=function(e){if(this.kt){this.isRunningSetter&&t(33,this.tt),this.isRunningSetter=!0;try{this.kt.call(this.Et,e)}finally{this.isRunningSetter=!1}}else t(34,this.tt)},n.trackAndCompute=function(){var e=this.Ot,t=this.I===R.P,n=this.Ct(!0),r=t||ze(e)||ze(n)||!this.Vt(e,n);return r&&(this.Ot=n),r},n.Ct=function(e){this.isComputing=!0;var t,n=Le(!1);if(e)t=Ve(this,this.derivation,this.Et);else if(!0===z.disableErrorBoundaries)t=this.derivation.call(this.Et);else try{t=this.derivation.call(this.Et)}catch(e){t=new Rn(e)}return Re(n),this.isComputing=!1,t},n.X=function(){this.Nt||(He(this),this.Ot=void 0)},n._t=function(e,t){var n=this,r=!0,i=void 0;return ct((function(){var a=n.get();if(!r||t){var o=We();e({observableKind:`computed`,debugObjectName:n.tt,type:or,object:n,newValue:a,oldValue:i}),Ge(o)}r=!1,i=a}))},n.Tt=function(){},n.toString=function(){return this.tt+`[`+this.derivation.toString()+`]`},n.valueOf=function(){return h(this.get())},n[Symbol.toPrimitive]=function(){return this.valueOf()},S(e,[{key:`isComputing`,get:function(){return _(this.bt,e.It)},set:function(t){this.bt=v(this.bt,e.It,t)}},{key:`isRunningSetter`,get:function(){return _(this.bt,e.Lt)},set:function(t){this.bt=v(this.bt,e.Lt,t)}},{key:`isBeingObserved`,get:function(){return _(this.bt,e.pt)},set:function(t){this.bt=v(this.bt,e.pt,t)}},{key:`isPendingUnobservation`,get:function(){return _(this.bt,e.yt)},set:function(t){this.bt=v(this.bt,e.yt,t)}},{key:`diffValue`,get:function(){return+!!_(this.bt,e.wt)},set:function(t){this.bt=v(this.bt,e.wt,t===1)}}])}();Fn.It=1,Fn.Lt=2,Fn.pt=4,Fn.yt=8,Fn.wt=16;var R,In,Ln=f(`ComputedValue`,Fn);(function(e){e[e.P=-1]=`NOT_TRACKING_`,e[e.L=0]=`UP_TO_DATE_`,e[e.B=1]=`POSSIBLY_STALE_`,e[e.K=2]=`STALE_`})(R||={}),function(e){e[e.NONE=0]=`NONE`,e[e.LOG=1]=`LOG`,e[e.BREAK=2]=`BREAK`}(In||={});var Rn=function(e){this.cause=void 0,this.cause=e},zn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`,`useProxies`],Bn=function(){this.version=6,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.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.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},Vn=!0,Hn=!1,z=function(){var e=n();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Vn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==new Bn().version&&(Vn=!1),Vn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Bn):(setTimeout((function(){Hn||t(35)}),1),new Bn)}(),Un=function(){function e(e,t,n,r){e===void 0&&(e=`Reaction`),this.tt=void 0,this.Pt=void 0,this.Kt=void 0,this.Bt=void 0,this.D=[],this.W=[],this.I=R.P,this.q=0,this.G=0,this.bt=0,this.Mt=In.NONE,this.tt=e,this.Pt=t,this.Kt=n,this.Bt=r}var t=e.prototype;return t.H=function(){this.Y()},t.Y=function(){this.isScheduled||(this.isScheduled=!0,z.pendingReactions.push(this),nt())},t.J=function(){if(!this.isDisposed){Qe(),this.isScheduled=!1;var e=z.trackingContext;if(z.trackingContext=this,Be(this)){this.isTrackPending=!0;try{this.Pt()}catch(e){this.Dt(e)}}z.trackingContext=e,$e()}},t.track=function(e){if(!this.isDisposed){Qe(),this.isRunning=!0;var t=z.trackingContext;z.trackingContext=this;var n=Ve(this,e,void 0);z.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&He(this),ze(n)&&this.Dt(n.cause),$e()}},t.Dt=function(e){var t=this;if(this.Kt)this.Kt(e,this);else{if(z.disableErrorBoundaries)throw e;z.suppressReactionErrors||console.error(`[mobx] uncaught error in '`+this+`'`,e),z.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},t.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||(Qe(),He(this),$e()))},t.Z=function(e){var t=this,n=function n(){t.dispose(),e==null||e.removeEventListener==null||e.removeEventListener(`abort`,n)};return e==null||e.addEventListener==null||e.addEventListener(`abort`,n),n[I]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(n[Symbol.dispose]=n),n},t.toString=function(){return`Reaction[`+this.tt+`]`},t.trace=function(){},S(e,[{key:`isDisposed`,get:function(){return _(this.bt,e.Wt)},set:function(t){this.bt=v(this.bt,e.Wt,t)}},{key:`isScheduled`,get:function(){return _(this.bt,e.qt)},set:function(t){this.bt=v(this.bt,e.qt,t)}},{key:`isTrackPending`,get:function(){return _(this.bt,e.Gt)},set:function(t){this.bt=v(this.bt,e.Gt,t)}},{key:`isRunning`,get:function(){return _(this.bt,e.Ht)},set:function(t){this.bt=v(this.bt,e.Ht,t)}},{key:`diffValue`,get:function(){return+!!_(this.bt,e.wt)},set:function(t){this.bt=v(this.bt,e.wt,t===1)}}])}();Un.Wt=1,Un.qt=2,Un.Gt=4,Un.Ht=8,Un.wt=16;var Wn=function(e){return e()},Gn=f(`Reaction`,Un),Kn=le(`action`),qn=le(`action.bound`,{bound:!0}),Jn=le(`autoAction`,{autoAction:!0}),Yn=le(`autoAction.bound`,{autoAction:!0,bound:!0}),Xn=at(!1);Object.assign(Xn,Kn);var Zn=at(!0);Object.assign(Zn,Jn),Xn.bound=D(qn),Zn.bound=D(Yn);var Qn=function(e){return e()},$n=0,er=function(e){function t(){var n;return n=e.call(this,`FLOW_CANCELLED`)||this,Object.setPrototypeOf(n,(this instanceof t?this.constructor:void 0).prototype),n.name=`FlowCancellationError`,n}return te(t,e),t.prototype.toString=function(){return`Error: `+this.message},t}(E(Error)),tr=me(`flow`),nr=me(`flow.bound`,{bound:!0}),rr=Object.assign((function(e,t){if(ae(t))return tr.t(e,t);if(o(t))return ie(e,t,tr);var n=e,r=n.name||`<unnamed flow>`,i=function(){var e,t=this,i=arguments,o=++$n,s=Xn(r+` - runid: `+o+` - init`,n).apply(t,i),c=void 0,l=new Promise((function(t,n){function i(e){var t;c=void 0;try{t=Xn(r+` - runid: `+o+` - yield `+ d++,s.next).call(s,e)}catch(e){return n(e)}u(t)}function l(e){var t;c=void 0;try{t=Xn(r+` - runid: `+o+` - yield `+ d++,s.throw).call(s,e)}catch(e){return n(e)}u(t)}function u(e){if(!a(e?.then))return e.done?t(e.value):(c=Promise.resolve(e.value)).then(i,l);e.then(u,n)}var d=0;e=n,i(void 0)}));return l.cancel=Xn(r+` - runid: `+o+` - cancel`,(function(){try{c&&gt(c);var t=s.return(void 0),n=Promise.resolve(t.value);n.then(F,F),gt(n),e(new er)}catch(t){e(t)}})),l};return i.isMobXFlow=!0,i}),tr);rr.bound=D(nr);var ir={has:function(e,t){return Ot(e).it(t)},get:function(e,t){return Ot(e).ct(t)},set:function(e,t,n){var r;return!!o(t)&&((r=Ot(e).ht(t,n,!0))==null||r)},deleteProperty:function(e,t){var n;return!!o(t)&&((n=Ot(e).Ut(t,!0))==null||n)},defineProperty:function(e,t,n){var r;return(r=Ot(e).l(t,n))==null||r},ownKeys:function(e){return Ot(e).rt()},preventExtensions:function(){t(13)}},ar=Symbol(`mobx-keys`),or=`update`,sr={get:function(e,t){var n=e[I];return t===I?n:t===`length`?n.Ft():typeof t!=`string`||isNaN(t)?g(lr,t)?lr[t]:e[t]:n.ct(parseInt(t))},set:function(e,t,n){var r=e[I];return t===`length`&&r.Xt(n),typeof t==`symbol`||isNaN(t)?e[t]=n:r.ht(parseInt(t),n),!0},preventExtensions:function(){t(15)}},cr=function(){function e(e,t,n,r){e===void 0&&(e=`ObservableArray`),this.zt=void 0,this.$t=void 0,this.st=void 0,this.j=[],this.et=void 0,this.ut=void 0,this.Jt=void 0,this.dehancer=void 0,this.v=void 0,this.Yt=0,this.zt=n,this.$t=r,this.st=new mn(e),this.Jt=function(e,n){return t(e,n,`ObservableArray[..]`)}}var n=e.prototype;return n.Qt=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.ft=function(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e},n.St=function(e){return At(this,e)},n._t=function(e,t){return t===void 0&&(t=!1),t&&e({observableKind:`array`,object:this.v,debugObjectName:this.st.tt,type:`splice`,index:0,added:this.j.slice(),addedCount:this.j.length,removed:[],removedCount:0}),Nt(this,e)},n.Ft=function(){return this.st.reportObserved(),this.j.length},n.Xt=function(e){(typeof e!=`number`||isNaN(e)||e<0)&&t(`Out of range: `+e);var n=this.j.length;if(e!==n)if(e>n){for(var r=Array(e-n),i=0;i<e-n;i++)r[i]=void 0;this.ot(n,0,r)}else this.ot(e,n-e)},n.Zt=function(e,n){e!==this.Yt&&t(16),this.Yt+=n,this.$t&&n>0&&Gt(e+n+1)},n.ot=function(e,t,n){var r=this,i=this.j.length;if(e===void 0?e=0:e>i?e=i:e<0&&(e=Math.max(0,i+e)),t=arguments.length===1?i-e:t==null?0:Math.max(0,Math.min(t,i-e)),n===void 0&&(n=on),kt(this)){var a=jt(this,{object:this.v,type:`splice`,index:e,removedCount:t,added:n});if(!a)return on;t=a.removedCount,n=a.added}if(n=n.length===0?n:n.map((function(e){return r.Jt(e,void 0)})),this.$t){var o=n.length-t;this.Zt(i,o)}var s=this.tn(e,t,n);return t===0&&n.length===0||this.nn(e,n,s),this.ft(s)},n.tn=function(e,t,n){var r;if(n.length<1e4)return(r=this.j).splice.apply(r,[e,t].concat(n));var i=this.j.slice(e,e+t),a=this.j.slice(e+t);this.j.length+=n.length-t;for(var o=0;o<n.length;o++)this.j[e+o]=n[o];for(var s=0;s<a.length;s++)this.j[e+n.length+s]=a[s];return i},n.in=function(e,t,n){var r=!this.zt&&!1,i=Mt(this),a=i||r?{observableKind:`array`,object:this.v,type:or,debugObjectName:this.st.tt,index:e,newValue:t,oldValue:n}:null;this.st.reportChanged(),i&&Pt(this,a)},n.nn=function(e,t,n){var r=!this.zt&&!1,i=Mt(this),a=i||r?{observableKind:`array`,object:this.v,debugObjectName:this.st.tt,type:`splice`,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.st.reportChanged(),i&&Pt(this,a)},n.ct=function(e){if(!(this.$t&&e>=this.j.length))return this.st.reportObserved(),this.Qt(this.j[e]);console.warn(`[mobx] Out of bounds read: `+e)},n.ht=function(e,n){var r=this.j;if(this.$t&&e>r.length&&t(17,e,r.length),e<r.length){var i=r[e];if(kt(this)){var a=jt(this,{type:or,object:this.v,index:e,newValue:n});if(!a)return;n=a.newValue}(n=this.Jt(n,i))!==i&&(r[e]=n,this.in(e,n,i))}else{for(var o=Array(e+1-r.length),s=0;s<o.length-1;s++)o[s]=void 0;o[o.length-1]=n,this.ot(r.length,0,o)}},e}(),lr={clear:function(){return this.splice(0)},replace:function(e){var t=this[I];return t.ot(0,t.j.length,e)},toJSON:function(){return this.slice()},splice:function(e,t){var n=[...arguments].slice(2),r=this[I];switch(arguments.length){case 0:return[];case 1:return r.ot(e);case 2:return r.ot(e,t)}return r.ot(e,t,n)},spliceWithArray:function(e,t,n){return this[I].ot(e,t,n)},push:function(){for(var e=this[I],t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.ot(e.j.length,0,n),e.j.length},pop:function(){return this.splice(Math.max(this[I].j.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){for(var e=this[I],t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.ot(0,0,n),e.j.length},reverse:function(){return z.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort:function(){z.trackingDerivation&&t(37,`sort`);var e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove:function(e){var t=this[I],n=t.ft(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};A(`at`,It),A(`concat`,It),A(`flat`,It),A(`includes`,It),A(`indexOf`,It),A(`join`,It),A(`lastIndexOf`,It),A(`slice`,It),A(`toString`,It),A(`toLocaleString`,It),A(`toSorted`,It),A(`toSpliced`,It),A(`with`,It),A(`every`,j),A(`filter`,j),A(`find`,j),A(`findIndex`,j),A(`findLast`,j),A(`findLastIndex`,j),A(`flatMap`,j),A(`forEach`,j),A(`map`,j),A(`some`,j),A(`toReversed`,j),A(`reduce`,Lt),A(`reduceRight`,Lt);var ur,dr,fr=f(`ObservableArrayAdministration`,cr),pr={},mr=`add`,hr=function(){function e(e,n,r){var i=this;n===void 0&&(n=se),r===void 0&&(r=`ObservableMap`),this.Jt=void 0,this.tt=void 0,this[I]=pr,this.vt=void 0,this.dt=void 0,this.lt=void 0,this.et=void 0,this.ut=void 0,this.dehancer=void 0,this.Jt=n,this.tt=r,a(Map)||t(18),Xt((function(){i.lt=oe(`ObservableMap.keys()`),i.vt=new Map,i.dt=new Map,e&&i.merge(e)}))}var n=e.prototype;return n.it=function(e){return this.vt.has(e)},n.has=function(e){var t=this;if(!z.trackingDerivation)return this.it(e);var n=this.dt.get(e);if(!n){var r=n=new Nn(this.it(e),ce,`ObservableMap.key?`,!1);this.dt.set(e,r),dt(r,(function(){return t.dt.delete(e)}))}return n.get()},n.set=function(e,t){var n=this.it(e);if(kt(this)){var r=jt(this,{type:n?or:mr,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.rn(e,t):this.en(e,t),this},n.delete=function(e){var t=this;if(kt(this)&&!jt(this,{type:`delete`,object:this,name:e}))return!1;if(this.it(e)){var n=Mt(this),r=n?{observableKind:`map`,debugObjectName:this.tt,type:`delete`,object:this,oldValue:this.vt.get(e).Ot,name:e}:null;return Tt((function(){var n;t.lt.reportChanged(),(n=t.dt.get(e))==null||n.gt(!1),t.vt.get(e).gt(void 0),t.vt.delete(e)})),n&&Pt(this,r),!0}return!1},n.rn=function(e,t){var n=this.vt.get(e);if((t=n.xt(t))!==z.UNCHANGED){var r=Mt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:or,object:this,oldValue:n.Ot,name:e,newValue:t}:null;n.gt(t),r&&Pt(this,i)}},n.en=function(e,t){var n=this;Tt((function(){var r,i=new Nn(t,n.Jt,`ObservableMap.key`,!1);n.vt.set(e,i),t=i.Ot,(r=n.dt.get(e))==null||r.gt(!0),n.lt.reportChanged()}));var r=Mt(this);r&&Pt(this,r?{observableKind:`map`,debugObjectName:this.tt,type:mr,object:this,name:e,newValue:t}:null)},n.get=function(e){return this.has(e)?this.Qt(this.vt.get(e).get()):this.Qt(void 0)},n.Qt=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.keys=function(){return this.lt.reportObserved(),this.vt.keys()},n.values=function(){var e=this,t=this.keys();return zt({next:function(){var n=t.next(),r=n.done;return{done:r,value:r?void 0:e.get(n.value)}}})},n.entries=function(){var e=this,t=this.keys();return zt({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},n[Symbol.iterator]=function(){return this.entries()},n.forEach=function(e,t){for(var n,r=C(this);!(n=r()).done;){var i=n.value;e.call(t,i[1],i[0],this)}},n.merge=function(e){var n=this;return gr(e)&&(e=new Map(e)),Tt((function(){var r,i;c(e)?function(e){var t=Object.keys(e);if(!un)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter((function(t){return an.propertyIsEnumerable.call(e,t)}))):t}(e).forEach((function(t){return n.set(t,e[t])})):Array.isArray(e)?e.forEach((function(e){return n.set(e[0],e[1])})):p(e)?(r=Object.getPrototypeOf(e),i=Object.getPrototypeOf(r),Object.getPrototypeOf(i)!==null&&t(19,e),e.forEach((function(e,t){return n.set(t,e)}))):e!=null&&t(20,e)})),this},n.clear=function(){var e=this;Tt((function(){Ue((function(){for(var t,n=C(e.keys());!(t=n()).done;)e.delete(t.value)}))}))},n.replace=function(e){var n=this;return Tt((function(){for(var r,i=function(e){if(p(e)||gr(e))return e;if(Array.isArray(e))return new Map(e);if(c(e)){var n=new Map;for(var r in e)n.set(r,e[r]);return n}return t(21,e)}(e),a=new Map,o=!1,s=C(n.vt.keys());!(r=s()).done;){var l=r.value;if(!i.has(l))if(n.delete(l))o=!0;else{var u=n.vt.get(l);a.set(l,u)}}for(var d,f=C(i.entries());!(d=f()).done;){var m=d.value,h=m[0],g=m[1],_=n.vt.has(h);if(n.set(h,g),n.vt.has(h)){var v=n.vt.get(h);a.set(h,v),_||(o=!0)}}if(!o)if(n.vt.size!==a.size)n.lt.reportChanged();else for(var y=n.vt.keys(),b=a.keys(),x=y.next(),S=b.next();!x.done;){if(x.value!==S.value){n.lt.reportChanged();break}x=y.next(),S=b.next()}n.vt=a})),this},n.toString=function(){return`[object ObservableMap]`},n.toJSON=function(){return Array.from(this)},n._t=function(e){return Nt(this,e)},n.St=function(e){return At(this,e)},S(e,[{key:`size`,get:function(){return this.lt.reportObserved(),this.vt.size}},{key:Symbol.toStringTag,get:function(){return`Map`}}])}(),gr=f(`ObservableMap`,hr),_r={},vr=function(){function e(e,n,r){var i=this;n===void 0&&(n=se),r===void 0&&(r=`ObservableSet`),this.tt=void 0,this[I]=_r,this.vt=new Set,this.st=void 0,this.ut=void 0,this.et=void 0,this.dehancer=void 0,this.Jt=void 0,this.tt=r,a(Set)||t(22),this.Jt=function(e,t){return n(e,t,r)},Xt((function(){i.st=oe(i.tt),e&&i.replace(e)}))}var n=e.prototype;return n.Qt=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.clear=function(){var e=this;Tt((function(){Ue((function(){for(var t,n=C(e.vt.values());!(t=n()).done;)e.delete(t.value)}))}))},n.forEach=function(e,t){for(var n,r=C(this);!(n=r()).done;){var i=n.value;e.call(t,i,i,this)}},n.add=function(e){var t=this;if(kt(this)){var n=jt(this,{type:mr,object:this,newValue:e});if(!n)return this;e=n.newValue}if(!this.has(e)){Tt((function(){t.vt.add(t.Jt(e,void 0)),t.st.reportChanged()}));var r=Mt(this);r&&Pt(this,r?{observableKind:`set`,debugObjectName:this.tt,type:mr,object:this,newValue:e}:null)}return this},n.delete=function(e){var t=this;if(kt(this)&&!jt(this,{type:`delete`,object:this,oldValue:e}))return!1;if(this.has(e)){var n=Mt(this),r=n?{observableKind:`set`,debugObjectName:this.tt,type:`delete`,object:this,oldValue:e}:null;return Tt((function(){t.st.reportChanged(),t.vt.delete(e)})),n&&Pt(this,r),!0}return!1},n.has=function(e){return this.st.reportObserved(),this.vt.has(this.Qt(e))},n.entries=function(){var e=this.values();return M({next:function(){var t=e.next(),n=t.value,r=t.done;return r?{value:void 0,done:r}:{value:[n,n],done:r}}})},n.keys=function(){return this.values()},n.values=function(){this.st.reportObserved();var e=this,t=this.vt.values();return M({next:function(){var n=t.next(),r=n.done;return r?{value:void 0,done:r}:{value:e.Qt(n.value),done:r}}})},n.intersection=function(e){return m(e)&&!yr(e)?e.intersection(this):new Set(this).intersection(e)},n.union=function(e){return m(e)&&!yr(e)?e.union(this):new Set(this).union(e)},n.difference=function(e){return new Set(this).difference(e)},n.symmetricDifference=function(e){return m(e)&&!yr(e)?e.symmetricDifference(this):new Set(this).symmetricDifference(e)},n.isSubsetOf=function(e){return new Set(this).isSubsetOf(e)},n.isSupersetOf=function(e){return new Set(this).isSupersetOf(e)},n.isDisjointFrom=function(e){return m(e)&&!yr(e)?e.isDisjointFrom(this):new Set(this).isDisjointFrom(e)},n.replace=function(e){var n=this;return yr(e)&&(e=new Set(e)),Tt((function(){Array.isArray(e)||m(e)?(n.clear(),e.forEach((function(e){return n.add(e)}))):e!=null&&t(`Cannot initialize set from `+e)})),this},n._t=function(e){return Nt(this,e)},n.St=function(e){return At(this,e)},n.toJSON=function(){return Array.from(this)},n.toString=function(){return`[object ObservableSet]`},n[Symbol.iterator]=function(){return this.values()},S(e,[{key:`size`,get:function(){return this.st.reportObserved(),this.vt.size}},{key:Symbol.toStringTag,get:function(){return`Set`}}])}(),yr=f(`ObservableSet`,vr),br=Object.create(null),xr=function(){function e(e,t,n,r){t===void 0&&(t=new Map),r===void 0&&(r=vn),this.h=void 0,this.j=void 0,this.tt=void 0,this.un=void 0,this.lt=void 0,this.ut=void 0,this.et=void 0,this.v=void 0,this.p=void 0,this.on=void 0,this.sn=void 0,this.h=e,this.j=t,this.tt=n,this.un=r,this.lt=new mn(`ObservableObject.keys`),this.p=c(this.h)}var n=e.prototype;return n.O=function(e){return this.j.get(e).get()},n.S=function(e,t){var n=this.j.get(e);if(n instanceof Fn)return n.set(t),!0;if(kt(this)){var r=jt(this,{type:or,object:this.v||this.h,name:e,newValue:t});if(!r)return null;t=r.newValue}if((t=n.xt(t))!==z.UNCHANGED){var i=Mt(this),a=i?{type:or,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.Ot,name:e,newValue:t}:null;n.gt(t),i&&Pt(this,a)}return!0},n.ct=function(e){return z.trackingDerivation&&!g(this.h,e)&&this.it(e),this.h[e]},n.ht=function(e,t,n){return n===void 0&&(n=!1),g(this.h,e)?this.j.has(e)?this.S(e,t):n?Reflect.set(this.h,e,t):(this.h[e]=t,!0):this.s(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.un,n)},n.it=function(e){if(!z.trackingDerivation)return e in this.h;this.sn||=new Map;var t=this.sn.get(e);return t||(t=new Nn(e in this.h,ce,`ObservableObject.key?`,!1),this.sn.set(e,t)),t.get()},n.o=function(e,n){if(!0===n&&(n=this.un),!1!==n){if(!(e in this.h)){var r;if((r=this.h[pn])!=null&&r[e])return;t(1,n.i,this.tt+`.`+e.toString())}for(var i=this.h;i&&i!==an;){var a=nn(i,e);if(a){var o=n.o(this,e,a,i);if(o===0)return;if(o===1)break}i=Object.getPrototypeOf(i)}Ht(this,0,e)}},n.s=function(e,t,n,r){if(r===void 0&&(r=!1),!0===n&&(n=this.un),!1===n)return this.l(e,t,r);var i=n.s(this,e,t,r);return i&&Ht(this,0,e),i},n.l=function(e,t,n){n===void 0&&(n=!1);try{Qe();var r=this.Ut(e);if(!r)return r;if(kt(this)){var i=jt(this,{object:this.v||this.h,name:e,type:mr,newValue:t.value});if(!i)return null;var a=i.newValue;t.value!==a&&(t=w({},t,{value:a}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else rn(this.h,e,t);this.fn(e,t.value)}finally{$e()}return!0},n.g=function(e,t,n,r){r===void 0&&(r=!1);try{Qe();var i=this.Ut(e);if(!i)return i;if(kt(this)){var a=jt(this,{object:this.v||this.h,name:e,type:mr,newValue:t});if(!a)return null;t=a.newValue}var o=Vt(e),s={configurable:!z.safeDescriptors||this.p,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.h,e,s))return!1}else rn(this.h,e,s);var c=new Nn(t,n,`ObservableObject.key`,!1);this.j.set(e,c),this.fn(e,c.Ot)}finally{$e()}return!0},n.m=function(e,t,n){n===void 0&&(n=!1);try{Qe();var r=this.Ut(e);if(!r)return r;if(kt(this)&&!jt(this,{object:this.v||this.h,name:e,type:mr,newValue:void 0}))return null;t.name||=`ObservableObject.key`,t.context=this.v||this.h;var i=Vt(e),a={configurable:!z.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else rn(this.h,e,a);this.j.set(e,new Fn(t)),this.fn(e,void 0)}finally{$e()}return!0},n.Ut=function(e,t){if(t===void 0&&(t=!1),!g(this.h,e))return!0;if(kt(this)&&!jt(this,{object:this.v||this.h,name:e,type:`remove`}))return null;try{var n;Qe();var r=Mt(this),i=this.j.get(e),a=void 0;if(!i&&r&&(a=nn(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 Nn&&(a=i.Ot),tt(i)),this.lt.reportChanged(),(n=this.sn)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&Pt(this,{type:`remove`,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{$e()}return!0},n._t=function(e){return Nt(this,e)},n.St=function(e){return At(this,e)},n.fn=function(e,t){var n,r=Mt(this);r&&r&&Pt(this,r?{type:mr,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,name:e,newValue:t}:null),(n=this.sn)==null||(n=n.get(e))==null||n.set(!0),this.lt.reportChanged()},n.rt=function(){return this.lt.reportObserved(),dn(this.h)},n.nt=function(){return this.lt.reportObserved(),Object.keys(this.h)},e}(),Sr=f(`ObservableObjectAdministration`,xr),Cr=Ut(0),wr=function(){var e=!1,t={};return Object.defineProperty(t,`0`,{set:function(){e=!0}}),Object.create(t)[0]=1,!1===e}(),Tr=0,Er=function(){};ur=Er,dr=Array.prototype,Object.setPrototypeOf?Object.setPrototypeOf(ur.prototype,dr):ur.prototype.__proto__===void 0?ur.prototype=dr:ur.prototype.__proto__=dr;var Dr=function(e){function t(t,n,r,i){var a;return r===void 0&&(r=`ObservableArray`),i===void 0&&(i=!1),a=e.call(this)||this,Xt((function(){var e=new cr(r,n,i,!0);e.v=a,d(a,I,e),t&&t.length&&a.spliceWithArray(0,0,t),wr&&Object.defineProperty(a,`0`,Cr)})),a}te(t,e);var n=t.prototype;return n.concat=function(){this[I].st.reportObserved();var e=[...arguments];return Array.prototype.concat.apply(this.slice(),e.map((function(e){return Rt(e)?e.slice():e})))},n[Symbol.iterator]=function(){var e=this,t=0;return $t({next:function(){return t<e.length?{value:e[t++],done:!1}:{done:!0,value:void 0}}})},S(t,[{key:`length`,get:function(){return this[I].Ft()},set:function(e){this[I].Xt(e)}},{key:Symbol.toStringTag,get:function(){return`Array`}}])}(Er);Object.entries(lr).forEach((function(e){var t=e[0];t!==`concat`&&u(Dr.prototype,t,e[1])})),Gt(1e3);var Or=an.toString,kr=n().Iterator?.prototype||{};[`Symbol`,`Map`,`Set`].forEach((function(e){n()[e]===void 0&&t(`MobX requires global '`+e+`' to be available or polyfilled`)})),typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__==`object`&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:it,extras:{getDebugName:Yt},$mobx:I}),e.$mobx=I,e.FlowCancellationError=er,e.ObservableMap=hr,e.ObservableSet=vr,e.Reaction=Un,e._allowStateChanges=Ie,e._allowStateChangesInsideComputed=ot,e._allowStateReadsEnd=qe,e._allowStateReadsStart=Ke,e._autoAction=Zn,e._endAction=Fe,e._getAdministration=Jt,e._getGlobalState=function(){return z},e._interceptReads=function(e,t,n){var r;return gr(e)||Rt(e)||Pn(e)?r=Jt(e):N(e)&&(r=Jt(e,t)),r.dehancer=typeof t==`function`?t:n,function(){r.dehancer=void 0}},e._isComputingDerivation=function(){return z.trackingDerivation!==null},e._resetGlobalState=function(){var e=new Bn;for(var t in e)zn.indexOf(t)===-1&&(z[t]=e[t]);z.allowStateChanges=!z.enforceActions},e._startAction=Pe,e.action=Xn,e.autorun=ct,e.comparer=gn,e.computed=On,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((z.pendingReactions.length||z.inBatch||z.isRunningReactions)&&t(36),Hn=!0,Vn){var e=n();--e.__mobxInstanceCount==0&&(e.__mobxGlobals=void 0),z=new Bn}}();var r,i,a=e.useProxies,o=e.enforceActions;if(a!==void 0&&(z.useProxies=a===`always`||a!==`never`&&typeof Proxy<`u`),a===`ifavailable`&&(z.verifyProxies=!0),o!==void 0){var s=o===`always`?`always`:o===`observed`;z.enforceActions=s,z.allowStateChanges=!0!==s&&s!==`always`}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach((function(t){t in e&&(z[t]=!!e[t])})),z.allowStateReads=!z.observableRequiresReaction,e.reactionScheduler&&(r=e.reactionScheduler,i=Wn,Wn=function(e){return r((function(){return i(e)}))})},e.createAtom=oe,e.defineProperty=function(e,n,r){if(N(e))return e[I].l(n,r);t(39)},e.entries=function(e){return N(e)?xt(e).map((function(t){return[t,e[t]]})):gr(e)?xt(e).map((function(t){return[t,e.get(t)]})):yr(e)?Array.from(e.entries()):Rt(e)?e.map((function(e,t){return[t,e]})):void t(7)},e.extendObservable=pt,e.flow=rr,e.flowResult=function(e){return e},e.get=function(e,n){if(St(e,n))return N(e)?e[I].ct(n):gr(e)?e.get(n):Rt(e)?e[n]:void t(11)},e.getAtom=qt,e.getDebugName=Yt,e.getDependencyTree=function(e,t){return mt(qt(e,t))},e.getObserverTree=function(e,t){return ht(qt(e,t))},e.has=St,e.intercept=function(e,t,n){return a(n)?function(e,t,n){return Jt(e,t).St(n)}(e,t,n):function(e,t){return Jt(e).St(t)}(e,t)},e.isAction=st,e.isBoxedObservable=Pn,e.isComputed=function(e){return vt(e)},e.isComputedProp=function(e,t){return vt(e,t)},e.isFlow=_t,e.isFlowCancellationError=function(e){return e instanceof er},e.isObservable=bt,e.isObservableArray=Rt,e.isObservableMap=gr,e.isObservableObject=N,e.isObservableProp=function(e,t){return yt(e,t)},e.isObservableSet=yr,e.keys=xt,e.makeAutoObservable=function(e,t,n){return c(e)?pt(e,e,t,n):(Xt((function(){var r=Bt(e,n)[I];if(!e[ar]){var i=Object.getPrototypeOf(e),a=new Set([].concat(dn(e),dn(i)));a.delete(`constructor`),a.delete(I),u(i,ar,a)}e[ar].forEach((function(e){return r.o(e,!t||!(e in t)||t[e])}))})),e)},e.makeObservable=function(e,t,n){return Xt((function(){var r=Bt(e,n)[I];t??=function(e){return g(e,pn)||u(e,pn,w({},e[pn])),e[pn]}(e),dn(t).forEach((function(e){return r.o(e,t[e])}))})),e},e.observable=Tn,e.observe=function(e,t,n,r){return a(n)?function(e,t,n,r){return Jt(e,t)._t(n,r)}(e,t,n,r):function(e,t,n){return Jt(e)._t(t,n)}(e,t,n)},e.onBecomeObserved=ut,e.onBecomeUnobserved=dt,e.onReactionError=function(e){return z.globalReactionErrorHandlers.push(e),function(){var t=z.globalReactionErrorHandlers.indexOf(e);t>=0&&z.globalReactionErrorHandlers.splice(t,1)}},e.override=_n,e.ownKeys=Ct,e.reaction=function(e,t,n){function r(){if(p=!1,!h.isDisposed){var t=!1,r=s;h.track((function(){var n=Ie(!1,(function(){return e(h)}));t=f||!m(s,n),s=n})),(f&&n.fireImmediately||!f&&t)&&l(s,r,h),f=!1}}var i;n===void 0&&(n=sn);var a,o,s,c=n.name??`Reaction`,l=Xn(c,n.onError?(a=n.onError,o=t,function(){try{return o.apply(this,arguments)}catch(e){a.call(this,e)}}):t),u=!n.scheduler&&!n.delay,d=lt(n),f=!0,p=!1,m=n.compareStructural?gn.structural:n.equals||gn.default,h=new Un(c,(function(){f||u?r():p||(p=!0,d(r))}),n.onError,n.requiresObservable);return(i=n)!=null&&(i=i.signal)!=null&&i.aborted||h.Y(),h.Z(n?.signal)},e.remove=function(e,n){N(e)?e[I].Ut(n):gr(e)||yr(e)?e.delete(n):Rt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=ot,e.set=function e(n,r,i){if(arguments.length!==2||yr(n))N(n)?n[I].ht(r,i):gr(n)?n.set(r,i):yr(n)?n.add(r):Rt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(`Invalid index: '`+r+`'`),Qe(),r>=n.length&&(n.length=r+1),n[r]=i,$e()):t(8);else{Qe();var a=r;try{for(var o in a)e(n,o,a[o])}finally{$e()}}},e.spy=it,e.toJS=function(e){return function e(t,n){if(typeof t!=`object`||!t||t instanceof Date||!bt(t))return t;if(Pn(t)||Ln(t))return e(t.get(),n);if(n.has(t))return n.get(t);if(Rt(t)){var r=wt(n,t,Array(t.length));return t.forEach((function(t,i){r[i]=e(t,n)})),r}if(yr(t)){var i=wt(n,t,new Set);return t.forEach((function(t){i.add(e(t,n))})),i}if(gr(t)){var a=wt(n,t,new Map);return t.forEach((function(t,r){a.set(r,e(t,n))})),a}var o=wt(n,t,{});return Ct(t).forEach((function(r){an.propertyIsEnumerable.call(t,r)&&(o[r]=e(t[r],n))})),o}(e,new Map)},e.trace=function(){},e.transaction=Tt,e.untracked=Ue,e.values=function(e){return N(e)?xt(e).map((function(t){return e[t]})):gr(e)?xt(e).map((function(t){return e.get(t)})):yr(e)?Array.from(e.values()):Rt(e)?e.slice():void t(6)},e.when=function(e,t,n){return arguments.length===1||t&&typeof t==`object`?Dt(e,t):Et(e,t,n||{})}})),Ev=he((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t={0:`Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'`,1:function(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.`,17:function(e,t){return`[mobx.array] Index out of bounds, `+e+` is larger than `+t},18:`mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js`,19:function(e){return`Cannot initialize from classes that inherit from Map: `+e.constructor.name},20:function(e){return`Cannot initialize map from `+e},21:function(e){return`Cannot convert to map from '`+e+`'`},22:`mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js`,23:`It is not possible to get index atoms from arrays`,24:function(e){return`Cannot obtain administration from `+e},25:function(e,t){return`the entry '`+e+`' does not exist in the observable map '`+t+`'`},26:`please specify a property`,27:function(e,t){return`no observable property '`+e.toString()+`' found on the observable object '`+t+`'`},28:function(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:function(e,t){return`Cycle detected in computation `+e+`: `+t},33:function(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:function(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:function(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`};function n(e){var n=[...arguments].slice(1),r=typeof e==`string`?e:t[e];throw typeof r==`function`&&(r=r.apply(null,n)),Error(`[MobX] `+r)}var r={};function i(){return typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:r}var a=Object.assign,o=Object.getOwnPropertyDescriptor,s=Object.defineProperty,c=Object.prototype,l=[];Object.freeze(l);var u={};Object.freeze(u);var d=typeof Proxy<`u`,f=Object.toString();function p(){d||n("`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`")}function m(e){L.verifyProxies&&n(`MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to `+e)}function h(){return++L.mobxGuid}function g(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}var _=function(){};function v(e){return typeof e==`function`}function y(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function b(e){return typeof e==`object`&&!!e}function x(e){if(!b(e))return!1;var t=Object.getPrototypeOf(e);if(t==null)return!0;var n=Object.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===f}function S(e){var t=e?.constructor;return t?t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`:!1}function C(e,t,n){s(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function w(e,t,n){s(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function ee(e,t){var n=`isMobX`+e;return t.prototype[n]=!0,function(e){return b(e)&&e[n]===!0}}function te(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function ne(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function T(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}var re=Object.getOwnPropertySymbols!==void 0;function E(e){var t=Object.keys(e);if(!re)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter(function(t){return c.propertyIsEnumerable.call(e,t)})):t}var D=typeof Reflect<`u`&&Reflect.ownKeys?Reflect.ownKeys:re?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function ie(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function ae(e){return e===null?null:typeof e==`object`?``+e:e}function oe(e,t){return c.hasOwnProperty.call(e,t)}var se=Object.getOwnPropertyDescriptors||function(e){var t={};return D(e).forEach(function(n){t[n]=o(e,n)}),t};function ce(e,t){return!!(e&t)}function le(e,t,n){return n?e|=t:e&=~t,e}function ue(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function de(e,t,n){if(ve())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&ye(i,n.prototype),i}function fe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,xe(r.key),r)}}function pe(e,t,n){return t&&fe(e.prototype,t),n&&fe(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function me(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=Se(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
54
+ `)){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 m_(e,t,n){return p_(e,t,n)}function h_(){return{abbrev:{fn:(e,t)=>mg(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},abbrevboth:{fn:(e,t,n)=>hg(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},camelcase:{fn:e=>Ag(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},cat:{fn:(...e)=>jg(...e),argTypes:[`string`],arity:{kind:`variadic`}},contains:{fn:(e,t)=>Mg(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasPrefix:{fn:(e,t)=>Ng(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},hasSuffix:{fn:(e,t)=>Pg(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},indent:{fn:(e,t)=>Fg(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},initials:{fn:e=>Ig(e),argTypes:[`string`],arity:{kind:`exact`}},join:{fn:(e,t)=>Lg(e,t),argTypes:[`string`,`list`],arity:{kind:`exact`}},kebabcase:{fn:e=>zg(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},lower:{fn:e=>Bg(e),argTypes:[`string`],arity:{kind:`exact`}},nindent:{fn:(e,t)=>Vg(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},nospace:{fn:e=>Hg(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},plural:{fn:(e,t,n)=>Ug(e,t,n),argTypes:[`string`,`string`,`int`],arity:{kind:`exact`},returnType:`string`},quote:{fn:(...e)=>Wg(...e),argTypes:[`string`],arity:{kind:`variadic`}},regexQuoteMeta:{fn:e=>Gg(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},repeat:{fn:(e,t)=>Kg(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},replace:{fn:(e,t,n)=>qg(e,t,n),argTypes:[`string`,`string`,`string`],arity:{kind:`exact`}},snakecase:{fn:e=>Jg(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},split:{fn:(e,t)=>Yg(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitList:{fn:(e,t)=>Xg(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},splitn:{fn:(e,t,n)=>Zg(e,t,n),argTypes:[`string`,`int`,`string`],arity:{kind:`exact`},returnType:`dict`},squote:{fn:(...e)=>$g(...e),argTypes:[`string`],arity:{kind:`variadic`}},substr:{fn:(e,t,n)=>e_(e,t,n),argTypes:[`int`,`int`,`string`],arity:{kind:`exact`}},swapcase:{fn:e=>t_(e),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},title:{fn:e=>i_(e),argTypes:[`string`],arity:{kind:`exact`}},trim:{fn:e=>a_(e),argTypes:[`string`],arity:{kind:`exact`}},trimAll:{fn:(e,t)=>o_(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimPrefix:{fn:(e,t)=>s_(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trimSuffix:{fn:(e,t)=>c_(e,t),argTypes:[`string`,`string`],arity:{kind:`exact`}},trunc:{fn:(e,t)=>l_(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},untitle:{fn:e=>u_(e),argTypes:[`string`],arity:{kind:`exact`}},upper:{fn:e=>d_(e),argTypes:[`string`],arity:{kind:`exact`}},wrap:{fn:(e,t)=>f_(e,t),argTypes:[`int`,`string`],arity:{kind:`exact`}},wrapWith:{fn:(e,t,n)=>m_(e,t,n),argTypes:[`int`,`string`,`string`],arity:{kind:`exact`}}}}function g_(e){return e}function __(e,t,n){return n===void 0?xu+yu(e)+`.`+yu(t):v_(n)}function v_(e){return xu+yu(e)}function y_(e,t){return e+`.`+t}function b_(e){return e+`.page`}const x_=[`closeOnPick`,`paged`,`key`,`distribution`],S_=e=>x_.includes(e),C_=`"closeOnPick" (bool, default false), "paged" (bool, default true), "key" (string, accordion grouping), "distribution" (one of ${ua.map(e=>`"${e}"`).join(`, `)}; default "van-der-corput")`;function w_(e){for(let t of Object.keys(e))if(!S_(t))throw Error(`unknown {{ menu }} option "${t}" — the options dict takes ${C_}`);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&&!da(r))throw Error(`{{ menu }} option "distribution" must be one of: ${ua.join(`, `)}; got ${JSON.stringify(r)}`);return{closeOnPick:t(`closeOnPick`,!1),paged:t(`paged`,!0),key:n,distribution:pa(r)}}const T_=`default`,E_={};function D_(e){return[...new Set([T_,...Object.keys(e)])]}function O_(e,t,n){return no(void 0,e,t,T_,n)}function k_(e,t){let n={[T_]:E_,...e}[t];if(n===void 0)throw Error(`Preset "${t}" is not declared in this config — effectivePresetName collapses unknown names to "${T_}", which always resolves; a miss here means a raw name reached this function without going through that resolution`);return n}function A_(e,t){let n=k_(e.presets,t).root??jc;return{node:Fc(Rc(n,e.root)),path:zc(n)?`presets.${t}.root`:`root`}}function j_(e,t){return{...e.globals,...k_(e.presets,t).globals}}const M_=`menu`,N_=`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`,P_=e=>e.kind===`call`&&e.name===`dict`,F_=e=>e.kind===`literal`&&typeof e.value!=`object`,I_=e=>Kc(``,e,2)===void 0;function L_(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&&P_(i)?i:void 0,o=a===void 0?r:r.slice(0,-1);if(o.some(P_))return t(`whose options (dict …) is not its last argument — ${N_}`);if(i!==void 0&&a===void 0&&!F_(i)&&I_(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=Kc(`whose trigger`,o.length,2);if(s!==void 0)return t(`${s} — ${N_}`);let c=a===void 0?{}:ah(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=w_(c)}catch(e){return t(`with invalid options — ${e.message}`)}let u=l.key;if(u!==void 0){let e=Tu(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 "${v_(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 R_(e){let t=mp({fromString:e=>e});try{return t.parse(e).referencedCalls().filter(e=>e.name===M_).map(L_)}catch{return`parse-failed`}}function z_(e){let t=mp({fromString:e=>e});try{return t.parse(e).referencedFunctions().has(M_)}catch{return!1}}function B_(e,t,n){e.issues.push({path:t,message:n,line:W(e.source,[`root`])})}function V_(e,t){Eu(e,t,xu,`{{ menu }} helpers`);for(let[n,r]of Object.entries(t.helpers??{}))z_(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:W(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`&&z_(i)&&B_(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.`)}if(t.root!==void 0)for(let n of Ms(Ic(t.root)))typeof n.when==`string`&&z_(n.when)&&B_(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||!z_(r))continue;let n=R_(r);if(n!==`parse-failed`)for(let r of n){let n=r.kind===`issue`?r.message:H_(r.apply);n!==void 0&&B_(e,`segments.${t}`,`segment "${t}" has a {{ menu }} ${n}.`)}}}function H_(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(g_(e)===`closed`)return`whose apply action is named "${Wc}", which collides with the menu's closed-state sentinel and leaves it unopenable. Rename the action`}function U_(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 D_(e.presets)){let a=new Map,s=new Map;for(let c of Ms(A_(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,R_(t.template));let l=i.get(c.name);if(l===`parse-failed`)continue;let u=Os(c);for(let[e,t]of l.entries()){if(t.kind===`issue`||H_(t.apply)!==void 0)continue;let{apply:i,options:l}=t,d=g_(i),f=__(u,i,l.key),p=b_(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=y_(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]=nl(f,d),n[f]=tl(f,Wc),n[p]={kind:`state`,key:p,default:`0`},r[p]={set:p,int:!0}}}}return{...e,variables:{...e.variables,...n},actions:{...e.actions,...r}}}const W_=mp({fromString:e=>e}),G_=`edit.mode`,K_=`edit.configure`,q_=`edit.toggle`,J_=`edit.unconfigure`,Y_=[q_,J_],X_=`arrange`,Z_=`${Su}draft.`;function Q_(e,t){return`${e}:${t}`}const $_={variable:G_,key:G_,member:X_},ev=Xc($_);function tv(e){try{return W_.parse(e).referencedCalls().some(e=>e.name===`action`&&e.args[0]===`edit.toggle`)}catch{return!1}}function nv(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??{}))for(let e of[t.template,t.bg,t.fg])if(typeof e==`string`&&tv(e))return!0;return!1}function rv(e,t){if(Eu(e,t,Su,`edit mode`),!nv(t))return;let{variables:n,actions:r}=iv();t.variables={...t.variables??{},...n},t.actions={...t.actions??{},...r}}function iv(){return{variables:{[G_]:tl(G_,Wc),[K_]:tl(K_,Wc)},actions:{[q_]:nl(G_,X_),[J_]:{set:K_,to:Wc}}}}const av=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g;function*ov(e){let t=e.indexOf(`{{`);for(;t!==-1;){let n=``,r=t+2;for(;r<e.length&&!e.startsWith(`}}`,r);){if(e.startsWith(`/*`,r)){let t=e.indexOf(`*/`,r+2);r=t===-1?e.length:t+2;continue}let t=r,i=e[r];if(r+=1,i===`"`||i===`'`||i==="`"){for(;r<e.length&&e[r]!==i;)r+=e[r]===`\\`&&i!=="`"?2:1;r+=1}n+=e.slice(t,r)}if(r>=e.length)return;yield n,t=e.indexOf(`{{`,r+2)}}const sv=`[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*`,cv=RegExp(`^(?:(\\$)(?:\\.(${sv}))?|\\.(${sv})?)(?=[\\s)]|$)`);function lv(e,t,n){let r=cv.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 uv=/^(\w+)\b\s*([\s\S]*)$/;function*dv(e,t){let n=[t];for(let r of ov(e)){let e=r.replace(/^-(?=\s)/,``).trim(),[,i=``,a=``]=uv.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};let r=/^with\b([\s\S]*)$/.exec(a);n[n.length-1]=r===null?s:lv(r[1],s,t);continue}yield{code:e,dot:o},i===`if`&&n.push(o),i===`with`&&n.push(lv(a,o,t)),(i===`range`||i===`define`||i===`block`)&&n.push(null)}}const fv=/(?<![.$])\btemplate\s+$/;function*pv(e,t,n){let r=0;for(let i of[...e.matchAll(av)]){let a=i.index+i[0].length;fv.test(e.slice(r,i.index))&&(yield{name:i[0].slice(1,-1),at:lv(e.slice(a),t,n)}),r=a}}function*mv(e,t){let n=new Set;function*r(e,i,a,o){for(let{code:s,dot:c}of[...dv(e,i)]){yield{code:s,dot:c,root:i,via:a};for(let e of[...pv(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)}const hv=RegExp(`(?<![A-Za-z0-9_)$])(\\$?)\\.(${sv})`,`g`);function*gv({code:e,dot:t,root:n}){let r=e.replace(av,``);for(let e of[...r.matchAll(hv)]){let r=e[1]===`$`?n:t;r!==null&&(yield`${r}${e[2]}`)}}function _v(e,t){let n=new Map;for(let r of mv(e,t))for(let e of gv(r))n.has(e)||n.set(e,r.via);return n}const vv=/(?<![.$])\b(action|picker|menu|carousel)\s+$/,yv={action:1,picker:2,menu:1,carousel:2};function*bv(e){let t=0,n=0,r=0,i=`action`;for(let a of[...e.matchAll(av)]){let o=e.slice(t,a.index),s=vv.exec(o);if(s!==null)n=yv[s[1]],r=0,i=s[1]===`action`?`action`:`options`;else for(let e of o)e===`(`&&r++,e===`)`&&r--,(r<0||e===`|`&&r===0)&&(n=0);n>0&&r===0&&(yield{name:a[0].slice(1,-1),site:i},n--),t=a.index+a[0].length}}function xv(e,t){let n=new Map;for(let{code:r,via:i}of mv(e,t))for(let{name:e,site:t}of bv(r)){let r=`${e}\0${i??`\0`}`;n.has(r)||n.set(r,{name:e,site:t,via:i})}return[...n.values()]}function Sv(e,t){let n=new Set;for(let{code:r,dot:i,root:a}of mv(e,t))for(let{name:e}of pv(r,i,a))Object.hasOwn(t,e)&&n.add(e);return n}function Cv(e,t){if(t.names.has(e))return!0;let n=`${e}.`;for(let e of t.names)if(e.startsWith(n))return!0;for(let n of t.documents)if(e.startsWith(`${n}.`))return!0;return!1}function wv(e){let t=new Set,n=new Set,r=(e,r)=>{t.add(e),Tv(r)&&n.add(e)};for(let[t,n]of Object.entries(e.variables))r(t,n);for(let[t,n]of Object.entries(e.segments))for(let[e,i]of Object.entries(n.vars??{}))r(`${t}.${e}`,i);return{names:t,documents:n,helpers:e.helpers}}function Tv(e){return(e.kind===`shell`||e.kind===`file`)&&Ls(e.parse)===`json`}var Ev=he((e=>{function t(e){var t=[...arguments].slice(1);throw Error(typeof e==`number`?`[MobX] minified error nr: `+e+(t.length?` `+t.map(String).join(`,`):``)+`. Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts`:`[MobX] `+e)}function n(){return typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:tn}function r(){cn||t(`Proxy not available`)}function i(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}function a(e){return typeof e==`function`}function o(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function s(e){return typeof e==`object`&&!!e}function c(e){if(!s(e))return!1;var t=Object.getPrototypeOf(e);if(t==null)return!0;var n=Object.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===ln}function l(e){var t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function u(e,t,n){rn(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function d(e,t,n){rn(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function f(e,t){var n=`isMobX`+e;return t.prototype[n]=!0,function(e){return s(e)&&!0===e[n]}}function p(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function m(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}function h(e){return e===null?null:typeof e==`object`?``+e:e}function g(e,t){return an.hasOwnProperty.call(e,t)}function _(e,t){return!!(e&t)}function v(e,t,n){return n?e|=t:e&=~t,e}function y(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t,n){if(te())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&ne(i,n.prototype),i}function x(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,re(r.key),r)}}function S(e,t,n){return t&&x(e.prototype,t),n&&x(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function C(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if(typeof e==`string`)return y(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
55
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function w(){return(w=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}function T(e){return(T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ne(e,t)}function te(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch{}return(te=function(){return!!e})()}function ne(e,t){return(ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function re(e){var t=function(e){if(typeof e!=`object`||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,`string`);if(typeof n!=`object`)return n;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}(e);return typeof t==`symbol`?t:t+``}function E(e){var t=typeof Map==`function`?new Map:void 0;return(E=function(e){function n(){return b(e,arguments,T(this).constructor)}if(e===null||!function(e){try{return Function.toString.call(e).indexOf(`[native code]`)!==-1}catch{return typeof e==`function`}}(e))return e;if(typeof e!=`function`)throw TypeError(`Super expression must either be null or a function`);if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,n)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ne(n,e)})(e)}function D(e){return Object.assign((function(t,n){if(ae(n))return e.t(t,n);ie(t,n,e)}),e)}function ie(e,t,n){g(e,pn)||u(e,pn,w({},e[pn])),function(e){return e.i===`override`}(n)||(e[pn][t]=n)}function ae(e){return typeof e==`object`&&typeof e.kind==`string`}function oe(e,t,n){t===void 0&&(t=F),n===void 0&&(n=F);var r=new mn(e);return t!==F&&ut(r,t),n!==F&&dt(r,n),r}function se(e,t,n){return bt(e)?e:Array.isArray(e)?Tn.array(e,{name:n}):c(e)?Tn.object(e,void 0,{name:n}):p(e)?Tn.map(e,{name:n}):m(e)?Tn.set(e,{name:n}):typeof e!=`function`||st(e)||_t(e)?e:l(e)?rr(e):Zn(n,e)}function ce(e){return e}function le(e,t){return{i:e,u:t,o:ue,s:de,t:fe}}function ue(e,t,n,r){var i;return(i=this.u)!=null&&i.bound?this.s(e,t,n,!1)===null?0:1:r===e.h?this.s(e,t,n,!1)===null?0:2:st(n.value)?1:(rn(r,t,pe(e,this,t,n,!1)),2)}function de(e,t,n,r){var i=pe(e,this,t,n);return e.l(t,i,r)}function fe(e,n){var r,i=n.kind,a=n.name,o=n.addInitializer,s=this,c=function(e){var t;return Me(s.u?.name??a.toString(),e,(t=s.u?.autoAction)!=null&&t)};return i==`field`?function(e){var t,n=e;return st(n)||(n=c(n)),(t=s.u)!=null&&t.bound&&((n=n.bind(this)).isMobxAction=!0),n}:i==`method`?(st(e)||(e=c(e)),(r=this.u)!=null&&r.bound&&o((function(){var e=this[a].bind(this);e.isMobxAction=!0,this[a]=e})),e):void t(`Cannot apply '`+s.i+`' to '`+String(a)+`' (kind: `+i+`):
56
+ '`+s.i+`' can only be used on properties with a function value.`)}function pe(e,t,n,r,i){var a,o,s;i===void 0&&(i=z.safeDescriptors);var c=r.value;return(a=t.u)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:Me(t.u?.name??n.toString(),c,(o=t.u?.autoAction)!=null&&o,(s=t.u)!=null&&s.bound?e.v??e.h:void 0),configurable:!i||e.p,enumerable:!1,writable:!i}}function me(e,t){return{i:e,u:t,o:he,s:ge,t:_e}}function he(e,t,n,r){var i;return r===e.h?this.s(e,t,n,!1)===null?0:2:(i=this.u)!=null&&i.bound&&(!g(e.h,t)||!_t(e.h[t]))&&this.s(e,t,n,!1)===null?0:_t(n.value)?1:(rn(r,t,O(e,0,0,n,!1,!1)),2)}function ge(e,t,n,r){var i=O(e,0,0,n,this.u?.bound);return e.l(t,i,r)}function _e(e,t){var n,r=t.name,i=t.addInitializer;return _t(e)||(e=rr(e)),(n=this.u)!=null&&n.bound&&i((function(){var e=this[r].bind(this);e.isMobXFlow=!0,this[r]=e})),e}function O(e,t,n,r,i,a){a===void 0&&(a=z.safeDescriptors);var o=r.value;return _t(o)||(o=rr(o)),i&&((o=o.bind(e.v??e.h)).isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function ve(e,t){return{i:e,u:t,o:ye,s:be,t:xe}}function ye(e,t,n){return this.s(e,t,n,!1)===null?0:1}function be(e,t,n,r){return e.m(t,w({},this.u,{get:n.get,set:n.set}),r)}function xe(e,t){var n=this,r=t.name;return(0,t.addInitializer)((function(){var t=Bt(this)[I],i=w({},n.u,{get:e,context:this});i.name||=`ObservableObject.`+r.toString(),t.j.set(r,new Fn(i))})),function(){return this[I].O(r)}}function Se(e,t){return{i:e,u:t,o:Ce,s:we,t:Te}}function Ce(e,t,n){return this.s(e,t,n,!1)===null?0:1}function we(e,t,n,r){return e.g(t,n.value,this.u?.enhancer??se,r)}function Te(e,t){function n(e,t){var n=Bt(e)[I],i=new Nn(t,r.u?.enhancer??se,`ObservableObject.`+a.toString(),!1);n.j.set(a,i),o.add(e)}var r=this,i=t.kind,a=t.name,o=new WeakSet;if(i==`accessor`)return{get:function(){return o.has(this)||n(this,e.get.call(this)),this[I].O(a)},set:function(e){return o.has(this)||n(this,e),this[I].S(a,e)},init:function(e){return o.has(this)||n(this,e),e}}}function Ee(e){return{i:`true`,u:e,o:De,s:Oe,t:ke}}function De(e,t,n,r){var i,a,o;if(n.get)return On.o(e,t,n,r);if(n.set){var s=st(n.set)?n.set:Me(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!z.safeDescriptors||e.p,set:s})===null?0:2:(rn(r,t,{configurable:!0,set:s}),2)}if(r!==e.h&&typeof n.value==`function`)return l(n.value)?((o=this.u)!=null&&o.autoBind?rr.bound:rr).o(e,t,n,r):((a=this.u)!=null&&a.autoBind?Zn.bound:Zn).o(e,t,n,r);var c=!1===this.u?.deep?Tn.ref:Tn;return typeof n.value==`function`&&(i=this.u)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),c.o(e,t,n,r)}function Oe(e,t,n,r){var i;return n.get?On.s(e,t,n,r):n.set?e.l(t,{configurable:!z.safeDescriptors||e.p,set:Me(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.u)!=null&&i.autoBind&&(n.value=n.value.bind(e.v??e.h)),(!1===this.u?.deep?Tn.ref:Tn).s(e,t,n,r))}function ke(){t(`'`+this.i+`' cannot be used as a decorator`)}function Ae(e){return e||yn}function k(e){return!0===e.deep?se:!1===e.deep?ce:(t=e.defaultDecorator)&&(n=(r=t.u)?.enhancer)!=null?n:se;var t,n,r}function je(e,t,n){return ae(t)?bn.t(e,t):o(t)?void ie(e,t,bn):bt(e)?e:c(e)?Tn.object(e,t,n):Array.isArray(e)?Tn.array(e,t):p(e)?Tn.map(e,t):m(e)?Tn.set(e,t):typeof e==`object`&&e?e:Tn.box(e,t)}function Me(e,t,n,r){function i(){return Ne(0,n,t,r||this,arguments)}return n===void 0&&(n=!1),i.isMobxAction=!0,i.toString=function(){return t.toString()},jn&&(Mn.value=e,rn(i,`name`,Mn)),i}function Ne(e,t,n,r,i){var a=Pe(0,t);try{return n.apply(r,i)}catch(e){throw a._=e,e}finally{Fe(a)}}function Pe(e,t){var n=z.trackingDerivation,r=!t||!n;Qe();var i=z.allowStateChanges;r&&(We(),i=Le(!0));var a={A:r,k:n,M:i,V:Ke(!0),R:!1,N:0,T:An++,C:kn};return kn=a.T,a}function Fe(e){kn!==e.T&&t(30),kn=e.C,e._!==void 0&&(z.suppressReactionErrors=!0),Re(e.M),qe(e.V),$e(),e.A&&Ge(e.k),z.suppressReactionErrors=!1}function Ie(e,t){var n=Le(e);try{return t()}finally{Re(n)}}function Le(e){var t=z.allowStateChanges;return z.allowStateChanges=e,t}function Re(e){z.allowStateChanges=e}function ze(e){return e instanceof Rn}function Be(e){switch(e.I){case R.L:return!1;case R.P:case R.K:return!0;case R.B:for(var t=Ke(!0),n=We(),r=e.D,i=r.length,a=0;a<i;a++){var o=r[a];if(Ln(o)){if(z.disableErrorBoundaries)o.get();else try{o.get()}catch{return Ge(n),qe(t),!0}if(e.I===R.K)return Ge(n),qe(t),!0}}return Je(e),Ge(n),qe(t),!1}}function Ve(e,t,n){var r=Ke(!0);Je(e),e.W=Array(e.q===0?100:e.D.length),e.G=0,e.q=++z.runId;var i,a=z.trackingDerivation;if(z.trackingDerivation=e,z.inBatch++,!0===z.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new Rn(e)}return z.inBatch--,z.trackingDerivation=a,function(e){for(var t=e.D,n=e.D=e.W,r=R.L,i=0,a=e.G,o=0;o<a;o++){var s=n[o];s.diffValue===0&&(s.diffValue=1,i!==o&&(n[i]=s),i++),s.I>r&&(r=s.I)}for(n.length=i,e.W=null,a=t.length;a--;){var c=t[a];c.diffValue===0&&Xe(c,e),c.diffValue=0}for(;i--;){var l=n[i];l.diffValue===1&&(l.diffValue=0,Ye(l,e))}r!==R.L&&(e.I=r,e.H())}(e),qe(r),i}function He(e){var t=e.D;e.D=[];for(var n=t.length;n--;)Xe(t[n],e);e.I=R.P}function Ue(e){var t=We();try{return e()}finally{Ge(t)}}function We(){var e=z.trackingDerivation;return z.trackingDerivation=null,e}function Ge(e){z.trackingDerivation=e}function Ke(e){var t=z.allowStateReads;return z.allowStateReads=e,t}function qe(e){z.allowStateReads=e}function Je(e){if(e.I!==R.L){e.I=R.L;for(var t=e.D,n=t.length;n--;)t[n].U=R.L}}function Ye(e,t){e.F.add(t),e.U>t.I&&(e.U=t.I)}function Xe(e,t){e.F.delete(t),e.F.size===0&&Ze(e)}function Ze(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,z.pendingUnobservations.push(e))}function Qe(){z.inBatch++}function $e(){if(--z.inBatch==0){nt();for(var e=z.pendingUnobservations,t=0;t<e.length;t++){var n=e[t];n.isPendingUnobservation=!1,n.F.size===0&&(n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof Fn&&n.X())}z.pendingUnobservations=[]}}function et(e){var t=z.trackingDerivation;return t===null?(e.F.size===0&&z.inBatch>0&&Ze(e),!1):(t.q!==e.$&&(e.$=t.q,t.W[t.G++]=e,!e.isBeingObserved&&z.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function tt(e){e.U!==R.K&&(e.U=R.K,e.F.forEach((function(e){e.I===R.L&&e.H(),e.I=R.K})))}function nt(){z.inBatch>0||z.isRunningReactions||Wn(rt)}function rt(){z.isRunningReactions=!0;for(var e=z.pendingReactions,t=0;e.length>0;){++t==100&&(console.error(`[mobx] cycle in reaction: `+e[0]),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r<i;r++)n[r].J()}z.isRunningReactions=!1}function it(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}}function at(e){return function(t,n){return a(t)?Me(t.name||`<unnamed action>`,t,e):a(n)?Me(t,n,e):ae(n)?(e?Jn:Kn).t(t,n):o(n)?ie(t,n,e?Jn:Kn):o(t)?D(le(e?`autoAction`:`action`,{name:t,autoAction:e})):void 0}}function ot(e){return Ne(0,!1,e,this,void 0)}function st(e){return a(e)&&!0===e.isMobxAction}function ct(e,t){function n(){e(i)}var r;t===void 0&&(t=sn);var i,a=t?.name??`Autorun`;if(t.scheduler||t.delay){var o=lt(t),s=!1;i=new Un(a,(function(){s||(s=!0,o((function(){s=!1,i.isDisposed||i.track(n)})))}),t.onError,t.requiresObservable)}else i=new Un(a,(function(){this.track(n)}),t.onError,t.requiresObservable);return(r=t)!=null&&(r=r.signal)!=null&&r.aborted||i.Y(),i.Z(t?.signal)}function lt(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:Qn}function ut(e,t,n){return ft(`onBO`,e,t,n)}function dt(e,t,n){return ft(`onBUO`,e,t,n)}function ft(e,t,n,r){var i=typeof r==`function`?qt(t,n):qt(t),o=a(r)?r:n,s=e+`L`;return i[s]?i[s].add(o):i[s]=new Set([o]),function(){var e=i[s];e&&(e.delete(o),e.size===0&&delete i[s])}}function pt(e,t,n,r){var i=fn(t);return Xt((function(){var t=Bt(e,r)[I];dn(i).forEach((function(e){t.s(e,i[e],!n||!(e in n)||n[e])}))})),e}function mt(e){var t,n={name:e.tt};return e.D&&e.D.length>0&&(n.dependencies=(t=e.D,Array.from(new Set(t))).map(mt)),n}function ht(e){var t={name:e.tt};return function(e){return e.F&&e.F.size>0}(e)&&(t.observers=Array.from(function(e){return e.F}(e)).map(ht)),t}function gt(e){a(e.cancel)&&e.cancel()}function _t(e){return!0===e?.isMobXFlow}function vt(e,t){return t===void 0?Ln(e):!1===N(e)||!e[I].j.has(t)?!1:Ln(qt(e,t))}function yt(e,t){return!!e&&(t===void 0?N(e)||!!e[I]||hn(e)||Gn(e)||Ln(e):!!N(e)&&e[I].j.has(t))}function bt(e){return yt(e)}function xt(e){return N(e)?e[I].nt():gr(e)||yr(e)?Array.from(e.keys()):Rt(e)?e.map((function(e,t){return t})):void t(5)}function St(e,n){return N(e)?e[I].it(n):gr(e)||yr(e)?e.has(n):Rt(e)?n>=0&&n<e.length:void t(10)}function Ct(e){if(N(e))return e[I].rt();t(38)}function wt(e,t,n){return e.set(t,n),n}function Tt(e,t){t===void 0&&(t=void 0),Qe();try{return e.apply(t)}finally{$e()}}function Et(e,t,n){var r;if(typeof n.timeout==`number`){var i=Error(`WHEN_TIMEOUT`);r=setTimeout((function(){if(!o[I].isDisposed){if(o(),!n.onError)throw i;n.onError(i)}}),n.timeout)}n.name=`When`;var a=Me(`When-effect`,t),o=ct((function(t){Ie(!1,e)&&(t.dispose(),r&&clearTimeout(r),a())}),n);return o}function Dt(e,t){var n,r,i;if(t!=null&&(n=t.signal)!=null&&n.aborted)return Object.assign(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:function(){return null}});var a=new Promise((function(n,a){var o,s=Et(e,n,w({},t,{onError:a}));r=function(){s(),a(Error(`WHEN_CANCELLED`))},i=function(){s(),a(Error(`WHEN_ABORTED`))},t==null||(o=t.signal)==null||o.addEventListener==null||o.addEventListener(`abort`,i)})).finally((function(){var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,i)}));return a.cancel=r,a}function Ot(e){return e[I]}function kt(e){return e.et!==void 0&&e.et.length>0}function At(e,t){var n=e.et||=[];return n.push(t),i((function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)}))}function jt(e,n){var r=We();try{for(var i=[].concat(e.et||[]),a=0,o=i.length;a<o&&((n=i[a](n))&&!n.type&&t(14),n);a++);return n}finally{Ge(r)}}function Mt(e){return e.ut!==void 0&&e.ut.length>0}function Nt(e,t){var n=e.ut||=[];return n.push(t),i((function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)}))}function Pt(e,t){var n=We(),r=e.ut;if(r){for(var i=0,a=(r=r.slice()).length;i<a;i++)r[i](t);Ge(n)}}function Ft(e,t,n,i){return n===void 0&&(n=`ObservableArray`),i===void 0&&(i=!1),r(),Xt((function(){var r=new cr(n,t,i,!1);d(r.j,I,r);var a=new Proxy(r.j,sr);return r.v=a,e&&e.length&&r.ot(0,0,e),a}))}function A(e,t){typeof Array.prototype[e]==`function`&&(lr[e]=t(e))}function It(e){return function(){var t=this[I];t.st.reportObserved();var n=t.ft(t.j);return n[e].apply(n,arguments)}}function j(e){return function(t,n){var r=this,i=this[I];return i.st.reportObserved(),i.ft(i.j)[e]((function(e,i){return t.call(n,e,i,r)}))}}function Lt(e){return function(){var t=this,n=this[I];n.st.reportObserved();var r=n.ft(n.j),i=arguments[0];return arguments[0]=function(e,n,r){return i(e,n,r,t)},r[e].apply(r,arguments)}}function Rt(e){return s(e)&&fr(e[I])}function zt(e){return e[Symbol.toStringTag]=`MapIterator`,$t(e)}function M(e){return e[Symbol.toStringTag]=`SetIterator`,$t(e)}function Bt(e,t){if(g(e,I))return e;var n=t?.name??`ObservableObject`;return u(e,I,new xr(e,new Map,String(n),function(e){return e?e.defaultDecorator??Ee(e):void 0}(t))),e}function Vt(e){return br[e]||(br[e]={get:function(){return this[I].O(e)},set:function(t){return this[I].S(e,t)}})}function N(e){return!!s(e)&&Sr(e[I])}function Ht(e,t,n){var r;(r=e.h[pn])==null||delete r[n]}function Ut(e){return{enumerable:!1,configurable:!0,get:function(){return this[I].ct(e)},set:function(t){this[I].ht(e,t)}}}function Wt(e){rn(Dr.prototype,``+e,Ut(e))}function Gt(e){if(e>Tr){for(var t=Tr;t<e+100;t++)Wt(t);Tr=e}}function Kt(e,t,n){return new Dr(e,t,n)}function qt(e,n){if(typeof e==`object`&&e){if(Rt(e))return n!==void 0&&t(23),e[I].st;if(yr(e))return e.st;if(gr(e)){if(n===void 0)return e.lt;var r=e.vt.get(n)||e.dt.get(n);return r||t(25,n,Yt(e)),r}if(N(e)){if(!n)return t(26);var i=e[I].j.get(n);return i||t(27,n,Yt(e)),i}if(hn(e)||Ln(e)||Gn(e))return e}else if(a(e)&&Gn(e[I]))return e[I];t(28)}function Jt(e,n){return e||t(29),n===void 0?hn(e)||Ln(e)||Gn(e)||gr(e)||yr(e)?e:e[I]?e[I]:void t(24,e):Jt(qt(e,n))}function Yt(e,t){var n;if(t!==void 0)n=qt(e,t);else{if(st(e))return e.name;n=N(e)||gr(e)||yr(e)?Jt(e):qt(e)}return n.tt}function Xt(e){var t=We(),n=Le(!0);Qe();try{return e()}finally{$e(),Re(n),Ge(t)}}function Zt(e,t,n){return n===void 0&&(n=-1),function e(t,n,r,i,o){if(t===n)return t!==0||1/t==1/n;if(t==null||n==null)return!1;if(t!=t)return n!=n;var s=typeof t;if(s!==`function`&&s!==`object`&&typeof n!=`object`)return!1;var c=Or.call(t);if(c!==Or.call(n))return!1;switch(c){case`[object RegExp]`:case`[object String]`:return``+t==``+n;case`[object Number]`:return+t==+t?+t==0?1/t==1/n:+t==+n:+n!=+n;case`[object Date]`:case`[object Boolean]`:return+t==+n;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(t)===Symbol.valueOf.call(n);case`[object Map]`:case`[object Set]`:r>=0&&r++}t=Qt(t),n=Qt(n);var l=c===`[object Array]`;if(!l){if(typeof t!=`object`||typeof n!=`object`)return!1;var u=t.constructor,d=n.constructor;if(u!==d&&!(a(u)&&u instanceof u&&a(d)&&d instanceof d)&&`constructor`in t&&`constructor`in n)return!1}if(r===0)return!1;r<0&&(r=-1),o||=[];for(var f=(i||=[]).length;f--;)if(i[f]===t)return o[f]===n;if(i.push(t),o.push(n),l){if((f=t.length)!==n.length)return!1;for(;f--;)if(!e(t[f],n[f],r-1,i,o))return!1}else{var p=Object.keys(t),m=p.length;if(Object.keys(n).length!==m)return!1;for(var h=0;h<m;h++){var _=p[h];if(!g(n,_)||!e(t[_],n[_],r-1,i,o))return!1}}return i.pop(),o.pop(),!0}(e,t,n)}function Qt(e){return Rt(e)?e.slice():p(e)||gr(e)||m(e)||yr(e)?Array.from(e.entries()):e}function $t(e){return e[Symbol.iterator]=en,Object.assign(Object.create(kr),e)}function en(){return this}Object.defineProperty(e,`__esModule`,{value:!0});var tn={},P=Object.assign,nn=Object.getOwnPropertyDescriptor,rn=Object.defineProperty,an=Object.prototype,on=[];Object.freeze(on);var sn={};Object.freeze(sn);var cn=typeof Proxy<`u`,ln=Object.toString(),F=function(){},un=Object.getOwnPropertySymbols!==void 0,dn=typeof Reflect<`u`&&Reflect.ownKeys?Reflect.ownKeys:un?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,fn=Object.getOwnPropertyDescriptors||function(e){var t={};return dn(e).forEach((function(n){t[n]=nn(e,n)})),t},pn=Symbol(`mobx-stored-annotations`),I=Symbol(`mobx administration`),mn=function(){function e(e){e===void 0&&(e=`Atom`),this.tt=void 0,this.bt=0,this.F=new Set,this.$=0,this.U=R.P,this.onBOL=void 0,this.onBUOL=void 0,this.tt=e}var t=e.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach((function(e){return e()}))},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach((function(e){return e()}))},t.reportObserved=function(){return et(this)},t.reportChanged=function(){Qe(),tt(this),$e()},t.toString=function(){return this.tt},S(e,[{key:`isBeingObserved`,get:function(){return _(this.bt,e.pt)},set:function(t){this.bt=v(this.bt,e.pt,t)}},{key:`isPendingUnobservation`,get:function(){return _(this.bt,e.yt)},set:function(t){this.bt=v(this.bt,e.yt,t)}},{key:`diffValue`,get:function(){return+!!_(this.bt,e.wt)},set:function(t){this.bt=v(this.bt,e.wt,t===1)}}])}();mn.pt=1,mn.yt=2,mn.wt=4;var hn=f(`Atom`,mn),gn={identity:function(e,t){return e===t},structural:function(e,t){return Zt(e,t)},default:function(e,t){return Object.is?Object.is(e,t):e===t?e!==0||1/e==1/t:e!=e&&t!=t},shallow:function(e,t){return Zt(e,t,1)}},_n=D({i:`override`,o:function(){return 0},s:function(){t(`'`+this.i+`' can only be used with 'makeObservable'`)},t:function(){console.warn(`'`+this.i+`' cannot be used with decorators - this is a no-op`)}}),vn=Ee(),yn={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(yn);var bn=Se(`observable`),xn=Se(`observable.ref`,{enhancer:ce}),L=Se(`observable.shallow`,{enhancer:function(e,t,n){return e==null||N(e)||Rt(e)||gr(e)||yr(e)?e:Array.isArray(e)?Tn.array(e,{name:n,deep:!1}):c(e)?Tn.object(e,void 0,{name:n,deep:!1}):p(e)?Tn.map(e,{name:n,deep:!1}):m(e)?Tn.set(e,{name:n,deep:!1}):void 0}}),Sn=Se(`observable.struct`,{enhancer:function(e,t){return Zt(e,t)?t:e}}),Cn=D(bn);P(je,Cn);var wn,Tn=P(je,{box:function(e,t){var n=Ae(t);return new Nn(e,k(n),n.name,!0,n.equals)},array:function(e,t){var n=Ae(t);return(!1===z.useProxies||!1===n.proxy?Kt:Ft)(e,k(n),n.name)},map:function(e,t){var n=Ae(t);return new hr(e,k(n),n.name)},set:function(e,t){var n=Ae(t);return new vr(e,k(n),n.name)},object:function(e,t,n){return Xt((function(){return pt(!1===z.useProxies||!1===n?.proxy?Bt({},n):function(e,t){var n;return r(),(n=(e=Bt(e,t))[I]).v??(n.v=new Proxy(e,ir))}({},n),e,t)}))},ref:D(xn),shallow:D(L),deep:Cn,struct:D(Sn)}),En=ve(`computed`),Dn=ve(`computed.struct`,{equals:gn.structural}),On=function(e,t){if(ae(t))return En.t(e,t);if(o(t))return ie(e,t,En);if(c(e))return D(ve(`computed`,e));var n=c(t)?t:{};return n.get=e,n.name||=e.name||``,new Fn(n)};Object.assign(On,En),On.struct=D(Dn);var kn=0,An=1,jn=(wn=nn((function(){}),`name`)?.configurable)!=null&&wn,Mn={value:`action`,configurable:!0,writable:!1,enumerable:!1},Nn=function(e){function t(t,n,r,i,a){var o;return r===void 0&&(r=`ObservableValue`),a===void 0&&(a=gn.default),(o=e.call(this,r)||this).enhancer=void 0,o.tt=void 0,o.equals=void 0,o.jt=!1,o.et=void 0,o.ut=void 0,o.Ot=void 0,o.dehancer=void 0,o.enhancer=n,o.tt=r,o.equals=a,o.Ot=n(t,void 0,r),o}ee(t,e);var n=t.prototype;return n.dehanceValue=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.set=function(e){(e=this.xt(e))!==z.UNCHANGED&&this.gt(e)},n.xt=function(e){if(kt(this)){var t=jt(this,{object:this,type:or,newValue:e});if(!t)return z.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.Ot,this.tt),this.equals(this.Ot,e)?z.UNCHANGED:e},n.gt=function(e){var t=this.Ot;this.Ot=e,this.reportChanged(),Mt(this)&&Pt(this,{type:or,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.Ot)},n.St=function(e){return At(this,e)},n._t=function(e,t){return t&&e({observableKind:`value`,debugObjectName:this.tt,object:this,type:or,newValue:this.Ot,oldValue:void 0}),Nt(this,e)},n.raw=function(){return this.Ot},n.toJSON=function(){return this.get()},n.toString=function(){return this.tt+`[`+this.Ot+`]`},n.valueOf=function(){return h(this.get())},n[Symbol.toPrimitive]=function(){return this.valueOf()},t}(mn),Pn=f(`ObservableValue`,Nn),Fn=function(){function e(e){this.I=R.P,this.D=[],this.W=null,this.F=new Set,this.q=0,this.$=0,this.U=R.L,this.G=0,this.Ot=new Rn(null),this.tt=void 0,this.At=void 0,this.bt=0,this.derivation=void 0,this.kt=void 0,this.Mt=In.NONE,this.Et=void 0,this.Vt=void 0,this.Rt=void 0,this.Nt=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.kt=Me(`ComputedValue-setter`,e.set)),this.Vt=e.equals||(e.compareStructural||e.struct?gn.structural:gn.default),this.Et=e.context,this.Rt=e.requiresReaction,this.Nt=!!e.keepAlive}var n=e.prototype;return n.H=function(){(function(e){e.U===R.L&&(e.U=R.B,e.F.forEach((function(e){e.I===R.L&&(e.I=R.B,e.H())})))})(this)},n.onBO=function(){this.onBOL&&this.onBOL.forEach((function(e){return e()}))},n.onBUO=function(){this.onBUOL&&this.onBUOL.forEach((function(e){return e()}))},n.get=function(){if(this.isComputing&&t(32,this.tt,this.derivation),z.inBatch!==0||this.F.size!==0||this.Nt){if(et(this),Be(this)){var e=z.trackingContext;this.Nt&&!e&&(z.trackingContext=this),this.trackAndCompute()&&function(e){e.U!==R.K&&(e.U=R.K,e.F.forEach((function(t){t.I===R.B?t.I=R.K:t.I===R.L&&(e.U=R.L)})))}(this),z.trackingContext=e}}else Be(this)&&(this.Tt(),Qe(),this.Ot=this.Ct(!1),$e());var n=this.Ot;if(ze(n))throw n.cause;return n},n.set=function(e){if(this.kt){this.isRunningSetter&&t(33,this.tt),this.isRunningSetter=!0;try{this.kt.call(this.Et,e)}finally{this.isRunningSetter=!1}}else t(34,this.tt)},n.trackAndCompute=function(){var e=this.Ot,t=this.I===R.P,n=this.Ct(!0),r=t||ze(e)||ze(n)||!this.Vt(e,n);return r&&(this.Ot=n),r},n.Ct=function(e){this.isComputing=!0;var t,n=Le(!1);if(e)t=Ve(this,this.derivation,this.Et);else if(!0===z.disableErrorBoundaries)t=this.derivation.call(this.Et);else try{t=this.derivation.call(this.Et)}catch(e){t=new Rn(e)}return Re(n),this.isComputing=!1,t},n.X=function(){this.Nt||(He(this),this.Ot=void 0)},n._t=function(e,t){var n=this,r=!0,i=void 0;return ct((function(){var a=n.get();if(!r||t){var o=We();e({observableKind:`computed`,debugObjectName:n.tt,type:or,object:n,newValue:a,oldValue:i}),Ge(o)}r=!1,i=a}))},n.Tt=function(){},n.toString=function(){return this.tt+`[`+this.derivation.toString()+`]`},n.valueOf=function(){return h(this.get())},n[Symbol.toPrimitive]=function(){return this.valueOf()},S(e,[{key:`isComputing`,get:function(){return _(this.bt,e.It)},set:function(t){this.bt=v(this.bt,e.It,t)}},{key:`isRunningSetter`,get:function(){return _(this.bt,e.Lt)},set:function(t){this.bt=v(this.bt,e.Lt,t)}},{key:`isBeingObserved`,get:function(){return _(this.bt,e.pt)},set:function(t){this.bt=v(this.bt,e.pt,t)}},{key:`isPendingUnobservation`,get:function(){return _(this.bt,e.yt)},set:function(t){this.bt=v(this.bt,e.yt,t)}},{key:`diffValue`,get:function(){return+!!_(this.bt,e.wt)},set:function(t){this.bt=v(this.bt,e.wt,t===1)}}])}();Fn.It=1,Fn.Lt=2,Fn.pt=4,Fn.yt=8,Fn.wt=16;var R,In,Ln=f(`ComputedValue`,Fn);(function(e){e[e.P=-1]=`NOT_TRACKING_`,e[e.L=0]=`UP_TO_DATE_`,e[e.B=1]=`POSSIBLY_STALE_`,e[e.K=2]=`STALE_`})(R||={}),function(e){e[e.NONE=0]=`NONE`,e[e.LOG=1]=`LOG`,e[e.BREAK=2]=`BREAK`}(In||={});var Rn=function(e){this.cause=void 0,this.cause=e},zn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`,`useProxies`],Bn=function(){this.version=6,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.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.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},Vn=!0,Hn=!1,z=function(){var e=n();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Vn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==new Bn().version&&(Vn=!1),Vn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Bn):(setTimeout((function(){Hn||t(35)}),1),new Bn)}(),Un=function(){function e(e,t,n,r){e===void 0&&(e=`Reaction`),this.tt=void 0,this.Pt=void 0,this.Kt=void 0,this.Bt=void 0,this.D=[],this.W=[],this.I=R.P,this.q=0,this.G=0,this.bt=0,this.Mt=In.NONE,this.tt=e,this.Pt=t,this.Kt=n,this.Bt=r}var t=e.prototype;return t.H=function(){this.Y()},t.Y=function(){this.isScheduled||(this.isScheduled=!0,z.pendingReactions.push(this),nt())},t.J=function(){if(!this.isDisposed){Qe(),this.isScheduled=!1;var e=z.trackingContext;if(z.trackingContext=this,Be(this)){this.isTrackPending=!0;try{this.Pt()}catch(e){this.Dt(e)}}z.trackingContext=e,$e()}},t.track=function(e){if(!this.isDisposed){Qe(),this.isRunning=!0;var t=z.trackingContext;z.trackingContext=this;var n=Ve(this,e,void 0);z.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&He(this),ze(n)&&this.Dt(n.cause),$e()}},t.Dt=function(e){var t=this;if(this.Kt)this.Kt(e,this);else{if(z.disableErrorBoundaries)throw e;z.suppressReactionErrors||console.error(`[mobx] uncaught error in '`+this+`'`,e),z.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},t.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||(Qe(),He(this),$e()))},t.Z=function(e){var t=this,n=function n(){t.dispose(),e==null||e.removeEventListener==null||e.removeEventListener(`abort`,n)};return e==null||e.addEventListener==null||e.addEventListener(`abort`,n),n[I]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(n[Symbol.dispose]=n),n},t.toString=function(){return`Reaction[`+this.tt+`]`},t.trace=function(){},S(e,[{key:`isDisposed`,get:function(){return _(this.bt,e.Wt)},set:function(t){this.bt=v(this.bt,e.Wt,t)}},{key:`isScheduled`,get:function(){return _(this.bt,e.qt)},set:function(t){this.bt=v(this.bt,e.qt,t)}},{key:`isTrackPending`,get:function(){return _(this.bt,e.Gt)},set:function(t){this.bt=v(this.bt,e.Gt,t)}},{key:`isRunning`,get:function(){return _(this.bt,e.Ht)},set:function(t){this.bt=v(this.bt,e.Ht,t)}},{key:`diffValue`,get:function(){return+!!_(this.bt,e.wt)},set:function(t){this.bt=v(this.bt,e.wt,t===1)}}])}();Un.Wt=1,Un.qt=2,Un.Gt=4,Un.Ht=8,Un.wt=16;var Wn=function(e){return e()},Gn=f(`Reaction`,Un),Kn=le(`action`),qn=le(`action.bound`,{bound:!0}),Jn=le(`autoAction`,{autoAction:!0}),Yn=le(`autoAction.bound`,{autoAction:!0,bound:!0}),Xn=at(!1);Object.assign(Xn,Kn);var Zn=at(!0);Object.assign(Zn,Jn),Xn.bound=D(qn),Zn.bound=D(Yn);var Qn=function(e){return e()},$n=0,er=function(e){function t(){var n;return n=e.call(this,`FLOW_CANCELLED`)||this,Object.setPrototypeOf(n,(this instanceof t?this.constructor:void 0).prototype),n.name=`FlowCancellationError`,n}return ee(t,e),t.prototype.toString=function(){return`Error: `+this.message},t}(E(Error)),tr=me(`flow`),nr=me(`flow.bound`,{bound:!0}),rr=Object.assign((function(e,t){if(ae(t))return tr.t(e,t);if(o(t))return ie(e,t,tr);var n=e,r=n.name||`<unnamed flow>`,i=function(){var e,t=this,i=arguments,o=++$n,s=Xn(r+` - runid: `+o+` - init`,n).apply(t,i),c=void 0,l=new Promise((function(t,n){function i(e){var t;c=void 0;try{t=Xn(r+` - runid: `+o+` - yield `+ d++,s.next).call(s,e)}catch(e){return n(e)}u(t)}function l(e){var t;c=void 0;try{t=Xn(r+` - runid: `+o+` - yield `+ d++,s.throw).call(s,e)}catch(e){return n(e)}u(t)}function u(e){if(!a(e?.then))return e.done?t(e.value):(c=Promise.resolve(e.value)).then(i,l);e.then(u,n)}var d=0;e=n,i(void 0)}));return l.cancel=Xn(r+` - runid: `+o+` - cancel`,(function(){try{c&&gt(c);var t=s.return(void 0),n=Promise.resolve(t.value);n.then(F,F),gt(n),e(new er)}catch(t){e(t)}})),l};return i.isMobXFlow=!0,i}),tr);rr.bound=D(nr);var ir={has:function(e,t){return Ot(e).it(t)},get:function(e,t){return Ot(e).ct(t)},set:function(e,t,n){var r;return!!o(t)&&((r=Ot(e).ht(t,n,!0))==null||r)},deleteProperty:function(e,t){var n;return!!o(t)&&((n=Ot(e).Ut(t,!0))==null||n)},defineProperty:function(e,t,n){var r;return(r=Ot(e).l(t,n))==null||r},ownKeys:function(e){return Ot(e).rt()},preventExtensions:function(){t(13)}},ar=Symbol(`mobx-keys`),or=`update`,sr={get:function(e,t){var n=e[I];return t===I?n:t===`length`?n.Ft():typeof t!=`string`||isNaN(t)?g(lr,t)?lr[t]:e[t]:n.ct(parseInt(t))},set:function(e,t,n){var r=e[I];return t===`length`&&r.Xt(n),typeof t==`symbol`||isNaN(t)?e[t]=n:r.ht(parseInt(t),n),!0},preventExtensions:function(){t(15)}},cr=function(){function e(e,t,n,r){e===void 0&&(e=`ObservableArray`),this.zt=void 0,this.$t=void 0,this.st=void 0,this.j=[],this.et=void 0,this.ut=void 0,this.Jt=void 0,this.dehancer=void 0,this.v=void 0,this.Yt=0,this.zt=n,this.$t=r,this.st=new mn(e),this.Jt=function(e,n){return t(e,n,`ObservableArray[..]`)}}var n=e.prototype;return n.Qt=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.ft=function(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e},n.St=function(e){return At(this,e)},n._t=function(e,t){return t===void 0&&(t=!1),t&&e({observableKind:`array`,object:this.v,debugObjectName:this.st.tt,type:`splice`,index:0,added:this.j.slice(),addedCount:this.j.length,removed:[],removedCount:0}),Nt(this,e)},n.Ft=function(){return this.st.reportObserved(),this.j.length},n.Xt=function(e){(typeof e!=`number`||isNaN(e)||e<0)&&t(`Out of range: `+e);var n=this.j.length;if(e!==n)if(e>n){for(var r=Array(e-n),i=0;i<e-n;i++)r[i]=void 0;this.ot(n,0,r)}else this.ot(e,n-e)},n.Zt=function(e,n){e!==this.Yt&&t(16),this.Yt+=n,this.$t&&n>0&&Gt(e+n+1)},n.ot=function(e,t,n){var r=this,i=this.j.length;if(e===void 0?e=0:e>i?e=i:e<0&&(e=Math.max(0,i+e)),t=arguments.length===1?i-e:t==null?0:Math.max(0,Math.min(t,i-e)),n===void 0&&(n=on),kt(this)){var a=jt(this,{object:this.v,type:`splice`,index:e,removedCount:t,added:n});if(!a)return on;t=a.removedCount,n=a.added}if(n=n.length===0?n:n.map((function(e){return r.Jt(e,void 0)})),this.$t){var o=n.length-t;this.Zt(i,o)}var s=this.tn(e,t,n);return t===0&&n.length===0||this.nn(e,n,s),this.ft(s)},n.tn=function(e,t,n){var r;if(n.length<1e4)return(r=this.j).splice.apply(r,[e,t].concat(n));var i=this.j.slice(e,e+t),a=this.j.slice(e+t);this.j.length+=n.length-t;for(var o=0;o<n.length;o++)this.j[e+o]=n[o];for(var s=0;s<a.length;s++)this.j[e+n.length+s]=a[s];return i},n.in=function(e,t,n){var r=!this.zt&&!1,i=Mt(this),a=i||r?{observableKind:`array`,object:this.v,type:or,debugObjectName:this.st.tt,index:e,newValue:t,oldValue:n}:null;this.st.reportChanged(),i&&Pt(this,a)},n.nn=function(e,t,n){var r=!this.zt&&!1,i=Mt(this),a=i||r?{observableKind:`array`,object:this.v,debugObjectName:this.st.tt,type:`splice`,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.st.reportChanged(),i&&Pt(this,a)},n.ct=function(e){if(!(this.$t&&e>=this.j.length))return this.st.reportObserved(),this.Qt(this.j[e]);console.warn(`[mobx] Out of bounds read: `+e)},n.ht=function(e,n){var r=this.j;if(this.$t&&e>r.length&&t(17,e,r.length),e<r.length){var i=r[e];if(kt(this)){var a=jt(this,{type:or,object:this.v,index:e,newValue:n});if(!a)return;n=a.newValue}(n=this.Jt(n,i))!==i&&(r[e]=n,this.in(e,n,i))}else{for(var o=Array(e+1-r.length),s=0;s<o.length-1;s++)o[s]=void 0;o[o.length-1]=n,this.ot(r.length,0,o)}},e}(),lr={clear:function(){return this.splice(0)},replace:function(e){var t=this[I];return t.ot(0,t.j.length,e)},toJSON:function(){return this.slice()},splice:function(e,t){var n=[...arguments].slice(2),r=this[I];switch(arguments.length){case 0:return[];case 1:return r.ot(e);case 2:return r.ot(e,t)}return r.ot(e,t,n)},spliceWithArray:function(e,t,n){return this[I].ot(e,t,n)},push:function(){for(var e=this[I],t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.ot(e.j.length,0,n),e.j.length},pop:function(){return this.splice(Math.max(this[I].j.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){for(var e=this[I],t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.ot(0,0,n),e.j.length},reverse:function(){return z.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort:function(){z.trackingDerivation&&t(37,`sort`);var e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove:function(e){var t=this[I],n=t.ft(t.j).indexOf(e);return n>-1&&(this.splice(n,1),!0)}};A(`at`,It),A(`concat`,It),A(`flat`,It),A(`includes`,It),A(`indexOf`,It),A(`join`,It),A(`lastIndexOf`,It),A(`slice`,It),A(`toString`,It),A(`toLocaleString`,It),A(`toSorted`,It),A(`toSpliced`,It),A(`with`,It),A(`every`,j),A(`filter`,j),A(`find`,j),A(`findIndex`,j),A(`findLast`,j),A(`findLastIndex`,j),A(`flatMap`,j),A(`forEach`,j),A(`map`,j),A(`some`,j),A(`toReversed`,j),A(`reduce`,Lt),A(`reduceRight`,Lt);var ur,dr,fr=f(`ObservableArrayAdministration`,cr),pr={},mr=`add`,hr=function(){function e(e,n,r){var i=this;n===void 0&&(n=se),r===void 0&&(r=`ObservableMap`),this.Jt=void 0,this.tt=void 0,this[I]=pr,this.vt=void 0,this.dt=void 0,this.lt=void 0,this.et=void 0,this.ut=void 0,this.dehancer=void 0,this.Jt=n,this.tt=r,a(Map)||t(18),Xt((function(){i.lt=oe(`ObservableMap.keys()`),i.vt=new Map,i.dt=new Map,e&&i.merge(e)}))}var n=e.prototype;return n.it=function(e){return this.vt.has(e)},n.has=function(e){var t=this;if(!z.trackingDerivation)return this.it(e);var n=this.dt.get(e);if(!n){var r=n=new Nn(this.it(e),ce,`ObservableMap.key?`,!1);this.dt.set(e,r),dt(r,(function(){return t.dt.delete(e)}))}return n.get()},n.set=function(e,t){var n=this.it(e);if(kt(this)){var r=jt(this,{type:n?or:mr,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.rn(e,t):this.en(e,t),this},n.delete=function(e){var t=this;if(kt(this)&&!jt(this,{type:`delete`,object:this,name:e}))return!1;if(this.it(e)){var n=Mt(this),r=n?{observableKind:`map`,debugObjectName:this.tt,type:`delete`,object:this,oldValue:this.vt.get(e).Ot,name:e}:null;return Tt((function(){var n;t.lt.reportChanged(),(n=t.dt.get(e))==null||n.gt(!1),t.vt.get(e).gt(void 0),t.vt.delete(e)})),n&&Pt(this,r),!0}return!1},n.rn=function(e,t){var n=this.vt.get(e);if((t=n.xt(t))!==z.UNCHANGED){var r=Mt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:or,object:this,oldValue:n.Ot,name:e,newValue:t}:null;n.gt(t),r&&Pt(this,i)}},n.en=function(e,t){var n=this;Tt((function(){var r,i=new Nn(t,n.Jt,`ObservableMap.key`,!1);n.vt.set(e,i),t=i.Ot,(r=n.dt.get(e))==null||r.gt(!0),n.lt.reportChanged()}));var r=Mt(this);r&&Pt(this,r?{observableKind:`map`,debugObjectName:this.tt,type:mr,object:this,name:e,newValue:t}:null)},n.get=function(e){return this.has(e)?this.Qt(this.vt.get(e).get()):this.Qt(void 0)},n.Qt=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.keys=function(){return this.lt.reportObserved(),this.vt.keys()},n.values=function(){var e=this,t=this.keys();return zt({next:function(){var n=t.next(),r=n.done;return{done:r,value:r?void 0:e.get(n.value)}}})},n.entries=function(){var e=this,t=this.keys();return zt({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},n[Symbol.iterator]=function(){return this.entries()},n.forEach=function(e,t){for(var n,r=C(this);!(n=r()).done;){var i=n.value;e.call(t,i[1],i[0],this)}},n.merge=function(e){var n=this;return gr(e)&&(e=new Map(e)),Tt((function(){var r,i;c(e)?function(e){var t=Object.keys(e);if(!un)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter((function(t){return an.propertyIsEnumerable.call(e,t)}))):t}(e).forEach((function(t){return n.set(t,e[t])})):Array.isArray(e)?e.forEach((function(e){return n.set(e[0],e[1])})):p(e)?(r=Object.getPrototypeOf(e),i=Object.getPrototypeOf(r),Object.getPrototypeOf(i)!==null&&t(19,e),e.forEach((function(e,t){return n.set(t,e)}))):e!=null&&t(20,e)})),this},n.clear=function(){var e=this;Tt((function(){Ue((function(){for(var t,n=C(e.keys());!(t=n()).done;)e.delete(t.value)}))}))},n.replace=function(e){var n=this;return Tt((function(){for(var r,i=function(e){if(p(e)||gr(e))return e;if(Array.isArray(e))return new Map(e);if(c(e)){var n=new Map;for(var r in e)n.set(r,e[r]);return n}return t(21,e)}(e),a=new Map,o=!1,s=C(n.vt.keys());!(r=s()).done;){var l=r.value;if(!i.has(l))if(n.delete(l))o=!0;else{var u=n.vt.get(l);a.set(l,u)}}for(var d,f=C(i.entries());!(d=f()).done;){var m=d.value,h=m[0],g=m[1],_=n.vt.has(h);if(n.set(h,g),n.vt.has(h)){var v=n.vt.get(h);a.set(h,v),_||(o=!0)}}if(!o)if(n.vt.size!==a.size)n.lt.reportChanged();else for(var y=n.vt.keys(),b=a.keys(),x=y.next(),S=b.next();!x.done;){if(x.value!==S.value){n.lt.reportChanged();break}x=y.next(),S=b.next()}n.vt=a})),this},n.toString=function(){return`[object ObservableMap]`},n.toJSON=function(){return Array.from(this)},n._t=function(e){return Nt(this,e)},n.St=function(e){return At(this,e)},S(e,[{key:`size`,get:function(){return this.lt.reportObserved(),this.vt.size}},{key:Symbol.toStringTag,get:function(){return`Map`}}])}(),gr=f(`ObservableMap`,hr),_r={},vr=function(){function e(e,n,r){var i=this;n===void 0&&(n=se),r===void 0&&(r=`ObservableSet`),this.tt=void 0,this[I]=_r,this.vt=new Set,this.st=void 0,this.ut=void 0,this.et=void 0,this.dehancer=void 0,this.Jt=void 0,this.tt=r,a(Set)||t(22),this.Jt=function(e,t){return n(e,t,r)},Xt((function(){i.st=oe(i.tt),e&&i.replace(e)}))}var n=e.prototype;return n.Qt=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.clear=function(){var e=this;Tt((function(){Ue((function(){for(var t,n=C(e.vt.values());!(t=n()).done;)e.delete(t.value)}))}))},n.forEach=function(e,t){for(var n,r=C(this);!(n=r()).done;){var i=n.value;e.call(t,i,i,this)}},n.add=function(e){var t=this;if(kt(this)){var n=jt(this,{type:mr,object:this,newValue:e});if(!n)return this;e=n.newValue}if(!this.has(e)){Tt((function(){t.vt.add(t.Jt(e,void 0)),t.st.reportChanged()}));var r=Mt(this);r&&Pt(this,r?{observableKind:`set`,debugObjectName:this.tt,type:mr,object:this,newValue:e}:null)}return this},n.delete=function(e){var t=this;if(kt(this)&&!jt(this,{type:`delete`,object:this,oldValue:e}))return!1;if(this.has(e)){var n=Mt(this),r=n?{observableKind:`set`,debugObjectName:this.tt,type:`delete`,object:this,oldValue:e}:null;return Tt((function(){t.st.reportChanged(),t.vt.delete(e)})),n&&Pt(this,r),!0}return!1},n.has=function(e){return this.st.reportObserved(),this.vt.has(this.Qt(e))},n.entries=function(){var e=this.values();return M({next:function(){var t=e.next(),n=t.value,r=t.done;return r?{value:void 0,done:r}:{value:[n,n],done:r}}})},n.keys=function(){return this.values()},n.values=function(){this.st.reportObserved();var e=this,t=this.vt.values();return M({next:function(){var n=t.next(),r=n.done;return r?{value:void 0,done:r}:{value:e.Qt(n.value),done:r}}})},n.intersection=function(e){return m(e)&&!yr(e)?e.intersection(this):new Set(this).intersection(e)},n.union=function(e){return m(e)&&!yr(e)?e.union(this):new Set(this).union(e)},n.difference=function(e){return new Set(this).difference(e)},n.symmetricDifference=function(e){return m(e)&&!yr(e)?e.symmetricDifference(this):new Set(this).symmetricDifference(e)},n.isSubsetOf=function(e){return new Set(this).isSubsetOf(e)},n.isSupersetOf=function(e){return new Set(this).isSupersetOf(e)},n.isDisjointFrom=function(e){return m(e)&&!yr(e)?e.isDisjointFrom(this):new Set(this).isDisjointFrom(e)},n.replace=function(e){var n=this;return yr(e)&&(e=new Set(e)),Tt((function(){Array.isArray(e)||m(e)?(n.clear(),e.forEach((function(e){return n.add(e)}))):e!=null&&t(`Cannot initialize set from `+e)})),this},n._t=function(e){return Nt(this,e)},n.St=function(e){return At(this,e)},n.toJSON=function(){return Array.from(this)},n.toString=function(){return`[object ObservableSet]`},n[Symbol.iterator]=function(){return this.values()},S(e,[{key:`size`,get:function(){return this.st.reportObserved(),this.vt.size}},{key:Symbol.toStringTag,get:function(){return`Set`}}])}(),yr=f(`ObservableSet`,vr),br=Object.create(null),xr=function(){function e(e,t,n,r){t===void 0&&(t=new Map),r===void 0&&(r=vn),this.h=void 0,this.j=void 0,this.tt=void 0,this.un=void 0,this.lt=void 0,this.ut=void 0,this.et=void 0,this.v=void 0,this.p=void 0,this.on=void 0,this.sn=void 0,this.h=e,this.j=t,this.tt=n,this.un=r,this.lt=new mn(`ObservableObject.keys`),this.p=c(this.h)}var n=e.prototype;return n.O=function(e){return this.j.get(e).get()},n.S=function(e,t){var n=this.j.get(e);if(n instanceof Fn)return n.set(t),!0;if(kt(this)){var r=jt(this,{type:or,object:this.v||this.h,name:e,newValue:t});if(!r)return null;t=r.newValue}if((t=n.xt(t))!==z.UNCHANGED){var i=Mt(this),a=i?{type:or,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.Ot,name:e,newValue:t}:null;n.gt(t),i&&Pt(this,a)}return!0},n.ct=function(e){return z.trackingDerivation&&!g(this.h,e)&&this.it(e),this.h[e]},n.ht=function(e,t,n){return n===void 0&&(n=!1),g(this.h,e)?this.j.has(e)?this.S(e,t):n?Reflect.set(this.h,e,t):(this.h[e]=t,!0):this.s(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.un,n)},n.it=function(e){if(!z.trackingDerivation)return e in this.h;this.sn||=new Map;var t=this.sn.get(e);return t||(t=new Nn(e in this.h,ce,`ObservableObject.key?`,!1),this.sn.set(e,t)),t.get()},n.o=function(e,n){if(!0===n&&(n=this.un),!1!==n){if(!(e in this.h)){var r;if((r=this.h[pn])!=null&&r[e])return;t(1,n.i,this.tt+`.`+e.toString())}for(var i=this.h;i&&i!==an;){var a=nn(i,e);if(a){var o=n.o(this,e,a,i);if(o===0)return;if(o===1)break}i=Object.getPrototypeOf(i)}Ht(this,0,e)}},n.s=function(e,t,n,r){if(r===void 0&&(r=!1),!0===n&&(n=this.un),!1===n)return this.l(e,t,r);var i=n.s(this,e,t,r);return i&&Ht(this,0,e),i},n.l=function(e,t,n){n===void 0&&(n=!1);try{Qe();var r=this.Ut(e);if(!r)return r;if(kt(this)){var i=jt(this,{object:this.v||this.h,name:e,type:mr,newValue:t.value});if(!i)return null;var a=i.newValue;t.value!==a&&(t=w({},t,{value:a}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else rn(this.h,e,t);this.fn(e,t.value)}finally{$e()}return!0},n.g=function(e,t,n,r){r===void 0&&(r=!1);try{Qe();var i=this.Ut(e);if(!i)return i;if(kt(this)){var a=jt(this,{object:this.v||this.h,name:e,type:mr,newValue:t});if(!a)return null;t=a.newValue}var o=Vt(e),s={configurable:!z.safeDescriptors||this.p,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.h,e,s))return!1}else rn(this.h,e,s);var c=new Nn(t,n,`ObservableObject.key`,!1);this.j.set(e,c),this.fn(e,c.Ot)}finally{$e()}return!0},n.m=function(e,t,n){n===void 0&&(n=!1);try{Qe();var r=this.Ut(e);if(!r)return r;if(kt(this)&&!jt(this,{object:this.v||this.h,name:e,type:mr,newValue:void 0}))return null;t.name||=`ObservableObject.key`,t.context=this.v||this.h;var i=Vt(e),a={configurable:!z.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else rn(this.h,e,a);this.j.set(e,new Fn(t)),this.fn(e,void 0)}finally{$e()}return!0},n.Ut=function(e,t){if(t===void 0&&(t=!1),!g(this.h,e))return!0;if(kt(this)&&!jt(this,{object:this.v||this.h,name:e,type:`remove`}))return null;try{var n;Qe();var r=Mt(this),i=this.j.get(e),a=void 0;if(!i&&r&&(a=nn(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 Nn&&(a=i.Ot),tt(i)),this.lt.reportChanged(),(n=this.sn)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&Pt(this,{type:`remove`,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{$e()}return!0},n._t=function(e){return Nt(this,e)},n.St=function(e){return At(this,e)},n.fn=function(e,t){var n,r=Mt(this);r&&r&&Pt(this,r?{type:mr,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,name:e,newValue:t}:null),(n=this.sn)==null||(n=n.get(e))==null||n.set(!0),this.lt.reportChanged()},n.rt=function(){return this.lt.reportObserved(),dn(this.h)},n.nt=function(){return this.lt.reportObserved(),Object.keys(this.h)},e}(),Sr=f(`ObservableObjectAdministration`,xr),Cr=Ut(0),wr=function(){var e=!1,t={};return Object.defineProperty(t,`0`,{set:function(){e=!0}}),Object.create(t)[0]=1,!1===e}(),Tr=0,Er=function(){};ur=Er,dr=Array.prototype,Object.setPrototypeOf?Object.setPrototypeOf(ur.prototype,dr):ur.prototype.__proto__===void 0?ur.prototype=dr:ur.prototype.__proto__=dr;var Dr=function(e){function t(t,n,r,i){var a;return r===void 0&&(r=`ObservableArray`),i===void 0&&(i=!1),a=e.call(this)||this,Xt((function(){var e=new cr(r,n,i,!0);e.v=a,d(a,I,e),t&&t.length&&a.spliceWithArray(0,0,t),wr&&Object.defineProperty(a,`0`,Cr)})),a}ee(t,e);var n=t.prototype;return n.concat=function(){this[I].st.reportObserved();var e=[...arguments];return Array.prototype.concat.apply(this.slice(),e.map((function(e){return Rt(e)?e.slice():e})))},n[Symbol.iterator]=function(){var e=this,t=0;return $t({next:function(){return t<e.length?{value:e[t++],done:!1}:{done:!0,value:void 0}}})},S(t,[{key:`length`,get:function(){return this[I].Ft()},set:function(e){this[I].Xt(e)}},{key:Symbol.toStringTag,get:function(){return`Array`}}])}(Er);Object.entries(lr).forEach((function(e){var t=e[0];t!==`concat`&&u(Dr.prototype,t,e[1])})),Gt(1e3);var Or=an.toString,kr=n().Iterator?.prototype||{};[`Symbol`,`Map`,`Set`].forEach((function(e){n()[e]===void 0&&t(`MobX requires global '`+e+`' to be available or polyfilled`)})),typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__==`object`&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:it,extras:{getDebugName:Yt},$mobx:I}),e.$mobx=I,e.FlowCancellationError=er,e.ObservableMap=hr,e.ObservableSet=vr,e.Reaction=Un,e._allowStateChanges=Ie,e._allowStateChangesInsideComputed=ot,e._allowStateReadsEnd=qe,e._allowStateReadsStart=Ke,e._autoAction=Zn,e._endAction=Fe,e._getAdministration=Jt,e._getGlobalState=function(){return z},e._interceptReads=function(e,t,n){var r;return gr(e)||Rt(e)||Pn(e)?r=Jt(e):N(e)&&(r=Jt(e,t)),r.dehancer=typeof t==`function`?t:n,function(){r.dehancer=void 0}},e._isComputingDerivation=function(){return z.trackingDerivation!==null},e._resetGlobalState=function(){var e=new Bn;for(var t in e)zn.indexOf(t)===-1&&(z[t]=e[t]);z.allowStateChanges=!z.enforceActions},e._startAction=Pe,e.action=Xn,e.autorun=ct,e.comparer=gn,e.computed=On,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((z.pendingReactions.length||z.inBatch||z.isRunningReactions)&&t(36),Hn=!0,Vn){var e=n();--e.__mobxInstanceCount==0&&(e.__mobxGlobals=void 0),z=new Bn}}();var r,i,a=e.useProxies,o=e.enforceActions;if(a!==void 0&&(z.useProxies=a===`always`||a!==`never`&&typeof Proxy<`u`),a===`ifavailable`&&(z.verifyProxies=!0),o!==void 0){var s=o===`always`?`always`:o===`observed`;z.enforceActions=s,z.allowStateChanges=!0!==s&&s!==`always`}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach((function(t){t in e&&(z[t]=!!e[t])})),z.allowStateReads=!z.observableRequiresReaction,e.reactionScheduler&&(r=e.reactionScheduler,i=Wn,Wn=function(e){return r((function(){return i(e)}))})},e.createAtom=oe,e.defineProperty=function(e,n,r){if(N(e))return e[I].l(n,r);t(39)},e.entries=function(e){return N(e)?xt(e).map((function(t){return[t,e[t]]})):gr(e)?xt(e).map((function(t){return[t,e.get(t)]})):yr(e)?Array.from(e.entries()):Rt(e)?e.map((function(e,t){return[t,e]})):void t(7)},e.extendObservable=pt,e.flow=rr,e.flowResult=function(e){return e},e.get=function(e,n){if(St(e,n))return N(e)?e[I].ct(n):gr(e)?e.get(n):Rt(e)?e[n]:void t(11)},e.getAtom=qt,e.getDebugName=Yt,e.getDependencyTree=function(e,t){return mt(qt(e,t))},e.getObserverTree=function(e,t){return ht(qt(e,t))},e.has=St,e.intercept=function(e,t,n){return a(n)?function(e,t,n){return Jt(e,t).St(n)}(e,t,n):function(e,t){return Jt(e).St(t)}(e,t)},e.isAction=st,e.isBoxedObservable=Pn,e.isComputed=function(e){return vt(e)},e.isComputedProp=function(e,t){return vt(e,t)},e.isFlow=_t,e.isFlowCancellationError=function(e){return e instanceof er},e.isObservable=bt,e.isObservableArray=Rt,e.isObservableMap=gr,e.isObservableObject=N,e.isObservableProp=function(e,t){return yt(e,t)},e.isObservableSet=yr,e.keys=xt,e.makeAutoObservable=function(e,t,n){return c(e)?pt(e,e,t,n):(Xt((function(){var r=Bt(e,n)[I];if(!e[ar]){var i=Object.getPrototypeOf(e),a=new Set([].concat(dn(e),dn(i)));a.delete(`constructor`),a.delete(I),u(i,ar,a)}e[ar].forEach((function(e){return r.o(e,!t||!(e in t)||t[e])}))})),e)},e.makeObservable=function(e,t,n){return Xt((function(){var r=Bt(e,n)[I];t??=function(e){return g(e,pn)||u(e,pn,w({},e[pn])),e[pn]}(e),dn(t).forEach((function(e){return r.o(e,t[e])}))})),e},e.observable=Tn,e.observe=function(e,t,n,r){return a(n)?function(e,t,n,r){return Jt(e,t)._t(n,r)}(e,t,n,r):function(e,t,n){return Jt(e)._t(t,n)}(e,t,n)},e.onBecomeObserved=ut,e.onBecomeUnobserved=dt,e.onReactionError=function(e){return z.globalReactionErrorHandlers.push(e),function(){var t=z.globalReactionErrorHandlers.indexOf(e);t>=0&&z.globalReactionErrorHandlers.splice(t,1)}},e.override=_n,e.ownKeys=Ct,e.reaction=function(e,t,n){function r(){if(p=!1,!h.isDisposed){var t=!1,r=s;h.track((function(){var n=Ie(!1,(function(){return e(h)}));t=f||!m(s,n),s=n})),(f&&n.fireImmediately||!f&&t)&&l(s,r,h),f=!1}}var i;n===void 0&&(n=sn);var a,o,s,c=n.name??`Reaction`,l=Xn(c,n.onError?(a=n.onError,o=t,function(){try{return o.apply(this,arguments)}catch(e){a.call(this,e)}}):t),u=!n.scheduler&&!n.delay,d=lt(n),f=!0,p=!1,m=n.compareStructural?gn.structural:n.equals||gn.default,h=new Un(c,(function(){f||u?r():p||(p=!0,d(r))}),n.onError,n.requiresObservable);return(i=n)!=null&&(i=i.signal)!=null&&i.aborted||h.Y(),h.Z(n?.signal)},e.remove=function(e,n){N(e)?e[I].Ut(n):gr(e)||yr(e)?e.delete(n):Rt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=ot,e.set=function e(n,r,i){if(arguments.length!==2||yr(n))N(n)?n[I].ht(r,i):gr(n)?n.set(r,i):yr(n)?n.add(r):Rt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(`Invalid index: '`+r+`'`),Qe(),r>=n.length&&(n.length=r+1),n[r]=i,$e()):t(8);else{Qe();var a=r;try{for(var o in a)e(n,o,a[o])}finally{$e()}}},e.spy=it,e.toJS=function(e){return function e(t,n){if(typeof t!=`object`||!t||t instanceof Date||!bt(t))return t;if(Pn(t)||Ln(t))return e(t.get(),n);if(n.has(t))return n.get(t);if(Rt(t)){var r=wt(n,t,Array(t.length));return t.forEach((function(t,i){r[i]=e(t,n)})),r}if(yr(t)){var i=wt(n,t,new Set);return t.forEach((function(t){i.add(e(t,n))})),i}if(gr(t)){var a=wt(n,t,new Map);return t.forEach((function(t,r){a.set(r,e(t,n))})),a}var o=wt(n,t,{});return Ct(t).forEach((function(r){an.propertyIsEnumerable.call(t,r)&&(o[r]=e(t[r],n))})),o}(e,new Map)},e.trace=function(){},e.transaction=Tt,e.untracked=Ue,e.values=function(e){return N(e)?xt(e).map((function(t){return e[t]})):gr(e)?xt(e).map((function(t){return e.get(t)})):yr(e)?Array.from(e.values()):Rt(e)?e.slice():void t(6)},e.when=function(e,t,n){return arguments.length===1||t&&typeof t==`object`?Dt(e,t):Et(e,t,n||{})}})),Dv=he((e=>{Object.defineProperty(e,`__esModule`,{value:!0});var t={0:`Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'`,1:function(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.`,17:function(e,t){return`[mobx.array] Index out of bounds, `+e+` is larger than `+t},18:`mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js`,19:function(e){return`Cannot initialize from classes that inherit from Map: `+e.constructor.name},20:function(e){return`Cannot initialize map from `+e},21:function(e){return`Cannot convert to map from '`+e+`'`},22:`mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js`,23:`It is not possible to get index atoms from arrays`,24:function(e){return`Cannot obtain administration from `+e},25:function(e,t){return`the entry '`+e+`' does not exist in the observable map '`+t+`'`},26:`please specify a property`,27:function(e,t){return`no observable property '`+e.toString()+`' found on the observable object '`+t+`'`},28:function(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:function(e,t){return`Cycle detected in computation `+e+`: `+t},33:function(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:function(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:function(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`};function n(e){var n=[...arguments].slice(1),r=typeof e==`string`?e:t[e];throw typeof r==`function`&&(r=r.apply(null,n)),Error(`[MobX] `+r)}var r={};function i(){return typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:r}var a=Object.assign,o=Object.getOwnPropertyDescriptor,s=Object.defineProperty,c=Object.prototype,l=[];Object.freeze(l);var u={};Object.freeze(u);var d=typeof Proxy<`u`,f=Object.toString();function p(){d||n("`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`")}function m(e){L.verifyProxies&&n(`MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to `+e)}function h(){return++L.mobxGuid}function g(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}var _=function(){};function v(e){return typeof e==`function`}function y(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function b(e){return typeof e==`object`&&!!e}function x(e){if(!b(e))return!1;var t=Object.getPrototypeOf(e);if(t==null)return!0;var n=Object.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===f}function S(e){var t=e?.constructor;return t?t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`:!1}function C(e,t,n){s(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function w(e,t,n){s(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function T(e,t){var n=`isMobX`+e;return t.prototype[n]=!0,function(e){return b(e)&&e[n]===!0}}function ee(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function te(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function ne(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}var re=Object.getOwnPropertySymbols!==void 0;function E(e){var t=Object.keys(e);if(!re)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter(function(t){return c.propertyIsEnumerable.call(e,t)})):t}var D=typeof Reflect<`u`&&Reflect.ownKeys?Reflect.ownKeys:re?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function ie(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function ae(e){return e===null?null:typeof e==`object`?``+e:e}function oe(e,t){return c.hasOwnProperty.call(e,t)}var se=Object.getOwnPropertyDescriptors||function(e){var t={};return D(e).forEach(function(n){t[n]=o(e,n)}),t};function ce(e,t){return!!(e&t)}function le(e,t,n){return n?e|=t:e&=~t,e}function ue(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function de(e,t,n){if(ve())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&ye(i,n.prototype),i}function fe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,xe(r.key),r)}}function pe(e,t,n){return t&&fe(e.prototype,t),n&&fe(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function me(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=Se(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
57
57
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function he(){return he=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},he.apply(null,arguments)}function ge(e){return ge=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ge(e)}function _e(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ye(e,t)}function O(e){try{return Function.toString.call(e).indexOf(`[native code]`)!==-1}catch{return typeof e==`function`}}function ve(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ve=function(){return!!e})()}function ye(e,t){return ye=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ye(e,t)}function be(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function xe(e){var t=be(e,`string`);return typeof t==`symbol`?t:t+``}function Se(e,t){if(e){if(typeof e==`string`)return ue(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ue(e,t):void 0}}function Ce(e){var t=typeof Map==`function`?new Map:void 0;return Ce=function(e){if(e===null||!O(e))return e;if(typeof e!=`function`)throw TypeError(`Super expression must either be null or a function`);if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return de(e,arguments,ge(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ye(n,e)},Ce(e)}var we=Symbol(`mobx-stored-annotations`);function Te(e){function t(t,n){if(ke(n))return e.decorate_20223_(t,n);Ee(t,n,e)}return Object.assign(t,e)}function Ee(e,t,r){oe(e,we)||C(e,we,he({},e[we])),Ge(r)&&!oe(e[we],t)&&n(`'`+(e.constructor.name+`.prototype.`+t.toString())+`' is decorated with 'override', but no such decorated member was found on prototype.`),De(e,r,t),Ge(r)||(e[we][t]=r)}function De(e,t,r){if(!Ge(t)&&oe(e[we],r)){var i=e.constructor.name+`.prototype.`+r.toString(),a=e[we][r].annotationType_,o=t.annotationType_;n(`Cannot apply '@`+o+`' to '`+i+`':`+(`
58
58
  The field is already decorated with '@`+a+`'.`)+`
59
59
  Re-decorating fields is not allowed.
60
- Use '@override' decorator for methods overridden by subclass.`)}}function Oe(e){return oe(e,we)||C(e,we,he({},e[we])),e[we]}function ke(e){return typeof e==`object`&&typeof e.kind==`string`}function Ae(e,t){t.includes(e.kind)||n(`The decorator applied to '`+String(e.name)+`' cannot be used on a `+e.kind+` element`)}var k=Symbol(`mobx administration`),je=function(){function e(e){e===void 0&&(e=`Atom@`+h()),this.name_=void 0,this.flags_=0,this.observers_=new Set,this.lastAccessedBy_=0,this.lowestObserverState_=P.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}var t=e.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(e){return e()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(e){return e()})},t.reportObserved=function(){return Mn(this)},t.reportChanged=function(){An(),Nn(this),jn()},t.toString=function(){return this.name_},pe(e,[{key:`isBeingObserved`,get:function(){return ce(this.flags_,e.isBeingObservedMask_)},set:function(t){this.flags_=le(this.flags_,e.isBeingObservedMask_,t)}},{key:`isPendingUnobservation`,get:function(){return ce(this.flags_,e.isPendingUnobservationMask_)},set:function(t){this.flags_=le(this.flags_,e.isPendingUnobservationMask_,t)}},{key:`diffValue`,get:function(){return+!!ce(this.flags_,e.diffValueMask_)},set:function(t){this.flags_=le(this.flags_,e.diffValueMask_,t===1)}}])}();je.isBeingObservedMask_=1,je.isPendingUnobservationMask_=2,je.diffValueMask_=4;var Me=ee(`Atom`,je);function Ne(e,t,n){t===void 0&&(t=_),n===void 0&&(n=_);var r=new je(e);return t!==_&&_r(r,t),n!==_&&vr(r,n),r}function Pe(e,t){return e===t}function Fe(e,t){return va(e,t)}function Ie(e,t){return va(e,t,1)}function Le(e,t){return Object.is?Object.is(e,t):e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Re={identity:Pe,structural:Fe,default:Le,shallow:Ie};function ze(e,t,n){return Kr(e)?e:Array.isArray(e)?j.array(e,{name:n}):x(e)?j.object(e,void 0,{name:n}):te(e)?j.map(e,{name:n}):T(e)?j.set(e,{name:n}):typeof e==`function`&&!lr(e)&&!Rr(e)?S(e)?Fr(e):sr(n,e):e}function Be(e,t,r){if(e==null||ea(e)||Ii(e)||Vi(e)||Ki(e))return e;if(Array.isArray(e))return j.array(e,{name:r,deep:!1});if(x(e))return j.object(e,void 0,{name:r,deep:!1});if(te(e))return j.map(e,{name:r,deep:!1});if(T(e))return j.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function Ve(e){return e}function He(e,t){return Kr(e)&&n(`observable.struct should not be used with observable values`),va(e,t)?t:e}var Ue=`override`,We=Te({annotationType_:Ue,make_:Ke,extend_:qe,decorate_20223_:Je});function Ge(e){return e.annotationType_===Ue}function Ke(e,t){return e.isPlainObject_&&n(`Cannot apply '`+this.annotationType_+`' to '`+e.name_+`.`+t.toString()+`':`+(`
60
+ Use '@override' decorator for methods overridden by subclass.`)}}function Oe(e){return oe(e,we)||C(e,we,he({},e[we])),e[we]}function ke(e){return typeof e==`object`&&typeof e.kind==`string`}function Ae(e,t){t.includes(e.kind)||n(`The decorator applied to '`+String(e.name)+`' cannot be used on a `+e.kind+` element`)}var k=Symbol(`mobx administration`),je=function(){function e(e){e===void 0&&(e=`Atom@`+h()),this.name_=void 0,this.flags_=0,this.observers_=new Set,this.lastAccessedBy_=0,this.lowestObserverState_=P.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}var t=e.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(e){return e()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(e){return e()})},t.reportObserved=function(){return Mn(this)},t.reportChanged=function(){An(),Nn(this),jn()},t.toString=function(){return this.name_},pe(e,[{key:`isBeingObserved`,get:function(){return ce(this.flags_,e.isBeingObservedMask_)},set:function(t){this.flags_=le(this.flags_,e.isBeingObservedMask_,t)}},{key:`isPendingUnobservation`,get:function(){return ce(this.flags_,e.isPendingUnobservationMask_)},set:function(t){this.flags_=le(this.flags_,e.isPendingUnobservationMask_,t)}},{key:`diffValue`,get:function(){return+!!ce(this.flags_,e.diffValueMask_)},set:function(t){this.flags_=le(this.flags_,e.diffValueMask_,t===1)}}])}();je.isBeingObservedMask_=1,je.isPendingUnobservationMask_=2,je.diffValueMask_=4;var Me=T(`Atom`,je);function Ne(e,t,n){t===void 0&&(t=_),n===void 0&&(n=_);var r=new je(e);return t!==_&&_r(r,t),n!==_&&vr(r,n),r}function Pe(e,t){return e===t}function Fe(e,t){return va(e,t)}function Ie(e,t){return va(e,t,1)}function Le(e,t){return Object.is?Object.is(e,t):e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Re={identity:Pe,structural:Fe,default:Le,shallow:Ie};function ze(e,t,n){return Kr(e)?e:Array.isArray(e)?j.array(e,{name:n}):x(e)?j.object(e,void 0,{name:n}):ee(e)?j.map(e,{name:n}):ne(e)?j.set(e,{name:n}):typeof e==`function`&&!lr(e)&&!Rr(e)?S(e)?Fr(e):sr(n,e):e}function Be(e,t,r){if(e==null||ea(e)||Ii(e)||Vi(e)||Ki(e))return e;if(Array.isArray(e))return j.array(e,{name:r,deep:!1});if(x(e))return j.object(e,void 0,{name:r,deep:!1});if(ee(e))return j.map(e,{name:r,deep:!1});if(ne(e))return j.set(e,{name:r,deep:!1});n(`The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets`)}function Ve(e){return e}function He(e,t){return Kr(e)&&n(`observable.struct should not be used with observable values`),va(e,t)?t:e}var Ue=`override`,We=Te({annotationType_:Ue,make_:Ke,extend_:qe,decorate_20223_:Je});function Ge(e){return e.annotationType_===Ue}function Ke(e,t){return e.isPlainObject_&&n(`Cannot apply '`+this.annotationType_+`' to '`+e.name_+`.`+t.toString()+`':`+(`
61
61
  '`+this.annotationType_+`' cannot be used on plain objects.`)),oe(e.appliedAnnotations_,t)||n(`'`+e.name_+`.`+t.toString()+`' is annotated with '`+this.annotationType_+`', but no such annotated member was found on prototype.`),0}function qe(e,t,r,i){n(`'`+this.annotationType_+`' can only be used with 'makeObservable'`)}function Je(e,t){console.warn(`'`+this.annotationType_+`' cannot be used with decorators - this is a no-op`)}function Ye(e,t){return{annotationType_:e,options_:t,make_:Xe,extend_:Ze,decorate_20223_:Qe}}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:lr(n.value)?1:(s(r,t,et(e,this,t,n,!1)),2)}function Ze(e,t,n,r){var i=et(e,this,t,n);return e.defineProperty_(t,i,r)}function Qe(e,t){Ae(t,[`method`,`field`]);var r=t.kind,i=t.name,a=t.addInitializer,o=this,s=function(e){return Wt(o.options_?.name??i.toString(),e,o.options_?.autoAction??!1)};if(r==`field`)return function(e){var t,n=e;return lr(n)||(n=s(n)),(t=o.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(r==`method`){var c;return lr(e)||(e=s(e)),(c=this.options_)!=null&&c.bound&&a(function(){var e=this,t=e[i].bind(e);t.isMobxAction=!0,e[i]=t}),e}n(`Cannot apply '`+o.annotationType_+`' to '`+String(i)+`' (kind: `+r+`):`+(`
62
62
  '`+o.annotationType_+`' can only be used on properties with a function value.`))}function $e(e,t,r,i){var a=t.annotationType_,o=i.value;v(o)||n(`Cannot apply '`+a+`' to '`+e.name_+`.`+r.toString()+`':`+(`
63
63
  '`+a+`' can only be used on properties with a function value.`))}function et(e,t,n,r,i){var a,o;i===void 0&&(i=L.safeDescriptors),$e(e,t,n,r);var s=r.value;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:Wt(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 tt(e,t){return{annotationType_:e,options_:t,make_:nt,extend_:rt,decorate_20223_:it}}function nt(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&&(!oe(e.target_,t)||!Rr(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:Rr(n.value)?1:(s(r,t,ot(e,this,t,n,!1,!1)),2)}function rt(e,t,n,r){var i=ot(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function it(e,t){var n;Ae(t,[`method`]);var r=t.name,i=t.addInitializer;return Rr(e)||(e=Fr(e)),(n=this.options_)!=null&&n.bound&&i(function(){var e=this,t=e[r].bind(e);t.isMobXFlow=!0,e[r]=t}),e}function at(e,t,r,i){var a=t.annotationType_,o=i.value;v(o)||n(`Cannot apply '`+a+`' to '`+e.name_+`.`+r.toString()+`':`+(`
64
64
  '`+a+`' can only be used on properties with a generator function value.`))}function ot(e,t,n,r,i,a){a===void 0&&(a=L.safeDescriptors),at(e,t,n,r);var o=r.value;return Rr(o)||(o=Fr(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function st(e,t){return{annotationType_:e,options_:t,make_:ct,extend_:lt,decorate_20223_:ut}}function ct(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function lt(e,t,n,r){return dt(e,this,t,n),e.defineComputedProperty_(t,he({},this.options_,{get:n.get,set:n.set}),r)}function ut(e,t){Ae(t,[`getter`]);var n=this,r=t.name,i=t.addInitializer;return i(function(){var t=Zi(this)[k],i=he({},n.options_,{get:e,context:this});i.name||=t.name_+`.`+r.toString(),t.values_.set(r,new en(i))}),function(){return this[k].getObservablePropValue_(r)}}function dt(e,t,r,i){var a=t.annotationType_;i.get||n(`Cannot apply '`+a+`' to '`+e.name_+`.`+r.toString()+`':`+(`
65
65
  '`+a+`' can only be used on getter(+setter) properties.`))}function ft(e,t){return{annotationType_:e,options_:t,make_:pt,extend_:mt,decorate_20223_:ht}}function pt(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function mt(e,t,n,r){return gt(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer??ze,r)}function ht(e,t){if(t.kind===`field`)throw n("Please use `@observable accessor "+String(t.name)+"` instead of `@observable "+String(t.name)+"`");Ae(t,[`accessor`]);var r=this,i=t.kind,a=t.name,o=new WeakSet;function s(e,t){var n=Zi(e)[k],i=new Qt(t,r.options_?.enhancer??ze,n.name_+`.`+a.toString(),!1);n.values_.set(a,i),o.add(e)}if(i==`accessor`)return{get:function(){return o.has(this)||s(this,e.get.call(this)),this[k].getObservablePropValue_(a)},set:function(e){return o.has(this)||s(this,e),this[k].setObservablePropValue_(a,e)},init:function(e){return o.has(this)||s(this,e),e}}}function gt(e,t,r,i){var a=t.annotationType_;`value`in i||n(`Cannot apply '`+a+`' to '`+e.name_+`.`+r.toString()+`':`+(`
66
- '`+a+`' cannot be used on getter/setter properties`))}var _t=`true`,vt=yt();function yt(e){return{annotationType_:_t,options_:e,make_:bt,extend_:xt,decorate_20223_:St}}function bt(e,t,n,r){var i;if(n.get)return Bt.make_(e,t,n,r);if(n.set){var a=lr(n.set)?n.set:Wt(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:L.safeDescriptors?e.isPlainObject_:!0,set:a})===null?0:2:(s(r,t,{configurable:!0,set:a}),2)}if(r!==e.target_&&typeof n.value==`function`){var o;if(S(n.value)){var c;return((c=this.options_)!=null&&c.autoBind?Fr.bound:Fr).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?sr.bound:sr).make_(e,t,n,r)}var l=this.options_?.deep===!1?j.ref:j;return typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),l.make_(e,t,n,r)}function xt(e,t,n,r){var i;return n.get?Bt.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:L.safeDescriptors?e.isPlainObject_:!0,set:Wt(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?j.ref:j).extend_(e,t,n,r))}function St(e,t){n(`'`+this.annotationType_+`' cannot be used as a decorator`)}var Ct=`observable`,wt=`observable.ref`,Tt=`observable.shallow`,Et=`observable.struct`,Dt={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(Dt);function Ot(e){return e||Dt}var kt=ft(Ct),At=ft(wt,{enhancer:Ve}),jt=ft(Tt,{enhancer:Be}),Mt=ft(Et,{enhancer:He}),Nt=Te(kt);function Pt(e){return e.deep===!0?ze:e.deep===!1?Ve:A(e.defaultDecorator)}function Ft(e){return e?e.defaultDecorator??yt(e):void 0}function A(e){return e?e.options_?.enhancer??ze:ze}function It(e,t,n){if(ke(t))return kt.decorate_20223_(e,t);if(y(t)){Ee(e,t,kt);return}return Kr(e)?e:x(e)?j.object(e,t,n):Array.isArray(e)?j.array(e,t):te(e)?j.map(e,t):T(e)?j.set(e,t):typeof e==`object`&&e?e:j.box(e,t)}a(It,Nt);var j=a(It,{box:function(e,t){var n=Ot(t);return new Qt(e,Pt(n),n.name,!0,n.equals)},array:function(e,t){var n=Ot(t);return(L.useProxies===!1||n.proxy===!1?fa:ji)(e,Pt(n),n.name)},map:function(e,t){var n=Ot(t);return new Bi(e,Pt(n),n.name)},set:function(e,t){var n=Ot(t);return new Gi(e,Pt(n),n.name)},object:function(e,t,n){return ga(function(){return wr(L.useProxies===!1||n?.proxy===!1?Zi({},n):gi({},n),e,t)})},ref:Te(At),shallow:Te(jt),deep:Nt,struct:Te(Mt)}),Lt=`computed`,Rt=`computed.struct`,zt=st(Lt),M=st(Rt,{equals:Re.structural}),Bt=function(e,t){if(ke(t))return zt.decorate_20223_(e,t);if(y(t))return Ee(e,t,zt);if(x(e))return Te(st(Lt,e));v(e)||n("First argument to `computed` should be an expression."),v(t)&&n("A setter as second argument is no longer supported, use `{ set: fn }` option instead");var r=x(t)?t:{};return r.get=e,r.name||=e.name||``,new en(r)};Object.assign(Bt,zt),Bt.struct=Te(M);var Vt=0,N=1,Ht=o(function(){},`name`)?.configurable??!1,Ut={value:`action`,configurable:!0,writable:!1,enumerable:!1};function Wt(e,t,r,i){r===void 0&&(r=!1),v(t)||n("`action` can only be invoked on functions"),(typeof e!=`string`||!e)&&n(`actions should have valid names, got: '`+e+`'`);function a(){return Gt(e,r,t,i||this,arguments)}return a.isMobxAction=!0,a.toString=function(){return t.toString()},Ht&&(Ut.value=e,s(a,`name`,Ut)),a}function Gt(e,t,n,r,i){var a=Kt(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{qt(a)}}function Kt(e,t,n,r){var i=Wn()&&!!e,a=0;i&&(a=Date.now(),Kn({type:Xn,name:e,object:n,arguments:r?Array.from(r):l}));var o=L.trackingDerivation,s=!t||!o;An();var c=L.allowStateChanges;s&&(I(),c=Yt(!0));var u=hn(!0),d={runAsAction_:s,prevDerivation_:o,prevAllowStateChanges_:c,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:N++,parentActionId_:Vt};return Vt=d.actionId_,d}function qt(e){Vt!==e.actionId_&&n(30),Vt=e.parentActionId_,e.error_!==void 0&&(L.suppressReactionErrors=!0),Xt(e.prevAllowStateChanges_),gn(e.prevAllowStateReads_),jn(),e.runAsAction_&&mn(e.prevDerivation_),e.notifySpy_&&Jn({time:Date.now()-e.startTime_}),L.suppressReactionErrors=!1}function Jt(e,t){var n=Yt(e);try{return t()}finally{Xt(n)}}function Yt(e){var t=L.allowStateChanges;return L.allowStateChanges=e,t}function Xt(e){L.allowStateChanges=e}var Zt=`create`,Qt=function(e){function t(t,n,r,i,a){var o;return r===void 0&&(r=`ObservableValue@`+h()),i===void 0&&(i=!0),a===void 0&&(a=Re.default),o=e.call(this,r)||this,o.enhancer=void 0,o.name_=void 0,o.equals=void 0,o.hasUnreportedChange_=!1,o.interceptors_=void 0,o.changeListeners_=void 0,o.value_=void 0,o.dehancer=void 0,o.enhancer=n,o.name_=r,o.equals=a,o.value_=n(t,void 0,r),i&&Wn()&&Gn({type:Zt,object:o,observableKind:`value`,debugObjectName:o.name_,newValue:``+o.value_?.toString()}),o}_e(t,e);var n=t.prototype;return n.dehanceValue=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.set=function(e){var t=this.value_;if(e=this.prepareNewValue_(e),e!==L.UNCHANGED){var n=Wn();n&&Kn({type:Di,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&Jn()}},n.prepareNewValue_=function(e){if(cn(this),_i(this)){var t=yi(this,{object:this,type:Di,newValue:e});if(!t)return L.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.value_,this.name_),this.equals(this.value_,e)?L.UNCHANGED:e},n.setNewValue_=function(e){var t=this.value_;this.value_=e,this.reportChanged(),bi(this)&&Si(this,{type:Di,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},n.intercept_=function(e){return vi(this,e)},n.observe_=function(e,t){return t&&e({observableKind:`value`,debugObjectName:this.name_,object:this,type:Di,newValue:this.value_,oldValue:void 0}),xi(this,e)},n.raw=function(){return this.value_},n.toJSON=function(){return this.get()},n.toString=function(){return this.name_+`[`+this.value_+`]`},n.valueOf=function(){return ae(this.get())},n[Symbol.toPrimitive]=function(){return this.valueOf()},t}(je),$t=ee(`ObservableValue`,Qt),en=function(){function e(e){this.dependenciesState_=P.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.observers_=new Set,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=P.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new rn(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.isTracing_=nn.NONE,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@`+h(),e.set&&(this.setter_=Wt(this.name_+`-setter`,e.set)),this.equals_=e.equals||(e.compareStructural||e.struct?Re.structural:Re.default),this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}var t=e.prototype;return t.onBecomeStale_=function(){Fn(this)},t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(e){return e()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(e){return e()})},t.get=function(){if(this.isComputing&&n(32,this.name_,this.derivation),L.inBatch===0&&this.observers_.size===0&&!this.keepAlive_)on(this)&&(this.warnAboutUntrackedRead_(),An(),this.value_=this.computeValue_(!1),jn());else if(Mn(this),on(this)){var e=L.trackingContext;this.keepAlive_&&!e&&(L.trackingContext=this),this.trackAndCompute()&&Pn(this),L.trackingContext=e}var t=this.value_;if(an(t))throw t.cause;return t},t.set=function(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_)},t.trackAndCompute=function(){var e=this.value_,t=this.dependenciesState_===P.NOT_TRACKING_,n=this.computeValue_(!0),r=t||an(e)||an(n)||!this.equals_(e,n);return r&&(this.value_=n,Wn()&&Gn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r},t.computeValue_=function(e){this.isComputing=!0;var t=Yt(!1),n;if(e)n=F(this,this.derivation,this.scope_);else if(L.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new rn(e)}return Xt(t),this.isComputing=!1,n},t.suspend_=function(){this.keepAlive_||(fn(this),this.value_=void 0,this.isTracing_!==nn.NONE&&console.log(`[mobx.trace] Computed value '`+this.name_+`' was suspended and it will recompute on the next access.`))},t.observe_=function(e,t){var n=this,r=!0,i=void 0;return ur(function(){var a=n.get();if(!r||t){var o=I();e({observableKind:`computed`,debugObjectName:n.name_,type:Di,object:n,newValue:a,oldValue:i}),mn(o)}r=!1,i=a})},t.warnAboutUntrackedRead_=function(){this.isTracing_!==nn.NONE&&console.log(`[mobx.trace] Computed value '`+this.name_+`' is being read outside a reactive context. Doing a full recompute.`),(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:L.computedRequiresReaction)&&console.warn(`[mobx] Computed value '`+this.name_+`' is being read outside a reactive context. Doing a full recompute.`)},t.toString=function(){return this.name_+`[`+this.derivation.toString()+`]`},t.valueOf=function(){return ae(this.get())},t[Symbol.toPrimitive]=function(){return this.valueOf()},pe(e,[{key:`isComputing`,get:function(){return ce(this.flags_,e.isComputingMask_)},set:function(t){this.flags_=le(this.flags_,e.isComputingMask_,t)}},{key:`isRunningSetter`,get:function(){return ce(this.flags_,e.isRunningSetterMask_)},set:function(t){this.flags_=le(this.flags_,e.isRunningSetterMask_,t)}},{key:`isBeingObserved`,get:function(){return ce(this.flags_,e.isBeingObservedMask_)},set:function(t){this.flags_=le(this.flags_,e.isBeingObservedMask_,t)}},{key:`isPendingUnobservation`,get:function(){return ce(this.flags_,e.isPendingUnobservationMask_)},set:function(t){this.flags_=le(this.flags_,e.isPendingUnobservationMask_,t)}},{key:`diffValue`,get:function(){return+!!ce(this.flags_,e.diffValueMask_)},set:function(t){this.flags_=le(this.flags_,e.diffValueMask_,t===1)}}])}();en.isComputingMask_=1,en.isRunningSetterMask_=2,en.isBeingObservedMask_=4,en.isPendingUnobservationMask_=8,en.diffValueMask_=16;var tn=ee(`ComputedValue`,en),P;(function(e){e[e.NOT_TRACKING_=-1]=`NOT_TRACKING_`,e[e.UP_TO_DATE_=0]=`UP_TO_DATE_`,e[e.POSSIBLY_STALE_=1]=`POSSIBLY_STALE_`,e[e.STALE_=2]=`STALE_`})(P||={});var nn;(function(e){e[e.NONE=0]=`NONE`,e[e.LOG=1]=`LOG`,e[e.BREAK=2]=`BREAK`})(nn||={});var rn=function(e){this.cause=void 0,this.cause=e};function an(e){return e instanceof rn}function on(e){switch(e.dependenciesState_){case P.UP_TO_DATE_:return!1;case P.NOT_TRACKING_:case P.STALE_:return!0;case P.POSSIBLY_STALE_:for(var t=hn(!0),n=I(),r=e.observing_,i=r.length,a=0;a<i;a++){var o=r[a];if(tn(o)){if(L.disableErrorBoundaries)o.get();else try{o.get()}catch{return mn(n),gn(t),!0}if(e.dependenciesState_===P.STALE_)return mn(n),gn(t),!0}}return _n(e),mn(n),gn(t),!1}}function sn(){return L.trackingDerivation!==null}function cn(e){var t=e.observers_.size>0;!L.allowStateChanges&&(t||L.enforceActions===`always`)&&console.warn(`[MobX] `+(L.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 ln(e){!L.allowStateReads&&L.observableRequiresReaction&&console.warn(`[mobx] Observable '`+e.name_+`' being read outside a reactive context.`)}function F(e,t,n){var r=hn(!0);_n(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++L.runId;var i=L.trackingDerivation;L.trackingDerivation=e,L.inBatch++;var a;if(L.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new rn(e)}return L.inBatch--,L.trackingDerivation=i,dn(e),un(e),gn(r),a}function un(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:L.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '`+e.name_+`' is created/updated without reading any observable value.`)}function dn(e){for(var t=e.observing_,n=e.observing_=e.newObserving_,r=P.UP_TO_DATE_,i=0,a=e.unboundDepsCount_,o=0;o<a;o++){var s=n[o];s.diffValue===0&&(s.diffValue=1,i!==o&&(n[i]=s),i++),s.dependenciesState_>r&&(r=s.dependenciesState_)}for(n.length=i,e.newObserving_=null,a=t.length;a--;){var c=t[a];c.diffValue===0&&On(c,e),c.diffValue=0}for(;i--;){var l=n[i];l.diffValue===1&&(l.diffValue=0,Dn(l,e))}r!==P.UP_TO_DATE_&&(e.dependenciesState_=r,e.onBecomeStale_())}function fn(e){var t=e.observing_;e.observing_=[];for(var n=t.length;n--;)On(t[n],e);e.dependenciesState_=P.NOT_TRACKING_}function pn(e){var t=I();try{return e()}finally{mn(t)}}function I(){var e=L.trackingDerivation;return L.trackingDerivation=null,e}function mn(e){L.trackingDerivation=e}function hn(e){var t=L.allowStateReads;return L.allowStateReads=e,t}function gn(e){L.allowStateReads=e}function _n(e){if(e.dependenciesState_!==P.UP_TO_DATE_){e.dependenciesState_=P.UP_TO_DATE_;for(var t=e.observing_,n=t.length;n--;)t[n].lowestObserverState_=P.UP_TO_DATE_}}var vn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`,`useProxies`],yn=function(){this.version=6,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.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.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},bn=!0,xn=!1,L=function(){var e=i();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(bn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==new yn().version&&(bn=!1),bn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new yn):(setTimeout(function(){xn||n(35)},1),new yn)}();function Sn(){if((L.pendingReactions.length||L.inBatch||L.isRunningReactions)&&n(36),xn=!0,bn){var e=i();--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),L=new yn}}function Cn(){return L}function wn(){var e=new yn;for(var t in e)vn.indexOf(t)===-1&&(L[t]=e[t]);L.allowStateChanges=!L.enforceActions}function Tn(e){return e.observers_&&e.observers_.size>0}function En(e){return e.observers_}function Dn(e,t){e.observers_.add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function On(e,t){e.observers_.delete(t),e.observers_.size===0&&kn(e)}function kn(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,L.pendingUnobservations.push(e))}function An(){L.inBatch++}function jn(){if(--L.inBatch===0){Vn();for(var e=L.pendingUnobservations,t=0;t<e.length;t++){var n=e[t];n.isPendingUnobservation=!1,n.observers_.size===0&&(n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof en&&n.suspend_())}L.pendingUnobservations=[]}}function Mn(e){ln(e);var t=L.trackingDerivation;return t===null?(e.observers_.size===0&&L.inBatch>0&&kn(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&L.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function Nn(e){e.lowestObserverState_!==P.STALE_&&(e.lowestObserverState_=P.STALE_,e.observers_.forEach(function(t){t.dependenciesState_===P.UP_TO_DATE_&&(t.isTracing_!==nn.NONE&&R(t,e),t.onBecomeStale_()),t.dependenciesState_=P.STALE_}))}function Pn(e){e.lowestObserverState_!==P.STALE_&&(e.lowestObserverState_=P.STALE_,e.observers_.forEach(function(t){t.dependenciesState_===P.POSSIBLY_STALE_?(t.dependenciesState_=P.STALE_,t.isTracing_!==nn.NONE&&R(t,e)):t.dependenciesState_===P.UP_TO_DATE_&&(e.lowestObserverState_=P.UP_TO_DATE_)}))}function Fn(e){e.lowestObserverState_===P.UP_TO_DATE_&&(e.lowestObserverState_=P.POSSIBLY_STALE_,e.observers_.forEach(function(e){e.dependenciesState_===P.UP_TO_DATE_&&(e.dependenciesState_=P.POSSIBLY_STALE_,e.onBecomeStale_())}))}function R(e,t){if(console.log(`[mobx.trace] '`+e.name_+`' is invalidated due to a change in: '`+t.name_+`'`),e.isTracing_===nn.BREAK){var n=[];In(Tr(e),n,1),Function(`debugger;
66
+ '`+a+`' cannot be used on getter/setter properties`))}var _t=`true`,vt=yt();function yt(e){return{annotationType_:_t,options_:e,make_:bt,extend_:xt,decorate_20223_:St}}function bt(e,t,n,r){var i;if(n.get)return Bt.make_(e,t,n,r);if(n.set){var a=lr(n.set)?n.set:Wt(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:L.safeDescriptors?e.isPlainObject_:!0,set:a})===null?0:2:(s(r,t,{configurable:!0,set:a}),2)}if(r!==e.target_&&typeof n.value==`function`){var o;if(S(n.value)){var c;return((c=this.options_)!=null&&c.autoBind?Fr.bound:Fr).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?sr.bound:sr).make_(e,t,n,r)}var l=this.options_?.deep===!1?j.ref:j;return typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),l.make_(e,t,n,r)}function xt(e,t,n,r){var i;return n.get?Bt.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:L.safeDescriptors?e.isPlainObject_:!0,set:Wt(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?j.ref:j).extend_(e,t,n,r))}function St(e,t){n(`'`+this.annotationType_+`' cannot be used as a decorator`)}var Ct=`observable`,wt=`observable.ref`,Tt=`observable.shallow`,Et=`observable.struct`,Dt={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(Dt);function Ot(e){return e||Dt}var kt=ft(Ct),At=ft(wt,{enhancer:Ve}),jt=ft(Tt,{enhancer:Be}),Mt=ft(Et,{enhancer:He}),Nt=Te(kt);function Pt(e){return e.deep===!0?ze:e.deep===!1?Ve:A(e.defaultDecorator)}function Ft(e){return e?e.defaultDecorator??yt(e):void 0}function A(e){return e?e.options_?.enhancer??ze:ze}function It(e,t,n){if(ke(t))return kt.decorate_20223_(e,t);if(y(t)){Ee(e,t,kt);return}return Kr(e)?e:x(e)?j.object(e,t,n):Array.isArray(e)?j.array(e,t):ee(e)?j.map(e,t):ne(e)?j.set(e,t):typeof e==`object`&&e?e:j.box(e,t)}a(It,Nt);var j=a(It,{box:function(e,t){var n=Ot(t);return new Qt(e,Pt(n),n.name,!0,n.equals)},array:function(e,t){var n=Ot(t);return(L.useProxies===!1||n.proxy===!1?fa:ji)(e,Pt(n),n.name)},map:function(e,t){var n=Ot(t);return new Bi(e,Pt(n),n.name)},set:function(e,t){var n=Ot(t);return new Gi(e,Pt(n),n.name)},object:function(e,t,n){return ga(function(){return wr(L.useProxies===!1||n?.proxy===!1?Zi({},n):gi({},n),e,t)})},ref:Te(At),shallow:Te(jt),deep:Nt,struct:Te(Mt)}),Lt=`computed`,Rt=`computed.struct`,zt=st(Lt),M=st(Rt,{equals:Re.structural}),Bt=function(e,t){if(ke(t))return zt.decorate_20223_(e,t);if(y(t))return Ee(e,t,zt);if(x(e))return Te(st(Lt,e));v(e)||n("First argument to `computed` should be an expression."),v(t)&&n("A setter as second argument is no longer supported, use `{ set: fn }` option instead");var r=x(t)?t:{};return r.get=e,r.name||=e.name||``,new en(r)};Object.assign(Bt,zt),Bt.struct=Te(M);var Vt=0,N=1,Ht=o(function(){},`name`)?.configurable??!1,Ut={value:`action`,configurable:!0,writable:!1,enumerable:!1};function Wt(e,t,r,i){r===void 0&&(r=!1),v(t)||n("`action` can only be invoked on functions"),(typeof e!=`string`||!e)&&n(`actions should have valid names, got: '`+e+`'`);function a(){return Gt(e,r,t,i||this,arguments)}return a.isMobxAction=!0,a.toString=function(){return t.toString()},Ht&&(Ut.value=e,s(a,`name`,Ut)),a}function Gt(e,t,n,r,i){var a=Kt(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{qt(a)}}function Kt(e,t,n,r){var i=Wn()&&!!e,a=0;i&&(a=Date.now(),Kn({type:Xn,name:e,object:n,arguments:r?Array.from(r):l}));var o=L.trackingDerivation,s=!t||!o;An();var c=L.allowStateChanges;s&&(I(),c=Yt(!0));var u=hn(!0),d={runAsAction_:s,prevDerivation_:o,prevAllowStateChanges_:c,prevAllowStateReads_:u,notifySpy_:i,startTime_:a,actionId_:N++,parentActionId_:Vt};return Vt=d.actionId_,d}function qt(e){Vt!==e.actionId_&&n(30),Vt=e.parentActionId_,e.error_!==void 0&&(L.suppressReactionErrors=!0),Xt(e.prevAllowStateChanges_),gn(e.prevAllowStateReads_),jn(),e.runAsAction_&&mn(e.prevDerivation_),e.notifySpy_&&Jn({time:Date.now()-e.startTime_}),L.suppressReactionErrors=!1}function Jt(e,t){var n=Yt(e);try{return t()}finally{Xt(n)}}function Yt(e){var t=L.allowStateChanges;return L.allowStateChanges=e,t}function Xt(e){L.allowStateChanges=e}var Zt=`create`,Qt=function(e){function t(t,n,r,i,a){var o;return r===void 0&&(r=`ObservableValue@`+h()),i===void 0&&(i=!0),a===void 0&&(a=Re.default),o=e.call(this,r)||this,o.enhancer=void 0,o.name_=void 0,o.equals=void 0,o.hasUnreportedChange_=!1,o.interceptors_=void 0,o.changeListeners_=void 0,o.value_=void 0,o.dehancer=void 0,o.enhancer=n,o.name_=r,o.equals=a,o.value_=n(t,void 0,r),i&&Wn()&&Gn({type:Zt,object:o,observableKind:`value`,debugObjectName:o.name_,newValue:``+o.value_?.toString()}),o}_e(t,e);var n=t.prototype;return n.dehanceValue=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.set=function(e){var t=this.value_;if(e=this.prepareNewValue_(e),e!==L.UNCHANGED){var n=Wn();n&&Kn({type:Di,object:this,observableKind:`value`,debugObjectName:this.name_,newValue:e,oldValue:t}),this.setNewValue_(e),n&&Jn()}},n.prepareNewValue_=function(e){if(cn(this),_i(this)){var t=yi(this,{object:this,type:Di,newValue:e});if(!t)return L.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.value_,this.name_),this.equals(this.value_,e)?L.UNCHANGED:e},n.setNewValue_=function(e){var t=this.value_;this.value_=e,this.reportChanged(),bi(this)&&Si(this,{type:Di,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},n.intercept_=function(e){return vi(this,e)},n.observe_=function(e,t){return t&&e({observableKind:`value`,debugObjectName:this.name_,object:this,type:Di,newValue:this.value_,oldValue:void 0}),xi(this,e)},n.raw=function(){return this.value_},n.toJSON=function(){return this.get()},n.toString=function(){return this.name_+`[`+this.value_+`]`},n.valueOf=function(){return ae(this.get())},n[Symbol.toPrimitive]=function(){return this.valueOf()},t}(je),$t=T(`ObservableValue`,Qt),en=function(){function e(e){this.dependenciesState_=P.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.observers_=new Set,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=P.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new rn(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.isTracing_=nn.NONE,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@`+h(),e.set&&(this.setter_=Wt(this.name_+`-setter`,e.set)),this.equals_=e.equals||(e.compareStructural||e.struct?Re.structural:Re.default),this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}var t=e.prototype;return t.onBecomeStale_=function(){Fn(this)},t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(e){return e()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(e){return e()})},t.get=function(){if(this.isComputing&&n(32,this.name_,this.derivation),L.inBatch===0&&this.observers_.size===0&&!this.keepAlive_)on(this)&&(this.warnAboutUntrackedRead_(),An(),this.value_=this.computeValue_(!1),jn());else if(Mn(this),on(this)){var e=L.trackingContext;this.keepAlive_&&!e&&(L.trackingContext=this),this.trackAndCompute()&&Pn(this),L.trackingContext=e}var t=this.value_;if(an(t))throw t.cause;return t},t.set=function(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_)},t.trackAndCompute=function(){var e=this.value_,t=this.dependenciesState_===P.NOT_TRACKING_,n=this.computeValue_(!0),r=t||an(e)||an(n)||!this.equals_(e,n);return r&&(this.value_=n,Wn()&&Gn({observableKind:`computed`,debugObjectName:this.name_,object:this.scope_,type:`update`,oldValue:e,newValue:n})),r},t.computeValue_=function(e){this.isComputing=!0;var t=Yt(!1),n;if(e)n=F(this,this.derivation,this.scope_);else if(L.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new rn(e)}return Xt(t),this.isComputing=!1,n},t.suspend_=function(){this.keepAlive_||(fn(this),this.value_=void 0,this.isTracing_!==nn.NONE&&console.log(`[mobx.trace] Computed value '`+this.name_+`' was suspended and it will recompute on the next access.`))},t.observe_=function(e,t){var n=this,r=!0,i=void 0;return ur(function(){var a=n.get();if(!r||t){var o=I();e({observableKind:`computed`,debugObjectName:n.name_,type:Di,object:n,newValue:a,oldValue:i}),mn(o)}r=!1,i=a})},t.warnAboutUntrackedRead_=function(){this.isTracing_!==nn.NONE&&console.log(`[mobx.trace] Computed value '`+this.name_+`' is being read outside a reactive context. Doing a full recompute.`),(typeof this.requiresReaction_==`boolean`?this.requiresReaction_:L.computedRequiresReaction)&&console.warn(`[mobx] Computed value '`+this.name_+`' is being read outside a reactive context. Doing a full recompute.`)},t.toString=function(){return this.name_+`[`+this.derivation.toString()+`]`},t.valueOf=function(){return ae(this.get())},t[Symbol.toPrimitive]=function(){return this.valueOf()},pe(e,[{key:`isComputing`,get:function(){return ce(this.flags_,e.isComputingMask_)},set:function(t){this.flags_=le(this.flags_,e.isComputingMask_,t)}},{key:`isRunningSetter`,get:function(){return ce(this.flags_,e.isRunningSetterMask_)},set:function(t){this.flags_=le(this.flags_,e.isRunningSetterMask_,t)}},{key:`isBeingObserved`,get:function(){return ce(this.flags_,e.isBeingObservedMask_)},set:function(t){this.flags_=le(this.flags_,e.isBeingObservedMask_,t)}},{key:`isPendingUnobservation`,get:function(){return ce(this.flags_,e.isPendingUnobservationMask_)},set:function(t){this.flags_=le(this.flags_,e.isPendingUnobservationMask_,t)}},{key:`diffValue`,get:function(){return+!!ce(this.flags_,e.diffValueMask_)},set:function(t){this.flags_=le(this.flags_,e.diffValueMask_,t===1)}}])}();en.isComputingMask_=1,en.isRunningSetterMask_=2,en.isBeingObservedMask_=4,en.isPendingUnobservationMask_=8,en.diffValueMask_=16;var tn=T(`ComputedValue`,en),P;(function(e){e[e.NOT_TRACKING_=-1]=`NOT_TRACKING_`,e[e.UP_TO_DATE_=0]=`UP_TO_DATE_`,e[e.POSSIBLY_STALE_=1]=`POSSIBLY_STALE_`,e[e.STALE_=2]=`STALE_`})(P||={});var nn;(function(e){e[e.NONE=0]=`NONE`,e[e.LOG=1]=`LOG`,e[e.BREAK=2]=`BREAK`})(nn||={});var rn=function(e){this.cause=void 0,this.cause=e};function an(e){return e instanceof rn}function on(e){switch(e.dependenciesState_){case P.UP_TO_DATE_:return!1;case P.NOT_TRACKING_:case P.STALE_:return!0;case P.POSSIBLY_STALE_:for(var t=hn(!0),n=I(),r=e.observing_,i=r.length,a=0;a<i;a++){var o=r[a];if(tn(o)){if(L.disableErrorBoundaries)o.get();else try{o.get()}catch{return mn(n),gn(t),!0}if(e.dependenciesState_===P.STALE_)return mn(n),gn(t),!0}}return _n(e),mn(n),gn(t),!1}}function sn(){return L.trackingDerivation!==null}function cn(e){var t=e.observers_.size>0;!L.allowStateChanges&&(t||L.enforceActions===`always`)&&console.warn(`[MobX] `+(L.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 ln(e){!L.allowStateReads&&L.observableRequiresReaction&&console.warn(`[mobx] Observable '`+e.name_+`' being read outside a reactive context.`)}function F(e,t,n){var r=hn(!0);_n(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++L.runId;var i=L.trackingDerivation;L.trackingDerivation=e,L.inBatch++;var a;if(L.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new rn(e)}return L.inBatch--,L.trackingDerivation=i,dn(e),un(e),gn(r),a}function un(e){e.observing_.length===0&&(typeof e.requiresObservable_==`boolean`?e.requiresObservable_:L.reactionRequiresObservable)&&console.warn(`[mobx] Derivation '`+e.name_+`' is created/updated without reading any observable value.`)}function dn(e){for(var t=e.observing_,n=e.observing_=e.newObserving_,r=P.UP_TO_DATE_,i=0,a=e.unboundDepsCount_,o=0;o<a;o++){var s=n[o];s.diffValue===0&&(s.diffValue=1,i!==o&&(n[i]=s),i++),s.dependenciesState_>r&&(r=s.dependenciesState_)}for(n.length=i,e.newObserving_=null,a=t.length;a--;){var c=t[a];c.diffValue===0&&On(c,e),c.diffValue=0}for(;i--;){var l=n[i];l.diffValue===1&&(l.diffValue=0,Dn(l,e))}r!==P.UP_TO_DATE_&&(e.dependenciesState_=r,e.onBecomeStale_())}function fn(e){var t=e.observing_;e.observing_=[];for(var n=t.length;n--;)On(t[n],e);e.dependenciesState_=P.NOT_TRACKING_}function pn(e){var t=I();try{return e()}finally{mn(t)}}function I(){var e=L.trackingDerivation;return L.trackingDerivation=null,e}function mn(e){L.trackingDerivation=e}function hn(e){var t=L.allowStateReads;return L.allowStateReads=e,t}function gn(e){L.allowStateReads=e}function _n(e){if(e.dependenciesState_!==P.UP_TO_DATE_){e.dependenciesState_=P.UP_TO_DATE_;for(var t=e.observing_,n=t.length;n--;)t[n].lowestObserverState_=P.UP_TO_DATE_}}var vn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`,`useProxies`],yn=function(){this.version=6,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.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.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},bn=!0,xn=!1,L=function(){var e=i();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(bn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==new yn().version&&(bn=!1),bn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new yn):(setTimeout(function(){xn||n(35)},1),new yn)}();function Sn(){if((L.pendingReactions.length||L.inBatch||L.isRunningReactions)&&n(36),xn=!0,bn){var e=i();--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),L=new yn}}function Cn(){return L}function wn(){var e=new yn;for(var t in e)vn.indexOf(t)===-1&&(L[t]=e[t]);L.allowStateChanges=!L.enforceActions}function Tn(e){return e.observers_&&e.observers_.size>0}function En(e){return e.observers_}function Dn(e,t){e.observers_.add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function On(e,t){e.observers_.delete(t),e.observers_.size===0&&kn(e)}function kn(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,L.pendingUnobservations.push(e))}function An(){L.inBatch++}function jn(){if(--L.inBatch===0){Vn();for(var e=L.pendingUnobservations,t=0;t<e.length;t++){var n=e[t];n.isPendingUnobservation=!1,n.observers_.size===0&&(n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof en&&n.suspend_())}L.pendingUnobservations=[]}}function Mn(e){ln(e);var t=L.trackingDerivation;return t===null?(e.observers_.size===0&&L.inBatch>0&&kn(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&L.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function Nn(e){e.lowestObserverState_!==P.STALE_&&(e.lowestObserverState_=P.STALE_,e.observers_.forEach(function(t){t.dependenciesState_===P.UP_TO_DATE_&&(t.isTracing_!==nn.NONE&&R(t,e),t.onBecomeStale_()),t.dependenciesState_=P.STALE_}))}function Pn(e){e.lowestObserverState_!==P.STALE_&&(e.lowestObserverState_=P.STALE_,e.observers_.forEach(function(t){t.dependenciesState_===P.POSSIBLY_STALE_?(t.dependenciesState_=P.STALE_,t.isTracing_!==nn.NONE&&R(t,e)):t.dependenciesState_===P.UP_TO_DATE_&&(e.lowestObserverState_=P.UP_TO_DATE_)}))}function Fn(e){e.lowestObserverState_===P.UP_TO_DATE_&&(e.lowestObserverState_=P.POSSIBLY_STALE_,e.observers_.forEach(function(e){e.dependenciesState_===P.UP_TO_DATE_&&(e.dependenciesState_=P.POSSIBLY_STALE_,e.onBecomeStale_())}))}function R(e,t){if(console.log(`[mobx.trace] '`+e.name_+`' is invalidated due to a change in: '`+t.name_+`'`),e.isTracing_===nn.BREAK){var n=[];In(Tr(e),n,1),Function(`debugger;
67
67
  /*
68
68
  Tracing '`+e.name_+`'
69
69
 
@@ -78,23 +78,23 @@ The dependencies for this derivation are:
78
78
  `+n.join(`
79
79
  `)+`
80
80
  */
81
- `)()}}function In(e,t,n){if(t.length>=1e3){t.push(`(and many more)`);return}t.push(``+` `.repeat(n-1)+e.name),e.dependencies&&e.dependencies.forEach(function(e){return In(e,t,n+1)})}var Ln=function(){function e(e,t,n,r){e===void 0&&(e=`Reaction@`+h()),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=P.NOT_TRACKING_,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.isTracing_=nn.NONE,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}var t=e.prototype;return t.onBecomeStale_=function(){this.schedule_()},t.schedule_=function(){this.isScheduled||(this.isScheduled=!0,L.pendingReactions.push(this),Vn())},t.runReaction_=function(){if(!this.isDisposed){An(),this.isScheduled=!1;var e=L.trackingContext;if(L.trackingContext=this,on(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&Wn()&&Gn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}L.trackingContext=e,jn()}},t.track=function(e){if(!this.isDisposed){An();var t=Wn(),n;t&&(n=Date.now(),Kn({name:this.name_,type:`reaction`})),this.isRunning=!0;var r=L.trackingContext;L.trackingContext=this;var i=F(this,e,void 0);L.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&fn(this),an(i)&&this.reportExceptionInDerivation_(i.cause),t&&Jn({time:Date.now()-n}),jn()}},t.reportExceptionInDerivation_=function(e){var t=this;if(this.errorHandler_){this.errorHandler_(e,this);return}if(L.disableErrorBoundaries)throw e;var n=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '`+this+`'`;L.suppressReactionErrors?console.warn(`[mobx] (error in reaction '`+this.name_+`' suppressed, fix error of causing action below)`):console.error(n,e),Wn()&&Gn({type:`error`,name:this.name_,message:n,error:``+e}),L.globalReactionErrorHandlers.forEach(function(n){return n(e,t)})},t.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||(An(),fn(this),jn()))},t.getDisposer_=function(e){var t=this,n=function n(){t.dispose(),e==null||e.removeEventListener==null||e.removeEventListener(`abort`,n)};return e==null||e.addEventListener==null||e.addEventListener(`abort`,n),n[k]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(n[Symbol.dispose]=n),n},t.toString=function(){return`Reaction[`+this.name_+`]`},t.trace=function(e){e===void 0&&(e=!1),ci(this,e)},pe(e,[{key:`isDisposed`,get:function(){return ce(this.flags_,e.isDisposedMask_)},set:function(t){this.flags_=le(this.flags_,e.isDisposedMask_,t)}},{key:`isScheduled`,get:function(){return ce(this.flags_,e.isScheduledMask_)},set:function(t){this.flags_=le(this.flags_,e.isScheduledMask_,t)}},{key:`isTrackPending`,get:function(){return ce(this.flags_,e.isTrackPendingMask_)},set:function(t){this.flags_=le(this.flags_,e.isTrackPendingMask_,t)}},{key:`isRunning`,get:function(){return ce(this.flags_,e.isRunningMask_)},set:function(t){this.flags_=le(this.flags_,e.isRunningMask_,t)}},{key:`diffValue`,get:function(){return+!!ce(this.flags_,e.diffValueMask_)},set:function(t){this.flags_=le(this.flags_,e.diffValueMask_,t===1)}}])}();Ln.isDisposedMask_=1,Ln.isScheduledMask_=2,Ln.isTrackPendingMask_=4,Ln.isRunningMask_=8,Ln.diffValueMask_=16;function Rn(e){return L.globalReactionErrorHandlers.push(e),function(){var t=L.globalReactionErrorHandlers.indexOf(e);t>=0&&L.globalReactionErrorHandlers.splice(t,1)}}var zn=100,Bn=function(e){return e()};function Vn(){L.inBatch>0||L.isRunningReactions||Bn(Hn)}function Hn(){L.isRunningReactions=!0;for(var e=L.pendingReactions,t=0;e.length>0;){++t===zn&&(console.error(`Reaction doesn't converge to a stable state after `+zn+` iterations.`+(` Probably there is a cycle in the reactive function: `+e[0])),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r<i;r++)n[r].runReaction_()}L.isRunningReactions=!1}var z=ee(`Reaction`,Ln);function Un(e){var t=Bn;Bn=function(n){return e(function(){return t(n)})}}function Wn(){return!!L.spyListeners.length}function Gn(e){if(L.spyListeners.length)for(var t=L.spyListeners,n=0,r=t.length;n<r;n++)t[n](e)}function Kn(e){Gn(he({},e,{spyReportStart:!0}))}var qn={type:`report-end`,spyReportEnd:!0};function Jn(e){Gn(e?he({},e,{type:`report-end`,spyReportEnd:!0}):qn)}function Yn(e){return L.spyListeners.push(e),g(function(){L.spyListeners=L.spyListeners.filter(function(t){return t!==e})})}var Xn=`action`,Zn=`action.bound`,Qn=`autoAction`,$n=`autoAction.bound`,er=`<unnamed action>`,tr=Ye(Xn),nr=Ye(Zn,{bound:!0}),rr=Ye(Qn,{autoAction:!0}),ir=Ye($n,{autoAction:!0,bound:!0});function ar(e){return function(t,r){if(v(t))return Wt(t.name||er,t,e);if(v(r))return Wt(t,r,e);if(ke(r))return(e?rr:tr).decorate_20223_(t,r);if(y(r))return Ee(t,r,e?rr:tr);if(y(t))return Te(Ye(e?Qn:Xn,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}var or=ar(!1);Object.assign(or,tr);var sr=ar(!0);Object.assign(sr,rr),or.bound=Te(nr),sr.bound=Te(ir);function cr(e){return Gt(e.name||er,!1,e,this,void 0)}function lr(e){return v(e)&&e.isMobxAction===!0}function ur(e,t){var r;t===void 0&&(t=u),v(e)||n(`Autorun expects a function as first argument`),lr(e)&&n(`Autorun does not accept actions since actions are untrackable`);var i=t?.name??(e.name||`Autorun@`+h()),a=!t.scheduler&&!t.delay,o;if(a)o=new Ln(i,function(){this.track(l)},t.onError,t.requiresObservable);else{var s=fr(t),c=!1;o=new Ln(i,function(){c||(c=!0,s(function(){c=!1,o.isDisposed||o.track(l)}))},t.onError,t.requiresObservable)}function l(){e(o)}return(r=t)!=null&&(r=r.signal)!=null&&r.aborted||o.schedule_(),o.getDisposer_(t?.signal)}var dr=function(e){return e()};function fr(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:dr}function pr(e,t,r){var i;r===void 0&&(r=u),(!v(e)||!v(t))&&n(`First and second argument to reaction should be functions`),x(r)||n(`Third argument of reactions should be an object`);var a=r.name??`Reaction@`+h(),o=or(a,r.onError?mr(r.onError,t):t),s=!r.scheduler&&!r.delay,c=fr(r),l=!0,d=!1,f,p=r.compareStructural?Re.structural:r.equals||Re.default,m=new Ln(a,function(){l||s?g():d||(d=!0,c(g))},r.onError,r.requiresObservable);function g(){if(d=!1,!m.isDisposed){var t=!1,n=f;m.track(function(){var n=Jt(!1,function(){return e(m)});t=l||!p(f,n),f=n}),(l&&r.fireImmediately||!l&&t)&&o(f,n,m),l=!1}}return(i=r)!=null&&(i=i.signal)!=null&&i.aborted||m.schedule_(),m.getDisposer_(r?.signal)}function mr(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}var hr=`onBO`,gr=`onBUO`;function _r(e,t,n){return yr(hr,e,t,n)}function vr(e,t,n){return yr(gr,e,t,n)}function yr(e,t,n,r){var i=typeof r==`function`?pa(t,n):pa(t),a=v(r)?r:n,o=e+`L`;return i[o]?i[o].add(a):i[o]=new Set([a]),function(){var e=i[o];e&&(e.delete(a),e.size===0&&delete i[o])}}var br=`never`,xr=`always`,Sr=`observed`;function Cr(e){e.isolateGlobalState===!0&&Sn();var t=e.useProxies,n=e.enforceActions;if(t!==void 0&&(L.useProxies=t===xr?!0:t===br?!1:typeof Proxy<`u`),t===`ifavailable`&&(L.verifyProxies=!0),n!==void 0){var r=n===xr?xr:n===Sr;L.enforceActions=r,L.allowStateChanges=!(r===!0||r===xr)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(function(t){t in e&&(L[t]=!!e[t])}),L.allowStateReads=!L.observableRequiresReaction,L.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&Un(e.reactionScheduler)}function wr(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),Vi(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),x(t)||n(`'extendObservable' only accepts plain objects as second argument`),(Kr(t)||Kr(r))&&n(`Extending an object with another observable (object) is not supported`);var a=se(t);return ga(function(){var t=Zi(e,i)[k];D(a).forEach(function(e){t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Tr(e,t){return Er(pa(e,t))}function Er(e){var t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=kr(e.observing_).map(Er)),t}function Dr(e,t){return Or(pa(e,t))}function Or(e){var t={name:e.name_};return Tn(e)&&(t.observers=Array.from(En(e)).map(Or)),t}function kr(e){return Array.from(new Set(e))}var Ar=0,jr=function(e){function t(){var n=e.call(this,`FLOW_CANCELLED`)||this;return Object.setPrototypeOf(n,(this instanceof t?this.constructor:void 0).prototype),n.name=`FlowCancellationError`,n}_e(t,e);var n=t.prototype;return n.toString=function(){return`Error: `+this.message},t}(Ce(Error));function Mr(e){return e instanceof jr}var Nr=tt(`flow`),Pr=tt(`flow.bound`,{bound:!0}),Fr=Object.assign(function(e,t){if(ke(t))return Nr.decorate_20223_(e,t);if(y(t))return Ee(e,t,Nr);arguments.length!==1&&n(`Flow expects single argument with generator function`);var r=e,i=r.name||`<unnamed flow>`,a=function(){var e=this,t=arguments,n=++Ar,a=or(i+` - runid: `+n+` - init`,r).apply(e,t),o,s=void 0,c=new Promise(function(e,t){var r=0;o=t;function c(e){s=void 0;var o;try{o=or(i+` - runid: `+n+` - yield `+ r++,a.next).call(a,e)}catch(e){return t(e)}u(o)}function l(e){s=void 0;var o;try{o=or(i+` - runid: `+n+` - yield `+ r++,a.throw).call(a,e)}catch(e){return t(e)}u(o)}function u(n){if(v(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=or(i+` - runid: `+n+` - cancel`,function(){try{s&&Ir(s);var e=a.return(void 0),t=Promise.resolve(e.value);t.then(_,_),Ir(t),o(new jr)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},Nr);Fr.bound=Te(Pr);function Ir(e){v(e.cancel)&&e.cancel()}function Lr(e){return e}function Rr(e){return e?.isMobXFlow===!0}function zr(e,t,r){var i;if(Vi(e)||Ii(e)||$t(e))i=ma(e);else if(ea(e)){if(!y(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=ma(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,function(){i.dehancer=void 0}):n(`An intercept reader was already established`)}function Br(e,t,n){return v(n)?Hr(e,t,n):Vr(e,t)}function Vr(e,t){return ma(e).intercept_(t)}function Hr(e,t,n){return ma(e,t).intercept_(n)}function Ur(e,t){return t===void 0?tn(e):ea(e)===!1||!e[k].values_.has(t)?!1:tn(pa(e,t))}function B(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):Ur(e)}function Wr(e,t){return y(t)?Ur(e,t):n(`isComputed expected a property name as second argument`)}function Gr(e,t){return e?t===void 0?ea(e)||!!e[k]||Me(e)||z(e)||tn(e):Vi(e)||Ii(e)?n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`):ea(e)?e[k].values_.has(t):!1:!1}function Kr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),Gr(e)}function qr(e,t){return y(t)?Gr(e,t):n(`expected a property name as second argument`)}function Jr(e){if(ea(e))return e[k].keys_();if(Vi(e)||Ki(e))return Array.from(e.keys());if(Ii(e))return e.map(function(e,t){return t});n(5)}function Yr(e){if(ea(e))return Jr(e).map(function(t){return e[t]});if(Vi(e))return Jr(e).map(function(t){return e.get(t)});if(Ki(e))return Array.from(e.values());if(Ii(e))return e.slice();n(6)}function Xr(e){if(ea(e))return Jr(e).map(function(t){return[t,e[t]]});if(Vi(e))return Jr(e).map(function(t){return[t,e.get(t)]});if(Ki(e))return Array.from(e.entries());if(Ii(e))return e.map(function(e,t){return[t,e]});n(7)}function Zr(e,t,r){if(arguments.length===2&&!Ki(e)){An();var i=t;try{for(var a in i)Zr(e,a,i[a])}finally{jn()}return}ea(e)?e[k].set_(t,r):Vi(e)?e.set(t,r):Ki(e)?e.add(t):Ii(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(`Invalid index: '`+t+`'`),An(),t>=e.length&&(e.length=t+1),e[t]=r,jn()):n(8)}function Qr(e,t){ea(e)?e[k].delete_(t):Vi(e)||Ki(e)?e.delete(t):Ii(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function $r(e,t){if(ea(e))return e[k].has_(t);if(Vi(e)||Ki(e))return e.has(t);if(Ii(e))return t>=0&&t<e.length;n(10)}function ei(e,t){if($r(e,t)){if(ea(e))return e[k].get_(t);if(Vi(e))return e.get(t);if(Ii(e))return e[t];n(11)}}function ti(e,t,r){if(ea(e))return e[k].defineProperty_(t,r);n(39)}function ni(e){if(ea(e))return e[k].ownKeys_();n(38)}function ri(e,t,n,r){return v(n)?ii(e,t,n,r):V(e,t,n)}function V(e,t,n){return ma(e).observe_(t,n)}function ii(e,t,n,r){return ma(e,t).observe_(n,r)}function ai(e,t,n){return e.set(t,n),n}function oi(e,t){if(typeof e!=`object`||!e||e instanceof Date||!Kr(e))return e;if($t(e)||tn(e))return oi(e.get(),t);if(t.has(e))return t.get(e);if(Ii(e)){var n=ai(t,e,Array(e.length));return e.forEach(function(e,r){n[r]=oi(e,t)}),n}if(Ki(e)){var r=ai(t,e,new Set);return e.forEach(function(e){r.add(oi(e,t))}),r}if(Vi(e)){var i=ai(t,e,new Map);return e.forEach(function(e,n){i.set(n,oi(e,t))}),i}else{var a=ai(t,e,{});return ni(e).forEach(function(n){c.propertyIsEnumerable.call(e,n)&&(a[n]=oi(e[n],t))}),a}}function si(e,t){return t&&n(`toJS no longer supports options`),oi(e,new Map)}function ci(){var e=!1,t=[...arguments];typeof t[t.length-1]==`boolean`&&(e=t.pop());var r=li(t);if(!r)return n(`'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly`);r.isTracing_===nn.NONE&&console.log(`[mobx.trace] '`+r.name_+`' tracing enabled`),r.isTracing_=e?nn.BREAK:nn.LOG}function li(e){switch(e.length){case 0:return L.trackingDerivation;case 1:return pa(e[0]);case 2:return pa(e[0],e[1])}}function ui(e,t){t===void 0&&(t=void 0),An();try{return e.apply(t)}finally{jn()}}function di(e,t,n){return arguments.length===1||t&&typeof t==`object`?pi(e,t):fi(e,t,n||{})}function fi(e,t,n){var r;if(typeof n.timeout==`number`){var i=Error(`WHEN_TIMEOUT`);r=setTimeout(function(){if(!o[k].isDisposed)if(o(),n.onError)n.onError(i);else throw i},n.timeout)}n.name=n.name||`When@`+h();var a=Wt(n.name+`-effect`,t),o=ur(function(t){Jt(!1,e)&&(t.dispose(),r&&clearTimeout(r),a())},n);return o}function pi(e,t){var r;if(t&&t.onError)return n(`the options 'onError' and 'promise' cannot be combined`);if(t!=null&&(r=t.signal)!=null&&r.aborted)return Object.assign(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:function(){return null}});var i,a,o=new Promise(function(n,r){var o,s=fi(e,n,he({},t,{onError:r}));i=function(){s(),r(Error(`WHEN_CANCELLED`))},a=function(){s(),r(Error(`WHEN_ABORTED`))},t==null||(o=t.signal)==null||o.addEventListener==null||o.addEventListener(`abort`,a)}).finally(function(){var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,a)});return o.cancel=i,o}function mi(e){return e[k]}var hi={has:function(e,t){return L.trackingDerivation&&m(`detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.`),mi(e).has_(t)},get:function(e,t){return mi(e).get_(t)},set:function(e,t,n){return y(t)?(mi(e).values_.has(t)||m(`add a new observable property through direct assignment. Use 'set' from 'mobx' instead.`),mi(e).set_(t,n,!0)??!0):!1},deleteProperty:function(e,t){return m(`delete properties from an observable object. Use 'remove' from 'mobx' instead.`),y(t)?mi(e).delete_(t,!0)??!0:!1},defineProperty:function(e,t,n){return m(`define property on an observable object. Use 'defineProperty' from 'mobx' instead.`),mi(e).defineProperty_(t,n)??!0},ownKeys:function(e){return L.trackingDerivation&&m(`iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.`),mi(e).ownKeys_()},preventExtensions:function(e){n(13)}};function gi(e,t){var n;return p(),e=Zi(e,t),(n=e[k]).proxy_??(n.proxy_=new Proxy(e,hi))}function _i(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function vi(e,t){var n=e.interceptors_||=[];return n.push(t),g(function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function yi(e,t){var r=I();try{for(var i=[].concat(e.interceptors_||[]),a=0,o=i.length;a<o&&(t=i[a](t),t&&!t.type&&n(14),t);a++);return t}finally{mn(r)}}function bi(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function xi(e,t){var n=e.changeListeners_||=[];return n.push(t),g(function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function Si(e,t){var n=I(),r=e.changeListeners_;if(r){r=r.slice();for(var i=0,a=r.length;i<a;i++)r[i](t);mn(n)}}function Ci(e,t,r){return ga(function(){var i=Zi(e,r)[k];t&&e[we]&&n(`makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.`),t??=Oe(e),D(t).forEach(function(e){return i.make_(e,t[e])})}),e}var wi=Symbol(`mobx-keys`);function Ti(e,t,r){return!x(e)&&!x(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),ea(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),x(e)?wr(e,e,t,r):(ga(function(){var n=Zi(e,r)[k];if(!e[wi]){var i=Object.getPrototypeOf(e),a=new Set([].concat(D(e),D(i)));a.delete(`constructor`),a.delete(k),C(i,wi,a)}e[wi].forEach(function(e){return n.make_(e,t&&e in t?t[e]:!0)})}),e)}var Ei=`splice`,Di=`update`,Oi=1e4,ki={get:function(e,t){var n=e[k];return t===k?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):oe(H,t)?H[t]:e[t]},set:function(e,t,n){var r=e[k];return t===`length`&&r.setArrayLength_(n),typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions:function(){n(15)}},Ai=function(){function e(e,t,n,r){e===void 0&&(e=`ObservableArray@`+h()),this.owned_=void 0,this.legacyMode_=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.legacyMode_=r,this.atom_=new je(e),this.enhancer_=function(n,r){return t(n,r,e+`[..]`)}}var t=e.prototype;return t.dehanceValue_=function(e){return this.dehancer===void 0?e:this.dehancer(e)},t.dehanceValues_=function(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e},t.intercept_=function(e){return vi(this,e)},t.observe_=function(e,t){return t===void 0&&(t=!1),t&&e({observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:`splice`,index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),xi(this,e)},t.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},t.setArrayLength_=function(e){(typeof e!=`number`||isNaN(e)||e<0)&&n(`Out of range: `+e);var t=this.values_.length;if(e!==t)if(e>t){for(var r=Array(e-t),i=0;i<e-t;i++)r[i]=void 0;this.spliceWithArray_(t,0,r)}else this.spliceWithArray_(e,t-e)},t.updateArrayLength_=function(e,t){e!==this.lastKnownLength_&&n(16),this.lastKnownLength_+=t,this.legacyMode_&&t>0&&da(e+t+1)},t.spliceWithArray_=function(e,t,n){var r=this;cn(this.atom_);var i=this.values_.length;if(e===void 0?e=0:e>i?e=i:e<0&&(e=Math.max(0,i+e)),t=arguments.length===1?i-e:t==null?0:Math.max(0,Math.min(t,i-e)),n===void 0&&(n=l),_i(this)){var a=yi(this,{object:this.proxy_,type:Ei,index:e,removedCount:t,added:n});if(!a)return l;t=a.removedCount,n=a.added}if(n=n.length===0?n:n.map(function(e){return r.enhancer_(e,void 0)}),this.legacyMode_||!0){var o=n.length-t;this.updateArrayLength_(i,o)}var s=this.spliceItemsIntoValues_(e,t,n);return(t!==0||n.length!==0)&&this.notifyArraySplice_(e,n,s),this.dehanceValues_(s)},t.spliceItemsIntoValues_=function(e,t,n){if(n.length<Oi){var r;return(r=this.values_).splice.apply(r,[e,t].concat(n))}else{var i=this.values_.slice(e,e+t),a=this.values_.slice(e+t);this.values_.length+=n.length-t;for(var o=0;o<n.length;o++)this.values_[e+o]=n[o];for(var s=0;s<a.length;s++)this.values_[e+n.length+s]=a[s];return i}},t.notifyArrayChildUpdate_=function(e,t,n){var r=!this.owned_&&Wn(),i=bi(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:Di,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&Kn(a),this.atom_.reportChanged(),i&&Si(this,a),r&&Jn()},t.notifyArraySplice_=function(e,t,n){var r=!this.owned_&&Wn(),i=bi(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:Ei,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&Kn(a),this.atom_.reportChanged(),i&&Si(this,a),r&&Jn()},t.get_=function(e){if(this.legacyMode_&&e>=this.values_.length){console.warn(`[mobx.array] Attempt to read an array index (`+e+`) that is out of bounds (`+this.values_.length+`). Please check length first. Out of bound indices will not be tracked by MobX`);return}return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])},t.set_=function(e,t){var r=this.values_;if(this.legacyMode_&&e>r.length&&n(17,e,r.length),e<r.length){cn(this.atom_);var i=r[e];if(_i(this)){var a=yi(this,{type:Di,object:this.proxy_,index:e,newValue:t});if(!a)return;t=a.newValue}t=this.enhancer_(t,i),t!==i&&(r[e]=t,this.notifyArrayChildUpdate_(e,t,i))}else{for(var o=Array(e+1-r.length),s=0;s<o.length-1;s++)o[s]=void 0;o[o.length-1]=t,this.spliceWithArray_(r.length,0,o)}},e}();function ji(e,t,n,r){return n===void 0&&(n=`ObservableArray@`+h()),r===void 0&&(r=!1),p(),ga(function(){var i=new Ai(n,t,r,!1);w(i.values_,k,i);var a=new Proxy(i.values_,ki);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var H={clear:function(){return this.splice(0)},replace:function(e){var t=this[k];return t.spliceWithArray_(0,t.values_.length,e)},toJSON:function(){return this.slice()},splice:function(e,t){var n=[...arguments].slice(2),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:function(e,t,n){return this[k].spliceWithArray_(e,t,n)},push:function(){var e=this[k],t=[...arguments];return e.spliceWithArray_(e.values_.length,0,t),e.values_.length},pop:function(){return this.splice(Math.max(this[k].values_.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){var e=this[k],t=[...arguments];return e.spliceWithArray_(0,0,t),e.values_.length},reverse:function(){return L.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort:function(){L.trackingDerivation&&n(37,`sort`);var e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove:function(e){var t=this[k],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};U(`at`,Mi),U(`concat`,Mi),U(`flat`,Mi),U(`includes`,Mi),U(`indexOf`,Mi),U(`join`,Mi),U(`lastIndexOf`,Mi),U(`slice`,Mi),U(`toString`,Mi),U(`toLocaleString`,Mi),U(`toSorted`,Mi),U(`toSpliced`,Mi),U(`with`,Mi),U(`every`,Ni),U(`filter`,Ni),U(`find`,Ni),U(`findIndex`,Ni),U(`findLast`,Ni),U(`findLastIndex`,Ni),U(`flatMap`,Ni),U(`forEach`,Ni),U(`map`,Ni),U(`some`,Ni),U(`toReversed`,Ni),U(`reduce`,Pi),U(`reduceRight`,Pi);function U(e,t){typeof Array.prototype[e]==`function`&&(H[e]=t(e))}function Mi(e){return function(){var t=this[k];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function Ni(e){return function(t,n){var r=this,i=this[k];return i.atom_.reportObserved(),i.dehanceValues_(i.values_)[e](function(e,i){return t.call(n,e,i,r)})}}function Pi(e){return function(){var t=this,n=this[k];n.atom_.reportObserved();var r=n.dehanceValues_(n.values_),i=arguments[0];return arguments[0]=function(e,n,r){return i(e,n,r,t)},r[e].apply(r,arguments)}}var Fi=ee(`ObservableArrayAdministration`,Ai);function Ii(e){return b(e)&&Fi(e[k])}var Li={},Ri=`add`,zi=`delete`,Bi=function(){function e(e,t,r){var i=this;t===void 0&&(t=ze),r===void 0&&(r=`ObservableMap@`+h()),this.enhancer_=void 0,this.name_=void 0,this[k]=Li,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_=r,v(Map)||n(18),ga(function(){i.keysAtom_=Ne(i.name_+`.keys()`),i.data_=new Map,i.hasMap_=new Map,e&&i.merge(e)})}var t=e.prototype;return t.has_=function(e){return this.data_.has(e)},t.has=function(e){var t=this;if(!L.trackingDerivation)return this.has_(e);var n=this.hasMap_.get(e);if(!n){var r=n=new Qt(this.has_(e),Ve,this.name_+`.`+ie(e)+`?`,!1);this.hasMap_.set(e,r),vr(r,function(){return t.hasMap_.delete(e)})}return n.get()},t.set=function(e,t){var n=this.has_(e);if(_i(this)){var r=yi(this,{type:n?Di:Ri,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this},t.delete=function(e){var t=this;if(cn(this.keysAtom_),_i(this)&&!yi(this,{type:zi,object:this,name:e}))return!1;if(this.has_(e)){var n=Wn(),r=bi(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:zi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return n&&Kn(i),ui(function(){var n;t.keysAtom_.reportChanged(),(n=t.hasMap_.get(e))==null||n.setNewValue_(!1),t.data_.get(e).setNewValue_(void 0),t.data_.delete(e)}),r&&Si(this,i),n&&Jn(),!0}return!1},t.updateValue_=function(e,t){var n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==L.UNCHANGED){var r=Wn(),i=bi(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:Di,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&Kn(a),n.setNewValue_(t),i&&Si(this,a),r&&Jn()}},t.addValue_=function(e,t){var n=this;cn(this.keysAtom_),ui(function(){var r,i=new Qt(t,n.enhancer_,n.name_+`.`+ie(e),!1);n.data_.set(e,i),t=i.value_,(r=n.hasMap_.get(e))==null||r.setNewValue_(!0),n.keysAtom_.reportChanged()});var r=Wn(),i=bi(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:Ri,object:this,name:e,newValue:t}:null;r&&Kn(a),i&&Si(this,a),r&&Jn()},t.get=function(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)},t.dehanceValue_=function(e){return this.dehancer===void 0?e:this.dehancer(e)},t.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},t.values=function(){var e=this,t=this.keys();return Hi({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:e.get(i)}}})},t.entries=function(){var e=this,t=this.keys();return Hi({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},t[Symbol.iterator]=function(){return this.entries()},t.forEach=function(e,t){for(var n=me(this),r;!(r=n()).done;){var i=r.value,a=i[0],o=i[1];e.call(t,o,a,this)}},t.merge=function(e){var t=this;return Vi(e)&&(e=new Map(e)),ui(function(){x(e)?E(e).forEach(function(n){return t.set(n,e[n])}):Array.isArray(e)?e.forEach(function(e){var n=e[0],r=e[1];return t.set(n,r)}):te(e)?(ne(e)||n(19,e),e.forEach(function(e,n){return t.set(n,e)})):e!=null&&n(20,e)}),this},t.clear=function(){var e=this;ui(function(){pn(function(){for(var t=me(e.keys()),n;!(n=t()).done;){var r=n.value;e.delete(r)}})})},t.replace=function(e){var t=this;return ui(function(){for(var n=Ui(e),r=new Map,i=!1,a=me(t.data_.keys()),o;!(o=a()).done;){var s=o.value;if(!n.has(s))if(t.delete(s))i=!0;else{var c=t.data_.get(s);r.set(s,c)}}for(var l=me(n.entries()),u;!(u=l()).done;){var d=u.value,f=d[0],p=d[1],m=t.data_.has(f);if(t.set(f,p),t.data_.has(f)){var h=t.data_.get(f);r.set(f,h),m||(i=!0)}}if(!i)if(t.data_.size!==r.size)t.keysAtom_.reportChanged();else for(var g=t.data_.keys(),_=r.keys(),v=g.next(),y=_.next();!v.done;){if(v.value!==y.value){t.keysAtom_.reportChanged();break}v=g.next(),y=_.next()}t.data_=r}),this},t.toString=function(){return`[object ObservableMap]`},t.toJSON=function(){return Array.from(this)},t.observe_=function(e,t){return t===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps."),xi(this,e)},t.intercept_=function(e){return vi(this,e)},pe(e,[{key:`size`,get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return`Map`}}])}(),Vi=ee(`ObservableMap`,Bi);function Hi(e){return e[Symbol.toStringTag]=`MapIterator`,Sa(e)}function Ui(e){if(te(e)||Vi(e))return e;if(Array.isArray(e))return new Map(e);if(x(e)){var t=new Map;for(var r in e)t.set(r,e[r]);return t}else return n(21,e)}var Wi={},Gi=function(){function e(e,t,r){var i=this;t===void 0&&(t=ze),r===void 0&&(r=`ObservableSet@`+h()),this.name_=void 0,this[k]=Wi,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_=r,v(Set)||n(22),this.enhancer_=function(e,n){return t(e,n,r)},ga(function(){i.atom_=Ne(i.name_),e&&i.replace(e)})}var t=e.prototype;return t.dehanceValue_=function(e){return this.dehancer===void 0?e:this.dehancer(e)},t.clear=function(){var e=this;ui(function(){pn(function(){for(var t=me(e.data_.values()),n;!(n=t()).done;){var r=n.value;e.delete(r)}})})},t.forEach=function(e,t){for(var n=me(this),r;!(r=n()).done;){var i=r.value;e.call(t,i,i,this)}},t.add=function(e){var t=this;if(cn(this.atom_),_i(this)){var n=yi(this,{type:Ri,object:this,newValue:e});if(!n)return this;e=n.newValue}if(!this.has(e)){ui(function(){t.data_.add(t.enhancer_(e,void 0)),t.atom_.reportChanged()});var r=Wn(),i=bi(this),a=i||r?{observableKind:`set`,debugObjectName:this.name_,type:Ri,object:this,newValue:e}:null;r&&Kn(a),i&&Si(this,a),r&&Jn()}return this},t.delete=function(e){var t=this;if(_i(this)&&!yi(this,{type:zi,object:this,oldValue:e}))return!1;if(this.has(e)){var n=Wn(),r=bi(this),i=r||n?{observableKind:`set`,debugObjectName:this.name_,type:zi,object:this,oldValue:e}:null;return n&&Kn(i),ui(function(){t.atom_.reportChanged(),t.data_.delete(e)}),r&&Si(this,i),n&&Jn(),!0}return!1},t.has=function(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))},t.entries=function(){var e=this.values();return qi({next:function(){var t=e.next(),n=t.value,r=t.done;return r?{value:void 0,done:r}:{value:[n,n],done:r}}})},t.keys=function(){return this.values()},t.values=function(){this.atom_.reportObserved();var e=this,t=this.data_.values();return qi({next:function(){var n=t.next(),r=n.value,i=n.done;return i?{value:void 0,done:i}:{value:e.dehanceValue_(r),done:i}}})},t.intersection=function(e){return T(e)&&!Ki(e)?e.intersection(this):new Set(this).intersection(e)},t.union=function(e){return T(e)&&!Ki(e)?e.union(this):new Set(this).union(e)},t.difference=function(e){return new Set(this).difference(e)},t.symmetricDifference=function(e){return T(e)&&!Ki(e)?e.symmetricDifference(this):new Set(this).symmetricDifference(e)},t.isSubsetOf=function(e){return new Set(this).isSubsetOf(e)},t.isSupersetOf=function(e){return new Set(this).isSupersetOf(e)},t.isDisjointFrom=function(e){return T(e)&&!Ki(e)?e.isDisjointFrom(this):new Set(this).isDisjointFrom(e)},t.replace=function(e){var t=this;return Ki(e)&&(e=new Set(e)),ui(function(){Array.isArray(e)||T(e)?(t.clear(),e.forEach(function(e){return t.add(e)})):e!=null&&n(`Cannot initialize set from `+e)}),this},t.observe_=function(e,t){return t===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets."),xi(this,e)},t.intercept_=function(e){return vi(this,e)},t.toJSON=function(){return Array.from(this)},t.toString=function(){return`[object ObservableSet]`},t[Symbol.iterator]=function(){return this.values()},pe(e,[{key:`size`,get:function(){return this.atom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return`Set`}}])}(),Ki=ee(`ObservableSet`,Gi);function qi(e){return e[Symbol.toStringTag]=`SetIterator`,Sa(e)}var Ji=Object.create(null),Yi=`remove`,Xi=function(){function e(e,t,r,i){t===void 0&&(t=new Map),i===void 0&&(i=vt),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.target_=e,this.values_=t,this.name_=r,this.defaultAnnotation_=i,this.keysAtom_=new je(this.name_+`.keys`),this.isPlainObject_=x(this.target_),wa(this.defaultAnnotation_)||n(`defaultAnnotation must be valid annotation`),this.appliedAnnotations_={}}var t=e.prototype;return t.getObservablePropValue_=function(e){return this.values_.get(e).get()},t.setObservablePropValue_=function(e,t){var n=this.values_.get(e);if(n instanceof en)return n.set(t),!0;if(_i(this)){var r=yi(this,{type:Di,object:this.proxy_||this.target_,name:e,newValue:t});if(!r)return null;t=r.newValue}if(t=n.prepareNewValue_(t),t!==L.UNCHANGED){var i=bi(this),a=Wn(),o=i||a?{type:Di,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;a&&Kn(o),n.setNewValue_(t),i&&Si(this,o),a&&Jn()}return!0},t.get_=function(e){return L.trackingDerivation&&!oe(this.target_,e)&&this.has_(e),this.target_[e]},t.set_=function(e,t,n){return n===void 0&&(n=!1),oe(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)},t.has_=function(e){if(!L.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;var t=this.pendingKeys_.get(e);return t||(t=new Qt(e in this.target_,Ve,this.name_+`.`+ie(e)+`?`,!1),this.pendingKeys_.set(e,t)),t.get()},t.make_=function(e,t){if(t===!0&&(t=this.defaultAnnotation_),t!==!1){if(na(this,t,e),!(e in this.target_)){var r;if((r=this.target_[we])!=null&&r[e])return;n(1,t.annotationType_,this.name_+`.`+e.toString())}for(var i=this.target_;i&&i!==c;){var a=o(i,e);if(a){var s=t.make_(this,e,a,i);if(s===0)return;if(s===1)break}i=Object.getPrototypeOf(i)}ta(this,t,e)}},t.extend_=function(e,t,n,r){if(r===void 0&&(r=!1),n===!0&&(n=this.defaultAnnotation_),n===!1)return this.defineProperty_(e,t,r);na(this,n,e);var i=n.extend_(this,e,t,r);return i&&ta(this,n,e),i},t.defineProperty_=function(e,t,n){n===void 0&&(n=!1),cn(this.keysAtom_);try{An();var r=this.delete_(e);if(!r)return r;if(_i(this)){var i=yi(this,{object:this.proxy_||this.target_,name:e,type:Ri,newValue:t.value});if(!i)return null;var a=i.newValue;t.value!==a&&(t=he({},t,{value:a}))}if(n){if(!Reflect.defineProperty(this.target_,e,t))return!1}else s(this.target_,e,t);this.notifyPropertyAddition_(e,t.value)}finally{jn()}return!0},t.defineObservableProperty_=function(e,t,n,r){r===void 0&&(r=!1),cn(this.keysAtom_);try{An();var i=this.delete_(e);if(!i)return i;if(_i(this)){var a=yi(this,{object:this.proxy_||this.target_,name:e,type:Ri,newValue:t});if(!a)return null;t=a.newValue}var o=$i(e),c={configurable:L.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.target_,e,c))return!1}else s(this.target_,e,c);var l=new Qt(t,n,this.name_+`.`+e.toString(),!1);this.values_.set(e,l),this.notifyPropertyAddition_(e,l.value_)}finally{jn()}return!0},t.defineComputedProperty_=function(e,t,n){n===void 0&&(n=!1),cn(this.keysAtom_);try{An();var r=this.delete_(e);if(!r)return r;if(_i(this)&&!yi(this,{object:this.proxy_||this.target_,name:e,type:Ri,newValue:void 0}))return null;t.name||=this.name_+`.`+e.toString(),t.context=this.proxy_||this.target_;var i=$i(e),a={configurable:L.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.target_,e,a))return!1}else s(this.target_,e,a);this.values_.set(e,new en(t)),this.notifyPropertyAddition_(e,void 0)}finally{jn()}return!0},t.delete_=function(e,t){if(t===void 0&&(t=!1),cn(this.keysAtom_),!oe(this.target_,e))return!0;if(_i(this)&&!yi(this,{object:this.proxy_||this.target_,name:e,type:Yi}))return null;try{var n;An();var r=bi(this),i=Wn(),a=this.values_.get(e),s=void 0;if(!a&&(r||i)&&(s=o(this.target_,e)?.value),t){if(!Reflect.deleteProperty(this.target_,e))return!1}else delete this.target_[e];if(delete this.appliedAnnotations_[e],a&&(this.values_.delete(e),a instanceof Qt&&(s=a.value_),Nn(a)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||i){var c={type:Yi,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};i&&Kn(c),r&&Si(this,c),i&&Jn()}}finally{jn()}return!0},t.observe_=function(e,t){return t===!0&&n("`observe` doesn't support the fire immediately property for observable objects."),xi(this,e)},t.intercept_=function(e){return vi(this,e)},t.notifyPropertyAddition_=function(e,t){var n,r=bi(this),i=Wn();if(r||i){var a=r||i?{type:Ri,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,name:e,newValue:t}:null;i&&Kn(a),r&&Si(this,a),i&&Jn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()},t.ownKeys_=function(){return this.keysAtom_.reportObserved(),D(this.target_)},t.keys_=function(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)},e}();function Zi(e,t){if(t&&ea(e)&&n(`Options can't be provided for already observable objects.`),oe(e,k))return ma(e)instanceof Xi||n(`Cannot convert '`+ha(e)+`' into observable object:
81
+ `)()}}function In(e,t,n){if(t.length>=1e3){t.push(`(and many more)`);return}t.push(``+` `.repeat(n-1)+e.name),e.dependencies&&e.dependencies.forEach(function(e){return In(e,t,n+1)})}var Ln=function(){function e(e,t,n,r){e===void 0&&(e=`Reaction@`+h()),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=P.NOT_TRACKING_,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.isTracing_=nn.NONE,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}var t=e.prototype;return t.onBecomeStale_=function(){this.schedule_()},t.schedule_=function(){this.isScheduled||(this.isScheduled=!0,L.pendingReactions.push(this),Vn())},t.runReaction_=function(){if(!this.isDisposed){An(),this.isScheduled=!1;var e=L.trackingContext;if(L.trackingContext=this,on(this)){this.isTrackPending=!0;try{this.onInvalidate_(),this.isTrackPending&&Wn()&&Gn({name:this.name_,type:`scheduled-reaction`})}catch(e){this.reportExceptionInDerivation_(e)}}L.trackingContext=e,jn()}},t.track=function(e){if(!this.isDisposed){An();var t=Wn(),n;t&&(n=Date.now(),Kn({name:this.name_,type:`reaction`})),this.isRunning=!0;var r=L.trackingContext;L.trackingContext=this;var i=F(this,e,void 0);L.trackingContext=r,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&fn(this),an(i)&&this.reportExceptionInDerivation_(i.cause),t&&Jn({time:Date.now()-n}),jn()}},t.reportExceptionInDerivation_=function(e){var t=this;if(this.errorHandler_){this.errorHandler_(e,this);return}if(L.disableErrorBoundaries)throw e;var n=`[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '`+this+`'`;L.suppressReactionErrors?console.warn(`[mobx] (error in reaction '`+this.name_+`' suppressed, fix error of causing action below)`):console.error(n,e),Wn()&&Gn({type:`error`,name:this.name_,message:n,error:``+e}),L.globalReactionErrorHandlers.forEach(function(n){return n(e,t)})},t.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||(An(),fn(this),jn()))},t.getDisposer_=function(e){var t=this,n=function n(){t.dispose(),e==null||e.removeEventListener==null||e.removeEventListener(`abort`,n)};return e==null||e.addEventListener==null||e.addEventListener(`abort`,n),n[k]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(n[Symbol.dispose]=n),n},t.toString=function(){return`Reaction[`+this.name_+`]`},t.trace=function(e){e===void 0&&(e=!1),ci(this,e)},pe(e,[{key:`isDisposed`,get:function(){return ce(this.flags_,e.isDisposedMask_)},set:function(t){this.flags_=le(this.flags_,e.isDisposedMask_,t)}},{key:`isScheduled`,get:function(){return ce(this.flags_,e.isScheduledMask_)},set:function(t){this.flags_=le(this.flags_,e.isScheduledMask_,t)}},{key:`isTrackPending`,get:function(){return ce(this.flags_,e.isTrackPendingMask_)},set:function(t){this.flags_=le(this.flags_,e.isTrackPendingMask_,t)}},{key:`isRunning`,get:function(){return ce(this.flags_,e.isRunningMask_)},set:function(t){this.flags_=le(this.flags_,e.isRunningMask_,t)}},{key:`diffValue`,get:function(){return+!!ce(this.flags_,e.diffValueMask_)},set:function(t){this.flags_=le(this.flags_,e.diffValueMask_,t===1)}}])}();Ln.isDisposedMask_=1,Ln.isScheduledMask_=2,Ln.isTrackPendingMask_=4,Ln.isRunningMask_=8,Ln.diffValueMask_=16;function Rn(e){return L.globalReactionErrorHandlers.push(e),function(){var t=L.globalReactionErrorHandlers.indexOf(e);t>=0&&L.globalReactionErrorHandlers.splice(t,1)}}var zn=100,Bn=function(e){return e()};function Vn(){L.inBatch>0||L.isRunningReactions||Bn(Hn)}function Hn(){L.isRunningReactions=!0;for(var e=L.pendingReactions,t=0;e.length>0;){++t===zn&&(console.error(`Reaction doesn't converge to a stable state after `+zn+` iterations.`+(` Probably there is a cycle in the reactive function: `+e[0])),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r<i;r++)n[r].runReaction_()}L.isRunningReactions=!1}var z=T(`Reaction`,Ln);function Un(e){var t=Bn;Bn=function(n){return e(function(){return t(n)})}}function Wn(){return!!L.spyListeners.length}function Gn(e){if(L.spyListeners.length)for(var t=L.spyListeners,n=0,r=t.length;n<r;n++)t[n](e)}function Kn(e){Gn(he({},e,{spyReportStart:!0}))}var qn={type:`report-end`,spyReportEnd:!0};function Jn(e){Gn(e?he({},e,{type:`report-end`,spyReportEnd:!0}):qn)}function Yn(e){return L.spyListeners.push(e),g(function(){L.spyListeners=L.spyListeners.filter(function(t){return t!==e})})}var Xn=`action`,Zn=`action.bound`,Qn=`autoAction`,$n=`autoAction.bound`,er=`<unnamed action>`,tr=Ye(Xn),nr=Ye(Zn,{bound:!0}),rr=Ye(Qn,{autoAction:!0}),ir=Ye($n,{autoAction:!0,bound:!0});function ar(e){return function(t,r){if(v(t))return Wt(t.name||er,t,e);if(v(r))return Wt(t,r,e);if(ke(r))return(e?rr:tr).decorate_20223_(t,r);if(y(r))return Ee(t,r,e?rr:tr);if(y(t))return Te(Ye(e?Qn:Xn,{name:t,autoAction:e}));n("Invalid arguments for `action`")}}var or=ar(!1);Object.assign(or,tr);var sr=ar(!0);Object.assign(sr,rr),or.bound=Te(nr),sr.bound=Te(ir);function cr(e){return Gt(e.name||er,!1,e,this,void 0)}function lr(e){return v(e)&&e.isMobxAction===!0}function ur(e,t){var r;t===void 0&&(t=u),v(e)||n(`Autorun expects a function as first argument`),lr(e)&&n(`Autorun does not accept actions since actions are untrackable`);var i=t?.name??(e.name||`Autorun@`+h()),a=!t.scheduler&&!t.delay,o;if(a)o=new Ln(i,function(){this.track(l)},t.onError,t.requiresObservable);else{var s=fr(t),c=!1;o=new Ln(i,function(){c||(c=!0,s(function(){c=!1,o.isDisposed||o.track(l)}))},t.onError,t.requiresObservable)}function l(){e(o)}return(r=t)!=null&&(r=r.signal)!=null&&r.aborted||o.schedule_(),o.getDisposer_(t?.signal)}var dr=function(e){return e()};function fr(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:dr}function pr(e,t,r){var i;r===void 0&&(r=u),(!v(e)||!v(t))&&n(`First and second argument to reaction should be functions`),x(r)||n(`Third argument of reactions should be an object`);var a=r.name??`Reaction@`+h(),o=or(a,r.onError?mr(r.onError,t):t),s=!r.scheduler&&!r.delay,c=fr(r),l=!0,d=!1,f,p=r.compareStructural?Re.structural:r.equals||Re.default,m=new Ln(a,function(){l||s?g():d||(d=!0,c(g))},r.onError,r.requiresObservable);function g(){if(d=!1,!m.isDisposed){var t=!1,n=f;m.track(function(){var n=Jt(!1,function(){return e(m)});t=l||!p(f,n),f=n}),(l&&r.fireImmediately||!l&&t)&&o(f,n,m),l=!1}}return(i=r)!=null&&(i=i.signal)!=null&&i.aborted||m.schedule_(),m.getDisposer_(r?.signal)}function mr(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}var hr=`onBO`,gr=`onBUO`;function _r(e,t,n){return yr(hr,e,t,n)}function vr(e,t,n){return yr(gr,e,t,n)}function yr(e,t,n,r){var i=typeof r==`function`?pa(t,n):pa(t),a=v(r)?r:n,o=e+`L`;return i[o]?i[o].add(a):i[o]=new Set([a]),function(){var e=i[o];e&&(e.delete(a),e.size===0&&delete i[o])}}var br=`never`,xr=`always`,Sr=`observed`;function Cr(e){e.isolateGlobalState===!0&&Sn();var t=e.useProxies,n=e.enforceActions;if(t!==void 0&&(L.useProxies=t===xr?!0:t===br?!1:typeof Proxy<`u`),t===`ifavailable`&&(L.verifyProxies=!0),n!==void 0){var r=n===xr?xr:n===Sr;L.enforceActions=r,L.allowStateChanges=!(r===!0||r===xr)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(function(t){t in e&&(L[t]=!!e[t])}),L.allowStateReads=!L.observableRequiresReaction,L.disableErrorBoundaries===!0&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled."),e.reactionScheduler&&Un(e.reactionScheduler)}function wr(e,t,r,i){arguments.length>4&&n(`'extendObservable' expected 2-4 arguments`),typeof e!=`object`&&n(`'extendObservable' expects an object as first argument`),Vi(e)&&n(`'extendObservable' should not be used on maps, use map.merge instead`),x(t)||n(`'extendObservable' only accepts plain objects as second argument`),(Kr(t)||Kr(r))&&n(`Extending an object with another observable (object) is not supported`);var a=se(t);return ga(function(){var t=Zi(e,i)[k];D(a).forEach(function(e){t.extend_(e,a[e],r&&e in r?r[e]:!0)})}),e}function Tr(e,t){return Er(pa(e,t))}function Er(e){var t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=kr(e.observing_).map(Er)),t}function Dr(e,t){return Or(pa(e,t))}function Or(e){var t={name:e.name_};return Tn(e)&&(t.observers=Array.from(En(e)).map(Or)),t}function kr(e){return Array.from(new Set(e))}var Ar=0,jr=function(e){function t(){var n=e.call(this,`FLOW_CANCELLED`)||this;return Object.setPrototypeOf(n,(this instanceof t?this.constructor:void 0).prototype),n.name=`FlowCancellationError`,n}_e(t,e);var n=t.prototype;return n.toString=function(){return`Error: `+this.message},t}(Ce(Error));function Mr(e){return e instanceof jr}var Nr=tt(`flow`),Pr=tt(`flow.bound`,{bound:!0}),Fr=Object.assign(function(e,t){if(ke(t))return Nr.decorate_20223_(e,t);if(y(t))return Ee(e,t,Nr);arguments.length!==1&&n(`Flow expects single argument with generator function`);var r=e,i=r.name||`<unnamed flow>`,a=function(){var e=this,t=arguments,n=++Ar,a=or(i+` - runid: `+n+` - init`,r).apply(e,t),o,s=void 0,c=new Promise(function(e,t){var r=0;o=t;function c(e){s=void 0;var o;try{o=or(i+` - runid: `+n+` - yield `+ r++,a.next).call(a,e)}catch(e){return t(e)}u(o)}function l(e){s=void 0;var o;try{o=or(i+` - runid: `+n+` - yield `+ r++,a.throw).call(a,e)}catch(e){return t(e)}u(o)}function u(n){if(v(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=or(i+` - runid: `+n+` - cancel`,function(){try{s&&Ir(s);var e=a.return(void 0),t=Promise.resolve(e.value);t.then(_,_),Ir(t),o(new jr)}catch(e){o(e)}}),c};return a.isMobXFlow=!0,a},Nr);Fr.bound=Te(Pr);function Ir(e){v(e.cancel)&&e.cancel()}function Lr(e){return e}function Rr(e){return e?.isMobXFlow===!0}function zr(e,t,r){var i;if(Vi(e)||Ii(e)||$t(e))i=ma(e);else if(ea(e)){if(!y(t))return n(`InterceptReads can only be used with a specific property, not with an object in general`);i=ma(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,function(){i.dehancer=void 0}):n(`An intercept reader was already established`)}function Br(e,t,n){return v(n)?Hr(e,t,n):Vr(e,t)}function Vr(e,t){return ma(e).intercept_(t)}function Hr(e,t,n){return ma(e,t).intercept_(n)}function Ur(e,t){return t===void 0?tn(e):ea(e)===!1||!e[k].values_.has(t)?!1:tn(pa(e,t))}function B(e){return arguments.length>1?n(`isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`):Ur(e)}function Wr(e,t){return y(t)?Ur(e,t):n(`isComputed expected a property name as second argument`)}function Gr(e,t){return e?t===void 0?ea(e)||!!e[k]||Me(e)||z(e)||tn(e):Vi(e)||Ii(e)?n(`isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.`):ea(e)?e[k].values_.has(t):!1:!1}function Kr(e){return arguments.length!==1&&n(`isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`),Gr(e)}function qr(e,t){return y(t)?Gr(e,t):n(`expected a property name as second argument`)}function Jr(e){if(ea(e))return e[k].keys_();if(Vi(e)||Ki(e))return Array.from(e.keys());if(Ii(e))return e.map(function(e,t){return t});n(5)}function Yr(e){if(ea(e))return Jr(e).map(function(t){return e[t]});if(Vi(e))return Jr(e).map(function(t){return e.get(t)});if(Ki(e))return Array.from(e.values());if(Ii(e))return e.slice();n(6)}function Xr(e){if(ea(e))return Jr(e).map(function(t){return[t,e[t]]});if(Vi(e))return Jr(e).map(function(t){return[t,e.get(t)]});if(Ki(e))return Array.from(e.entries());if(Ii(e))return e.map(function(e,t){return[t,e]});n(7)}function Zr(e,t,r){if(arguments.length===2&&!Ki(e)){An();var i=t;try{for(var a in i)Zr(e,a,i[a])}finally{jn()}return}ea(e)?e[k].set_(t,r):Vi(e)?e.set(t,r):Ki(e)?e.add(t):Ii(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&n(`Invalid index: '`+t+`'`),An(),t>=e.length&&(e.length=t+1),e[t]=r,jn()):n(8)}function Qr(e,t){ea(e)?e[k].delete_(t):Vi(e)||Ki(e)?e.delete(t):Ii(e)?(typeof t!=`number`&&(t=parseInt(t,10)),e.splice(t,1)):n(9)}function $r(e,t){if(ea(e))return e[k].has_(t);if(Vi(e)||Ki(e))return e.has(t);if(Ii(e))return t>=0&&t<e.length;n(10)}function ei(e,t){if($r(e,t)){if(ea(e))return e[k].get_(t);if(Vi(e))return e.get(t);if(Ii(e))return e[t];n(11)}}function ti(e,t,r){if(ea(e))return e[k].defineProperty_(t,r);n(39)}function ni(e){if(ea(e))return e[k].ownKeys_();n(38)}function ri(e,t,n,r){return v(n)?ii(e,t,n,r):V(e,t,n)}function V(e,t,n){return ma(e).observe_(t,n)}function ii(e,t,n,r){return ma(e,t).observe_(n,r)}function ai(e,t,n){return e.set(t,n),n}function oi(e,t){if(typeof e!=`object`||!e||e instanceof Date||!Kr(e))return e;if($t(e)||tn(e))return oi(e.get(),t);if(t.has(e))return t.get(e);if(Ii(e)){var n=ai(t,e,Array(e.length));return e.forEach(function(e,r){n[r]=oi(e,t)}),n}if(Ki(e)){var r=ai(t,e,new Set);return e.forEach(function(e){r.add(oi(e,t))}),r}if(Vi(e)){var i=ai(t,e,new Map);return e.forEach(function(e,n){i.set(n,oi(e,t))}),i}else{var a=ai(t,e,{});return ni(e).forEach(function(n){c.propertyIsEnumerable.call(e,n)&&(a[n]=oi(e[n],t))}),a}}function si(e,t){return t&&n(`toJS no longer supports options`),oi(e,new Map)}function ci(){var e=!1,t=[...arguments];typeof t[t.length-1]==`boolean`&&(e=t.pop());var r=li(t);if(!r)return n(`'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly`);r.isTracing_===nn.NONE&&console.log(`[mobx.trace] '`+r.name_+`' tracing enabled`),r.isTracing_=e?nn.BREAK:nn.LOG}function li(e){switch(e.length){case 0:return L.trackingDerivation;case 1:return pa(e[0]);case 2:return pa(e[0],e[1])}}function ui(e,t){t===void 0&&(t=void 0),An();try{return e.apply(t)}finally{jn()}}function di(e,t,n){return arguments.length===1||t&&typeof t==`object`?pi(e,t):fi(e,t,n||{})}function fi(e,t,n){var r;if(typeof n.timeout==`number`){var i=Error(`WHEN_TIMEOUT`);r=setTimeout(function(){if(!o[k].isDisposed)if(o(),n.onError)n.onError(i);else throw i},n.timeout)}n.name=n.name||`When@`+h();var a=Wt(n.name+`-effect`,t),o=ur(function(t){Jt(!1,e)&&(t.dispose(),r&&clearTimeout(r),a())},n);return o}function pi(e,t){var r;if(t&&t.onError)return n(`the options 'onError' and 'promise' cannot be combined`);if(t!=null&&(r=t.signal)!=null&&r.aborted)return Object.assign(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:function(){return null}});var i,a,o=new Promise(function(n,r){var o,s=fi(e,n,he({},t,{onError:r}));i=function(){s(),r(Error(`WHEN_CANCELLED`))},a=function(){s(),r(Error(`WHEN_ABORTED`))},t==null||(o=t.signal)==null||o.addEventListener==null||o.addEventListener(`abort`,a)}).finally(function(){var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,a)});return o.cancel=i,o}function mi(e){return e[k]}var hi={has:function(e,t){return L.trackingDerivation&&m(`detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.`),mi(e).has_(t)},get:function(e,t){return mi(e).get_(t)},set:function(e,t,n){return y(t)?(mi(e).values_.has(t)||m(`add a new observable property through direct assignment. Use 'set' from 'mobx' instead.`),mi(e).set_(t,n,!0)??!0):!1},deleteProperty:function(e,t){return m(`delete properties from an observable object. Use 'remove' from 'mobx' instead.`),y(t)?mi(e).delete_(t,!0)??!0:!1},defineProperty:function(e,t,n){return m(`define property on an observable object. Use 'defineProperty' from 'mobx' instead.`),mi(e).defineProperty_(t,n)??!0},ownKeys:function(e){return L.trackingDerivation&&m(`iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.`),mi(e).ownKeys_()},preventExtensions:function(e){n(13)}};function gi(e,t){var n;return p(),e=Zi(e,t),(n=e[k]).proxy_??(n.proxy_=new Proxy(e,hi))}function _i(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function vi(e,t){var n=e.interceptors_||=[];return n.push(t),g(function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function yi(e,t){var r=I();try{for(var i=[].concat(e.interceptors_||[]),a=0,o=i.length;a<o&&(t=i[a](t),t&&!t.type&&n(14),t);a++);return t}finally{mn(r)}}function bi(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function xi(e,t){var n=e.changeListeners_||=[];return n.push(t),g(function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function Si(e,t){var n=I(),r=e.changeListeners_;if(r){r=r.slice();for(var i=0,a=r.length;i<a;i++)r[i](t);mn(n)}}function Ci(e,t,r){return ga(function(){var i=Zi(e,r)[k];t&&e[we]&&n(`makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.`),t??=Oe(e),D(t).forEach(function(e){return i.make_(e,t[e])})}),e}var wi=Symbol(`mobx-keys`);function Ti(e,t,r){return!x(e)&&!x(Object.getPrototypeOf(e))&&n(`'makeAutoObservable' can only be used for classes that don't have a superclass`),ea(e)&&n(`makeAutoObservable can only be used on objects not already made observable`),x(e)?wr(e,e,t,r):(ga(function(){var n=Zi(e,r)[k];if(!e[wi]){var i=Object.getPrototypeOf(e),a=new Set([].concat(D(e),D(i)));a.delete(`constructor`),a.delete(k),C(i,wi,a)}e[wi].forEach(function(e){return n.make_(e,t&&e in t?t[e]:!0)})}),e)}var Ei=`splice`,Di=`update`,Oi=1e4,ki={get:function(e,t){var n=e[k];return t===k?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):oe(H,t)?H[t]:e[t]},set:function(e,t,n){var r=e[k];return t===`length`&&r.setArrayLength_(n),typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions:function(){n(15)}},Ai=function(){function e(e,t,n,r){e===void 0&&(e=`ObservableArray@`+h()),this.owned_=void 0,this.legacyMode_=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.legacyMode_=r,this.atom_=new je(e),this.enhancer_=function(n,r){return t(n,r,e+`[..]`)}}var t=e.prototype;return t.dehanceValue_=function(e){return this.dehancer===void 0?e:this.dehancer(e)},t.dehanceValues_=function(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e},t.intercept_=function(e){return vi(this,e)},t.observe_=function(e,t){return t===void 0&&(t=!1),t&&e({observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:`splice`,index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),xi(this,e)},t.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},t.setArrayLength_=function(e){(typeof e!=`number`||isNaN(e)||e<0)&&n(`Out of range: `+e);var t=this.values_.length;if(e!==t)if(e>t){for(var r=Array(e-t),i=0;i<e-t;i++)r[i]=void 0;this.spliceWithArray_(t,0,r)}else this.spliceWithArray_(e,t-e)},t.updateArrayLength_=function(e,t){e!==this.lastKnownLength_&&n(16),this.lastKnownLength_+=t,this.legacyMode_&&t>0&&da(e+t+1)},t.spliceWithArray_=function(e,t,n){var r=this;cn(this.atom_);var i=this.values_.length;if(e===void 0?e=0:e>i?e=i:e<0&&(e=Math.max(0,i+e)),t=arguments.length===1?i-e:t==null?0:Math.max(0,Math.min(t,i-e)),n===void 0&&(n=l),_i(this)){var a=yi(this,{object:this.proxy_,type:Ei,index:e,removedCount:t,added:n});if(!a)return l;t=a.removedCount,n=a.added}if(n=n.length===0?n:n.map(function(e){return r.enhancer_(e,void 0)}),this.legacyMode_||!0){var o=n.length-t;this.updateArrayLength_(i,o)}var s=this.spliceItemsIntoValues_(e,t,n);return(t!==0||n.length!==0)&&this.notifyArraySplice_(e,n,s),this.dehanceValues_(s)},t.spliceItemsIntoValues_=function(e,t,n){if(n.length<Oi){var r;return(r=this.values_).splice.apply(r,[e,t].concat(n))}else{var i=this.values_.slice(e,e+t),a=this.values_.slice(e+t);this.values_.length+=n.length-t;for(var o=0;o<n.length;o++)this.values_[e+o]=n[o];for(var s=0;s<a.length;s++)this.values_[e+n.length+s]=a[s];return i}},t.notifyArrayChildUpdate_=function(e,t,n){var r=!this.owned_&&Wn(),i=bi(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:Di,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;r&&Kn(a),this.atom_.reportChanged(),i&&Si(this,a),r&&Jn()},t.notifyArraySplice_=function(e,t,n){var r=!this.owned_&&Wn(),i=bi(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:Ei,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&Kn(a),this.atom_.reportChanged(),i&&Si(this,a),r&&Jn()},t.get_=function(e){if(this.legacyMode_&&e>=this.values_.length){console.warn(`[mobx.array] Attempt to read an array index (`+e+`) that is out of bounds (`+this.values_.length+`). Please check length first. Out of bound indices will not be tracked by MobX`);return}return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])},t.set_=function(e,t){var r=this.values_;if(this.legacyMode_&&e>r.length&&n(17,e,r.length),e<r.length){cn(this.atom_);var i=r[e];if(_i(this)){var a=yi(this,{type:Di,object:this.proxy_,index:e,newValue:t});if(!a)return;t=a.newValue}t=this.enhancer_(t,i),t!==i&&(r[e]=t,this.notifyArrayChildUpdate_(e,t,i))}else{for(var o=Array(e+1-r.length),s=0;s<o.length-1;s++)o[s]=void 0;o[o.length-1]=t,this.spliceWithArray_(r.length,0,o)}},e}();function ji(e,t,n,r){return n===void 0&&(n=`ObservableArray@`+h()),r===void 0&&(r=!1),p(),ga(function(){var i=new Ai(n,t,r,!1);w(i.values_,k,i);var a=new Proxy(i.values_,ki);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var H={clear:function(){return this.splice(0)},replace:function(e){var t=this[k];return t.spliceWithArray_(0,t.values_.length,e)},toJSON:function(){return this.slice()},splice:function(e,t){var n=[...arguments].slice(2),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:function(e,t,n){return this[k].spliceWithArray_(e,t,n)},push:function(){var e=this[k],t=[...arguments];return e.spliceWithArray_(e.values_.length,0,t),e.values_.length},pop:function(){return this.splice(Math.max(this[k].values_.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){var e=this[k],t=[...arguments];return e.spliceWithArray_(0,0,t),e.values_.length},reverse:function(){return L.trackingDerivation&&n(37,`reverse`),this.replace(this.slice().reverse()),this},sort:function(){L.trackingDerivation&&n(37,`sort`);var e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove:function(e){var t=this[k],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};U(`at`,Mi),U(`concat`,Mi),U(`flat`,Mi),U(`includes`,Mi),U(`indexOf`,Mi),U(`join`,Mi),U(`lastIndexOf`,Mi),U(`slice`,Mi),U(`toString`,Mi),U(`toLocaleString`,Mi),U(`toSorted`,Mi),U(`toSpliced`,Mi),U(`with`,Mi),U(`every`,Ni),U(`filter`,Ni),U(`find`,Ni),U(`findIndex`,Ni),U(`findLast`,Ni),U(`findLastIndex`,Ni),U(`flatMap`,Ni),U(`forEach`,Ni),U(`map`,Ni),U(`some`,Ni),U(`toReversed`,Ni),U(`reduce`,Pi),U(`reduceRight`,Pi);function U(e,t){typeof Array.prototype[e]==`function`&&(H[e]=t(e))}function Mi(e){return function(){var t=this[k];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function Ni(e){return function(t,n){var r=this,i=this[k];return i.atom_.reportObserved(),i.dehanceValues_(i.values_)[e](function(e,i){return t.call(n,e,i,r)})}}function Pi(e){return function(){var t=this,n=this[k];n.atom_.reportObserved();var r=n.dehanceValues_(n.values_),i=arguments[0];return arguments[0]=function(e,n,r){return i(e,n,r,t)},r[e].apply(r,arguments)}}var Fi=T(`ObservableArrayAdministration`,Ai);function Ii(e){return b(e)&&Fi(e[k])}var Li={},Ri=`add`,zi=`delete`,Bi=function(){function e(e,t,r){var i=this;t===void 0&&(t=ze),r===void 0&&(r=`ObservableMap@`+h()),this.enhancer_=void 0,this.name_=void 0,this[k]=Li,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_=r,v(Map)||n(18),ga(function(){i.keysAtom_=Ne(i.name_+`.keys()`),i.data_=new Map,i.hasMap_=new Map,e&&i.merge(e)})}var t=e.prototype;return t.has_=function(e){return this.data_.has(e)},t.has=function(e){var t=this;if(!L.trackingDerivation)return this.has_(e);var n=this.hasMap_.get(e);if(!n){var r=n=new Qt(this.has_(e),Ve,this.name_+`.`+ie(e)+`?`,!1);this.hasMap_.set(e,r),vr(r,function(){return t.hasMap_.delete(e)})}return n.get()},t.set=function(e,t){var n=this.has_(e);if(_i(this)){var r=yi(this,{type:n?Di:Ri,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this},t.delete=function(e){var t=this;if(cn(this.keysAtom_),_i(this)&&!yi(this,{type:zi,object:this,name:e}))return!1;if(this.has_(e)){var n=Wn(),r=bi(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:zi,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return n&&Kn(i),ui(function(){var n;t.keysAtom_.reportChanged(),(n=t.hasMap_.get(e))==null||n.setNewValue_(!1),t.data_.get(e).setNewValue_(void 0),t.data_.delete(e)}),r&&Si(this,i),n&&Jn(),!0}return!1},t.updateValue_=function(e,t){var n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==L.UNCHANGED){var r=Wn(),i=bi(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:Di,object:this,oldValue:n.value_,name:e,newValue:t}:null;r&&Kn(a),n.setNewValue_(t),i&&Si(this,a),r&&Jn()}},t.addValue_=function(e,t){var n=this;cn(this.keysAtom_),ui(function(){var r,i=new Qt(t,n.enhancer_,n.name_+`.`+ie(e),!1);n.data_.set(e,i),t=i.value_,(r=n.hasMap_.get(e))==null||r.setNewValue_(!0),n.keysAtom_.reportChanged()});var r=Wn(),i=bi(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:Ri,object:this,name:e,newValue:t}:null;r&&Kn(a),i&&Si(this,a),r&&Jn()},t.get=function(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)},t.dehanceValue_=function(e){return this.dehancer===void 0?e:this.dehancer(e)},t.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},t.values=function(){var e=this,t=this.keys();return Hi({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:e.get(i)}}})},t.entries=function(){var e=this,t=this.keys();return Hi({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},t[Symbol.iterator]=function(){return this.entries()},t.forEach=function(e,t){for(var n=me(this),r;!(r=n()).done;){var i=r.value,a=i[0],o=i[1];e.call(t,o,a,this)}},t.merge=function(e){var t=this;return Vi(e)&&(e=new Map(e)),ui(function(){x(e)?E(e).forEach(function(n){return t.set(n,e[n])}):Array.isArray(e)?e.forEach(function(e){var n=e[0],r=e[1];return t.set(n,r)}):ee(e)?(te(e)||n(19,e),e.forEach(function(e,n){return t.set(n,e)})):e!=null&&n(20,e)}),this},t.clear=function(){var e=this;ui(function(){pn(function(){for(var t=me(e.keys()),n;!(n=t()).done;){var r=n.value;e.delete(r)}})})},t.replace=function(e){var t=this;return ui(function(){for(var n=Ui(e),r=new Map,i=!1,a=me(t.data_.keys()),o;!(o=a()).done;){var s=o.value;if(!n.has(s))if(t.delete(s))i=!0;else{var c=t.data_.get(s);r.set(s,c)}}for(var l=me(n.entries()),u;!(u=l()).done;){var d=u.value,f=d[0],p=d[1],m=t.data_.has(f);if(t.set(f,p),t.data_.has(f)){var h=t.data_.get(f);r.set(f,h),m||(i=!0)}}if(!i)if(t.data_.size!==r.size)t.keysAtom_.reportChanged();else for(var g=t.data_.keys(),_=r.keys(),v=g.next(),y=_.next();!v.done;){if(v.value!==y.value){t.keysAtom_.reportChanged();break}v=g.next(),y=_.next()}t.data_=r}),this},t.toString=function(){return`[object ObservableMap]`},t.toJSON=function(){return Array.from(this)},t.observe_=function(e,t){return t===!0&&n("`observe` doesn't support fireImmediately=true in combination with maps."),xi(this,e)},t.intercept_=function(e){return vi(this,e)},pe(e,[{key:`size`,get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return`Map`}}])}(),Vi=T(`ObservableMap`,Bi);function Hi(e){return e[Symbol.toStringTag]=`MapIterator`,Sa(e)}function Ui(e){if(ee(e)||Vi(e))return e;if(Array.isArray(e))return new Map(e);if(x(e)){var t=new Map;for(var r in e)t.set(r,e[r]);return t}else return n(21,e)}var Wi={},Gi=function(){function e(e,t,r){var i=this;t===void 0&&(t=ze),r===void 0&&(r=`ObservableSet@`+h()),this.name_=void 0,this[k]=Wi,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_=r,v(Set)||n(22),this.enhancer_=function(e,n){return t(e,n,r)},ga(function(){i.atom_=Ne(i.name_),e&&i.replace(e)})}var t=e.prototype;return t.dehanceValue_=function(e){return this.dehancer===void 0?e:this.dehancer(e)},t.clear=function(){var e=this;ui(function(){pn(function(){for(var t=me(e.data_.values()),n;!(n=t()).done;){var r=n.value;e.delete(r)}})})},t.forEach=function(e,t){for(var n=me(this),r;!(r=n()).done;){var i=r.value;e.call(t,i,i,this)}},t.add=function(e){var t=this;if(cn(this.atom_),_i(this)){var n=yi(this,{type:Ri,object:this,newValue:e});if(!n)return this;e=n.newValue}if(!this.has(e)){ui(function(){t.data_.add(t.enhancer_(e,void 0)),t.atom_.reportChanged()});var r=Wn(),i=bi(this),a=i||r?{observableKind:`set`,debugObjectName:this.name_,type:Ri,object:this,newValue:e}:null;r&&Kn(a),i&&Si(this,a),r&&Jn()}return this},t.delete=function(e){var t=this;if(_i(this)&&!yi(this,{type:zi,object:this,oldValue:e}))return!1;if(this.has(e)){var n=Wn(),r=bi(this),i=r||n?{observableKind:`set`,debugObjectName:this.name_,type:zi,object:this,oldValue:e}:null;return n&&Kn(i),ui(function(){t.atom_.reportChanged(),t.data_.delete(e)}),r&&Si(this,i),n&&Jn(),!0}return!1},t.has=function(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))},t.entries=function(){var e=this.values();return qi({next:function(){var t=e.next(),n=t.value,r=t.done;return r?{value:void 0,done:r}:{value:[n,n],done:r}}})},t.keys=function(){return this.values()},t.values=function(){this.atom_.reportObserved();var e=this,t=this.data_.values();return qi({next:function(){var n=t.next(),r=n.value,i=n.done;return i?{value:void 0,done:i}:{value:e.dehanceValue_(r),done:i}}})},t.intersection=function(e){return ne(e)&&!Ki(e)?e.intersection(this):new Set(this).intersection(e)},t.union=function(e){return ne(e)&&!Ki(e)?e.union(this):new Set(this).union(e)},t.difference=function(e){return new Set(this).difference(e)},t.symmetricDifference=function(e){return ne(e)&&!Ki(e)?e.symmetricDifference(this):new Set(this).symmetricDifference(e)},t.isSubsetOf=function(e){return new Set(this).isSubsetOf(e)},t.isSupersetOf=function(e){return new Set(this).isSupersetOf(e)},t.isDisjointFrom=function(e){return ne(e)&&!Ki(e)?e.isDisjointFrom(this):new Set(this).isDisjointFrom(e)},t.replace=function(e){var t=this;return Ki(e)&&(e=new Set(e)),ui(function(){Array.isArray(e)||ne(e)?(t.clear(),e.forEach(function(e){return t.add(e)})):e!=null&&n(`Cannot initialize set from `+e)}),this},t.observe_=function(e,t){return t===!0&&n("`observe` doesn't support fireImmediately=true in combination with sets."),xi(this,e)},t.intercept_=function(e){return vi(this,e)},t.toJSON=function(){return Array.from(this)},t.toString=function(){return`[object ObservableSet]`},t[Symbol.iterator]=function(){return this.values()},pe(e,[{key:`size`,get:function(){return this.atom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return`Set`}}])}(),Ki=T(`ObservableSet`,Gi);function qi(e){return e[Symbol.toStringTag]=`SetIterator`,Sa(e)}var Ji=Object.create(null),Yi=`remove`,Xi=function(){function e(e,t,r,i){t===void 0&&(t=new Map),i===void 0&&(i=vt),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.target_=e,this.values_=t,this.name_=r,this.defaultAnnotation_=i,this.keysAtom_=new je(this.name_+`.keys`),this.isPlainObject_=x(this.target_),wa(this.defaultAnnotation_)||n(`defaultAnnotation must be valid annotation`),this.appliedAnnotations_={}}var t=e.prototype;return t.getObservablePropValue_=function(e){return this.values_.get(e).get()},t.setObservablePropValue_=function(e,t){var n=this.values_.get(e);if(n instanceof en)return n.set(t),!0;if(_i(this)){var r=yi(this,{type:Di,object:this.proxy_||this.target_,name:e,newValue:t});if(!r)return null;t=r.newValue}if(t=n.prepareNewValue_(t),t!==L.UNCHANGED){var i=bi(this),a=Wn(),o=i||a?{type:Di,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;a&&Kn(o),n.setNewValue_(t),i&&Si(this,o),a&&Jn()}return!0},t.get_=function(e){return L.trackingDerivation&&!oe(this.target_,e)&&this.has_(e),this.target_[e]},t.set_=function(e,t,n){return n===void 0&&(n=!1),oe(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)},t.has_=function(e){if(!L.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;var t=this.pendingKeys_.get(e);return t||(t=new Qt(e in this.target_,Ve,this.name_+`.`+ie(e)+`?`,!1),this.pendingKeys_.set(e,t)),t.get()},t.make_=function(e,t){if(t===!0&&(t=this.defaultAnnotation_),t!==!1){if(na(this,t,e),!(e in this.target_)){var r;if((r=this.target_[we])!=null&&r[e])return;n(1,t.annotationType_,this.name_+`.`+e.toString())}for(var i=this.target_;i&&i!==c;){var a=o(i,e);if(a){var s=t.make_(this,e,a,i);if(s===0)return;if(s===1)break}i=Object.getPrototypeOf(i)}ta(this,t,e)}},t.extend_=function(e,t,n,r){if(r===void 0&&(r=!1),n===!0&&(n=this.defaultAnnotation_),n===!1)return this.defineProperty_(e,t,r);na(this,n,e);var i=n.extend_(this,e,t,r);return i&&ta(this,n,e),i},t.defineProperty_=function(e,t,n){n===void 0&&(n=!1),cn(this.keysAtom_);try{An();var r=this.delete_(e);if(!r)return r;if(_i(this)){var i=yi(this,{object:this.proxy_||this.target_,name:e,type:Ri,newValue:t.value});if(!i)return null;var a=i.newValue;t.value!==a&&(t=he({},t,{value:a}))}if(n){if(!Reflect.defineProperty(this.target_,e,t))return!1}else s(this.target_,e,t);this.notifyPropertyAddition_(e,t.value)}finally{jn()}return!0},t.defineObservableProperty_=function(e,t,n,r){r===void 0&&(r=!1),cn(this.keysAtom_);try{An();var i=this.delete_(e);if(!i)return i;if(_i(this)){var a=yi(this,{object:this.proxy_||this.target_,name:e,type:Ri,newValue:t});if(!a)return null;t=a.newValue}var o=$i(e),c={configurable:L.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.target_,e,c))return!1}else s(this.target_,e,c);var l=new Qt(t,n,this.name_+`.`+e.toString(),!1);this.values_.set(e,l),this.notifyPropertyAddition_(e,l.value_)}finally{jn()}return!0},t.defineComputedProperty_=function(e,t,n){n===void 0&&(n=!1),cn(this.keysAtom_);try{An();var r=this.delete_(e);if(!r)return r;if(_i(this)&&!yi(this,{object:this.proxy_||this.target_,name:e,type:Ri,newValue:void 0}))return null;t.name||=this.name_+`.`+e.toString(),t.context=this.proxy_||this.target_;var i=$i(e),a={configurable:L.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.target_,e,a))return!1}else s(this.target_,e,a);this.values_.set(e,new en(t)),this.notifyPropertyAddition_(e,void 0)}finally{jn()}return!0},t.delete_=function(e,t){if(t===void 0&&(t=!1),cn(this.keysAtom_),!oe(this.target_,e))return!0;if(_i(this)&&!yi(this,{object:this.proxy_||this.target_,name:e,type:Yi}))return null;try{var n;An();var r=bi(this),i=Wn(),a=this.values_.get(e),s=void 0;if(!a&&(r||i)&&(s=o(this.target_,e)?.value),t){if(!Reflect.deleteProperty(this.target_,e))return!1}else delete this.target_[e];if(delete this.appliedAnnotations_[e],a&&(this.values_.delete(e),a instanceof Qt&&(s=a.value_),Nn(a)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||i){var c={type:Yi,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:s,name:e};i&&Kn(c),r&&Si(this,c),i&&Jn()}}finally{jn()}return!0},t.observe_=function(e,t){return t===!0&&n("`observe` doesn't support the fire immediately property for observable objects."),xi(this,e)},t.intercept_=function(e){return vi(this,e)},t.notifyPropertyAddition_=function(e,t){var n,r=bi(this),i=Wn();if(r||i){var a=r||i?{type:Ri,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,name:e,newValue:t}:null;i&&Kn(a),r&&Si(this,a),i&&Jn()}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()},t.ownKeys_=function(){return this.keysAtom_.reportObserved(),D(this.target_)},t.keys_=function(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)},e}();function Zi(e,t){if(t&&ea(e)&&n(`Options can't be provided for already observable objects.`),oe(e,k))return ma(e)instanceof Xi||n(`Cannot convert '`+ha(e)+`' into observable object:
82
82
  The target is already observable of different type.
83
- Extending builtins is not supported.`),e;Object.isExtensible(e)||n(`Cannot make the designated object observable; it is not extensible`);var r=t?.name??(x(e)?`ObservableObject`:e.constructor.name)+`@`+h();return C(e,k,new Xi(e,new Map,String(r),Ft(t))),e}var Qi=ee(`ObservableObjectAdministration`,Xi);function $i(e){return Ji[e]||(Ji[e]={get:function(){return this[k].getObservablePropValue_(e)},set:function(t){return this[k].setObservablePropValue_(e,t)}})}function ea(e){return b(e)?Qi(e[k]):!1}function ta(e,t,n){var r;e.appliedAnnotations_[n]=t,(r=e.target_[we])==null||delete r[n]}function na(e,t,r){if(wa(t)||n(`Cannot annotate '`+e.name_+`.`+r.toString()+`': Invalid annotation.`),!Ge(t)&&oe(e.appliedAnnotations_,r)){var i=e.name_+`.`+r.toString(),a=e.appliedAnnotations_[r].annotationType_,o=t.annotationType_;n(`Cannot apply '`+o+`' to '`+i+`':`+(`
83
+ Extending builtins is not supported.`),e;Object.isExtensible(e)||n(`Cannot make the designated object observable; it is not extensible`);var r=t?.name??(x(e)?`ObservableObject`:e.constructor.name)+`@`+h();return C(e,k,new Xi(e,new Map,String(r),Ft(t))),e}var Qi=T(`ObservableObjectAdministration`,Xi);function $i(e){return Ji[e]||(Ji[e]={get:function(){return this[k].getObservablePropValue_(e)},set:function(t){return this[k].setObservablePropValue_(e,t)}})}function ea(e){return b(e)?Qi(e[k]):!1}function ta(e,t,n){var r;e.appliedAnnotations_[n]=t,(r=e.target_[we])==null||delete r[n]}function na(e,t,r){if(wa(t)||n(`Cannot annotate '`+e.name_+`.`+r.toString()+`': Invalid annotation.`),!Ge(t)&&oe(e.appliedAnnotations_,r)){var i=e.name_+`.`+r.toString(),a=e.appliedAnnotations_[r].annotationType_,o=t.annotationType_;n(`Cannot apply '`+o+`' to '`+i+`':`+(`
84
84
  The field is already annotated with '`+a+`'.`)+`
85
85
  Re-annotating fields is not allowed.
86
- Use 'override' annotation for methods overridden by subclass.`)}}var ra=la(0),ia=function(){var e=!1,t={};return Object.defineProperty(t,`0`,{set:function(){e=!0}}),Object.create(t)[0]=1,e===!1}(),aa=0,oa=function(){};function sa(e,t){Object.setPrototypeOf?Object.setPrototypeOf(e.prototype,t):e.prototype.__proto__===void 0?e.prototype=t:e.prototype.__proto__=t}sa(oa,Array.prototype);var ca=function(e){function t(t,n,r,i){var a;return r===void 0&&(r=`ObservableArray@`+h()),i===void 0&&(i=!1),a=e.call(this)||this,ga(function(){var e=new Ai(r,n,i,!0);e.proxy_=a,w(a,k,e),t&&t.length&&a.spliceWithArray(0,0,t),ia&&Object.defineProperty(a,`0`,ra)}),a}_e(t,e);var n=t.prototype;return n.concat=function(){this[k].atom_.reportObserved();var e=[...arguments];return Array.prototype.concat.apply(this.slice(),e.map(function(e){return Ii(e)?e.slice():e}))},n[Symbol.iterator]=function(){var e=this,t=0;return Sa({next:function(){return t<e.length?{value:e[t++],done:!1}:{done:!0,value:void 0}}})},pe(t,[{key:`length`,get:function(){return this[k].getArrayLength_()},set:function(e){this[k].setArrayLength_(e)}},{key:Symbol.toStringTag,get:function(){return`Array`}}])}(oa);Object.entries(H).forEach(function(e){var t=e[0],n=e[1];t!==`concat`&&C(ca.prototype,t,n)});function la(e){return{enumerable:!1,configurable:!0,get:function(){return this[k].get_(e)},set:function(t){this[k].set_(e,t)}}}function ua(e){s(ca.prototype,``+e,la(e))}function da(e){if(e>aa){for(var t=aa;t<e+100;t++)ua(t);aa=e}}da(1e3);function fa(e,t,n){return new ca(e,t,n)}function pa(e,t){if(typeof e==`object`&&e){if(Ii(e))return t!==void 0&&n(23),e[k].atom_;if(Ki(e))return e.atom_;if(Vi(e)){if(t===void 0)return e.keysAtom_;var r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,ha(e)),r}if(ea(e)){if(!t)return n(26);var i=e[k].values_.get(t);return i||n(27,t,ha(e)),i}if(Me(e)||tn(e)||z(e))return e}else if(v(e)&&z(e[k]))return e[k];n(28)}function ma(e,t){if(e||n(29),t!==void 0)return ma(pa(e,t));if(Me(e)||tn(e)||z(e)||Vi(e)||Ki(e))return e;if(e[k])return e[k];n(24,e)}function ha(e,t){var n;if(t!==void 0)n=pa(e,t);else if(lr(e))return e.name;else n=ea(e)||Vi(e)||Ki(e)?ma(e):pa(e);return n.name_}function ga(e){var t=I(),n=Yt(!0);An();try{return e()}finally{jn(),Xt(n),mn(t)}}var _a=c.toString;function va(e,t,n){return n===void 0&&(n=-1),ya(e,t,n)}function ya(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;var a=typeof e;if(a!==`function`&&a!==`object`&&typeof t!=`object`)return!1;var o=_a.call(e);if(o!==_a.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=ba(e),t=ba(t);var s=o===`[object Array]`;if(!s){if(typeof e!=`object`||typeof t!=`object`)return!1;var c=e.constructor,l=t.constructor;if(c!==l&&!(v(c)&&c instanceof c&&v(l)&&l instanceof l)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),r||=[],i||=[];for(var u=r.length;u--;)if(r[u]===e)return i[u]===t;if(r.push(e),i.push(t),s){if(u=e.length,u!==t.length)return!1;for(;u--;)if(!ya(e[u],t[u],n-1,r,i))return!1}else{var d=Object.keys(e),f=d.length;if(Object.keys(t).length!==f)return!1;for(var p=0;p<f;p++){var m=d[p];if(!(oe(t,m)&&ya(e[m],t[m],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function ba(e){return Ii(e)?e.slice():te(e)||Vi(e)||T(e)||Ki(e)?Array.from(e.entries()):e}var xa=i().Iterator?.prototype||{};function Sa(e){return e[Symbol.iterator]=Ca,Object.assign(Object.create(xa),e)}function Ca(){return this}function wa(e){return e instanceof Object&&typeof e.annotationType_==`string`&&v(e.make_)&&v(e.extend_)}[`Symbol`,`Map`,`Set`].forEach(function(e){i()[e]===void 0&&n(`MobX requires global '`+e+`' to be available or polyfilled`)}),typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__==`object`&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:Yn,extras:{getDebugName:ha},$mobx:k}),e.$mobx=k,e.FlowCancellationError=jr,e.ObservableMap=Bi,e.ObservableSet=Gi,e.Reaction=Ln,e._allowStateChanges=Jt,e._allowStateChangesInsideComputed=cr,e._allowStateReadsEnd=gn,e._allowStateReadsStart=hn,e._autoAction=sr,e._endAction=qt,e._getAdministration=ma,e._getGlobalState=Cn,e._interceptReads=zr,e._isComputingDerivation=sn,e._resetGlobalState=wn,e._startAction=Kt,e.action=or,e.autorun=ur,e.comparer=Re,e.computed=Bt,e.configure=Cr,e.createAtom=Ne,e.defineProperty=ti,e.entries=Xr,e.extendObservable=wr,e.flow=Fr,e.flowResult=Lr,e.get=ei,e.getAtom=pa,e.getDebugName=ha,e.getDependencyTree=Tr,e.getObserverTree=Dr,e.has=$r,e.intercept=Br,e.isAction=lr,e.isBoxedObservable=$t,e.isComputed=B,e.isComputedProp=Wr,e.isFlow=Rr,e.isFlowCancellationError=Mr,e.isObservable=Kr,e.isObservableArray=Ii,e.isObservableMap=Vi,e.isObservableObject=ea,e.isObservableProp=qr,e.isObservableSet=Ki,e.keys=Jr,e.makeAutoObservable=Ti,e.makeObservable=Ci,e.observable=j,e.observe=ri,e.onBecomeObserved=_r,e.onBecomeUnobserved=vr,e.onReactionError=Rn,e.override=We,e.ownKeys=ni,e.reaction=pr,e.remove=Qr,e.runInAction=cr,e.set=Zr,e.spy=Yn,e.toJS=si,e.trace=ci,e.transaction=ui,e.untracked=pn,e.values=Yr,e.when=di})),Dv=he(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=Tv():t.exports=Ev()}))();function Ov(e){if(Array.isArray(e))return Object.freeze(e.map(Ov));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]=Ov(r);return Object.freeze(t)}return e}function kv(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 Av(e){return typeof e==`string`?e:String(e)}function jv(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 Mv(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")`)}function Nv(e,t){if(!(e instanceof H))throw TypeError(`template function expected a RichText fragment, got ${typeof e==`object`?Object.prototype.toString.call(e):typeof e}`);let n=e.copy();return n.style=Pv(e.style).add(t),n}function Pv(e){if(e instanceof B)return e;try{return B.parse(e)}catch(t){throw t instanceof Hr?TypeError(`template function cannot style a fragment whose base style "${e}" is not a style definition: a style name resolves only against the theme of a render`,{cause:t}):t}}function Fv(e){return{fn:(t=>Nv(t,e)),argTypes:[`liftable`],arity:{kind:`exact`},returnType:`T`}}function Iv(e){return{fn:((t,n)=>Nv(n,new B({[e]:vn.parse(t)}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`}}function Lv(e,t){return new B({[e]:t})}function Rv(){let e={};for(let t of zr)e[t]=Fv(Lv(t,!0)),e[`not_${t}`]=Fv(Lv(t,!1));for(let[t,n]of Object.entries(Vr))e[t]=Fv(Lv(n,!0));return e}const zv={fn:((e,t)=>Nv(t,B.parse(e))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`},Bv={fn:((e,t)=>Nv(t,new B({link:e}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`};function Vv(){return{fg:Iv(`color`),bg:Iv(`bgcolor`),...Rv(),link:Bv,style:zv}}function Hv(e,t){if(!Zn.test(e.trim()))throw 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)}) …`);return Qn(e)}function Uv(e,t){return{fn:t,argTypes:e,arity:{kind:`exact`},returnType:`string`}}function Wv(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 Gv=Uv([`string`,`int`],((e,t)=>ar(Hv(e,`darken`),t).hex)),Kv=Uv([`string`,`int`],((e,t)=>ar(Hv(e,`lighten`),-t).hex)),qv={min:0,max:100,note:`0 = from, 100 = toward`},Jv=Uv([`string`,`string`,`float`],((e,t,n)=>En(Hv(e,`mix`),Hv(t,`mix`),Wv(n,`mix`,`percentage`,qv)/100).hex)),Yv={min:1,max:21,note:`4.5 = AA body text, 3 = AA large text`},Xv=Uv([`string`],(e=>or(Hv(e,`contrastOn`)).hex)),Zv=e=>Uv([`string`,`string`,`float`],((t,n,r)=>sr(Hv(t,`readableOn`),Hv(n,`readableOn`),Wv(r,`readableOn`,`ratio`,Yv),e()).hex)),Qv={hueShift:`shiftHue`,chromaScale:`scaleChroma`,lightnessScale:`scaleLightness`,lightnessShift:`shiftLightness`};function $v(){let e={};for(let[t,n]of Object.entries(Qv)){let r=t;e[n]=Uv([`string`,`float`],((e,t)=>{let i={...zn,[r]:Wv(t,n,`amount`)};return Yn.fromRgba(Hv(e,n)).applyKey(i).toRgba().hex}))}return e}function ey(e=()=>F.TRUECOLOR){return{darken:Gv,lighten:Kv,mix:Jv,contrastOn:Xv,readableOn:Zv(e),...$v()}}function ty(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:$n(t,e[r+1])});return n}function ny(e){return{color:{fn:(t=>$n(e(),t).hex),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},ramp:{fn:((t,n,...r)=>new Lr(Ir(n),ty(r,e())).at(t).hex),argTypes:[`float`,`string`],arity:{kind:`alternating`,minimum:4},returnType:`string`}}}function ry(e){return{...Vv(),...ey(e)}}new B({color:`red`,dim:!0});const iy=/^(?:(?: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,ay=/^(?<family>opus|sonnet|haiku)\s+(?<major>\d+)(?:\.(?<minor>\d))?$/i;function oy(e){if(!e)return`Claude`;let t=e.trim().replace(/\s*\([^)]*\)\s*$/,``).replace(/\s*\[[^\]]*\]\s*$/,``).trim(),n=t.match(iy);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(ay);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 sy(e){let t=e.match(ay);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 cy(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 ly(e){return e.toLocaleString()}function uy(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 dy(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 fy=[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],py=fy.length;function my(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*(py-1));o+=fy[t]}return o}function hy(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 gy(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 _y=Qa(),vy=[...fo];function yy(){return{basename:{fn:e=>l(e),argTypes:[`string`],arity:{kind:`exact`}},dirname:{fn:e=>u(e),argTypes:[`string`],arity:{kind:`exact`}},abbreviatePath:{fn:e=>cy(e),argTypes:[`string`],arity:{kind:`exact`}},int:{fn:e=>Math.trunc(jv(e)),argTypes:[`value`],arity:{kind:`exact`}},string:{fn:e=>Av(e),argTypes:[`value`],arity:{kind:`exact`}},bool:{fn:e=>Mv(e),argTypes:[`value`],arity:{kind:`exact`}},urlEncode:{fn:e=>encodeURIComponent(e),argTypes:[`string`],arity:{kind:`exact`}},themes:{fn:()=>_y,argTypes:[],arity:{kind:`exact`}},endcaps:{fn:()=>vy,argTypes:[],arity:{kind:`exact`}},sparkline:{fn:(e,t,...n)=>(gy(`sparkline`,[`width`],n),my(hy(e),t)),argTypes:[`string`,`int`],arity:{kind:`variadic`}},cascade:{fn:(e,...t)=>dy(e,uy(t)),argTypes:[`float`,`string`],arity:{kind:`variadic`}}}}function by(e=()=>new Date){return{minutesUntilReset:{fn:t=>Math.round(Math.max(0,t*1e3-e().getTime())/6e4),argTypes:[`int`],arity:{kind:`exact`}},formatInteger:{fn:e=>ly(e),argTypes:[`int`],arity:{kind:`exact`}},round:{fn:e=>Math.round(e),argTypes:[`float`],arity:{kind:`exact`}},formatModelName:{fn:e=>oy(e),argTypes:[`string`],arity:{kind:`exact`}},shortenModelName:{fn:e=>sy(e),argTypes:[`string`],arity:{kind:`exact`}}}}function xy(e,t=()=>new Date,n){return mp({fromString:e=>new H(e),toString:e=>e.plain,isT:e=>e instanceof H,clock:t,missingKey:`error`,funcs:{...rh(),...h_(),...Uh(),...dg(),...Ym(t),...zp(),..._h(),...ry(n),...yy(),...by(t),...e??{}}})}function Sy(e){return Cy(e,new Set(e.names()),``)}function Cy(e,t,n){return new Proxy(Object.create(null),{has(e,r){if(typeof r!=`string`)return!1;let i=n?`${n}.${r}`:r;if(t.has(i))return!0;let a=`${i}.`;for(let e of t)if(e.startsWith(a))return!0;return!1},get(r,i){if(typeof i!=`string`)return;let a=n?`${n}.${i}`:i;if(t.has(a))return e.getKind(a)===`document`?Ty(a,e.readDocument(a)):e.read(a);let o=`${a}.`;for(let n of t)if(n.startsWith(o))return Cy(e,t,a)}})}function wy(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 Ty(e,t){switch(t.kind){case`ok`:return t.value;case`absent`:throw Error(`variable "${e}" has no value yet: its source has not completed a scan`);case`failed`:throw Error(`variable "${e}": ${t.reason}`)}}function J(e){return{kind:`ok`,value:e}}const Y={kind:`absent`};function X(e){return{kind:`failed`,reason:e}}function Ey(e,t){return e?.kind===`ok`?e.value:t}function Dy(e,t,n){return t.ok?J(t.stdout):t.reason===`non-zero`&&n===`absent`||t.reason===`non-zero`&&n===t.exitCode?Y:X(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??Oy(t.stderr)].filter(Boolean).join(`, `)}`)}function Oy(e){return e.trim().split(`
87
- `,1)[0]??``}function ky(e,t){if(e.kind!==`ok`)return e;let n=t(e.value);return n===null?Y:J(n)}function Ay(e){if(e.kind!==`ok`)return e;let t=e.value.trim();return t?J(t):Y}const jy=/^[A-Za-z]:[\\/]/;function My(e){let t=e.trim();if(jy.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 Ny(e){return My(e)?.host||null}function Py(e){let t=Ny(e);return t?t===`github.com`||t.endsWith(`.github.com`)?`github`:/(^|\.)gitlab\./.test(t)?`gitlab`:null:null}function Fy(e){let t=new Map;for(let n of e.split(`
88
- `)){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 Iy(e){return e.urls.find(e=>Vy(e)!==null)??e.urls[0]??null}function Ly(e){return e.find(e=>e.name===`origin`)??e[0]??null}function Ry(e){let t=Ly(e);return t?Iy(t):null}function zy(e){let t=Ly(e);return t?t.urls.find(e=>Py(e)!==null)??Iy(t):null}function By(e){let t=(My(e)?.path??e.replace(/[\\/]+$/,``)).split(`/`);return(t[t.length-1]??``).replace(/\.git$/,``)||null}function Vy(e){let t=My(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 Hy(e){let t=Ry(e);return t===null?null:Vy(t)}function Uy(e,t,n,r){return t.ok?r(t.stdout):t.reason===`spawn-error`&&/ENOENT/i.test(t.error??``)||t.reason===`non-zero`&&n.test(t.stderr)?Y:X(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??Oy(t.stderr)].filter(Boolean).join(`, `)}`)}function Wy(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Gy(e){let t=`detached`,n=Y,r=Y,i=Y,a=0,o=0,s=0,c=0;for(let l of e.split(`
89
- `)){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)`?Y:J(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=J(e.slice(16).trim());else if(e.startsWith(`branch.ab `)){let t=e.slice(10).trim().match(/^\+(\d+)\s+-(\d+)$/);t&&(i=J({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 Ky(e){let t;try{t=JSON.parse(e)}catch(e){return X(`gh pr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`)}if(!Wy(t))return X(`gh pr view: JSON is not an object`);let{number:n,state:r,url:i}=t;return typeof n!=`number`||typeof r!=`string`||typeof i!=`string`?X(`gh pr view: missing number/state/url`):r.toUpperCase()===`OPEN`?J({number:n,state:r,url:i}):Y}function qy(e){let t;try{t=JSON.parse(e)}catch(e){return X(`glab mr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`)}if(!Wy(t))return X(`glab mr view: JSON is not an object`);let n=t.iid,r=t.state,i=t.web_url;return typeof n!=`number`||typeof r!=`string`||typeof i!=`string`?X(`glab mr view: missing iid/state/web_url`):r.toLowerCase()===`opened`?J({number:n,state:r,url:i}):Y}function Jy(e){try{let t=r.statSync(e);return{key:`${t.dev}:${t.ino}`,stamp:`${t.mtimeMs}:${t.size}`}}catch{return null}}var Yy=class{isGitRepo(e){try{return r.existsSync(c.join(e,`.git`))}catch{return!1}}async execGitAsync(e,t){return Oe({bin:`git`,args:[...e],cwd:t.cwd,env:{...process.env,GIT_OPTIONAL_LOCKS:`0`},timeoutMs:t.timeout,category:`git`})}async resolveEffectiveGitDir(e,t){return this.isWorktree(e)?J(e):t&&this.isGitRepo(t)?J(t):this.isGitRepo(e)?J(e):this.findGitRoot(e)}async findGitRoot(e){let t=c.resolve(e);for(;;){if(this.isGitRepo(t))return J(t);let e=c.dirname(t);if(e===t)return Y;t=e}}async getGitInfo(e,t={},n){try{return await this.computeGitInfo(e,t,n)}catch(e){return X(`git: ${e instanceof Error?e.message:String(e)}`)}}async computeGitInfo(e,t={},n){let r,i=this.isWorktree(e);if(i)r=e;else if(n&&this.isGitRepo(n))r=n;else if(this.isGitRepo(e))r=e;else{let t=await this.findGitRoot(e);if(t.kind!==`ok`)return t;r=t.value}let a=await this.getCoreAsync(r);if(a.kind!==`ok`)return a;let o={branch:a.value.branch,status:a.value.status,aheadBehind:a.value.aheadBehind};t.showWorkingTree&&(o.workingTree=a.value.workingTree),t.showSha&&(o.sha=ky(a.value.oid,e=>e.slice(0,7))),t.showUpstream&&(o.upstream=a.value.upstream),t.showTag&&(o.tag=await this.getNearestTagAsync(r)),t.showTimeSinceCommit&&(o.timeSinceCommit=await this.timeSinceCommit(r,a.value.oid)),t.showStashCount&&(o.stashCount=this.getStashCount(r));let s=t.showRepoName||t.showRepoUrl?await this.getRemotesAsync(r):void 0;return s!==void 0&&t.showRepoName&&(o.repoName=ky(s,e=>this.repoNameFrom(e,r)),o.isWorktree=i),s!==void 0&&t.showRepoUrl&&(o.repoUrl=ky(s,Hy)),t.showOperation&&(o.operation=this.getOngoingOperation(r)),J(o)}resolveGitDir(e){let t=c.join(e,`.git`);try{if(r.existsSync(t)&&r.statSync(t).isFile()){let n=r.readFileSync(t,`utf-8`).match(/^gitdir:\s*(.+)$/m);if(n?.[1])return c.resolve(e,n[1].trim())}}catch{}return t}getOngoingOperation(e){try{let t=this.resolveGitDir(e);return r.existsSync(c.join(t,`MERGE_HEAD`))?J(`MERGE`):r.existsSync(c.join(t,`CHERRY_PICK_HEAD`))?J(`CHERRY-PICK`):r.existsSync(c.join(t,`REVERT_HEAD`))?J(`REVERT`):r.existsSync(c.join(t,`BISECT_LOG`))?J(`BISECT`):r.existsSync(c.join(t,`rebase-merge`))||r.existsSync(c.join(t,`rebase-apply`))?J(`REBASE`):Y}catch(e){return X(`git operation probe: ${e instanceof Error?e.message:String(e)}`)}}async getNearestTagAsync(e){return Ay(Dy(`git describe --tags`,await this.execGitAsync([`describe`,`--tags`,`--abbrev=0`],{cwd:e,timeout:2e3}),`absent`))}async timeSinceCommit(e,t){return t.kind===`ok`?ky(await this.commitTimestampMs(e,t.value),e=>Math.floor((Date.now()-e)/1e3)):t}commitTimes=new Map;async commitTimestampMs(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.readCommitTimestampMs(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 readCommitTimestampMs(e,t){let n=Ay(Dy(`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)*1e3;return Number.isNaN(r)?X(`git log -1: unparseable timestamp "${n.value}"`):J(r)}resolveCommonGitDir(e){let t=this.resolveGitDir(e);try{let e=r.readFileSync(c.join(t,`commondir`),`utf-8`).trim();if(e)return c.resolve(t,e)}catch{}return t}getStashCount(e){let t=c.join(this.resolveCommonGitDir(e),`logs`,`refs`,`stash`),n;try{n=r.readFileSync(t,`utf-8`)}catch(e){return e.code===`ENOENT`?J(0):X(`git stash reflog ${t}: ${e instanceof Error?e.message:String(e)}`)}let i=n.trim();return J(i?i.split(`
90
- `).length:0)}async getRemotesAsync(e){let t=Jy(c.join(this.resolveCommonGitDir(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){let t=Dy(`git config --get-regexp remote url`,await this.execGitAsync([`config`,`--local`,`--get-regexp`,`^remote\\..*\\.url$`],{cwd:e,timeout:2e3}),1);return t.kind===`failed`?t:J(t.kind===`ok`?Fy(t.value):[])}repoNameFrom(e,t){let n=Ry(e);return(n===null?null:By(n))??c.basename(t)}async getRepoRemoteUrl(e){let t=await this.getRemotesAsync(e);if(t.kind!==`ok`)return t;let n=zy(t.value);return n===null?Y:J(n)}async execForgeAsync(e,t,n){return Oe({bin:e,args:[...t],cwd:n.cwd,env:{...process.env},timeoutMs:n.timeout,category:`forge`})}async resolvePullRequest(e,t){let n=Py(t);return n===`github`?Uy(`gh pr view`,await this.execForgeAsync(`gh`,[`pr`,`view`,`--json`,`number,state,url`],{cwd:e,timeout:5e3}),/no (open )?pull requests? found/i,Ky):n===`gitlab`?Uy(`glab mr view`,await this.execForgeAsync(`glab`,[`mr`,`view`,`--output`,`json`],{cwd:e,timeout:5e3}),/no (open )?merge requests? (found|available)/i,qy):Y}isWorktree(e){try{let t=c.join(e,`.git`);return!!(r.existsSync(t)&&r.statSync(t).isFile())}catch{return!1}}async getCoreAsync(e){O(`[GIT-EXEC] Running git status --porcelain=v2 in ${e}`);let t=Dy(`git status --porcelain=v2 --branch`,await this.execGitAsync([`status`,`--porcelain=v2`,`--branch`],{cwd:e,timeout:2e3}),`failed`);return t.kind===`ok`?J(Gy(t.value)):t}};let Xy=null;function Zy(e){if(Xy!==null)return Xy;r.mkdirSync(c.dirname(e),{recursive:!0});try{Xy=r.statSync(e).size}catch{Xy=0}return Xy}function Qy(e){for(let t=2;t>=1;t--){let n=`${e}.${t}`,i=`${e}.${t+1}`;try{r.renameSync(n,i)}catch{}}try{r.renameSync(e,`${e}.1`)}catch{}Xy=0}const $y=(e,t)=>O(t);function Z(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=Je(),t=Zy(e);r.appendFileSync(e,n),Xy=t+Buffer.byteLength(n,`utf8`),Xy>=5242880&&Qy(e)}catch(e){Xy=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}const eb=(e,t)=>O(t);var tb=class{slots=new Map;maxWatchers;counters;logger;closed=!1;constructor(e={}){this.maxWatchers=e.maxWatchers??128,this.counters=e.counters,this.logger=e.logger??eb}acquire(e,t,n){if(this.closed)return{release:()=>{}};let r=this.slots.get(e);if(r)return r.refcount++,r.onInvalidate=n,r.lastTouched=Date.now(),this.slots.delete(e),this.slots.set(e,r),this.makeHandle(e);let i={key:e,watchers:[],refcount:1,debounceTimer:null,onInvalidate:n,targets:t,lastTouched:Date.now()};return this.openWatchers(i),this.slots.set(e,i),this.counters&&this.counters.watchersOpened++,this.evictIfNeeded(),this.makeHandle(e)}makeHandle(e){let t=!1;return{release:()=>{if(t)return;t=!0;let n=this.slots.get(e);n&&(n.refcount=Math.max(0,n.refcount-1),n.refcount===0&&(this.closeSlot(n),this.slots.delete(e)))}}}openWatchers(e){let t=()=>{e.debounceTimer||(e.debounceTimer=setTimeout(()=>{e.debounceTimer=null;try{e.onInvalidate()}catch(e){this.logger(`warn`,`watcher invalidate threw: ${e.message}`)}},50),e.debounceTimer.unref())};for(let n of e.targets.files)try{let i=r.watch(n,{persistent:!1},t);i.on(`error`,e=>{this.logger(`warn`,`watcher error ${n}: ${e.message}`)}),e.watchers.push(i)}catch(e){this.logger(`warn`,`watch failed ${n}: ${e.message}`)}for(let n of e.targets.dirs)try{let i=n.filenames?new Set(n.filenames):null,a=r.watch(n.path,{persistent:!1},(e,n)=>{i&&(!n||!i.has(n))||t()});a.on(`error`,e=>{this.logger(`warn`,`watcher error ${n.path}: ${e.message}`)}),e.watchers.push(a)}catch(e){this.logger(`warn`,`watch failed ${n.path}: ${e.message}`)}}closeSlot(e){e.debounceTimer&&=(clearTimeout(e.debounceTimer),null);for(let t of e.watchers)try{t.close()}catch{}e.watchers=[],this.counters&&this.counters.watchersClosed++}evictIfNeeded(){for(;this.slots.size>this.maxWatchers;){let e=this.slots.keys().next().value;if(e===void 0)break;let t=this.slots.get(e);this.closeSlot(t),this.slots.delete(e),this.counters&&this.counters.watchersEvicted++;try{t.onInvalidate()}catch{}this.logger(`info`,`watcher LRU evict ${e}`)}}size(){return this.slots.size}closeAll(){this.closed=!0;for(let e of this.slots.values())this.closeSlot(e);this.slots.clear()}},nb=class{running=new Set;again=new Set;run(e,t){return this.again.add(e),this.running.has(e)?{kind:`queued`}:(this.running.add(e),{kind:`started`,done:this.loop(e,t)})}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 rb={showSha:!0,showStashCount:!0};function ib(e){let t=Object.keys(e).sort(),n={};for(let r of t)n[r]=e[r];return JSON.stringify(n)}function ab(e){let t=t=>{try{return r.statSync(c.join(e,t)).mtimeMs}catch{return 0}};return{head:t(`HEAD`),index:t(`index`)}}function ob(e,t){return e.head!==t.head||e.index!==t.index}function sb(e){let t=[],n=c.join(e,`refs/heads`);try{r.statSync(n).isDirectory()&&t.push({path:n})}catch{}return{files:[c.join(e,`HEAD`),c.join(e,`index`)],dirs:t}}var cb=class extends Yy{entries=new Map;subscribersByRepo=new Map;fetchInFlight=new Map;resolutions=new Map;prCache=new Map;prFetchInFlight=new Map;refreshes=new nb;hits=0;misses=0;invalidations=0;inner;ttlMs;maxEntries;watchers;ownsWatchers;logger;sanityTimer=null;constructor(e={}){super(),this.inner=e.inner??new Yy,this.ttlMs=e.ttlMs??3e4,this.maxEntries=e.maxEntries??64,this.logger=e.logger??$y,e.watchers?(this.watchers=e.watchers,this.ownsWatchers=!1):(this.watchers=new tb({logger:this.logger}),this.ownsWatchers=!0);let t=e.sanityIntervalMs??3e5;t>0&&(this.sanityTimer=setInterval(()=>this.runSanityCheck(),t),this.sanityTimer.unref())}getWatcherRegistry(){return this.watchers}getStats(){return{size:this.entries.size,hits:this.hits,misses:this.misses,invalidations:this.invalidations,watchers:this.watchers.size()}}resolveEffectiveGitDir(e,t){let n=`${e}|${t??``}`,r=Date.now(),i=this.resolutions.get(n);if(i&&r-i.computedAt<this.ttlMs)return this.resolutions.delete(n),this.resolutions.set(n,i),i.dir;let a=this.inner.resolveEffectiveGitDir(e,t);return this.resolutions.set(n,{dir:a,computedAt:r}),a.catch(()=>{this.resolutions.get(n)?.dir===a&&this.resolutions.delete(n)}),this.evictResolutionsIfNeeded(),a}evictResolutionsIfNeeded(){for(;this.resolutions.size>this.maxEntries;){let e=this.resolutions.keys().next().value;if(e===void 0)break;this.resolutions.delete(e)}}async getGitInfo(e,t={},n){let r=await this.resolveEffectiveGitDir(e,n);return r.kind===`ok`?this.getGitInfoForRoot(r.value,t):r}getGitInfoForRoot(e,t){let n=`${e}|${ib(t)}`,r=Date.now(),i=this.entries.get(n);if(i&&r-i.computedAt<this.ttlMs)return this.entries.delete(n),this.entries.set(n,i),this.hits++,Promise.resolve(J(i.info));let a=this.fetchInFlight.get(n);if(a)return a;let o=this.doFetch(e,n,t,r).finally(()=>{this.fetchInFlight.delete(n)});return this.fetchInFlight.set(n,o),o}async doFetch(e,t,n,r){this.misses++;let i=this.inner.resolveGitDir(e),a=ab(i),o=await this.inner.getGitInfo(e,n);if(o.kind!==`ok`)return o;let s=o.value;n.showPullRequest&&(s.pullRequest=await this.getPullRequestCached(e,s.branch)),this.dropEntry(t);let c=this.watchers.acquire(`git:${e}`,sb(i),()=>this.invalidateRepo(e));return this.entries.set(t,{info:s,computedAt:r,mtime:a,watcher:c,repoRoot:e}),this.evictIfNeeded(),o}async getPullRequestCached(e,t){let n=await this.inner.getRepoRemoteUrl(e);if(n.kind===`failed`)return n;if(n.kind===`absent`)return Y;let r=n.value,i=`${e}|${t}|${r}`,a=Date.now(),o=this.prCache.get(i);if(o){let e=o.pr.kind===`failed`?45e3:3e5;if(a-o.computedAt<e)return this.prCache.delete(i),this.prCache.set(i,o),o.pr}let s=this.prFetchInFlight.get(i);if(s)return s;let c=this.inner.resolvePullRequest(e,r).then(e=>(this.prCache.set(i,{pr:e,computedAt:Date.now()}),this.evictPrIfNeeded(),e)).finally(()=>{this.prFetchInFlight.delete(i)});return this.prFetchInFlight.set(i,c),c}evictPrIfNeeded(){for(;this.prCache.size>this.maxEntries;){let e=this.prCache.keys().next().value;if(e===void 0)break;this.prCache.delete(e)}}deliverable(e,t){return e.kind===`failed`?(this.logger(`warn`,`git fetch failed (${t}): ${e.reason}`),null):e.kind===`ok`?e.value:null}subscribe(e,t){let n=!1,r=null;return{firstDelivery:(async()=>{let i=await this.resolveEffectiveGitDir(e);if(n)return;if(i.kind!==`ok`){i.kind===`failed`&&this.logger(`warn`,`git resolve failed (subscribe ${e}): ${i.reason}`),this.safeInvoke(t,null);return}let a=i.value,o=this.subscribersByRepo.get(a);if(!o){let t=this.inner.resolveGitDir(a),n=this.watchers.acquire(`git:${a}`,sb(t),()=>this.invalidateRepo(a));o={workingDir:e,repoRoot:a,callbacks:new Set,watcher:n},this.subscribersByRepo.set(a,o)}o.callbacks.add(t),r={repoRoot:a,entry:o};let s=await this.getGitInfoForRoot(a,{...rb});n||this.safeInvoke(t,this.deliverable(s,a))})(),unsubscribe:()=>{if(n=!0,!r)return;let{repoRoot:e,entry:i}=r;i.callbacks.delete(t),i.callbacks.size===0&&(i.watcher.release(),this.subscribersByRepo.delete(e))}}}invalidateRepo(e){let t=0;for(let[n,r]of this.entries)r.repoRoot===e&&(r.watcher.release(),this.entries.delete(n),t++);t>0&&(this.invalidations+=t,this.logger(`info`,`gitCache invalidate ${e} dropped=${t}`)),this.refreshSubscribers(e)}refreshSubscribers(e){let t=this.subscribersByRepo.get(e);!t||t.callbacks.size===0||this.refreshes.run(e,()=>this.refreshOnce(e))}async refreshOnce(e){let t=this.subscribersByRepo.get(e);if(!t||t.callbacks.size===0)return;let n=await this.getGitInfoForRoot(e,{...rb}),r=this.deliverable(n,e),i=this.subscribersByRepo.get(e);if(!(!i||i.callbacks.size===0))for(let e of[...i.callbacks])i.callbacks.has(e)&&this.safeInvoke(e,r)}safeInvoke(e,t){try{e(t)}catch(e){this.logger(`warn`,`git subscriber threw: ${e.message??String(e)}`)}}dropEntry(e){let t=this.entries.get(e);t&&(t.watcher.release(),this.entries.delete(e))}evictIfNeeded(){for(;this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.dropEntry(e),this.logger(`info`,`gitCache evict ${e}`)}}runSanityCheck(){let e=new Map;for(let t of this.entries.values()){let n=e.get(t.repoRoot);n||(n=ab(this.inner.resolveGitDir(t.repoRoot)),e.set(t.repoRoot,n)),ob(t.mtime,n)&&this.invalidateRepo(t.repoRoot)}}runSanityCheckNow(){this.runSanityCheck()}close(){this.sanityTimer&&=(clearInterval(this.sanityTimer),null);for(let e of this.entries.values())e.watcher.release();this.entries.clear();for(let e of this.subscribersByRepo.values())e.callbacks.clear(),e.watcher.release();this.subscribersByRepo.clear(),this.refreshes.clear(),this.fetchInFlight.clear(),this.prCache.clear(),this.prFetchInFlight.clear(),this.resolutions.clear(),this.ownsWatchers&&this.watchers.closeAll()}};const lb=/\r\n|\r|\n/g,ub=e=>J(e.replace(lb,` `).trim());function db(e){return t=>{let n=e.exec(t)?.[1];return n===void 0?X(`regex no-match`):J(n.replace(lb,` `))}}const fb=e=>{try{return J(JSON.parse(e))}catch(e){return X(`JSON parse failed: ${e.message}`)}};function pb(e,t){return t.kind!==`ttl`||t.durationMs>=500?t:(O(`declareShell "${e}": ttl ${t.durationMs}ms below floor 500ms; clamping`),{kind:`ttl`,durationMs:500})}function mb(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 hb=`session.id`;function gb(e,t,n){return{where:`output of "${e}" in ${t}`,read:async()=>{let r=await Oe({bin:`/bin/sh`,args:[`-c`,e],cwd:t,category:`user-shell`,signal:n});if(!r.ok&&r.reason===`aborted`)throw n.reason;return r.ok?J(r.stdout):X(`shell "${e}" ${r.exitCode===null?[r.reason,r.error].filter(e=>e!==void 0).join(`: `):`exited with code ${r.exitCode}`} in ${t}`)}}}function _b(e,t,n){return{where:`"${e}"`,read:async()=>{try{let r=await S(e,{encoding:`utf8`,signal:n});return J(t===`first-line`?r.split(/\r?\n/)[0]??``:r)}catch{if(n.aborted)throw n.reason;return X(`file unreadable: ${e}`)}}}}function vb(e,t,n){if(e.kind!==`ok`)return e;let r=t(e.value);return r.kind===`failed`?X(`${r.reason} in ${n}`):r}const yb=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],bb=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],xb=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Sb=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function Cb(e,t){let n=[[`2006`,e=>String(e.getFullYear())],[`January`,e=>yb[e.getMonth()]],[`Monday`,e=>xb[e.getDay()]],[`Jan`,e=>bb[e.getMonth()]],[`Mon`,e=>Sb[e.getDay()]],[`15`,e=>String(e.getHours()).padStart(2,`0`)],[`06`,e=>String(e.getFullYear()%100).padStart(2,`0`)],[`01`,e=>String(e.getMonth()+1).padStart(2,`0`)],[`02`,e=>String(e.getDate()).padStart(2,`0`)],[`04`,e=>String(e.getMinutes()).padStart(2,`0`)],[`05`,e=>String(e.getSeconds()).padStart(2,`0`)],[`PM`,e=>e.getHours()<12?`AM`:`PM`],[`pm`,e=>e.getHours()<12?`am`:`pm`],[`1`,e=>String(e.getMonth()+1)],[`2`,e=>String(e.getDate())],[`3`,e=>String(e.getHours()%12||12)],[`4`,e=>String(e.getMinutes())],[`5`,e=>String(e.getSeconds())]],r=``,i=0;for(;i<e.length;){let a=!1;for(let[o,s]of n)if(e.startsWith(o,i)){r+=s(t),i+=o.length,a=!0;break}a||(r+=e[i],i++)}return r}const wb={branch:`string`,sha:`string`,dirty:`boolean`,ahead:`number`,behind:`number`,stash:`number`};function Tb(e,t,n,r){if(e===null){if(n!==void 0)return n;let e=wb[t];try{return kb(r,e)}catch{return Ab(e)}}switch(t){case`branch`:return e.branch===`detached`?``:e.branch;case`sha`:return Ey(e.sha,``);case`dirty`:return e.status!==`clean`;case`ahead`:return Ey(e.aheadBehind,{ahead:0,behind:0}).ahead;case`behind`:return Ey(e.aheadBehind,{ahead:0,behind:0}).behind;case`stash`:return Ey(e.stashCount,0)}}var Eb=class{watchers=new Map;subscribe(e,t){let n=this.watchers.get(e);if(!n){let t=new Set,r;try{r=s(e,()=>{for(let e of t)e()})}catch{return()=>{}}n={watcher:r,callbacks:t},this.watchers.set(e,n)}return n.callbacks.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){let n=this.watchers.get(e);n&&(n.callbacks.delete(t),n.callbacks.size===0&&(n.watcher.close(),this.watchers.delete(e)))}dispose(){for(let{watcher:e}of this.watchers.values())e.close();this.watchers.clear()}size(){return this.watchers.size}},Db=class{buckets=new Map;subscribe(e,t){let n=this.buckets.get(e);if(!n){let t=new Set;n={timer:te(()=>{for(let e of t)e()},e),callbacks:t},this.buckets.set(e,n)}return n.callbacks.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){let n=this.buckets.get(e);n&&(n.callbacks.delete(t),n.callbacks.size===0&&(ee(n.timer),this.buckets.delete(e)))}dispose(){for(let{timer:e}of this.buckets.values())ee(e);this.buckets.clear()}bucketCount(){return this.buckets.size}};function Ob(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function kb(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`?Av(e):t===`number`?jv(e):Mv(e)}function Ab(e){return e===`number`?0:e===`boolean`?!1:``}var jb=class{inputMetas=new Map;lastErrors=new Map;watchMgr=new Eb;ttlMgr=new Db;gitSubscriptions=new Map;cleanups=[];inFlight=new Map;reads=new nb;abort=new AbortController;drawn=Dv.observable.box(F.TRUECOLOR);drawnAt=()=>this.drawn.get();engine=xy(void 0,void 0,this.drawnAt);gitProvider;ownsGitProvider;sessionState;constructor(e,t=``,n,r){this.store=e,this.defaultEmptyValue=t,n?(this.gitProvider=n,this.ownsGitProvider=!1):(this.gitProvider=new cb({sanityIntervalMs:0}),this.ownsGitProvider=!0),this.sessionState=r}get variableStore(){return this.store}declareLiteral(e,t){this.store.defineBox(e,kv(t),t)}declareInput(e,t,n,r){let i=r===void 0?this.defaultFor(n):r;this.store.defineBox(e,n,i),this.inputMetas.set(e,{path:t,varDefault:r})}declareEnv(e,t,n){let r=process.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,gb(t,n.cwd,this.abort.signal),pb(e,n.cache),n.parse)}declareFile(e,t,n){this.declareSource(e,_b(t,n.readMode??`whole`,this.abort.signal),n.cache,n.parse)}declareSource(e,t,n,r){let i=this.publisherFor(e,r,t.where),a=()=>this.runSource(e,t,i);a(),this.registerCachePolicy(e,n,a)}publisherFor(e,t,n){switch(t.kind){case`text`:return this.scalarPublisher(e,ub,t.default,n);case`regex`:return this.scalarPublisher(e,db(t.regex),t.default,n);case`json`:return this.documentPublisher(e,t.default,n)}}scalarPublisher(e,t,n,r){let i=this.stringInitial(n);return this.store.defineBox(e,`string`,i),n=>{let a=vb(n,t,r);this.noteOutcome(e,a),this.store.setBox(e,Ey(a,i))}}documentPublisher(e,t,n){let r=t===void 0?Y:J(t);return this.store.defineDocument(e,r),i=>{let a=vb(i,fb,n);this.noteOutcome(e,a),this.store.setDocument(e,a.kind===`ok`||t===void 0?a:r)}}runSource(e,t,n){let r=this.reads.run(e,()=>t.read().then(n,e=>{if(e!==this.abort.signal.reason)throw e}));r.kind===`started`&&this.track(e,r.done)}track(e,t){let n=t.finally(()=>{this.inFlight.get(e)===n&&this.inFlight.delete(e)});this.inFlight.set(e,n)}async settled(e){let t=Date.now()+e;for(;this.inFlight.size>0;){let e=t-Date.now();if(e<=0)break;let n,r=await Promise.race([Promise.all(this.inFlight.values()).then(()=>`settled`),new Promise(t=>{n=setTimeout(()=>t(`deadline`),e)})]);if(clearTimeout(n),r===`deadline`)break}return[...this.inFlight.keys()]}declareTemplate(e,t,n={}){let r=this.engine.parse(t);this.store.defineComputed(e,`string`,t=>{let i=Sy(this.store);try{let t=r.evaluate(i).map(e=>e.plain).join(``);return this.lastErrors.delete(e),t}catch(t){let r=t instanceof Error?t.message:String(t);if(this.recordError(e,r),n.varDefault===void 0)throw Error(`variable "${e}": ${r}`);return n.varDefault}});try{this.store.read(e)}catch{}}declareTime(e,t){let n=t.ttlMs??1e3;this.store.defineBox(e,`string`,(e=>{try{return Cb(t.format,e)}catch{return this.stringInitial(t.varDefault)}})(new Date));let r=this.ttlMgr.subscribe(n,()=>{try{this.store.setBox(e,Cb(t.format,new Date)),this.lastErrors.delete(e)}catch(n){this.applyFallback(e,`string`,t.varDefault,n instanceof Error?n.message:String(n))}});this.cleanups.push(r)}declareGit(e,t){let n=wb[t.field],r=t.varDefault===void 0?Ab(n):kb(t.varDefault,n);this.store.defineBox(e,n,r);let i=this.gitSubscriptions.get(t.cwd);if(!i){let e=new Map,n=this.gitProvider.subscribe(t.cwd,t=>{this.store.runInAction(()=>{for(let[n,r]of e)for(let{name:e,varDefault:i}of r)this.store.setBox(e,Tb(t,n,i,this.defaultEmptyValue))})});i={fieldSubs:e,firstDelivery:n.firstDelivery,unsubscribe:n.unsubscribe},this.gitSubscriptions.set(t.cwd,i)}let a=i.fieldSubs.get(t.field);a||(a=[],i.fieldSubs.set(t.field,a)),a.push({name:e,varDefault:t.varDefault}),this.track(e,i.firstDelivery)}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(hb);if(typeof i!=`string`||!i)return r;let a=n.get(i,t.key);return a===null?r:a})}applyInput(e){this.store.runInAction(()=>{for(let[t,n]of this.inputMetas){let r=Ob(e,n.path),i=this.store.getType(t);if(r!==void 0)try{this.store.setBox(t,kb(r,i)),this.lastErrors.delete(t)}catch(e){this.applyFallback(t,i,n.varDefault,e instanceof Error?e.message:String(e))}else this.applyFallback(t,i,n.varDefault,`input path "${n.path}" not found in payload`)}})}drawAt(e){this.store.runInAction(()=>this.drawn.set(e))}getLastError(e){return this.lastErrors.get(e)}dispose(){this.abort.abort();for(let e of this.cleanups)e();this.cleanups.length=0;for(let e of this.gitSubscriptions.values())e.unsubscribe();this.gitSubscriptions.clear(),this.reads.clear(),this.watchMgr.dispose(),this.ttlMgr.dispose(),this.ownsGitProvider&&this.gitProvider.close()}registerCachePolicy(e,t,n){switch(t.kind){case`never`:break;case`ttl`:{let e=this.ttlMgr.subscribe(t.durationMs,n);this.cleanups.push(e);break}case`watch_file`:{let e=this.watchMgr.subscribe(t.path,n);this.cleanups.push(e);break}case`key`:{let e=this.engine.parse(t.template),r=(0,Dv.reaction)(()=>{let t=Sy(this.store);try{return e.evaluate(t).map(e=>e.plain).join(``)}catch{return``}},n);this.cleanups.push(r);break}case`depends_on`:{let e=(0,Dv.reaction)(()=>t.varNames.map(e=>this.store.changeKey(e)).join(`,`),n);this.cleanups.push(e);break}}}applyFallback(e,t,n,r){if(this.recordError(e,r),n!==void 0){this.store.setBox(e,n);return}try{this.store.setBox(e,kb(this.defaultEmptyValue,t))}catch{this.store.setBox(e,Ab(t))}}defaultFor(e){try{return kb(this.defaultEmptyValue,e)}catch{return Ab(e)}}stringInitial(e){return e===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:e}recordError(e,t){this.lastErrors.set(e,{timestamp:Date.now(),message:t})}noteOutcome(e,t){t.kind===`ok`?this.lastErrors.delete(e):this.recordError(e,t.kind===`failed`?t.reason:`no value`)}};const Mb={project_dir:{kind:`input`,path:`workspace.project_dir`,default:``},[hb]:{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:``},"theme.effective":{kind:`input`,path:`theme.effective`,default:``},"style.effective":{kind:`input`,path:`style.effective`,default:``},"preset.effective":{kind:`input`,path:`preset.effective`,default:``},"preset.customized":{kind:`input`,path:`preset.customized`,type:`boolean`,default:!1},"preset.bundled":{kind:`input`,path:`preset.bundled`,type:`boolean`,default:!0},"endcaps.effective":{kind:`input`,path:`endcaps.effective`,default:``},"variation.effective":{kind:`input`,path:`variation.effective`,default:``},"charset.effective":{kind:`input`,path:`charset.effective`,default:``},"colorCompatibility.effective":{kind:`input`,path:`colorCompatibility.effective`,default:``},"autoWrap.effective":{kind:`input`,path:`autoWrap.effective`,type:`boolean`,default:!0},"padding.effective":{kind:`input`,path:`padding.effective`,type:`number`,default:1},"updateNotice.effective":{kind:`input`,path:`updateNotice.effective`,type:`boolean`,default:!0},"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:``},"git.repoUrl":{kind:`input`,path:`git.repoUrl`,default:``}},Nb=`ne .tmux.pane ""`,Pb={theme:{configKey:`palette`,sessionKey:`theme`,effectiveVar:`theme.effective`,label:`🎨`},preset:{configKey:`preset`,sessionKey:`preset`,effectiveVar:`preset.effective`,label:`▦`},style:{configKey:`style`,sessionKey:`style`,effectiveVar:`style.effective`,label:`◐`},endcaps:{configKey:`endcaps`,sessionKey:`endcaps`,effectiveVar:`endcaps.effective`,label:`✦`},variation:{configKey:`variation`,sessionKey:`variation`,effectiveVar:`variation.effective`,label:`🎼`},autoWrap:{configKey:`autoWrap`,sessionKey:`autoWrap`,effectiveVar:`autoWrap.effective`,label:`wrap`},padding:{configKey:`padding`,sessionKey:`padding`,effectiveVar:`padding.effective`,label:`padding`},updateNotice:{configKey:`updateNotice`,sessionKey:`updateNotice`,effectiveVar:`updateNotice.effective`,label:`update notice`}},Fb=Object.values(Pb),Ib=[{configKey:`charset`,effectiveVar:`charset.effective`},{configKey:`colorCompatibility`,effectiveVar:`colorCompatibility.effective`}],Lb=new Set(Ib.map(e=>e.configKey)),Rb=new Map([...Fb,...Ib].map(e=>[e.configKey,e.effectiveVar])),zb=new Map(Fb.map(e=>[e.sessionKey,e.effectiveVar]));function Bb(e){return Object.fromEntries(Object.keys(Pb).map(t=>[t,e(t)]))}const Vb=new Map(Object.keys(Pb).map(e=>[Pb[e].sessionKey,e]));function Hb(e,t,n){let r=new Set,i=e=>{for(let t of _v(e??``,n).keys())r.add(t)};for(let t of Object.values(e.segments))i(t.template),i(t.bg),i(t.fg),i(t.when);for(let e of t)for(let t of Ms(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(hb);for(let t of Object.values(e.actions)){r.add(hb),`copy`in t&&i(t.copy),`open`in t&&i(t.open);let e=`set`in t?zb.get(t.set):void 0,n=`persist`in t?Rb.get(t.persist):void 0;e!==void 0&&r.add(e),n!==void 0&&r.add(n)}return r}function Ub(e,t,n){let r=Cv({...n,variables:{...n.variables,...e.variables},segments:{...n.segments,...e.segments}}),i={};for(let a of Hb(e,t,n.helpers)){if(Sv(a,r))continue;let e=Mb[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}const Wb=new Map,Gb=new Map;function Kb(e){let t=Jb(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 qb(e,t){return e===`bar`?t:Kb(e)}function Jb(e){let t=Wb.get(e);if(t!==void 0)return t;let n=Tr(e);return n===null?null:(Wb.set(e,n),n)}function Yb(e,t){let n=`${e.name} ${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,r=Gb.get(n);if(r!==void 0)return r;let i=Nr(e,t);return Gb.set(n,i),i}function Xb(e){let t=Jb(e);return t===null?null:{kind:`decided`,name:e,value:t}}function Zb(e,t,n){let r=Xb(e);return r===null?(n(`${t} rendered "${Xa}": "${e}" names no installed theme${Ya(e)}`),$b()):r}function Qb(e,t,n){return ao(e,t,n,$b(),Xb)}function $b(){return Xb(Xa)}function ex(e){return oo(Qb(void 0,null,e),$b).value}const tx=new Map;function nx(e,t,n){tx.set(e,{permanent:!0,resolve:t,paletteOf:n})}nx(`themes`,()=>Qa(),e=>Kb(e));const rx=`placementThemes`;nx(rx,$a,(e,t)=>qb(e,t.palette)),nx(`endcaps`,()=>fo),nx(`variations`,()=>yo),nx(`charsets`,()=>ho),nx(`colorCompatibilities`,()=>_o);function ix(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>Yb(n.basePalette,e.styles[t])}],[`presets`,{members:D_(e.presets)}]])}function ax(e){return[...new Set([...tx.keys(),...e.keys()])]}function ox(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=tx.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(`unknown option domain "${e}" (have: ${ax(t).join(`, `)})`)}function sx(e){return{label:e.label,domain:cx(e.domain)}}function cx(e){return e===`theme`?{from:rx}:e===`bool`||`min`in e?e:{from:e}}function lx(e,t,n,r,i){let a=Jc(e.label),{domain:o}=e;if(o===`bool`)return{kind:`inline`,template:`{{ action "${r}" "☑ ${a}" "☐ ${a}" }}`,actions:{[r]:{set:t,cycle:[...wo]}},variables:{}};if(`from`in o)return ux(a,t,r,i,o.from);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 ux(e,t,n,r,i){let a={variable:r,key:r,member:n},o=y_(r,n),s=`${n}.open`,c=b_(r),l=`${c}.first`;return{kind:`picker`,template:`{{ "${e}" }} {{ carousel "${n}" 0 "${s}" }}`,actions:{[n]:{set:t,from:i},[o]:nl(r,n),[c]:{set:c,int:!0},[l]:{set:c,to:`0`},[s]:{do:[o,l]}},variables:{[r]:tl(r,Wc),[c]:{kind:`state`,key:c,default:`0`}},list:{ref:a,template:`{{ picker "${n}" "${c}" false true true }}`}}}const dx=/^segments\.([^.]+)\.palette$/,fx=/^presets\.(.+)\.root$/,px=/^presets\.(.+)\.globals\.([^.]+)$/;function mx(e){return`presets.${e}.root`}function hx(e,t){return`presets.${e}.globals.${t}`}function gx(e){if(kl(e))return{scope:`globals`,field:e};let t=dx.exec(e);if(t)return{scope:`segment-palette`,segment:t[1]};let n=px.exec(e);if(n&&Sl(n[2]))return{scope:`preset-globals`,preset:n[1],field:n[2]};let r=fx.exec(e);return r?{scope:`preset-root`,preset:r[1]}:null}function _x(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`]}}const vx=`open`;function yx(e,t,n,r){let i={variable:e,key:e,member:vx};return r.variables[e]=tl(e,Wc),r.actions[e]=nl(e,vx),r.segments[e]={template:Qc(e,`(?)`,`✕`),...bx(n)},Yc(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 bx(e){let[t,...n]=e;return t===void 0?{}:{when:Xc(t,...n)}}const xx=`none`;var Sx=class extends Error{constructor(e,t,n){super(`Invalid ${t} color ${JSON.stringify(e)}: ${n}`),this.name=`ColorSpecError`}};function Cx(e,t,n,r,i){let{palette:a,tint:o}=e,s=wx(n,i),c=s!==xx,l=c?s===void 0?o:Tx(a,s,`bg`):Tx(a,`background`,`bg`);e.bg=l;let u=wx(r,i),d=u===void 0?c?Aa(a,l,t):void 0:Tx(a,u,`fg`);return new B({...c&&{bgcolor:vn.fromRgba(l)},...d!==void 0&&{color:vn.fromRgba(d)}})}function wx(e,t){if(e!==void 0)return e.evaluate(t).map(e=>e.plain).join(``)}function Tx(e,t,n){try{return $n(e,t)}catch(e){throw e instanceof Xn?new Sx(t,n,e.message):e}}const Ex={help:[`-h`,`--help`],version:[`-V`,`--version`]},Dx=[`✚ inserts`,`✖ removes`,`⚙️ configures`,`↺ resets layout`],Ox=`
86
+ Use 'override' annotation for methods overridden by subclass.`)}}var ra=la(0),ia=function(){var e=!1,t={};return Object.defineProperty(t,`0`,{set:function(){e=!0}}),Object.create(t)[0]=1,e===!1}(),aa=0,oa=function(){};function sa(e,t){Object.setPrototypeOf?Object.setPrototypeOf(e.prototype,t):e.prototype.__proto__===void 0?e.prototype=t:e.prototype.__proto__=t}sa(oa,Array.prototype);var ca=function(e){function t(t,n,r,i){var a;return r===void 0&&(r=`ObservableArray@`+h()),i===void 0&&(i=!1),a=e.call(this)||this,ga(function(){var e=new Ai(r,n,i,!0);e.proxy_=a,w(a,k,e),t&&t.length&&a.spliceWithArray(0,0,t),ia&&Object.defineProperty(a,`0`,ra)}),a}_e(t,e);var n=t.prototype;return n.concat=function(){this[k].atom_.reportObserved();var e=[...arguments];return Array.prototype.concat.apply(this.slice(),e.map(function(e){return Ii(e)?e.slice():e}))},n[Symbol.iterator]=function(){var e=this,t=0;return Sa({next:function(){return t<e.length?{value:e[t++],done:!1}:{done:!0,value:void 0}}})},pe(t,[{key:`length`,get:function(){return this[k].getArrayLength_()},set:function(e){this[k].setArrayLength_(e)}},{key:Symbol.toStringTag,get:function(){return`Array`}}])}(oa);Object.entries(H).forEach(function(e){var t=e[0],n=e[1];t!==`concat`&&C(ca.prototype,t,n)});function la(e){return{enumerable:!1,configurable:!0,get:function(){return this[k].get_(e)},set:function(t){this[k].set_(e,t)}}}function ua(e){s(ca.prototype,``+e,la(e))}function da(e){if(e>aa){for(var t=aa;t<e+100;t++)ua(t);aa=e}}da(1e3);function fa(e,t,n){return new ca(e,t,n)}function pa(e,t){if(typeof e==`object`&&e){if(Ii(e))return t!==void 0&&n(23),e[k].atom_;if(Ki(e))return e.atom_;if(Vi(e)){if(t===void 0)return e.keysAtom_;var r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,ha(e)),r}if(ea(e)){if(!t)return n(26);var i=e[k].values_.get(t);return i||n(27,t,ha(e)),i}if(Me(e)||tn(e)||z(e))return e}else if(v(e)&&z(e[k]))return e[k];n(28)}function ma(e,t){if(e||n(29),t!==void 0)return ma(pa(e,t));if(Me(e)||tn(e)||z(e)||Vi(e)||Ki(e))return e;if(e[k])return e[k];n(24,e)}function ha(e,t){var n;if(t!==void 0)n=pa(e,t);else if(lr(e))return e.name;else n=ea(e)||Vi(e)||Ki(e)?ma(e):pa(e);return n.name_}function ga(e){var t=I(),n=Yt(!0);An();try{return e()}finally{jn(),Xt(n),mn(t)}}var _a=c.toString;function va(e,t,n){return n===void 0&&(n=-1),ya(e,t,n)}function ya(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;var a=typeof e;if(a!==`function`&&a!==`object`&&typeof t!=`object`)return!1;var o=_a.call(e);if(o!==_a.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=ba(e),t=ba(t);var s=o===`[object Array]`;if(!s){if(typeof e!=`object`||typeof t!=`object`)return!1;var c=e.constructor,l=t.constructor;if(c!==l&&!(v(c)&&c instanceof c&&v(l)&&l instanceof l)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),r||=[],i||=[];for(var u=r.length;u--;)if(r[u]===e)return i[u]===t;if(r.push(e),i.push(t),s){if(u=e.length,u!==t.length)return!1;for(;u--;)if(!ya(e[u],t[u],n-1,r,i))return!1}else{var d=Object.keys(e),f=d.length;if(Object.keys(t).length!==f)return!1;for(var p=0;p<f;p++){var m=d[p];if(!(oe(t,m)&&ya(e[m],t[m],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function ba(e){return Ii(e)?e.slice():ee(e)||Vi(e)||ne(e)||Ki(e)?Array.from(e.entries()):e}var xa=i().Iterator?.prototype||{};function Sa(e){return e[Symbol.iterator]=Ca,Object.assign(Object.create(xa),e)}function Ca(){return this}function wa(e){return e instanceof Object&&typeof e.annotationType_==`string`&&v(e.make_)&&v(e.extend_)}[`Symbol`,`Map`,`Set`].forEach(function(e){i()[e]===void 0&&n(`MobX requires global '`+e+`' to be available or polyfilled`)}),typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__==`object`&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:Yn,extras:{getDebugName:ha},$mobx:k}),e.$mobx=k,e.FlowCancellationError=jr,e.ObservableMap=Bi,e.ObservableSet=Gi,e.Reaction=Ln,e._allowStateChanges=Jt,e._allowStateChangesInsideComputed=cr,e._allowStateReadsEnd=gn,e._allowStateReadsStart=hn,e._autoAction=sr,e._endAction=qt,e._getAdministration=ma,e._getGlobalState=Cn,e._interceptReads=zr,e._isComputingDerivation=sn,e._resetGlobalState=wn,e._startAction=Kt,e.action=or,e.autorun=ur,e.comparer=Re,e.computed=Bt,e.configure=Cr,e.createAtom=Ne,e.defineProperty=ti,e.entries=Xr,e.extendObservable=wr,e.flow=Fr,e.flowResult=Lr,e.get=ei,e.getAtom=pa,e.getDebugName=ha,e.getDependencyTree=Tr,e.getObserverTree=Dr,e.has=$r,e.intercept=Br,e.isAction=lr,e.isBoxedObservable=$t,e.isComputed=B,e.isComputedProp=Wr,e.isFlow=Rr,e.isFlowCancellationError=Mr,e.isObservable=Kr,e.isObservableArray=Ii,e.isObservableMap=Vi,e.isObservableObject=ea,e.isObservableProp=qr,e.isObservableSet=Ki,e.keys=Jr,e.makeAutoObservable=Ti,e.makeObservable=Ci,e.observable=j,e.observe=ri,e.onBecomeObserved=_r,e.onBecomeUnobserved=vr,e.onReactionError=Rn,e.override=We,e.ownKeys=ni,e.reaction=pr,e.remove=Qr,e.runInAction=cr,e.set=Zr,e.spy=Yn,e.toJS=si,e.trace=ci,e.transaction=ui,e.untracked=pn,e.values=Yr,e.when=di})),Ov=he(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=Ev():t.exports=Dv()}))();function kv(e){if(Array.isArray(e))return Object.freeze(e.map(kv));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]=kv(r);return Object.freeze(t)}return e}function Av(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 jv(e){return typeof e==`string`?e:String(e)}function Mv(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 Nv(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")`)}function Pv(e,t){if(!(e instanceof H))throw TypeError(`template function expected a RichText fragment, got ${typeof e==`object`?Object.prototype.toString.call(e):typeof e}`);let n=e.copy();return n.style=Fv(e.style).add(t),n}function Fv(e){if(e instanceof B)return e;try{return B.parse(e)}catch(t){throw t instanceof Hr?TypeError(`template function cannot style a fragment whose base style "${e}" is not a style definition: a style name resolves only against the theme of a render`,{cause:t}):t}}function Iv(e){return{fn:(t=>Pv(t,e)),argTypes:[`liftable`],arity:{kind:`exact`},returnType:`T`}}function Lv(e){return{fn:((t,n)=>Pv(n,new B({[e]:vn.parse(t)}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`}}function Rv(e,t){return new B({[e]:t})}function zv(){let e={};for(let t of zr)e[t]=Iv(Rv(t,!0)),e[`not_${t}`]=Iv(Rv(t,!1));for(let[t,n]of Object.entries(Vr))e[t]=Iv(Rv(n,!0));return e}const Bv={fn:((e,t)=>Pv(t,B.parse(e))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`},Vv={fn:((e,t)=>Pv(t,new B({link:e}))),argTypes:[`string`,`liftable`],arity:{kind:`exact`},returnType:`T`};function Hv(){return{fg:Lv(`color`),bg:Lv(`bgcolor`),...zv(),link:Vv,style:Bv}}function Uv(e,t){if(!Zn.test(e.trim()))throw 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)}) …`);return Qn(e)}function Wv(e,t){return{fn:t,argTypes:e,arity:{kind:`exact`},returnType:`string`}}function Gv(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 Kv=Wv([`string`,`int`],((e,t)=>ar(Uv(e,`darken`),t).hex)),qv=Wv([`string`,`int`],((e,t)=>ar(Uv(e,`lighten`),-t).hex)),Jv={min:0,max:100,note:`0 = from, 100 = toward`},Yv=Wv([`string`,`string`,`float`],((e,t,n)=>En(Uv(e,`mix`),Uv(t,`mix`),Gv(n,`mix`,`percentage`,Jv)/100).hex)),Xv={min:1,max:21,note:`4.5 = AA body text, 3 = AA large text`},Zv=Wv([`string`],(e=>or(Uv(e,`contrastOn`)).hex)),Qv=e=>Wv([`string`,`string`,`float`],((t,n,r)=>sr(Uv(t,`readableOn`),Uv(n,`readableOn`),Gv(r,`readableOn`,`ratio`,Xv),e()).hex)),$v={hueShift:`shiftHue`,chromaScale:`scaleChroma`,lightnessScale:`scaleLightness`,lightnessShift:`shiftLightness`};function ey(){let e={};for(let[t,n]of Object.entries($v)){let r=t;e[n]=Wv([`string`,`float`],((e,t)=>{let i={...zn,[r]:Gv(t,n,`amount`)};return Yn.fromRgba(Uv(e,n)).applyKey(i).toRgba().hex}))}return e}function ty(e=()=>F.TRUECOLOR){return{darken:Kv,lighten:qv,mix:Yv,contrastOn:Zv,readableOn:Qv(e),...ey()}}function ny(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:$n(t,e[r+1])});return n}function ry(e){return{color:{fn:(t=>$n(e(),t).hex),argTypes:[`string`],arity:{kind:`exact`},returnType:`string`},ramp:{fn:((t,n,...r)=>new Lr(Ir(n),ny(r,e())).at(t).hex),argTypes:[`float`,`string`],arity:{kind:`alternating`,minimum:4},returnType:`string`}}}function iy(e){return{...Hv(),...ty(e)}}new B({color:`red`,dim:!0});const ay=/^(?:(?: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,oy=/^(?<family>opus|sonnet|haiku)\s+(?<major>\d+)(?:\.(?<minor>\d))?$/i;function sy(e){if(!e)return`Claude`;let t=e.trim().replace(/\s*\([^)]*\)\s*$/,``).replace(/\s*\[[^\]]*\]\s*$/,``).trim(),n=t.match(ay);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(oy);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 cy(e){let t=e.match(oy);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 ly(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 uy(e){return e.toLocaleString()}function dy(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 fy(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 py=[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],my=py.length;function hy(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*(my-1));o+=py[t]}return o}function gy(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 _y(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 vy=Qa(),yy=[...fo];function by(){return{basename:{fn:e=>l(e),argTypes:[`string`],arity:{kind:`exact`}},dirname:{fn:e=>u(e),argTypes:[`string`],arity:{kind:`exact`}},abbreviatePath:{fn:e=>ly(e),argTypes:[`string`],arity:{kind:`exact`}},int:{fn:e=>Math.trunc(Mv(e)),argTypes:[`value`],arity:{kind:`exact`}},string:{fn:e=>jv(e),argTypes:[`value`],arity:{kind:`exact`}},bool:{fn:e=>Nv(e),argTypes:[`value`],arity:{kind:`exact`}},urlEncode:{fn:e=>encodeURIComponent(e),argTypes:[`string`],arity:{kind:`exact`}},themes:{fn:()=>vy,argTypes:[],arity:{kind:`exact`}},endcaps:{fn:()=>yy,argTypes:[],arity:{kind:`exact`}},sparkline:{fn:(e,t,...n)=>(_y(`sparkline`,[`width`],n),hy(gy(e),t)),argTypes:[`string`,`int`],arity:{kind:`variadic`}},cascade:{fn:(e,...t)=>fy(e,dy(t)),argTypes:[`float`,`string`],arity:{kind:`variadic`}}}}function xy(e=()=>new Date){return{minutesUntilReset:{fn:t=>Math.round(Math.max(0,t*1e3-e().getTime())/6e4),argTypes:[`int`],arity:{kind:`exact`}},formatInteger:{fn:e=>uy(e),argTypes:[`int`],arity:{kind:`exact`}},round:{fn:e=>Math.round(e),argTypes:[`float`],arity:{kind:`exact`}},formatModelName:{fn:e=>sy(e),argTypes:[`string`],arity:{kind:`exact`}},shortenModelName:{fn:e=>cy(e),argTypes:[`string`],arity:{kind:`exact`}}}}function Sy(e,t=()=>new Date,n){return mp({fromString:e=>new H(e),toString:e=>e.plain,isT:e=>e instanceof H,clock:t,missingKey:`error`,funcs:{...rh(),...h_(),...Uh(),...dg(),...Ym(t),...zp(),..._h(),...iy(n),...by(),...xy(t),...e??{}}})}function Cy(e){return wy(e,new Set(e.names()),``)}function wy(e,t,n){return new Proxy(Object.create(null),{has(e,r){if(typeof r!=`string`)return!1;let i=n?`${n}.${r}`:r;if(t.has(i))return!0;let a=`${i}.`;for(let e of t)if(e.startsWith(a))return!0;return!1},get(r,i){if(typeof i!=`string`)return;let a=n?`${n}.${i}`:i;if(t.has(a))return e.getKind(a)===`document`?Ey(a,e.readDocument(a)):e.read(a);let o=`${a}.`;for(let n of t)if(n.startsWith(o))return wy(e,t,a)}})}function Ty(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 Ey(e,t){switch(t.kind){case`ok`:return t.value;case`absent`:throw Error(`variable "${e}" has no value yet: its source has not completed a scan`);case`failed`:throw Error(`variable "${e}": ${t.reason}`)}}function J(e){return{kind:`ok`,value:e}}const Y={kind:`absent`};function X(e){return{kind:`failed`,reason:e}}function Dy(e,t){return e?.kind===`ok`?e.value:t}function Oy(e,t,n){return t.ok?J(t.stdout):t.reason===`non-zero`&&n===`absent`||t.reason===`non-zero`&&n===t.exitCode?Y:X(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??ky(t.stderr)].filter(Boolean).join(`, `)}`)}function ky(e){return e.trim().split(`
87
+ `,1)[0]??``}function Ay(e,t){if(e.kind!==`ok`)return e;let n=t(e.value);return n===null?Y:J(n)}function jy(e){if(e.kind!==`ok`)return e;let t=e.value.trim();return t?J(t):Y}const My=/^[A-Za-z]:[\\/]/;function Ny(e){let t=e.trim();if(My.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 Py(e){return Ny(e)?.host||null}function Fy(e){let t=Py(e);return t?t===`github.com`||t.endsWith(`.github.com`)?`github`:/(^|\.)gitlab\./.test(t)?`gitlab`:null:null}function Iy(e){let t=new Map;for(let n of e.split(`
88
+ `)){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 Ly(e){return e.urls.find(e=>Hy(e)!==null)??e.urls[0]??null}function Ry(e){return e.find(e=>e.name===`origin`)??e[0]??null}function zy(e){let t=Ry(e);return t?Ly(t):null}function By(e){let t=Ry(e);return t?t.urls.find(e=>Fy(e)!==null)??Ly(t):null}function Vy(e){let t=(Ny(e)?.path??e.replace(/[\\/]+$/,``)).split(`/`);return(t[t.length-1]??``).replace(/\.git$/,``)||null}function Hy(e){let t=Ny(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 Uy(e){let t=zy(e);return t===null?null:Hy(t)}function Wy(e,t,n,r){return t.ok?r(t.stdout):t.reason===`spawn-error`&&/ENOENT/i.test(t.error??``)||t.reason===`non-zero`&&n.test(t.stderr)?Y:X(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??ky(t.stderr)].filter(Boolean).join(`, `)}`)}function Gy(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ky(e){let t=`detached`,n=Y,r=Y,i=Y,a=0,o=0,s=0,c=0;for(let l of e.split(`
89
+ `)){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)`?Y:J(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=J(e.slice(16).trim());else if(e.startsWith(`branch.ab `)){let t=e.slice(10).trim().match(/^\+(\d+)\s+-(\d+)$/);t&&(i=J({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 qy(e){let t;try{t=JSON.parse(e)}catch(e){return X(`gh pr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`)}if(!Gy(t))return X(`gh pr view: JSON is not an object`);let{number:n,state:r,url:i}=t;return typeof n!=`number`||typeof r!=`string`||typeof i!=`string`?X(`gh pr view: missing number/state/url`):r.toUpperCase()===`OPEN`?J({number:n,state:r,url:i}):Y}function Jy(e){let t;try{t=JSON.parse(e)}catch(e){return X(`glab mr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`)}if(!Gy(t))return X(`glab mr view: JSON is not an object`);let n=t.iid,r=t.state,i=t.web_url;return typeof n!=`number`||typeof r!=`string`||typeof i!=`string`?X(`glab mr view: missing iid/state/web_url`):r.toLowerCase()===`opened`?J({number:n,state:r,url:i}):Y}function Yy(e){try{let t=r.statSync(e);return{key:`${t.dev}:${t.ino}`,stamp:`${t.mtimeMs}:${t.size}`}}catch{return null}}var Xy=class{isGitRepo(e){try{return r.existsSync(c.join(e,`.git`))}catch{return!1}}async execGitAsync(e,t){return Oe({bin:`git`,args:[...e],cwd:t.cwd,env:{...process.env,GIT_OPTIONAL_LOCKS:`0`},timeoutMs:t.timeout,category:`git`})}async resolveEffectiveGitDir(e,t){return this.isWorktree(e)?J(e):t&&this.isGitRepo(t)?J(t):this.isGitRepo(e)?J(e):this.findGitRoot(e)}async findGitRoot(e){let t=c.resolve(e);for(;;){if(this.isGitRepo(t))return J(t);let e=c.dirname(t);if(e===t)return Y;t=e}}async getGitInfo(e,t={},n){try{return await this.computeGitInfo(e,t,n)}catch(e){return X(`git: ${e instanceof Error?e.message:String(e)}`)}}async computeGitInfo(e,t={},n){let r,i=this.isWorktree(e);if(i)r=e;else if(n&&this.isGitRepo(n))r=n;else if(this.isGitRepo(e))r=e;else{let t=await this.findGitRoot(e);if(t.kind!==`ok`)return t;r=t.value}let a=await this.getCoreAsync(r);if(a.kind!==`ok`)return a;let o={branch:a.value.branch,status:a.value.status,aheadBehind:a.value.aheadBehind};t.showWorkingTree&&(o.workingTree=a.value.workingTree),t.showSha&&(o.sha=Ay(a.value.oid,e=>e.slice(0,7))),t.showUpstream&&(o.upstream=a.value.upstream),t.showTag&&(o.tag=await this.getNearestTagAsync(r)),t.showTimeSinceCommit&&(o.timeSinceCommit=await this.timeSinceCommit(r,a.value.oid)),t.showStashCount&&(o.stashCount=this.getStashCount(r));let s=t.showRepoName||t.showRepoUrl?await this.getRemotesAsync(r):void 0;return s!==void 0&&t.showRepoName&&(o.repoName=Ay(s,e=>this.repoNameFrom(e,r)),o.isWorktree=i),s!==void 0&&t.showRepoUrl&&(o.repoUrl=Ay(s,Uy)),t.showOperation&&(o.operation=this.getOngoingOperation(r)),J(o)}resolveGitDir(e){let t=c.join(e,`.git`);try{if(r.existsSync(t)&&r.statSync(t).isFile()){let n=r.readFileSync(t,`utf-8`).match(/^gitdir:\s*(.+)$/m);if(n?.[1])return c.resolve(e,n[1].trim())}}catch{}return t}getOngoingOperation(e){try{let t=this.resolveGitDir(e);return r.existsSync(c.join(t,`MERGE_HEAD`))?J(`MERGE`):r.existsSync(c.join(t,`CHERRY_PICK_HEAD`))?J(`CHERRY-PICK`):r.existsSync(c.join(t,`REVERT_HEAD`))?J(`REVERT`):r.existsSync(c.join(t,`BISECT_LOG`))?J(`BISECT`):r.existsSync(c.join(t,`rebase-merge`))||r.existsSync(c.join(t,`rebase-apply`))?J(`REBASE`):Y}catch(e){return X(`git operation probe: ${e instanceof Error?e.message:String(e)}`)}}async getNearestTagAsync(e){return jy(Oy(`git describe --tags`,await this.execGitAsync([`describe`,`--tags`,`--abbrev=0`],{cwd:e,timeout:2e3}),`absent`))}async timeSinceCommit(e,t){return t.kind===`ok`?Ay(await this.commitTimestampMs(e,t.value),e=>Math.floor((Date.now()-e)/1e3)):t}commitTimes=new Map;async commitTimestampMs(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.readCommitTimestampMs(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 readCommitTimestampMs(e,t){let n=jy(Oy(`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)*1e3;return Number.isNaN(r)?X(`git log -1: unparseable timestamp "${n.value}"`):J(r)}resolveCommonGitDir(e){let t=this.resolveGitDir(e);try{let e=r.readFileSync(c.join(t,`commondir`),`utf-8`).trim();if(e)return c.resolve(t,e)}catch{}return t}getStashCount(e){let t=c.join(this.resolveCommonGitDir(e),`logs`,`refs`,`stash`),n;try{n=r.readFileSync(t,`utf-8`)}catch(e){return e.code===`ENOENT`?J(0):X(`git stash reflog ${t}: ${e instanceof Error?e.message:String(e)}`)}let i=n.trim();return J(i?i.split(`
90
+ `).length:0)}async getRemotesAsync(e){let t=Yy(c.join(this.resolveCommonGitDir(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){let t=Oy(`git config --get-regexp remote url`,await this.execGitAsync([`config`,`--local`,`--get-regexp`,`^remote\\..*\\.url$`],{cwd:e,timeout:2e3}),1);return t.kind===`failed`?t:J(t.kind===`ok`?Iy(t.value):[])}repoNameFrom(e,t){let n=zy(e);return(n===null?null:Vy(n))??c.basename(t)}async getRepoRemoteUrl(e){let t=await this.getRemotesAsync(e);if(t.kind!==`ok`)return t;let n=By(t.value);return n===null?Y:J(n)}async execForgeAsync(e,t,n){return Oe({bin:e,args:[...t],cwd:n.cwd,env:{...process.env},timeoutMs:n.timeout,category:`forge`})}async resolvePullRequest(e,t){let n=Fy(t);return n===`github`?Wy(`gh pr view`,await this.execForgeAsync(`gh`,[`pr`,`view`,`--json`,`number,state,url`],{cwd:e,timeout:5e3}),/no (open )?pull requests? found/i,qy):n===`gitlab`?Wy(`glab mr view`,await this.execForgeAsync(`glab`,[`mr`,`view`,`--output`,`json`],{cwd:e,timeout:5e3}),/no (open )?merge requests? (found|available)/i,Jy):Y}isWorktree(e){try{let t=c.join(e,`.git`);return!!(r.existsSync(t)&&r.statSync(t).isFile())}catch{return!1}}async getCoreAsync(e){O(`[GIT-EXEC] Running git status --porcelain=v2 in ${e}`);let t=Oy(`git status --porcelain=v2 --branch`,await this.execGitAsync([`status`,`--porcelain=v2`,`--branch`],{cwd:e,timeout:2e3}),`failed`);return t.kind===`ok`?J(Ky(t.value)):t}};let Zy=null;function Qy(e){if(Zy!==null)return Zy;r.mkdirSync(c.dirname(e),{recursive:!0});try{Zy=r.statSync(e).size}catch{Zy=0}return Zy}function $y(e){for(let t=2;t>=1;t--){let n=`${e}.${t}`,i=`${e}.${t+1}`;try{r.renameSync(n,i)}catch{}}try{r.renameSync(e,`${e}.1`)}catch{}Zy=0}const eb=(e,t)=>O(t);function Z(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=Je(),t=Qy(e);r.appendFileSync(e,n),Zy=t+Buffer.byteLength(n,`utf8`),Zy>=5242880&&$y(e)}catch(e){Zy=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}const tb=(e,t)=>O(t);var nb=class{slots=new Map;maxWatchers;counters;logger;closed=!1;constructor(e={}){this.maxWatchers=e.maxWatchers??128,this.counters=e.counters,this.logger=e.logger??tb}acquire(e,t,n){if(this.closed)return{release:()=>{}};let r=this.slots.get(e);if(r)return r.refcount++,r.onInvalidate=n,r.lastTouched=Date.now(),this.slots.delete(e),this.slots.set(e,r),this.makeHandle(e);let i={key:e,watchers:[],refcount:1,debounceTimer:null,onInvalidate:n,targets:t,lastTouched:Date.now()};return this.openWatchers(i),this.slots.set(e,i),this.counters&&this.counters.watchersOpened++,this.evictIfNeeded(),this.makeHandle(e)}makeHandle(e){let t=!1;return{release:()=>{if(t)return;t=!0;let n=this.slots.get(e);n&&(n.refcount=Math.max(0,n.refcount-1),n.refcount===0&&(this.closeSlot(n),this.slots.delete(e)))}}}openWatchers(e){let t=()=>{e.debounceTimer||(e.debounceTimer=setTimeout(()=>{e.debounceTimer=null;try{e.onInvalidate()}catch(e){this.logger(`warn`,`watcher invalidate threw: ${e.message}`)}},50),e.debounceTimer.unref())};for(let n of e.targets.files)try{let i=r.watch(n,{persistent:!1},t);i.on(`error`,e=>{this.logger(`warn`,`watcher error ${n}: ${e.message}`)}),e.watchers.push(i)}catch(e){this.logger(`warn`,`watch failed ${n}: ${e.message}`)}for(let n of e.targets.dirs)try{let i=n.filenames?new Set(n.filenames):null,a=r.watch(n.path,{persistent:!1},(e,n)=>{i&&(!n||!i.has(n))||t()});a.on(`error`,e=>{this.logger(`warn`,`watcher error ${n.path}: ${e.message}`)}),e.watchers.push(a)}catch(e){this.logger(`warn`,`watch failed ${n.path}: ${e.message}`)}}closeSlot(e){e.debounceTimer&&=(clearTimeout(e.debounceTimer),null);for(let t of e.watchers)try{t.close()}catch{}e.watchers=[],this.counters&&this.counters.watchersClosed++}evictIfNeeded(){for(;this.slots.size>this.maxWatchers;){let e=this.slots.keys().next().value;if(e===void 0)break;let t=this.slots.get(e);this.closeSlot(t),this.slots.delete(e),this.counters&&this.counters.watchersEvicted++;try{t.onInvalidate()}catch{}this.logger(`info`,`watcher LRU evict ${e}`)}}size(){return this.slots.size}closeAll(){this.closed=!0;for(let e of this.slots.values())this.closeSlot(e);this.slots.clear()}},rb=class{running=new Set;again=new Set;run(e,t){return this.again.add(e),this.running.has(e)?{kind:`queued`}:(this.running.add(e),{kind:`started`,done:this.loop(e,t)})}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 ib={showSha:!0,showStashCount:!0};function ab(e){let t=Object.keys(e).sort(),n={};for(let r of t)n[r]=e[r];return JSON.stringify(n)}function ob(e){let t=t=>{try{return r.statSync(c.join(e,t)).mtimeMs}catch{return 0}};return{head:t(`HEAD`),index:t(`index`)}}function sb(e,t){return e.head!==t.head||e.index!==t.index}function cb(e){let t=[],n=c.join(e,`refs/heads`);try{r.statSync(n).isDirectory()&&t.push({path:n})}catch{}return{files:[c.join(e,`HEAD`),c.join(e,`index`)],dirs:t}}var lb=class extends Xy{entries=new Map;subscribersByRepo=new Map;fetchInFlight=new Map;resolutions=new Map;prCache=new Map;prFetchInFlight=new Map;refreshes=new rb;hits=0;misses=0;invalidations=0;inner;ttlMs;maxEntries;watchers;ownsWatchers;logger;sanityTimer=null;constructor(e={}){super(),this.inner=e.inner??new Xy,this.ttlMs=e.ttlMs??3e4,this.maxEntries=e.maxEntries??64,this.logger=e.logger??eb,e.watchers?(this.watchers=e.watchers,this.ownsWatchers=!1):(this.watchers=new nb({logger:this.logger}),this.ownsWatchers=!0);let t=e.sanityIntervalMs??3e5;t>0&&(this.sanityTimer=setInterval(()=>this.runSanityCheck(),t),this.sanityTimer.unref())}getWatcherRegistry(){return this.watchers}getStats(){return{size:this.entries.size,hits:this.hits,misses:this.misses,invalidations:this.invalidations,watchers:this.watchers.size()}}resolveEffectiveGitDir(e,t){let n=`${e}|${t??``}`,r=Date.now(),i=this.resolutions.get(n);if(i&&r-i.computedAt<this.ttlMs)return this.resolutions.delete(n),this.resolutions.set(n,i),i.dir;let a=this.inner.resolveEffectiveGitDir(e,t);return this.resolutions.set(n,{dir:a,computedAt:r}),a.catch(()=>{this.resolutions.get(n)?.dir===a&&this.resolutions.delete(n)}),this.evictResolutionsIfNeeded(),a}evictResolutionsIfNeeded(){for(;this.resolutions.size>this.maxEntries;){let e=this.resolutions.keys().next().value;if(e===void 0)break;this.resolutions.delete(e)}}async getGitInfo(e,t={},n){let r=await this.resolveEffectiveGitDir(e,n);return r.kind===`ok`?this.getGitInfoForRoot(r.value,t):r}getGitInfoForRoot(e,t){let n=`${e}|${ab(t)}`,r=Date.now(),i=this.entries.get(n);if(i&&r-i.computedAt<this.ttlMs)return this.entries.delete(n),this.entries.set(n,i),this.hits++,Promise.resolve(J(i.info));let a=this.fetchInFlight.get(n);if(a)return a;let o=this.doFetch(e,n,t,r).finally(()=>{this.fetchInFlight.delete(n)});return this.fetchInFlight.set(n,o),o}async doFetch(e,t,n,r){this.misses++;let i=this.inner.resolveGitDir(e),a=ob(i),o=await this.inner.getGitInfo(e,n);if(o.kind!==`ok`)return o;let s=o.value;n.showPullRequest&&(s.pullRequest=await this.getPullRequestCached(e,s.branch)),this.dropEntry(t);let c=this.watchers.acquire(`git:${e}`,cb(i),()=>this.invalidateRepo(e));return this.entries.set(t,{info:s,computedAt:r,mtime:a,watcher:c,repoRoot:e}),this.evictIfNeeded(),o}async getPullRequestCached(e,t){let n=await this.inner.getRepoRemoteUrl(e);if(n.kind===`failed`)return n;if(n.kind===`absent`)return Y;let r=n.value,i=`${e}|${t}|${r}`,a=Date.now(),o=this.prCache.get(i);if(o){let e=o.pr.kind===`failed`?45e3:3e5;if(a-o.computedAt<e)return this.prCache.delete(i),this.prCache.set(i,o),o.pr}let s=this.prFetchInFlight.get(i);if(s)return s;let c=this.inner.resolvePullRequest(e,r).then(e=>(this.prCache.set(i,{pr:e,computedAt:Date.now()}),this.evictPrIfNeeded(),e)).finally(()=>{this.prFetchInFlight.delete(i)});return this.prFetchInFlight.set(i,c),c}evictPrIfNeeded(){for(;this.prCache.size>this.maxEntries;){let e=this.prCache.keys().next().value;if(e===void 0)break;this.prCache.delete(e)}}deliverable(e,t){return e.kind===`failed`?(this.logger(`warn`,`git fetch failed (${t}): ${e.reason}`),null):e.kind===`ok`?e.value:null}subscribe(e,t){let n=!1,r=null;return{firstDelivery:(async()=>{let i=await this.resolveEffectiveGitDir(e);if(n)return;if(i.kind!==`ok`){i.kind===`failed`&&this.logger(`warn`,`git resolve failed (subscribe ${e}): ${i.reason}`),this.safeInvoke(t,null);return}let a=i.value,o=this.subscribersByRepo.get(a);if(!o){let t=this.inner.resolveGitDir(a),n=this.watchers.acquire(`git:${a}`,cb(t),()=>this.invalidateRepo(a));o={workingDir:e,repoRoot:a,callbacks:new Set,watcher:n},this.subscribersByRepo.set(a,o)}o.callbacks.add(t),r={repoRoot:a,entry:o};let s=await this.getGitInfoForRoot(a,{...ib});n||this.safeInvoke(t,this.deliverable(s,a))})(),unsubscribe:()=>{if(n=!0,!r)return;let{repoRoot:e,entry:i}=r;i.callbacks.delete(t),i.callbacks.size===0&&(i.watcher.release(),this.subscribersByRepo.delete(e))}}}invalidateRepo(e){let t=0;for(let[n,r]of this.entries)r.repoRoot===e&&(r.watcher.release(),this.entries.delete(n),t++);t>0&&(this.invalidations+=t,this.logger(`info`,`gitCache invalidate ${e} dropped=${t}`)),this.refreshSubscribers(e)}refreshSubscribers(e){let t=this.subscribersByRepo.get(e);!t||t.callbacks.size===0||this.refreshes.run(e,()=>this.refreshOnce(e))}async refreshOnce(e){let t=this.subscribersByRepo.get(e);if(!t||t.callbacks.size===0)return;let n=await this.getGitInfoForRoot(e,{...ib}),r=this.deliverable(n,e),i=this.subscribersByRepo.get(e);if(!(!i||i.callbacks.size===0))for(let e of[...i.callbacks])i.callbacks.has(e)&&this.safeInvoke(e,r)}safeInvoke(e,t){try{e(t)}catch(e){this.logger(`warn`,`git subscriber threw: ${e.message??String(e)}`)}}dropEntry(e){let t=this.entries.get(e);t&&(t.watcher.release(),this.entries.delete(e))}evictIfNeeded(){for(;this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.dropEntry(e),this.logger(`info`,`gitCache evict ${e}`)}}runSanityCheck(){let e=new Map;for(let t of this.entries.values()){let n=e.get(t.repoRoot);n||(n=ob(this.inner.resolveGitDir(t.repoRoot)),e.set(t.repoRoot,n)),sb(t.mtime,n)&&this.invalidateRepo(t.repoRoot)}}runSanityCheckNow(){this.runSanityCheck()}close(){this.sanityTimer&&=(clearInterval(this.sanityTimer),null);for(let e of this.entries.values())e.watcher.release();this.entries.clear();for(let e of this.subscribersByRepo.values())e.callbacks.clear(),e.watcher.release();this.subscribersByRepo.clear(),this.refreshes.clear(),this.fetchInFlight.clear(),this.prCache.clear(),this.prFetchInFlight.clear(),this.resolutions.clear(),this.ownsWatchers&&this.watchers.closeAll()}};const ub=/\r\n|\r|\n/g,db=e=>J(e.replace(ub,` `).trim());function fb(e){return t=>{let n=e.exec(t)?.[1];return n===void 0?X(`regex no-match`):J(n.replace(ub,` `))}}const pb=e=>{try{return J(JSON.parse(e))}catch(e){return X(`JSON parse failed: ${e.message}`)}};function mb(e,t){return t.kind!==`ttl`||t.durationMs>=500?t:(O(`declareShell "${e}": ttl ${t.durationMs}ms below floor 500ms; clamping`),{kind:`ttl`,durationMs:500})}function hb(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 gb=`session.id`;function _b(e,t,n){return{where:`output of "${e}" in ${t}`,read:async()=>{let r=await Oe({bin:`/bin/sh`,args:[`-c`,e],cwd:t,category:`user-shell`,signal:n});if(!r.ok&&r.reason===`aborted`)throw n.reason;return r.ok?J(r.stdout):X(`shell "${e}" ${r.exitCode===null?[r.reason,r.error].filter(e=>e!==void 0).join(`: `):`exited with code ${r.exitCode}`} in ${t}`)}}}function vb(e,t,n){return{where:`"${e}"`,read:async()=>{try{let r=await S(e,{encoding:`utf8`,signal:n});return J(t===`first-line`?r.split(/\r?\n/)[0]??``:r)}catch{if(n.aborted)throw n.reason;return X(`file unreadable: ${e}`)}}}}function yb(e,t,n){if(e.kind!==`ok`)return e;let r=t(e.value);return r.kind===`failed`?X(`${r.reason} in ${n}`):r}const bb=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],xb=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Sb=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Cb=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function wb(e,t){let n=[[`2006`,e=>String(e.getFullYear())],[`January`,e=>bb[e.getMonth()]],[`Monday`,e=>Sb[e.getDay()]],[`Jan`,e=>xb[e.getMonth()]],[`Mon`,e=>Cb[e.getDay()]],[`15`,e=>String(e.getHours()).padStart(2,`0`)],[`06`,e=>String(e.getFullYear()%100).padStart(2,`0`)],[`01`,e=>String(e.getMonth()+1).padStart(2,`0`)],[`02`,e=>String(e.getDate()).padStart(2,`0`)],[`04`,e=>String(e.getMinutes()).padStart(2,`0`)],[`05`,e=>String(e.getSeconds()).padStart(2,`0`)],[`PM`,e=>e.getHours()<12?`AM`:`PM`],[`pm`,e=>e.getHours()<12?`am`:`pm`],[`1`,e=>String(e.getMonth()+1)],[`2`,e=>String(e.getDate())],[`3`,e=>String(e.getHours()%12||12)],[`4`,e=>String(e.getMinutes())],[`5`,e=>String(e.getSeconds())]],r=``,i=0;for(;i<e.length;){let a=!1;for(let[o,s]of n)if(e.startsWith(o,i)){r+=s(t),i+=o.length,a=!0;break}a||(r+=e[i],i++)}return r}const Tb={branch:`string`,sha:`string`,dirty:`boolean`,ahead:`number`,behind:`number`,stash:`number`};function Eb(e,t,n,r){if(e===null){if(n!==void 0)return n;let e=Tb[t];try{return Ab(r,e)}catch{return jb(e)}}switch(t){case`branch`:return e.branch===`detached`?``:e.branch;case`sha`:return Dy(e.sha,``);case`dirty`:return e.status!==`clean`;case`ahead`:return Dy(e.aheadBehind,{ahead:0,behind:0}).ahead;case`behind`:return Dy(e.aheadBehind,{ahead:0,behind:0}).behind;case`stash`:return Dy(e.stashCount,0)}}var Db=class{watchers=new Map;subscribe(e,t){let n=this.watchers.get(e);if(!n){let t=new Set,r;try{r=s(e,()=>{for(let e of t)e()})}catch{return()=>{}}n={watcher:r,callbacks:t},this.watchers.set(e,n)}return n.callbacks.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){let n=this.watchers.get(e);n&&(n.callbacks.delete(t),n.callbacks.size===0&&(n.watcher.close(),this.watchers.delete(e)))}dispose(){for(let{watcher:e}of this.watchers.values())e.close();this.watchers.clear()}size(){return this.watchers.size}},Ob=class{buckets=new Map;subscribe(e,t){let n=this.buckets.get(e);if(!n){let t=new Set;n={timer:ee(()=>{for(let e of t)e()},e),callbacks:t},this.buckets.set(e,n)}return n.callbacks.add(t),()=>this.unsubscribe(e,t)}unsubscribe(e,t){let n=this.buckets.get(e);n&&(n.callbacks.delete(t),n.callbacks.size===0&&(T(n.timer),this.buckets.delete(e)))}dispose(){for(let{timer:e}of this.buckets.values())T(e);this.buckets.clear()}bucketCount(){return this.buckets.size}};function kb(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function Ab(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`?jv(e):t===`number`?Mv(e):Nv(e)}function jb(e){return e===`number`?0:e===`boolean`?!1:``}var Mb=class{inputMetas=new Map;lastErrors=new Map;watchMgr=new Db;ttlMgr=new Ob;gitSubscriptions=new Map;cleanups=[];inFlight=new Map;reads=new rb;abort=new AbortController;drawn=Ov.observable.box(F.TRUECOLOR);drawnAt=()=>this.drawn.get();engine=Sy(void 0,void 0,this.drawnAt);gitProvider;ownsGitProvider;sessionState;constructor(e,t=``,n,r){this.store=e,this.defaultEmptyValue=t,n?(this.gitProvider=n,this.ownsGitProvider=!1):(this.gitProvider=new lb({sanityIntervalMs:0}),this.ownsGitProvider=!0),this.sessionState=r}get variableStore(){return this.store}declareLiteral(e,t){this.store.defineBox(e,Av(t),t)}declareInput(e,t,n,r){let i=r===void 0?this.defaultFor(n):r;this.store.defineBox(e,n,i),this.inputMetas.set(e,{path:t,varDefault:r})}declareEnv(e,t,n){let r=process.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,_b(t,n.cwd,this.abort.signal),mb(e,n.cache),n.parse)}declareFile(e,t,n){this.declareSource(e,vb(t,n.readMode??`whole`,this.abort.signal),n.cache,n.parse)}declareSource(e,t,n,r){let i=this.publisherFor(e,r,t.where),a=()=>this.runSource(e,t,i);a(),this.registerCachePolicy(e,n,a)}publisherFor(e,t,n){switch(t.kind){case`text`:return this.scalarPublisher(e,db,t.default,n);case`regex`:return this.scalarPublisher(e,fb(t.regex),t.default,n);case`json`:return this.documentPublisher(e,t.default,n)}}scalarPublisher(e,t,n,r){let i=this.stringInitial(n);return this.store.defineBox(e,`string`,i),n=>{let a=yb(n,t,r);this.noteOutcome(e,a),this.store.setBox(e,Dy(a,i))}}documentPublisher(e,t,n){let r=t===void 0?Y:J(t);return this.store.defineDocument(e,r),i=>{let a=yb(i,pb,n);this.noteOutcome(e,a),this.store.setDocument(e,a.kind===`ok`||t===void 0?a:r)}}runSource(e,t,n){let r=this.reads.run(e,()=>t.read().then(n,e=>{if(e!==this.abort.signal.reason)throw e}));r.kind===`started`&&this.track(e,r.done)}track(e,t){let n=t.finally(()=>{this.inFlight.get(e)===n&&this.inFlight.delete(e)});this.inFlight.set(e,n)}async settled(e){let t=Date.now()+e;for(;this.inFlight.size>0;){let e=t-Date.now();if(e<=0)break;let n,r=await Promise.race([Promise.all(this.inFlight.values()).then(()=>`settled`),new Promise(t=>{n=setTimeout(()=>t(`deadline`),e)})]);if(clearTimeout(n),r===`deadline`)break}return[...this.inFlight.keys()]}declareTemplate(e,t,n={}){let r=this.engine.parse(t);this.store.defineComputed(e,`string`,t=>{let i=Cy(this.store);try{let t=r.evaluate(i).map(e=>e.plain).join(``);return this.lastErrors.delete(e),t}catch(t){let r=t instanceof Error?t.message:String(t);if(this.recordError(e,r),n.varDefault===void 0)throw Error(`variable "${e}": ${r}`);return n.varDefault}});try{this.store.read(e)}catch{}}declareTime(e,t){let n=t.ttlMs??1e3;this.store.defineBox(e,`string`,(e=>{try{return wb(t.format,e)}catch{return this.stringInitial(t.varDefault)}})(new Date));let r=this.ttlMgr.subscribe(n,()=>{try{this.store.setBox(e,wb(t.format,new Date)),this.lastErrors.delete(e)}catch(n){this.applyFallback(e,`string`,t.varDefault,n instanceof Error?n.message:String(n))}});this.cleanups.push(r)}declareGit(e,t){let n=Tb[t.field],r=t.varDefault===void 0?jb(n):Ab(t.varDefault,n);this.store.defineBox(e,n,r);let i=this.gitSubscriptions.get(t.cwd);if(!i){let e=new Map,n=this.gitProvider.subscribe(t.cwd,t=>{this.store.runInAction(()=>{for(let[n,r]of e)for(let{name:e,varDefault:i}of r)this.store.setBox(e,Eb(t,n,i,this.defaultEmptyValue))})});i={fieldSubs:e,firstDelivery:n.firstDelivery,unsubscribe:n.unsubscribe},this.gitSubscriptions.set(t.cwd,i)}let a=i.fieldSubs.get(t.field);a||(a=[],i.fieldSubs.set(t.field,a)),a.push({name:e,varDefault:t.varDefault}),this.track(e,i.firstDelivery)}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(gb);if(typeof i!=`string`||!i)return r;let a=n.get(i,t.key);return a===null?r:a})}applyInput(e){this.store.runInAction(()=>{for(let[t,n]of this.inputMetas){let r=kb(e,n.path),i=this.store.getType(t);if(r!==void 0)try{this.store.setBox(t,Ab(r,i)),this.lastErrors.delete(t)}catch(e){this.applyFallback(t,i,n.varDefault,e instanceof Error?e.message:String(e))}else this.applyFallback(t,i,n.varDefault,`input path "${n.path}" not found in payload`)}})}drawAt(e){this.store.runInAction(()=>this.drawn.set(e))}getLastError(e){return this.lastErrors.get(e)}dispose(){this.abort.abort();for(let e of this.cleanups)e();this.cleanups.length=0;for(let e of this.gitSubscriptions.values())e.unsubscribe();this.gitSubscriptions.clear(),this.reads.clear(),this.watchMgr.dispose(),this.ttlMgr.dispose(),this.ownsGitProvider&&this.gitProvider.close()}registerCachePolicy(e,t,n){switch(t.kind){case`never`:break;case`ttl`:{let e=this.ttlMgr.subscribe(t.durationMs,n);this.cleanups.push(e);break}case`watch_file`:{let e=this.watchMgr.subscribe(t.path,n);this.cleanups.push(e);break}case`key`:{let e=this.engine.parse(t.template),r=(0,Ov.reaction)(()=>{let t=Cy(this.store);try{return e.evaluate(t).map(e=>e.plain).join(``)}catch{return``}},n);this.cleanups.push(r);break}case`depends_on`:{let e=(0,Ov.reaction)(()=>t.varNames.map(e=>this.store.changeKey(e)).join(`,`),n);this.cleanups.push(e);break}}}applyFallback(e,t,n,r){if(this.recordError(e,r),n!==void 0){this.store.setBox(e,n);return}try{this.store.setBox(e,Ab(this.defaultEmptyValue,t))}catch{this.store.setBox(e,jb(t))}}defaultFor(e){try{return Ab(this.defaultEmptyValue,e)}catch{return jb(e)}}stringInitial(e){return e===void 0?typeof this.defaultEmptyValue==`string`?this.defaultEmptyValue:``:e}recordError(e,t){this.lastErrors.set(e,{timestamp:Date.now(),message:t})}noteOutcome(e,t){t.kind===`ok`?this.lastErrors.delete(e):this.recordError(e,t.kind===`failed`?t.reason:`no value`)}};const Nb={project_dir:{kind:`input`,path:`workspace.project_dir`,default:``},[gb]:{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:``},"theme.effective":{kind:`input`,path:`theme.effective`,default:``},"style.effective":{kind:`input`,path:`style.effective`,default:``},"preset.effective":{kind:`input`,path:`preset.effective`,default:``},"preset.customized":{kind:`input`,path:`preset.customized`,type:`boolean`,default:!1},"preset.bundled":{kind:`input`,path:`preset.bundled`,type:`boolean`,default:!0},"endcaps.effective":{kind:`input`,path:`endcaps.effective`,default:``},"variation.effective":{kind:`input`,path:`variation.effective`,default:``},"charset.effective":{kind:`input`,path:`charset.effective`,default:``},"colorCompatibility.effective":{kind:`input`,path:`colorCompatibility.effective`,default:``},"autoWrap.effective":{kind:`input`,path:`autoWrap.effective`,type:`boolean`,default:!0},"padding.effective":{kind:`input`,path:`padding.effective`,type:`number`,default:1},"updateNotice.effective":{kind:`input`,path:`updateNotice.effective`,type:`boolean`,default:!0},"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:``},"git.repoUrl":{kind:`input`,path:`git.repoUrl`,default:``}},Pb=`ne .tmux.pane ""`,Fb={theme:{configKey:`palette`,sessionKey:`theme`,effectiveVar:`theme.effective`,label:`🎨`},preset:{configKey:`preset`,sessionKey:`preset`,effectiveVar:`preset.effective`,label:`▦`},style:{configKey:`style`,sessionKey:`style`,effectiveVar:`style.effective`,label:`◐`},endcaps:{configKey:`endcaps`,sessionKey:`endcaps`,effectiveVar:`endcaps.effective`,label:`✦`},variation:{configKey:`variation`,sessionKey:`variation`,effectiveVar:`variation.effective`,label:`🎼`},autoWrap:{configKey:`autoWrap`,sessionKey:`autoWrap`,effectiveVar:`autoWrap.effective`,label:`wrap`},padding:{configKey:`padding`,sessionKey:`padding`,effectiveVar:`padding.effective`,label:`padding`},updateNotice:{configKey:`updateNotice`,sessionKey:`updateNotice`,effectiveVar:`updateNotice.effective`,label:`update notice`}},Ib=Object.values(Fb),Lb=[{configKey:`charset`,effectiveVar:`charset.effective`},{configKey:`colorCompatibility`,effectiveVar:`colorCompatibility.effective`}],Rb=new Set(Lb.map(e=>e.configKey)),zb=new Map([...Ib,...Lb].map(e=>[e.configKey,e.effectiveVar])),Bb=new Map(Ib.map(e=>[e.sessionKey,e.effectiveVar]));function Vb(e){return Object.fromEntries(Object.keys(Fb).map(t=>[t,e(t)]))}const Hb=new Map(Object.keys(Fb).map(e=>[Fb[e].sessionKey,e]));function Ub(e,t,n){let r=new Set,i=e=>{for(let t of _v(e??``,n).keys())r.add(t)};for(let t of Object.values(e.segments))i(t.template),i(t.bg),i(t.fg),i(t.when);for(let e of t)for(let t of Ms(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(gb);for(let t of Object.values(e.actions)){r.add(gb),`copy`in t&&i(t.copy),`open`in t&&i(t.open);let e=`set`in t?Bb.get(t.set):void 0,n=`persist`in t?zb.get(t.persist):void 0;e!==void 0&&r.add(e),n!==void 0&&r.add(n)}return r}function Wb(e,t,n){let r=wv({...n,variables:{...n.variables,...e.variables},segments:{...n.segments,...e.segments}}),i={};for(let a of Ub(e,t,n.helpers)){if(Cv(a,r))continue;let e=Nb[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}const Gb=new Map,Kb=new Map;function qb(e){let t=Yb(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 Jb(e,t){return e===`bar`?t:qb(e)}function Yb(e){let t=Gb.get(e);if(t!==void 0)return t;let n=Tr(e);return n===null?null:(Gb.set(e,n),n)}function Xb(e,t){let n=`${e.name} ${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,r=Kb.get(n);if(r!==void 0)return r;let i=Nr(e,t);return Kb.set(n,i),i}function Zb(e){let t=Yb(e);return t===null?null:{kind:`decided`,name:e,value:t}}function Qb(e,t,n){let r=Zb(e);return r===null?(n(`${t} rendered "${Xa}": "${e}" names no installed theme${Ya(e)}`),ex()):r}function $b(e,t,n){return ao(e,t,n,ex(),Zb)}function ex(){return Zb(Xa)}function tx(e){return oo($b(void 0,null,e),ex).value}const nx=new Map;function rx(e,t,n){nx.set(e,{permanent:!0,resolve:t,paletteOf:n})}rx(`themes`,()=>Qa(),e=>qb(e));const ix=`placementThemes`;rx(ix,$a,(e,t)=>Jb(e,t.palette)),rx(`endcaps`,()=>fo),rx(`variations`,()=>yo),rx(`charsets`,()=>ho),rx(`colorCompatibilities`,()=>_o);function ax(e){return new Map([[`styles`,{members:Object.keys(e.styles),paletteOf:(t,n)=>Xb(n.basePalette,e.styles[t])}],[`presets`,{members:D_(e.presets)}]])}function ox(e){return[...new Set([...nx.keys(),...e.keys()])]}function sx(e,t){if(typeof e!=`string`)return{members:e};let n=t.get(e);if(n)return n;let r=nx.get(e);if(r)return{members:r.resolve(),paletteOf:r.paletteOf};throw Error(`unknown option domain "${e}" (have: ${ox(t).join(`, `)})`)}function cx(e){return{label:e.label,domain:lx(e.domain)}}function lx(e){return e===`theme`?{from:ix}:e===`bool`||`min`in e?e:{from:e}}function ux(e,t,n,r,i){let a=Jc(e.label),{domain:o}=e;if(o===`bool`)return{kind:`inline`,template:`{{ action "${r}" "☑ ${a}" "☐ ${a}" }}`,actions:{[r]:{set:t,cycle:[...wo]}},variables:{}};if(`from`in o)return dx(a,t,r,i,o.from);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 dx(e,t,n,r,i){let a={variable:r,key:r,member:n},o=y_(r,n),s=`${n}.open`,c=b_(r),l=`${c}.first`;return{kind:`picker`,template:`{{ "${e}" }} {{ carousel "${n}" 0 "${s}" }}`,actions:{[n]:{set:t,from:i},[o]:nl(r,n),[c]:{set:c,int:!0},[l]:{set:c,to:`0`},[s]:{do:[o,l]}},variables:{[r]:tl(r,Wc),[c]:{kind:`state`,key:c,default:`0`}},list:{ref:a,template:`{{ picker "${n}" "${c}" false true true }}`}}}const fx=/^segments\.([^.]+)\.palette$/,px=/^presets\.(.+)\.root$/,mx=/^presets\.(.+)\.globals\.([^.]+)$/;function hx(e){return`presets.${e}.root`}function gx(e,t){return`presets.${e}.globals.${t}`}function _x(e){if(kl(e))return{scope:`globals`,field:e};let t=fx.exec(e);if(t)return{scope:`segment-palette`,segment:t[1]};let n=mx.exec(e);if(n&&Sl(n[2]))return{scope:`preset-globals`,preset:n[1],field:n[2]};let r=px.exec(e);return r?{scope:`preset-root`,preset:r[1]}:null}function vx(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`]}}const yx=`open`;function bx(e,t,n,r){let i={variable:e,key:e,member:yx};return r.variables[e]=tl(e,Wc),r.actions[e]=nl(e,yx),r.segments[e]={template:Qc(e,`(?)`,`✕`),...xx(n)},Yc(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 xx(e){let[t,...n]=e;return t===void 0?{}:{when:Xc(t,...n)}}const Sx=`none`;var Cx=class extends Error{constructor(e,t,n){super(`Invalid ${t} color ${JSON.stringify(e)}: ${n}`),this.name=`ColorSpecError`}};function wx(e,t,n,r,i){let{palette:a,tint:o}=e,s=Tx(n,i),c=s!==Sx,l=c?s===void 0?o:Ex(a,s,`bg`):Ex(a,`background`,`bg`);e.bg=l;let u=Tx(r,i),d=u===void 0?c?Aa(a,l,t):void 0:Ex(a,u,`fg`);return new B({...c&&{bgcolor:vn.fromRgba(l)},...d!==void 0&&{color:vn.fromRgba(d)}})}function Tx(e,t){if(e!==void 0)return e.evaluate(t).map(e=>e.plain).join(``)}function Ex(e,t,n){try{return $n(e,t)}catch(e){throw e instanceof Xn?new Cx(t,n,e.message):e}}const Dx={help:[`-h`,`--help`],version:[`-V`,`--version`]},Ox=[`✚ inserts`,`✖ removes`,`⚙️ configures`,`↺ resets layout`],kx=`
91
91
  cc-candybar - Beautiful powerline statusline for Claude Code
92
92
 
93
93
  Usage: cc-candybar [options]
94
94
 
95
95
  Standalone Commands:
96
- ${Ex.help.join(`, `).padEnd(25)}Show this help
97
- ${Ex.version.join(`, `).padEnd(25)}Print the version of this runtime (cc-candybar <version>)
96
+ ${Dx.help.join(`, `).padEnd(25)}Show this help
97
+ ${Dx.version.join(`, `).padEnd(25)}Print the version of this runtime (cc-candybar <version>)
98
98
 
99
99
  Debugging:
100
100
  CC_CANDYBAR_DEBUG=1 Enable debug logging for troubleshooting
@@ -117,7 +117,7 @@ Configuration:
117
117
  failed row's [fix] to repair it (the same checks \`cc-candybar doctor\` runs).
118
118
 
119
119
  Anywhere the bar shows (?), clicking it reveals these same instructions
120
- in place. In edit mode: ${Dx.join(`, `)}.
120
+ in place. In edit mode: ${Ox.join(`, `)}.
121
121
 
122
122
  Subcommands:
123
123
  install One-shot setup: stages the runtime (native render
@@ -135,18 +135,21 @@ Subcommands:
135
135
  request totals. Does not spawn a daemon.
136
136
 
137
137
  Config tooling:
138
- doctor Check your setup the way the bar's 🩺 doctor does —
138
+ doctor [file] Check your setup the way the bar's 🩺 doctor does —
139
139
  one line per check. Exit 0 all ok, 1 any failed,
140
140
  2 usage error / unreadable settings. Run it from a
141
141
  Claude Code shell (or inside the same tmux pane) so
142
- it sees Claude Code's own environment.
142
+ it sees Claude Code's own environment. [file] is
143
+ the config to check, when the statusline command
144
+ names one with --config.
143
145
  check [--render] [file] Validate a config on the full render pipeline (parse
144
- → merge → validate → register → render) with no
145
- daemon. With no path, checks the same file the daemon
146
- would load from here. Exit 0 clean (warnings on
147
- stderr), 1 invalid, 2 unreadable. --render also
148
- prints the bar it rendered, so you can read a config
149
- without installing it. "lint" is an alias.
146
+ → merge → validate → register → render, under
147
+ every preset) with no daemon. With no path, checks
148
+ the same file the daemon would load from here. Exit
149
+ 0 clean (warnings on stderr), 1 invalid, 2
150
+ unreadable. --render also prints the bar a fresh
151
+ session opens on, so you can read a config without
152
+ installing it. "lint" is an alias.
150
153
  schema Print the JSON Schema for the config file shape
151
154
  (.cc-candybar.json5). Point an editor's $schema at it
152
155
  for autocomplete + structural validation.
@@ -155,26 +158,27 @@ Config tooling:
155
158
  config [--json] The effective merged config. (All three query the
156
159
  running daemon; none spawn one.)
157
160
 
158
- `,kx=`readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3`,Ax={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function jx(e){let t=e[Ax.socket]??``,n=e[Ax.pane]??``;if(t===``||n===``)return null;let r=e[Ax.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}const Mx=Ax.truecolor,Nx=[{name:`tmuxTruecolor`,label:`tmux truecolor`,probe:({tmux:e,claudeSettings: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`:{if(e.termfeatures.kind===`failed`)return{ok:!1,reason:`tmux could not be asked: ${e.termfeatures.reason}`};if(!e.termfeatures.value.includes(`RGB`)||e.hint.truecolor!==null)return{ok:!0};let n=t.env[Mx];return typeof n==`string`&&n!==``?{ok:!1,reason:`${Mx} is set in ${t.path} — restart Claude Code to apply`}:{ok:!1,reason:`Claude Code renders the bar in 256 colours inside tmux`,fix:{kind:`claude-settings-env`,name:Mx,value:`1`}}}}}}];function Px(e){return Nx.map(t=>({check:t,verdict:t.probe(e)}))}function Fx(e){return Nx.find(t=>t.name===e)}const Ix=`${K}doctor.`;function Lx(e){let t=`${Ix}${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`}}function Rx(e){return e.flatMap(({check:e,verdict:t})=>{let n=Lx(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:``},{key:n.fixable,value:Co}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:t.reason},{key:n.fixable,value:t.fix===void 0?Co:So}]})}const zx={copySession:{copy:`{{ .session.id }}`},copyResume:{copy:`{{ .resume_command }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},openConfig:{open:`{{ .config_path }}`}};function Bx(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(zx).map(([t,n])=>[`${e}${t}`,n]))}}const Vx=`armed`,Hx=`disarmed`,Ux=`.armed`,Wx=e=>e.endsWith(Ux);function Gx(e,t,n){let r=`${e}${Ux}`,i=`${e}.arm`,a=`${e}.disarm`,o=`(eq .${e} "${Vx}")`;return{template:`{{ if ${o} }}{{ action "${e}" "${t.confirm}" }} {{ action "${a}" "✕" }}{{ else }}{{ action "${i}" "${t.arm}" }}{{ end }}`,actions:{[i]:{set:r,to:Vx},[a]:{set:r,to:Hx},[e]:{do:[a,...n]}},armed:o,variables:{[e]:{kind:`state`,key:r,default:Hx}},disarm:a}}const Kx=RegExp(`^/[^\\s\\x00-\\x1f\\x7f-\\x9f/][^\\x00-\\x1f\\x7f-\\x9f]*$`);function qx(e){return typeof e==`string`&&Kx.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 Jx(e){let t=qx(e);if(t.kind===`refused`)throw Error(t.reason);return t.line}const Yx=[`/compact`,`/model`],Xx=`/clear`;function Zx(e){let t=t=>`${e}${t.slice(1)}`,n=`${e}clear.slash`,r=Gx(`${e}clear`,{arm:Xx,confirm:`${Xx} ✓ confirm`},[n]);return{template:Yx.map(e=>`{{ action "${t(e)}" "${e}" }} `).join(``)+r.template,when:`{{ ${Nb} }}`,actions:{...Object.fromEntries(Yx.map(e=>[t(e),{slash:Jx(e)}])),...r.actions,[n]:{slash:Jx(Xx)}},variables:r.variables,disarm:r.disarm}}function Qx(e,t){let n=(e.CLAUDE_CONFIG_DIR??``).split(`,`)[0].trim();return n===``?void 0:c.resolve(t,n)}function $x(e){return e??c.join(m.homedir(),`.claude`)}function eS(e){return c.join(e,`settings.json`)}function tS(e){return c.join(e,`plugins`,`installed_plugins.json`)}function nS(e){return r.existsSync(e)?r.readFileSync(e,`utf8`):``}function rS(e){let t;try{let n=nS(e);if(/^\s*$/.test(n))return{};t=Ko.parse(n)}catch(t){throw Error(`cannot read ${e}: ${iS(t)}`,{cause:t})}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`cannot read ${e}: not a JSON object`);return t}const iS=e=>e instanceof Error?e.message:String(e),aS=Array.from({length:10},(e,t)=>(t+1)*1e5),oS=aS[0],sS=aS[aS.length-1];function cS(e){let t;try{t=rS(e)}catch(e){return X(e instanceof Error?e.message:String(e))}let n=t.autoCompactWindow;return n===void 0?J(`auto`):typeof n==`number`&&Number.isInteger(n)&&n>=oS&&n<=sS?J(n):X(`${e}: autoCompactWindow is ${JSON.stringify(n)}, not a window /autocompact accepts (${oS}–${sS} tokens)`)}function lS(e,t){let n=Math.min(t??sS,sS),r=e===`auto`?n:Math.min(e,n);return{window:e===`auto`?0:e,applied:e===`auto`?0:r,lower:aS.filter(e=>e<r).at(-1)??0,higher:aS.find(e=>e>r&&e<=n)??0}}function uS(e,t){return{template:`{{ if ne .autocompact.error "" }}⇲ ⚠ {{ .autocompact.error }}{{ else }}⇲ {{ if eq .autocompact.window 0 }}auto{{ else }}${t(`.autocompact.applied`)}{{ end }}{{ if ${Nb} }}{{ 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:Jx(`/autocompact auto`)},...Object.fromEntries(aS.map(t=>[`${e}${t}`,{slash:Jx(`/autocompact ${t}`)}]))}}}const dS=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 }}`,fS=`${K}menu`,pS=`open`,mS=`${K}edit`,hS=`${K}toolbar`,gS=Bx(K),_S=`${K}commands`,vS=Zx(`${_S}.`),yS=`${K}autocompact`,bS=uS(`${yS}.`,dS),xS=e=>({kind:`segment`,name:e}),SS=`${K}tab`,CS=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],wS=e=>`${SS}.${e}`,TS=e=>`${wS(e)}.toggle`,ES=e=>({variable:SS,key:SS,member:e}),DS=`${K}save`,OS=`${K}preset.save`,kS=`${K}preset.delete`,AS=`${K}resetAll`,jS=`${fS}.toggle`,MS={variable:fS,key:fS,member:pS},NS=`${K}undo`,PS=`${K}back`,FS=`${PS}.step`,IS=`${K}navigation.back`,LS=PS,RS={template:`{{ if gt .${IS} 0 }}{{ action "${PS}" "◁" }}{{ else }}{{ fg (${kx}) "◁" }}{{ end }}`},zS=`${K}redo`,BS=`${K}doctor`,VS=`${BS}.run`,HS=e=>`${BS}.fix.${e}`,US=e=>`${BS}.${e}`,WS=v_(`${K}pickers`),GS=[{template:`{{ themePreview }}`}],KS={template:`{{ layoutPreview }}`},qS={preset:[KS,{when:`{{ not .preset.bundled }}`,template:`{{ action "${kS}" (printf "🗑 delete %s" .${Pb.preset.effectiveVar}) }}`}],theme:GS,style:GS,variation:[KS]},JS=e=>`${K}${e}`,YS=e=>`${K}apply.${e}`,XS=e=>`${K}reset.${e}`,ZS=e=>`${K}list.${e}`,QS=(e,t)=>`${ZS(e)}.${t}`,$S=e=>`${K}resettable.${e}`,eC=e=>e.length===0?`false`:`(or ${e.map(e=>`.${$S(e)}`).join(` `)})`,tC=Object.keys(Pb).map(e=>{let t=Pb[e],n=pl(t.configKey);if(n===`text`)throw Error(`settings menu: globals.${t.configKey} is free text, which no control can change — list it in UNCONTROLLED_GLOBALS instead of SETTINGS`);let r=lx({label:t.label,domain:n},t.sessionKey,t.effectiveVar,YS(e),WS);return{...t,name:e,control:r,beneath:qS[e]??[]}}),nC={preset:`door`,theme:`look`,style:`look`,variation:`look`,endcaps:`look`,autoWrap:`layout`,padding:`layout`,updateNotice:`config`},rC=e=>tC.filter(t=>nC[t.name]===e),iC=e=>rC(e).map(gC);new Set(tC.flatMap(e=>[e.sessionKey,e.configKey]));const aC=Gx(AS,{arm:`⟲`,confirm:`⟲ reset all?`},tC.map(e=>XS(e.name))),oC=[`unsaved`,`history.undo`,`history.redo`],sC=e=>`${K}${e}`,cC=sC(`unsaved`),lC=(e,t)=>({body:t,shown:`(gt .${sC(e)} 0)`}),uC=[lC(`unsaved`,`{{ action "${DS}" (printf "💾 save %d" .${cC}) }}`),lC(`history.undo`,`{{ action "${NS}" "↶" }}`),lC(`history.redo`,`{{ action "${zS}" "↷" }}`),{body:aC.template,shown:`(or ${eC(tC.map(e=>e.name))} ${aC.armed})`}],dC={when:`{{ or ${uC.map(e=>e.shown).join(` `)} }}`,template:`{{ $sep := "" }}`+uC.map(e=>`{{ if ${e.shown} }}{{ $sep }}${e.body}{{ $sep = " " }}{{ end }}`).join(``)},fC=[{step:aC,place:`door`},{step:vS,place:`session`}],pC=e=>e.map(e=>e.step.disarm),mC=pC(fC),hC=pC(fC.filter(e=>e.place!==`door`));function gC(e){let t=JS(e.name);return e.control.kind===`inline`?xS(t):Yc(t,e.control.list.ref,{kind:`container`,direction:`vertical`,children:[xS(ZS(e.name)),...e.beneath.map((t,n)=>xS(QS(e.name,n)))]},`drop`)}function _C(e){return e===fS}function vC(e){let t=xS(fS);if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[vC(n),...r]}:{kind:`container`,direction:`vertical`,children:[t,e]}}return e.kind===`container`&&e.when===void 0?{...e,children:[t,...e.children]}:{kind:`container`,direction:`horizontal`,children:[t,e]}}function yC(e){return bC(e)>0?e:vC(e)}function bC(e){let t=0;for(let n of Ms(e))n.kind===`segment`&&_C(n.name)&&(t+=1);return t}function xC(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&_C(e.name)||e.opens!==void 0&&xC(e.opens.body,!0):e.children.some(e=>xC(e,n))}const SC={session:{direction:`vertical`,content:[xS(hS),{kind:`container`,direction:`horizontal`,children:[xS(_S),xS(yS)]}]},look:{direction:`horizontal`,content:[]},layout:{direction:`horizontal`,content:[xS(OS),xS(mS)]},config:{direction:`horizontal`,content:[]},tools:{direction:`vertical`,content:[xS(BS),...Nx.map(e=>xS(US(e.name)))]}},CC=e=>({kind:`container`,direction:SC[e].direction,children:[...SC[e].content,...iC(e)]});function wC(e){return e.kind===`segment`?_C(e.name)?Yc(e.name,MS,EC,`above`):e:OC(e)}function TC(){return{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[xS(LS),...iC(`door`),xS(DS)]},{kind:`container`,direction:`horizontal`,children:CS.map(({member:e})=>Yc(wS(e),ES(e),CC(e),`drop`))}]}}const EC=TC();function DC(e){let t=new Map;for(let e of Ms(EC))e.kind===`segment`&&e.opens!==void 0&&t.set(e.opens.ref.key,e.opens.ref.variable);return[...t].map(([t,n])=>{let r=e.variables[n];if(r?.kind!==`state`||r.default===void 0)throw Error(`settings menu: the door folds "${t}", but "${n}" is not a state variable the menu declares with a default`);let i=`${fS}.fold.${yu(t)}`;return e.actions[i]={set:t,to:r.default},i})}function OC(e){return{...e,children:e.children.map(e=>wC(e))}}function kC(e){let t={variables:{[fS]:tl(fS,Wc)},actions:{[jS]:nl(fS,pS),[VS]:{doctor:`run`},[mS]:{do:[...Y_]},...gS.actions,...vS.actions,...bS.actions,[DS]:{save:!0},[NS]:{undo:!0},[FS]:{back:!0},[PS]:{do:[FS,...mC]},[zS]:{redo:!0},[OS]:{preset:`save`},[kS]:{preset:`delete`,name:`{{ .${Pb.preset.effectiveVar} }}`}},segments:{[fS]:{template:`{{ $door := ${$c(fS,el(e),el(`✖`))} }}{{ if ${Zc(MS)} }}{{ fg (color "error") $door }}{{ else }}{{ $door }}{{ end }}`},[hS]:{template:gS.template},[_S]:{template:vS.template,when:vS.when},[yS]:{template:bS.template,bg:bS.bg,when:bS.when},[LS]:RS,[DS]:dC,[OS]:{template:`{{ action "${OS}" "+ preset" }}`},[BS]:{template:`{{ action "${VS}" "🩺 doctor" }}`},[mS]:{template:`{{ action "${mS}" "✎ arrange" "✎ done" }}`}}};t.variables[IS]={kind:`input`,path:`navigation.back`,type:`number`,default:0};for(let e of oC)t.variables[sC(e)]={kind:`input`,path:e,type:`number`,default:0};t.variables[SS]=tl(SS,`session`);for(let{member:e,label:n}of CS){t.actions[TS(e)]=nl(SS,e),t.actions[wS(e)]={do:[TS(e),...hC]};let r=eC(rC(e).map(e=>e.name)),i=`(ternary ${el(` •`)} "" ${r})`,a=e=>`(print ${el(e)} ${i})`;t.segments[wS(e)]={template:`{{ ${$c(wS(e),a(n),a(`▾ ${n}`))} }}`}}return Object.assign(t.variables,vS.variables,aC.variables),jC(t),AC(t),t.actions[fS]={do:[jS,...mC,...DC(t)]},t}function AC(e){for(let t of Nx){let n=Lx(t.name),r=HS(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},e.segments[US(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${So}" }} {{ action "${r}" "[fix]" }}{{ end }}{{ end }}`}}}function jC(e){for(let t of tC){Object.assign(e.actions,t.control.actions);let n=XS(t.name);e.actions[n]={reset:t.configKey},e.variables[$S(t.name)]={kind:`input`,path:`resettable.${t.name}`,type:`boolean`,default:!1};let r=`{{ if .${$S(t.name)} }} {{ action "${n}" "↺" }}{{ end }}`;Object.assign(e.variables,t.control.variables),e.segments[JS(t.name)]={template:`${t.control.template}${r}`},t.control.kind===`picker`&&(e.segments[ZS(t.name)]={template:t.control.list.template}),t.beneath.forEach((n,r)=>{e.segments[QS(t.name,r)]=n})}Object.assign(e.actions,aC.actions)}function MC(e){let{variables:t,actions:n}=iv();Object.assign(e.variables,t),Object.assign(e.actions,n)}function NC(e){let t=kC(e.globals.menuGlyph??`🍫`);MC(t);let n={...e.presets},r=[];for(let t of D_(e.presets)){let{node:i}=A_(e,t),a=wC(yC(i));r.push(a),n[t]={...k_(e.presets,t),root:a}}let i=Ub(t,r,e);return{...e,variables:{...i,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:n}}const PC=`${Su}live`,FC=[`☐ live`,`☑ live`],IC=`${Su}done`,LC=`${Su}cancel`,RC=`${Su}rewind`,zC=`${Su}changes`,BC=`(gt .${zC} 0)`,VC=`(or ${BC} (gt .${cC} 0))`,HC={variable:PC,key:PC,member:`open`};function UC(e){return`${Su}configuring.p${e}`}function WC(e){return`and ${Zc($_)} (not ${Zc(HC)}) (ne .${UC(e)} "true")`}function GC(e){return{kind:`template`,template:`{{ or ${e.map(e=>`(eq .${K_} "${Jc(e)}")`).join(` `)} false }}`}}function KC(e,t,n){return`{{ if ${WC(e)} }}${t}{{ else }}${n}{{ end }}`}const qC=`{{ and ${Zc($_)} .preset.customized }}`,JC=wu,YC=`${Su}addable`;function XC(e){return new Map([[YC,{members:Object.keys(e.segments).filter(e=>!JC(e)),library:{groups:_u.map(e=>({id:e,label:vu[e]})),entry:t=>{let n=e.segments[t];return{group:n.group??`other`,...n.description!==void 0&&{description:n.description}}}}}]])}function ZC(e,t,n){return n.segments[e]={template:t,when:ev,bg:xx},{kind:`segment`,name:e}}function QC(e,t,n){let r=`${Su}${e.presetIdent}.remove.${t}`;return e.artifacts.actions[r]={persist:e.rootKey,removeSegment:n},`{{ fg (${`readableOn (color "error") (bgOf) ${ka}`}) (action "${r}" "✖") }}`}function $C(e){return`{{ if ${Zc($_)} }}${e}{{ end }}`}function ew(e,t){return e.reduce((e,t)=>`{{ if and ${Zc($_)} ${Zc(t)} }}true{{ else }}${e}{{ end }}`,t)}function tw(e){return e.flatMap(e=>[...Ms(e)].flatMap(e=>e.kind===`segment`&&e.opens?.ref.key===`edit.configure`?[e.opens.ref]:[]))}function nw(e,t,n){return`${Z_}${e}.${t}.${n}`}function rw(e,t,n,r){let i=Os(n),a=`${Su}${e.presetIdent}`,o=Q_(e.presetIdent,i);e.configured.push(o);let s=`${a}.configure.${t}`,c=v_(s),l=`${s}.fold`;e.artifacts.actions[l]={set:c,to:Wc},e.artifacts.actions[s]={do:[`${s}.open`,l]},e.artifacts.actions[`${s}.open`]={set:K_,to:o};let u={},d=Object.entries(r).map(([r,o])=>{let s=nw(e.presetIdent,i,r),l=`${Z_}p${e.presetIdent}.d${t}.${r}`;e.artifacts.variables[l]={kind:`state`,key:s,default:Ks(n.settings?.[r]??o.default)},u[r]={id:i,key:s,variable:l};let d=`${a}.setting.${t}.${r}`,f=lx(sx(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};let p=`${d}.list`;return e.artifacts.segments[d]={template:f.template},e.artifacts.segments[p]={template:f.list.template},Yc(d,f.list.ref,{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:p}]},`drop`)});return{term:`{{ action "${s}" "⚙️" }}`,ref:{variable:K_,key:K_,member:o},body:{kind:`container`,direction:`vertical`,children:d},drafts:u}}const iw=`${Su}label:`;function aw(e){if(e.startsWith(iw)){let t=e.slice(iw.length);return t.slice(t.indexOf(`:`)+1)}return e.startsWith(`edit.`)?void 0:e}function ow(e,t,n,r){let{artifacts:i}=n,a=Os(e),o=`${iw}${a}:${e.name}`;i.segments[o]={template:`{{ "${Jc(a)}" }}`,...t.palette!==void 0&&{palette:t.palette}};let s=e.settings?.[Vs];return{...Yc(o,r.ref,r.body,`drop`,ew([r.ref],`{{ ${WC(n.presetIdent)} }}`)),...s!==void 0&&{settings:{theme:s}},drafts:{[Vs]:r.drafts[Vs]}}}function sw(e,t,n,r){let{presetIdent:i,artifacts:a}=e,o=`${Su}${i}.insert.${t}`,s=`${Su}${i}.insertSeg.${t}`;a.actions[o]={persist:e.rootKey,insertSegmentFrom:YC,anchor:n,relation:r};let c=g_(o),l=__(s,o,void 0),u=b_(l),d=y_(l,c);return a.variables[l]=tl(l,Wc),a.variables[u]={kind:`state`,key:u,default:`0`},a.actions[d]=nl(l,c),a.actions[u]={set:u,int:!0},{host:s,template:`{{ $m := menu "${o}" "✚" "✕" }}{{ if ${Zc({variable:l,key:l,member:c})} }}{{ $m }}{{ else }}{{ fg (${`readableOn (color "success") (bgOf) ${ka}`}) $m }}{{ end }}`}}function cw(e,t){let n=[],r=e.children.findIndex(e=>e.kind===`segment`&&!JC(e.name)),i=e=>cw(e,t);for(let[a,o]of e.children.entries()){if(o.kind===`container`){n.push(i(o));continue}let s=js(o,i);if(JC(o.name)){n.push(s);continue}let c=Os(o),l=a===r?[sw(t,String(t.posCounter.n++),c,`before`)]:[],u=String(t.posCounter.n++),d=sw(t,u,c,`after`),f=QC(t,u,c),p=t.segments[o.name],m=rw(t,u,o,Hs(p)),h=$C(f),g=$C(m.term),_={kind:`container`,direction:`horizontal`,children:[...l.map(e=>ZC(e.host,e.template,t.artifacts)),{...ow(o,p,t,m),lead:h,trail:g},{...s,when:KC(t.presetIdent,`false`,o.when??`true`),lead:h,trail:g,drafts:m.drafts},ZC(d.host,d.template,t.artifacts)]};n.push(e.direction===`vertical`?{kind:`container`,direction:`horizontal`,children:[_]}:_)}return{...e,children:n,...e.when!==void 0&&{when:ew(tw(n),KC(t.presetIdent,`true`,e.when))}}}function lw(e,t,n,r,i,a,o){let s=`${Su}${t}.resetLayout`,c=`${Su}${t}.customized`;return r.actions[s]={reset:n},r.segments[c]={template:`{{ action "${s}" "↺ reset layout" }}`,when:qC},{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[...i,{kind:`segment`,name:c},a]},uw(e,o)]}}function uw(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),uw(n,t)]}:{...e,children:[...e.children,t]}}function dw(e,t,n,r,i,a){let{node:o}=A_(e,t),s={presetIdent:yu(t),rootKey:mx(t),segments:e.segments,artifacts:n,posCounter:{n:0},configured:[]},c=cw(o,s);return n.variables[UC(s.presetIdent)]=GC(s.configured),lw(c,s.presetIdent,s.rootKey,n,r,i,a)}function fw(e){let t={variables:{},actions:{},segments:{}},n=yx(`${Su}help`,Dx,[$_],t);t.variables[PC]=tl(PC,Wc),t.actions[PC]=nl(PC,HC.member),t.segments[PC]={template:Qc(PC,...FC),when:ev};let r={kind:`segment`,name:PC},i=n;t.variables[zC]={kind:`input`,path:`history.sinceEdit`,type:`number`,default:0},t.actions[IC]={do:[DS,...Y_]},t.segments[IC]={template:`{{ if ${VC} }}{{ action "${IC}" "✓ save" }}{{ else }}{{ action "${IC}" "✓ done" }}{{ end }}`,when:ev},t.actions[RC]={rewind:!0},t.actions[LC]={do:[RC,...Y_]},t.segments[LC]={template:`{{ action "${LC}" "↩ cancel" }}`,when:`{{ and ${Zc($_)} ${BC} }}`};let a=[{kind:`segment`,name:IC},{kind:`segment`,name:LC}],o={...e.presets},s=[];for(let n of D_(e.presets)){let c=dw(e,n,t,a,r,i);s.push(c),o[n]={...k_(e.presets,n),root:c}}let c=Ub(t,s,e);return{...e,variables:{...c,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:o}}const pw=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`doctor`,`ceiling`,`slash`,`do`];function mw(e){return e.ceiling===`set`?[`set`,e.to]:[`clear`]}function hw(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function gw(e,t){if(t===void 0)return{};if(!nc(t))return Q(e,`actions`,`actions must be an object, got ${rc(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=_w(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function Q(e,t,n){e.issues.push({path:t,message:n,line:W(e.source,t.split(`.`))})}function _w(e,t,n){if(!nc(n))return Q(e,t,`${t} must be an action object, got ${rc(n)}`),null;if(`persistWhen`in n)return Q(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 r=pw.filter(e=>e in n);return r.length===1?vw[r[0]](e,t,n):(Q(e,t,`action must declare exactly one of: ${pw.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const vw={set:(e,t,n)=>Xw(e,t,n,`set`,Kw),persist:(e,t,n)=>Xw(e,t,n,`persist`,qw),copy:yw(`copy`),open:yw(`open`),reset:bw,undo:Sw(`undo`),redo:Sw(`redo`),back:Sw(`back`),rewind:Sw(`rewind`),save:Sw(`save`),preset:Cw,doctor:ww,ceiling:Tw,slash:Ew,do:Dw};function yw(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Q(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=Zs(t,n,r,e);return i===null?null:{[e]:i}}}function bw(e,t,n){for(let r of Object.keys(n))r!==`reset`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=Ow(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 xw={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 Sw(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Q(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(Q(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — ${xw[e]}), got ${G(r[e])}`),null)}}function Cw(e,t,n){let r=n.preset,i=r===`save`?[`preset`]:[`preset`,`name`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a preset action. Expected only: ${i.join(`, `)}`);if(r!==`save`&&r!==`delete`)return Q(e,`${t}.preset`,`preset must be "save" or "delete", got ${G(r)}`),null;if(r===`save`)return{preset:`save`};let a=Zs(e,t,n,`name`);return a===null?null:{preset:`delete`,name:a}}function ww(e,t,n){let r=n.doctor,i=r===`run`?[`doctor`]:[`doctor`,`check`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${i.join(`, `)}`);if(r!==`run`&&r!==`fix`)return Q(e,`${t}.doctor`,`doctor must be "run" or "fix", got ${G(r)}`),null;if(r===`run`)return{doctor:`run`};let a=n.check;return typeof a!=`string`||Fx(a)===void 0?(Q(e,`${t}.check`,`doctor fix must name a check (have: ${Nx.map(e=>e.name).join(`, `)}), got ${G(a)}`),null):{doctor:`fix`,check:a}}function Tw(e,t,n){let r=n.ceiling,i=r===`clear`?[`ceiling`]:[`ceiling`,`to`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a ceiling action. Expected only: ${i.join(`, `)}`);if(r===`clear`)return{ceiling:`clear`};if(r!==`set`)return Q(e,`${t}.ceiling`,`ceiling must be "set" or "clear", got ${G(r)}`),null;let a=n.to;return typeof a!=`string`||a.trim()===``?(Q(e,`${t}.to`,`ceiling set needs \`to\`: a memento ceiling value such as "+100_000", "400000" or "off", got ${G(a)}`),null):{ceiling:`set`,to:a}}function Ew(e,t,n){for(let r of Object.keys(n))r!==`slash`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a slash action. Expected only: slash`);let r=qx(n.slash);return r.kind===`refused`?(Q(e,`${t}.slash`,r.reason),null):{slash:r.line}}function Dw(e,t,n){for(let r of Object.keys(n))r!==`do`&&Q(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===``)?(Q(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 ${G(r)}`),null):{do:r}}function Ow(e,t,n,r,i,a){let o=Zs(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(Q(e,s,i),null):o.includes(`/`)?(Q(e,s,a(o)),null):o}const kw={set:`the SessionState key to write`,persist:`the config globals field to write`};function Aw(e,t,n,r){let i=kw[r],a=Ow(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 jw(e){return e===`set`?`set-state`:`set-config`}const Mw={to:Zw(`set`)},Nw={to:Zw(`persist`)},Pw={from:Qw(`set`)},Fw={from:Qw(`persist`)},Iw={min:rT(),max:rT(),by:rT()},Lw={int:eT()},Rw={cycle:$w(`set`)},zw={cycle:$w(`persist`)},Bw={removeSegment:tT(`removeSegment`)},Vw={insertSegment:tT(`insertSegment`),anchor:tT(`anchor`),relation:nT()},Hw={insertSegmentFrom:Qw(`persist`),anchor:tT(`anchor`),relation:nT()},Uw={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},Ww={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function Gw(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=[e],s=(e,n,r)=>oc(e,t,n,r),c=wc(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?mc(s,...n):s}}const Kw=[Gw(`set`,Mw),Gw(`set`,Pw),Gw(`set`,Iw,[Uw,Ww]),Gw(`set`,Lw),Gw(`set`,Rw)],qw=[Gw(`persist`,Nw),Gw(`persist`,Fw),Gw(`persist`,Iw,[Uw,Ww]),Gw(`persist`,zw),Gw(`persist`,Bw),Gw(`persist`,Vw,[],[`insertSegment`]),Gw(`persist`,Hw,[],[`insertSegmentFrom`])];function Jw(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 Yw(e){let t=Jw(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 Xw(e,t,n,r,i){let a=Aw(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return Q(e,t,`${Yw(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)||Q(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 Zw(e){let t=jw(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>Ow(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 Qw(e){let t=jw(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===``){Q(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){Q(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===``)){Q(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){Q(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){Q(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}Q(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${G(o)}`)}}}function $w(e){let t=jw(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`)){Q(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${rc(o)}`);return}let c=o;if(c.length<2){Q(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){Q(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){Q(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){Q(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function eT(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){Q(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${G(r[n])}`);return}return!0}}}function tT(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=Zs(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){Q(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){Q(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 nT(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){Q(e,`${t}.${n}`,`relation must be "before" or "after", got ${G(i)}`);return}return i}}}function rT(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){Q(e,`${t}.${n}`,`${n} must be an integer, got ${G(i)}`);return}return i}}}function iT(e,t,n){return`${e}: "${t}" is an endcaps shape, not a style — endcaps were renamed from "style" to "endcaps"; write ${n}: "${t}"`}const aT={noun:`style key`,fields:{hueShift:vc(),chromaScale:vc({min:0}),lightnessScale:vc(),lightnessShift:vc()}};function oT(e,t){if(!nc(t))return e.issues.push({path:`styles`,message:`styles must be an object mapping style names to adaptation objects, got ${rc(t)}`,line:W(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:W(e.source,[`styles`,r])});continue}if(po(r)){e.issues.push({path:`styles.${r}`,message:iT(`styles.${r}`,r,`globals.endcaps`),line:W(e.source,[`styles`,r])});continue}let t=ic(e,aT,`styles.${r}`,i);t!==null&&(n[r]={...zn,...t})}return n}const sT={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:fd(e,`${t}.${n}`,r[n])},globals:{required:!1,json:El(),parse:(e,t,n,r)=>r[n]===void 0?void 0:Tl(e,`${t}.${n}`,r[n])}}};function cT(e,t){if(!nc(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${rc(t)}`,line:W(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:W(e.source,[`presets`,r])});continue}let t=ic(e,sT,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function lT(e,t){if(t===void 0)return{};if(!nc(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${rc(t)}`,line:W(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 ${G(i)}`,line:W(e.source,[`helpers`,r])});continue}n[r]=i}return n}const uT=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 dT(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 fT(e){let t=uT.get(e);return t===void 0?void 0:`variables.${e} is no longer read: ${dT(t)}`}function pT(e){let t=uT.get(e);return t===void 0?``:` — ".${e}" is no longer a variable: ${dT(t)}; a "${t.segment}" template reads it as ".settings.${t.setting}"`}function mT(e,t){let n=new Map;for(let e of Object.keys(t)){let t=yu(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:W(e.source,[`presets`])})}function hT(e,t,n){let r=[[[`globals`],t.globals.style],[[`editGlobals`],t.editGlobals.style],...Object.entries(t.presets).map(([e,t])=>[[`presets`,e,`globals`],t.globals?.style])];for(let[n,i]of r){if(i===void 0||io(i)||Object.prototype.hasOwnProperty.call(t.styles,i))continue;let r=`${n.join(`.`)}.style`;e.issues.push({path:r,message:po(i)?iT(r,i,`${n.join(`.`)}.endcaps`):`${r} "${i}" does not match any declared style (have: ${Object.keys(t.styles).join(`, `)})`,line:W(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:W(e.source,[`globals`,`preset`])}),mT(e,t.presets);let i=ix(t);for(let[n,r]of Object.entries(t.actions))`set`in r&&Lb.has(r.set)&&e.issues.push({path:`actions.${n}.set`,message:`actions.${n} sets "${r.set}", which has no session pick — globals.${r.set} is set in the config file only, so a click would change nothing; write it with { persist: "${r.set}", … } instead`,line:W(e.source,[`actions`,n,`set`])}),!(!(`set`in r)||!(`from`in r)||typeof r.from!=`string`)&&(ax(i).includes(r.from)||e.issues.push({path:`actions.${n}.from`,message:`actions.${n} from: references unknown option domain "${r.from}" (have: ${ax(i).join(`, `)})`,line:W(e.source,[`actions`,n,`from`])}));for(let[n,r]of Object.entries(t.actions))`do`in r&&r.do.forEach((i,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,i)?t.actions[i]:void 0,s=o===void 0?`references unknown action "${i}"`:`do`in o?`"${i}" is itself a do action — list its members here instead`:r.do.indexOf(i)===a?a>0&&hw(o)?`"${i}" 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:`"${i}" 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:W(e.source,[`actions`,n,`do`])})});for(let[n,r]of Object.entries(t.actions)){let i=`persist`in r?r.persist:`reset`in r?r.reset:null;if(i===null)continue;let a=`persist`in r?`persist`:`reset`,o=gx(i);if(o===null){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is not a config globals field (have: ${Al().join(`, `)}), a "segments.<name>.palette" target, a "presets.<name>.globals.<field>" target, or a "presets.<name>.root" target`,line:W(e.source,[`actions`,n,a])});continue}let s=gT.filter(e=>e in r);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:W(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){_T(e,t,n,a,i,o.preset,r);continue}if(o.scope===`preset-globals`&&!D_(t.presets).includes(o.preset)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" names preset "${o.preset}" which is not declared (have: ${D_(t.presets).join(`, `)})`,line:W(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}: "${i}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})${Ou(o.segment)}`,line:W(e.source,[`actions`,n,a])});continue}`min`in r&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:W(e.source,[`actions`,n,a])})}}let a=Cv(t);for(let t of a.names)t!==`settings`&&!t.startsWith(vT)||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:W(e.source,[`variables`,t])});let o=(t,n,r)=>{bC(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${fS}" ${bC(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:r}),xC(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${fS}" 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:r}),s(t)&&e.issues.push({path:n,message:`${n} sets "distribution" on a container inside a bar cell — everything inside a cell wears that cell's hue and tone, so it would place nothing. Set it on the row whose children are the cells (the horizontal container) or on the root, which places the rows.`,line:r});let i=new Map;for(let e of Ms(t)){if(e.kind!==`segment`)continue;let t=Os(e);i.set(t,[...i.get(t)??[],e])}for(let[t,a]of i){if(a.length<2)continue;let o=a[1].name,s=As(o,new Set(i.keys()));e.issues.push({path:n,message:`${n} has ${a.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: "${o}", id: "${s}" }. A placement without an "id" takes its segment's name.`,line:r})}};function s(e,t=!1){return e.kind===`segment`?!1:t&&e.distribution!==void 0||e.children.some(n=>s(n,t||Ds[e.direction]===`cell`))}let c=(n,r)=>{for(let[i,o]of Lc(n,r)){let n=W(e.source,o.split(`.`));if(i.when!==void 0&&(AT(e,`${o}.when`,i.when,a,{line:n}),kT(e,`${o}.when`,i.when,n)),i.kind===`segment`){if(_C(i.name)){(i.id!==void 0||i.settings!==void 0)&&e.issues.push({path:o,message:`${r} gives the global settings menu anchor "${fS}" an id or settings — the anchor only marks where the menu goes, so place it as the bare name "${fS}"`,line:n});continue}Object.prototype.hasOwnProperty.call(t.segments,i.name)||e.issues.push({path:o,message:`${r} entry "${i.name}" does not match any declared segment${Ou(i.name)}`,line:n}),ET(e,t,i,o,n)}}};n.root!==void 0&&c(n.root,`root`);for(let[e,t]of Object.entries(n.presets??{}))t.root!==void 0&&c(t.root,`presets.${e}.root`);let l=new Map([[`root`,Fc(t.root)]]);for(let e of D_(t.presets)){let{node:n,path:r}=A_(t,e);l.set(r,n)}for(let[t,n]of l)o(n,t,W(e.source,t.split(`.`)));for(let[n,r]of Object.entries(t.variables)){DT(e,`variables.${n}`,r,a);let t=fT(n);t!==void 0&&e.issues.push({path:`variables.${n}`,message:t,line:W(e.source,[`variables`,n])})}for(let[n,r]of Object.entries(t.segments)){if(r.vars)for(let[t,i]of Object.entries(r.vars))DT(e,`segments.${n}.vars.${t}`,i,a,n);let i=Hs(r);bT(e,n,i);let o=yT(a,i);for(let a of[`template`,`bg`,`fg`,`when`]){let s=r[a];if(typeof s==`string`){AT(e,`segments.${n}.${a}`,s,o,{segCtx:n,settings:i});for(let{name:r,site:i,via:o}of xv(s,t.helpers)){if(Object.prototype.hasOwnProperty.call(t.actions,r))continue;let s=i===`options`?` (in a picker, menu or carousel)`:``;if(o!==null){jT(e,o,`Template references unknown action "${r}"${s}`);continue}e.issues.push({path:`segments.${n}.${a}`,message:`${a} references unknown action "${r}"${s}`,line:W(e.source,[`segments`,n,a])})}}}}for(let[n,r]of Object.entries(t.variables))OT(e,`variables.${n}`,r,a);for(let[n,r]of Object.entries(t.segments))if(r.vars)for(let[t,i]of Object.entries(r.vars))OT(e,`segments.${n}.vars.${t}`,i,a,n)}const gT=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function _T(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=W(e.source,[`actions`,n,r]);if(!D_(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${D_(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(`, `)})${Ou(i)}`,line:c})},p=new Set(ks(A_(t,a).node)),m=(r,i)=>{!Du.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${Ou(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 vT=`settings.`;function yT(e,t){return{...e,names:new Set([...e.names,...Object.keys(t).map(e=>vT+e)])}}function bT(e,t,n){let r=e=>`segments.${t}.settings.${e}`,i=(n,i)=>{e.issues.push({path:r(n),message:`${r(n)}: ${i}`,line:W(e.source,[`segments`,t,`settings`,n])})},a=CT(n);for(let{setting:e,message:t}of a)i(e,t);if(!(a.length>0))for(let{setting:e,message:t}of Ws(n,ST(n)))i(e,`the defaults do not stand together: ${t}`)}function xT(e){return CT(e).length>0||Ws(e,ST(e)).length>0}function ST(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default]))}function CT(e){let t=t=>Us(wT(e,t))?.atLeast;return Object.keys(e).flatMap(n=>{let r=t(n);if(r===void 0)return[];if(r===n||Us(wT(e,r))===void 0)return[{setting:n,message:`atLeast "${r}" must name another range setting of this segment (its range settings: ${TT(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 wT(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function TT(e,t){return Object.entries(e).filter(([e,n])=>e!==t&&Us(n)!==void 0).map(([e])=>e)}function ET(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=Hs(a),s=`${r}: placement "${Os(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(`, `)})`:Gs(c,a)?void 0:`sets "${t}" to ${JSON.stringify(a)}${c.domain===`theme`?Ya(a):``}, but it must be ${Js(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])=>Gs(o[e],t))||xT(o)))for(let{message:t}of Ws(o,c))e.issues.push({path:r,message:`${s}: ${t}`,line:i})}function DT(e,t,n,r,i){n.kind===`template`&&AT(e,`${t}.template`,n.template,r,{segCtx:i}),zs(n)&&n.cache&&`key`in n.cache&&AT(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function OT(e,t,n,r,i){if(zs(n)&&n.cache&&`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:W(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function kT(e,t,n,r){try{W_.parse(n)}catch(n){e.issues.push({path:t,message:`Template parse error in ${t}: ${n.message}`,line:r})}}function AT(e,t,n,r,i){for(let[a,o]of _v(n,r.helpers)){if(Sv(a,r))continue;if(a.startsWith(vT)){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??W(e.source,t.split(`.`))});continue}if(o!==null){jT(e,o,`Template references unknown variable ".${a}"${pT(a)}`);continue}let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,s=n!==void 0&&Sv(n,r)?` (segment-local vars are namespaced — write ".${n}")`:pT(a);e.issues.push({path:t,message:`Template references unknown variable ".${a}"${s}`,line:i?.line??W(e.source,t.split(`.`))})}}function jT(e,t,n){let r=`helpers.${t}`;e.issues.some(e=>e.path===r&&e.message===n)||e.issues.push({path:r,message:n,line:W(e.source,[`helpers`,t])})}function MT(e,t){let{graph:n,nodeInfo:r}=NT(t),i=new Map,a=[];for(let e of n.keys())i.set(e,0);for(let e of n.keys())if(i.get(e)===0&&o(e))return;function o(t){i.set(t,1),a.push(t);for(let s of n.get(t)??[]){let t=i.get(s);if(t===1){let t=a.indexOf(s),n=[...a.slice(t),s],i=n[0],o=r.get(i);return e.issues.push({path:o?.declarationPath??`variables.${i}`,message:`Dependency cycle: ${n.join(` → `)}`,line:W(e.source,o?.linePathParts??[`variables`,i])}),!0}if(t===0&&o(s))return!0}return i.set(t,2),a.pop(),!1}}function NT(e){let t=new Set(Object.keys(e.variables)),n=new Map;for(let t of Object.keys(e.variables))n.set(t,{declarationPath:`variables.${t}`,linePathParts:[`variables`,t]});for(let[r,i]of Object.entries(e.segments))if(i.vars)for(let e of Object.keys(i.vars)){let i=`${r}.${e}`;t.add(i),n.set(i,{declarationPath:`segments.${r}.vars.${e}`,linePathParts:[`segments`,r,`vars`,e]})}let r=new Map;for(let e of t)r.set(e,new Set);let i=(n,i)=>{for(let a of _v(i,e.helpers).keys()){if(t.has(a)){r.get(n).add(a);continue}let e=a.split(`.`)[0];e!==a&&t.has(e)&&r.get(n).add(e)}},a=(e,n)=>{if(n.kind===`template`&&i(e,n.template),zs(n)&&(n.cache&&`key`in n.cache&&i(e,n.cache.key),n.cache&&`depends_on`in n.cache))for(let i of n.cache.depends_on)t.has(i)&&r.get(e).add(i)};for(let[t,n]of Object.entries(e.variables))a(t,n);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))a(`${t}.${e}`,r);return{graph:r,nodeInfo:n}}const PT=[`json5`,`json`];function FT(e){try{return r.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function IT(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?m.homedir()+e.slice(1):e}function LT(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?PT.map(t=>c.join(e,`.cc-candybar.${t}`)):[],...PT.map(e=>c.join(r,`.cc-candybar.${e}`)),...PT.map(e=>`${RT()}.${e}`)])]}function RT(){let e=process.env.XDG_CONFIG_HOME??c.join(m.homedir(),`.config`);return c.join(e,`cc-candybar`,`config`)}function zT(e,t,n){let r=[];for(let i of LT(e,t,n)){let e=FT(i);if(e===`present`)return{kind:`file`,path:i,unchecked:r};e!==`absent`&&r.push(e)}if(n===void 0)return{kind:`default`,unchecked:r};let[i]=r;return i===void 0?{kind:`missing`,path:n}:{kind:`unreadable`,...i}}function BT(e,t,n){let r=zT(e,t,n);return r.kind===`default`?`${RT()}.${PT[0]}`:r.path}function VT(e){return HT(e).join(`
159
- `)||null}function HT(e){switch(e.kind){case`file`:case`default`: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 UT(e,t){let n=LT(e,t).filter(e=>FT(e)===`present`),r=new Map;for(let e of n){let t=c.dirname(e),n=c.basename(e).replace(/\.(json5|json)$/,``),i=c.join(t,n);r.has(i)||r.set(i,[]),r.get(i).push(e)}let i=[...r.values()].filter(e=>e.length>1);return i.length===0?null:`config-extension collision: ${i.map(e=>{let[t,...n]=e;return`${t} shadows ${n.join(`, `)}`}).join(`; `)} — remove the duplicate`}function WT(e,t,n){return e===null?{...KT,config:Bc(KT.raw,t)}:GT(e,r.readFileSync(e,`utf-8`),t,n)}function GT(e,t,n,r){let i={source:t,...YT(e,t,r,Hu(n))};return{...i,config:Bc(i.raw,n)}}const KT={raw:{},source:``,warnings:[]};function qT({config:e,raw:t,source:n},r=`<config>`,i=new Set(Qa())){let a=[],o={source:n,issues:a,allowedPalettes:i,groups:[]};if(hT(o,e,t),MT(o,e),a.length>0)throw new xs(r,a);let s=U_(e,a);if(a.length>0)throw new xs(r,a);return fw(NC(s))}function JT(e,t,n=new Set(Qa()),r=XT){return YT(e,t,n,r).raw}function YT(e,t,n,r){let i=ZT(e,t),a=ws(e,t),o=a===null?[]:[a],s=[],c={source:t,issues:s,allowedPalettes:n??new Set(Qa()),groups:[]};if(!nc(i))throw new xs(e,[{path:``,message:`Config root must be an object, got ${rc(i)}`}],o);let l=QT(c,i,r);if(s.length>0)throw new xs(e,s,o);return{raw:l,warnings:o}}const XT=new Set;function ZT(e,t){try{return tt.default.parse(t)}catch(t){let n=t;throw new xs(e,[{path:``,message:`JSON5 syntax error: ${n.message}`,line:n.lineNumber,col:n.columnNumber}])}}function QT(e,t,n){for(let n of Object.keys(t))$T.has(n)||e.issues.push({path:n,message:`Unknown top-level key "${n}". Expected one of: ${[...$T].join(`, `)}`,line:W(e.source,[n])});let r={};return t.globals!==void 0&&(r.globals=wl(e,`globals`,t.globals)),t.variables!==void 0&&(r.variables=Wl(e,`variables`,t.variables)),t.segments!==void 0&&(r.segments=Uu(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.
161
+ `,Ax=`readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3`,jx={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function Mx(e){let t=e[jx.socket]??``,n=e[jx.pane]??``;if(t===``||n===``)return null;let r=e[jx.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}function Nx(e){let[t,...n]=e;return t===void 0?{ok:!0}:{ok:!1,reason:t,more:n}}const Px=jx.truecolor,Fx={name:`tmuxTruecolor`,label:`tmux truecolor`,probe:({tmux:e,claudeSettings: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`:{if(e.termfeatures.kind===`failed`)return{ok:!1,reason:`tmux could not be asked: ${e.termfeatures.reason}`};if(!e.termfeatures.value.includes(`RGB`)||e.hint.truecolor!==null)return{ok:!0};let n=t.env[Px];return typeof n==`string`&&n!==``?{ok:!1,reason:`${Px} is set in ${t.path} — restart Claude Code to apply`}:{ok:!1,reason:`Claude Code renders the bar in 256 colours inside tmux`,fix:{kind:`claude-settings-env`,name:Px,value:`1`}}}}}},Ix={variable:`is never read`,action:`is never clicked`,helper:`is never called`,segment:`is in no preset`},Lx=[{name:`config`,label:`config`,probe:({config:e})=>{switch(e.kind){case`failed`:{let[t=`the config failed to load`,...n]=[...e.error.split(`
162
+ `).map(e=>e.trim()).filter(e=>e!==``),...e.warnings];return{ok:!1,reason:t,more:n}}case`loaded`:return Nx([...e.warnings,...e.shadowed.map(t=>`${t} is never read — ${e.path??`another config`} is found first`),...e.unused.map(({kind:e,name:t})=>`${e} "${t}" ${Ix[e]}`)])}}},Fx];function Rx(e){return Lx.map(t=>({check:t,verdict:t.probe(e)}))}function zx(e){return Lx.find(t=>t.name===e)}const Bx=`${K}doctor.`;function Vx(e){let t=`${Bx}${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`}}function Hx(e,t=[]){return t.length===0?e:`${e} (+${t.length} more — run \`cc-candybar doctor\`)`}function Ux(e){return e.flatMap(({check:e,verdict:t})=>{let n=Vx(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:``},{key:n.fixable,value:Co}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:Hx(t.reason,t.more)},{key:n.fixable,value:t.fix===void 0?Co:So}]})}const Wx={copySession:{copy:`{{ .session.id }}`},copyResume:{copy:`{{ .resume_command }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},openConfig:{open:`{{ .config_path }}`}};function Gx(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(Wx).map(([t,n])=>[`${e}${t}`,n]))}}const Kx=`armed`,qx=`disarmed`,Jx=`.armed`,Yx=e=>e.endsWith(Jx);function Xx(e,t,n){let r=`${e}${Jx}`,i=`${e}.arm`,a=`${e}.disarm`,o=`(eq .${e} "${Kx}")`;return{template:`{{ if ${o} }}{{ action "${e}" "${t.confirm}" }} {{ action "${a}" "✕" }}{{ else }}{{ action "${i}" "${t.arm}" }}{{ end }}`,actions:{[i]:{set:r,to:Kx},[a]:{set:r,to:qx},[e]:{do:[a,...n]}},armed:o,variables:{[e]:{kind:`state`,key:r,default:qx}},disarm:a}}const Zx=RegExp(`^/[^\\s\\x00-\\x1f\\x7f-\\x9f/][^\\x00-\\x1f\\x7f-\\x9f]*$`);function Qx(e){return typeof e==`string`&&Zx.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 $x(e){let t=Qx(e);if(t.kind===`refused`)throw Error(t.reason);return t.line}const eS=[`/compact`,`/model`],tS=`/clear`;function nS(e){let t=t=>`${e}${t.slice(1)}`,n=`${e}clear.slash`,r=Xx(`${e}clear`,{arm:tS,confirm:`${tS} ✓ confirm`},[n]);return{template:eS.map(e=>`{{ action "${t(e)}" "${e}" }} `).join(``)+r.template,when:`{{ ${Pb} }}`,actions:{...Object.fromEntries(eS.map(e=>[t(e),{slash:$x(e)}])),...r.actions,[n]:{slash:$x(tS)}},variables:r.variables,disarm:r.disarm}}function rS(e,t){let n=(e.CLAUDE_CONFIG_DIR??``).split(`,`)[0].trim();return n===``?void 0:c.resolve(t,n)}function iS(e){return e??c.join(m.homedir(),`.claude`)}function aS(e){return c.join(e,`settings.json`)}function oS(e){return c.join(e,`plugins`,`installed_plugins.json`)}function sS(e){return r.existsSync(e)?r.readFileSync(e,`utf8`):``}function cS(e){let t;try{let n=sS(e);if(/^\s*$/.test(n))return{};t=Ko.parse(n)}catch(t){throw Error(`cannot read ${e}: ${lS(t)}`,{cause:t})}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`cannot read ${e}: not a JSON object`);return t}const lS=e=>e instanceof Error?e.message:String(e),uS=Array.from({length:10},(e,t)=>(t+1)*1e5),dS=uS[0],fS=uS[uS.length-1];function pS(e){let t;try{t=cS(e)}catch(e){return X(e instanceof Error?e.message:String(e))}let n=t.autoCompactWindow;return n===void 0?J(`auto`):typeof n==`number`&&Number.isInteger(n)&&n>=dS&&n<=fS?J(n):X(`${e}: autoCompactWindow is ${JSON.stringify(n)}, not a window /autocompact accepts (${dS}–${fS} tokens)`)}function mS(e,t){let n=Math.min(t??fS,fS),r=e===`auto`?n:Math.min(e,n);return{window:e===`auto`?0:e,applied:e===`auto`?0:r,lower:uS.filter(e=>e<r).at(-1)??0,higher:uS.find(e=>e>r&&e<=n)??0}}function hS(e,t){return{template:`{{ if ne .autocompact.error "" }}⇲ ⚠ {{ .autocompact.error }}{{ else }}⇲ {{ if eq .autocompact.window 0 }}auto{{ else }}${t(`.autocompact.applied`)}{{ end }}{{ if ${Pb} }}{{ 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:$x(`/autocompact auto`)},...Object.fromEntries(uS.map(t=>[`${e}${t}`,{slash:$x(`/autocompact ${t}`)}]))}}}const gS=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 }}`,_S=`${K}menu`,vS=`open`,yS=`${K}edit`,bS=`${K}toolbar`,xS=Gx(K),SS=`${K}commands`,CS=nS(`${SS}.`),wS=`${K}autocompact`,TS=hS(`${wS}.`,gS),ES=e=>({kind:`segment`,name:e}),DS=`${K}tab`,OS=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],kS=e=>`${DS}.${e}`,AS=e=>`${kS(e)}.toggle`,jS=e=>({variable:DS,key:DS,member:e}),MS=`${K}save`,NS=`${K}preset.save`,PS=`${K}preset.delete`,FS=`${K}resetAll`,IS=`${_S}.toggle`,LS={variable:_S,key:_S,member:vS},RS=`${K}undo`,zS=`${K}back`,BS=`${zS}.step`,VS=`${K}navigation.back`,HS=zS,US={template:`{{ if gt .${VS} 0 }}{{ action "${zS}" "◁" }}{{ else }}{{ fg (${Ax}) "◁" }}{{ end }}`},WS=`${K}redo`,GS=`${K}doctor`,KS=`${GS}.run`,qS=e=>`${GS}.fix.${e}`,JS=e=>`${GS}.${e}`,YS=v_(`${K}pickers`),XS=[{template:`{{ themePreview }}`}],ZS={template:`{{ layoutPreview }}`},QS={preset:[ZS,{when:`{{ not .preset.bundled }}`,template:`{{ action "${PS}" (printf "🗑 delete %s" .${Fb.preset.effectiveVar}) }}`}],theme:XS,style:XS,variation:[ZS]},$S=e=>`${K}${e}`,eC=e=>`${K}apply.${e}`,tC=e=>`${K}reset.${e}`,nC=e=>`${K}list.${e}`,rC=(e,t)=>`${nC(e)}.${t}`,iC=e=>`${K}resettable.${e}`,aC=e=>e.length===0?`false`:`(or ${e.map(e=>`.${iC(e)}`).join(` `)})`,oC=Object.keys(Fb).map(e=>{let t=Fb[e],n=pl(t.configKey);if(n===`text`)throw Error(`settings menu: globals.${t.configKey} is free text, which no control can change — list it in UNCONTROLLED_GLOBALS instead of SETTINGS`);let r=ux({label:t.label,domain:n},t.sessionKey,t.effectiveVar,eC(e),YS);return{...t,name:e,control:r,beneath:QS[e]??[]}}),sC={preset:`door`,theme:`look`,style:`look`,variation:`look`,endcaps:`look`,autoWrap:`layout`,padding:`layout`,updateNotice:`config`},cC=e=>oC.filter(t=>sC[t.name]===e),lC=e=>cC(e).map(xC);new Set(oC.flatMap(e=>[e.sessionKey,e.configKey]));const uC=Xx(FS,{arm:`⟲`,confirm:`⟲ reset all?`},oC.map(e=>tC(e.name))),dC=[`unsaved`,`history.undo`,`history.redo`],fC=e=>`${K}${e}`,pC=fC(`unsaved`),mC=(e,t)=>({body:t,shown:`(gt .${fC(e)} 0)`}),hC=[mC(`unsaved`,`{{ action "${MS}" (printf "💾 save %d" .${pC}) }}`),mC(`history.undo`,`{{ action "${RS}" "↶" }}`),mC(`history.redo`,`{{ action "${WS}" "↷" }}`),{body:uC.template,shown:`(or ${aC(oC.map(e=>e.name))} ${uC.armed})`}],gC={when:`{{ or ${hC.map(e=>e.shown).join(` `)} }}`,template:`{{ $sep := "" }}`+hC.map(e=>`{{ if ${e.shown} }}{{ $sep }}${e.body}{{ $sep = " " }}{{ end }}`).join(``)},_C=[{step:uC,place:`door`},{step:CS,place:`session`}],vC=e=>e.map(e=>e.step.disarm),yC=vC(_C),bC=vC(_C.filter(e=>e.place!==`door`));function xC(e){let t=$S(e.name);return e.control.kind===`inline`?ES(t):Yc(t,e.control.list.ref,{kind:`container`,direction:`vertical`,children:[ES(nC(e.name)),...e.beneath.map((t,n)=>ES(rC(e.name,n)))]},`drop`)}function SC(e){return e===_S}function CC(e){let t=ES(_S);if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[CC(n),...r]}:{kind:`container`,direction:`vertical`,children:[t,e]}}return e.kind===`container`&&e.when===void 0?{...e,children:[t,...e.children]}:{kind:`container`,direction:`horizontal`,children:[t,e]}}function wC(e){return TC(e)>0?e:CC(e)}function TC(e){let t=0;for(let n of Ms(e))n.kind===`segment`&&SC(n.name)&&(t+=1);return t}function EC(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&SC(e.name)||e.opens!==void 0&&EC(e.opens.body,!0):e.children.some(e=>EC(e,n))}const DC={session:{direction:`vertical`,content:[ES(bS),{kind:`container`,direction:`horizontal`,children:[ES(SS),ES(wS)]}]},look:{direction:`horizontal`,content:[]},layout:{direction:`horizontal`,content:[ES(NS),ES(yS)]},config:{direction:`horizontal`,content:[]},tools:{direction:`vertical`,content:[ES(GS),...Lx.map(e=>ES(JS(e.name)))]}},OC=e=>({kind:`container`,direction:DC[e].direction,children:[...DC[e].content,...lC(e)]});function kC(e){return e.kind===`segment`?SC(e.name)?Yc(e.name,LS,jC,`above`):e:NC(e)}function AC(){return{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[ES(HS),...lC(`door`),ES(MS)]},{kind:`container`,direction:`horizontal`,children:OS.map(({member:e})=>Yc(kS(e),jS(e),OC(e),`drop`))}]}}const jC=AC();function MC(e){let t=new Map;for(let e of Ms(jC))e.kind===`segment`&&e.opens!==void 0&&t.set(e.opens.ref.key,e.opens.ref.variable);return[...t].map(([t,n])=>{let r=e.variables[n];if(r?.kind!==`state`||r.default===void 0)throw Error(`settings menu: the door folds "${t}", but "${n}" is not a state variable the menu declares with a default`);let i=`${_S}.fold.${yu(t)}`;return e.actions[i]={set:t,to:r.default},i})}function NC(e){return{...e,children:e.children.map(e=>kC(e))}}function PC(e){let t={variables:{[_S]:tl(_S,Wc)},actions:{[IS]:nl(_S,vS),[KS]:{doctor:`run`},[yS]:{do:[...Y_]},...xS.actions,...CS.actions,...TS.actions,[MS]:{save:!0},[RS]:{undo:!0},[BS]:{back:!0},[zS]:{do:[BS,...yC]},[WS]:{redo:!0},[NS]:{preset:`save`},[PS]:{preset:`delete`,name:`{{ .${Fb.preset.effectiveVar} }}`}},segments:{[_S]:{template:`{{ $door := ${$c(_S,el(e),el(`✖`))} }}{{ if ${Zc(LS)} }}{{ fg (color "error") $door }}{{ else }}{{ $door }}{{ end }}`},[bS]:{template:xS.template},[SS]:{template:CS.template,when:CS.when},[wS]:{template:TS.template,bg:TS.bg,when:TS.when},[HS]:US,[MS]:gC,[NS]:{template:`{{ action "${NS}" "+ preset" }}`},[GS]:{template:`{{ action "${KS}" "🩺 doctor" }}`},[yS]:{template:`{{ action "${yS}" "✎ arrange" "✎ done" }}`}}};t.variables[VS]={kind:`input`,path:`navigation.back`,type:`number`,default:0};for(let e of dC)t.variables[fC(e)]={kind:`input`,path:e,type:`number`,default:0};t.variables[DS]=tl(DS,`session`);for(let{member:e,label:n}of OS){t.actions[AS(e)]=nl(DS,e),t.actions[kS(e)]={do:[AS(e),...bC]};let r=aC(cC(e).map(e=>e.name)),i=`(ternary ${el(` •`)} "" ${r})`,a=e=>`(print ${el(e)} ${i})`;t.segments[kS(e)]={template:`{{ ${$c(kS(e),a(n),a(`▾ ${n}`))} }}`}}return Object.assign(t.variables,CS.variables,uC.variables),IC(t),FC(t),t.actions[_S]={do:[IS,...yC,...MC(t)]},t}function FC(e){for(let t of Lx){let n=Vx(t.name),r=qS(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},e.segments[JS(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${So}" }} {{ action "${r}" "[fix]" }}{{ end }}{{ end }}`}}}function IC(e){for(let t of oC){Object.assign(e.actions,t.control.actions);let n=tC(t.name);e.actions[n]={reset:t.configKey},e.variables[iC(t.name)]={kind:`input`,path:`resettable.${t.name}`,type:`boolean`,default:!1};let r=`{{ if .${iC(t.name)} }} {{ action "${n}" "↺" }}{{ end }}`;Object.assign(e.variables,t.control.variables),e.segments[$S(t.name)]={template:`${t.control.template}${r}`},t.control.kind===`picker`&&(e.segments[nC(t.name)]={template:t.control.list.template}),t.beneath.forEach((n,r)=>{e.segments[rC(t.name,r)]=n})}Object.assign(e.actions,uC.actions)}function LC(e){let{variables:t,actions:n}=iv();Object.assign(e.variables,t),Object.assign(e.actions,n)}function RC(e){let t=PC(e.globals.menuGlyph??`🍫`);LC(t);let n={...e.presets},r=[];for(let t of D_(e.presets)){let{node:i}=A_(e,t),a=kC(wC(i));r.push(a),n[t]={...k_(e.presets,t),root:a}}let i=Wb(t,r,e);return{...e,variables:{...i,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:n}}const zC=`${Su}live`,BC=[`☐ live`,`☑ live`],VC=`${Su}done`,HC=`${Su}cancel`,UC=`${Su}rewind`,WC=`${Su}changes`,GC=`(gt .${WC} 0)`,KC=`(or ${GC} (gt .${pC} 0))`,qC={variable:zC,key:zC,member:`open`};function JC(e){return`${Su}configuring.p${e}`}function YC(e){return`and ${Zc($_)} (not ${Zc(qC)}) (ne .${JC(e)} "true")`}function XC(e){return{kind:`template`,template:`{{ or ${e.map(e=>`(eq .${K_} "${Jc(e)}")`).join(` `)} false }}`}}function ZC(e,t,n){return`{{ if ${YC(e)} }}${t}{{ else }}${n}{{ end }}`}const QC=`{{ and ${Zc($_)} .preset.customized }}`,$C=wu,ew=`${Su}addable`;function tw(e){return new Map([[ew,{members:Object.keys(e.segments).filter(e=>!$C(e)),library:{groups:_u.map(e=>({id:e,label:vu[e]})),entry:t=>{let n=e.segments[t];return{group:n.group??`other`,...n.description!==void 0&&{description:n.description}}}}}]])}function nw(e,t,n){return n.segments[e]={template:t,when:ev,bg:Sx},{kind:`segment`,name:e}}function rw(e,t,n){let r=`${Su}${e.presetIdent}.remove.${t}`;return e.artifacts.actions[r]={persist:e.rootKey,removeSegment:n},`{{ fg (${`readableOn (color "error") (bgOf) ${ka}`}) (action "${r}" "✖") }}`}function iw(e){return`{{ if ${Zc($_)} }}${e}{{ end }}`}function aw(e,t){return e.reduce((e,t)=>`{{ if and ${Zc($_)} ${Zc(t)} }}true{{ else }}${e}{{ end }}`,t)}function ow(e){return e.flatMap(e=>[...Ms(e)].flatMap(e=>e.kind===`segment`&&e.opens?.ref.key===`edit.configure`?[e.opens.ref]:[]))}function sw(e,t,n){return`${Z_}${e}.${t}.${n}`}function cw(e,t,n,r){let i=Os(n),a=`${Su}${e.presetIdent}`,o=Q_(e.presetIdent,i);e.configured.push(o);let s=`${a}.configure.${t}`,c=v_(s),l=`${s}.fold`;e.artifacts.actions[l]={set:c,to:Wc},e.artifacts.actions[s]={do:[`${s}.open`,l]},e.artifacts.actions[`${s}.open`]={set:K_,to:o};let u={},d=Object.entries(r).map(([r,o])=>{let s=sw(e.presetIdent,i,r),l=`${Z_}p${e.presetIdent}.d${t}.${r}`;e.artifacts.variables[l]={kind:`state`,key:s,default:Ks(n.settings?.[r]??o.default)},u[r]={id:i,key:s,variable:l};let d=`${a}.setting.${t}.${r}`,f=ux(cx(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};let p=`${d}.list`;return e.artifacts.segments[d]={template:f.template},e.artifacts.segments[p]={template:f.list.template},Yc(d,f.list.ref,{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:p}]},`drop`)});return{term:`{{ action "${s}" "⚙️" }}`,ref:{variable:K_,key:K_,member:o},body:{kind:`container`,direction:`vertical`,children:d},drafts:u}}const lw=`${Su}label:`;function uw(e){if(e.startsWith(lw)){let t=e.slice(lw.length);return t.slice(t.indexOf(`:`)+1)}return e.startsWith(`edit.`)?void 0:e}function dw(e,t,n,r){let{artifacts:i}=n,a=Os(e),o=`${lw}${a}:${e.name}`;i.segments[o]={template:`{{ "${Jc(a)}" }}`,...t.palette!==void 0&&{palette:t.palette}};let s=e.settings?.[Vs];return{...Yc(o,r.ref,r.body,`drop`,aw([r.ref],`{{ ${YC(n.presetIdent)} }}`)),...s!==void 0&&{settings:{theme:s}},drafts:{[Vs]:r.drafts[Vs]}}}function fw(e,t,n,r){let{presetIdent:i,artifacts:a}=e,o=`${Su}${i}.insert.${t}`,s=`${Su}${i}.insertSeg.${t}`;a.actions[o]={persist:e.rootKey,insertSegmentFrom:ew,anchor:n,relation:r};let c=g_(o),l=__(s,o,void 0),u=b_(l),d=y_(l,c);return a.variables[l]=tl(l,Wc),a.variables[u]={kind:`state`,key:u,default:`0`},a.actions[d]=nl(l,c),a.actions[u]={set:u,int:!0},{host:s,template:`{{ $m := menu "${o}" "✚" "✕" }}{{ if ${Zc({variable:l,key:l,member:c})} }}{{ $m }}{{ else }}{{ fg (${`readableOn (color "success") (bgOf) ${ka}`}) $m }}{{ end }}`}}function pw(e,t){let n=[],r=e.children.findIndex(e=>e.kind===`segment`&&!$C(e.name)),i=e=>pw(e,t);for(let[a,o]of e.children.entries()){if(o.kind===`container`){n.push(i(o));continue}let s=js(o,i);if($C(o.name)){n.push(s);continue}let c=Os(o),l=a===r?[fw(t,String(t.posCounter.n++),c,`before`)]:[],u=String(t.posCounter.n++),d=fw(t,u,c,`after`),f=rw(t,u,c),p=t.segments[o.name],m=cw(t,u,o,Hs(p)),h=iw(f),g=iw(m.term),_={kind:`container`,direction:`horizontal`,children:[...l.map(e=>nw(e.host,e.template,t.artifacts)),{...dw(o,p,t,m),lead:h,trail:g},{...s,when:ZC(t.presetIdent,`false`,o.when??`true`),lead:h,trail:g,drafts:m.drafts},nw(d.host,d.template,t.artifacts)]};n.push(e.direction===`vertical`?{kind:`container`,direction:`horizontal`,children:[_]}:_)}return{...e,children:n,...e.when!==void 0&&{when:aw(ow(n),ZC(t.presetIdent,`true`,e.when))}}}function mw(e,t,n,r,i,a,o){let s=`${Su}${t}.resetLayout`,c=`${Su}${t}.customized`;return r.actions[s]={reset:n},r.segments[c]={template:`{{ action "${s}" "↺ reset layout" }}`,when:QC},{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[...i,{kind:`segment`,name:c},a]},hw(e,o)]}}function hw(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),hw(n,t)]}:{...e,children:[...e.children,t]}}function gw(e,t,n,r,i,a){let{node:o}=A_(e,t),s={presetIdent:yu(t),rootKey:hx(t),segments:e.segments,artifacts:n,posCounter:{n:0},configured:[]},c=pw(o,s);return n.variables[JC(s.presetIdent)]=XC(s.configured),mw(c,s.presetIdent,s.rootKey,n,r,i,a)}function _w(e){let t={variables:{},actions:{},segments:{}},n=bx(`${Su}help`,Ox,[$_],t);t.variables[zC]=tl(zC,Wc),t.actions[zC]=nl(zC,qC.member),t.segments[zC]={template:Qc(zC,...BC),when:ev};let r={kind:`segment`,name:zC},i=n;t.variables[WC]={kind:`input`,path:`history.sinceEdit`,type:`number`,default:0},t.actions[VC]={do:[MS,...Y_]},t.segments[VC]={template:`{{ if ${KC} }}{{ action "${VC}" "✓ save" }}{{ else }}{{ action "${VC}" "✓ done" }}{{ end }}`,when:ev},t.actions[UC]={rewind:!0},t.actions[HC]={do:[UC,...Y_]},t.segments[HC]={template:`{{ action "${HC}" "↩ cancel" }}`,when:`{{ and ${Zc($_)} ${GC} }}`};let a=[{kind:`segment`,name:VC},{kind:`segment`,name:HC}],o={...e.presets},s=[];for(let n of D_(e.presets)){let c=gw(e,n,t,a,r,i);s.push(c),o[n]={...k_(e.presets,n),root:c}}let c=Wb(t,s,e);return{...e,variables:{...c,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:o}}const vw=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`doctor`,`ceiling`,`slash`,`do`];function yw(e){return e.ceiling===`set`?[`set`,e.to]:[`clear`]}function bw(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function xw(e,t){if(t===void 0)return{};if(!nc(t))return Q(e,`actions`,`actions must be an object, got ${rc(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=Sw(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function Q(e,t,n){e.issues.push({path:t,message:n,line:W(e.source,t.split(`.`))})}function Sw(e,t,n){if(!nc(n))return Q(e,t,`${t} must be an action object, got ${rc(n)}`),null;if(`persistWhen`in n)return Q(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 r=vw.filter(e=>e in n);return r.length===1?Cw[r[0]](e,t,n):(Q(e,t,`action must declare exactly one of: ${vw.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const Cw={set:(e,t,n)=>tT(e,t,n,`set`,Zw),persist:(e,t,n)=>tT(e,t,n,`persist`,Qw),copy:ww(`copy`),open:ww(`open`),reset:Tw,undo:Dw(`undo`),redo:Dw(`redo`),back:Dw(`back`),rewind:Dw(`rewind`),save:Dw(`save`),preset:Ow,doctor:kw,ceiling:Aw,slash:jw,do:Mw};function ww(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Q(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=Zs(t,n,r,e);return i===null?null:{[e]:i}}}function Tw(e,t,n){for(let r of Object.keys(n))r!==`reset`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=Nw(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 Ew={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 Dw(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Q(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(Q(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — ${Ew[e]}), got ${G(r[e])}`),null)}}function Ow(e,t,n){let r=n.preset,i=r===`save`?[`preset`]:[`preset`,`name`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a preset action. Expected only: ${i.join(`, `)}`);if(r!==`save`&&r!==`delete`)return Q(e,`${t}.preset`,`preset must be "save" or "delete", got ${G(r)}`),null;if(r===`save`)return{preset:`save`};let a=Zs(e,t,n,`name`);return a===null?null:{preset:`delete`,name:a}}function kw(e,t,n){let r=n.doctor,i=r===`run`?[`doctor`]:[`doctor`,`check`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${i.join(`, `)}`);if(r!==`run`&&r!==`fix`)return Q(e,`${t}.doctor`,`doctor must be "run" or "fix", got ${G(r)}`),null;if(r===`run`)return{doctor:`run`};let a=n.check;return typeof a!=`string`||zx(a)===void 0?(Q(e,`${t}.check`,`doctor fix must name a check (have: ${Lx.map(e=>e.name).join(`, `)}), got ${G(a)}`),null):{doctor:`fix`,check:a}}function Aw(e,t,n){let r=n.ceiling,i=r===`clear`?[`ceiling`]:[`ceiling`,`to`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a ceiling action. Expected only: ${i.join(`, `)}`);if(r===`clear`)return{ceiling:`clear`};if(r!==`set`)return Q(e,`${t}.ceiling`,`ceiling must be "set" or "clear", got ${G(r)}`),null;let a=n.to;return typeof a!=`string`||a.trim()===``?(Q(e,`${t}.to`,`ceiling set needs \`to\`: a memento ceiling value such as "+100_000", "400000" or "off", got ${G(a)}`),null):{ceiling:`set`,to:a}}function jw(e,t,n){for(let r of Object.keys(n))r!==`slash`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a slash action. Expected only: slash`);let r=Qx(n.slash);return r.kind===`refused`?(Q(e,`${t}.slash`,r.reason),null):{slash:r.line}}function Mw(e,t,n){for(let r of Object.keys(n))r!==`do`&&Q(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===``)?(Q(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 ${G(r)}`),null):{do:r}}function Nw(e,t,n,r,i,a){let o=Zs(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(Q(e,s,i),null):o.includes(`/`)?(Q(e,s,a(o)),null):o}const Pw={set:`the SessionState key to write`,persist:`the config globals field to write`};function Fw(e,t,n,r){let i=Pw[r],a=Nw(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 Iw(e){return e===`set`?`set-state`:`set-config`}const Lw={to:nT(`set`)},Rw={to:nT(`persist`)},zw={from:rT(`set`)},Bw={from:rT(`persist`)},Vw={min:cT(),max:cT(),by:cT()},Hw={int:aT()},Uw={cycle:iT(`set`)},Ww={cycle:iT(`persist`)},Gw={removeSegment:oT(`removeSegment`)},Kw={insertSegment:oT(`insertSegment`),anchor:oT(`anchor`),relation:sT()},qw={insertSegmentFrom:rT(`persist`),anchor:oT(`anchor`),relation:sT()},Jw={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},Yw={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function Xw(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=[e],s=(e,n,r)=>oc(e,t,n,r),c=wc(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?mc(s,...n):s}}const Zw=[Xw(`set`,Lw),Xw(`set`,zw),Xw(`set`,Vw,[Jw,Yw]),Xw(`set`,Hw),Xw(`set`,Uw)],Qw=[Xw(`persist`,Rw),Xw(`persist`,Bw),Xw(`persist`,Vw,[Jw,Yw]),Xw(`persist`,Ww),Xw(`persist`,Gw),Xw(`persist`,Kw,[],[`insertSegment`]),Xw(`persist`,qw,[],[`insertSegmentFrom`])];function $w(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 eT(e){let t=$w(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 tT(e,t,n,r,i){let a=Fw(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return Q(e,t,`${eT(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)||Q(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 nT(e){let t=Iw(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>Nw(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 rT(e){let t=Iw(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===``){Q(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){Q(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===``)){Q(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){Q(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){Q(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}Q(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${G(o)}`)}}}function iT(e){let t=Iw(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`)){Q(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${rc(o)}`);return}let c=o;if(c.length<2){Q(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){Q(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){Q(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){Q(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function aT(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){Q(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${G(r[n])}`);return}return!0}}}function oT(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=Zs(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){Q(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){Q(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 sT(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){Q(e,`${t}.${n}`,`relation must be "before" or "after", got ${G(i)}`);return}return i}}}function cT(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){Q(e,`${t}.${n}`,`${n} must be an integer, got ${G(i)}`);return}return i}}}function lT(e,t,n){return`${e}: "${t}" is an endcaps shape, not a style — endcaps were renamed from "style" to "endcaps"; write ${n}: "${t}"`}const uT={noun:`style key`,fields:{hueShift:vc(),chromaScale:vc({min:0}),lightnessScale:vc(),lightnessShift:vc()}};function dT(e,t){if(!nc(t))return e.issues.push({path:`styles`,message:`styles must be an object mapping style names to adaptation objects, got ${rc(t)}`,line:W(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:W(e.source,[`styles`,r])});continue}if(po(r)){e.issues.push({path:`styles.${r}`,message:lT(`styles.${r}`,r,`globals.endcaps`),line:W(e.source,[`styles`,r])});continue}let t=ic(e,uT,`styles.${r}`,i);t!==null&&(n[r]={...zn,...t})}return n}const fT={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:fd(e,`${t}.${n}`,r[n])},globals:{required:!1,json:El(),parse:(e,t,n,r)=>r[n]===void 0?void 0:Tl(e,`${t}.${n}`,r[n])}}};function pT(e,t){if(!nc(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${rc(t)}`,line:W(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:W(e.source,[`presets`,r])});continue}let t=ic(e,fT,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function mT(e,t){if(t===void 0)return{};if(!nc(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${rc(t)}`,line:W(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 ${G(i)}`,line:W(e.source,[`helpers`,r])});continue}n[r]=i}return n}const hT=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 gT(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 _T(e){let t=hT.get(e);return t===void 0?void 0:`variables.${e} is no longer read: ${gT(t)}`}function vT(e){let t=hT.get(e);return t===void 0?``:` — ".${e}" is no longer a variable: ${gT(t)}; a "${t.segment}" template reads it as ".settings.${t.setting}"`}function yT(e,t){let n=new Map;for(let e of Object.keys(t)){let t=yu(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:W(e.source,[`presets`])})}function bT(e,t,n){let r=[[[`globals`],t.globals.style],[[`editGlobals`],t.editGlobals.style],...Object.entries(t.presets).map(([e,t])=>[[`presets`,e,`globals`],t.globals?.style])];for(let[n,i]of r){if(i===void 0||io(i)||Object.prototype.hasOwnProperty.call(t.styles,i))continue;let r=`${n.join(`.`)}.style`;e.issues.push({path:r,message:po(i)?lT(r,i,`${n.join(`.`)}.endcaps`):`${r} "${i}" does not match any declared style (have: ${Object.keys(t.styles).join(`, `)})`,line:W(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:W(e.source,[`globals`,`preset`])}),yT(e,t.presets);let i=ax(t);for(let[n,r]of Object.entries(t.actions))`set`in r&&Rb.has(r.set)&&e.issues.push({path:`actions.${n}.set`,message:`actions.${n} sets "${r.set}", which has no session pick — globals.${r.set} is set in the config file only, so a click would change nothing; write it with { persist: "${r.set}", … } instead`,line:W(e.source,[`actions`,n,`set`])}),!(!(`set`in r)||!(`from`in r)||typeof r.from!=`string`)&&(ox(i).includes(r.from)||e.issues.push({path:`actions.${n}.from`,message:`actions.${n} from: references unknown option domain "${r.from}" (have: ${ox(i).join(`, `)})`,line:W(e.source,[`actions`,n,`from`])}));for(let[n,r]of Object.entries(t.actions))`do`in r&&r.do.forEach((i,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,i)?t.actions[i]:void 0,s=o===void 0?`references unknown action "${i}"`:`do`in o?`"${i}" is itself a do action — list its members here instead`:r.do.indexOf(i)===a?a>0&&bw(o)?`"${i}" 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:`"${i}" 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:W(e.source,[`actions`,n,`do`])})});for(let[n,r]of Object.entries(t.actions)){let i=`persist`in r?r.persist:`reset`in r?r.reset:null;if(i===null)continue;let a=`persist`in r?`persist`:`reset`,o=_x(i);if(o===null){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is not a config globals field (have: ${Al().join(`, `)}), a "segments.<name>.palette" target, a "presets.<name>.globals.<field>" target, or a "presets.<name>.root" target`,line:W(e.source,[`actions`,n,a])});continue}let s=xT.filter(e=>e in r);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:W(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){ST(e,t,n,a,i,o.preset,r);continue}if(o.scope===`preset-globals`&&!D_(t.presets).includes(o.preset)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" names preset "${o.preset}" which is not declared (have: ${D_(t.presets).join(`, `)})`,line:W(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}: "${i}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})${Ou(o.segment)}`,line:W(e.source,[`actions`,n,a])});continue}`min`in r&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${i}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:W(e.source,[`actions`,n,a])})}}let a=wv(t);for(let t of a.names)t!==`settings`&&!t.startsWith(CT)||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:W(e.source,[`variables`,t])});let o=(t,n,r)=>{TC(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${_S}" ${TC(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:r}),EC(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${_S}" 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:r}),s(t)&&e.issues.push({path:n,message:`${n} sets "distribution" on a container inside a bar cell — everything inside a cell wears that cell's hue and tone, so it would place nothing. Set it on the row whose children are the cells (the horizontal container) or on the root, which places the rows.`,line:r});let i=new Map;for(let e of Ms(t)){if(e.kind!==`segment`)continue;let t=Os(e);i.set(t,[...i.get(t)??[],e])}for(let[t,a]of i){if(a.length<2)continue;let o=a[1].name,s=As(o,new Set(i.keys()));e.issues.push({path:n,message:`${n} has ${a.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: "${o}", id: "${s}" }. A placement without an "id" takes its segment's name.`,line:r})}};function s(e,t=!1){return e.kind===`segment`?!1:t&&e.distribution!==void 0||e.children.some(n=>s(n,t||Ds[e.direction]===`cell`))}let c=(n,r)=>{for(let[i,o]of Lc(n,r)){let n=W(e.source,o.split(`.`));if(i.when!==void 0&&(FT(e,`${o}.when`,i.when,a,{line:n}),PT(e,`${o}.when`,i.when,n)),i.kind===`segment`){if(SC(i.name)){(i.id!==void 0||i.settings!==void 0)&&e.issues.push({path:o,message:`${r} gives the global settings menu anchor "${_S}" an id or settings — the anchor only marks where the menu goes, so place it as the bare name "${_S}"`,line:n});continue}Object.prototype.hasOwnProperty.call(t.segments,i.name)||e.issues.push({path:o,message:`${r} entry "${i.name}" does not match any declared segment${Ou(i.name)}`,line:n}),jT(e,t,i,o,n)}}};n.root!==void 0&&c(n.root,`root`);for(let[e,t]of Object.entries(n.presets??{}))t.root!==void 0&&c(t.root,`presets.${e}.root`);let l=new Map([[`root`,Fc(t.root)]]);for(let e of D_(t.presets)){let{node:n,path:r}=A_(t,e);l.set(r,n)}for(let[t,n]of l)o(n,t,W(e.source,t.split(`.`)));for(let[n,r]of Object.entries(t.variables)){MT(e,`variables.${n}`,r,a);let t=_T(n);t!==void 0&&e.issues.push({path:`variables.${n}`,message:t,line:W(e.source,[`variables`,n])})}for(let[n,r]of Object.entries(t.segments)){if(r.vars)for(let[t,i]of Object.entries(r.vars))MT(e,`segments.${n}.vars.${t}`,i,a,n);let i=Hs(r);TT(e,n,i);let o=wT(a,i);for(let a of[`template`,`bg`,`fg`,`when`]){let s=r[a];if(typeof s==`string`){FT(e,`segments.${n}.${a}`,s,o,{segCtx:n,settings:i});for(let{name:r,site:i,via:o}of xv(s,t.helpers)){if(Object.prototype.hasOwnProperty.call(t.actions,r))continue;let s=i===`options`?` (in a picker, menu or carousel)`:``;if(o!==null){IT(e,o,`Template references unknown action "${r}"${s}`);continue}e.issues.push({path:`segments.${n}.${a}`,message:`${a} references unknown action "${r}"${s}`,line:W(e.source,[`segments`,n,a])})}}}}for(let[n,r]of Object.entries(t.variables))NT(e,`variables.${n}`,r,a);for(let[n,r]of Object.entries(t.segments))if(r.vars)for(let[t,i]of Object.entries(r.vars))NT(e,`segments.${n}.vars.${t}`,i,a,n)}const xT=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function ST(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=W(e.source,[`actions`,n,r]);if(!D_(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${D_(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(`, `)})${Ou(i)}`,line:c})},p=new Set(ks(A_(t,a).node)),m=(r,i)=>{!Du.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${Ou(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 CT=`settings.`;function wT(e,t){return{...e,names:new Set([...e.names,...Object.keys(t).map(e=>CT+e)])}}function TT(e,t,n){let r=e=>`segments.${t}.settings.${e}`,i=(n,i)=>{e.issues.push({path:r(n),message:`${r(n)}: ${i}`,line:W(e.source,[`segments`,t,`settings`,n])})},a=OT(n);for(let{setting:e,message:t}of a)i(e,t);if(!(a.length>0))for(let{setting:e,message:t}of Ws(n,DT(n)))i(e,`the defaults do not stand together: ${t}`)}function ET(e){return OT(e).length>0||Ws(e,DT(e)).length>0}function DT(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default]))}function OT(e){let t=t=>Us(kT(e,t))?.atLeast;return Object.keys(e).flatMap(n=>{let r=t(n);if(r===void 0)return[];if(r===n||Us(kT(e,r))===void 0)return[{setting:n,message:`atLeast "${r}" must name another range setting of this segment (its range settings: ${AT(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 kT(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function AT(e,t){return Object.entries(e).filter(([e,n])=>e!==t&&Us(n)!==void 0).map(([e])=>e)}function jT(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=Hs(a),s=`${r}: placement "${Os(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(`, `)})`:Gs(c,a)?void 0:`sets "${t}" to ${JSON.stringify(a)}${c.domain===`theme`?Ya(a):``}, but it must be ${Js(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])=>Gs(o[e],t))||ET(o)))for(let{message:t}of Ws(o,c))e.issues.push({path:r,message:`${s}: ${t}`,line:i})}function MT(e,t,n,r,i){n.kind===`template`&&FT(e,`${t}.template`,n.template,r,{segCtx:i}),zs(n)&&n.cache&&`key`in n.cache&&FT(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function NT(e,t,n,r,i){if(zs(n)&&n.cache&&`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:W(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function PT(e,t,n,r){try{W_.parse(n)}catch(n){e.issues.push({path:t,message:`Template parse error in ${t}: ${n.message}`,line:r})}}function FT(e,t,n,r,i){for(let[a,o]of _v(n,r.helpers)){if(Cv(a,r))continue;if(a.startsWith(CT)){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??W(e.source,t.split(`.`))});continue}if(o!==null){IT(e,o,`Template references unknown variable ".${a}"${vT(a)}`);continue}let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,s=n!==void 0&&Cv(n,r)?` (segment-local vars are namespaced — write ".${n}")`:vT(a);e.issues.push({path:t,message:`Template references unknown variable ".${a}"${s}`,line:i?.line??W(e.source,t.split(`.`))})}}function IT(e,t,n){let r=`helpers.${t}`;e.issues.some(e=>e.path===r&&e.message===n)||e.issues.push({path:r,message:n,line:W(e.source,[`helpers`,t])})}function LT(e,t){let{graph:n,nodeInfo:r}=RT(t),i=new Map,a=[];for(let e of n.keys())i.set(e,0);for(let e of n.keys())if(i.get(e)===0&&o(e))return;function o(t){i.set(t,1),a.push(t);for(let s of n.get(t)??[]){let t=i.get(s);if(t===1){let t=a.indexOf(s),n=[...a.slice(t),s],i=n[0],o=r.get(i);return e.issues.push({path:o?.declarationPath??`variables.${i}`,message:`Dependency cycle: ${n.join(` → `)}`,line:W(e.source,o?.linePathParts??[`variables`,i])}),!0}if(t===0&&o(s))return!0}return i.set(t,2),a.pop(),!1}}function RT(e){let t=new Set(Object.keys(e.variables)),n=new Map;for(let t of Object.keys(e.variables))n.set(t,{declarationPath:`variables.${t}`,linePathParts:[`variables`,t]});for(let[r,i]of Object.entries(e.segments))if(i.vars)for(let e of Object.keys(i.vars)){let i=`${r}.${e}`;t.add(i),n.set(i,{declarationPath:`segments.${r}.vars.${e}`,linePathParts:[`segments`,r,`vars`,e]})}let r=new Map;for(let e of t)r.set(e,new Set);let i=(n,i)=>{for(let a of _v(i,e.helpers).keys()){if(t.has(a)){r.get(n).add(a);continue}let e=a.split(`.`)[0];e!==a&&t.has(e)&&r.get(n).add(e)}},a=(e,n)=>{if(n.kind===`template`&&i(e,n.template),zs(n)&&(n.cache&&`key`in n.cache&&i(e,n.cache.key),n.cache&&`depends_on`in n.cache))for(let i of n.cache.depends_on)t.has(i)&&r.get(e).add(i)};for(let[t,n]of Object.entries(e.variables))a(t,n);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))a(`${t}.${e}`,r);return{graph:r,nodeInfo:n}}const zT=[`json5`,`json`];function BT(e){try{return r.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function VT(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?m.homedir()+e.slice(1):e}function HT(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?zT.map(t=>c.join(e,`.cc-candybar.${t}`)):[],...zT.map(e=>c.join(r,`.cc-candybar.${e}`)),...zT.map(e=>`${UT()}.${e}`)])]}function UT(){let e=process.env.XDG_CONFIG_HOME??c.join(m.homedir(),`.config`);return c.join(e,`cc-candybar`,`config`)}function WT(e,t,n){let r=[];for(let i of HT(e,t,n)){let e=BT(i);if(e===`present`)return{kind:`file`,path:i,unchecked:r};e!==`absent`&&r.push(e)}if(n===void 0)return{kind:`default`,unchecked:r};let[i]=r;return i===void 0?{kind:`missing`,path:n}:{kind:`unreadable`,...i}}function GT(e,t,n){let r=WT(e,t,n);return r.kind===`default`?`${UT()}.${zT[0]}`:r.path}function KT(e){return qT(e).join(`
163
+ `)||null}function qT(e){switch(e.kind){case`file`:case`default`: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 JT(e,t,n){let i=new Map;for(let a of HT(e,t,n)){if(BT(a)!==`present`)continue;let e=r.realpathSync(c.dirname(a));i.has(e)||i.set(e,a)}return[...i.values()].slice(1)}function YT(e,t){let n=HT(e,t).filter(e=>BT(e)===`present`),r=new Map;for(let e of n){let t=c.dirname(e),n=c.basename(e).replace(/\.(json5|json)$/,``),i=c.join(t,n);r.has(i)||r.set(i,[]),r.get(i).push(e)}let i=[...r.values()].filter(e=>e.length>1);return i.length===0?null:`config-extension collision: ${i.map(e=>{let[t,...n]=e;return`${t} shadows ${n.join(`, `)}`}).join(`; `)} — remove the duplicate`}function XT(e,t,n){return e===null?{...QT,config:Bc(QT.raw,t)}:ZT(e,r.readFileSync(e,`utf-8`),t,n)}function ZT(e,t,n,r){let i={source:t,...tE(e,t,r,Hu(n))};return{...i,config:Bc(i.raw,n)}}const QT={raw:{},source:``,warnings:[]};function $T({config:e,raw:t,source:n},r=`<config>`,i=new Set(Qa())){let a=[],o={source:n,issues:a,allowedPalettes:i,groups:[]};if(bT(o,e,t),LT(o,e),a.length>0)throw new xs(r,a);let s=U_(e,a);if(a.length>0)throw new xs(r,a);return _w(RC(s))}function eE(e,t,n=new Set(Qa()),r=nE){return tE(e,t,n,r).raw}function tE(e,t,n,r){let i=rE(e,t),a=ws(e,t),o=a===null?[]:[a],s=[],c={source:t,issues:s,allowedPalettes:n??new Set(Qa()),groups:[]};if(!nc(i))throw new xs(e,[{path:``,message:`Config root must be an object, got ${rc(i)}`}],o);let l=iE(c,i,r);if(s.length>0)throw new xs(e,s,o);return{raw:l,warnings:o}}const nE=new Set;function rE(e,t){try{return tt.default.parse(t)}catch(t){let n=t;throw new xs(e,[{path:``,message:`JSON5 syntax error: ${n.message}`,line:n.lineNumber,col:n.columnNumber}])}}function iE(e,t,n){for(let n of Object.keys(t))aE.has(n)||e.issues.push({path:n,message:`Unknown top-level key "${n}". Expected one of: ${[...aE].join(`, `)}`,line:W(e.source,[n])});let r={};return t.globals!==void 0&&(r.globals=wl(e,`globals`,t.globals)),t.variables!==void 0&&(r.variables=Wl(e,`variables`,t.variables)),t.segments!==void 0&&(r.segments=Uu(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.
160
164
  Replace: layout: [["seg1", "seg2"], ["seg3"]]
161
165
  With: root: { v: [{ h: ["seg1", "seg2"] }, "seg3"] }
162
- Single-row example: root: { h: ["seg1", "seg2"] }`,line:W(e.source,[`layout`])}),t.root!==void 0&&(r.root=fd(e,`root`,t.root)),t.actions!==void 0&&(r.actions=gw(e,t.actions)),t.looks!==void 0&&e.issues.push({path:`looks`,message:`"looks" was renamed "styles" — move the block under styles: { … } (and globals.look to globals.style)`,line:W(e.source,[`looks`])}),t.styles!==void 0&&(r.styles=oT(e,t.styles)),t.presets!==void 0&&(r.presets=cT(e,t.presets)),t.editGlobals!==void 0&&(r.editGlobals=Dl(e,`editGlobals`,t.editGlobals)),t.helpers!==void 0&&(r.helpers=lT(e,t.helpers)),bd(e,r),V_(e,r),rv(e,r),Eu(e,r,K,`the global settings menu`),r}const $T=new Set([`globals`,`variables`,`segments`,`layout`,`looks`,`root`,`actions`,`styles`,`presets`,`editGlobals`,`helpers`]);function eE(e){let t=oE(e.termCols),n=oE(e.termRows),r=sE(e.ssh),i=iE(e.tmux),a=rE(e.configEnv),o=nE(e.claudeConfigDir),s=tE(e.mementoEnv);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&&{mementoEnv:s}}}function tE(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=Ye.filter(e=>t[e]!==void 0);return n.every(e=>nE(t[e])!==void 0)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function nE(e){return typeof e==`string`&&c.isAbsolute(e)?e:void 0}function rE(e){return typeof e==`string`&&e!==``?IT(e):void 0}function iE(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 aE=1e4;function oE(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>aE?aE:t}function sE(e){return typeof e==`boolean`?e:void 0}var cE=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function lE(e){let t=Buffer.from(JSON.stringify(e),`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function uE(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 cE(`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 cE(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function dE(e,t,n){return new Promise((r,i)=>{let a=!1,o=t=>{if(!a){a=!0,clearTimeout(s),e.removeAllListeners();try{t()}catch{}}},s=setTimeout(()=>{o(()=>{e.destroy(),i(Error(`TIMEOUT`))})},n),c=uE(e=>o(()=>r(e)),e=>o(()=>i(e)));e.on(`data`,c),e.on(`error`,e=>o(()=>i(e))),e.on(`close`,()=>o(()=>i(Error(`socket closed before response`)))),e.write(lE(t))})}async function fE(e,t,n){let r=null;try{r=await _E(Ie(),t.connectMs);let i=await dE(r,{v:3,...e},t.budgetMs);return hE(e.kind,i,n)}catch(e){return gE(e)}finally{r&&r.destroy()}}function pE(e,t){return typeof e==`string`?e:t}function mE(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function hE(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=pE(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:mE(r.daemonV)};case`TIMEOUT`:return{kind:`transient`,cause:`timeout`,message:i};case`BAD_REQUEST`:return{kind:`permanent`,cause:`bad_request`,message:i};case`RENDER_FAILED`:return{kind:`permanent`,cause:`render_failed`,message:i};default:return{kind:`permanent`,cause:`malformed_response`,message:`unknown error code: ${String(r.code)}`}}}function gE(e){if(e instanceof cE||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 t===`CONNECT_TIMEOUT`||t===`TIMEOUT`?{kind:`transient`,cause:`timeout`,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 _E(e,t){return new Promise((n,r)=>{let i=b.createConnection({path:e}),a=setTimeout(()=>{i.destroy(),r(Error(`CONNECT_TIMEOUT`))},t);i.once(`connect`,()=>{clearTimeout(a),n(i)}),i.once(`error`,e=>{clearTimeout(a),r(e)})})}function vE(e){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`malformed_response`:return`daemon error (${e.cause}): ${e.message}`}}const yE={connectMs:50,budgetMs:150},bE={connectMs:50,budgetMs:200};function xE(e){let t=e.output;return typeof t==`string`?t:void 0}function SE(e,t,n,r){return fE({kind:`render`,hookData:e,args:t,cwd:n,...r},yE,xE)}function CE(e,t){return fE({kind:`click`,verb:e,value:t},bE,xE)}function wE(e){let t=[];for(let n of e){let e=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(`
163
- `)}function TE(e,t){return e===`darwin`?[EE(`footprint`,[`-p`,String(t)]),EE(`vmmap`,[`--summary`,String(t)])]:e===`linux`?[DE(`/proc/self/smaps_rollup`),DE(`/proc/self/status`)]:[]}function EE(e,t){return{name:`${e} ${t.join(` `)}`,read:()=>{let n=ke({bin:e,args:[...t],timeoutMs:5e3,category:`limits.memory-report`});return n.ok?n.stdout.trim().length>0?{kind:`text`,text:n.stdout}:{kind:`unavailable`,reason:`exited 0 but printed nothing`}:{kind:`unavailable`,reason:`${n.reason}${n.error===void 0?``:`: ${n.error}`}${OE(n.stderr)}`}}}}function DE(e){return{name:e,read:()=>{try{let t=r.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}}}}}function OE(e){let t=e.split(`
164
- `).map(e=>e.trim()).find(e=>e.length>0);return t===void 0?``:` (${t})`}const kE=`CC_CANDYBAR_RSS_LIMIT_MB`;function AE(e){let t=e[kE];if(t===void 0)return 512;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${kE} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function jE(e){return AE(e)*2}const ME=1024*1024;function NE(e){return AE(e)*ME}const PE={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function FE(e,t,n){let{prefix:r,suffix:i}=PE[t];return c.join(e,`${r}${n}${i}`)}function IE(e){for(let t of Object.keys(PE)){let{prefix:n,suffix:r}=PE[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function LE(e){let t=e.rssLimitBytes??512*ME,n=e.snapshotsKeep??3,r=!1;function i(){if(r)return!0;let{rss:i,heapTotal:a}=e.memoryBytes();if(i<=t)return!1;r=!0,e.log(`warn`,`RSS ${i} > limit ${t} (v8 heap ${a}); recording memory then shutting down`);let o=`${new Date(e.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return RE(e.log,`memory report`,()=>{let t=FE(e.snapshotDir,`memoryReport`,o);e.writeMemoryReport(t,e.captureMemoryReport()),e.log(`info`,`memory report written: ${t}`)}),RE(e.log,`heap snapshot`,()=>{let t=FE(e.snapshotDir,`heapSnapshot`,o);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),RE(e.log,`artifact rotation`,()=>{BE(e.listArtifacts(),n,e.removeFile)}),e.shutdown(0),!0}function a(){let{rss:n,heapTotal:r}=e.memoryBytes();return n>t*.75?`rss ${n} approaching limit ${t} (v8 heap ${r})`:null}function o(e=6e4){let t=setInterval(()=>{i()},e);return t.unref(),{disarm:()=>clearInterval(t)}}return{checkRss:i,describeNextRestart:a,arm:o}}function RE(e,t,n){try{n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function zE(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=IE(t);if(n===null)return t;let{prefix:r,suffix:i}=PE[n];return t.slice(r.length,t.length-i.length)}function BE(e,t,n){let r=new Map;for(let t of e){let e=zE(t),n=r.get(e);n===void 0?r.set(e,[t]):n.push(t)}let i=[...r.keys()].sort((e,t)=>t.localeCompare(e));for(let e of i.slice(t))for(let t of r.get(e)??[])try{n(t)}catch{}}function VE(e,t,n={}){let i=Fe();return{now:()=>Date.now(),pid:process.pid,snapshotDir:i,log:Z,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},captureMemoryReport:()=>wE(TE(process.platform,process.pid)),writeMemoryReport:(e,t)=>r.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>ne.writeHeapSnapshot(e),listArtifacts:()=>{try{return r.readdirSync(i).filter(e=>IE(e)!==null).map(e=>c.join(i,e))}catch{return[]}},removeFile:e=>r.unlinkSync(e),shutdown:t,startedAtMs:e,...n}}function HE(e={}){if(iD()!==null)return;let n=e.spawn??aD,r=tD();if(r.kind===`contended`){let e=WE();e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),UE(n));return}if(r.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${r.reason}) — spawning unlocked\n`),UE(n);return}try{UE(n)}finally{rD()}}function UE(e){ZE()&&GE(e)}function WE(){try{let e=r.statSync(We());return Date.now()-e.mtimeMs}catch{return null}}function GE(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
165
- `)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function KE(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function qE(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function JE(e){try{let t=r.readFileSync(e,`utf8`).trim(),n=Number(t);return!Number.isInteger(n)||n<0?0:Math.min(n,5)}catch{return 0}}function YE(e,n){try{r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,String(n),{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.backoff: ${e.message}\n`)}}function XE(){try{r.unlinkSync(Ke())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function ZE(){let e=Ge(),n=Ke(),r=JE(n),i=KE(QE(e),qE(r));return i.kind===`deny`?!1:(i.kind===`allow-future-garbage`&&t.stderr.write(`cc-candybar: spawn.cooldown mtime is ${i.futureMs}ms in the future — ignoring and spawning\n`),$E(e),YE(n,Math.min(r+1,5)),!0)}function QE(e){try{return Date.now()-r.statSync(e).mtimeMs}catch{return null}}function $E(e){try{r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,`${t.pid} ${Date.now()}\n`,{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.cooldown: ${e.message}\n`)}}let eD=null;function tD(){let e=We();for(let n=0;n<2;n++){try{let n=r.openSync(e,`wx`,384);try{r.writeSync(n,JSON.stringify({pid:t.pid,ts:Date.now()}))}catch{}return eD={fd:n,path:e},{kind:`held`}}catch(t){let n=t.code;if(n!==`EEXIST`)return{kind:`error`,reason:`openSync(${e}): ${n??t.message}`}}if(!nD(e))return{kind:`contended`};try{r.unlinkSync(e)}catch(e){if(e.code!==`ENOENT`)return{kind:`error`,reason:`unlink stale spawn.lock: ${e.message}`}}}return{kind:`contended`}}function nD(e){try{let t=r.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function rD(){if(!eD)return;let{fd:e,path:t}=eD;eD=null;try{r.closeSync(e)}catch{}try{r.unlinkSync(t)}catch{}}function iD(){try{return r.mkdirSync(Fe(),{recursive:!0}),null}catch(e){return`mkdir ${Fe()}: ${e.message}`}}function aD(){let e=t.execPath,n=t.argv[1];return n?Ae({bin:e,args:[`--max-old-space-size=${jE(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const oD=`cc-candybar`,sD=`dispatch`,cD=`set-state`,lD=`step-state`,uD=`copy`,dD=`open-vscode`,fD=`toolbar-toggle`,pD=`show-config-error`,mD=`show-config-warning`,hD=`set-config`,gD=`step-config`,_D=`save`,vD=`save-preset`,yD=`delete-preset`,bD=`reset-config`,xD=`apply-layout-op`,SD=`undo`,CD=`redo`,wD=`back`,TD=`rewind`,ED=`apply-update`,DD=`doctor-run`,OD=`doctor-fix`,kD=`ceiling`,AD=`slash`;function jD(e){return e.map(encodeURIComponent).join(`/`)}function MD(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function ND(e){return`${oD}://${sD}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${jD(e.args)}`)}`).join(`&`)}`}function PD(e){return new re(e).getAll(`e`).map(RD)}const FD=new Set([cD,bD]);function ID(e){return e.reduce((e,t)=>{let n=e.at(-1),r=n&&LD(n,t);return r?[...e.slice(0,-1),r]:[...e,t]},[])}function LD(e,t){if(e.verb!==t.verb||!FD.has(e.verb))return;let[n,r]=[RD(e.value),RD(t.value)];return n.verb===r.verb?{verb:e.verb,value:`${n.verb}/${n.value}/${r.value}`}:void 0}function RD(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const zD=`1.114.0`,BD=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function VD(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function HD(e){return BD.test(e)?e:VD(e)}const UD=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function WD(e){let t=UD.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)`}}function GD(e){return e.join(`.`)}function KD([e,t,n],[r,i,a]){return e-r||t-i||n-a}const qD=`@promptctl/cc-candybar`;async function JD(e,t,n){let r=`${n}/-/package/${encodeURIComponent(e)}/dist-tags`;try{let e=await t(r,{signal:AbortSignal.timeout(5e3)});if(!e.ok)return X(`registry responded ${e.status} for ${r}`);let n=await e.json();return typeof n.latest==`string`?WD(n.latest):Y}catch(e){return X(e instanceof Error?e.message:String(e))}}function YD(e,t){let n=WD(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=KD(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 XD(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${GD(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${GD(t.installed)} is newer than the registry's latest release (${GD(t.latest)}): an unpublished build.\n`};case`stale`:{let n=GD(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${GD(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 ZD=`CCCandybarURLHandler`,QD=[],$D={"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 eO(e,t){return[e,...t].map(HD).join(` `)}function tO(){return c.join(m.homedir(),`Applications`,`${ZD}.app`)}function nO(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function rO(){if(process.platform===`darwin`)return c.join(m.homedir(),`Library`,`Application Support`,`CCCandybar`);let e=process.env.XDG_DATA_HOME??c.join(m.homedir(),`.local`,`share`);return c.join(e,`cc-candybar`)}function iO(){return c.join(rO(),`bin`,`cc-candybar`)}function aO(){return c.join(rO(),`dist`,`index.mjs`)}function oO(e,t){return[`on open location L`,`\tdo shell script "'${e.replace(/"/g,`\\"`)}' '${t.replace(/"/g,`\\"`)}' url-handle " & quoted form of L`,`end open location`].join(`
166
- `)}function sO(e){if(!e)throw Error(`install: process.argv[1] not set`);return e.endsWith(`.mjs`)||e.endsWith(`.js`)?e:c.resolve(c.dirname(e),`..`,`dist`,`index.mjs`)}function cO(t){let n=$D[`${process.platform}-${process.arch}`];if(n){let r=e(t);try{return{kind:`native`,sourcePath:r.resolve(`${n}/bin/cc-candybar`)}}catch{}}return{kind:`node-shim`,sourcePath:c.resolve(c.dirname(t),`..`,`bin`,`cc-candybar`)}}function lO(e,t){c.resolve(e)!==c.resolve(t)&&r.copyFileSync(e,t)}function uO(e){let t=r.openSync(e,`r`);try{let n=Buffer.alloc(2),i=r.readSync(t,n,0,2,0);if(i<2)throw Error(`install: staged render entry at ${e} is truncated (${i} byte(s)). Re-run: pnpm dlx ${qD}@latest install`);return n.toString(`latin1`)===`#!`?`node-shim`:`native`}finally{r.closeSync(t)}}function dO(){let e=sO(process.argv[1]);if(!r.existsSync(e))throw Error(`install: bundled dist not found at ${e}. Reinstall the package.`);let t=cO(e);if(!r.existsSync(t.sourcePath))throw Error(`install: render entry not found at ${t.sourcePath}. Reinstall the package.`);r.mkdirSync(c.dirname(aO()),{recursive:!0}),r.mkdirSync(c.dirname(iO()),{recursive:!0}),lO(e,aO()),lO(t.sourcePath,iO()),r.chmodSync(iO(),493),r.rmSync(c.join(rO(),`url-handler.mjs`),{force:!0});let n=uO(iO());return process.stdout.write(`Staged cc-candybar v${zD} runtime at ${rO()}\n`+(n===`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:iO(),distPath:aO(),entryKind:n}}function fO(){return[{key:`CFBundleIdentifier`,xml:`<string>com.cccandybar.url-handler</string>`},{key:`CFBundleURLTypes`,xml:[`<array>`,` <dict>`,` <key>CFBundleURLName</key>`,` <string>Claude Powerline Click Action</string>`,` <key>CFBundleURLSchemes</key>`,` <array>`,` <string>${oD}</string>`,` </array>`,` </dict>`,`</array>`].join(`
167
- `)}]}function pO(e){let t=tO();r.mkdirSync(c.dirname(t),{recursive:!0}),r.existsSync(t)&&r.rmSync(t,{recursive:!0,force:!0}),process.stdout.write(`Building ${t}\n`);let n=ke({bin:`/usr/bin/osacompile`,args:[`-o`,t,`-e`,oO(process.execPath,e)],category:`install.osacompile`});if(!n.ok)throw process.stderr.write(n.stderr),Error(`osacompile failed (${n.reason})`);let i=c.join(t,`Contents`,`Info.plist`);for(let{key:e}of fO())ke({bin:`/usr/bin/plutil`,args:[`-remove`,e,i],category:`install.plutil`});for(let{key:e,xml:t}of fO()){let n=ke({bin:`/usr/bin/plutil`,args:[`-insert`,e,`-xml`,t,i],category:`install.plutil`});if(!n.ok)throw process.stderr.write(n.stderr),Error(`plutil -insert ${e} failed (${n.reason})`)}process.stdout.write(`Registering ${oD}:// with Launch Services\n`);let a=ke({bin:`/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister`,args:[`-f`,t],category:`install.lsregister`});if(!a.ok)throw process.stderr.write(a.stderr),Error(`lsregister failed (${a.reason})`);process.stdout.write(`✓ ${ZD}.app installed and registered.\n`),process.stdout.write(` Test: open '${oD}://hello-world' && pbpaste\n`)}function mO(){nO(),pO(dO().distPath)}function hO(e,t=oD){let n=`${t}://`;if(!e.startsWith(n))throw Error(`expected ${n} scheme, got: ${e}`);let r=e.slice(n.length),i=r.indexOf(`/`);return i===-1?{verb:uD,value:r}:{verb:decodeURIComponent(r.slice(0,i)),value:r.slice(i+1)}}async function gO(e){e||(process.stderr.write(`url-handle: missing URL argument.
168
- `),process.exit(1));let t;try{t=hO(e)}catch(e){process.stderr.write(`url-handle: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)}let n=await CE(t.verb,t.value);n.kind===`ok`&&process.exit(0),n.kind===`transient`&&(HE(),process.stderr.write(`url-handle: daemon unavailable (${n.cause}: ${n.message})\n`),process.exit(1)),process.stderr.write(_O(n)+`
169
- `),process.exit(1)}function _O(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`malformed_response`:return`url-handle: daemon rejected click (malformed response: ${e.message})`}}function vO(){return`✓ install complete.
166
+ Single-row example: root: { h: ["seg1", "seg2"] }`,line:W(e.source,[`layout`])}),t.root!==void 0&&(r.root=fd(e,`root`,t.root)),t.actions!==void 0&&(r.actions=xw(e,t.actions)),t.looks!==void 0&&e.issues.push({path:`looks`,message:`"looks" was renamed "styles" — move the block under styles: { … } (and globals.look to globals.style)`,line:W(e.source,[`looks`])}),t.styles!==void 0&&(r.styles=dT(e,t.styles)),t.presets!==void 0&&(r.presets=pT(e,t.presets)),t.editGlobals!==void 0&&(r.editGlobals=Dl(e,`editGlobals`,t.editGlobals)),t.helpers!==void 0&&(r.helpers=mT(e,t.helpers)),bd(e,r),V_(e,r),rv(e,r),Eu(e,r,K,`the global settings menu`),r}const aE=new Set([`globals`,`variables`,`segments`,`layout`,`looks`,`root`,`actions`,`styles`,`presets`,`editGlobals`,`helpers`]);function oE(e){let t=fE(e.termCols),n=fE(e.termRows),r=pE(e.ssh),i=uE(e.tmux),a=lE(e.configEnv),o=cE(e.claudeConfigDir),s=sE(e.mementoEnv);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&&{mementoEnv:s}}}function sE(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=Ye.filter(e=>t[e]!==void 0);return n.every(e=>cE(t[e])!==void 0)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function cE(e){return typeof e==`string`&&c.isAbsolute(e)?e:void 0}function lE(e){return typeof e==`string`&&e!==``?VT(e):void 0}function uE(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 dE=1e4;function fE(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>dE?dE:t}function pE(e){return typeof e==`boolean`?e:void 0}var mE=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function hE(e){let t=Buffer.from(JSON.stringify(e),`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function gE(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 mE(`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 mE(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function _E(e,t,n){return new Promise((r,i)=>{let a=!1,o=t=>{if(!a){a=!0,clearTimeout(s),e.removeAllListeners();try{t()}catch{}}},s=setTimeout(()=>{o(()=>{e.destroy(),i(Error(`TIMEOUT`))})},n),c=gE(e=>o(()=>r(e)),e=>o(()=>i(e)));e.on(`data`,c),e.on(`error`,e=>o(()=>i(e))),e.on(`close`,()=>o(()=>i(Error(`socket closed before response`)))),e.write(hE(t))})}async function vE(e,t,n){let r=null;try{r=await CE(Ie(),t.connectMs);let i=await _E(r,{v:3,...e},t.budgetMs);return xE(e.kind,i,n)}catch(e){return SE(e)}finally{r&&r.destroy()}}function yE(e,t){return typeof e==`string`?e:t}function bE(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function xE(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=yE(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:bE(r.daemonV)};case`TIMEOUT`:return{kind:`transient`,cause:`timeout`,message:i};case`BAD_REQUEST`:return{kind:`permanent`,cause:`bad_request`,message:i};case`RENDER_FAILED`:return{kind:`permanent`,cause:`render_failed`,message:i};default:return{kind:`permanent`,cause:`malformed_response`,message:`unknown error code: ${String(r.code)}`}}}function SE(e){if(e instanceof mE||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 t===`CONNECT_TIMEOUT`||t===`TIMEOUT`?{kind:`transient`,cause:`timeout`,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 CE(e,t){return new Promise((n,r)=>{let i=b.createConnection({path:e}),a=setTimeout(()=>{i.destroy(),r(Error(`CONNECT_TIMEOUT`))},t);i.once(`connect`,()=>{clearTimeout(a),n(i)}),i.once(`error`,e=>{clearTimeout(a),r(e)})})}function wE(e){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`malformed_response`:return`daemon error (${e.cause}): ${e.message}`}}const TE={connectMs:50,budgetMs:150},EE={connectMs:50,budgetMs:200};function DE(e){let t=e.output;return typeof t==`string`?t:void 0}function OE(e,t,n,r){return vE({kind:`render`,hookData:e,args:t,cwd:n,...r},TE,DE)}function kE(e,t){return vE({kind:`click`,verb:e,value:t},EE,DE)}function AE(e){let t=[];for(let n of e){let e=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(`
167
+ `)}function jE(e,t){return e===`darwin`?[ME(`footprint`,[`-p`,String(t)]),ME(`vmmap`,[`--summary`,String(t)])]:e===`linux`?[NE(`/proc/self/smaps_rollup`),NE(`/proc/self/status`)]:[]}function ME(e,t){return{name:`${e} ${t.join(` `)}`,read:()=>{let n=ke({bin:e,args:[...t],timeoutMs:5e3,category:`limits.memory-report`});return n.ok?n.stdout.trim().length>0?{kind:`text`,text:n.stdout}:{kind:`unavailable`,reason:`exited 0 but printed nothing`}:{kind:`unavailable`,reason:`${n.reason}${n.error===void 0?``:`: ${n.error}`}${PE(n.stderr)}`}}}}function NE(e){return{name:e,read:()=>{try{let t=r.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}}}}}function PE(e){let t=e.split(`
168
+ `).map(e=>e.trim()).find(e=>e.length>0);return t===void 0?``:` (${t})`}const FE=`CC_CANDYBAR_RSS_LIMIT_MB`;function IE(e){let t=e[FE];if(t===void 0)return 512;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${FE} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function LE(e){return IE(e)*2}const RE=1024*1024;function zE(e){return IE(e)*RE}const BE={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function VE(e,t,n){let{prefix:r,suffix:i}=BE[t];return c.join(e,`${r}${n}${i}`)}function HE(e){for(let t of Object.keys(BE)){let{prefix:n,suffix:r}=BE[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function UE(e){let t=e.rssLimitBytes??512*RE,n=e.snapshotsKeep??3,r=!1;function i(){if(r)return!0;let{rss:i,heapTotal:a}=e.memoryBytes();if(i<=t)return!1;r=!0,e.log(`warn`,`RSS ${i} > limit ${t} (v8 heap ${a}); recording memory then shutting down`);let o=`${new Date(e.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return WE(e.log,`memory report`,()=>{let t=VE(e.snapshotDir,`memoryReport`,o);e.writeMemoryReport(t,e.captureMemoryReport()),e.log(`info`,`memory report written: ${t}`)}),WE(e.log,`heap snapshot`,()=>{let t=VE(e.snapshotDir,`heapSnapshot`,o);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),WE(e.log,`artifact rotation`,()=>{KE(e.listArtifacts(),n,e.removeFile)}),e.shutdown(0),!0}function a(){let{rss:n,heapTotal:r}=e.memoryBytes();return n>t*.75?`rss ${n} approaching limit ${t} (v8 heap ${r})`:null}function o(e=6e4){let t=setInterval(()=>{i()},e);return t.unref(),{disarm:()=>clearInterval(t)}}return{checkRss:i,describeNextRestart:a,arm:o}}function WE(e,t,n){try{n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function GE(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=HE(t);if(n===null)return t;let{prefix:r,suffix:i}=BE[n];return t.slice(r.length,t.length-i.length)}function KE(e,t,n){let r=new Map;for(let t of e){let e=GE(t),n=r.get(e);n===void 0?r.set(e,[t]):n.push(t)}let i=[...r.keys()].sort((e,t)=>t.localeCompare(e));for(let e of i.slice(t))for(let t of r.get(e)??[])try{n(t)}catch{}}function qE(e,t,n={}){let i=Fe();return{now:()=>Date.now(),pid:process.pid,snapshotDir:i,log:Z,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},captureMemoryReport:()=>AE(jE(process.platform,process.pid)),writeMemoryReport:(e,t)=>r.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>te.writeHeapSnapshot(e),listArtifacts:()=>{try{return r.readdirSync(i).filter(e=>HE(e)!==null).map(e=>c.join(i,e))}catch{return[]}},removeFile:e=>r.unlinkSync(e),shutdown:t,startedAtMs:e,...n}}function JE(e={}){if(uD()!==null)return;let n=e.spawn??dD,r=sD();if(r.kind===`contended`){let e=XE();e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),YE(n));return}if(r.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${r.reason}) — spawning unlocked\n`),YE(n);return}try{YE(n)}finally{lD()}}function YE(e){rD()&&ZE(e)}function XE(){try{let e=r.statSync(We());return Date.now()-e.mtimeMs}catch{return null}}function ZE(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
169
+ `)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function QE(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function $E(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function eD(e){try{let t=r.readFileSync(e,`utf8`).trim(),n=Number(t);return!Number.isInteger(n)||n<0?0:Math.min(n,5)}catch{return 0}}function tD(e,n){try{r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,String(n),{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.backoff: ${e.message}\n`)}}function nD(){try{r.unlinkSync(Ke())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function rD(){let e=Ge(),n=Ke(),r=eD(n),i=QE(iD(e),$E(r));return i.kind===`deny`?!1:(i.kind===`allow-future-garbage`&&t.stderr.write(`cc-candybar: spawn.cooldown mtime is ${i.futureMs}ms in the future — ignoring and spawning\n`),aD(e),tD(n,Math.min(r+1,5)),!0)}function iD(e){try{return Date.now()-r.statSync(e).mtimeMs}catch{return null}}function aD(e){try{r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,`${t.pid} ${Date.now()}\n`,{mode:384})}catch(e){t.stderr.write(`cc-candybar: could not record spawn.cooldown: ${e.message}\n`)}}let oD=null;function sD(){let e=We();for(let n=0;n<2;n++){try{let n=r.openSync(e,`wx`,384);try{r.writeSync(n,JSON.stringify({pid:t.pid,ts:Date.now()}))}catch{}return oD={fd:n,path:e},{kind:`held`}}catch(t){let n=t.code;if(n!==`EEXIST`)return{kind:`error`,reason:`openSync(${e}): ${n??t.message}`}}if(!cD(e))return{kind:`contended`};try{r.unlinkSync(e)}catch(e){if(e.code!==`ENOENT`)return{kind:`error`,reason:`unlink stale spawn.lock: ${e.message}`}}}return{kind:`contended`}}function cD(e){try{let t=r.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function lD(){if(!oD)return;let{fd:e,path:t}=oD;oD=null;try{r.closeSync(e)}catch{}try{r.unlinkSync(t)}catch{}}function uD(){try{return r.mkdirSync(Fe(),{recursive:!0}),null}catch(e){return`mkdir ${Fe()}: ${e.message}`}}function dD(){let e=t.execPath,n=t.argv[1];return n?Ae({bin:e,args:[`--max-old-space-size=${LE(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const fD=`cc-candybar`,pD=`dispatch`,mD=`set-state`,hD=`step-state`,gD=`copy`,_D=`open-vscode`,vD=`toolbar-toggle`,yD=`show-config-error`,bD=`show-config-warning`,xD=`set-config`,SD=`step-config`,CD=`save`,wD=`save-preset`,TD=`delete-preset`,ED=`reset-config`,DD=`apply-layout-op`,OD=`undo`,kD=`redo`,AD=`back`,jD=`rewind`,MD=`apply-update`,ND=`doctor-run`,PD=`doctor-fix`,FD=`ceiling`,ID=`slash`;function LD(e){return e.map(encodeURIComponent).join(`/`)}function RD(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function zD(e){return`${fD}://${pD}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${LD(e.args)}`)}`).join(`&`)}`}function BD(e){return new re(e).getAll(`e`).map(WD)}const VD=new Set([mD,ED]);function HD(e){return e.reduce((e,t)=>{let n=e.at(-1),r=n&&UD(n,t);return r?[...e.slice(0,-1),r]:[...e,t]},[])}function UD(e,t){if(e.verb!==t.verb||!VD.has(e.verb))return;let[n,r]=[WD(e.value),WD(t.value)];return n.verb===r.verb?{verb:e.verb,value:`${n.verb}/${n.value}/${r.value}`}:void 0}function WD(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const GD=`1.115.0`,KD=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function qD(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function JD(e){return KD.test(e)?e:qD(e)}const YD=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function XD(e){let t=YD.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)`}}function ZD(e){return e.join(`.`)}function QD([e,t,n],[r,i,a]){return e-r||t-i||n-a}const $D=`@promptctl/cc-candybar`;async function eO(e,t,n){let r=`${n}/-/package/${encodeURIComponent(e)}/dist-tags`;try{let e=await t(r,{signal:AbortSignal.timeout(5e3)});if(!e.ok)return X(`registry responded ${e.status} for ${r}`);let n=await e.json();return typeof n.latest==`string`?XD(n.latest):Y}catch(e){return X(e instanceof Error?e.message:String(e))}}function tO(e,t){let n=XD(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=QD(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 nO(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${ZD(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${ZD(t.installed)} is newer than the registry's latest release (${ZD(t.latest)}): an unpublished build.\n`};case`stale`:{let n=ZD(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${ZD(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 rO=`CCCandybarURLHandler`,iO=[],aO={"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 oO(e,t){return[e,...t].map(JD).join(` `)}function sO(){return c.join(m.homedir(),`Applications`,`${rO}.app`)}function cO(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function lO(){if(process.platform===`darwin`)return c.join(m.homedir(),`Library`,`Application Support`,`CCCandybar`);let e=process.env.XDG_DATA_HOME??c.join(m.homedir(),`.local`,`share`);return c.join(e,`cc-candybar`)}function uO(){return c.join(lO(),`bin`,`cc-candybar`)}function dO(){return c.join(lO(),`dist`,`index.mjs`)}function fO(e,t){return[`on open location L`,`\tdo shell script "'${e.replace(/"/g,`\\"`)}' '${t.replace(/"/g,`\\"`)}' url-handle " & quoted form of L`,`end open location`].join(`
170
+ `)}function pO(e){if(!e)throw Error(`install: process.argv[1] not set`);return e.endsWith(`.mjs`)||e.endsWith(`.js`)?e:c.resolve(c.dirname(e),`..`,`dist`,`index.mjs`)}function mO(t){let n=aO[`${process.platform}-${process.arch}`];if(n){let r=e(t);try{return{kind:`native`,sourcePath:r.resolve(`${n}/bin/cc-candybar`)}}catch{}}return{kind:`node-shim`,sourcePath:c.resolve(c.dirname(t),`..`,`bin`,`cc-candybar`)}}function hO(e,t){c.resolve(e)!==c.resolve(t)&&r.copyFileSync(e,t)}function gO(e){let t=r.openSync(e,`r`);try{let n=Buffer.alloc(2),i=r.readSync(t,n,0,2,0);if(i<2)throw Error(`install: staged render entry at ${e} is truncated (${i} byte(s)). Re-run: pnpm dlx ${$D}@latest install`);return n.toString(`latin1`)===`#!`?`node-shim`:`native`}finally{r.closeSync(t)}}function _O(){let e=pO(process.argv[1]);if(!r.existsSync(e))throw Error(`install: bundled dist not found at ${e}. Reinstall the package.`);let t=mO(e);if(!r.existsSync(t.sourcePath))throw Error(`install: render entry not found at ${t.sourcePath}. Reinstall the package.`);r.mkdirSync(c.dirname(dO()),{recursive:!0}),r.mkdirSync(c.dirname(uO()),{recursive:!0}),hO(e,dO()),hO(t.sourcePath,uO()),r.chmodSync(uO(),493),r.rmSync(c.join(lO(),`url-handler.mjs`),{force:!0});let n=gO(uO());return process.stdout.write(`Staged cc-candybar v${GD} runtime at ${lO()}\n`+(n===`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:uO(),distPath:dO(),entryKind:n}}function vO(){return[{key:`CFBundleIdentifier`,xml:`<string>com.cccandybar.url-handler</string>`},{key:`CFBundleURLTypes`,xml:[`<array>`,` <dict>`,` <key>CFBundleURLName</key>`,` <string>Claude Powerline Click Action</string>`,` <key>CFBundleURLSchemes</key>`,` <array>`,` <string>${fD}</string>`,` </array>`,` </dict>`,`</array>`].join(`
171
+ `)}]}function yO(e){let t=sO();r.mkdirSync(c.dirname(t),{recursive:!0}),r.existsSync(t)&&r.rmSync(t,{recursive:!0,force:!0}),process.stdout.write(`Building ${t}\n`);let n=ke({bin:`/usr/bin/osacompile`,args:[`-o`,t,`-e`,fO(process.execPath,e)],category:`install.osacompile`});if(!n.ok)throw process.stderr.write(n.stderr),Error(`osacompile failed (${n.reason})`);let i=c.join(t,`Contents`,`Info.plist`);for(let{key:e}of vO())ke({bin:`/usr/bin/plutil`,args:[`-remove`,e,i],category:`install.plutil`});for(let{key:e,xml:t}of vO()){let n=ke({bin:`/usr/bin/plutil`,args:[`-insert`,e,`-xml`,t,i],category:`install.plutil`});if(!n.ok)throw process.stderr.write(n.stderr),Error(`plutil -insert ${e} failed (${n.reason})`)}process.stdout.write(`Registering ${fD}:// with Launch Services\n`);let a=ke({bin:`/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister`,args:[`-f`,t],category:`install.lsregister`});if(!a.ok)throw process.stderr.write(a.stderr),Error(`lsregister failed (${a.reason})`);process.stdout.write(`✓ ${rO}.app installed and registered.\n`),process.stdout.write(` Test: open '${fD}://hello-world' && pbpaste\n`)}function bO(){cO(),yO(_O().distPath)}function xO(e,t=fD){let n=`${t}://`;if(!e.startsWith(n))throw Error(`expected ${n} scheme, got: ${e}`);let r=e.slice(n.length),i=r.indexOf(`/`);return i===-1?{verb:gD,value:r}:{verb:decodeURIComponent(r.slice(0,i)),value:r.slice(i+1)}}async function SO(e){e||(process.stderr.write(`url-handle: missing URL argument.
172
+ `),process.exit(1));let t;try{t=xO(e)}catch(e){process.stderr.write(`url-handle: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)}let n=await kE(t.verb,t.value);n.kind===`ok`&&process.exit(0),n.kind===`transient`&&(JE(),process.stderr.write(`url-handle: daemon unavailable (${n.cause}: ${n.message})\n`),process.exit(1)),process.stderr.write(CO(n)+`
173
+ `),process.exit(1)}function CO(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`malformed_response`:return`url-handle: daemon rejected click (malformed response: ${e.message})`}}function wO(){return`✓ install complete.
170
174
  Restart Claude Code to pick up the new statusline.
171
- Tip: every bar carries a settings menu — click it (${Gc} by\n default) for quick actions, preset switching, edit mode, and clickable\n theme/style/variation/endcaps/wrap/padding controls.\n`}async function yO(e){let t=e.includes(`--force`),n=e.filter(e=>e!==`--force`),r=n.length>0?n:[...QD],i=dO();process.platform===`darwin`?pO(i.distPath):process.stdout.write(`Skipping URL handler (cmd-click verbs are macOS-only).
172
- `),bO(i.binPath,r,t),process.stdout.write(vO());let a=XD(qD,YD(zD,await JD(qD,fetch,`https://registry.npmjs.org`)));process[a.stream].write(a.text)}function bO(e,t,n,i){let a=i??eS($x(Qx(process.env,process.cwd())));r.mkdirSync(c.dirname(a),{recursive:!0});let o={};if(r.existsSync(a))try{o=JSON.parse(r.readFileSync(a,`utf-8`))}catch(e){throw Error(`Could not parse ${a}: ${e instanceof Error?e.message:String(e)}`)}let s=o.statusLine?.command,l=[e,HD(e),VD(e)],u=typeof s==`string`&&(s.startsWith(`pnpm dlx @promptctl/cc-candybar@`)||l.some(e=>s===e||s.startsWith(`${e} `)));if(s&&!u&&!n){process.stderr.write(`Skipping settings.json update: existing statusLine.command appears customized.\n Current: ${s}\n To overwrite, re-run with --force.\n`);return}o.statusLine={type:`command`,command:eO(e,t)},je(a,JSON.stringify(o,null,2)),process.stdout.write(`Updated ${a}\n`)}function xO(e,t){return e.kind===`owned`?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 SO(e){let t;try{t=r.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 i=n,a=i?.pid;if(typeof a!=`number`||!Number.isInteger(a)||a<=0)return{kind:`unreadable`,detail:`no valid pid (got ${JSON.stringify(a)})`};let o=i?.startTime;return o!=null&&typeof o!=`string`?{kind:`unreadable`,detail:`invalid startTime (got ${JSON.stringify(o)})`}:{kind:`owned`,pid:a,startTime:o??null}}function CO(e,n){let i=`${e}.${t.pid}.tmp`;try{return r.writeFileSync(i,JSON.stringify(n),{mode:384}),r.renameSync(i,e),null}catch(e){let t=e.message;try{r.unlinkSync(i)}catch(e){if(e.code!==`ENOENT`)return`${t}; also failed to remove temp ${i}: ${e.message}`}return t}}function wO(e,t){let n=SO(e);if(n.kind===`owned`&&n.pid===t)try{r.unlinkSync(e)}catch{}}function TO(e){try{let t=r.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 EO(e,t,n,r){let i=DO(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 DO(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 OO(e){let t=!1;function n(){let n=EO(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=setInterval(()=>{n().kind===`displaced`&&clearInterval(r)},t);return r.unref(),{disarm:()=>clearInterval(r)}}return{check:n,arm:r}}function kO(e,t=ke){let n=t({bin:`ps`,args:[`-o`,`lstart=`,`-p`,String(e)],category:`process-fingerprint`,timeoutMs:2e3,env:{...process.env,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 AO(e,t,n){if(t===null)return n.pidAlive(e);let r=n.readStartTime(e);switch(r.kind){case`start`:return r.token===t;case`unavailable`:return n.pidAlive(e)}}function jO(e,t=kO){let n=t(e);return n.kind===`start`?n.token:null}const MO=`CC_CANDYBAR_PARENT_PID`;function NO(e){let t=e[MO];if(t===void 0)return{kind:`outlives-nobody`};let n=Number.parseInt(t,10);if(!Number.isInteger(n)||n<=0)throw Error(`${MO} must be a positive integer pid, got ${JSON.stringify(t)}`);return{kind:`anchored`,pid:n}}function PO(e){if(e.anchor.kind===`outlives-nobody`)return{disarm:()=>{}};let{pid:t}=e.anchor,n=setInterval(()=>{e.isAlive(t)||e.onOrphaned(`spawner pid ${t} gone`)},e.intervalMs??250);return n.unref(),{disarm:()=>clearInterval(n)}}function FO(e){try{return t.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function IO(){let e=Number(process.env.CC_CANDYBAR_DAEMON_CEILING??``);return Number.isInteger(e)&&e>0?e:16}function LO(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 RO(e){try{return r.readdirSync(e).filter(e=>e.endsWith(`.json`)).map(t=>c.join(e,t))}catch{return[]}}function zO(e){let t;try{t=r.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}}function BO(e,t,n){let r=0;for(let i of e)t(i.identity.pid,i.identity.startTime)?r++:n(i.path);return r}function VO(e){if(!e.isolated)return{decision:LO(!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=LO(!0,BO(t,e.isSameLiveProcess,e.removeFile),e.ceiling);if(!n.allow)return{decision:n,registryPath:null};let r=c.join(e.registryDir,`pid-${e.pid}.json`);return e.writeEntry(r,{pid:e.pid,startTime:e.startTime}),{decision:n,registryPath:r}}function HO(e,t,n,r){let i=n(e);if(i!==null&&i.pid===t)try{r(e)}catch{}}function UO(e,t={}){return{isolated:!!process.env.CC_CANDYBAR_SOCKET,registryDir:Ue(),ceiling:IO(),pid:process.pid,startTime:e,isSameLiveProcess:(e,t)=>AO(e,t,{readStartTime:kO,pidAlive:FO}),listFiles:RO,readEntry:zO,removeFile:e=>{try{r.unlinkSync(e)}catch{}},writeEntry:(e,t)=>{let n=`${e}.${t.pid}.tmp`;try{r.writeFileSync(n,JSON.stringify(t),{mode:384}),r.renameSync(n,e)}catch(e){try{r.unlinkSync(n)}catch(e){e.code}throw e}},ensureDirSafe:process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR?Le:e=>{Le(c.dirname(e)),Le(e)},...t}}function WO(e){return e<32||e===127||e>=128&&e<=159}function GO(e){let t=``;for(let n of e)t+=WO(n.codePointAt(0)??0)?` `:n;return t.replace(/\s+/g,` `).trim()}function KO(e,t){let n=GO(e),r=``,i=0;for(let e of n){if(i===t)return r.replace(/.$/u,`…`);r+=e,i++}return r}const qO=`\x1B[38;2;255;255;255m`,JO=`\x1B[48;2;200;40;40m`;function YO(e){let t=/;2;(\d+);(\d+);(\d+)m$/.exec(e);if(t===null)throw Error(`diagnostic-style: not a 24-bit SGR: ${e}`);return`#`+t.slice(1,4).map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}const XO={fg:YO(qO),bg:YO(JO)},ZO={fg:YO(`\x1B[38;2;0;0;0m`),bg:YO(`\x1B[48;2;220;160;40m`)},QO={unicode:zi,ascii:{glyph:`>`,divider:`|`,lead:`<`,tail:`>`}},$O={unicode:{},ascii:{left:`(`,right:`)`}};function ek(e,t,n){switch(e){case`capsule`:return new Gi($O[t]);case`plain`:return new Ki(n===void 0?{}:{separator:n});case`powerline`:return new Hi(QO[t]);default:return e}}const tk=new Map;function nk(e){let t=JSON.stringify([e.endcaps,e.charset,e.separator??null]),n=tk.get(t);if(n!==void 0)return n;let r=ek(e.endcaps,e.charset,e.separator),i=e=>new H(`x`,{end:``,overflow:`ignore`,style:new B({bgcolor:e})}),a=e=>new H(Yi(new U(e,r),{colorSystem:null}).replace(/\n$/,``)).cellLength,o=a([i(`#101010`)]),s={chrome:o-1,seam:a([i(`#101010`),i(`#202020`)])-o-1};return tk.set(t,s),s}function rk(e){return nk(e).chrome}function ik(e){return nk(e).seam}function ak(e,t){if(e.length===0)return``;let n=ek(t.endcaps,t.charset,t.separator),r=t.colorCompatibility,i=t.wrap&&Number.isFinite(t.width)?Yi(new ta([...e],{joiner:n}),{width:t.width,colorSystem:r}):Yi(new U([...e],n),{colorSystem:r});if(!i.endsWith(`
173
- `))throw Error(`renderStripCells: rich-js strip output did not end its last line`);return i.slice(0,-1)}function ok(e){return Math.min(20,e??20)}const sk={heading:`ERROR`,glyph:`⚠`,colors:XO},ck={heading:`WARNING`,glyph:`⚠`,colors:ZO},lk={heading:`UPDATE`,glyph:`⬆`,colors:ZO};function uk(e,t){return{text:GO(e),link:t}}function dk(e,t,n){let[r,...i]=[fk(e,sk,pD),t,fk(n,ck,mD)].flat();return r===void 0?null:{channels:[r,...i]}}function fk(e,t,n){let r=ND([{verb:n,args:[e]}]),[i,...a]=e.split(/\r\n|\r|\n/).map(e=>uk(e,r)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:t,message:e,lines:[i,...a]}]}function pk(e){return e.channels.map(e=>`${e.severity.heading}\n${e.message}\n`).join(`
174
- `)}function mk(e,t,n,r){if(t===null)return e;let i=hk(r),a=t.channels.flatMap(e=>gk(e,i)),o=n.failedConfigFile!==null||a.length>r.rowCap,s=a.slice(0,r.rowCap-Number(o)),c=o?[_k(t,n,a.length-s.length,i)]:[],l=[...s,...c].join(`
175
- `);return e?`${l}\n${e}`:l}function hk(e){return{endcaps:`plain`,separator:``,width:e.width,wrap:!0,padding:0,charset:`unicode`,colorCompatibility:e.colorCompatibility}}function gk(e,t){let n=new B({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=Bt(Math.max(2,t.width-1)),i=(e,t)=>new H(`${e} `,{style:t,end:``,overflow:`ignore`});return e.lines.flatMap((a,o)=>ak([i(o===0?e.severity.glyph:` `,n.withLink(a[0].link)),...a.flatMap(e=>{let t=n.withLink(e.link);return e.text.split(` `).flatMap(e=>Ut(e,r)).map(e=>i(e,t))})],t).split(`
176
- `))}function _k(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:a,failedConfigFile:o}=t,s=new B({bgcolor:i.bg,color:i.fg}),c=(e,t)=>new H(e,{style:t,end:``,overflow:`ignore`}),l=n>0?[c(`${n} more rows · `,s),a.kind===`file`?c(`open full text`,s.withLink(D(a.path).href)):c(`full text unavailable: ${GO(a.reason)}`,s)]:[],u=o===null?[]:[c(`${l.length>0?` · `:``}open `,s),c(GO(o),s.withLink(D(o).href))],d=[c(`↳ `,s),...l,...u.slice(0,-1)],f=d.reduce((e,t)=>e+t.cellLength,0),p=u.slice(-1).map(e=>e.truncate(Math.max(1,r.width-f),{mode:`middle`})),m=H.fromFragments([...d,...p]).truncate(r.width);return m.overflow=`ignore`,ak([m],r)}const vk=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function yk(e,t){return t.isSymbolicLink()?Buffer.from(r.readlinkSync(e)):r.readFileSync(e)}function bk(e,t){return r.readdirSync(t).filter(vk).sort().flatMap(n=>{let i=c.join(t,n),a=r.lstatSync(i,{throwIfNoEntry:!1});return a===void 0?[]:a.isDirectory()?bk(e,i):[[c.relative(e,i).split(c.sep).join(`/`),yk(i,a)]]})}function xk(e){let t=ie.createHash(`sha256`);for(let[n,r]of bk(e,e))t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}const Sk=e=>e.slice(0,7);function Ck(e){return c.dirname(c.dirname(e))}function wk(){return{version:zD,digest:`2c386694b6b8b93252262f938f95117ae56c400858c2859fc1ab18c0da3d84da`}}function Tk(e){let t=JSON.parse(r.readFileSync(c.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${c.join(e,`package.json`)} has no version string`);return n}function Ek(e,t){try{let n=Ck(E(e)),i=c.join(n,`src`);if(!r.existsSync(i))return{kind:`not-source-checkout`};let a=t(),o=xk(i);return o===a.digest?{kind:`current`,root:n,stamp:a}:{kind:`stale`,root:n,source:{version:Tk(n),digest:o},running:a}}catch(e){return{kind:`unchecked`,reason:e.message}}}var $=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};function Dk(e){return e.op===`remove`?`remove:${e.target}`:`insert:${e.segment}:${e.anchor}:${e.relation}`}function Ok(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 kk(e,t,n){let r=As(e,new Set(n.map(ks).filter(e=>e.includes(t)).flat()));return r===e?{seg:e}:{seg:e,id:r}}const Ak=/^-?\d+$/;function jk(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 Mk(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!Ak.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 Nk(e,t,n){return r=>r?Ak.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 Pk(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=>!Ak.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 Fk(e){return e===`config`?`set-config`:`set-state`}function Ik(e,t,n){return t.kind===`int`?Mk(`menu page "${e}"`):t.kind===`range`?Nk(t.min,t.max,`${n} stepper "${e}"`):jk(t.allowed,`${n} "${e}"`,Fk(n))}function Lk(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:Pk(e,n,t)}))}function Rk(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 Lk(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,Ik(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 zk(e,t,n){let r=[],i=0,a=new WeakMap;return{register(n,a){let o={key:n,allowed:a};Rk(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=Rk(e,r,n(o),t);return a.set(o,{epoch:i,gate:c}),c}}}const Bk=zk({},`config`,qk);function Vk(e,t){return Bk.register(e,t)}function Hk(e){return Bk.gateFor(e)}function Uk(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:ox(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:[Dk({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[Dk({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:ox(e.insertSegmentFrom,t).members.map(t=>Dk({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function Wk(e,t){let n=Ml(e).get(t);return n===void 0?null:String(n)}function Gk(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?gx(n.persist):null;e?.scope===`preset-root`&&t.add(mx(e.preset))}return[...t].map(e=>({key:e,spec:{kind:`allow-list`,allowed:[]}}))}function Kk(e){let t=new Map([...ix(e),...XC(e)]);return[...Gk(e),...Object.values(e.actions).flatMap(e=>Uk(e,t))]}function qk(e){return Lk(Kk(e),`config`)}const Jk=Zx(`commands.`),Yk=uS(`autocompact.`,e=>`{{ template "formatTokenCount" ${e} }}`),Xk=`trimPrefix "/" (trimPrefix .project_dir .current_dir)`,Zk=`{{ \$dir := .current_dir }}{{ if and (ne .home "") (or (eq .home .current_dir) (hasPrefix (printf "%s/" .home) .current_dir)) }}{{ \$dir = printf "~%s" (trimPrefix .home .current_dir) }}{{ else }}{{ if or (eq .project_dir .current_dir) (hasPrefix (printf "%s/" .project_dir) .current_dir) }}{{ $dir = ternary (${Xk}) (basename .project_dir) (ne (${Xk}) "") }}{{ end }}{{ end }}{{ action "copyDir" (abbreviatePath \$dir) }}`,Qk=`{{ ${kx} }}`,$k={min:0,max:100,step:5},eA={warnAt:{label:`warning at %`,domain:$k,default:50},errorAt:{label:`error at %`,domain:{...$k,atLeast:`warnAt`},default:80}};function tA(e){return{budget:{label:`budget $`,domain:{min:0,max:1e4,step:5},default:e},warnAt:{label:`warning at %`,domain:$k,default:80}}}const nA={globals:{palette:`tokyo-night`},variables:{...Jk.variables,...Mb,current_dir:{kind:`input`,path:`workspace.current_dir`,default:`?`},"model.display_name":{kind:`input`,path:`model.display_name`,default:``},version:{kind:`input`,path:`version`,default:``},home:{kind:`input`,path:`home`,default:``},"tmux.session":{kind:`input`,path:`tmux.session`,default:``},"host.name":{kind:`input`,path:`host.name`,default:``},"host.user":{kind:`input`,path:`host.user`,default:``},"host.ssh":{kind:`input`,path:`host.ssh`,type:`boolean`,default:!1},"git.repoName":{kind:`input`,path:`git.repoName`,default:``},"git.branch":{kind:`input`,path:`git.branch`,default:``},"git.sha":{kind:`input`,path:`git.sha`,default:``},"git.ahead":{kind:`input`,path:`git.ahead`,type:`number`,default:0},"git.behind":{kind:`input`,path:`git.behind`,type:`number`,default:0},"git.staged":{kind:`input`,path:`git.staged`,type:`number`,default:0},"git.unstaged":{kind:`input`,path:`git.unstaged`,type:`number`,default:0},"git.untracked":{kind:`input`,path:`git.untracked`,type:`number`,default:0},"git.conflicts":{kind:`input`,path:`git.conflicts`,type:`number`,default:0},"git.upstream":{kind:`input`,path:`git.upstream`,default:``},"git.stash":{kind:`input`,path:`git.stash`,type:`number`,default:0},"git.status":{kind:`input`,path:`git.status`,default:`clean`},"git.operation":{kind:`input`,path:`git.operation`,default:``},"git.timeSinceCommit":{kind:`input`,path:`git.timeSinceCommit`,type:`number`,default:0},"git.color.branch":{kind:`literal`,value:`primary`},"git.color.staged":{kind:`literal`,value:`success`},"git.color.unstaged":{kind:`literal`,value:`warning`},"git.color.untracked":{kind:`literal`,value:`accent`},"git.color.conflicts":{kind:`literal`,value:`error`},"git.color.ahead":{kind:`literal`,value:`success`},"git.color.behind":{kind:`literal`,value:`warning`},"git.color.stash":{kind:`literal`,value:`accent`},"git.detail":{kind:`state`,key:`git-detail`,default:`collapsed`},"git.prNumber":{kind:`input`,path:`git.prNumber`,type:`number`,default:0},"git.prState":{kind:`input`,path:`git.prState`,default:``},"git.prUrl":{kind:`input`,path:`git.prUrl`,default:``},"git.prError":{kind:`input`,path:`git.prError`,default:``},"cache.expiresAt":{kind:`input`,path:`cache.expiresAt`,type:`number`,default:0},"session.cost":{kind:`input`,path:`session.cost`,type:`number`,default:0},"session.tokens":{kind:`input`,path:`session.tokens`,type:`number`,default:0},"today.cost":{kind:`input`,path:`today.cost`,type:`number`,default:0},"today.tokens":{kind:`input`,path:`today.tokens`,type:`number`,default:0},"block.nativeUtilization":{kind:`input`,path:`block.nativeUtilization`,type:`number`,default:0},"block.resetsAt":{kind:`input`,path:`block.resetsAt`,type:`number`,default:0},"weekly.percentage":{kind:`input`,path:`weekly.percentage`,type:`number`,default:0},"weekly.resetsAt":{kind:`input`,path:`weekly.resetsAt`,type:`number`,default:0},"burn.costPerHour":{kind:`input`,path:`burn.costPerHour`,type:`number`,default:-1},"block.etaMinutes":{kind:`input`,path:`block.etaMinutes`,type:`number`,default:-1},"weekly.etaMinutes":{kind:`input`,path:`weekly.etaMinutes`,type:`number`,default:-1},"speed.input":{kind:`input`,path:`speed.input`,type:`number`,default:-1},"speed.output":{kind:`input`,path:`speed.output`,type:`number`,default:-1},"speed.total":{kind:`input`,path:`speed.total`,type:`number`,default:-1},"speed.history":{kind:`input`,path:`speed.history`,type:`string`,default:``},"context.totalTokens":{kind:`input`,path:`context.totalTokens`,type:`number`,default:0},"context.contextLeft":{kind:`input`,path:`context.contextLeft`,type:`number`,default:100},"memento.ceiling":{kind:`input`,path:`memento.ceiling`,type:`number`,default:-1},"memento.off":{kind:`input`,path:`memento.off`,type:`boolean`,default:!1},"memento.session":{kind:`input`,path:`memento.session`,default:``},"memento.error":{kind:`input`,path:`memento.error`,default:``},"metrics.lastResponseTime":{kind:`input`,path:`metrics.lastResponseTime`,type:`number`,default:0},"metrics.responseTime":{kind:`input`,path:`metrics.responseTime`,type:`number`,default:0},"metrics.sessionDuration":{kind:`input`,path:`metrics.sessionDuration`,type:`number`,default:0},"metrics.messageCount":{kind:`input`,path:`metrics.messageCount`,type:`number`,default:0},"metrics.linesAdded":{kind:`input`,path:`metrics.linesAdded`,type:`number`,default:0},"metrics.linesRemoved":{kind:`input`,path:`metrics.linesRemoved`,type:`number`,default:0},"activity.command":{kind:`input`,path:`activity.command`,type:`string`,default:``},"activity.todo.total":{kind:`input`,path:`activity.todo.total`,type:`number`,default:0},"activity.todo.completed":{kind:`input`,path:`activity.todo.completed`,type:`number`,default:0},"activity.todo.position":{kind:`input`,path:`activity.todo.position`,type:`number`,default:0},"activity.todo.active":{kind:`input`,path:`activity.todo.active`,type:`string`,default:``},"activity.tool.running":{kind:`input`,path:`activity.tool.running`,type:`string`,default:``},"activity.tool.done":{kind:`input`,path:`activity.tool.done`,type:`string`,default:``}},segments:{directory:{group:`location`,description:"The current directory, shortened fish-style — `~` under home, project-relative inside the project. Click to copy the full path.",template:Zk},model:{group:`model-context`,description:`The active model's display name.`,template:`✱ {{ formatModelName .model.display_name }}`,when:`{{ ne .model.display_name "" }}`},sessionId:{group:`session-tools`,description:`The session id, truncated to 8 characters.`,template:`⌗{{ trunc 8 .session.id }}`,when:`{{ ne .session.id "" }}`},version:{group:`model-context`,description:`The Claude Code version reported in the hook payload.`,template:`◈ v{{ .version }}`,when:`{{ ne .version "" }}`},tmux:{group:`location`,description:`The tmux session name; hidden when not inside tmux.`,template:`tmux:{{ .tmux.session | default "none" }}`,when:`{{ ne .tmux.session "" }}`},host:{group:`location`,description:`user@host on a warning background, shown only over SSH.`,template:`⇄ {{ .host.user | default "?" }}@{{ .host.name | default "?" }}`,bg:`warning`,when:`{{ .host.ssh }}`},gitaculous:{group:`git`,description:`The git state: a summary (branch, ahead/behind, S/U/? flags) that the arrow at its right edge expands to every fact — repo, in-progress operation, sha, upstream ±, stash count, time since the last commit.`,template:`{{ if eq .git.detail "expanded" }}{{ template "gitExpanded" . }}{{ else }}{{ template "gitCollapsed" . }}{{ end }} {{ action "gitDetail" "▸" "◂" }}`,fg:Qk,when:`{{ ne .git.branch "" }}`,settings:{aheadBehind:{label:`ahead/behind`,domain:`bool`,default:!0},flags:{label:`dirty flags`,domain:`bool`,default:!0},operation:{label:`operation`,domain:`bool`,default:!0},repo:{label:`repo name`,domain:`bool`,default:!0},sha:{label:`commit hash`,domain:`bool`,default:!0},stash:{label:`stash`,domain:`bool`,default:!0},upstream:{label:`upstream`,domain:`bool`,default:!0},age:{label:`time since commit`,domain:`bool`,default:!0}}},gitPr:{group:`git`,description:"The pull request open for this branch, as a link; `⚠ PR` when the forge lookup failed.",template:`{{ if ne .git.prUrl "" }}{{ link .git.prUrl (printf "⇆ #%v" .git.prNumber) }}{{ else }}⚠ PR{{ end }}`,when:`{{ or (ne .git.prUrl "") (ne .git.prError "") }}`},toolbar:{group:`session-tools`,description:`Quick actions: copy the session id, and open the project, transcript or repo.`,template:Bx(``).template},commands:{group:`session-tools`,description:`Type /compact, /model or /clear into this session; /clear asks for a second click. Hidden when not inside tmux.`,template:Jk.template,when:Jk.when},themeSwitcher:{group:`session-tools`,description:"`◀ <theme> ▶`: the theme the bar is wearing; ◀ and ▶ switch this session to the previous or next theme, wrapping at the ends.",template:`{{ carousel "stepTheme" 0 }}`},session:{group:`cost-limits`,description:`This session's cost and token total, with a budget warning once a budget is configured.`,template:`§ {{ template "formatCost" .session.cost }} ({{ template "formatTokens" .session.tokens }}){{ template "budgetStatus" (dict "cost" .session.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:tA(0)},today:{group:`cost-limits`,description:`Today's cost and tokens across every session, with a budget warning once a budget is configured.`,template:`☉ {{ template "formatCost" .today.cost }} ({{ template "formatTokens" .today.tokens }}){{ template "budgetStatus" (dict "cost" .today.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:tA(50)},block:{group:`cost-limits`,description:`The 5-hour rate-limit block: percent used and time to reset, heating to warning then error.`,template:`◱ {{ round .block.nativeUtilization }}% ({{ template "formatResetCountdown" .block.resetsAt }})`,bg:`{{ ramp (round .block.nativeUtilization) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:eA,when:`{{ gt .block.resetsAt 0 }}`},weekly:{group:`cost-limits`,description:`The weekly rate-limit quota: percent used and time to reset, heating to warning then error.`,template:`◑ {{ round .weekly.percentage }}% ({{ template "formatResetCountdown" .weekly.resetsAt }})`,bg:`{{ ramp (round .weekly.percentage) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:eA,when:`{{ gt .weekly.resetsAt 0 }}`},burnrate:{group:`cost-limits`,description:`Spend per hour, with the projected time to the 5-hour and weekly limits.`,template:`⚡ {{ template "formatRate" .burn.costPerHour }} · {{ template "formatEta" .block.etaMinutes }} to 5h · {{ template "formatEta" .weekly.etaMinutes }} to wk`,bg:`{{ ramp .block.etaMinutes "step" -1 (tint) 0 "error" .settings.errorWithin "warning" .settings.warnWithin (tint) }}`,settings:{errorWithin:{label:`error within (min)`,domain:{min:0,max:300,step:5},default:30},warnWithin:{label:`warning within (min)`,domain:{min:0,max:300,step:5,atLeast:`errorWithin`},default:60}},when:`{{ or (gt .block.resetsAt 0) (gt .weekly.resetsAt 0) }}`},speed:{group:`activity`,description:`Token throughput for the latest exchange: output, input, and total.`,template:`⇅ out {{ template "formatSpeed" .speed.output }} · in {{ template "formatSpeed" .speed.input }} · tot {{ template "formatSpeed" .speed.total }}`,when:`{{ gt .session.tokens 0 }}`},tokenSparkline:{group:`activity`,description:`A sparkline of recent token throughput.`,template:`⚡ {{ sparkline .speed.history 24 }}`,when:`{{ ne .speed.history "" }}`},cacheTimer:{group:`activity`,description:"Minutes until the prompt cache expires, or `cold` once it has.",template:`◴ {{ if le (minutesUntilReset .cache.expiresAt) 0 }}cold{{ else }}{{ minutesUntilReset .cache.expiresAt }}m{{ end }}`,fg:`{{ readableOn (color (cascade (minutesUntilReset .cache.expiresAt) "0:error" "9:warning" "21:foreground")) (bgOf) ${ka} }}`,when:`{{ gt .cache.expiresAt 0 }}`},context:{group:`model-context`,description:`Context used, in tokens and percent remaining, heating as it fills.`,template:`◔ {{ formatInteger .context.totalTokens }} ({{ .context.contextLeft }}%)`,bg:`{{ ramp .context.contextLeft "step" 0 "error" 21 "warning" 41 (tint) }}`,when:`{{ gt .context.totalTokens 0 }}`},ceiling:{group:`model-context`,description:`The memento plugin's context ceiling for this session: − and + move it by 100K, ∞ lifts it, ↺ drops this session's own setting.`,template:`{{ if ne .memento.error "" }}⌈ ⚠ {{ .memento.error }} {{ action "ceiling.clear" "↺" }}{{ else }}⌈ {{ if .memento.off }}off{{ else }}{{ template "formatTokenCount" .memento.ceiling }} {{ action "ceiling.lower" "−" }} {{ action "ceiling.raise" "+" }} {{ action "ceiling.off" "∞" }}{{ end }}{{ if ne .memento.session "" }} {{ action "ceiling.clear" "↺" }}{{ end }}{{ end }}`,bg:`{{ if ne .memento.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .memento.ceiling 0) (ne .memento.error "") }}`},autocompact:{group:`model-context`,description:`Claude Code's auto-compact window: − and + move it by 100K, ↺ returns it to auto. Clicks type /autocompact into this session, so the controls show only inside tmux.`,template:Yk.template,bg:Yk.bg,when:Yk.when},metrics:{group:`activity`,description:`Response times, session duration, message count, and lines added/removed.`,template:`{{ if .metrics.lastResponseTime }} Δ {{ template "formatResponseTime" .metrics.lastResponseTime }}{{ end }}{{ if .metrics.responseTime }} ⧖ {{ template "formatResponseTime" .metrics.responseTime }}{{ end }}{{ if .metrics.sessionDuration }} ⧗ {{ template "formatDuration" .metrics.sessionDuration }}{{ end }}{{ if .metrics.messageCount }} ◆ {{ .metrics.messageCount }}{{ end }}{{ if .metrics.linesAdded }} + {{ .metrics.linesAdded }}{{ end }}{{ if .metrics.linesRemoved }} - {{ .metrics.linesRemoved }}{{ end }} `,when:`{{ or (gt .metrics.lastResponseTime 0.0) (gt .metrics.responseTime 0.0) (gt .metrics.sessionDuration 0.0) (gt .metrics.messageCount 0) (gt .metrics.linesAdded 0) (gt .metrics.linesRemoved 0) }}`},activity:{group:`activity`,description:`What Claude is doing: the slash command that opened the turn, the in-progress todo, and the tools in flight.`,template:`{{ if .activity.command }} ⌘ {{ .activity.command }}{{ end }}{{ if .activity.todo.total }}{{ if .activity.todo.active }} ☐ {{ .activity.todo.position }}/{{ .activity.todo.total }} {{ abbrev 32 .activity.todo.active }}{{ else }} ☑ {{ .activity.todo.completed }}/{{ .activity.todo.total }}{{ end }}{{ end }}{{ if .activity.tool.running }} ⟳ {{ template "formatToolTally" .activity.tool.running }}{{ end }}{{ if .activity.tool.done }} ✓ {{ template "formatToolTally" .activity.tool.done }}{{ end }} `,when:`{{ or (ne .activity.command "") (gt .activity.todo.total 0) (ne .activity.tool.running "") (ne .activity.tool.done "") }}`}},root:{rows:{identity:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`}]},status:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`activity`}]}}},actions:{...Bx(``).actions,...Jk.actions,copyDir:{copy:`{{ .current_dir }}`},stepTheme:{set:`theme`,from:`themes`},gitDetail:{set:`git-detail`,cycle:[`collapsed`,`expanded`]},"ceiling.raise":{ceiling:`set`,to:`+100_000`},"ceiling.lower":{ceiling:`set`,to:`-100_000`},"ceiling.off":{ceiling:`set`,to:`off`},"ceiling.clear":{ceiling:`clear`},...Yk.actions},styles:{none:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:0},vivid:{hueShift:0,chromaScale:1.35,lightnessScale:1,lightnessShift:0},muted:{hueShift:0,chromaScale:.55,lightnessScale:1,lightnessShift:0},dim:{hueShift:0,chromaScale:1,lightnessScale:.85,lightnessShift:0},bright:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:.08},inverted:{hueShift:0,chromaScale:1,lightnessScale:-1,lightnessShift:1}},presets:{default:{},compact:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`context`}]},globals:{padding:0}},verbose:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},zen:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`context`}]},globals:{endcaps:`plain`,style:`dim`}},git:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{kind:`segment`,name:`activity`}]}]}},usage:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`session`},{kind:`segment`,name:`today`},{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},dense:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`session`},{kind:`segment`,name:`activity`}]},globals:{padding:0}}},editGlobals:{endcaps:`plain`,default_separator:` | `},helpers:{gitPaint:`{{ fg (readableOn (color .color) (bgOf) ${ka}) .text }}`,gitCollapsed:`{{ template "gitBranch" . }}{{ template "gitAheadBehind" . }}{{ template "gitFlags" . }}`,gitExpanded:`(git){{ template "gitRepo" . }}{{ template "gitOperation" . }}{{ template "gitSha" . }}{{ template "gitFlags" . }} {{ template "gitBranch" . }}{{ template "gitUpstream" . }}{{ template "gitStash" . }}{{ template "gitAge" . }}`,gitBranch:`⎇ {{ template "gitPaint" (dict "color" .git.color.branch "text" .git.branch) }}`,gitRepo:`{{ if and .settings.repo (ne .git.repoName "") }} {{ .git.repoName }}{{ end }}`,gitOperation:`{{ if and .settings.operation (ne .git.operation "") }} [{{ .git.operation }}]{{ end }}`,gitSha:`{{ if and .settings.sha (ne .git.sha "") }} {{ .git.sha }}{{ end }}`,gitFlags:`{{ if and .settings.flags (or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0)) }} {{ if gt .git.staged 0 }}{{ template "gitPaint" (dict "color" .git.color.staged "text" "S") }}{{ end }}{{ if gt .git.unstaged 0 }}{{ template "gitPaint" (dict "color" .git.color.unstaged "text" "U") }}{{ end }}{{ if gt .git.untracked 0 }}{{ template "gitPaint" (dict "color" .git.color.untracked "text" "?") }}{{ end }}{{ if gt .git.conflicts 0 }}{{ template "gitPaint" (dict "color" .git.color.conflicts "text" (printf "!%v" .git.conflicts)) }}{{ end }}{{ end }}`,gitAheadBehind:`{{ if and .settings.aheadBehind (or (gt .git.ahead 0) (gt .git.behind 0)) }} {{ if gt .git.ahead 0 }}{{ template "gitPaint" (dict "color" .git.color.ahead "text" (printf "+%v" .git.ahead)) }}{{ end }}{{ if and (gt .git.ahead 0) (gt .git.behind 0) }}/{{ end }}{{ if gt .git.behind 0 }}{{ template "gitPaint" (dict "color" .git.color.behind "text" (printf "-%v" .git.behind)) }}{{ end }}{{ end }}`,gitUpstream:`{{ if and .settings.upstream (ne .git.upstream "") }} [{{ .git.upstream }}{{ template "gitAheadBehind" . }}]{{ end }}`,gitStash:`{{ if and .settings.stash (gt .git.stash 0) }} {{ template "gitPaint" (dict "color" .git.color.stash "text" (printf "(%v stashed)" .git.stash)) }}{{ end }}`,gitAge:`{{ if and .settings.age (gt .git.timeSinceCommit 0) }} ◷ {{ template "formatTimeSince" .git.timeSinceCommit }}{{ end }}`,formatCost:'{{ if lt . 0.01 }}<$0.01{{ else }}${{ printf "%.2f" . }}{{ end }}',formatTokenCount:dS(`.`),formatTokens:`{{ template "formatTokenCount" . }} tokens`,formatToolTally:`{{ $names := splitList "," . }}{{ range $i, $pair := $names }}{{ if lt $i 2 }}{{ if $i }} {{ end }}{{ $kv := splitList ":" $pair }}{{ index $kv 0 }}{{ if ne (index $kv 1) "1" }}×{{ index $kv 1 }}{{ end }}{{ end }}{{ end }}{{ if gt (len $names) 2 }} +{{ sub (len $names) 2 }}{{ end }}`,formatRate:`{{ if lt . 0 }}—/hr{{ else }}{{ template "formatCost" . }}/hr{{ end }}`,formatEta:`{{ if lt . 0 }}—{{ else }}{{ template "formatLongTimeRemaining" . }}{{ end }}`,formatSpeed:`{{ if lt . 0 }}—{{ else }}{{ template "formatTokenCount" (round .) }}/s{{ end }}`,formatTokenBreakdown:`{{ $first := true }}{{ if gt .input 0 }}{{ template "formatTokenCount" .input }} in{{ $first = false }}{{ end }}{{ if gt .output 0 }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" .output }} out{{ $first = false }}{{ end }}{{ if or (gt .cacheCreation 0) (gt .cacheRead 0) }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" (add .cacheCreation .cacheRead) }} cached{{ $first = false }}{{ end }}{{ if $first }}0 tokens{{ end }}`,budgetStatus:`{{ if or (le .budget 0) (lt .cost 0) }}{{ else }}{{ $pct := minf 100 (mulf (divf .cost .budget) 100) }}{{ $p := printf "%.0f%%" $pct }}{{ if ge $pct .warn }} !{{ $p }}{{ else }}{{ if ge $pct 50 }} +{{ $p }}{{ else }} {{ $p }}{{ end }}{{ end }}{{ end }}`,formatTimeSince:`{{ if lt . 60 }}{{ . }}s{{ else if lt . 3600 }}{{ div . 60 }}m{{ else if lt . 86400 }}{{ div . 3600 }}h{{ else if lt . 604800 }}{{ div . 86400 }}d{{ else }}{{ div . 604800 }}w{{ end }}`,formatDuration:`{{ if lt . 60 }}{{ printf "%.0f" . }}s{{ else if lt . 3600 }}{{ printf "%.0f" (divf . 60) }}m{{ else if lt . 86400 }}{{ printf "%.1f" (divf . 3600) }}h{{ else }}{{ printf "%.1f" (divf . 86400) }}d{{ end }}`,formatResponseTime:`{{ if lt . 60 }}{{ printf "%.1f" . }}s{{ else }}{{ printf "%.1f" (divf . 60) }}m{{ end }}`,formatLongTimeRemaining:`{{ if ge . 1440 }}{{ $d := div . 1440 }}{{ $h := div (mod . 1440) 60 }}{{ if gt $h 0 }}{{ $d }}d {{ $h }}h{{ else }}{{ $d }}d{{ end }}{{ else if ge . 60 }}{{ $h := div . 60 }}{{ $m := mod . 60 }}{{ if gt $m 0 }}{{ $h }}h {{ $m }}m{{ else }}{{ $h }}h{{ end }}{{ else }}{{ . }}m{{ end }}`,formatResetCountdown:`{{ template "formatLongTimeRemaining" (add 1 (minutesUntilReset .)) }}`}},rA=new Set([nA.globals.palette,...Object.values(nA.segments).map(e=>e.palette)].filter(e=>e!==void 0)),iA=Bc(JT(`<default>`,JSON.stringify(nA),rA),nA),aA=D_(iA.presets);function oA(e){return aA.includes(e)}function sA(e){if(!e)return 0;try{return o(e).mtimeMs}catch{return 0}}const cA=new 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()}}(8);function lA(e){return((...t)=>cA.run(()=>e(...t)))}const uA=lA(C),dA=lA(S),fA=lA(w);async function pA(e,t){return cA.run(async()=>{let n=null;try{n=await x(e,`r`);let{size:r,mtimeMs:i,ino:a}=await n.stat(),o=t!==void 0&&(a!==t.ino||r<t.offset),s=o||t===void 0?0:t.offset;if(s>=r)return J({buf:Buffer.alloc(0),start:s,size:r,mtimeMs:i,ino:a,reset:o});let c=Buffer.alloc(r-s),l=0;for(;l<c.length;){let{bytesRead:e}=await n.read(c,l,c.length-l,s+l);if(e===0)break;l+=e}return J({buf:l===c.length?c:c.subarray(0,l),start:s,size:r,mtimeMs:i,ino:a,reset:o})}catch(t){return t.code===`ENOENT`?Y:X(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{O(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}async function mA(e,t){return cA.run(async()=>{let n=null;try{n=await x(e,`r`);let{size:r}=await n.stat(),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let{bytesRead:e}=await n.read(a,o,a.length-o,i+o);if(e===0)break;o+=e}return J({buf:o===a.length?a:a.subarray(0,o),fromStart:i===0})}catch(t){return t.code===`ENOENT`?Y:X(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{O(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}const hA=/"(?:cache_read_input_tokens|cache_creation_input_tokens)":[1-9]/;function gA(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}async function _A(e){let t=await vA(e);return t.kind===`ok`?J(Math.floor((t.value+36e5)/1e3)):t}async function vA(e){for(let t of[65536,1048576]){let n=await mA(e,t);if(n.kind!==`ok`)return n;let r=yA(n.value.buf,n.value.fromStart);if(r!=null)return J(r);if(n.value.fromStart)return Y}return Y}function yA(e,t){let n=e.toString(`utf8`).split(`
177
- `),r=+!t;for(let e=n.length-1;e>=r;e--){let t=n[e];if(!t||!hA.test(t))continue;let r=gA(t);if(r!=null)return r}return null}function bA(e,t){return{...e,claudeConfigDir:$x(t.claudeConfigDir),env:t.mementoEnv}}const xA=c.join(`lib`,`ceiling_config.py`),SA=c.join(`skills`,`ceiling`,`bin`,`ceiling`);function CA(e,t){let n=typeof e==`object`&&e?e.plugins:void 0;if(typeof n!=`object`||!n)throw Error(`${t} has no "plugins" object`);return Object.entries(n).filter(([e])=>e.split(`@`)[0]===`memento`).flatMap(([e,n])=>{if(!Array.isArray(n))throw Error(`${t}: "${e}" is not a list of installs`);return n.map(n=>{let{scope:r,installPath:i,projectPath:a}=n??{};if(typeof r!=`string`||typeof i!=`string`)throw Error(`${t}: an install of "${e}" has no scope/path`);return typeof a==`string`?{key:e,scope:r,installPath:i,projectPath:a}:{key:e,scope:r,installPath:i}})})}function wA(e,t){let n=!0;for(let i of e){if(!r.existsSync(i))continue;let e;try{e=JSON.parse(r.readFileSync(i,`utf8`))?.enabledPlugins?.[t]}catch(e){return X(`memento lookup: ${i}: ${e.message}`)}typeof e==`boolean`&&(n=e)}return J(n)}function TA(e,t){if(!r.existsSync(e))return Y;let n;try{n=CA(JSON.parse(r.readFileSync(e,`utf8`)),e)}catch(e){return X(`memento lookup: ${e.message}`)}let i=n.find(e=>e.projectPath===t)??n.find(e=>e.scope===`user`);if(i===void 0)return Y;let a=wA([c.join(c.dirname(c.dirname(e)),`settings.json`),c.join(t,`.claude`,`settings.json`),c.join(t,`.claude`,`settings.local.json`)],i.key);if(a.kind!==`ok`)return a;if(!a.value)return Y;let o=[xA,SA].filter(e=>!r.existsSync(c.join(i.installPath,e)));return o.length===0?J(i.installPath):X(`memento at ${i.installPath} has no ${o.join(` or `)} — upgrade the plugin`)}function EA(e,t=process.env){let n=new Set([`CLAUDE_PROJECT_DIR`,`CLAUDE_CODE_SESSION_ID`,...e.env===void 0?[]:Ye]);return{...Object.fromEntries(Object.entries(t).filter(([e])=>!n.has(e))),...e.env,CLAUDE_CODE_SESSION_ID:e.sessionId,CLAUDE_PROJECT_DIR:e.projectDir||e.cwd}}function DA(e){return e.stderr.trim()||e.error||`${e.reason}${e.exitCode===null?``:` (exit ${e.exitCode})`}`}function OA(e){let t;try{t=JSON.parse(e)}catch{return X(`memento read: not JSON: ${e.trim()}`)}let{ceiling:n,session:r}=t??{},i=n===`off`||typeof n==`number`&&n>=0?n:void 0;return i!==void 0&&(r===null||typeof r==`string`)?J({ceiling:i,session:r}):X(`memento read: unexpected answer: ${e.trim()}`)}async function kA(e,t){let n=await Oe({bin:`python3`,args:[`-c`,`
175
+ Tip: every bar carries a settings menu — click it (${Gc} by\n default) for quick actions, preset switching, edit mode, and clickable\n theme/style/variation/endcaps/wrap/padding controls.\n`}async function TO(e){let t=e.includes(`--force`),n=e.filter(e=>e!==`--force`),r=n.length>0?n:[...iO],i=_O();process.platform===`darwin`?yO(i.distPath):process.stdout.write(`Skipping URL handler (cmd-click verbs are macOS-only).
176
+ `),EO(i.binPath,r,t),process.stdout.write(wO());let a=nO($D,tO(GD,await eO($D,fetch,`https://registry.npmjs.org`)));process[a.stream].write(a.text)}function EO(e,t,n,i){let a=i??aS(iS(rS(process.env,process.cwd())));r.mkdirSync(c.dirname(a),{recursive:!0});let o={};if(r.existsSync(a))try{o=JSON.parse(r.readFileSync(a,`utf-8`))}catch(e){throw Error(`Could not parse ${a}: ${e instanceof Error?e.message:String(e)}`)}let s=o.statusLine?.command,l=[e,JD(e),qD(e)],u=typeof s==`string`&&(s.startsWith(`pnpm dlx @promptctl/cc-candybar@`)||l.some(e=>s===e||s.startsWith(`${e} `)));if(s&&!u&&!n){process.stderr.write(`Skipping settings.json update: existing statusLine.command appears customized.\n Current: ${s}\n To overwrite, re-run with --force.\n`);return}o.statusLine={type:`command`,command:oO(e,t)},je(a,JSON.stringify(o,null,2)),process.stdout.write(`Updated ${a}\n`)}function DO(e,t){return e.kind===`owned`?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 OO(e){let t;try{t=r.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 i=n,a=i?.pid;if(typeof a!=`number`||!Number.isInteger(a)||a<=0)return{kind:`unreadable`,detail:`no valid pid (got ${JSON.stringify(a)})`};let o=i?.startTime;return o!=null&&typeof o!=`string`?{kind:`unreadable`,detail:`invalid startTime (got ${JSON.stringify(o)})`}:{kind:`owned`,pid:a,startTime:o??null}}function kO(e,n){let i=`${e}.${t.pid}.tmp`;try{return r.writeFileSync(i,JSON.stringify(n),{mode:384}),r.renameSync(i,e),null}catch(e){let t=e.message;try{r.unlinkSync(i)}catch(e){if(e.code!==`ENOENT`)return`${t}; also failed to remove temp ${i}: ${e.message}`}return t}}function AO(e,t){let n=OO(e);if(n.kind===`owned`&&n.pid===t)try{r.unlinkSync(e)}catch{}}function jO(e){try{let t=r.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 MO(e,t,n,r){let i=NO(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 NO(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 PO(e){let t=!1;function n(){let n=MO(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=setInterval(()=>{n().kind===`displaced`&&clearInterval(r)},t);return r.unref(),{disarm:()=>clearInterval(r)}}return{check:n,arm:r}}function FO(e,t=ke){let n=t({bin:`ps`,args:[`-o`,`lstart=`,`-p`,String(e)],category:`process-fingerprint`,timeoutMs:2e3,env:{...process.env,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 IO(e,t,n){if(t===null)return n.pidAlive(e);let r=n.readStartTime(e);switch(r.kind){case`start`:return r.token===t;case`unavailable`:return n.pidAlive(e)}}function LO(e,t=FO){let n=t(e);return n.kind===`start`?n.token:null}const RO=`CC_CANDYBAR_PARENT_PID`;function zO(e){let t=e[RO];if(t===void 0)return{kind:`outlives-nobody`};let n=Number.parseInt(t,10);if(!Number.isInteger(n)||n<=0)throw Error(`${RO} must be a positive integer pid, got ${JSON.stringify(t)}`);return{kind:`anchored`,pid:n}}function BO(e){if(e.anchor.kind===`outlives-nobody`)return{disarm:()=>{}};let{pid:t}=e.anchor,n=setInterval(()=>{e.isAlive(t)||e.onOrphaned(`spawner pid ${t} gone`)},e.intervalMs??250);return n.unref(),{disarm:()=>clearInterval(n)}}function VO(e){try{return t.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function HO(){let e=Number(process.env.CC_CANDYBAR_DAEMON_CEILING??``);return Number.isInteger(e)&&e>0?e:16}function UO(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 WO(e){try{return r.readdirSync(e).filter(e=>e.endsWith(`.json`)).map(t=>c.join(e,t))}catch{return[]}}function GO(e){let t;try{t=r.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}}function KO(e,t,n){let r=0;for(let i of e)t(i.identity.pid,i.identity.startTime)?r++:n(i.path);return r}function qO(e){if(!e.isolated)return{decision:UO(!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=UO(!0,KO(t,e.isSameLiveProcess,e.removeFile),e.ceiling);if(!n.allow)return{decision:n,registryPath:null};let r=c.join(e.registryDir,`pid-${e.pid}.json`);return e.writeEntry(r,{pid:e.pid,startTime:e.startTime}),{decision:n,registryPath:r}}function JO(e,t,n,r){let i=n(e);if(i!==null&&i.pid===t)try{r(e)}catch{}}function YO(e,t={}){return{isolated:!!process.env.CC_CANDYBAR_SOCKET,registryDir:Ue(),ceiling:HO(),pid:process.pid,startTime:e,isSameLiveProcess:(e,t)=>IO(e,t,{readStartTime:FO,pidAlive:VO}),listFiles:WO,readEntry:GO,removeFile:e=>{try{r.unlinkSync(e)}catch{}},writeEntry:(e,t)=>{let n=`${e}.${t.pid}.tmp`;try{r.writeFileSync(n,JSON.stringify(t),{mode:384}),r.renameSync(n,e)}catch(e){try{r.unlinkSync(n)}catch(e){e.code}throw e}},ensureDirSafe:process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR?Le:e=>{Le(c.dirname(e)),Le(e)},...t}}function XO(e){return e<32||e===127||e>=128&&e<=159}function ZO(e){let t=``;for(let n of e)t+=XO(n.codePointAt(0)??0)?` `:n;return t.replace(/\s+/g,` `).trim()}function QO(e,t){let n=ZO(e),r=``,i=0;for(let e of n){if(i===t)return r.replace(/.$/u,`…`);r+=e,i++}return r}const $O=`\x1B[38;2;255;255;255m`,ek=`\x1B[48;2;200;40;40m`;function tk(e){let t=/;2;(\d+);(\d+);(\d+)m$/.exec(e);if(t===null)throw Error(`diagnostic-style: not a 24-bit SGR: ${e}`);return`#`+t.slice(1,4).map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}const nk={fg:tk($O),bg:tk(ek)},rk={fg:tk(`\x1B[38;2;0;0;0m`),bg:tk(`\x1B[48;2;220;160;40m`)},ik={unicode:zi,ascii:{glyph:`>`,divider:`|`,lead:`<`,tail:`>`}},ak={unicode:{},ascii:{left:`(`,right:`)`}};function ok(e,t,n){switch(e){case`capsule`:return new Gi(ak[t]);case`plain`:return new Ki(n===void 0?{}:{separator:n});case`powerline`:return new Hi(ik[t]);default:return e}}const sk=new Map;function ck(e){let t=JSON.stringify([e.endcaps,e.charset,e.separator??null]),n=sk.get(t);if(n!==void 0)return n;let r=ok(e.endcaps,e.charset,e.separator),i=e=>new H(`x`,{end:``,overflow:`ignore`,style:new B({bgcolor:e})}),a=e=>new H(Yi(new U(e,r),{colorSystem:null}).replace(/\n$/,``)).cellLength,o=a([i(`#101010`)]),s={chrome:o-1,seam:a([i(`#101010`),i(`#202020`)])-o-1};return sk.set(t,s),s}function lk(e){return ck(e).chrome}function uk(e){return ck(e).seam}function dk(e,t){if(e.length===0)return``;let n=ok(t.endcaps,t.charset,t.separator),r=t.colorCompatibility,i=t.wrap&&Number.isFinite(t.width)?Yi(new ta([...e],{joiner:n}),{width:t.width,colorSystem:r}):Yi(new U([...e],n),{colorSystem:r});if(!i.endsWith(`
177
+ `))throw Error(`renderStripCells: rich-js strip output did not end its last line`);return i.slice(0,-1)}function fk(e){return Math.min(20,e??20)}const pk={heading:`ERROR`,glyph:`⚠`,colors:nk},mk={heading:`WARNING`,glyph:`⚠`,colors:rk},hk={heading:`UPDATE`,glyph:`⬆`,colors:rk};function gk(e,t){return{text:ZO(e),link:t}}function _k(e,t,n){let[r,...i]=[vk(e,pk,yD),t,vk(n,mk,bD)].flat();return r===void 0?null:{channels:[r,...i]}}function vk(e,t,n){let r=zD([{verb:n,args:[e]}]),[i,...a]=e.split(/\r\n|\r|\n/).map(e=>gk(e,r)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:t,message:e,lines:[i,...a]}]}function yk(e){return e.channels.map(e=>`${e.severity.heading}\n${e.message}\n`).join(`
178
+ `)}function bk(e,t,n,r){if(t===null)return e;let i=xk(r),a=t.channels.flatMap(e=>Sk(e,i)),o=n.failedConfigFile!==null||a.length>r.rowCap,s=a.slice(0,r.rowCap-Number(o)),c=o?[Ck(t,n,a.length-s.length,i)]:[],l=[...s,...c].join(`
179
+ `);return e?`${l}\n${e}`:l}function xk(e){return{endcaps:`plain`,separator:``,width:e.width,wrap:!0,padding:0,charset:`unicode`,colorCompatibility:e.colorCompatibility}}function Sk(e,t){let n=new B({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=Bt(Math.max(2,t.width-1)),i=(e,t)=>new H(`${e} `,{style:t,end:``,overflow:`ignore`});return e.lines.flatMap((a,o)=>dk([i(o===0?e.severity.glyph:` `,n.withLink(a[0].link)),...a.flatMap(e=>{let t=n.withLink(e.link);return e.text.split(` `).flatMap(e=>Ut(e,r)).map(e=>i(e,t))})],t).split(`
180
+ `))}function Ck(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:a,failedConfigFile:o}=t,s=new B({bgcolor:i.bg,color:i.fg}),c=(e,t)=>new H(e,{style:t,end:``,overflow:`ignore`}),l=n>0?[c(`${n} more rows · `,s),a.kind===`file`?c(`open full text`,s.withLink(D(a.path).href)):c(`full text unavailable: ${ZO(a.reason)}`,s)]:[],u=o===null?[]:[c(`${l.length>0?` · `:``}open `,s),c(ZO(o),s.withLink(D(o).href))],d=[c(`↳ `,s),...l,...u.slice(0,-1)],f=d.reduce((e,t)=>e+t.cellLength,0),p=u.slice(-1).map(e=>e.truncate(Math.max(1,r.width-f),{mode:`middle`})),m=H.fromFragments([...d,...p]).truncate(r.width);return m.overflow=`ignore`,dk([m],r)}const wk=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Tk(e,t){return t.isSymbolicLink()?Buffer.from(r.readlinkSync(e)):r.readFileSync(e)}function Ek(e,t){return r.readdirSync(t).filter(wk).sort().flatMap(n=>{let i=c.join(t,n),a=r.lstatSync(i,{throwIfNoEntry:!1});return a===void 0?[]:a.isDirectory()?Ek(e,i):[[c.relative(e,i).split(c.sep).join(`/`),Tk(i,a)]]})}function Dk(e){let t=ie.createHash(`sha256`);for(let[n,r]of Ek(e,e))t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}const Ok=e=>e.slice(0,7);function kk(e){return c.dirname(c.dirname(e))}function Ak(){return{version:GD,digest:`dbcc521583d1e8f53efed1ba6791ddcffb0ef272bed3cb4933a16b100b09b9fd`}}function jk(e){let t=JSON.parse(r.readFileSync(c.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${c.join(e,`package.json`)} has no version string`);return n}function Mk(e,t){try{let n=kk(E(e)),i=c.join(n,`src`);if(!r.existsSync(i))return{kind:`not-source-checkout`};let a=t(),o=Dk(i);return o===a.digest?{kind:`current`,root:n,stamp:a}:{kind:`stale`,root:n,source:{version:jk(n),digest:o},running:a}}catch(e){return{kind:`unchecked`,reason:e.message}}}var $=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};function Nk(e){return e.op===`remove`?`remove:${e.target}`:`insert:${e.segment}:${e.anchor}:${e.relation}`}function Pk(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 Fk(e,t,n){let r=As(e,new Set(n.map(ks).filter(e=>e.includes(t)).flat()));return r===e?{seg:e}:{seg:e,id:r}}const Ik=/^-?\d+$/;function Lk(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 Rk(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!Ik.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 zk(e,t,n){return r=>r?Ik.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 Bk(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=>!Ik.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 Vk(e){return e===`config`?`set-config`:`set-state`}function Hk(e,t,n){return t.kind===`int`?Rk(`menu page "${e}"`):t.kind===`range`?zk(t.min,t.max,`${n} stepper "${e}"`):Lk(t.allowed,`${n} "${e}"`,Vk(n))}function Uk(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:Bk(e,n,t)}))}function Wk(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 Uk(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,Hk(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 Gk(e,t,n){let r=[],i=0,a=new WeakMap;return{register(n,a){let o={key:n,allowed:a};Wk(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=Wk(e,r,n(o),t);return a.set(o,{epoch:i,gate:c}),c}}}const Kk=Gk({},`config`,$k);function qk(e,t){return Kk.register(e,t)}function Jk(e){return Kk.gateFor(e)}function Yk(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:sx(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:[Nk({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[Nk({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:sx(e.insertSegmentFrom,t).members.map(t=>Nk({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function Xk(e,t){let n=Ml(e).get(t);return n===void 0?null:String(n)}function Zk(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?_x(n.persist):null;e?.scope===`preset-root`&&t.add(hx(e.preset))}return[...t].map(e=>({key:e,spec:{kind:`allow-list`,allowed:[]}}))}function Qk(e){let t=new Map([...ax(e),...tw(e)]);return[...Zk(e),...Object.values(e.actions).flatMap(e=>Yk(e,t))]}function $k(e){return Uk(Qk(e),`config`)}const eA=nS(`commands.`),tA=hS(`autocompact.`,e=>`{{ template "formatTokenCount" ${e} }}`),nA=`trimPrefix "/" (trimPrefix .project_dir .current_dir)`,rA=`{{ \$dir := .current_dir }}{{ if and (ne .home "") (or (eq .home .current_dir) (hasPrefix (printf "%s/" .home) .current_dir)) }}{{ \$dir = printf "~%s" (trimPrefix .home .current_dir) }}{{ else }}{{ if or (eq .project_dir .current_dir) (hasPrefix (printf "%s/" .project_dir) .current_dir) }}{{ $dir = ternary (${nA}) (basename .project_dir) (ne (${nA}) "") }}{{ end }}{{ end }}{{ action "copyDir" (abbreviatePath \$dir) }}`,iA=`{{ ${Ax} }}`,aA={min:0,max:100,step:5},oA={warnAt:{label:`warning at %`,domain:aA,default:50},errorAt:{label:`error at %`,domain:{...aA,atLeast:`warnAt`},default:80}};function sA(e){return{budget:{label:`budget $`,domain:{min:0,max:1e4,step:5},default:e},warnAt:{label:`warning at %`,domain:aA,default:80}}}const cA={globals:{palette:`tokyo-night`},variables:{...eA.variables,...Nb,current_dir:{kind:`input`,path:`workspace.current_dir`,default:`?`},"model.display_name":{kind:`input`,path:`model.display_name`,default:``},version:{kind:`input`,path:`version`,default:``},home:{kind:`input`,path:`home`,default:``},"tmux.session":{kind:`input`,path:`tmux.session`,default:``},"host.name":{kind:`input`,path:`host.name`,default:``},"host.user":{kind:`input`,path:`host.user`,default:``},"host.ssh":{kind:`input`,path:`host.ssh`,type:`boolean`,default:!1},"git.repoName":{kind:`input`,path:`git.repoName`,default:``},"git.branch":{kind:`input`,path:`git.branch`,default:``},"git.sha":{kind:`input`,path:`git.sha`,default:``},"git.ahead":{kind:`input`,path:`git.ahead`,type:`number`,default:0},"git.behind":{kind:`input`,path:`git.behind`,type:`number`,default:0},"git.staged":{kind:`input`,path:`git.staged`,type:`number`,default:0},"git.unstaged":{kind:`input`,path:`git.unstaged`,type:`number`,default:0},"git.untracked":{kind:`input`,path:`git.untracked`,type:`number`,default:0},"git.conflicts":{kind:`input`,path:`git.conflicts`,type:`number`,default:0},"git.upstream":{kind:`input`,path:`git.upstream`,default:``},"git.stash":{kind:`input`,path:`git.stash`,type:`number`,default:0},"git.status":{kind:`input`,path:`git.status`,default:`clean`},"git.operation":{kind:`input`,path:`git.operation`,default:``},"git.timeSinceCommit":{kind:`input`,path:`git.timeSinceCommit`,type:`number`,default:0},"git.color.branch":{kind:`literal`,value:`primary`},"git.color.staged":{kind:`literal`,value:`success`},"git.color.unstaged":{kind:`literal`,value:`warning`},"git.color.untracked":{kind:`literal`,value:`accent`},"git.color.conflicts":{kind:`literal`,value:`error`},"git.color.ahead":{kind:`literal`,value:`success`},"git.color.behind":{kind:`literal`,value:`warning`},"git.color.stash":{kind:`literal`,value:`accent`},"git.detail":{kind:`state`,key:`git-detail`,default:`collapsed`},"git.prNumber":{kind:`input`,path:`git.prNumber`,type:`number`,default:0},"git.prState":{kind:`input`,path:`git.prState`,default:``},"git.prUrl":{kind:`input`,path:`git.prUrl`,default:``},"git.prError":{kind:`input`,path:`git.prError`,default:``},"cache.expiresAt":{kind:`input`,path:`cache.expiresAt`,type:`number`,default:0},"session.cost":{kind:`input`,path:`session.cost`,type:`number`,default:0},"session.tokens":{kind:`input`,path:`session.tokens`,type:`number`,default:0},"today.cost":{kind:`input`,path:`today.cost`,type:`number`,default:0},"today.tokens":{kind:`input`,path:`today.tokens`,type:`number`,default:0},"block.nativeUtilization":{kind:`input`,path:`block.nativeUtilization`,type:`number`,default:0},"block.resetsAt":{kind:`input`,path:`block.resetsAt`,type:`number`,default:0},"weekly.percentage":{kind:`input`,path:`weekly.percentage`,type:`number`,default:0},"weekly.resetsAt":{kind:`input`,path:`weekly.resetsAt`,type:`number`,default:0},"burn.costPerHour":{kind:`input`,path:`burn.costPerHour`,type:`number`,default:-1},"block.etaMinutes":{kind:`input`,path:`block.etaMinutes`,type:`number`,default:-1},"weekly.etaMinutes":{kind:`input`,path:`weekly.etaMinutes`,type:`number`,default:-1},"speed.input":{kind:`input`,path:`speed.input`,type:`number`,default:-1},"speed.output":{kind:`input`,path:`speed.output`,type:`number`,default:-1},"speed.total":{kind:`input`,path:`speed.total`,type:`number`,default:-1},"speed.history":{kind:`input`,path:`speed.history`,type:`string`,default:``},"context.totalTokens":{kind:`input`,path:`context.totalTokens`,type:`number`,default:0},"context.contextLeft":{kind:`input`,path:`context.contextLeft`,type:`number`,default:100},"memento.ceiling":{kind:`input`,path:`memento.ceiling`,type:`number`,default:-1},"memento.off":{kind:`input`,path:`memento.off`,type:`boolean`,default:!1},"memento.session":{kind:`input`,path:`memento.session`,default:``},"memento.error":{kind:`input`,path:`memento.error`,default:``},"metrics.lastResponseTime":{kind:`input`,path:`metrics.lastResponseTime`,type:`number`,default:0},"metrics.responseTime":{kind:`input`,path:`metrics.responseTime`,type:`number`,default:0},"metrics.sessionDuration":{kind:`input`,path:`metrics.sessionDuration`,type:`number`,default:0},"metrics.messageCount":{kind:`input`,path:`metrics.messageCount`,type:`number`,default:0},"metrics.linesAdded":{kind:`input`,path:`metrics.linesAdded`,type:`number`,default:0},"metrics.linesRemoved":{kind:`input`,path:`metrics.linesRemoved`,type:`number`,default:0},"activity.command":{kind:`input`,path:`activity.command`,type:`string`,default:``},"activity.todo.total":{kind:`input`,path:`activity.todo.total`,type:`number`,default:0},"activity.todo.completed":{kind:`input`,path:`activity.todo.completed`,type:`number`,default:0},"activity.todo.position":{kind:`input`,path:`activity.todo.position`,type:`number`,default:0},"activity.todo.active":{kind:`input`,path:`activity.todo.active`,type:`string`,default:``},"activity.tool.running":{kind:`input`,path:`activity.tool.running`,type:`string`,default:``},"activity.tool.done":{kind:`input`,path:`activity.tool.done`,type:`string`,default:``}},segments:{directory:{group:`location`,description:"The current directory, shortened fish-style — `~` under home, project-relative inside the project. Click to copy the full path.",template:rA},model:{group:`model-context`,description:`The active model's display name.`,template:`✱ {{ formatModelName .model.display_name }}`,when:`{{ ne .model.display_name "" }}`},sessionId:{group:`session-tools`,description:`The session id, truncated to 8 characters.`,template:`⌗{{ trunc 8 .session.id }}`,when:`{{ ne .session.id "" }}`},version:{group:`model-context`,description:`The Claude Code version reported in the hook payload.`,template:`◈ v{{ .version }}`,when:`{{ ne .version "" }}`},tmux:{group:`location`,description:`The tmux session name; hidden when not inside tmux.`,template:`tmux:{{ .tmux.session | default "none" }}`,when:`{{ ne .tmux.session "" }}`},host:{group:`location`,description:`user@host on a warning background, shown only over SSH.`,template:`⇄ {{ .host.user | default "?" }}@{{ .host.name | default "?" }}`,bg:`warning`,when:`{{ .host.ssh }}`},gitaculous:{group:`git`,description:`The git state: a summary (branch, ahead/behind, S/U/? flags) that the arrow at its right edge expands to every fact — repo, in-progress operation, sha, upstream ±, stash count, time since the last commit.`,template:`{{ if eq .git.detail "expanded" }}{{ template "gitExpanded" . }}{{ else }}{{ template "gitCollapsed" . }}{{ end }} {{ action "gitDetail" "▸" "◂" }}`,fg:iA,when:`{{ ne .git.branch "" }}`,settings:{aheadBehind:{label:`ahead/behind`,domain:`bool`,default:!0},flags:{label:`dirty flags`,domain:`bool`,default:!0},operation:{label:`operation`,domain:`bool`,default:!0},repo:{label:`repo name`,domain:`bool`,default:!0},sha:{label:`commit hash`,domain:`bool`,default:!0},stash:{label:`stash`,domain:`bool`,default:!0},upstream:{label:`upstream`,domain:`bool`,default:!0},age:{label:`time since commit`,domain:`bool`,default:!0}}},gitPr:{group:`git`,description:"The pull request open for this branch, as a link; `⚠ PR` when the forge lookup failed.",template:`{{ if ne .git.prUrl "" }}{{ link .git.prUrl (printf "⇆ #%v" .git.prNumber) }}{{ else }}⚠ PR{{ end }}`,when:`{{ or (ne .git.prUrl "") (ne .git.prError "") }}`},toolbar:{group:`session-tools`,description:`Quick actions: copy the session id, and open the project, transcript or repo.`,template:Gx(``).template},commands:{group:`session-tools`,description:`Type /compact, /model or /clear into this session; /clear asks for a second click. Hidden when not inside tmux.`,template:eA.template,when:eA.when},themeSwitcher:{group:`session-tools`,description:"`◀ <theme> ▶`: the theme the bar is wearing; ◀ and ▶ switch this session to the previous or next theme, wrapping at the ends.",template:`{{ carousel "stepTheme" 0 }}`},session:{group:`cost-limits`,description:`This session's cost and token total, with a budget warning once a budget is configured.`,template:`§ {{ template "formatCost" .session.cost }} ({{ template "formatTokens" .session.tokens }}){{ template "budgetStatus" (dict "cost" .session.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:sA(0)},today:{group:`cost-limits`,description:`Today's cost and tokens across every session, with a budget warning once a budget is configured.`,template:`☉ {{ template "formatCost" .today.cost }} ({{ template "formatTokens" .today.tokens }}){{ template "budgetStatus" (dict "cost" .today.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:sA(50)},block:{group:`cost-limits`,description:`The 5-hour rate-limit block: percent used and time to reset, heating to warning then error.`,template:`◱ {{ round .block.nativeUtilization }}% ({{ template "formatResetCountdown" .block.resetsAt }})`,bg:`{{ ramp (round .block.nativeUtilization) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:oA,when:`{{ gt .block.resetsAt 0 }}`},weekly:{group:`cost-limits`,description:`The weekly rate-limit quota: percent used and time to reset, heating to warning then error.`,template:`◑ {{ round .weekly.percentage }}% ({{ template "formatResetCountdown" .weekly.resetsAt }})`,bg:`{{ ramp (round .weekly.percentage) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:oA,when:`{{ gt .weekly.resetsAt 0 }}`},burnrate:{group:`cost-limits`,description:`Spend per hour, with the projected time to the 5-hour and weekly limits.`,template:`⚡ {{ template "formatRate" .burn.costPerHour }} · {{ template "formatEta" .block.etaMinutes }} to 5h · {{ template "formatEta" .weekly.etaMinutes }} to wk`,bg:`{{ ramp .block.etaMinutes "step" -1 (tint) 0 "error" .settings.errorWithin "warning" .settings.warnWithin (tint) }}`,settings:{errorWithin:{label:`error within (min)`,domain:{min:0,max:300,step:5},default:30},warnWithin:{label:`warning within (min)`,domain:{min:0,max:300,step:5,atLeast:`errorWithin`},default:60}},when:`{{ or (gt .block.resetsAt 0) (gt .weekly.resetsAt 0) }}`},speed:{group:`activity`,description:`Token throughput for the latest exchange: output, input, and total.`,template:`⇅ out {{ template "formatSpeed" .speed.output }} · in {{ template "formatSpeed" .speed.input }} · tot {{ template "formatSpeed" .speed.total }}`,when:`{{ gt .session.tokens 0 }}`},tokenSparkline:{group:`activity`,description:`A sparkline of recent token throughput.`,template:`⚡ {{ sparkline .speed.history 24 }}`,when:`{{ ne .speed.history "" }}`},cacheTimer:{group:`activity`,description:"Minutes until the prompt cache expires, or `cold` once it has.",template:`◴ {{ if le (minutesUntilReset .cache.expiresAt) 0 }}cold{{ else }}{{ minutesUntilReset .cache.expiresAt }}m{{ end }}`,fg:`{{ readableOn (color (cascade (minutesUntilReset .cache.expiresAt) "0:error" "9:warning" "21:foreground")) (bgOf) ${ka} }}`,when:`{{ gt .cache.expiresAt 0 }}`},context:{group:`model-context`,description:`Context used, in tokens and percent remaining, heating as it fills.`,template:`◔ {{ formatInteger .context.totalTokens }} ({{ .context.contextLeft }}%)`,bg:`{{ ramp .context.contextLeft "step" 0 "error" 21 "warning" 41 (tint) }}`,when:`{{ gt .context.totalTokens 0 }}`},ceiling:{group:`model-context`,description:`The memento plugin's context ceiling for this session: − and + move it by 100K, ∞ lifts it, ↺ drops this session's own setting.`,template:`{{ if ne .memento.error "" }}⌈ ⚠ {{ .memento.error }} {{ action "ceiling.clear" "↺" }}{{ else }}⌈ {{ if .memento.off }}off{{ else }}{{ template "formatTokenCount" .memento.ceiling }} {{ action "ceiling.lower" "−" }} {{ action "ceiling.raise" "+" }} {{ action "ceiling.off" "∞" }}{{ end }}{{ if ne .memento.session "" }} {{ action "ceiling.clear" "↺" }}{{ end }}{{ end }}`,bg:`{{ if ne .memento.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .memento.ceiling 0) (ne .memento.error "") }}`},autocompact:{group:`model-context`,description:`Claude Code's auto-compact window: − and + move it by 100K, ↺ returns it to auto. Clicks type /autocompact into this session, so the controls show only inside tmux.`,template:tA.template,bg:tA.bg,when:tA.when},metrics:{group:`activity`,description:`Response times, session duration, message count, and lines added/removed.`,template:`{{ if .metrics.lastResponseTime }} Δ {{ template "formatResponseTime" .metrics.lastResponseTime }}{{ end }}{{ if .metrics.responseTime }} ⧖ {{ template "formatResponseTime" .metrics.responseTime }}{{ end }}{{ if .metrics.sessionDuration }} ⧗ {{ template "formatDuration" .metrics.sessionDuration }}{{ end }}{{ if .metrics.messageCount }} ◆ {{ .metrics.messageCount }}{{ end }}{{ if .metrics.linesAdded }} + {{ .metrics.linesAdded }}{{ end }}{{ if .metrics.linesRemoved }} - {{ .metrics.linesRemoved }}{{ end }} `,when:`{{ or (gt .metrics.lastResponseTime 0.0) (gt .metrics.responseTime 0.0) (gt .metrics.sessionDuration 0.0) (gt .metrics.messageCount 0) (gt .metrics.linesAdded 0) (gt .metrics.linesRemoved 0) }}`},activity:{group:`activity`,description:`What Claude is doing: the slash command that opened the turn, the in-progress todo, and the tools in flight.`,template:`{{ if .activity.command }} ⌘ {{ .activity.command }}{{ end }}{{ if .activity.todo.total }}{{ if .activity.todo.active }} ☐ {{ .activity.todo.position }}/{{ .activity.todo.total }} {{ abbrev 32 .activity.todo.active }}{{ else }} ☑ {{ .activity.todo.completed }}/{{ .activity.todo.total }}{{ end }}{{ end }}{{ if .activity.tool.running }} ⟳ {{ template "formatToolTally" .activity.tool.running }}{{ end }}{{ if .activity.tool.done }} ✓ {{ template "formatToolTally" .activity.tool.done }}{{ end }} `,when:`{{ or (ne .activity.command "") (gt .activity.todo.total 0) (ne .activity.tool.running "") (ne .activity.tool.done "") }}`}},root:{rows:{identity:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`}]},status:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`activity`}]}}},actions:{...Gx(``).actions,...eA.actions,copyDir:{copy:`{{ .current_dir }}`},stepTheme:{set:`theme`,from:`themes`},gitDetail:{set:`git-detail`,cycle:[`collapsed`,`expanded`]},"ceiling.raise":{ceiling:`set`,to:`+100_000`},"ceiling.lower":{ceiling:`set`,to:`-100_000`},"ceiling.off":{ceiling:`set`,to:`off`},"ceiling.clear":{ceiling:`clear`},...tA.actions},styles:{none:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:0},vivid:{hueShift:0,chromaScale:1.35,lightnessScale:1,lightnessShift:0},muted:{hueShift:0,chromaScale:.55,lightnessScale:1,lightnessShift:0},dim:{hueShift:0,chromaScale:1,lightnessScale:.85,lightnessShift:0},bright:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:.08},inverted:{hueShift:0,chromaScale:1,lightnessScale:-1,lightnessShift:1}},presets:{default:{},compact:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`context`}]},globals:{padding:0}},verbose:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},zen:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`context`}]},globals:{endcaps:`plain`,style:`dim`}},git:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{kind:`segment`,name:`activity`}]}]}},usage:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`session`},{kind:`segment`,name:`today`},{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},dense:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`session`},{kind:`segment`,name:`activity`}]},globals:{padding:0}}},editGlobals:{endcaps:`plain`,default_separator:` | `},helpers:{gitPaint:`{{ fg (readableOn (color .color) (bgOf) ${ka}) .text }}`,gitCollapsed:`{{ template "gitBranch" . }}{{ template "gitAheadBehind" . }}{{ template "gitFlags" . }}`,gitExpanded:`(git){{ template "gitRepo" . }}{{ template "gitOperation" . }}{{ template "gitSha" . }}{{ template "gitFlags" . }} {{ template "gitBranch" . }}{{ template "gitUpstream" . }}{{ template "gitStash" . }}{{ template "gitAge" . }}`,gitBranch:`⎇ {{ template "gitPaint" (dict "color" .git.color.branch "text" .git.branch) }}`,gitRepo:`{{ if and .settings.repo (ne .git.repoName "") }} {{ .git.repoName }}{{ end }}`,gitOperation:`{{ if and .settings.operation (ne .git.operation "") }} [{{ .git.operation }}]{{ end }}`,gitSha:`{{ if and .settings.sha (ne .git.sha "") }} {{ .git.sha }}{{ end }}`,gitFlags:`{{ if and .settings.flags (or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0)) }} {{ if gt .git.staged 0 }}{{ template "gitPaint" (dict "color" .git.color.staged "text" "S") }}{{ end }}{{ if gt .git.unstaged 0 }}{{ template "gitPaint" (dict "color" .git.color.unstaged "text" "U") }}{{ end }}{{ if gt .git.untracked 0 }}{{ template "gitPaint" (dict "color" .git.color.untracked "text" "?") }}{{ end }}{{ if gt .git.conflicts 0 }}{{ template "gitPaint" (dict "color" .git.color.conflicts "text" (printf "!%v" .git.conflicts)) }}{{ end }}{{ end }}`,gitAheadBehind:`{{ if and .settings.aheadBehind (or (gt .git.ahead 0) (gt .git.behind 0)) }} {{ if gt .git.ahead 0 }}{{ template "gitPaint" (dict "color" .git.color.ahead "text" (printf "+%v" .git.ahead)) }}{{ end }}{{ if and (gt .git.ahead 0) (gt .git.behind 0) }}/{{ end }}{{ if gt .git.behind 0 }}{{ template "gitPaint" (dict "color" .git.color.behind "text" (printf "-%v" .git.behind)) }}{{ end }}{{ end }}`,gitUpstream:`{{ if and .settings.upstream (ne .git.upstream "") }} [{{ .git.upstream }}{{ template "gitAheadBehind" . }}]{{ end }}`,gitStash:`{{ if and .settings.stash (gt .git.stash 0) }} {{ template "gitPaint" (dict "color" .git.color.stash "text" (printf "(%v stashed)" .git.stash)) }}{{ end }}`,gitAge:`{{ if and .settings.age (gt .git.timeSinceCommit 0) }} ◷ {{ template "formatTimeSince" .git.timeSinceCommit }}{{ end }}`,formatCost:'{{ if lt . 0.01 }}<$0.01{{ else }}${{ printf "%.2f" . }}{{ end }}',formatTokenCount:gS(`.`),formatTokens:`{{ template "formatTokenCount" . }} tokens`,formatToolTally:`{{ $names := splitList "," . }}{{ range $i, $pair := $names }}{{ if lt $i 2 }}{{ if $i }} {{ end }}{{ $kv := splitList ":" $pair }}{{ index $kv 0 }}{{ if ne (index $kv 1) "1" }}×{{ index $kv 1 }}{{ end }}{{ end }}{{ end }}{{ if gt (len $names) 2 }} +{{ sub (len $names) 2 }}{{ end }}`,formatRate:`{{ if lt . 0 }}—/hr{{ else }}{{ template "formatCost" . }}/hr{{ end }}`,formatEta:`{{ if lt . 0 }}—{{ else }}{{ template "formatLongTimeRemaining" . }}{{ end }}`,formatSpeed:`{{ if lt . 0 }}—{{ else }}{{ template "formatTokenCount" (round .) }}/s{{ end }}`,formatTokenBreakdown:`{{ $first := true }}{{ if gt .input 0 }}{{ template "formatTokenCount" .input }} in{{ $first = false }}{{ end }}{{ if gt .output 0 }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" .output }} out{{ $first = false }}{{ end }}{{ if or (gt .cacheCreation 0) (gt .cacheRead 0) }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" (add .cacheCreation .cacheRead) }} cached{{ $first = false }}{{ end }}{{ if $first }}0 tokens{{ end }}`,budgetStatus:`{{ if or (le .budget 0) (lt .cost 0) }}{{ else }}{{ $pct := minf 100 (mulf (divf .cost .budget) 100) }}{{ $p := printf "%.0f%%" $pct }}{{ if ge $pct .warn }} !{{ $p }}{{ else }}{{ if ge $pct 50 }} +{{ $p }}{{ else }} {{ $p }}{{ end }}{{ end }}{{ end }}`,formatTimeSince:`{{ if lt . 60 }}{{ . }}s{{ else if lt . 3600 }}{{ div . 60 }}m{{ else if lt . 86400 }}{{ div . 3600 }}h{{ else if lt . 604800 }}{{ div . 86400 }}d{{ else }}{{ div . 604800 }}w{{ end }}`,formatDuration:`{{ if lt . 60 }}{{ printf "%.0f" . }}s{{ else if lt . 3600 }}{{ printf "%.0f" (divf . 60) }}m{{ else if lt . 86400 }}{{ printf "%.1f" (divf . 3600) }}h{{ else }}{{ printf "%.1f" (divf . 86400) }}d{{ end }}`,formatResponseTime:`{{ if lt . 60 }}{{ printf "%.1f" . }}s{{ else }}{{ printf "%.1f" (divf . 60) }}m{{ end }}`,formatLongTimeRemaining:`{{ if ge . 1440 }}{{ $d := div . 1440 }}{{ $h := div (mod . 1440) 60 }}{{ if gt $h 0 }}{{ $d }}d {{ $h }}h{{ else }}{{ $d }}d{{ end }}{{ else if ge . 60 }}{{ $h := div . 60 }}{{ $m := mod . 60 }}{{ if gt $m 0 }}{{ $h }}h {{ $m }}m{{ else }}{{ $h }}h{{ end }}{{ else }}{{ . }}m{{ end }}`,formatResetCountdown:`{{ template "formatLongTimeRemaining" (add 1 (minutesUntilReset .)) }}`}},lA=new Set([cA.globals.palette,...Object.values(cA.segments).map(e=>e.palette)].filter(e=>e!==void 0)),uA=Bc(eE(`<default>`,JSON.stringify(cA),lA),cA),dA=D_(uA.presets);function fA(e){return dA.includes(e)}function pA(e){if(!e)return 0;try{return o(e).mtimeMs}catch{return 0}}const mA=new 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()}}(8);function hA(e){return((...t)=>mA.run(()=>e(...t)))}const gA=hA(C),_A=hA(S),vA=hA(w);async function yA(e,t){return mA.run(async()=>{let n=null;try{n=await x(e,`r`);let{size:r,mtimeMs:i,ino:a}=await n.stat(),o=t!==void 0&&(a!==t.ino||r<t.offset),s=o||t===void 0?0:t.offset;if(s>=r)return J({buf:Buffer.alloc(0),start:s,size:r,mtimeMs:i,ino:a,reset:o});let c=Buffer.alloc(r-s),l=0;for(;l<c.length;){let{bytesRead:e}=await n.read(c,l,c.length-l,s+l);if(e===0)break;l+=e}return J({buf:l===c.length?c:c.subarray(0,l),start:s,size:r,mtimeMs:i,ino:a,reset:o})}catch(t){return t.code===`ENOENT`?Y:X(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{O(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}async function bA(e,t){return mA.run(async()=>{let n=null;try{n=await x(e,`r`);let{size:r}=await n.stat(),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let{bytesRead:e}=await n.read(a,o,a.length-o,i+o);if(e===0)break;o+=e}return J({buf:o===a.length?a:a.subarray(0,o),fromStart:i===0})}catch(t){return t.code===`ENOENT`?Y:X(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{O(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}const xA=/"(?:cache_read_input_tokens|cache_creation_input_tokens)":[1-9]/;function SA(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}async function CA(e){let t=await wA(e);return t.kind===`ok`?J(Math.floor((t.value+36e5)/1e3)):t}async function wA(e){for(let t of[65536,1048576]){let n=await bA(e,t);if(n.kind!==`ok`)return n;let r=TA(n.value.buf,n.value.fromStart);if(r!=null)return J(r);if(n.value.fromStart)return Y}return Y}function TA(e,t){let n=e.toString(`utf8`).split(`
181
+ `),r=+!t;for(let e=n.length-1;e>=r;e--){let t=n[e];if(!t||!xA.test(t))continue;let r=SA(t);if(r!=null)return r}return null}function EA(e,t){return{...e,claudeConfigDir:iS(t.claudeConfigDir),env:t.mementoEnv}}const DA=c.join(`lib`,`ceiling_config.py`),OA=c.join(`skills`,`ceiling`,`bin`,`ceiling`);function kA(e,t){let n=typeof e==`object`&&e?e.plugins:void 0;if(typeof n!=`object`||!n)throw Error(`${t} has no "plugins" object`);return Object.entries(n).filter(([e])=>e.split(`@`)[0]===`memento`).flatMap(([e,n])=>{if(!Array.isArray(n))throw Error(`${t}: "${e}" is not a list of installs`);return n.map(n=>{let{scope:r,installPath:i,projectPath:a}=n??{};if(typeof r!=`string`||typeof i!=`string`)throw Error(`${t}: an install of "${e}" has no scope/path`);return typeof a==`string`?{key:e,scope:r,installPath:i,projectPath:a}:{key:e,scope:r,installPath:i}})})}function AA(e,t){let n=!0;for(let i of e){if(!r.existsSync(i))continue;let e;try{e=JSON.parse(r.readFileSync(i,`utf8`))?.enabledPlugins?.[t]}catch(e){return X(`memento lookup: ${i}: ${e.message}`)}typeof e==`boolean`&&(n=e)}return J(n)}function jA(e,t){if(!r.existsSync(e))return Y;let n;try{n=kA(JSON.parse(r.readFileSync(e,`utf8`)),e)}catch(e){return X(`memento lookup: ${e.message}`)}let i=n.find(e=>e.projectPath===t)??n.find(e=>e.scope===`user`);if(i===void 0)return Y;let a=AA([c.join(c.dirname(c.dirname(e)),`settings.json`),c.join(t,`.claude`,`settings.json`),c.join(t,`.claude`,`settings.local.json`)],i.key);if(a.kind!==`ok`)return a;if(!a.value)return Y;let o=[DA,OA].filter(e=>!r.existsSync(c.join(i.installPath,e)));return o.length===0?J(i.installPath):X(`memento at ${i.installPath} has no ${o.join(` or `)} — upgrade the plugin`)}function MA(e,t=process.env){let n=new Set([`CLAUDE_PROJECT_DIR`,`CLAUDE_CODE_SESSION_ID`,...e.env===void 0?[]:Ye]);return{...Object.fromEntries(Object.entries(t).filter(([e])=>!n.has(e))),...e.env,CLAUDE_CODE_SESSION_ID:e.sessionId,CLAUDE_PROJECT_DIR:e.projectDir||e.cwd}}function NA(e){return e.stderr.trim()||e.error||`${e.reason}${e.exitCode===null?``:` (exit ${e.exitCode})`}`}function PA(e){let t;try{t=JSON.parse(e)}catch{return X(`memento read: not JSON: ${e.trim()}`)}let{ceiling:n,session:r}=t??{},i=n===`off`||typeof n==`number`&&n>=0?n:void 0;return i!==void 0&&(r===null||typeof r==`string`)?J({ceiling:i,session:r}):X(`memento read: unexpected answer: ${e.trim()}`)}async function FA(e,t){let n=await Oe({bin:`python3`,args:[`-c`,`
178
182
  import json, math, sys
179
183
  sys.path.insert(0, sys.argv[1])
180
184
  from ceiling_config import CONFIG_NAME, anchored, ceiling_in, in_force, session_directory
@@ -183,38 +187,39 @@ ceiling = in_force(directory, anchored(sys.argv[3]))
183
187
  layer = ceiling_in(directory / CONFIG_NAME)
184
188
  print(json.dumps({"ceiling": "off" if ceiling == math.inf else ceiling,
185
189
  "session": layer.text if layer else None}))
186
- `,c.join(e,`lib`),t.sessionId,t.cwd],env:EA(t),timeoutMs:3e3,category:`memento.read`});return n.ok?OA(n.stdout):X(DA(n))}function AA(e,t,n){let r=ke({bin:c.join(e,SA),args:n.kind===`set`?[`set`,`session`,n.to]:[`clear`,`session`],env:EA(t),timeoutMs:5e3,category:`memento.move`});if(!r.ok)throw Error(DA(r))}function jA(){return{locate:e=>TA(tS(e.claudeConfigDir),e.projectDir),read:kA,move:AA}}function MA(e,t,n){let r=n===void 0?``:`CLAUDE_CONFIG_DIR=${HD(n)} `,i=e.added_dirs.map(e=>` --add-dir ${HD(e)}`).join(``);return`cd ${HD(e.project_dir)} && ${r}claude --resume ${HD(t)}${i}`}function NA(e,t,n){let r=O_(t(`preset`),e.globals.preset,e.presets),i=j_(e,r),a=t(`edit.mode`)===`arrange`?e.editGlobals:{};return{preset:r,presetCustomized:n(r),theme:Qb(a.palette,t(`theme`),i.palette),style:uo(a.style,t(`style`),i.style,e.styles),endcaps:mo(a.endcaps,t(`endcaps`),i.endcaps),variation:xo(a.variation,t(`variation`),i.variation),separator:a.default_separator??i.default_separator,autoWrap:Oo(a.autoWrap,t(`autoWrap`),i.autoWrap),padding:Ao(a.padding,t(`padding`),i.padding),charset:a.charset??i.charset??`unicode`,updateNotice:ko(a.updateNotice,t(`updateNotice`),i.updateNotice),colorCompatibility:a.colorCompatibility??i.colorCompatibility??`truecolor`}}function PA(e,t){return{endcaps:e.endcaps,separator:e.separator,colorCompatibility:e.colorCompatibility,wrap:e.autoWrap,padding:e.padding,charset:e.charset,width:t}}function FA(e){return{theme:e.theme,style:e.style,preset:e.preset,variation:e.variation}}function IA(e){return{preset:{effective:e.preset,customized:e.presetCustomized,bundled:oA(e.preset)},endcaps:{effective:e.endcaps},variation:{effective:e.variation},charset:{effective:e.charset},colorCompatibility:{effective:e.colorCompatibility},autoWrap:{effective:e.autoWrap},padding:{effective:e.padding},updateNotice:{effective:e.updateNotice}}}const LA=10*1e3;function RA(e,t,n,r){let i=n-(t*1e3-r);if(i<3e5||e<=0)return;let a=e/i,o=(100-e)/a;return Math.max(0,Math.round(o/6e4))}function zA(e,t){if(!(t<60))return e*3600/t}function BA(e,t,n,r){let i=r-t;if(i<50||i>LA)return;let a=n-e;if(!(a<=0))return a*1e3/i}function VA(e){let{prev:t,cur:n}=e;if(t===void 0)return;let r=BA(t.input,t.atMs,n.input,n.atMs),i=BA(t.output,t.atMs,n.output,n.atMs),a=BA(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 HA(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>LA)continue;let o=BA(r.total,r.atMs,i.total,i.atMs);n.push(o??0)}if(n.length!==0)return n.join(`,`)}function UA(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}function WA(e){let t=[],n=(e,n)=>{try{let e=n();return e===``?void 0:e}catch(n){t.push(`host.${e}: ${String(n)}`);return}},r=n(`name`,()=>UA(m.hostname())),i=n(`user`,()=>m.userInfo().username);return{host:{...r!==void 0&&{name:r},...i!==void 0&&{user:i},...e.ssh!==void 0&&{ssh:e.ssh}},failures:t}}function GA(e,t){let n=new Map;for(let[t,r]of Object.entries(e.variables))n.set(t,r);for(let[t,r]of Object.entries(e.segments))if(r.vars)for(let[e,i]of Object.entries(r.vars))n.set(`${t}.${e}`,i);let r=[],i=new Set,a=t=>_v(t,e.helpers).keys(),o=j_(e,t);for(let e of ro){let t=o[e];if(io(t))for(let e of a(t))r.push(e)}for(let n of Ms(A_(e,t).node)){if(n.when)for(let e of a(n.when))r.push(e);if(n.kind!==`segment`)continue;let t=e.segments[n.name];if(t){for(let e of[t.template,t.when,t.bg,t.fg])if(e)for(let t of a(e))r.push(t)}}let s=new Set;for(;r.length>0;){let e=r.pop();for(let t of qA(n,e)){if(i.has(t))continue;i.add(t);let e=n.get(t);if(e){if(e.kind===`input`)s.add(e.path);else if(e.kind===`template`)for(let t of a(e.template))r.push(t)}}}return s}function KA(e){let t=new Map;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=GA(e,n);return t.set(n,i),i}}function qA(e,t){let n=t;for(;n.length>0;){if(e.has(n))return[n];let t=n.lastIndexOf(`.`);if(t<0)break;n=n.slice(0,t)}let r=`${t}.`,i=[];for(let t of e.keys())t.startsWith(r)&&i.push(t);return i}function JA(e,t){for(let n of e)if(n===t||n.startsWith(t+`.`))return!0;return!1}function YA(e){let t=t=>e.has(t),n=t(`git.staged`)||t(`git.unstaged`)||t(`git.untracked`)||t(`git.conflicts`);return{...t(`git.sha`)&&{showSha:!0},...n&&{showWorkingTree:!0},...t(`git.stash`)&&{showStashCount:!0},...t(`git.upstream`)&&{showUpstream:!0},...t(`git.repoName`)&&{showRepoName:!0},...t(`git.repoUrl`)&&{showRepoUrl:!0},...t(`git.operation`)&&{showOperation:!0},...t(`git.timeSinceCommit`)&&{showTimeSinceCommit:!0},...(t(`git.prNumber`)||t(`git.prState`)||t(`git.prUrl`)||t(`git.prError`))&&{showPullRequest:!0}}}async function XA(e,t,n,r,i,a,{configPath:o,...s}){let c=e=>JA(r,e),l=(t.clock??(()=>new Date))().getTime(),u=a.tmux??null,d=(e,t,n)=>t?n().catch(t=>X(`${e}: ${String(t)}`)):Promise.resolve(Y),[f,p,m,h,g,_,v,y,b,x,S]=await Promise.all([d(`git`,c(`git`),()=>t.gitProvider.getGitInfo(n??e.workspace?.current_dir,YA(r),e.workspace?.project_dir)),d(`session`,c(`session.cost`)||c(`session.tokens`)||c(`burn`),()=>t.usageStore.getUsageInfo(e.session_id,e)),d(`today`,c(`today`),()=>t.usageStore.getTodayInfo(e,a.claudeConfigDir)),d(`context`,c(`context`)||c(`autocompact`),()=>t.contextProvider.getContextInfo(e)),d(`metrics`,c(`metrics`)||c(`burn`),()=>t.metricsProvider.getMetricsInfo(e.session_id,e)),d(`activity`,c(`activity`),()=>t.activityProvider.getActivityInfo(e.session_id,e)),d(`tmux`,c(`tmux.session`),()=>u===null?Promise.resolve(Y):t.tmuxService.getSessionName(u)),d(`cache`,c(`cache`),()=>_A(e.transcript_path)),d(`speed`,c(`speed`),()=>t.usageStore.observeSpeed(e.session_id,e.transcript_path,l)),d(`memento`,c(`memento`),()=>t.mementoProvider.getCeiling(bA({sessionId:e.session_id,projectDir:e.workspace?.project_dir??``,cwd:n??e.workspace?.current_dir??``},a))),d(`autocompact`,c(`autocompact`),()=>Promise.resolve(t.autoCompact(eS($x(a.claudeConfigDir)))))]),C=[],w=e=>{if(e.kind===`failed`){C.push(e.reason);return}return e.kind===`ok`?e.value:void 0},ee=ij(f);C.push(...ee.failures);let te=WA(a);C.push(...te.failures);let ne=w(p),T=w(m),re=w(h),E=w(g),D=w(_),ie=w(v),ae=w(y),oe=$A(x);x.kind===`failed`&&C.push(`memento: ${x.reason}`);let se=ZA(S,re?.maxTokens);S.kind===`failed`&&C.push(`autocompact: ${S.reason}`);for(let e of C)t.log(`warn`,`provider fetch failed: ${e}`);let ce=e.rate_limits?.five_hour,le=e.rate_limits?.seven_day,ue=ce?RA(ce.used_percentage,ce.resets_at,18e6,l):void 0,de=le?RA(le.used_percentage,le.resets_at,6048e5,l):void 0,fe=ne?.session.cost,pe=E?.sessionDuration,me=c(`burn`)&&fe!=null&&pe!=null?zA(fe,pe):void 0,he=w(b),ge=he===void 0?void 0:VA(he),_e=he===void 0?void 0:HA(he),O=ge!==void 0||_e!==void 0?{...ge,..._e!==void 0&&{history:_e}}:void 0,ve=rj(process.env.HOME??process.env.USERPROFILE),ye=e.workspace?{...e.workspace,current_dir:rj(e.workspace.current_dir)??``,project_dir:rj(e.workspace.project_dir)??``,added_dirs:(e.workspace.added_dirs??[]).map(e=>rj(e)??e)}:e.workspace,be=ne===void 0?void 0:nj({cost:ne.session.cost,tokens:ne.session.tokens}),xe=T===void 0?void 0:{cost:T.cost,tokens:T.tokens},Se=E===void 0?void 0:nj({lastResponseTime:E.lastResponseTime,responseTime:E.responseTime,sessionDuration:E.sessionDuration,messageCount:E.messageCount,linesAdded:E.linesAdded,linesRemoved:E.linesRemoved}),Ce=D===void 0?void 0:ej(D);return{...e,...ye!==void 0&&{workspace:ye},...ve!==void 0&&{home:ve},...ee.git!==void 0&&{git:ee.git},...u!==null&&{tmux:{pane:u.pane,...ie!==void 0&&{session:ie}}},host:te.host,...IA(i),history:t.history(e.session_id),navigation:{back:t.navigation(e.session_id)},...s,...o!==null&&{configPath:o},resumeCommand:MA(ye,e.session_id,a.claudeConfigDir),...be!==void 0&&{session:be},...xe!==void 0&&{today:xe},...me!==void 0&&{burn:{costPerHour:me}},...O!==void 0&&{speed:O},...c(`block`)&&ce!==void 0&&{block:{nativeUtilization:ce.used_percentage,resetsAt:ce.resets_at,...ue!==void 0&&{etaMinutes:ue}}},...le!==void 0&&{weekly:{percentage:le.used_percentage,resetsAt:le.resets_at,...de!==void 0&&{etaMinutes:de}}},...ae!==void 0&&{cache:{expiresAt:ae}},...re!==void 0&&{context:{totalTokens:re.totalTokens,contextLeft:re.contextLeftPercentage}},...Se!==void 0&&{metrics:Se},...Ce!==void 0&&{activity:Ce},...oe!==void 0&&{memento:oe},...se!==void 0&&{autocompact:se}}}function ZA(e,t){switch(e.kind){case`absent`:return;case`failed`:return{error:e.reason};case`ok`:return lS(e.value,t)}}const QA=e=>e.trim().split(`
187
- `).at(-1).trim();function $A(e){switch(e.kind){case`absent`:return;case`failed`:return{error:QA(e.reason)};case`ok`:{let{ceiling:t,session:n}=e.value;return{ceiling:t===`off`?0:t,off:t===`off`,session:n??``}}}}function ej(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=tj(e.running),i=tj(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 tj(e){return e.length===0?void 0:e.map(e=>`${e.name}:${e.count}`).join(`,`)}function nj(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 rj(e){return e===void 0||e.length===0||c.sep!==`\\`?e:e.replace(/\\/g,`/`)}function ij(e){if(e.kind===`absent`)return{failures:[]};if(e.kind===`failed`)return{failures:[e.reason]};let t=e.value,n=[],r=(e,t)=>{if(!(t===void 0||t.kind===`absent`)){if(t.kind===`failed`){n.push(`git.${e}: ${t.reason}`);return}return t.value}},i=r(`aheadBehind`,t.aheadBehind),a=r(`sha`,t.sha),o=r(`operation`,t.operation),s=r(`timeSinceCommit`,t.timeSinceCommit),c=r(`stash`,t.stashCount),l=r(`upstream`,t.upstream),u=r(`repoName`,t.repoName),d=r(`repoUrl`,t.repoUrl),f=t.pullRequest,p={};return f?.kind===`ok`?(p.prNumber=f.value.number,p.prState=f.value.state,p.prUrl=f.value.url):f?.kind===`failed`&&(n.push(`git.pr: ${f.reason}`),p.prError=f.reason),{git:{branch:t.branch,status:t.status,...i!==void 0&&{ahead:i.ahead,behind:i.behind},...t.workingTree!==void 0&&{staged:t.workingTree.staged,unstaged:t.workingTree.unstaged,untracked:t.workingTree.untracked,conflicts:t.workingTree.conflicts},...a!==void 0&&{sha:a},...o!==void 0&&{operation:o},...s!==void 0&&{timeSinceCommit:s},...c!==void 0&&{stash:c},...l!==void 0&&{upstream:l},...u!==void 0&&{repoName:u},...d!==void 0&&{repoUrl:d},...p},failures:n}}const aj={theme:e=>e.theme.kind===`decided`?e.theme.name:null,preset:e=>e.preset,style:e=>e.style.kind===`decided`?e.style.name:null,endcaps:e=>e.endcaps,variation:e=>e.variation,autoWrap:e=>e.autoWrap?So:Co,padding:e=>String(e.padding),updateNotice:e=>e.updateNotice?So:Co},oj=Object.entries(Pb),sj=new Set(Fb.map(e=>e.sessionKey)),cj=()=>!1;function lj(e,t){return NA(e,e=>sj.has(e)?t(e):null,cj)}function uj(e,t,n,r){return e.flatMap(([e,i])=>{let a=aj[e](t);return a===null||a===aj[e](n(e))?[]:[{...i,value:a,target:r(i)}]})}function dj(e,t,n){return aj[n](lj(e,t))}function fj(e,t){let n=lj(e,t),r=NA(e,()=>null,cj),i=NA(e,e=>e===Pb.preset.sessionKey?n.preset:null,cj);return uj(oj,n,e=>e===`preset`?r:i,t=>pj(e,n.preset,t.configKey))}function pj(e,t,n){return n in(k_(e.presets,t).globals??{})?hx(t,n):n}function mj(e,t,n){let r=O_(t(Pb.preset.sessionKey),e.globals.preset,e.presets),i=gx(n);return{key:i?.scope===`globals`?pj(e,r,i.field):n,globals:j_(e,r)}}function hj(e,t){let{preset:n}=lj(e,t);return vj(e,n).flatMap(({id:e,setting:r,key:i,decl:a,saved:o})=>{let s=t(i),c=s===null?void 0:qs(a,s);return c===void 0||Ks(c)===Ks(o)?[]:[{preset:n,id:e,setting:r,key:i,value:c}]})}function gj(e,t,n){let r=new Map(n.map(e=>[e.key,e.value]));return D_(e.presets).flatMap(n=>{let i=vj(e,n);return[...new Set(i.filter(e=>r.has(e.key)).map(e=>e.id))].flatMap(e=>{let n=i.filter(t=>t.id===e);return Ws(Object.fromEntries(n.map(e=>[e.setting,e.decl])),Object.fromEntries(n.map(e=>{let n=r.get(e.key)??t(e.key),i=n===null?void 0:qs(e.decl,n);return[e.setting,i??e.saved]}))).map(({message:t})=>`placement "${e}": ${t}`)})})}const _j=new WeakMap;function vj(e,t){let n=_j.get(e)??new Map;_j.set(e,n);let r=n.get(t);if(r!==void 0)return r;let i=[...Ms(A_(e,t).node)].flatMap(t=>t.kind!==`segment`||t.drafts===void 0?[]:Object.entries(t.drafts).map(([n,{id:r,key:i}])=>{let a=Hs(e.segments[t.name])[n];return{id:r,setting:n,key:i,decl:a,saved:t.settings?.[n]??a.default}})),a=[...new Map(i.map(e=>[e.key,e])).values()];return n.set(t,a),a}function yj(e,t){let n=lj(e,t),r=NA(e,e=>e===Pb.preset.sessionKey?n.preset:null,cj);return{from:n.preset,globals:k_(e.presets,n.preset).globals??{},picks:uj(oj.filter(([e])=>e!==`preset`),n,()=>r,e=>e.configKey),placements:hj(e,t)}}function bj(e){return{sessionKeys:Fb.filter(t=>t.configKey===e).map(e=>e.sessionKey),fileKeys:[e,...Sl(e)?aA.map(t=>hx(t,e)):[]]}}function xj(e){return new Set(Fb.map(e=>e.configKey).filter(t=>bj(t).fileKeys.some(t=>wj(e,Cj(t)))))}function Sj(e,t,n){let r=fj(e,n),i=new Set(r.map(e=>e.configKey)),a=Bb(e=>i.has(Pb[e].configKey)||t.has(Pb[e].configKey));return{unsaved:r.length+hj(e,n).length,resettable:a}}function Cj(e){let t=gx(e);if(t===null||t.scope===`preset-root`)throw Error(`reset layer "${e}" is not a value path`);return _x(t)}function wj(e,t){let[n,...r]=t;return n===void 0?e!==void 0:typeof e==`object`&&!!e&&wj(e[n],r)}const Tj=Qa(),Ej=new Set(Tj),Dj=new Set(fo),Oj=e=>e?Ej.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${Tj.join(`, `)})`}:{ok:!1,reason:`theme name is required`},kj=e=>e?Dj.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown endcaps "${e}" (have: ${fo.join(`, `)})`}:{ok:!1,reason:`endcaps name is required`},Aj=new Set([`1`,`true`]),jj=new Set([`0`,`false`]),Mj={endcaps:kj,theme:Oj,"toolbar-expanded":e=>Aj.has(e)?{ok:!0,value:`1`}:jj.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}},Nj=zk(Mj,`state`,Bj);function Pj(e,t){return Nj.register(e,t)}function Fj(e){return Nj.gateFor(e)}function Ij(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:ox(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 Lj(e){return e.filter(e=>e.spec.kind!==`allow-list`||!Object.hasOwn(Mj,e.key))}function Rj(e,t,n){let r=Vb.get(n);if(r!==void 0)return dj(e,t,r);let i=Object.values(e.variables).find(e=>e.kind===`state`&&e.key===n);return i?.kind===`state`?i.default??null:null}function zj(e){let t=ix(e);return Lj(Object.values(e.actions).flatMap(e=>Ij(e,t)))}function Bj(e){return Lk(zj(e))}const Vj=`update.dismissed`,Hj=`updateNotice`,Uj=Pb.updateNotice.sessionKey;function Wj(e){return e.kind===`source`?e.newer.digest:GD(e.newer)}const Gj=e=>`${e.version} [${Sk(e.digest)}]`;function Kj(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:Gj(e.newer),running:Gj(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:GD(e.newer),running:GD(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${qD}@${GD(e.newer)}`,`install`]}}}}const qj={kind:`idle`},Jj={kind:`running`};function Yj(e,t,n){if(e===null)return[];let r=Wj(e);if(!n.enabled||n.dismissed===r)return[];let i=Kj(e),a=`${i.headline}: ${i.newer}. You're on ${i.running}.`,o=t.kind===`failed`&&t.identity===r?[`${i.act} failed: ${t.reason}`]:[],s=[a,...o].join(`
188
- `),c=ND([{verb:mD,args:[s]}]),l=t.kind===`running`?uk(`[${i.busy}]`,c):uk(`[${i.act}]`,ND([{verb:ED,args:[n.sessionId]}]));return[{severity:lk,message:s,lines:[[uk(a,c),l,uk(`[dismiss]`,ND([{verb:cD,args:[n.sessionId,Vj,r]}])),uk(`[disable]`,ND([{verb:hD,args:[n.sessionId,Hj,`false`]},{verb:cD,args:[n.sessionId,Uj,`false`]}]))],...o.map(e=>[uk(e,c)])]}]}function Xj(e,t){return e.kind===`stale`?{kind:`source`,root:e.root,newer:e.source,running:e.running}:e.kind===`not-source-checkout`&&t!==null&&t.kind===`stale`?{kind:`release`,newer:t.latest,running:t.installed}:null}function Zj(e){switch(e.kind){case`current`:return[`info`,`build: current ${Gj(e.stamp)}`];case`stale`:return[`info`,`build: stale — source ${Gj(e.source)}, running ${Gj(e.running)}`];case`not-source-checkout`:return[`info`,`build: not a source checkout`];case`unchecked`:return[`warn`,`build: unchecked: ${e.reason}`]}}function Qj(e){switch(e.kind){case`current`:return[`info`,`release: current ${GD(e.installed)}`];case`stale`:return[`info`,`release: stale — latest ${GD(e.latest)}, running ${GD(e.installed)}`];case`ahead`:return[`info`,`release: ahead — running ${GD(e.installed)}, latest ${GD(e.latest)}`];case`unchecked`:return[`warn`,`release: unchecked: ${e.reason}`]}}function $j(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const eM=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e!==``).at(-1);function tM(e){let t=e.exitCode===null?``:` (exit ${e.exitCode})`,n=eM(e.stderr)??e.error??eM(e.stdout)??`no output`;return`${e.reason}${t}: ${n}`}function nM(){let e=[Vk(Hj,[`false`]),Pj(Uj,[`false`]),Pj(Vj,[])];return()=>e.forEach(e=>e())}function rM(e){let{entryUrl:t,intervalMs:n,releaseIntervalMs:r,registryUrl:i,fetchImpl:a,onApplied:o,log:s}=e,c={kind:`unchecked`,reason:`not sampled yet`},l=null,u=qj,d=null,f=$j(s),p=$j(s),m=()=>Xj(c,l);function h(){let e=m(),t=e===null?null:Wj(e);(d===null?null:d.identity)!==t&&(d?.dispose(),d=t===null?null:{identity:t,dispose:Pj(Vj,[t])})}function g(){c=Ek(t,wk),f(Zj(c)),h()}async function _(){l=YD(zD,await JD(qD,a,i)),p(Qj(l)),h()}return{arm(){nM(),g(),setInterval(g,n).unref(),c.kind===`not-source-checkout`&&(_(),setInterval(()=>void _(),r).unref())},notice:e=>Yj(m(),u,e),act(){let e=m();if(e===null)throw new $(`apply-update: nothing newer is known to apply`);let t=Kj(e);if(u.kind===`running`)throw new $(`apply-update: already ${t.busy}`);u=Jj,s(`info`,`apply-update: ${t.act} — ${t.command.bin} ${t.command.args?.join(` `)??``}`),Oe({...t.command,category:`update.apply`,timeoutMs:6e5}).then(n=>{if(n.ok){u=qj,s(`info`,`apply-update: ${t.act} succeeded`),g(),o();return}let r=tM(n);u={kind:`failed`,identity:Wj(e),reason:r},s(`error`,`apply-update: ${t.act} failed: ${r}`)})}}}var iM=class{static CACHE_DIR=Pe();static USAGE_CACHE_DIR=c.join(this.CACHE_DIR,`usage`);static LOCKS_DIR=c.join(this.CACHE_DIR,`locks`);static isLocked(e){let t=c.join(this.LOCKS_DIR,e);if(!r.existsSync(t))return!1;try{let n=r.readFileSync(t,`utf-8`),i=parseInt(n.trim(),10);if(isNaN(i))return O(`Invalid PID in lock file ${e}, removing stale lock`),r.unlinkSync(t),!1;try{return process.kill(i,0),!0}catch(n){return n.code===`ESRCH`?(O(`Removing stale lock file ${e} for dead process ${i}`),r.unlinkSync(t),!1):(O(`Error checking process ${i} for lock ${e}:`,n),!0)}}catch(t){return O(`Error reading lock file ${e}:`,t),!0}}static async acquireLock(e,t=5e3){await this.ensureCacheDirectories();let n=c.join(this.LOCKS_DIR,e),i=Date.now(),a=String(process.pid);for(;Date.now()-i<t;)try{return await r.promises.writeFile(n,a,{flag:`wx`}),O(`Lock acquired for ${e}`),!0}catch(e){if(e.code===`EEXIST`)await se(50);else throw e}return O(`Failed to acquire lock for ${e} within ${t}ms`),!1}static async releaseLock(e){let t=c.join(this.LOCKS_DIR,e);try{await r.promises.unlink(t),O(`Lock released for ${e}`)}catch(t){t.code!==`ENOENT`&&O(`Error releasing lock for ${e}:`,t)}}static async ensureCacheDirectories(){try{await Promise.all([r.promises.mkdir(this.CACHE_DIR,{recursive:!0}),r.promises.mkdir(this.USAGE_CACHE_DIR,{recursive:!0}),r.promises.mkdir(this.LOCKS_DIR,{recursive:!0})])}catch(e){O(`Failed to create cache directories:`,e)}}static createProjectHash(e){return ae(`md5`).update(e).digest(`hex`).substring(0,8)}static async getUsageCache(e,t){await this.ensureCacheDirectories();let n=c.join(this.USAGE_CACHE_DIR,`${e}.json`),i=`${e}.usage.lock`;for(let a=0;a<3;a++){if(this.isLocked(i)){O(`Cache for ${e} is locked, waiting...`),await se(75);continue}try{let i=await r.promises.readFile(n,`utf-8`),a=JSON.parse(i);return!t||a.timestamp>=t?(O(`[CACHE-HIT] ${e} disk cache: found`),this.deserializeDates(a.data)):(O(`${e} cache outdated: cache=${a.timestamp}, latest=${t}`),null)}catch(t){if(t.code===`ENOENT`)return O(`No shared ${e} usage cache found`),null;O(`Attempt ${a+1} failed to read ${e} cache: ${t.message}. Retrying...`),await se(75)}}return O(`Failed to read ${e} 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){let i=`${e}.usage.lock`;if(!await this.acquireLock(i)){O(`Could not acquire lock to set usage cache for ${e}`);return}try{await this.ensureCacheDirectories();let i=c.join(this.USAGE_CACHE_DIR,`${e}.json`),a=JSON.stringify({data:t,timestamp:n||Date.now()});await r.promises.writeFile(i,a,`utf-8`),O(`[CACHE-SET] ${e} disk cache stored`)}catch(t){O(`Failed to save ${e} usage cache:`,t)}finally{await this.releaseLock(i)}}};const aM={"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 oM=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(){let e=Date.now()-1440*60*1e3;return await iM.getUsageCache(`pricing`,e)}static async saveDiskCache(e){await iM.setUsageCache(`pricing`,e)}static async fetchPricingData(){return new Promise(e=>{let t=new T(this.GITHUB_PRICING_URL),n=oe({hostname:t.hostname,path:t.pathname,headers:{"User-Agent":`cc-candybar`,"Cache-Control":`no-cache`},timeout:5e3},t=>{if(t.statusCode!==200){O(`HTTP ${t.statusCode}: ${t.statusMessage}`),e(null);return}let r=``,i=0;t.on(`data`,t=>{if(i+=t.length,i>1048576){O(`Response too large`),n.destroy(),e(null);return}r+=t}),t.on(`end`,()=>{try{let t=JSON.parse(r),n=t._meta,i={};for(let[e,n]of Object.entries(t))e!==`_meta`&&(i[e]=n);this.validatePricingData(i)?(O(`Fetched fresh pricing from GitHub for ${Object.keys(i).length} models`),O(`Pricing last updated: ${n?.updated||`unknown`}`),e(i)):(O(`Invalid pricing data structure`),e(null))}catch(t){O(`Failed to parse JSON:`,t),e(null)}}),t.on(`error`,t=>{O(`Response error:`,t),e(null)})});n.on(`error`,t=>{O(`Request error:`,t),e(null)}),n.on(`timeout`,()=>{O(`Request timeout`),n.destroy(),e(null)}),n.end()})}static async getCurrentPricing(){if(this.executionCache!==null)return O(`[CACHE-HIT] Pricing execution cache: ${Object.keys(this.executionCache).length} models`),this.executionCache;let e=await this.loadDiskCache();if(e)return O(`[CACHE-HIT] Pricing disk cache: ${Object.keys(e).length} models`),this.executionCache=e,O(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(e).length} models`),e;let t=await this.fetchPricingData();return t?(await this.saveDiskCache(t),O(`[CACHE-SET] Pricing disk cache stored: ${Object.keys(t).length} models`),this.executionCache=t,O(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(t).length} models`),t):(O(`[CACHE-FALLBACK] Using offline pricing data: ${Object.keys(aM).length} models`),this.executionCache=aM,O(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(aM).length} models`),aM)}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){if(this.modelPricingCache.has(e))return O(`[CACHE-HIT] Model pricing cache: ${e}`),this.modelPricingCache.get(e);let t=await this.getCurrentPricing(),n;return n=t[e]?t[e]:this.fuzzyMatchModel(e,t),this.modelPricingCache.set(e,n),O(`[CACHE-SET] Model pricing cache: ${e}`),n}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){let t=e.message?.usage;if(!t)return 0;let n=this.extractModelId(e),r=await this.getModelPricing(n),i=t.input_tokens||0,a=t.output_tokens||0,o=t.cache_creation_input_tokens||0,s=t.cache_read_input_tokens||0,c=i/1e6*r.input,l=a/1e6*r.output,u=s/1e6*r.cache_read,d=o/1e6*r.cache_write_5m;return c+l+d+u}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`}};const sM=/<command-name>\s*([^<\s][^<]*?)\s*<\/command-name>/;function cM(e){if(typeof e==`string`)return sM.exec(e)?.[1]}function lM(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 uM(e){let t=e.message?.content,n=e.type===`user`,r=[],i=[],a,o;if(typeof t==`string`)o=t;else if(Array.isArray(t))for(let e of t){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=lM(t.input)??a);break}case`tool_result`:{let e=t.tool_use_id;typeof e==`string`&&i.push(e);break}case`text`:o??=t.text;break;default:break}}let s=n?cM(o):void 0;if(!(r.length===0&&i.length===0&&a===void 0&&s===void 0))return{...r.length>0&&{started:r},...i.length>0&&{finished:i},...a!==void 0&&{todos:a},...s!==void 0&&{command:s}}}function dM(e){if(e!==void 0)return[e];let t=h();return[f(t,`.config`,`claude`),f(t,`.claude`)].filter(e=>a(e))}async function fM(e){let t=[];for(let n of e){let e=f(n,`projects`);if(a(e))try{let n=await uA(e,{withFileTypes:!0});for(let r of n)if(r.isDirectory()){let n=f(e,r.name);t.push(n)}}catch(t){O(`Failed to read projects directory ${e}:`,t)}}return t}async function pM(e,t,n){let r=[],i=f(t,e,`subagents`);try{let t=(await uA(i)).filter(e=>e.startsWith(`agent-`)&&e.endsWith(`.jsonl`));for(let a of t){let t=f(i,a);if(n?.has(t)){r.push(t);continue}try{let n=(await dA(t,`utf-8`)).split(`
189
- `)[0];n&&JSON.parse(n).sessionId===e&&r.push(t)}catch{O(`Failed to check agent file ${t}`)}}}catch(e){O(`Failed to read subagents directory ${i}:`,e)}return r}function mM(e){let t=e.type||e.message?.role||e.message?.type,n=e.type===`user`&&e.message?.firstContentType===`tool_result`;return t===`user`&&!n}const hM=new Map;async function gM(e){try{let t=await fA(e),n=t.size,r=hM.get(e);if(r&&r.mtime===t.mtimeMs&&r.size===n)return O(`[parse-cache] hit ${e}`),hM.delete(e),hM.set(e,r),r.entries;let i;return n>1048576?(O(`Using streaming parser for large file ${e} (${Math.round(n/1024)}KB)`),i=await xM(e)):i=await yM(e),O(`Parsed ${i.length} entries from ${e}`),n>5242880?i:(hM.delete(e),hM.size>=16&&hM.delete(hM.keys().next().value),hM.set(e,{mtime:t.mtimeMs,size:n,entries:i}),i)}catch(t){if(t.code===`ENOENT`)return O(`Transcript not present yet: ${e}`),[];throw t}}function _M(e){if(!e.timestamp)return null;let t=e.message,n=t?.usage,r=t?.content,i=Array.isArray(r)&&typeof r[0]==`object`&&r[0]?r[0]:void 0;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,firstContentType:typeof i?.type==`string`?i.type:void 0}:void 0,costUSD:typeof e.costUSD==`number`?e.costUSD:void 0,isSidechain:e.isSidechain===!0,activity:uM(e),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 vM(e){let t=[];for(let n of e.split(`
190
- `))if(n.trim())try{let e=_M(JSON.parse(n));e&&t.push(e)}catch(e){O(`Failed to parse JSONL line: ${e}`);continue}return t}async function yM(e){return vM(await dA(e,`utf-8`))}async function bM(e,t){let n=await pA(e,t===void 0?void 0:{offset:t.offset,ino:t.ino});if(n.kind!==`ok`)return n;let{buf:r,start:i,mtimeMs:a,ino:o,reset:s}=n.value,c=r.lastIndexOf(10);return J(c<0?{entries:[],cursor:{offset:i,mtimeMs:a,ino:o},reset:s}:{entries:vM(r.subarray(0,c+1).toString(`utf-8`)),cursor:{offset:i+c+1,mtimeMs:a,ino:o},reset:s})}async function xM(e){return new Promise((t,n)=>{let r=[],a=i(e,{encoding:`utf8`}),o=ce({input:a,crlfDelay:1/0});o.on(`line`,e=>{let t=e.trim();if(t)try{let e=_M(JSON.parse(t));e&&r.push(e)}catch(e){O(`Failed to parse JSONL line: ${e}`)}}),o.on(`close`,()=>{t(r)}),o.on(`error`,t=>{O(`Streaming parser error for ${e}:`,t),n(t)}),a.on(`error`,t=>{O(`File stream error for ${e}:`,t),n(t)})})}var SM=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 CM(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 wM=new Map,TM={cost:0,input:0,output:0,cacheCreation:0,cacheRead:0},EM={cost:null,calculatedCost:null,officialCost:null,tokens:null,tokenBreakdown:null};function DM(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function OM(){let e=new Date;return e.setHours(0,0,0,0),e.setDate(e.getDate()-1),e.getTime()}function kM(){return{input:0,output:0,cacheCreation:0,cacheRead:0}}async function AM(e,t,n,r){let i=DM(new Date(OM())),a=e&&!t?e:void 0,o=a?.entries??0,s=a?.cost??0,c=a?{...a.breakdown}:kM(),l=new Map;if(a)for(let[e,t]of a.days)e>=i&&l.set(e,{...t});for(let e of n){let t=e.message?.usage;if(!t)continue;o++;let n=e.costUSD??await oM.calculateCostForEntry(e.raw);s+=n,c.input+=t.input_tokens||0,c.output+=t.output_tokens||0,c.cacheCreation+=t.cache_creation_input_tokens||0,c.cacheRead+=t.cache_read_input_tokens||0;let r=DM(new Date(e.timestamp));if(r<i)continue;let a=l.get(r)??{...TM};a.cost+=n,a.input+=t.input_tokens||0,a.output+=t.output_tokens||0,a.cacheCreation+=t.cache_creation_input_tokens||0,a.cacheRead+=t.cache_read_input_tokens||0,l.set(r,a)}return{cursor:r,entries:o,cost:s,breakdown:c,days:l}}function jM(e){let t=0,n=0,r=kM(),i=new Map;for(let 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)??{...TM};n.cost+=t.cost,n.input+=t.input,n.output+=t.output,n.cacheCreation+=t.cacheCreation,n.cacheRead+=t.cacheRead,i.set(e,n)}}if(t===0)return{sessionInfo:EM,days:i};let a=r.input+r.output+r.cacheCreation+r.cacheRead;return{sessionInfo:{cost:n,calculatedCost:n,officialCost:null,tokens:a,tokenBreakdown:r},days:i}}async function MM(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))}var NM=class{entries=new Map;flight=new SM;seeded=new Map;seededDay=``;speedRings=new Map;speedFlight=new SM;maxEntries;staleAgeMs;log;hits=0;misses=0;sweeps=0;seeds=0;sweepTimer=null;constructor(e={}){this.log=e.logger??$y,this.maxEntries=e.maxEntries??256,this.staleAgeMs=e.staleAgeMs??864e5;let t=e.sweepIntervalMs??3e5;t>0&&(this.sweepTimer=setInterval(()=>this.sweepStale(),t),this.sweepTimer.unref())}getStats(){return{size:this.entries.size,hits:this.hits,misses:this.misses,sweeps:this.sweeps,seeds:this.seeds}}async getUsageInfo(e,t){let n=await this.ingest(e,t?.transcript_path);if(n.kind===`failed`)return n;let r=n.kind===`ok`?n.value.sessionInfo:EM,i=t?.cost?.total_cost_usd??null;return J({session:{...r,cost:i??r.cost,officialCost:i}})}async getTodayInfo(e,t){let n=DM(new Date),r=dM(t);try{await this.ensureSeeded(n,r)}catch(e){return X(`usage seed: ${e instanceof Error?e.message:String(e)}`)}let i=await this.ingest(e?.session_id??``,e?.transcript_path);if(i.kind===`failed`)return i;let a=r.map(e=>f(e,`projects`)+p),o={...TM},s=!1;for(let[t,r]of this.entries){let i=r.transcriptPath??``,c=t===e?.session_id||a.some(e=>i.startsWith(e))?r.days:wM;s||=c.has(n);let l=c.get(n)??TM;o.cost+=l.cost,o.input+=l.input,o.output+=l.output,o.cacheCreation+=l.cacheCreation,o.cacheRead+=l.cacheRead}return s?J({cost:o.cost,tokens:o.input+o.output+o.cacheCreation+o.cacheRead,tokenBreakdown:{input:o.input,output:o.output,cacheCreation:o.cacheCreation,cacheRead:o.cacheRead},date:n}):Y}async observeSpeed(e,t,n){let r=sA(t);return this.speedFlight.run(`${e}:${r}`,async()=>{let i=await this.ingest(e,t,r);if(i.kind===`failed`)return i;let a=CM(i.kind===`ok`?i.value.sessionInfo.tokenBreakdown:null,n),o=this.speedRings.get(e)??[],s;for(let e of o)e.atMs<a.atMs&&(s===void 0||e.atMs>s.atMs)&&(s=e);return o.push(a),o.sort((e,t)=>e.atMs-t.atMs),o.length>64&&o.shift(),this.speedRings.set(e,o),J({...s!==void 0&&{prev:s},cur:a,samples:[...o]})})}async ingest(e,t,n){if(!e)return Y;let r=n??sA(t),i=this.entries.get(e);if(i&&r!==0&&i.transcriptMtime===r)return i.lastSeenAt=Date.now(),this.entries.delete(e),this.entries.set(e,i),this.hits++,J(i);if(!t)return i?J(i):Y;this.misses++;let a;try{a=await this.flight.run(`${e}:${r}`,()=>this.refold(e,t,this.entries.get(e)))}catch(t){return X(`usage refold (${e}): ${t instanceof Error?t.message:String(t)}`)}if(a.kind!==`ok`)return a;let o={files:a.value.files,sessionInfo:a.value.sessionInfo,days:a.value.days,transcriptMtime:a.value.mainMtime,transcriptPath:t,lastSeenAt:Date.now()};return this.entries.delete(e),this.entries.set(e,o),this.evictIfNeeded(),J(o)}async refold(e,t,n){let r=await pM(e,u(t),n===void 0?void 0:new Set(n.files.keys())),i=new Map,a=0;for(let e of[t,...r]){let r=n?.files.get(e),o=await bM(e,r?.cursor);if(o.kind===`failed`)return o;if(o.kind===`absent`){r&&i.set(e,r);continue}let{entries:s,cursor:c,reset:l}=o.value;i.set(e,await AM(r,l,s,c)),e===t&&(a=c.mtimeMs)}return J({files:i,...jM(i),mainMtime:a})}ensureSeeded(e,t){this.seededDay!==e&&(this.seeded.clear(),this.seededDay=e);let n=t.join(`\0`),r=this.seeded.get(n);if(r)return r;let i=this.seed(t);return this.seeded.set(n,i),i.catch(()=>{this.seeded.get(n)===i&&this.seeded.delete(n)}),i}async seed(e){let t=OM(),n=await fM(e),r=[];for(let e of n){let n;try{n=await uA(e)}catch{continue}for(let i of n){if(!i.endsWith(`.jsonl`))continue;let n=f(e,i),a;try{a=(await fA(n)).mtimeMs}catch{continue}a<t||r.push({sessionId:i.slice(0,-6),path:n,mtime:a})}}await MM(r,8,async e=>{let t=await this.ingest(e.sessionId,e.path,e.mtime);t.kind===`failed`&&this.log(`warn`,`usageStore seed: ${t.reason}`)}),this.seeds++,this.log(`info`,`usageStore seed sessions=${r.length} dirs=${e.join(`,`)}`)}sweepStale(){let e=Date.now(),t=0;for(let[n,r]of this.entries)e-r.lastSeenAt>this.staleAgeMs&&(this.entries.delete(n),this.speedRings.delete(n),t++);return t>0&&(this.sweeps++,this.log(`info`,`usageStore sweep dropped=${t}`)),t}evictIfNeeded(){for(;this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.entries.delete(e),this.speedRings.delete(e),this.log(`info`,`usageStore evict ${e}`)}}close(){this.sweepTimer&&=(clearInterval(this.sweepTimer),null),this.entries.clear(),this.seeded.clear(),this.speedRings.clear()}},PM=class{thresholds={LOW:50,MEDIUM:80};getContextUsageThresholds(){return this.thresholds}ratioPercentages(e,t){let n=Math.min(100,Math.max(0,Math.round(e/t*100)));return{percentage:n,contextLeftPercentage:Math.max(0,100-n)}}calculateContextFromHookData(e){let t=e.context_window;if(!t?.current_usage)return O(`No current_usage in hook data, falling back to transcript parsing`),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);O(`Native current_usage: input=${n.input_tokens}, cache_create=${n.cache_creation_input_tokens}, cache_read=${n.cache_read_input_tokens}, total=${i} (limit: ${r})`);let a=this.ratioPercentages(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)}}async calculateContextTokensFromTranscript(e,t){try{O(`Calculating context tokens from transcript: ${e}`);let n=await gM(e);if(n.length===0)return O(`No entries in transcript`),Y;let r=null;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t&&t.message?.usage?.input_tokens&&t.isSidechain!==!0){r=t,O(`Context segment: Found most recent entry at ${t.timestamp.toISOString()}, stopping search`);break}}if(r?.message?.usage){let e=r.message.usage,n=(e.input_tokens||0)+(e.cache_read_input_tokens||0)+(e.cache_creation_input_tokens||0);return O(`Most recent main chain context: ${n} tokens (limit: ${t})`),J({totalTokens:n,maxTokens:t,...this.ratioPercentages(n,t)})}return O(`No main chain entries with usage data found`),Y}catch(e){return X(`context transcript: ${e instanceof Error?e.message:String(e)}`)}}async getContextInfo(e){let t=this.calculateContextFromHookData(e);if(t)return J(t);let n=e.context_window?.context_window_size??2e5;return this.calculateContextTokensFromTranscript(e.transcript_path,n)}},FM=class{states=new Map;constructor(e,t,n=256){this.empty=e,this.step=t,this.maxSessions=n}async read(e,t){let n=this.states.get(e),r=sA(t);if(n&&r!==0&&n.cursor.mtimeMs===r)return this.touch(e,n),{kind:`ok`,value:n.value};let i=await bM(t,n?.cursor);if(i.kind===`failed`)return i;if(i.kind===`absent`)return{kind:`ok`,value:n?.value??this.empty};let{entries:a,cursor:o,reset:s}=i.value,c=s||n===void 0?this.empty:n.value;for(let e of a)c=this.step(c,e);for(this.touch(e,{cursor:o,value:c});this.states.size>this.maxSessions;){let e=this.states.keys().next().value;if(e===void 0)break;this.states.delete(e)}return{kind:`ok`,value:c}}touch(e,t){this.states.delete(e),this.states.set(e,t)}};const IM={messageCount:0,recent:[]};function LM(e,t){if(t.isSidechain)return e;let n=[...e.recent,t];return{messageCount:e.messageCount+ +!!mM(t),recent:n.length>20?n.slice(-20):n}}function RM(e){let t=null,n=null;for(let r of e){let e=r.type||r.message?.role||r.message?.type;if(mM(r))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 zM=class{fold=new FM(IM,LM);async getMetricsInfo(e,t){if(O(`Getting metrics from hook data for session: ${e}`),!t.cost)return Y;let n=await this.fold.read(e,t.transcript_path);return n.kind===`failed`?X(`metrics (${e}): ${n.reason}`):J({responseTime:t.cost.total_api_duration_ms/1e3,lastResponseTime:RM(n.value.recent),sessionDuration:t.cost.total_duration_ms/1e3,messageCount:n.value.messageCount,linesAdded:t.cost.total_lines_added,linesRemoved:t.cost.total_lines_removed})}};const BM={command:null,todos:[],pending:[],done:[]};function VM(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 HM(e,t){if(t.isSidechain)return e;let n=mM(t)?{...e,command:t.activity?.command??null,pending:[],done:[]}:e,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=VM(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 UM(e){return{command:e.command,todos:e.todos,running:e.pending.reduce((e,t)=>VM(e,t.name),[]),done:e.done}}var WM=class{fold=new FM(BM,HM);async getActivityInfo(e,t){let n=await this.fold.read(e,t.transcript_path);return n.kind===`failed`?X(`activity (${e}): ${n.reason}`):J(UM(n.value))}};function GM(e,t,n,r){return{bin:`tmux`,args:[`-S`,e.socket,...n],timeoutMs:2e3,category:t,stdinInput:r}}function KM(e,t){if(e.ok)return{kind:`ok`,stdout:e.stdout};if(e.reason===`rate-limited`)return{kind:`rate-limited`,reason:e.error??`rate-limited`};let n=e.error??[e.reason,e.stderr.trim()].filter(e=>e!==``).join(`: `);return{kind:`failed`,reason:`tmux ${t[0]} failed (${n})`}}function qM(e,t,n,r){return KM(ke(GM(e,t,n,r)),n)}async function JM(e,t,n){return KM(await Oe(GM(e,t,n)),n)}const YM=e=>`${e.socket}\n${e.pane}`;var XM=class{names=new Map;asking=new SM;constructor(e=Date.now){this.now=e}getSessionName(e){let t=YM(e),n=this.names.get(t);if(n&&this.now()-n.at<3e4)return Promise.resolve(n.outcome);let r=this.asking.run(t,()=>this.ask(t,e));return n?Promise.resolve(n.outcome):r}async ask(e,t){O(`Getting tmux session name for pane ${t.pane} on ${t.socket}`);let n=await JM(t,`tmux`,[`display-message`,`-p`,`-t`,t.pane,`#S`]),r=n.kind===`ok`?n.stdout.trim():``,i=n.kind===`ok`?r?J(r):Y:X(n.reason);for(this.names.delete(e),this.names.set(e,{outcome:i,at:this.now()});this.names.size>64;)this.names.delete(this.names.keys().next().value);return i}};const ZM=e=>JSON.stringify([e.sessionId,e.projectDir,e.cwd,e.claudeConfigDir,e.env===void 0?null:Ye.map(t=>e.env?.[t]??null)]);var QM=class{readings=new Map;inFlight=new Map;constructor(e,t=Date.now){this.edge=e,this.now=t}getCeiling(e){let t=ZM(e),n=this.readings.get(t);if(n&&this.now()-n.at<1e4)return Promise.resolve(n.outcome);let r=this.inFlight.get(t)??this.fetch(t,e);return n?Promise.resolve(n.outcome):r}fetch(e,t){let n=this.edge.locate(t),r=(n.kind===`ok`?this.edge.read(n.value,t):Promise.resolve(n)).then(t=>{if(this.inFlight.get(e)!==r)return t;for(this.readings.delete(e),this.readings.set(e,{outcome:t,at:this.now()});this.readings.size>64;)this.readings.delete(this.readings.keys().next().value);return t}).finally(()=>{this.inFlight.get(e)===r&&this.inFlight.delete(e)});return this.inFlight.set(e,r),r}move(e,t){let n=this.edge.locate(e);if(n.kind!==`ok`)throw Error(n.kind===`failed`?n.reason:`memento is not installed or not enabled for this project`);let r=ZM(e);try{this.edge.move(n.value,e,t)}finally{this.readings.delete(r),this.inFlight.delete(r),this.fetch(r,e)}}};function $M(e){return{gitProvider:new cb({watchers:e.watchers,logger:e.logger}),usageStore:new NM({logger:e.logger}),contextProvider:new PM,metricsProvider:new zM,activityProvider:new WM,tmuxService:new XM,mementoProvider:new QM(jA()),autoCompact:cS,log:e.logger}}function eN(e,t){return e===void 0?!0:e.evaluate(t).map(e=>e.plain).join(``)!==`false`}function tN(e,t){let n=H.fromFragments(e);return n.end=``,n.overflow=`ignore`,t!==void 0&&!t.isNull&&(n.style=t),n}function nN(e,t,n){e.cellLength>t?e.truncate(t,{mode:n.truncate,marker:`…`}):e.cellLength<t&&e.align(n.justify,t)}function rN({lead:e,text:t,trail:n}){return[...e===void 0?[]:[e],t,...n===void 0?[]:[n]]}function iN(e){let t=rN(e);if(t.length===1)return e.text;let n=tN(t);return n.style=e.text.style,n}function aN(e,t){let{width:n,justify:r,truncate:i,baseStyle:a,padding:o,lead:s=[],trail:c=[]}=t;if(e.length===0)return[];let l=tN(e,a).pad(o),u=new H(` `.repeat(o)),d={...s.length>0&&{lead:tN([u,...s],a)},...c.length>0&&{trail:tN([...c,u],a)}};if(n===`auto`)return[{text:l,...d}];let f={justify:r,truncate:i};return n===`fill`?[{text:l,fill:f,...d}]:(nN(l,n,f),[{text:l,...d}])}const oN=RegExp(`\\x1b\\[[0-9;]*m|${bi.source}`,`g`);function sN(e){return M(e.replace(oN,``))}function cN(e,t){let n=e.map(iN),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=ak(n,t).split(`
191
- `);if(i.length>1)return n;let a=Math.max(0,t.width-sN(i[0]??``)),o=Math.floor(a/r.length),s=a-o*r.length;return r.forEach(({at:t,how:i},a)=>{let c=o+(a===r.length-1?s:0),{text:l}=e[t];nN(l,l.cellLength+c,i),n[t]=iN(e[t])}),n}function lN(e,t){let n=[],r=[],i=()=>{if(!r.length)return;let e=uN(r,t);e.plain.length>0&&n.push(e),r=[]};for(let a of e)if(fN(a.style).link){i();let e=uN([a],t);e.plain.length>0&&n.push(e)}else r.push(a);return i(),n}function uN(e,t){let n=t!==void 0&&!t.isNull?e.map(e=>dN(e,t)):e,r=H.fromFragments(n);return r.end=``,r.overflow=`ignore`,n.length===1?r.style=n[0].style:t!==void 0&&!t.isNull&&(r.style=t),r}function dN(e,t){let n=e.copy();return n.style=t.add(fN(e.style)),n}function fN(e){return e instanceof B?e:B.parse(e)}function pN(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,mN(e,t,o,n,r,i));return i}function mN(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=ox(n.from,i);return{kind:`set-option`,key:n.set,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,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=Rb.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=ox(n.from,i);return{kind:`persist-option`,key:n.persist,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,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=ox(n.insertSegmentFrom,i);return{kind:`layout-op-option`,key:n.persist,anchor:n.anchor,relation:n.relation,options:[...e.members],paletteOf:e.paletteOf,library:e.library}}return{kind:`persist-bounded`,key:n.persist,by:n.by}}if(`copy`in n)return{kind:`copy`,text:_N(e,n.copy,t)};if(`open`in n)return{kind:`open`,target:_N(e,n.open,t)};if(`reset`in n)return{kind:`reset`,key:n.reset};if(`doctor`in n)return n.doctor===`run`?{kind:`doctor-run`}:{kind:`doctor-fix`,check:n.check};if(`ceiling`in n)return{kind:`ceiling`,args:mw(n)};if(`slash`in n)return{kind:`slash`,line:n.slash};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:_N(e,n.name,t)};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 hN(e){return e.kind===`do`?hN(e.head):e}function gN(e){switch(hN(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`doctor-run`:case`doctor-fix`:case`ceiling`:case`slash`:case`do`:return!1}}function _N(e,t,n){try{return e(t)}catch(e){throw Error(`Template parse error in actions.${n}: ${e.message}`,{cause:e})}}function vN(e,t){return e.has(t)?Av(e.read(t)):``}function yN(e,t){return e.evaluate(t).map(e=>e.plain).join(``)}function bN(e,t,n,r){let i=new H(e,{style:B.combine([r,new B({link:t,bold:n})])});return i.overflow=`ignore`,i.end=``,i}function xN(e,t){return Math.max(e.members.indexOf(vN(t,e.stateVar)),0)}function SN(e,t,n,r,i){switch(e.kind){case`set-literal`:{let t=vN(r,e.stateVar);return{effects:[{verb:cD,args:[i,e.key,e.value]}],active:t===e.value}}case`set-option`:{let a=n??t,o=vN(r,e.stateVar);return{effects:[{verb:cD,args:[i,e.key,a]}],active:o===a}}case`set-int`:{let a=n??t,o=vN(r,e.stateVar);return{effects:[{verb:cD,args:[i,e.key,a]}],active:o===a}}case`set-cycle`:{let t=e.members[(xN(e,r)+1)%e.members.length];return{effects:[{verb:cD,args:[i,e.key,t]}],active:!1}}case`set-bounded`:return{effects:[{verb:lD,args:[i,e.key,String(e.by)]}],active:!1};case`copy`:return{effects:[{verb:uD,args:[yN(e.text,Sy(r))]}],active:!1};case`open`:return{effects:[{verb:dD,args:[yN(e.target,Sy(r))]}],active:!1};case`persist-literal`:{let t=vN(r,e.stateVar);return{effects:[{verb:hD,args:[i,e.key,e.value]}],active:t===e.value}}case`persist-option`:{let a=n??t,o=vN(r,e.stateVar);return{effects:[{verb:hD,args:[i,e.key,a]}],active:o===a}}case`persist-cycle`:{let t=e.members[(xN(e,r)+1)%e.members.length];return{effects:[{verb:hD,args:[i,e.key,t]}],active:!1}}case`persist-bounded`:return{effects:[{verb:gD,args:[i,e.key,String(e.by)]}],active:!1};case`reset`:return{effects:[{verb:bD,args:[i,e.key]}],active:!1};case`undo`:return{effects:[{verb:SD,args:[i]}],active:!1};case`redo`:return{effects:[{verb:CD,args:[i]}],active:!1};case`back`:return{effects:[{verb:wD,args:[i]}],active:!1};case`rewind`:return{effects:[{verb:TD,args:[i]}],active:!1};case`save`:return{effects:[{verb:_D,args:[i]}],active:!1};case`preset-save`:return{effects:[{verb:vD,args:[i]}],active:!1};case`preset-delete`:return{effects:[{verb:yD,args:[i,yN(e.name,Sy(r))]}],active:!1};case`doctor-run`:return{effects:[{verb:DD,args:[i]}],active:!1};case`doctor-fix`:return{effects:[{verb:OD,args:[i,e.check]}],active:!1};case`ceiling`:return{effects:[{verb:kD,args:[i,...e.args]}],active:!1};case`slash`:return{effects:[{verb:AD,args:[i,e.line]}],active:!1};case`layout-op`:return{effects:[{verb:xD,args:[i,e.key,Dk(e.op)]}],active:!1};case`do`:{let a=SN(e.head,t,n,r,i);return{effects:[...a.effects,...e.rest.flatMap(e=>SN(e,t,void 0,r,i).effects)],active:a.active}}case`layout-op-option`:{let r={op:`insert`,segment:n??t,anchor:e.anchor,relation:e.relation};return{effects:[{verb:xD,args:[i,e.key,Dk(r)]}],active:!1}}}}function CN(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:qc(`action "${e}"`,n,t.members.length,xN(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]}}function wN(e,t,n){let r=n.compiled.get(e);if(!r)throw Error(`action "${e}" is not declared in this config`);let i=n.store,{display:a,boundValue:o}=CN(e,hN(r),t,i),{effects:s,active:c}=SN(r,a,o,i,vN(i,`session.id`));return bN(a,ND(s),c)}function TN(e){return{action:{fn:(t,...n)=>wN(t,n,e),argTypes:[`string`,`string`],arity:{kind:`variadic`},returnType:`T`}}}function EN(e,t){return bN(`✕`,ND([{verb:cD,args:[vN(e,`session.id`),t,Wc]}]),!1)}function DN(e,t,n){return new B({bgcolor:vn.fromRgba(t),color:vn.fromRgba(Aa(e,t,n))})}function ON(e,t,n){return new B({color:vn.fromRgba(sr(ba(e,`warning`),t,ka,n))})}function kN(e,t,n){return B.combine([DN(e,t,n),ON(e,t,n)])}function AN(e,t,n){return DN(e.palette,Ua(e.palette,e.disclosure,[t],n),n)}function jN(e,t,n,r,i,a){return r===void 0?n=>AN(e,{...n,distribution:t},i):(e,t)=>MN(r(t,n),a,i)}function MN(e,t,n){return new B({bgcolor:vn.fromRgba(t),color:vn.fromRgba(sr(ba(e,`primary`),t,4.5,n))})}function NN(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=>PN(e.indices,8).map(t=>[{label:e.label,indices:t}])):[r]}function PN(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))}function FN(e,t){return new H(e).truncate(t,{marker:`…`}).plain}function IN(e){return{current:null,drawnAt:e}}function LN(e,t,n,r,i,a){let o={segName:t,placementId:n,palette:r,disclosure:i,tint:a,bg:void 0,drops:[]};return e.current=o,o}function RN(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 zN(e){return new H(e).cellLength}function BN(e){return Math.max(1,e.width-e.chromeCols-2*e.padding)}function VN(e){return Math.max(1,BN(e)-(zN(`✕`)+2*e.padding+e.seamCols))}function HN(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 UN(e,t,n){let r=zN(`←`)+1+zN(`→`)+1,i=HN(e,t,n);return(i.length>1?HN(e,t,n+r):i).map(e=>[{label:``,indices:e}])}function WN(e,t){let n=[];for(let t of e)n.length>0&&n.push(new H(` `)),n.push(t);let r=H.fromFragments(n);return r.overflow=t?`ignore`:void 0,r.end=``,r}function GN(e,t,n,r){let i=e.compiled.get(t);if(!i||i.kind!==n)throw Error(`picker references action "${t}" which must be ${r}, got ${i?`a ${i.kind} action`:`no such action`}`);return i}function KN(e,t,n){let r=e.compiled.get(t),i=r&&hN(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 qN(e,t,n,r,i,a,o){let s=KN(i,e,`picker`),c=i.compiled.get(e),l=i.store,u=vN(l,`session.id`),d=`stateVar`in s?vN(l,s.stateVar):void 0,f=r?n.kind===`led`?VN(i):BN(i):1/0,p=n.kind===`led`?0:zN(`✕`)+1,m=s.library&&{groups:s.library.groups,entries:s.options.map(s.library.entry)},h=m===void 0?UN(s.options.map(zN),f,p):NN(m.entries,m.groups,r),g=parseInt(vN(l,t.stateVar),10),_=Number.isInteger(g)?Math.max(0,Math.min(g,h.length-1)):0,v=h[_]??[],y=e=>ND([{verb:cD,args:[u,t.key,String(e)]}]),b=n.kind===`led`?[]:[{verb:cD,args:[u,...n.writes.flatMap(([e,t])=>[e,t])]}],x=n.kind===`own`&&n.onPick?b:[],S=e=>ND([...SN(c,e,e,l,u).effects,...x]),C=(e,t)=>{let n=s.options[e];return bN(t,S(n),n===d,a({index:e,count:s.options.length},n))},w=n.kind===`led`?[]:[bN(`✕`,ND(b),!1,o)];_>0&&w.push(bN(`←`,y(_-1),!1));let ee=_<h.length-1?[bN(`→`,y(_+1),!1)]:[];if(m===void 0){let e=v.flatMap(e=>e.indices);return[WN([...w,...e.map(e=>C(e,s.options[e])),...ee],r)]}let te=new B({bold:!0}),ne=h.length>1?` ${_+1}/${h.length}`:``,T=v.length===1?[new H(`${v[0].label}${ne}`,{style:te})]:[],re=[WN([...w,...T,...ee],r)];for(let e of v){v.length>1&&re.push(WN([new H(e.label,{style:te})],r));let t=Math.max(...e.indices.map(e=>zN(s.options[e])));for(let n of e.indices){let e=s.options[n],i=m.entries[n].description,a=i===void 0?void 0:GO(i),o=` `.repeat(t-zN(e)+2),c=a===void 0?e:`${e}${o}${a}`;re.push(WN([C(n,FN(c,f))],r))}}return re}function JN(e,t){return{picker:{fn:(n,r,i,a,o,...s)=>{gy(`picker "${n}"`,[`closeOnPick`,`paged`,`inBody`],s);let c=GN(e,r,`set-int`,`an int action ({ set, int: true })`);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=KN(e,n,`picker`);if(l.library!==void 0)throw Error(`{{ picker "${n}" … }} ranges a catalogue domain, which lays out as one row per member; a catalogue renders in a {{ menu }} body`);let u=RN(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]=qN(n,{key:c.key,stateVar:c.stateVar},o===!0?{kind:`led`}:{kind:`own`,writes:[[c.key,`-1`]],onPick:i===!0},a===!0,e,jN(u,pa(void 0),e,l.paletteOf,t.drawnAt(),u.bg),ON(u.palette,u.bg,t.drawnAt()));return d},argTypes:[`string`,`string`,`bool`],arity:{kind:`variadic`},returnType:`T`}}}function YN(e,t,n,r,i){let a=Math.min(Math.floor((t-1)/2),i),o=n,s=0;for(;s<a;){let t=o+zN(e(-(s+1)))+1+zN(e(s+1))+1;if(t>r)break;o=t,s+=1}return s}function XN(e,t,n,r,i,a){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 o=n.store;if(!o.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 s=n.compiled.get(e),c=vN(o,`session.id`),{options:l}=t,u=l.length;if(u===0)return WN([],!0);let d=vN(o,t.stateVar),f=Math.max(l.indexOf(d),0),p=e=>((f+e)%u+u)%u,m=e=>l[p(e)],h=new Map,g=e=>{let t=h.get(e);if(t!==void 0)return t;let n=ND(SN(s,m(e),m(e),o,c).effects);return h.set(e,n),n},_=e=>bN(m(e),g(e),m(e)===d,r({index:p(e),count:u},m(e))),v=a===void 0?_(0):bN(m(0),ND(SN(n.compiled.get(a),m(0),void 0,o,c).effects),!1),y=YN(m,u,zN(`◀`)+1+v.cellLength+1+zN(`▶`),VN(n),i),b=e=>Array.from({length:y},(t,n)=>_(e*(n+1)));return WN([...b(-1).reverse(),bN(`◀`,g(-1),!1),v,bN(`▶`,g(1),!1),...b(1)],!0)}function ZN(e,t){return{carousel:{fn:(n,...r)=>{let[i,a,...o]=r;if(gy(`carousel "${n}"`,[`neighbours`,`centre`],o),i!==void 0&&!(Number.isInteger(i)&&i>=0))throw Error(`carousel "${n}": neighbours must be a whole number ≥ 0 (0 shows only ◀ CURRENT ▶), got ${String(i)}`);if(a!==void 0&&!(typeof a==`string`&&e.compiled.has(a)))throw Error(`carousel "${n}": centre must name a declared action, got ${JSON.stringify(a)}`);if(a!==void 0&&gN(e.compiled.get(a)))throw Error(`carousel "${n}": centre "${a}" writes a value the template binds, and the centre binds none — name an action that writes a fixed value, a cycle, or a do of them`);let s=i??1/0,c=KN(e,n,`carousel`),l=RN(t,`{{ carousel }}`);if(l.bg===void 0)throw Error(`{{ carousel }} is not available while segments.${l.segName}'s own "bg:" is being evaluated — a carousel is drawn on that background`);return XN(n,c,e,jN(l,pa(void 0),e,c.paletteOf,t.drawnAt(),l.bg),s,a)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}const QN=[`~/code`,`main`,`opus`,`42%`,`5m`,`$1.20`];function $N(e,t,n){let r=Ia(e,{hue:oa,depth:0},n);return[sa(t.hues).map((t,n)=>({text:QN[n%QN.length],colour:xa(e,t)})),[{text:`▾ open`,colour:r.state},{text:`menu`,colour:r.plane}],[{text:`warn`,colour:ba(e,`warning`)},{text:`error`,colour:ba(e,`error`)}]]}function eP(e,t,n,r){let i=$N(e,t,n).flatMap((t,r)=>t.map(({text:t,colour:i},a)=>({gap:r>0&&a===0?` `:``,cell:new H(` ${t} `,{style:DN(e,i,n)})}))),a=[],o=0;for(let{gap:e,cell:t}of i){if(o+=e.length+t.cellLength,o>r)break;e!==``&&a.push(new H(e)),a.push(t)}let s=H.fromFragments(a);return s.overflow=`ignore`,s.end=``,s}function tP(e,t){return{themePreview:{fn:()=>eP(e.palette,e.variation,t.drawnAt(),VN(e)),argTypes:[],arity:{kind:`exact`},returnType:`T`}}}const nP=e=>e.slice(e.lastIndexOf(`.`)+1),rP=(e,t)=>{let n=new H(nP(e));return n.truncate(t,{marker:`…`}),n.plain};function iP(e,t){let n=e.map(e=>e.map(({name:e})=>zN(nP(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 aP(e,t,n,r){let i=iP(e,r),a=e.map(e=>{let a=[],o=0;for(let{name:s,address:c,palette:l}of e){let e=new H(` ${rP(s,i)} `,{style:DN(l,qa(l,{kind:`bar`,variation:t,address:c},n).tint,n)});if(o+=e.cellLength,o>r)break;a.push(e)}return a}),o=H.fromFragments(a.flatMap((e,t)=>t===0?e:[new H(`
192
- `),...e]));return o.overflow=`ignore`,o.end=``,o}function oP(e,t){return{layoutPreview:{fn:()=>aP(e.layout(),e.variation,t.drawnAt(),VN(e)),argTypes:[],arity:{kind:`exact`},returnType:`T`}}}function sP(e,t,n,r){let i=RN(r.activeSegment,`{{ menu }}`),a=r.action,o=__(i.placementId,e,n.key),s=b_(o),c=g_(e),l=vN(a.store,o)===c,u=vN(a.store,`session.id`),d=l?Wc:c,f=bN(qc(`{{ menu "${e}" }}`,t,2,+!!l),ND([{verb:cD,args:[u,o,d,s,`0`]}]),!1);return i.drops.push(...l?(()=>{let t=r.activeSegment.drawnAt(),c=Ia(i.palette,i.disclosure,t).plane;return qN(e,{key:s,stateVar:s},{kind:`own`,writes:[[o,Wc],[s,`0`]],onPick:n.closeOnPick},n.paged,a,jN(i,n.distribution,a,KN(a,e,`menu`).paletteOf,t,c),ON(i.palette,c,t))})():[]),f}const cP=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function lP(e,t){let n=t[t.length-1],r=cP(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:w_(r??{})}}function uP(e){return{menu:{fn:(t,...n)=>{let{displays:r,options:i}=lP(t,n);return sP(t,r,i,e)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function dP(e){let{value:t,max:n,width:r,filled:i,empty:a,colourAt:o}=e,s=fP(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 H(t?i:a,{style:l===void 0?void 0:new B({color:l})}))}let l=H.fromFragments(c);return l.end=``,l.overflow=`ignore`,l}function fP(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 pP(e){let t={fn:(()=>{let t=RN(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:(()=>RN(e,`{{ tint }}`).tint.hex),argTypes:[],arity:{kind:`exact`},returnType:`string`},r=ny(()=>RN(e,`{{ color }} / {{ ramp }} / {{ gauge }}`).palette),i={fn:((e,t,n,i,a,o,...s)=>{let c=o===void 0?void 0:[o,...mP(s)];return dP({value:e,max:t,width:n,filled:i,empty:a,colourAt:c===void 0?void 0:e=>String(r.ramp.fn(e,...c))})}),argTypes:[`float`,`float`,`int`,`string`,`string`,`string`],arity:{kind:`variadic`},returnType:`T`};return{...r,bgOf:t,tint:n,gauge:i}}function mP(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 hP(e){let t=[],n=[];for(let r of e){if(!r.contains(`
190
+ `,c.join(e,`lib`),t.sessionId,t.cwd],env:MA(t),timeoutMs:3e3,category:`memento.read`});return n.ok?PA(n.stdout):X(NA(n))}function IA(e,t,n){let r=ke({bin:c.join(e,OA),args:n.kind===`set`?[`set`,`session`,n.to]:[`clear`,`session`],env:MA(t),timeoutMs:5e3,category:`memento.move`});if(!r.ok)throw Error(NA(r))}function LA(){return{locate:e=>jA(oS(e.claudeConfigDir),e.projectDir),read:FA,move:IA}}function RA(e,t,n){let r=n===void 0?``:`CLAUDE_CONFIG_DIR=${JD(n)} `,i=e.added_dirs.map(e=>` --add-dir ${JD(e)}`).join(``);return`cd ${JD(e.project_dir)} && ${r}claude --resume ${JD(t)}${i}`}function zA(e,t,n){let r=O_(t(`preset`),e.globals.preset,e.presets),i=j_(e,r),a=t(`edit.mode`)===`arrange`?e.editGlobals:{};return{preset:r,presetCustomized:n(r),theme:$b(a.palette,t(`theme`),i.palette),style:uo(a.style,t(`style`),i.style,e.styles),endcaps:mo(a.endcaps,t(`endcaps`),i.endcaps),variation:xo(a.variation,t(`variation`),i.variation),separator:a.default_separator??i.default_separator,autoWrap:Oo(a.autoWrap,t(`autoWrap`),i.autoWrap),padding:Ao(a.padding,t(`padding`),i.padding),charset:a.charset??i.charset??`unicode`,updateNotice:ko(a.updateNotice,t(`updateNotice`),i.updateNotice),colorCompatibility:a.colorCompatibility??i.colorCompatibility??`truecolor`}}function BA(e,t){return{endcaps:e.endcaps,separator:e.separator,colorCompatibility:e.colorCompatibility,wrap:e.autoWrap,padding:e.padding,charset:e.charset,width:t}}function VA(e){return{theme:e.theme,style:e.style,preset:e.preset,variation:e.variation}}function HA(e){return{preset:{effective:e.preset,customized:e.presetCustomized,bundled:fA(e.preset)},endcaps:{effective:e.endcaps},variation:{effective:e.variation},charset:{effective:e.charset},colorCompatibility:{effective:e.colorCompatibility},autoWrap:{effective:e.autoWrap},padding:{effective:e.padding},updateNotice:{effective:e.updateNotice}}}const UA=10*1e3;function WA(e,t,n,r){let i=n-(t*1e3-r);if(i<3e5||e<=0)return;let a=e/i,o=(100-e)/a;return Math.max(0,Math.round(o/6e4))}function GA(e,t){if(!(t<60))return e*3600/t}function KA(e,t,n,r){let i=r-t;if(i<50||i>UA)return;let a=n-e;if(!(a<=0))return a*1e3/i}function qA(e){let{prev:t,cur:n}=e;if(t===void 0)return;let r=KA(t.input,t.atMs,n.input,n.atMs),i=KA(t.output,t.atMs,n.output,n.atMs),a=KA(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 JA(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>UA)continue;let o=KA(r.total,r.atMs,i.total,i.atMs);n.push(o??0)}if(n.length!==0)return n.join(`,`)}function YA(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}function XA(e){let t=[],n=(e,n)=>{try{let e=n();return e===``?void 0:e}catch(n){t.push(`host.${e}: ${String(n)}`);return}},r=n(`name`,()=>YA(m.hostname())),i=n(`user`,()=>m.userInfo().username);return{host:{...r!==void 0&&{name:r},...i!==void 0&&{user:i},...e.ssh!==void 0&&{ssh:e.ssh}},failures:t}}function ZA(e,t){let n=new Map;for(let[t,r]of Object.entries(e.variables))n.set(t,r);for(let[t,r]of Object.entries(e.segments))if(r.vars)for(let[e,i]of Object.entries(r.vars))n.set(`${t}.${e}`,i);let r=[],i=new Set,a=t=>_v(t,e.helpers).keys(),o=j_(e,t);for(let e of ro){let t=o[e];if(io(t))for(let e of a(t))r.push(e)}for(let n of Ms(A_(e,t).node)){if(n.when)for(let e of a(n.when))r.push(e);if(n.kind!==`segment`)continue;let t=e.segments[n.name];if(t){for(let e of[t.template,t.when,t.bg,t.fg])if(e)for(let t of a(e))r.push(t)}}let s=new Set;for(;r.length>0;){let e=r.pop();for(let t of $A(n,e)){if(i.has(t))continue;i.add(t);let e=n.get(t);if(e){if(e.kind===`input`)s.add(e.path);else if(e.kind===`template`)for(let t of a(e.template))r.push(t)}}}return s}function QA(e){let t=new Map;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=ZA(e,n);return t.set(n,i),i}}function $A(e,t){let n=t;for(;n.length>0;){if(e.has(n))return[n];let t=n.lastIndexOf(`.`);if(t<0)break;n=n.slice(0,t)}let r=`${t}.`,i=[];for(let t of e.keys())t.startsWith(r)&&i.push(t);return i}function ej(e,t){for(let n of e)if(n===t||n.startsWith(t+`.`))return!0;return!1}function tj(e){let t=t=>e.has(t),n=t(`git.staged`)||t(`git.unstaged`)||t(`git.untracked`)||t(`git.conflicts`);return{...t(`git.sha`)&&{showSha:!0},...n&&{showWorkingTree:!0},...t(`git.stash`)&&{showStashCount:!0},...t(`git.upstream`)&&{showUpstream:!0},...t(`git.repoName`)&&{showRepoName:!0},...t(`git.repoUrl`)&&{showRepoUrl:!0},...t(`git.operation`)&&{showOperation:!0},...t(`git.timeSinceCommit`)&&{showTimeSinceCommit:!0},...(t(`git.prNumber`)||t(`git.prState`)||t(`git.prUrl`)||t(`git.prError`))&&{showPullRequest:!0}}}async function nj(e,t,n,r,i,a,{configPath:o,...s}){let c=e=>ej(r,e),l=(t.clock??(()=>new Date))().getTime(),u=a.tmux??null,d=(e,t,n)=>t?n().catch(t=>X(`${e}: ${String(t)}`)):Promise.resolve(Y),[f,p,m,h,g,_,v,y,b,x,S]=await Promise.all([d(`git`,c(`git`),()=>t.gitProvider.getGitInfo(n??e.workspace?.current_dir,tj(r),e.workspace?.project_dir)),d(`session`,c(`session.cost`)||c(`session.tokens`)||c(`burn`),()=>t.usageStore.getUsageInfo(e.session_id,e)),d(`today`,c(`today`),()=>t.usageStore.getTodayInfo(e,a.claudeConfigDir)),d(`context`,c(`context`)||c(`autocompact`),()=>t.contextProvider.getContextInfo(e)),d(`metrics`,c(`metrics`)||c(`burn`),()=>t.metricsProvider.getMetricsInfo(e.session_id,e)),d(`activity`,c(`activity`),()=>t.activityProvider.getActivityInfo(e.session_id,e)),d(`tmux`,c(`tmux.session`),()=>u===null?Promise.resolve(Y):t.tmuxService.getSessionName(u)),d(`cache`,c(`cache`),()=>CA(e.transcript_path)),d(`speed`,c(`speed`),()=>t.usageStore.observeSpeed(e.session_id,e.transcript_path,l)),d(`memento`,c(`memento`),()=>t.mementoProvider.getCeiling(EA({sessionId:e.session_id,projectDir:e.workspace?.project_dir??``,cwd:n??e.workspace?.current_dir??``},a))),d(`autocompact`,c(`autocompact`),()=>Promise.resolve(t.autoCompact(aS(iS(a.claudeConfigDir)))))]),C=[],w=e=>{if(e.kind===`failed`){C.push(e.reason);return}return e.kind===`ok`?e.value:void 0},T=uj(f);C.push(...T.failures);let ee=XA(a);C.push(...ee.failures);let te=w(p),ne=w(m),re=w(h),E=w(g),D=w(_),ie=w(v),ae=w(y),oe=aj(x);x.kind===`failed`&&C.push(`memento: ${x.reason}`);let se=rj(S,re?.maxTokens);S.kind===`failed`&&C.push(`autocompact: ${S.reason}`);for(let e of C)t.log(`warn`,`provider fetch failed: ${e}`);let ce=e.rate_limits?.five_hour,le=e.rate_limits?.seven_day,ue=ce?WA(ce.used_percentage,ce.resets_at,18e6,l):void 0,de=le?WA(le.used_percentage,le.resets_at,6048e5,l):void 0,fe=te?.session.cost,pe=E?.sessionDuration,me=c(`burn`)&&fe!=null&&pe!=null?GA(fe,pe):void 0,he=w(b),ge=he===void 0?void 0:qA(he),_e=he===void 0?void 0:JA(he),O=ge!==void 0||_e!==void 0?{...ge,..._e!==void 0&&{history:_e}}:void 0,ve=lj(process.env.HOME??process.env.USERPROFILE),ye=e.workspace?{...e.workspace,current_dir:lj(e.workspace.current_dir)??``,project_dir:lj(e.workspace.project_dir)??``,added_dirs:(e.workspace.added_dirs??[]).map(e=>lj(e)??e)}:e.workspace,be=te===void 0?void 0:cj({cost:te.session.cost,tokens:te.session.tokens}),xe=ne===void 0?void 0:{cost:ne.cost,tokens:ne.tokens},Se=E===void 0?void 0:cj({lastResponseTime:E.lastResponseTime,responseTime:E.responseTime,sessionDuration:E.sessionDuration,messageCount:E.messageCount,linesAdded:E.linesAdded,linesRemoved:E.linesRemoved}),Ce=D===void 0?void 0:oj(D);return{...e,...ye!==void 0&&{workspace:ye},...ve!==void 0&&{home:ve},...T.git!==void 0&&{git:T.git},...u!==null&&{tmux:{pane:u.pane,...ie!==void 0&&{session:ie}}},host:ee.host,...HA(i),history:t.history(e.session_id),navigation:{back:t.navigation(e.session_id)},...s,...o!==null&&{configPath:o},resumeCommand:RA(ye,e.session_id,a.claudeConfigDir),...be!==void 0&&{session:be},...xe!==void 0&&{today:xe},...me!==void 0&&{burn:{costPerHour:me}},...O!==void 0&&{speed:O},...c(`block`)&&ce!==void 0&&{block:{nativeUtilization:ce.used_percentage,resetsAt:ce.resets_at,...ue!==void 0&&{etaMinutes:ue}}},...le!==void 0&&{weekly:{percentage:le.used_percentage,resetsAt:le.resets_at,...de!==void 0&&{etaMinutes:de}}},...ae!==void 0&&{cache:{expiresAt:ae}},...re!==void 0&&{context:{totalTokens:re.totalTokens,contextLeft:re.contextLeftPercentage}},...Se!==void 0&&{metrics:Se},...Ce!==void 0&&{activity:Ce},...oe!==void 0&&{memento:oe},...se!==void 0&&{autocompact:se}}}function rj(e,t){switch(e.kind){case`absent`:return;case`failed`:return{error:e.reason};case`ok`:return mS(e.value,t)}}const ij=e=>e.trim().split(`
191
+ `).at(-1).trim();function aj(e){switch(e.kind){case`absent`:return;case`failed`:return{error:ij(e.reason)};case`ok`:{let{ceiling:t,session:n}=e.value;return{ceiling:t===`off`?0:t,off:t===`off`,session:n??``}}}}function oj(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=sj(e.running),i=sj(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 sj(e){return e.length===0?void 0:e.map(e=>`${e.name}:${e.count}`).join(`,`)}function cj(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 lj(e){return e===void 0||e.length===0||c.sep!==`\\`?e:e.replace(/\\/g,`/`)}function uj(e){if(e.kind===`absent`)return{failures:[]};if(e.kind===`failed`)return{failures:[e.reason]};let t=e.value,n=[],r=(e,t)=>{if(!(t===void 0||t.kind===`absent`)){if(t.kind===`failed`){n.push(`git.${e}: ${t.reason}`);return}return t.value}},i=r(`aheadBehind`,t.aheadBehind),a=r(`sha`,t.sha),o=r(`operation`,t.operation),s=r(`timeSinceCommit`,t.timeSinceCommit),c=r(`stash`,t.stashCount),l=r(`upstream`,t.upstream),u=r(`repoName`,t.repoName),d=r(`repoUrl`,t.repoUrl),f=t.pullRequest,p={};return f?.kind===`ok`?(p.prNumber=f.value.number,p.prState=f.value.state,p.prUrl=f.value.url):f?.kind===`failed`&&(n.push(`git.pr: ${f.reason}`),p.prError=f.reason),{git:{branch:t.branch,status:t.status,...i!==void 0&&{ahead:i.ahead,behind:i.behind},...t.workingTree!==void 0&&{staged:t.workingTree.staged,unstaged:t.workingTree.unstaged,untracked:t.workingTree.untracked,conflicts:t.workingTree.conflicts},...a!==void 0&&{sha:a},...o!==void 0&&{operation:o},...s!==void 0&&{timeSinceCommit:s},...c!==void 0&&{stash:c},...l!==void 0&&{upstream:l},...u!==void 0&&{repoName:u},...d!==void 0&&{repoUrl:d},...p},failures:n}}const dj={theme:e=>e.theme.kind===`decided`?e.theme.name:null,preset:e=>e.preset,style:e=>e.style.kind===`decided`?e.style.name:null,endcaps:e=>e.endcaps,variation:e=>e.variation,autoWrap:e=>e.autoWrap?So:Co,padding:e=>String(e.padding),updateNotice:e=>e.updateNotice?So:Co},fj=Object.entries(Fb),pj=new Set(Ib.map(e=>e.sessionKey)),mj=()=>!1;function hj(e,t){return zA(e,e=>pj.has(e)?t(e):null,mj)}function gj(e,t,n,r){return e.flatMap(([e,i])=>{let a=dj[e](t);return a===null||a===dj[e](n(e))?[]:[{...i,value:a,target:r(i)}]})}function _j(e,t,n){return dj[n](hj(e,t))}function vj(e,t){let n=hj(e,t),r=zA(e,()=>null,mj),i=zA(e,e=>e===Fb.preset.sessionKey?n.preset:null,mj);return gj(fj,n,e=>e===`preset`?r:i,t=>yj(e,n.preset,t.configKey))}function yj(e,t,n){return n in(k_(e.presets,t).globals??{})?gx(t,n):n}function bj(e,t,n){let r=O_(t(Fb.preset.sessionKey),e.globals.preset,e.presets),i=_x(n);return{key:i?.scope===`globals`?yj(e,r,i.field):n,globals:j_(e,r)}}function xj(e,t){let{preset:n}=hj(e,t);return wj(e,n).flatMap(({id:e,setting:r,key:i,decl:a,saved:o})=>{let s=t(i),c=s===null?void 0:qs(a,s);return c===void 0||Ks(c)===Ks(o)?[]:[{preset:n,id:e,setting:r,key:i,value:c}]})}function Sj(e,t,n){let r=new Map(n.map(e=>[e.key,e.value]));return D_(e.presets).flatMap(n=>{let i=wj(e,n);return[...new Set(i.filter(e=>r.has(e.key)).map(e=>e.id))].flatMap(e=>{let n=i.filter(t=>t.id===e);return Ws(Object.fromEntries(n.map(e=>[e.setting,e.decl])),Object.fromEntries(n.map(e=>{let n=r.get(e.key)??t(e.key),i=n===null?void 0:qs(e.decl,n);return[e.setting,i??e.saved]}))).map(({message:t})=>`placement "${e}": ${t}`)})})}const Cj=new WeakMap;function wj(e,t){let n=Cj.get(e)??new Map;Cj.set(e,n);let r=n.get(t);if(r!==void 0)return r;let i=[...Ms(A_(e,t).node)].flatMap(t=>t.kind!==`segment`||t.drafts===void 0?[]:Object.entries(t.drafts).map(([n,{id:r,key:i}])=>{let a=Hs(e.segments[t.name])[n];return{id:r,setting:n,key:i,decl:a,saved:t.settings?.[n]??a.default}})),a=[...new Map(i.map(e=>[e.key,e])).values()];return n.set(t,a),a}function Tj(e,t){let n=hj(e,t),r=zA(e,e=>e===Fb.preset.sessionKey?n.preset:null,mj);return{from:n.preset,globals:k_(e.presets,n.preset).globals??{},picks:gj(fj.filter(([e])=>e!==`preset`),n,()=>r,e=>e.configKey),placements:xj(e,t)}}function Ej(e){return{sessionKeys:Ib.filter(t=>t.configKey===e).map(e=>e.sessionKey),fileKeys:[e,...Sl(e)?dA.map(t=>gx(t,e)):[]]}}function Dj(e){return new Set(Ib.map(e=>e.configKey).filter(t=>Ej(t).fileKeys.some(t=>Aj(e,kj(t)))))}function Oj(e,t,n){let r=vj(e,n),i=new Set(r.map(e=>e.configKey)),a=Vb(e=>i.has(Fb[e].configKey)||t.has(Fb[e].configKey));return{unsaved:r.length+xj(e,n).length,resettable:a}}function kj(e){let t=_x(e);if(t===null||t.scope===`preset-root`)throw Error(`reset layer "${e}" is not a value path`);return vx(t)}function Aj(e,t){let[n,...r]=t;return n===void 0?e!==void 0:typeof e==`object`&&!!e&&Aj(e[n],r)}const jj=Qa(),Mj=new Set(jj),Nj=new Set(fo),Pj=e=>e?Mj.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${jj.join(`, `)})`}:{ok:!1,reason:`theme name is required`},Fj=e=>e?Nj.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown endcaps "${e}" (have: ${fo.join(`, `)})`}:{ok:!1,reason:`endcaps name is required`},Ij=new Set([`1`,`true`]),Lj=new Set([`0`,`false`]),Rj={endcaps:Fj,theme:Pj,"toolbar-expanded":e=>Ij.has(e)?{ok:!0,value:`1`}:Lj.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}},zj=Gk(Rj,`state`,Kj);function Bj(e,t){return zj.register(e,t)}function Vj(e){return zj.gateFor(e)}function Hj(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:sx(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 Uj(e){return e.filter(e=>e.spec.kind!==`allow-list`||!Object.hasOwn(Rj,e.key))}function Wj(e,t,n){let r=Hb.get(n);if(r!==void 0)return _j(e,t,r);let i=Object.values(e.variables).find(e=>e.kind===`state`&&e.key===n);return i?.kind===`state`?i.default??null:null}function Gj(e){let t=ax(e);return Uj(Object.values(e.actions).flatMap(e=>Hj(e,t)))}function Kj(e){return Uk(Gj(e))}const qj=`update.dismissed`,Jj=`updateNotice`,Yj=Fb.updateNotice.sessionKey;function Xj(e){return e.kind===`source`?e.newer.digest:ZD(e.newer)}const Zj=e=>`${e.version} [${Ok(e.digest)}]`;function Qj(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:Zj(e.newer),running:Zj(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:ZD(e.newer),running:ZD(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${$D}@${ZD(e.newer)}`,`install`]}}}}const $j={kind:`idle`},eM={kind:`running`};function tM(e,t,n){if(e===null)return[];let r=Xj(e);if(!n.enabled||n.dismissed===r)return[];let i=Qj(e),a=`${i.headline}: ${i.newer}. You're on ${i.running}.`,o=t.kind===`failed`&&t.identity===r?[`${i.act} failed: ${t.reason}`]:[],s=[a,...o].join(`
192
+ `),c=zD([{verb:bD,args:[s]}]),l=t.kind===`running`?gk(`[${i.busy}]`,c):gk(`[${i.act}]`,zD([{verb:MD,args:[n.sessionId]}]));return[{severity:hk,message:s,lines:[[gk(a,c),l,gk(`[dismiss]`,zD([{verb:mD,args:[n.sessionId,qj,r]}])),gk(`[disable]`,zD([{verb:xD,args:[n.sessionId,Jj,`false`]},{verb:mD,args:[n.sessionId,Yj,`false`]}]))],...o.map(e=>[gk(e,c)])]}]}function nM(e,t){return e.kind===`stale`?{kind:`source`,root:e.root,newer:e.source,running:e.running}:e.kind===`not-source-checkout`&&t!==null&&t.kind===`stale`?{kind:`release`,newer:t.latest,running:t.installed}:null}function rM(e){switch(e.kind){case`current`:return[`info`,`build: current ${Zj(e.stamp)}`];case`stale`:return[`info`,`build: stale — source ${Zj(e.source)}, running ${Zj(e.running)}`];case`not-source-checkout`:return[`info`,`build: not a source checkout`];case`unchecked`:return[`warn`,`build: unchecked: ${e.reason}`]}}function iM(e){switch(e.kind){case`current`:return[`info`,`release: current ${ZD(e.installed)}`];case`stale`:return[`info`,`release: stale — latest ${ZD(e.latest)}, running ${ZD(e.installed)}`];case`ahead`:return[`info`,`release: ahead — running ${ZD(e.installed)}, latest ${ZD(e.latest)}`];case`unchecked`:return[`warn`,`release: unchecked: ${e.reason}`]}}function aM(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const oM=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e!==``).at(-1);function sM(e){let t=e.exitCode===null?``:` (exit ${e.exitCode})`,n=oM(e.stderr)??e.error??oM(e.stdout)??`no output`;return`${e.reason}${t}: ${n}`}function cM(){let e=[qk(Jj,[`false`]),Bj(Yj,[`false`]),Bj(qj,[])];return()=>e.forEach(e=>e())}function lM(e){let{entryUrl:t,intervalMs:n,releaseIntervalMs:r,registryUrl:i,fetchImpl:a,onApplied:o,log:s}=e,c={kind:`unchecked`,reason:`not sampled yet`},l=null,u=$j,d=null,f=aM(s),p=aM(s),m=()=>nM(c,l);function h(){let e=m(),t=e===null?null:Xj(e);(d===null?null:d.identity)!==t&&(d?.dispose(),d=t===null?null:{identity:t,dispose:Bj(qj,[t])})}function g(){c=Mk(t,Ak),f(rM(c)),h()}async function _(){l=tO(GD,await eO($D,a,i)),p(iM(l)),h()}return{arm(){cM(),g(),setInterval(g,n).unref(),c.kind===`not-source-checkout`&&(_(),setInterval(()=>void _(),r).unref())},notice:e=>tM(m(),u,e),act(){let e=m();if(e===null)throw new $(`apply-update: nothing newer is known to apply`);let t=Qj(e);if(u.kind===`running`)throw new $(`apply-update: already ${t.busy}`);u=eM,s(`info`,`apply-update: ${t.act} — ${t.command.bin} ${t.command.args?.join(` `)??``}`),Oe({...t.command,category:`update.apply`,timeoutMs:6e5}).then(n=>{if(n.ok){u=$j,s(`info`,`apply-update: ${t.act} succeeded`),g(),o();return}let r=sM(n);u={kind:`failed`,identity:Xj(e),reason:r},s(`error`,`apply-update: ${t.act} failed: ${r}`)})}}}var uM=class{static CACHE_DIR=Pe();static USAGE_CACHE_DIR=c.join(this.CACHE_DIR,`usage`);static LOCKS_DIR=c.join(this.CACHE_DIR,`locks`);static isLocked(e){let t=c.join(this.LOCKS_DIR,e);if(!r.existsSync(t))return!1;try{let n=r.readFileSync(t,`utf-8`),i=parseInt(n.trim(),10);if(isNaN(i))return O(`Invalid PID in lock file ${e}, removing stale lock`),r.unlinkSync(t),!1;try{return process.kill(i,0),!0}catch(n){return n.code===`ESRCH`?(O(`Removing stale lock file ${e} for dead process ${i}`),r.unlinkSync(t),!1):(O(`Error checking process ${i} for lock ${e}:`,n),!0)}}catch(t){return O(`Error reading lock file ${e}:`,t),!0}}static async acquireLock(e,t=5e3){await this.ensureCacheDirectories();let n=c.join(this.LOCKS_DIR,e),i=Date.now(),a=String(process.pid);for(;Date.now()-i<t;)try{return await r.promises.writeFile(n,a,{flag:`wx`}),O(`Lock acquired for ${e}`),!0}catch(e){if(e.code===`EEXIST`)await se(50);else throw e}return O(`Failed to acquire lock for ${e} within ${t}ms`),!1}static async releaseLock(e){let t=c.join(this.LOCKS_DIR,e);try{await r.promises.unlink(t),O(`Lock released for ${e}`)}catch(t){t.code!==`ENOENT`&&O(`Error releasing lock for ${e}:`,t)}}static async ensureCacheDirectories(){try{await Promise.all([r.promises.mkdir(this.CACHE_DIR,{recursive:!0}),r.promises.mkdir(this.USAGE_CACHE_DIR,{recursive:!0}),r.promises.mkdir(this.LOCKS_DIR,{recursive:!0})])}catch(e){O(`Failed to create cache directories:`,e)}}static createProjectHash(e){return ae(`md5`).update(e).digest(`hex`).substring(0,8)}static async getUsageCache(e,t){await this.ensureCacheDirectories();let n=c.join(this.USAGE_CACHE_DIR,`${e}.json`),i=`${e}.usage.lock`;for(let a=0;a<3;a++){if(this.isLocked(i)){O(`Cache for ${e} is locked, waiting...`),await se(75);continue}try{let i=await r.promises.readFile(n,`utf-8`),a=JSON.parse(i);return!t||a.timestamp>=t?(O(`[CACHE-HIT] ${e} disk cache: found`),this.deserializeDates(a.data)):(O(`${e} cache outdated: cache=${a.timestamp}, latest=${t}`),null)}catch(t){if(t.code===`ENOENT`)return O(`No shared ${e} usage cache found`),null;O(`Attempt ${a+1} failed to read ${e} cache: ${t.message}. Retrying...`),await se(75)}}return O(`Failed to read ${e} 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){let i=`${e}.usage.lock`;if(!await this.acquireLock(i)){O(`Could not acquire lock to set usage cache for ${e}`);return}try{await this.ensureCacheDirectories();let i=c.join(this.USAGE_CACHE_DIR,`${e}.json`),a=JSON.stringify({data:t,timestamp:n||Date.now()});await r.promises.writeFile(i,a,`utf-8`),O(`[CACHE-SET] ${e} disk cache stored`)}catch(t){O(`Failed to save ${e} usage cache:`,t)}finally{await this.releaseLock(i)}}};const dM={"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 fM=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(){let e=Date.now()-1440*60*1e3;return await uM.getUsageCache(`pricing`,e)}static async saveDiskCache(e){await uM.setUsageCache(`pricing`,e)}static async fetchPricingData(){return new Promise(e=>{let t=new ne(this.GITHUB_PRICING_URL),n=oe({hostname:t.hostname,path:t.pathname,headers:{"User-Agent":`cc-candybar`,"Cache-Control":`no-cache`},timeout:5e3},t=>{if(t.statusCode!==200){O(`HTTP ${t.statusCode}: ${t.statusMessage}`),e(null);return}let r=``,i=0;t.on(`data`,t=>{if(i+=t.length,i>1048576){O(`Response too large`),n.destroy(),e(null);return}r+=t}),t.on(`end`,()=>{try{let t=JSON.parse(r),n=t._meta,i={};for(let[e,n]of Object.entries(t))e!==`_meta`&&(i[e]=n);this.validatePricingData(i)?(O(`Fetched fresh pricing from GitHub for ${Object.keys(i).length} models`),O(`Pricing last updated: ${n?.updated||`unknown`}`),e(i)):(O(`Invalid pricing data structure`),e(null))}catch(t){O(`Failed to parse JSON:`,t),e(null)}}),t.on(`error`,t=>{O(`Response error:`,t),e(null)})});n.on(`error`,t=>{O(`Request error:`,t),e(null)}),n.on(`timeout`,()=>{O(`Request timeout`),n.destroy(),e(null)}),n.end()})}static async getCurrentPricing(){if(this.executionCache!==null)return O(`[CACHE-HIT] Pricing execution cache: ${Object.keys(this.executionCache).length} models`),this.executionCache;let e=await this.loadDiskCache();if(e)return O(`[CACHE-HIT] Pricing disk cache: ${Object.keys(e).length} models`),this.executionCache=e,O(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(e).length} models`),e;let t=await this.fetchPricingData();return t?(await this.saveDiskCache(t),O(`[CACHE-SET] Pricing disk cache stored: ${Object.keys(t).length} models`),this.executionCache=t,O(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(t).length} models`),t):(O(`[CACHE-FALLBACK] Using offline pricing data: ${Object.keys(dM).length} models`),this.executionCache=dM,O(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(dM).length} models`),dM)}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){if(this.modelPricingCache.has(e))return O(`[CACHE-HIT] Model pricing cache: ${e}`),this.modelPricingCache.get(e);let t=await this.getCurrentPricing(),n;return n=t[e]?t[e]:this.fuzzyMatchModel(e,t),this.modelPricingCache.set(e,n),O(`[CACHE-SET] Model pricing cache: ${e}`),n}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){let t=e.message?.usage;if(!t)return 0;let n=this.extractModelId(e),r=await this.getModelPricing(n),i=t.input_tokens||0,a=t.output_tokens||0,o=t.cache_creation_input_tokens||0,s=t.cache_read_input_tokens||0,c=i/1e6*r.input,l=a/1e6*r.output,u=s/1e6*r.cache_read,d=o/1e6*r.cache_write_5m;return c+l+d+u}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`}};const pM=/<command-name>\s*([^<\s][^<]*?)\s*<\/command-name>/;function mM(e){if(typeof e==`string`)return pM.exec(e)?.[1]}function hM(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 gM(e){let t=e.message?.content,n=e.type===`user`,r=[],i=[],a,o;if(typeof t==`string`)o=t;else if(Array.isArray(t))for(let e of t){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=hM(t.input)??a);break}case`tool_result`:{let e=t.tool_use_id;typeof e==`string`&&i.push(e);break}case`text`:o??=t.text;break;default:break}}let s=n?mM(o):void 0;if(!(r.length===0&&i.length===0&&a===void 0&&s===void 0))return{...r.length>0&&{started:r},...i.length>0&&{finished:i},...a!==void 0&&{todos:a},...s!==void 0&&{command:s}}}function _M(e){if(e!==void 0)return[e];let t=h();return[f(t,`.config`,`claude`),f(t,`.claude`)].filter(e=>a(e))}async function vM(e){let t=[];for(let n of e){let e=f(n,`projects`);if(a(e))try{let n=await gA(e,{withFileTypes:!0});for(let r of n)if(r.isDirectory()){let n=f(e,r.name);t.push(n)}}catch(t){O(`Failed to read projects directory ${e}:`,t)}}return t}async function yM(e,t,n){let r=[],i=f(t,e,`subagents`);try{let t=(await gA(i)).filter(e=>e.startsWith(`agent-`)&&e.endsWith(`.jsonl`));for(let a of t){let t=f(i,a);if(n?.has(t)){r.push(t);continue}try{let n=(await _A(t,`utf-8`)).split(`
193
+ `)[0];n&&JSON.parse(n).sessionId===e&&r.push(t)}catch{O(`Failed to check agent file ${t}`)}}}catch(e){O(`Failed to read subagents directory ${i}:`,e)}return r}function bM(e){let t=e.type||e.message?.role||e.message?.type,n=e.type===`user`&&e.message?.firstContentType===`tool_result`;return t===`user`&&!n}const xM=new Map;async function SM(e){try{let t=await vA(e),n=t.size,r=xM.get(e);if(r&&r.mtime===t.mtimeMs&&r.size===n)return O(`[parse-cache] hit ${e}`),xM.delete(e),xM.set(e,r),r.entries;let i;return n>1048576?(O(`Using streaming parser for large file ${e} (${Math.round(n/1024)}KB)`),i=await DM(e)):i=await TM(e),O(`Parsed ${i.length} entries from ${e}`),n>5242880?i:(xM.delete(e),xM.size>=16&&xM.delete(xM.keys().next().value),xM.set(e,{mtime:t.mtimeMs,size:n,entries:i}),i)}catch(t){if(t.code===`ENOENT`)return O(`Transcript not present yet: ${e}`),[];throw t}}function CM(e){if(!e.timestamp)return null;let t=e.message,n=t?.usage,r=t?.content,i=Array.isArray(r)&&typeof r[0]==`object`&&r[0]?r[0]:void 0;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,firstContentType:typeof i?.type==`string`?i.type:void 0}:void 0,costUSD:typeof e.costUSD==`number`?e.costUSD:void 0,isSidechain:e.isSidechain===!0,activity:gM(e),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 wM(e){let t=[];for(let n of e.split(`
194
+ `))if(n.trim())try{let e=CM(JSON.parse(n));e&&t.push(e)}catch(e){O(`Failed to parse JSONL line: ${e}`);continue}return t}async function TM(e){return wM(await _A(e,`utf-8`))}async function EM(e,t){let n=await yA(e,t===void 0?void 0:{offset:t.offset,ino:t.ino});if(n.kind!==`ok`)return n;let{buf:r,start:i,mtimeMs:a,ino:o,reset:s}=n.value,c=r.lastIndexOf(10);return J(c<0?{entries:[],cursor:{offset:i,mtimeMs:a,ino:o},reset:s}:{entries:wM(r.subarray(0,c+1).toString(`utf-8`)),cursor:{offset:i+c+1,mtimeMs:a,ino:o},reset:s})}async function DM(e){return new Promise((t,n)=>{let r=[],a=i(e,{encoding:`utf8`}),o=ce({input:a,crlfDelay:1/0});o.on(`line`,e=>{let t=e.trim();if(t)try{let e=CM(JSON.parse(t));e&&r.push(e)}catch(e){O(`Failed to parse JSONL line: ${e}`)}}),o.on(`close`,()=>{t(r)}),o.on(`error`,t=>{O(`Streaming parser error for ${e}:`,t),n(t)}),a.on(`error`,t=>{O(`File stream error for ${e}:`,t),n(t)})})}var OM=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 kM(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 AM=new Map,jM={cost:0,input:0,output:0,cacheCreation:0,cacheRead:0},MM={cost:null,calculatedCost:null,officialCost:null,tokens:null,tokenBreakdown:null};function NM(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function PM(){let e=new Date;return e.setHours(0,0,0,0),e.setDate(e.getDate()-1),e.getTime()}function FM(){return{input:0,output:0,cacheCreation:0,cacheRead:0}}async function IM(e,t,n,r){let i=NM(new Date(PM())),a=e&&!t?e:void 0,o=a?.entries??0,s=a?.cost??0,c=a?{...a.breakdown}:FM(),l=new Map;if(a)for(let[e,t]of a.days)e>=i&&l.set(e,{...t});for(let e of n){let t=e.message?.usage;if(!t)continue;o++;let n=e.costUSD??await fM.calculateCostForEntry(e.raw);s+=n,c.input+=t.input_tokens||0,c.output+=t.output_tokens||0,c.cacheCreation+=t.cache_creation_input_tokens||0,c.cacheRead+=t.cache_read_input_tokens||0;let r=NM(new Date(e.timestamp));if(r<i)continue;let a=l.get(r)??{...jM};a.cost+=n,a.input+=t.input_tokens||0,a.output+=t.output_tokens||0,a.cacheCreation+=t.cache_creation_input_tokens||0,a.cacheRead+=t.cache_read_input_tokens||0,l.set(r,a)}return{cursor:r,entries:o,cost:s,breakdown:c,days:l}}function LM(e){let t=0,n=0,r=FM(),i=new Map;for(let 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)??{...jM};n.cost+=t.cost,n.input+=t.input,n.output+=t.output,n.cacheCreation+=t.cacheCreation,n.cacheRead+=t.cacheRead,i.set(e,n)}}if(t===0)return{sessionInfo:MM,days:i};let a=r.input+r.output+r.cacheCreation+r.cacheRead;return{sessionInfo:{cost:n,calculatedCost:n,officialCost:null,tokens:a,tokenBreakdown:r},days:i}}async function RM(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))}var zM=class{entries=new Map;flight=new OM;seeded=new Map;seededDay=``;speedRings=new Map;speedFlight=new OM;maxEntries;staleAgeMs;log;hits=0;misses=0;sweeps=0;seeds=0;sweepTimer=null;constructor(e={}){this.log=e.logger??eb,this.maxEntries=e.maxEntries??256,this.staleAgeMs=e.staleAgeMs??864e5;let t=e.sweepIntervalMs??3e5;t>0&&(this.sweepTimer=setInterval(()=>this.sweepStale(),t),this.sweepTimer.unref())}getStats(){return{size:this.entries.size,hits:this.hits,misses:this.misses,sweeps:this.sweeps,seeds:this.seeds}}async getUsageInfo(e,t){let n=await this.ingest(e,t?.transcript_path);if(n.kind===`failed`)return n;let r=n.kind===`ok`?n.value.sessionInfo:MM,i=t?.cost?.total_cost_usd??null;return J({session:{...r,cost:i??r.cost,officialCost:i}})}async getTodayInfo(e,t){let n=NM(new Date),r=_M(t);try{await this.ensureSeeded(n,r)}catch(e){return X(`usage seed: ${e instanceof Error?e.message:String(e)}`)}let i=await this.ingest(e?.session_id??``,e?.transcript_path);if(i.kind===`failed`)return i;let a=r.map(e=>f(e,`projects`)+p),o={...jM},s=!1;for(let[t,r]of this.entries){let i=r.transcriptPath??``,c=t===e?.session_id||a.some(e=>i.startsWith(e))?r.days:AM;s||=c.has(n);let l=c.get(n)??jM;o.cost+=l.cost,o.input+=l.input,o.output+=l.output,o.cacheCreation+=l.cacheCreation,o.cacheRead+=l.cacheRead}return s?J({cost:o.cost,tokens:o.input+o.output+o.cacheCreation+o.cacheRead,tokenBreakdown:{input:o.input,output:o.output,cacheCreation:o.cacheCreation,cacheRead:o.cacheRead},date:n}):Y}async observeSpeed(e,t,n){let r=pA(t);return this.speedFlight.run(`${e}:${r}`,async()=>{let i=await this.ingest(e,t,r);if(i.kind===`failed`)return i;let a=kM(i.kind===`ok`?i.value.sessionInfo.tokenBreakdown:null,n),o=this.speedRings.get(e)??[],s;for(let e of o)e.atMs<a.atMs&&(s===void 0||e.atMs>s.atMs)&&(s=e);return o.push(a),o.sort((e,t)=>e.atMs-t.atMs),o.length>64&&o.shift(),this.speedRings.set(e,o),J({...s!==void 0&&{prev:s},cur:a,samples:[...o]})})}async ingest(e,t,n){if(!e)return Y;let r=n??pA(t),i=this.entries.get(e);if(i&&r!==0&&i.transcriptMtime===r)return i.lastSeenAt=Date.now(),this.entries.delete(e),this.entries.set(e,i),this.hits++,J(i);if(!t)return i?J(i):Y;this.misses++;let a;try{a=await this.flight.run(`${e}:${r}`,()=>this.refold(e,t,this.entries.get(e)))}catch(t){return X(`usage refold (${e}): ${t instanceof Error?t.message:String(t)}`)}if(a.kind!==`ok`)return a;let o={files:a.value.files,sessionInfo:a.value.sessionInfo,days:a.value.days,transcriptMtime:a.value.mainMtime,transcriptPath:t,lastSeenAt:Date.now()};return this.entries.delete(e),this.entries.set(e,o),this.evictIfNeeded(),J(o)}async refold(e,t,n){let r=await yM(e,u(t),n===void 0?void 0:new Set(n.files.keys())),i=new Map,a=0;for(let e of[t,...r]){let r=n?.files.get(e),o=await EM(e,r?.cursor);if(o.kind===`failed`)return o;if(o.kind===`absent`){r&&i.set(e,r);continue}let{entries:s,cursor:c,reset:l}=o.value;i.set(e,await IM(r,l,s,c)),e===t&&(a=c.mtimeMs)}return J({files:i,...LM(i),mainMtime:a})}ensureSeeded(e,t){this.seededDay!==e&&(this.seeded.clear(),this.seededDay=e);let n=t.join(`\0`),r=this.seeded.get(n);if(r)return r;let i=this.seed(t);return this.seeded.set(n,i),i.catch(()=>{this.seeded.get(n)===i&&this.seeded.delete(n)}),i}async seed(e){let t=PM(),n=await vM(e),r=[];for(let e of n){let n;try{n=await gA(e)}catch{continue}for(let i of n){if(!i.endsWith(`.jsonl`))continue;let n=f(e,i),a;try{a=(await vA(n)).mtimeMs}catch{continue}a<t||r.push({sessionId:i.slice(0,-6),path:n,mtime:a})}}await RM(r,8,async e=>{let t=await this.ingest(e.sessionId,e.path,e.mtime);t.kind===`failed`&&this.log(`warn`,`usageStore seed: ${t.reason}`)}),this.seeds++,this.log(`info`,`usageStore seed sessions=${r.length} dirs=${e.join(`,`)}`)}sweepStale(){let e=Date.now(),t=0;for(let[n,r]of this.entries)e-r.lastSeenAt>this.staleAgeMs&&(this.entries.delete(n),this.speedRings.delete(n),t++);return t>0&&(this.sweeps++,this.log(`info`,`usageStore sweep dropped=${t}`)),t}evictIfNeeded(){for(;this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.entries.delete(e),this.speedRings.delete(e),this.log(`info`,`usageStore evict ${e}`)}}close(){this.sweepTimer&&=(clearInterval(this.sweepTimer),null),this.entries.clear(),this.seeded.clear(),this.speedRings.clear()}},BM=class{thresholds={LOW:50,MEDIUM:80};getContextUsageThresholds(){return this.thresholds}ratioPercentages(e,t){let n=Math.min(100,Math.max(0,Math.round(e/t*100)));return{percentage:n,contextLeftPercentage:Math.max(0,100-n)}}calculateContextFromHookData(e){let t=e.context_window;if(!t?.current_usage)return O(`No current_usage in hook data, falling back to transcript parsing`),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);O(`Native current_usage: input=${n.input_tokens}, cache_create=${n.cache_creation_input_tokens}, cache_read=${n.cache_read_input_tokens}, total=${i} (limit: ${r})`);let a=this.ratioPercentages(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)}}async calculateContextTokensFromTranscript(e,t){try{O(`Calculating context tokens from transcript: ${e}`);let n=await SM(e);if(n.length===0)return O(`No entries in transcript`),Y;let r=null;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t&&t.message?.usage?.input_tokens&&t.isSidechain!==!0){r=t,O(`Context segment: Found most recent entry at ${t.timestamp.toISOString()}, stopping search`);break}}if(r?.message?.usage){let e=r.message.usage,n=(e.input_tokens||0)+(e.cache_read_input_tokens||0)+(e.cache_creation_input_tokens||0);return O(`Most recent main chain context: ${n} tokens (limit: ${t})`),J({totalTokens:n,maxTokens:t,...this.ratioPercentages(n,t)})}return O(`No main chain entries with usage data found`),Y}catch(e){return X(`context transcript: ${e instanceof Error?e.message:String(e)}`)}}async getContextInfo(e){let t=this.calculateContextFromHookData(e);if(t)return J(t);let n=e.context_window?.context_window_size??2e5;return this.calculateContextTokensFromTranscript(e.transcript_path,n)}},VM=class{states=new Map;constructor(e,t,n=256){this.empty=e,this.step=t,this.maxSessions=n}async read(e,t){let n=this.states.get(e),r=pA(t);if(n&&r!==0&&n.cursor.mtimeMs===r)return this.touch(e,n),{kind:`ok`,value:n.value};let i=await EM(t,n?.cursor);if(i.kind===`failed`)return i;if(i.kind===`absent`)return{kind:`ok`,value:n?.value??this.empty};let{entries:a,cursor:o,reset:s}=i.value,c=s||n===void 0?this.empty:n.value;for(let e of a)c=this.step(c,e);for(this.touch(e,{cursor:o,value:c});this.states.size>this.maxSessions;){let e=this.states.keys().next().value;if(e===void 0)break;this.states.delete(e)}return{kind:`ok`,value:c}}touch(e,t){this.states.delete(e),this.states.set(e,t)}};const HM={messageCount:0,recent:[]};function UM(e,t){if(t.isSidechain)return e;let n=[...e.recent,t];return{messageCount:e.messageCount+ +!!bM(t),recent:n.length>20?n.slice(-20):n}}function WM(e){let t=null,n=null;for(let r of e){let e=r.type||r.message?.role||r.message?.type;if(bM(r))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 GM=class{fold=new VM(HM,UM);async getMetricsInfo(e,t){if(O(`Getting metrics from hook data for session: ${e}`),!t.cost)return Y;let n=await this.fold.read(e,t.transcript_path);return n.kind===`failed`?X(`metrics (${e}): ${n.reason}`):J({responseTime:t.cost.total_api_duration_ms/1e3,lastResponseTime:WM(n.value.recent),sessionDuration:t.cost.total_duration_ms/1e3,messageCount:n.value.messageCount,linesAdded:t.cost.total_lines_added,linesRemoved:t.cost.total_lines_removed})}};const KM={command:null,todos:[],pending:[],done:[]};function qM(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 JM(e,t){if(t.isSidechain)return e;let n=bM(t)?{...e,command:t.activity?.command??null,pending:[],done:[]}:e,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=qM(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 YM(e){return{command:e.command,todos:e.todos,running:e.pending.reduce((e,t)=>qM(e,t.name),[]),done:e.done}}var XM=class{fold=new VM(KM,JM);async getActivityInfo(e,t){let n=await this.fold.read(e,t.transcript_path);return n.kind===`failed`?X(`activity (${e}): ${n.reason}`):J(YM(n.value))}};function ZM(e,t,n,r){return{bin:`tmux`,args:[`-S`,e.socket,...n],timeoutMs:2e3,category:t,stdinInput:r}}function QM(e,t){if(e.ok)return{kind:`ok`,stdout:e.stdout};if(e.reason===`rate-limited`)return{kind:`rate-limited`,reason:e.error??`rate-limited`};let n=e.error??[e.reason,e.stderr.trim()].filter(e=>e!==``).join(`: `);return{kind:`failed`,reason:`tmux ${t[0]} failed (${n})`}}function $M(e,t,n,r){return QM(ke(ZM(e,t,n,r)),n)}async function eN(e,t,n){return QM(await Oe(ZM(e,t,n)),n)}const tN=e=>`${e.socket}\n${e.pane}`;var nN=class{names=new Map;asking=new OM;constructor(e=Date.now){this.now=e}getSessionName(e){let t=tN(e),n=this.names.get(t);if(n&&this.now()-n.at<3e4)return Promise.resolve(n.outcome);let r=this.asking.run(t,()=>this.ask(t,e));return n?Promise.resolve(n.outcome):r}async ask(e,t){O(`Getting tmux session name for pane ${t.pane} on ${t.socket}`);let n=await eN(t,`tmux`,[`display-message`,`-p`,`-t`,t.pane,`#S`]),r=n.kind===`ok`?n.stdout.trim():``,i=n.kind===`ok`?r?J(r):Y:X(n.reason);for(this.names.delete(e),this.names.set(e,{outcome:i,at:this.now()});this.names.size>64;)this.names.delete(this.names.keys().next().value);return i}};const rN=e=>JSON.stringify([e.sessionId,e.projectDir,e.cwd,e.claudeConfigDir,e.env===void 0?null:Ye.map(t=>e.env?.[t]??null)]);var iN=class{readings=new Map;inFlight=new Map;constructor(e,t=Date.now){this.edge=e,this.now=t}getCeiling(e){let t=rN(e),n=this.readings.get(t);if(n&&this.now()-n.at<1e4)return Promise.resolve(n.outcome);let r=this.inFlight.get(t)??this.fetch(t,e);return n?Promise.resolve(n.outcome):r}fetch(e,t){let n=this.edge.locate(t),r=(n.kind===`ok`?this.edge.read(n.value,t):Promise.resolve(n)).then(t=>{if(this.inFlight.get(e)!==r)return t;for(this.readings.delete(e),this.readings.set(e,{outcome:t,at:this.now()});this.readings.size>64;)this.readings.delete(this.readings.keys().next().value);return t}).finally(()=>{this.inFlight.get(e)===r&&this.inFlight.delete(e)});return this.inFlight.set(e,r),r}move(e,t){let n=this.edge.locate(e);if(n.kind!==`ok`)throw Error(n.kind===`failed`?n.reason:`memento is not installed or not enabled for this project`);let r=rN(e);try{this.edge.move(n.value,e,t)}finally{this.readings.delete(r),this.inFlight.delete(r),this.fetch(r,e)}}};function aN(e){return{gitProvider:new lb({watchers:e.watchers,logger:e.logger}),usageStore:new zM({logger:e.logger}),contextProvider:new BM,metricsProvider:new GM,activityProvider:new XM,tmuxService:new nN,mementoProvider:new iN(LA()),autoCompact:pS,log:e.logger}}function oN(e,t){return e===void 0?!0:e.evaluate(t).map(e=>e.plain).join(``)!==`false`}function sN(e,t){let n=H.fromFragments(e);return n.end=``,n.overflow=`ignore`,t!==void 0&&!t.isNull&&(n.style=t),n}function cN(e,t,n){e.cellLength>t?e.truncate(t,{mode:n.truncate,marker:`…`}):e.cellLength<t&&e.align(n.justify,t)}function lN({lead:e,text:t,trail:n}){return[...e===void 0?[]:[e],t,...n===void 0?[]:[n]]}function uN(e){let t=lN(e);if(t.length===1)return e.text;let n=sN(t);return n.style=e.text.style,n}function dN(e,t){let{width:n,justify:r,truncate:i,baseStyle:a,padding:o,lead:s=[],trail:c=[]}=t;if(e.length===0)return[];let l=sN(e,a).pad(o),u=new H(` `.repeat(o)),d={...s.length>0&&{lead:sN([u,...s],a)},...c.length>0&&{trail:sN([...c,u],a)}};if(n===`auto`)return[{text:l,...d}];let f={justify:r,truncate:i};return n===`fill`?[{text:l,fill:f,...d}]:(cN(l,n,f),[{text:l,...d}])}const fN=RegExp(`\\x1b\\[[0-9;]*m|${bi.source}`,`g`);function pN(e){return M(e.replace(fN,``))}function mN(e,t){let n=e.map(uN),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=dk(n,t).split(`
195
+ `);if(i.length>1)return n;let a=Math.max(0,t.width-pN(i[0]??``)),o=Math.floor(a/r.length),s=a-o*r.length;return r.forEach(({at:t,how:i},a)=>{let c=o+(a===r.length-1?s:0),{text:l}=e[t];cN(l,l.cellLength+c,i),n[t]=uN(e[t])}),n}function hN(e,t){let n=[],r=[],i=()=>{if(!r.length)return;let e=gN(r,t);e.plain.length>0&&n.push(e),r=[]};for(let a of e)if(vN(a.style).link){i();let e=gN([a],t);e.plain.length>0&&n.push(e)}else r.push(a);return i(),n}function gN(e,t){let n=t!==void 0&&!t.isNull?e.map(e=>_N(e,t)):e,r=H.fromFragments(n);return r.end=``,r.overflow=`ignore`,n.length===1?r.style=n[0].style:t!==void 0&&!t.isNull&&(r.style=t),r}function _N(e,t){let n=e.copy();return n.style=t.add(vN(e.style)),n}function vN(e){return e instanceof B?e:B.parse(e)}function yN(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,bN(e,t,o,n,r,i));return i}function bN(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=sx(n.from,i);return{kind:`set-option`,key:n.set,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,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=zb.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=sx(n.from,i);return{kind:`persist-option`,key:n.persist,stateVar:e,options:[...t.members],paletteOf:t.paletteOf,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=sx(n.insertSegmentFrom,i);return{kind:`layout-op-option`,key:n.persist,anchor:n.anchor,relation:n.relation,options:[...e.members],paletteOf:e.paletteOf,library:e.library}}return{kind:`persist-bounded`,key:n.persist,by:n.by}}if(`copy`in n)return{kind:`copy`,text:CN(e,n.copy,t)};if(`open`in n)return{kind:`open`,target:CN(e,n.open,t)};if(`reset`in n)return{kind:`reset`,key:n.reset};if(`doctor`in n)return n.doctor===`run`?{kind:`doctor-run`}:{kind:`doctor-fix`,check:n.check};if(`ceiling`in n)return{kind:`ceiling`,args:yw(n)};if(`slash`in n)return{kind:`slash`,line:n.slash};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:CN(e,n.name,t)};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 xN(e){return e.kind===`do`?xN(e.head):e}function SN(e){switch(xN(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`doctor-run`:case`doctor-fix`:case`ceiling`:case`slash`:case`do`:return!1}}function CN(e,t,n){try{return e(t)}catch(e){throw Error(`Template parse error in actions.${n}: ${e.message}`,{cause:e})}}function wN(e,t){return e.has(t)?jv(e.read(t)):``}function TN(e,t){return e.evaluate(t).map(e=>e.plain).join(``)}function EN(e,t,n,r){let i=new H(e,{style:B.combine([r,new B({link:t,bold:n})])});return i.overflow=`ignore`,i.end=``,i}function DN(e,t){return Math.max(e.members.indexOf(wN(t,e.stateVar)),0)}function ON(e,t,n,r,i){switch(e.kind){case`set-literal`:{let t=wN(r,e.stateVar);return{effects:[{verb:mD,args:[i,e.key,e.value]}],active:t===e.value}}case`set-option`:{let a=n??t,o=wN(r,e.stateVar);return{effects:[{verb:mD,args:[i,e.key,a]}],active:o===a}}case`set-int`:{let a=n??t,o=wN(r,e.stateVar);return{effects:[{verb:mD,args:[i,e.key,a]}],active:o===a}}case`set-cycle`:{let t=e.members[(DN(e,r)+1)%e.members.length];return{effects:[{verb:mD,args:[i,e.key,t]}],active:!1}}case`set-bounded`:return{effects:[{verb:hD,args:[i,e.key,String(e.by)]}],active:!1};case`copy`:return{effects:[{verb:gD,args:[TN(e.text,Cy(r))]}],active:!1};case`open`:return{effects:[{verb:_D,args:[TN(e.target,Cy(r))]}],active:!1};case`persist-literal`:{let t=wN(r,e.stateVar);return{effects:[{verb:xD,args:[i,e.key,e.value]}],active:t===e.value}}case`persist-option`:{let a=n??t,o=wN(r,e.stateVar);return{effects:[{verb:xD,args:[i,e.key,a]}],active:o===a}}case`persist-cycle`:{let t=e.members[(DN(e,r)+1)%e.members.length];return{effects:[{verb:xD,args:[i,e.key,t]}],active:!1}}case`persist-bounded`:return{effects:[{verb:SD,args:[i,e.key,String(e.by)]}],active:!1};case`reset`:return{effects:[{verb:ED,args:[i,e.key]}],active:!1};case`undo`:return{effects:[{verb:OD,args:[i]}],active:!1};case`redo`:return{effects:[{verb:kD,args:[i]}],active:!1};case`back`:return{effects:[{verb:AD,args:[i]}],active:!1};case`rewind`:return{effects:[{verb:jD,args:[i]}],active:!1};case`save`:return{effects:[{verb:CD,args:[i]}],active:!1};case`preset-save`:return{effects:[{verb:wD,args:[i]}],active:!1};case`preset-delete`:return{effects:[{verb:TD,args:[i,TN(e.name,Cy(r))]}],active:!1};case`doctor-run`:return{effects:[{verb:ND,args:[i]}],active:!1};case`doctor-fix`:return{effects:[{verb:PD,args:[i,e.check]}],active:!1};case`ceiling`:return{effects:[{verb:FD,args:[i,...e.args]}],active:!1};case`slash`:return{effects:[{verb:ID,args:[i,e.line]}],active:!1};case`layout-op`:return{effects:[{verb:DD,args:[i,e.key,Nk(e.op)]}],active:!1};case`do`:{let a=ON(e.head,t,n,r,i);return{effects:[...a.effects,...e.rest.flatMap(e=>ON(e,t,void 0,r,i).effects)],active:a.active}}case`layout-op-option`:{let r={op:`insert`,segment:n??t,anchor:e.anchor,relation:e.relation};return{effects:[{verb:DD,args:[i,e.key,Nk(r)]}],active:!1}}}}function kN(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:qc(`action "${e}"`,n,t.members.length,DN(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]}}function AN(e,t,n){let r=n.compiled.get(e);if(!r)throw Error(`action "${e}" is not declared in this config`);let i=n.store,{display:a,boundValue:o}=kN(e,xN(r),t,i),{effects:s,active:c}=ON(r,a,o,i,wN(i,`session.id`));return EN(a,zD(s),c)}function jN(e){return{action:{fn:(t,...n)=>AN(t,n,e),argTypes:[`string`,`string`],arity:{kind:`variadic`},returnType:`T`}}}function MN(e,t){return EN(`✕`,zD([{verb:mD,args:[wN(e,`session.id`),t,Wc]}]),!1)}function NN(e,t,n){return new B({bgcolor:vn.fromRgba(t),color:vn.fromRgba(Aa(e,t,n))})}function PN(e,t,n){return new B({color:vn.fromRgba(sr(ba(e,`warning`),t,ka,n))})}function FN(e,t,n){return B.combine([NN(e,t,n),PN(e,t,n)])}function IN(e,t,n){return NN(e.palette,Ua(e.palette,e.disclosure,[t],n),n)}function LN(e,t,n,r,i,a){return r===void 0?n=>IN(e,{...n,distribution:t},i):(e,t)=>RN(r(t,n),a,i)}function RN(e,t,n){return new B({bgcolor:vn.fromRgba(t),color:vn.fromRgba(sr(ba(e,`primary`),t,4.5,n))})}function zN(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=>BN(e.indices,8).map(t=>[{label:e.label,indices:t}])):[r]}function BN(e,t){return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))}function VN(e,t){return new H(e).truncate(t,{marker:`…`}).plain}function HN(e){return{current:null,drawnAt:e}}function UN(e,t,n,r,i,a){let o={segName:t,placementId:n,palette:r,disclosure:i,tint:a,bg:void 0,drops:[]};return e.current=o,o}function WN(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 GN(e){return new H(e).cellLength}function KN(e){return Math.max(1,e.width-e.chromeCols-2*e.padding)}function qN(e){return Math.max(1,KN(e)-(GN(`✕`)+2*e.padding+e.seamCols))}function JN(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 YN(e,t,n){let r=GN(`←`)+1+GN(`→`)+1,i=JN(e,t,n);return(i.length>1?JN(e,t,n+r):i).map(e=>[{label:``,indices:e}])}function XN(e,t){let n=[];for(let t of e)n.length>0&&n.push(new H(` `)),n.push(t);let r=H.fromFragments(n);return r.overflow=t?`ignore`:void 0,r.end=``,r}function ZN(e,t,n,r){let i=e.compiled.get(t);if(!i||i.kind!==n)throw Error(`picker references action "${t}" which must be ${r}, got ${i?`a ${i.kind} action`:`no such action`}`);return i}function QN(e,t,n){let r=e.compiled.get(t),i=r&&xN(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 $N(e,t,n,r,i,a,o){let s=QN(i,e,`picker`),c=i.compiled.get(e),l=i.store,u=wN(l,`session.id`),d=`stateVar`in s?wN(l,s.stateVar):void 0,f=r?n.kind===`led`?qN(i):KN(i):1/0,p=n.kind===`led`?0:GN(`✕`)+1,m=s.library&&{groups:s.library.groups,entries:s.options.map(s.library.entry)},h=m===void 0?YN(s.options.map(GN),f,p):zN(m.entries,m.groups,r),g=parseInt(wN(l,t.stateVar),10),_=Number.isInteger(g)?Math.max(0,Math.min(g,h.length-1)):0,v=h[_]??[],y=e=>zD([{verb:mD,args:[u,t.key,String(e)]}]),b=n.kind===`led`?[]:[{verb:mD,args:[u,...n.writes.flatMap(([e,t])=>[e,t])]}],x=n.kind===`own`&&n.onPick?b:[],S=e=>zD([...ON(c,e,e,l,u).effects,...x]),C=(e,t)=>{let n=s.options[e];return EN(t,S(n),n===d,a({index:e,count:s.options.length},n))},w=n.kind===`led`?[]:[EN(`✕`,zD(b),!1,o)];_>0&&w.push(EN(`←`,y(_-1),!1));let T=_<h.length-1?[EN(`→`,y(_+1),!1)]:[];if(m===void 0){let e=v.flatMap(e=>e.indices);return[XN([...w,...e.map(e=>C(e,s.options[e])),...T],r)]}let ee=new B({bold:!0}),te=h.length>1?` ${_+1}/${h.length}`:``,ne=v.length===1?[new H(`${v[0].label}${te}`,{style:ee})]:[],re=[XN([...w,...ne,...T],r)];for(let e of v){v.length>1&&re.push(XN([new H(e.label,{style:ee})],r));let t=Math.max(...e.indices.map(e=>GN(s.options[e])));for(let n of e.indices){let e=s.options[n],i=m.entries[n].description,a=i===void 0?void 0:ZO(i),o=` `.repeat(t-GN(e)+2),c=a===void 0?e:`${e}${o}${a}`;re.push(XN([C(n,VN(c,f))],r))}}return re}function eP(e,t){return{picker:{fn:(n,r,i,a,o,...s)=>{_y(`picker "${n}"`,[`closeOnPick`,`paged`,`inBody`],s);let c=ZN(e,r,`set-int`,`an int action ({ set, int: true })`);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=QN(e,n,`picker`);if(l.library!==void 0)throw Error(`{{ picker "${n}" … }} ranges a catalogue domain, which lays out as one row per member; a catalogue renders in a {{ menu }} body`);let u=WN(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]=$N(n,{key:c.key,stateVar:c.stateVar},o===!0?{kind:`led`}:{kind:`own`,writes:[[c.key,`-1`]],onPick:i===!0},a===!0,e,LN(u,pa(void 0),e,l.paletteOf,t.drawnAt(),u.bg),PN(u.palette,u.bg,t.drawnAt()));return d},argTypes:[`string`,`string`,`bool`],arity:{kind:`variadic`},returnType:`T`}}}function tP(e,t,n,r,i){let a=Math.min(Math.floor((t-1)/2),i),o=n,s=0;for(;s<a;){let t=o+GN(e(-(s+1)))+1+GN(e(s+1))+1;if(t>r)break;o=t,s+=1}return s}function nP(e,t,n,r,i,a){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 o=n.store;if(!o.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 s=n.compiled.get(e),c=wN(o,`session.id`),{options:l}=t,u=l.length;if(u===0)return XN([],!0);let d=wN(o,t.stateVar),f=Math.max(l.indexOf(d),0),p=e=>((f+e)%u+u)%u,m=e=>l[p(e)],h=new Map,g=e=>{let t=h.get(e);if(t!==void 0)return t;let n=zD(ON(s,m(e),m(e),o,c).effects);return h.set(e,n),n},_=e=>EN(m(e),g(e),m(e)===d,r({index:p(e),count:u},m(e))),v=a===void 0?_(0):EN(m(0),zD(ON(n.compiled.get(a),m(0),void 0,o,c).effects),!1),y=tP(m,u,GN(`◀`)+1+v.cellLength+1+GN(`▶`),qN(n),i),b=e=>Array.from({length:y},(t,n)=>_(e*(n+1)));return XN([...b(-1).reverse(),EN(`◀`,g(-1),!1),v,EN(`▶`,g(1),!1),...b(1)],!0)}function rP(e,t){return{carousel:{fn:(n,...r)=>{let[i,a,...o]=r;if(_y(`carousel "${n}"`,[`neighbours`,`centre`],o),i!==void 0&&!(Number.isInteger(i)&&i>=0))throw Error(`carousel "${n}": neighbours must be a whole number ≥ 0 (0 shows only ◀ CURRENT ▶), got ${String(i)}`);if(a!==void 0&&!(typeof a==`string`&&e.compiled.has(a)))throw Error(`carousel "${n}": centre must name a declared action, got ${JSON.stringify(a)}`);if(a!==void 0&&SN(e.compiled.get(a)))throw Error(`carousel "${n}": centre "${a}" writes a value the template binds, and the centre binds none — name an action that writes a fixed value, a cycle, or a do of them`);let s=i??1/0,c=QN(e,n,`carousel`),l=WN(t,`{{ carousel }}`);if(l.bg===void 0)throw Error(`{{ carousel }} is not available while segments.${l.segName}'s own "bg:" is being evaluated — a carousel is drawn on that background`);return nP(n,c,e,LN(l,pa(void 0),e,c.paletteOf,t.drawnAt(),l.bg),s,a)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}const iP=[`~/code`,`main`,`opus`,`42%`,`5m`,`$1.20`];function aP(e,t,n){let r=Ia(e,{hue:oa,depth:0},n);return[sa(t.hues).map((t,n)=>({text:iP[n%iP.length],colour:xa(e,t)})),[{text:`▾ open`,colour:r.state},{text:`menu`,colour:r.plane}],[{text:`warn`,colour:ba(e,`warning`)},{text:`error`,colour:ba(e,`error`)}]]}function oP(e,t,n,r){let i=aP(e,t,n).flatMap((t,r)=>t.map(({text:t,colour:i},a)=>({gap:r>0&&a===0?` `:``,cell:new H(` ${t} `,{style:NN(e,i,n)})}))),a=[],o=0;for(let{gap:e,cell:t}of i){if(o+=e.length+t.cellLength,o>r)break;e!==``&&a.push(new H(e)),a.push(t)}let s=H.fromFragments(a);return s.overflow=`ignore`,s.end=``,s}function sP(e,t){return{themePreview:{fn:()=>oP(e.palette,e.variation,t.drawnAt(),qN(e)),argTypes:[],arity:{kind:`exact`},returnType:`T`}}}const cP=e=>e.slice(e.lastIndexOf(`.`)+1),lP=(e,t)=>{let n=new H(cP(e));return n.truncate(t,{marker:`…`}),n.plain};function uP(e,t){let n=e.map(e=>e.map(({name:e})=>GN(cP(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 dP(e,t,n,r){let i=uP(e,r),a=e.map(e=>{let a=[],o=0;for(let{name:s,address:c,palette:l}of e){let e=new H(` ${lP(s,i)} `,{style:NN(l,qa(l,{kind:`bar`,variation:t,address:c},n).tint,n)});if(o+=e.cellLength,o>r)break;a.push(e)}return a}),o=H.fromFragments(a.flatMap((e,t)=>t===0?e:[new H(`
196
+ `),...e]));return o.overflow=`ignore`,o.end=``,o}function fP(e,t){return{layoutPreview:{fn:()=>dP(e.layout(),e.variation,t.drawnAt(),qN(e)),argTypes:[],arity:{kind:`exact`},returnType:`T`}}}function pP(e,t,n,r){let i=WN(r.activeSegment,`{{ menu }}`),a=r.action,o=__(i.placementId,e,n.key),s=b_(o),c=g_(e),l=wN(a.store,o)===c,u=wN(a.store,`session.id`),d=l?Wc:c,f=EN(qc(`{{ menu "${e}" }}`,t,2,+!!l),zD([{verb:mD,args:[u,o,d,s,`0`]}]),!1);return i.drops.push(...l?(()=>{let t=r.activeSegment.drawnAt(),c=Ia(i.palette,i.disclosure,t).plane;return $N(e,{key:s,stateVar:s},{kind:`own`,writes:[[o,Wc],[s,`0`]],onPick:n.closeOnPick},n.paged,a,LN(i,n.distribution,a,QN(a,e,`menu`).paletteOf,t,c),PN(i.palette,c,t))})():[]),f}const mP=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function hP(e,t){let n=t[t.length-1],r=mP(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:w_(r??{})}}function gP(e){return{menu:{fn:(t,...n)=>{let{displays:r,options:i}=hP(t,n);return pP(t,r,i,e)},argTypes:[`string`,`value`],arity:{kind:`variadic`},returnType:`T`}}}function _P(e){let{value:t,max:n,width:r,filled:i,empty:a,colourAt:o}=e,s=vP(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 H(t?i:a,{style:l===void 0?void 0:new B({color:l})}))}let l=H.fromFragments(c);return l.end=``,l.overflow=`ignore`,l}function vP(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 yP(e){let t={fn:(()=>{let t=WN(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:(()=>WN(e,`{{ tint }}`).tint.hex),argTypes:[],arity:{kind:`exact`},returnType:`string`},r=ry(()=>WN(e,`{{ color }} / {{ ramp }} / {{ gauge }}`).palette),i={fn:((e,t,n,i,a,o,...s)=>{let c=o===void 0?void 0:[o,...bP(s)];return _P({value:e,max:t,width:n,filled:i,empty:a,colourAt:c===void 0?void 0:e=>String(r.ramp.fn(e,...c))})}),argTypes:[`float`,`float`,`int`,`string`,`string`,`string`],arity:{kind:`variadic`},returnType:`T`};return{...r,bgOf:t,tint:n,gauge:i}}function bP(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 xP(e){let t=[],n=[];for(let r of e){if(!r.contains(`
193
197
  `)){n.push(r);continue}let e=r.split(`
194
- `);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function gP(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,..._P(e,r)]}function _P(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 vP(e,t){let n=(e,r)=>t(e)?e.kind===`segment`?[{cells:[{name:e.name,address:r,settings:e.settings}],band:`own`,place:`flow`}]:gP(e.direction,e.children.map((t,i)=>n(t,[...r,yP(e,i)]))):[];return n(e,[]).map(e=>[...e.cells])}function yP(e,t){return{index:t,count:e.children.length,distribution:e.distribution,axis:Ds[e.direction]}}const bP={compile(e,t){return{kind:`container`,direction:e.direction,when:t.when,distribution:pa(e.distribution),children:e.children.map((e,n)=>t.compileChild(e,Ns(t.path,n)))}},render(e,t){return gP(e.direction,e.children.map((n,r)=>t.renderChild(n,t.visible,yP(e,r))))}},xP={drop:e=>e.place,above:()=>`above`},SP={drop:(e,t)=>({lead:t(),stays:e}),above:e=>({lead:e.slice(0,1).flatMap(e=>e.cells),stays:e.slice(1)})},CP={compile(e,t){return{kind:`segment`,when:t.when,name:e.name,id:Os(e),settings:t.placementSettings(e),...e.opens!==void 0&&{opens:{open:t.parse(Xc(e.opens.ref),`opens`),body:t.compileChild(e.opens.body,Ps(t.path)),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){let n=t.lookupSegment(e.name);if(!n)throw Error(`Layout segment "${e.name}" has no matching segment`);let{seg:r,compiled:i}=n;if(!t.visible)return[];let a=wy(t.scope,e.settings);try{if(!eN(i.when,a))return[];let n=qb(e.settings.theme,t.palette),o=e.opens!==void 0&&eN(e.opens.open,t.scope),{styles:s,fragments:c,lead:l,trail:u,drops:d,open:f}=t.evaluateSegment(e,a,n,t.region,{bg:i.bg,fg:i.fg,body:i.template,lead:e.lead,trail:e.trail},o),p=f?s.trigger:s.closed,m={width:r.width??`auto`,justify:r.justify??`left`,truncate:r.truncate??`right`,baseStyle:p,padding:t.padding},h=e.opens,g=h===void 0?[]:t.renderBody(h.body,o,s.disclosure).map(e=>({...e,place:xP[h.placement](e)})),_=hP(lN(c,p)).map((e,t)=>({cells:aN(e,{...m,lead:t===0?lN(l,p):[],trail:t===0?lN(u,p):[]}),band:`own`,place:`flow`})),v=d.map(e=>({cells:aN(lN([e],s.band),{...m,baseStyle:s.band}),band:`deeper`,place:`flow`})),y=(e,t,n)=>aN(lN([e],t),{...m,width:`auto`,baseStyle:t,padding:n}),b=g.findIndex(e=>e.band===`own`),{lead:x,stays:S}=h!==void 0&&b!==-1?SP[h.placement](_,()=>y(t.closeDisclosure(h.key),s.close,t.padding)):{lead:[],stays:_},C=x.flatMap(e=>y(new H(` `.repeat(rN(e).reduce((e,t)=>e+t.cellLength,0))),s.trigger,0)),w=(e,t)=>e.band===`own`?t===b?x:C:[],ee=g.map((e,t)=>({cells:[...w(e,t),...e.cells],band:`deeper`,place:e.place})),te=[...S,...v];return t.perSegmentSink!==void 0&&t.perSegmentSink.set(e.id,[...te.flatMap(e=>e.cells),...g.flatMap(w)].flatMap(rN)),[...te,...ee]}catch(n){let r=n.message??String(n);t.onSegmentError?.(e.id,r);let i=r.replace(/\s*\n\s*/g,` `);return[{cells:aN([new H(`⚠ ${e.id}: ${i}`,{end:``})],{width:`auto`,justify:`left`,truncate:`right`,padding:0,lead:wP(e.lead,e,a,t),trail:wP(e.trail,e,a,t)}),band:`own`,place:`flow`}]}}};function wP(e,t,n,r){if(e===void 0)return[];try{return r.evaluateSegment(t,n,r.palette,r.region,{bg:void 0,fg:void 0,body:e,lead:void 0,trail:void 0},!1).fragments}catch(e){return r.onSegmentError?.(t.id,e.message??String(e)),[]}}const TP={container:bP,segment:CP};function EP(e){return TP[e]}function DP(e){if(`ttl`in e)return{kind:`ttl`,durationMs:mb(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 OP(e,t){switch(Ls(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 kP(e,t,n,r){switch(n.kind){case`literal`:e.declareLiteral(t,n.value);break;case`input`:e.declareInput(t,n.path,n.type??`string`,n.default);break;case`env`:e.declareEnv(t,n.name,n.default);break;case`file`:e.declareFile(t,n.path,{readMode:n.readMode,cache:DP(n.cache),parse:OP(n.parse,n.default)});break;case`shell`:e.declareShell(t,n.command,{cwd:r,cache:DP(n.cache),parse:OP(n.parse,n.default)});break;case`template`:e.declareTemplate(t,n.template,{varDefault:n.default});break;case`time`:e.declareTime(t,{format:n.layout,ttlMs:n.cache?mb(n.cache.ttl):void 0,varDefault:n.default});break;case`git`:e.declareGit(t,{field:n.field,cwd:r,varDefault:n.default});break;case`state`:e.declareState(t,{key:n.key,...n.default!==void 0&&{varDefault:n.default}});break}}function AP(e,t){let n=Yd.EMPTY;for(let[r,i]of Object.entries(t))try{n=e.parse(`{{ define "${r}" }}${i}{{ end }}`,n).defines()}catch(e){throw Error(`Template parse error in helpers.${r}: ${e.message}`,{cause:e})}return n}const jP=e=>xo(void 0,null,e.globals.variation);function MP(e,t,n){let r=n.cwd,i=ex(e.globals.palette),a={store:t.variableStore,compiled:new Map,chromeCols:rk({endcaps:`powerline`,charset:go}),width:80,basePalette:i,palette:i,variation:aa[jP(e)],padding:1,seamCols:ik({endcaps:`powerline`,charset:go}),layout:()=>[]},o=IN(t.drawnAt),s={action:a,activeSegment:o},c=Object.keys(e.styles),l=D_(e.presets),u=new Map([...ix(e),...XC(e)]),d=xy({...TN(a),...JN(a,o),...ZN(a,o),...tP(a,o),...oP(a,o),...uP(s),...pP(o),styles:{fn:()=>c,argTypes:[],arity:{kind:`exact`}},presets:{fn:()=>l,argTypes:[],arity:{kind:`exact`}}},n.clock,t.drawnAt),f=AP(d,e.helpers),p=e=>d.parse(e,f),m=new Map,h=e=>{let t=m.get(e);if(t!==void 0)return t;let n=p(e);return m.set(e,n),n},g=new Map;for(let[t,n]of zb)n in e.variables&&g.set(t,n);for(let[t,n]of Object.entries(e.variables))n.kind===`state`&&!g.has(n.key)&&g.set(n.key,t);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))r.kind===`state`&&!g.has(r.key)&&g.set(r.key,`${t}.${e}`);a.compiled=pN(p,e.actions,g,u);let _=[];for(let[n,i]of Object.entries(e.variables))try{kP(t,n,i,r)}catch(e){_.push(`Variable "${n}": ${e.message??String(e)}`)}for(let[n,i]of Object.entries(e.segments))if(i.vars)for(let[e,a]of Object.entries(i.vars))try{kP(t,`${n}.${e}`,a,r)}catch(t){_.push(`Variable "${n}.${e}": ${t.message??String(t)}`)}let v=Object.create(null);for(let[t,n]of Object.entries(e.segments)){let e=(e,n,r=p)=>{try{return r(e)}catch(e){throw Error(`Template parse error in segments.${t}.${n}: ${e.message}`,{cause:e})}};v[t]={when:n.when===void 0?void 0:e(n.when,`when`,h),template:e(n.template,`template`),bg:n.bg===void 0?void 0:e(n.bg,`bg`),fg:n.fg===void 0?void 0:e(n.fg,`fg`)}}let y=(e,t,n)=>{try{return h(e)}catch(e){throw Error(`Template parse error in ${t}.${n}: ${e.message}`,{cause:e})}},b=t.variableStore,x=t=>{let n=Hs(e.segments[t.name]),r=Object.create(null);for(let[e,i]of Object.entries(n)){let n=t.settings?.[e]??i.default,a=t.drafts?.[e];Object.defineProperty(r,e,{enumerable:!0,get:a===void 0?()=>n:()=>qs(i,String(b.read(a.variable)))??n})}return Object.freeze(r)},S=(e,t)=>{let n={path:t,when:e.when===void 0?void 0:y(e.when,t,`when`),parse:(e,n)=>y(e,t,n),compileChild:S,placementSettings:x};return EP(e.kind).compile(e,n)},C=new Map;for(let t of l){let{node:n,path:r}=A_(e,t);C.set(t,S(n,r))}let w=new Map(ro.map(e=>[e,new Map])),ee=[[`globals`,e.globals],...Object.entries(e.presets).map(([e,t])=>[`presets.${e}.globals`,t.globals??{}])];for(let[e,t]of ee)for(let n of ro){let r=t[n];if(!io(r))continue;let i=`${e}.${n}`,a=w.get(n),o=a.get(r);a.set(r,o===void 0?{where:i,template:NP(p,i,r)}:{where:`${o.where}, ${i}`,template:o.template})}return{segments:v,roots:C,activeSegment:o,menuRuntime:s,globalExpressions:w,loadWarnings:_}}function NP(e,t,n){try{return e(n)}catch(e){throw Error(`${t} is not a valid template: ${e instanceof Error?e.message:String(e)}`)}}function PP(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 render but no compiled template exists — registerDslConfig and the resolution disagree about isExpression`);return r}function FP(e,t){return e.template.evaluate(t).map(e=>e.plain).join(``)}function IP(e,t){return e.kind===`decided`?e.name:t}function LP(e,t,n,r,i,a,o,s){let{perSegmentSink:c,onSegmentError:l,onRenderWarning:u}=o??{};r.drawAt(vo(a.colorCompatibility));let{preset:d=T_}=s??{},f=j_(e,d),p=aa[s?.variation??xo(void 0,null,f.variation)];t.menuRuntime.action.variation=p;let m=s?.style??lo(`none`,e.styles),h=s?.theme??Qb(void 0,null,f.palette),g=(e,t)=>({...i,term:{cols:a.width},theme:{effective:e},style:{effective:t}});r.applyInput(g(IP(h,Xa),IP(m,so))),t.menuRuntime.action.chromeCols=rk(a),t.menuRuntime.action.padding=a.padding,t.menuRuntime.action.width=a.width,t.menuRuntime.action.seamCols=ik(a);let _=Sy(n),v=oo(h,e=>{let n=PP(t,`palette`,e);return Zb(FP(n,_),n.where,e=>u?.(e))}),y=oo(m,n=>lo(FP(PP(t,`style`,n),_),e.styles));(v!==h||y!==m)&&r.applyInput(g(v.name,y.name));let b=v.value;t.menuRuntime.action.basePalette=b;let x=Yb(b,y.value);t.menuRuntime.action.palette=x,c?.clear();let S=n=>{let r=e.segments[n],i=t.segments[n];return r!==void 0&&i!==void 0?{seg:r,compiled:i}:void 0},C=(e,n,i,a,o,s)=>{try{let c=r.drawnAt(),{tint:l,disclosure:u}=qa(i,a,c),d=LN(t.activeSegment,e.name,e.id,i,u,l),f=Cx(d,c,o.bg,o.fg,n),p=()=>Ia(i,u,c).state;s&&(d.bg=p());let m=o.body.evaluate(n),h=d.drops.length>0||s;h&&(d.bg=p());let g=o.lead?.evaluate(n)??[],_=o.trail?.evaluate(n)??[];return{styles:{closed:f,get trigger(){return DN(i,p(),c)},get band(){return DN(i,Ia(i,u,c).plane,c)},get close(){return kN(i,p(),c)},disclosure:u},fragments:m,lead:g,trail:_,drops:d.drops,open:h}}finally{t.activeSegment.current=null}},w=(e,t,r)=>{let i=t&&eN(e.when,_),o={scope:_,palette:x,visible:i,padding:a.padding,region:r,perSegmentSink:c,onSegmentError:l,evaluateSegment:C,lookupSegment:S,renderChild:(e,t,n)=>w(e,t,Ga(r,n)),renderBody:(e,t,n)=>w(e,i&&t,Ka(n)),closeDisclosure:e=>EN(n,e)};return EP(e.kind).render(e,o)},ee=t.roots.get(d);if(ee===void 0)throw Error(`Preset "${d}" has no compiled layout — registerDslConfig compiles one per declared preset and effectivePresetName collapses unknown names to "${T_}"; a miss here is merge/policy drift (have: ${[...t.roots.keys()].join(`, `)})`);let te=e=>{if(!eN(e.when,_))return!1;if(e.kind===`container`)return!0;if(aw(e.name)===void 0)return!1;try{return eN(t.segments[e.name].when,wy(_,e.settings))}catch{return!0}};return t.menuRuntime.action.layout=()=>vP(ee,te).map(e=>e.flatMap(({name:e,address:t,settings:n})=>{let r=aw(e);return r===void 0?[]:[{name:r,address:t,palette:qb(n.theme,x)}]})),w(ee,!0,Wa(p)).map(e=>ak(cN(e.cells,a),a)).join(`
195
- `)}var RP=class{kind=`box`;cell;lastChangedAt;constructor(e,t,n){this.name=e,this.type=t,WP(e,t,n,`initial value`),this.cell=Dv.observable.box(n,{deep:!1}),this.lastChangedAt=Date.now()}read(){return this.cell.get()}set(e){WP(this.name,this.type,e,`set value`),!Object.is(this.cell.get(),e)&&(this.cell.set(e),this.lastChangedAt=Date.now())}lastUpdatedMs(){return this.lastChangedAt}},zP=class{kind=`computed`;cell;constructor(e,t,n){this.name=e,this.type=t,this.cell=(0,Dv.computed)(()=>{let e=n();return WP(this.name,this.type,e,`computed result`),e},{keepAlive:!0})}read(){return this.cell.get()}lastUpdatedMs(){return null}},BP=class{kind=`document`;cell;lastChangedAt;constructor(e,t){this.name=e,this.cell=Dv.observable.box(UP(t),{deep:!1}),this.lastChangedAt=Date.now()}read(){return this.cell.get()}set(e){let t=UP(e);HP(this.cell.get(),t)||(this.cell.set(t),this.lastChangedAt=Date.now())}lastUpdatedMs(){return this.lastChangedAt}};function VP(e){return JSON.stringify(e)}function HP(e,t){return VP(e)===VP(t)}function UP(e){return e.kind===`ok`?{kind:`ok`,value:Ov(e.value)}:e}function WP(e,t,n,r){let i=kv(n);if(i!==t)throw TypeError(`Variable "${e}": ${r} type ${i} does not match declared type ${t}`)}var GP=class{nodes=new Map;defineBox(e,t,n){this.assertNotDefined(e),this.nodes.set(e,new RP(e,t,n))}defineDocument(e,t){this.assertNotDefined(e),this.nodes.set(e,new BP(e,t))}defineComputed(e,t,n){this.assertNotDefined(e);let r=e=>this.read(e);this.nodes.set(e,new zP(e,t,()=>n(r)))}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()}setDocument(e,t){let n=this.requireNode(e);if(n.kind!==`document`)throw TypeError(`Variable "${e}" is a ${n.kind}, not a document (use defineDocument to create one)`);(0,Dv.runInAction)(()=>n.set(t))}setBox(e,t){let n=this.requireNode(e);if(n.kind!==`box`)throw TypeError(`Variable "${e}" is a ${n.kind}, not a box (use defineBox to create a settable variable)`);(0,Dv.runInAction)(()=>n.set(t))}runInAction(e){(0,Dv.runInAction)(e)}has(e){return this.nodes.has(e)}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`)return VP(t.read());try{return String(t.read())}catch(e){return`failed:${e instanceof Error?e.message:String(e)}`}}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.nodes.keys()]}requireNode(e){let t=this.nodes.get(e);if(!t)throw ReferenceError(`Unknown variable "${e}"`);return t}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}assertNotDefined(e){if(this.nodes.has(e))throw Error(`Variable "${e}" is already declared`)}};function KP(e,t,n){return e+`\0`+t+`\0`+(n??``)}function qP(e,t){return new Set(D_(e.presets).filter(n=>A_(e,n).path===`root`?t.root!==void 0:t.presets?.[n]?.root!==void 0))}function JP(e){let t=c.basename(e),n=c.dirname(e);for(;!r.existsSync(n);)t=c.basename(n),n=c.dirname(n);return{dir:n,name:t}}function YP(e,t){let n=new Map;for(let t of LT(e.projectDir,e.cwd,e.configFile)){let{dir:e,name:r}=JP(t);n.has(e)||n.set(e,new Set),n.get(e).add(r)}return{files:t===null?[]:[t],dirs:[...n.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({path:e,filenames:[...t].sort()}))}}function XP(e){return e.filter(Boolean).join(`
196
- `)||null}function ZP(e,t,n,r){let i=WT(t,iA),{config:a,raw:o}=i;n.push(...i.warnings);let s=qT(i,t??`<default>`),c=new GP,l=new jb(c,s.globals.default_empty_value??``,r.gitService,r.sessionState),u;try{u=MP(s,l,{cwd:e}),n.push(...u.loadWarnings),Fj(s),Hk(s)}catch(e){throw l.dispose(),e}return{config:s,store:c,registry:l,compiled:u,neededInputPaths:KA(s),lastRenderCellsBySegment:new Map,authoredRoots:qP(a,o),fileHeldSettings:xj(o)}}var QP=class{entries=new Map;deps;maxEntries;observers;constructor(e,t={}){this.deps=e,this.maxEntries=t.maxEntries??256,this.observers=t.observers??{}}getOrCreate(e,t,n){let r=KP(e,t,n),i=this.entries.get(r);if(i)return this.entries.delete(r),this.entries.set(r,i),i;let a=this.loadFromDisk(e,t,n),o={projectDir:e,cwd:t,configFile:n,configFilePath:null,lastError:a.error,lastWarning:a.warning,state:a.state??ZP(t,null,[],this.deps),watcher:null,watcherKey:null};if(this.entries.set(r,o),this.entries.size>this.maxEntries){let e=this.entries.entries().next().value;if(e!==void 0){let[t,n]=e;n.state.registry.dispose(),n.watcher?.release(),this.entries.delete(t)}}return this.refreshWatcher(o,a.resolvedPath),this.observers.onReload?.(o),o}reload(e,t,n){this.reloadInto(this.getOrCreate(e,t,n))}reloadInto(e){let t=this.loadFromDisk(e.projectDir,e.cwd,e.configFile);e.lastWarning=t.warning,e.lastError=t.error,t.state!==null&&(e.state.registry.dispose(),e.state=t.state),this.refreshWatcher(e,t.resolvedPath),this.observers.onReload?.(e)}loadFromDisk(e,t,n){let r=zT(e,t,n),i=r.kind===`file`?r.path:null,a=[UT(e,t),VT(r)],o;try{o=ZP(t,i,a,this.deps)}catch(e){return e instanceof xs&&a.push(...e.warnings),{resolvedPath:i,warning:XP(a),state:null,error:e instanceof xs||e instanceof Error?e.message:String(e)}}return{resolvedPath:i,warning:XP(a),state:o,error:null}}refreshWatcher(e,t){e.configFilePath=t;let n=YP(e,t),r=`config:${e.projectDir}:${e.cwd}:${e.configFile??``}:${JSON.stringify(n)}`;e.watcher!==null&&e.watcherKey===r||(e.watcher?.release(),e.watcherKey=r,e.watcher=this.deps.watchers.acquire(r,n,()=>this.onConfigChanged(e)))}onConfigChanged(e){Z(`info`,`config change detected for entry projectDir=${e.projectDir} cwd=${e.cwd}`),this.reloadInto(e)}get size(){return this.entries.size}firstState(){return this.entries.values().next().value?.state??null}};const $P=16384;var eF=class{startedAt=new Date;requestsTotal=0;requestsErrored=0;requestsTimedOut=0;inFlight=0;watchersOpened=0;watchersClosed=0;watchersEvicted=0;subprocessTotal=0;subprocessInFlight=0;subprocessCount=new Map;subprocessHistogram=new Map;subprocessHistogramRotator=new Map;rollingTimestamps=[];rollingHead=0;launchStats={onStart:e=>{this.subprocessTotal++,this.subprocessInFlight++,this.subprocessCount.set(e,(this.subprocessCount.get(e)??0)+1),this.recordRollingNow()},onEnd:(e,t)=>{this.subprocessInFlight=Math.max(0,this.subprocessInFlight-1),this.recordDuration(e,t)}};recordRollingNow(){let e=Date.now();if(this.rollingTimestamps.length<$P){this.rollingTimestamps.push(e);return}this.rollingTimestamps[this.rollingHead]=e,this.rollingHead=(this.rollingHead+1)%$P}recordDuration(e,t){let n=this.subprocessHistogram.get(e);if(n||(n=[],this.subprocessHistogram.set(e,n)),n.length<16){n.push(t);return}let r=(this.subprocessHistogramRotator.get(e)??0)%16;n[r]=t,this.subprocessHistogramRotator.set(e,r+1)}snapshotSubprocesses(){let e=Date.now()-6e4,t=0;for(let n of this.rollingTimestamps)n>=e&&t++;let n={};for(let[e,t]of this.subprocessCount)t>0&&(n[e]=t);let r={},i={};for(let[e,t]of this.subprocessHistogram){if(t.length===0)continue;let n=[...t].sort((e,t)=>e-t),a=Math.floor(n.length*.5),o=Math.min(n.length-1,Math.floor(n.length*.99)),s=n[a],c=n[o];s!==void 0&&(r[e]=s),c!==void 0&&(i[e]=c)}return{total:this.subprocessTotal,inFlight:this.subprocessInFlight,lastMinute:t,byCategory:n,p50DurationMs:r,p99DurationMs:i}}snapshot(e){let t=process.memoryUsage();return{pid:process.pid,version:zD,protocolVersion:3,startedAt:this.startedAt.toISOString(),uptimeSec:Math.floor((Date.now()-this.startedAt.getTime())/1e3),rssBytes:t.rss,heapUsedBytes:t.heapUsed,heapTotalBytes:t.heapTotal,externalBytes:t.external,arrayBuffersBytes:t.arrayBuffers,requests:{total:this.requestsTotal,errored:this.requestsErrored,timedOut:this.requestsTimedOut,inFlight:this.inFlight},gitCache:e.gitCache,usageCache:e.usageCache,renderCache:{size:e.renderCacheSize},watchers:{active:e.watchersActive,opened:this.watchersOpened,closed:this.watchersClosed,evicted:this.watchersEvicted},subprocesses:this.snapshotSubprocesses(),nextRestartReason:e.nextRestartReason??null}}};function tF(e,t,n){let r=(r,i,a)=>{let o=i.filter(t).map(t=>({key:t,before:e.get(r,t)}));a();for(let{key:t,before:i}of o)n(r,t,i,e.get(r,t))};return{get:(t,n)=>e.get(t,n),set:(t,n,i)=>r(t,[n],()=>e.set(t,n,i)),setBatch:(t,n)=>r(t,n.map(e=>e.key),()=>e.setBatch(t,n)),clear:(t,n)=>r(t,[n],()=>e.clear(t,n))}}const nF={load:()=>({}),save:()=>{},flush:()=>{}};function rF(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,new Map(Object.entries(r)));return t}var iF=class{sessions;storage;atom=(0,Dv.createAtom)(`SessionState`);constructor(e=nF,t=256){this.maxSessions=t,this.storage=e,this.sessions=new Map,this.hydrateFromStorage()}useStorage(e){this.storage=e,this.hydrateFromStorage()}hydrateFromStorage(){this.sessions=rF(this.storage.load()),this.evictOldest(),this.persist()}get(e,t){this.atom.reportObserved();let n=this.sessions.get(e);return n?(this.touch(e,n),n.get(t)??null):null}set(e,t,n){this.setBatch(e,[{key:t,value:n}])}setBatch(e,t){t.length!==0&&(0,Dv.runInAction)(()=>{let n=this.sessions.get(e)??new Map;for(let{key:e,value:r}of t)n.set(e,r);this.touch(e,n),this.evictOldest(),this.persist(),this.atom.reportChanged()})}clear(e,t){(0,Dv.runInAction)(()=>{let n=this.sessions.get(e);n&&(n.delete(t),n.size===0?this.sessions.delete(e):this.touch(e,n)),this.persist(),this.atom.reportChanged()})}prune(e){(0,Dv.runInAction)(()=>{for(let t of this.sessions.keys())e.has(t)||this.sessions.delete(t);this.persist(),this.atom.reportChanged()})}touch(e,t){this.sessions.delete(e),this.sessions.set(e,t)}evictOldest(){let e=this.sessions.size-this.maxSessions;if(!(e<=0)){for(let t of this.sessions.keys())if(this.sessions.delete(t),--e===0)break}}flush(){this.storage.flush()}persist(){this.storage.save(this.serialize())}serialize(){let e=Object.create(null);for(let[t,n]of this.sessions)e[t]=Object.fromEntries(n);return e}};function aF(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 oF=class{timer=null;pending=null;constructor(e,t=500,n=$y){this.filePath=e,this.debounceMs=t,this.logger=n}load(){let e;try{e=r.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 aF(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.timer&&(this.timer=setTimeout(()=>this.flush(),this.debounceMs),this.timer.unref())}flush(){if(this.timer&&=(clearTimeout(this.timer),null),this.pending===null)return;let e=this.pending;try{r.mkdirSync(c.dirname(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp`;r.writeFileSync(t,JSON.stringify(e),{mode:384}),r.chmodSync(t,384),r.renameSync(t,this.filePath),this.pending=null}catch(e){this.logger(`warn`,`session-state save failed: ${e.message}`)}}};const sF={default_empty_value:`string`,default_separator:`string`,palette:`string`,style:`string`,preset:`string`,endcaps:`string`,variation:`string`,autoWrap:`boolean`,padding:`number`,charset:`string`,updateNotice:`boolean`,colorCompatibility:`string`,menuGlyph:`string`},cF=new Set([`1`,`true`]),lF=new Set([`0`,`false`,``]);function uF(e,t){let n=FF(e),r=n.scope===`segment-palette`?`string`:sF[n.field];if(r===`string`)return JSON.stringify(t);if(r===`number`){let n=Number(t);if(!Number.isFinite(n))throw Error(`persistValueText: "${e}" expects a number, got "${t}"`);return String(n)}if(cF.has(t))return`true`;if(lF.has(t))return`false`;throw Error(`persistValueText: "${e}" expects boolean-ish (1, 0, true, false), got "${t}"`)}function dF(e){try{return r.readFileSync(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return null;throw e}}function fF(e,t,n){try{if(t===null){r.rmSync(e,{force:!0});return}r.mkdirSync(c.dirname(e),{recursive:!0}),je(e,t)}catch(t){let r=`config write failed (${e}): ${t.message}`;throw n(`error`,r),Error(r)}}function pF(e){return/^\s*$/.test(e)?null:Lo(e)}function mF(e,t){return e!==null&&zo(e,t)!==void 0}function hF(e){if(e.kind===`segment`)return e.when===void 0?e.name:{seg:e.name,when:e.when};if(e.kind===`container`){let{kind:t,direction:n,children:r,...i}=e;return{[n===`horizontal`?`h`:`v`]:r.map(hF),...i}}return e}function gF(e){if(!Mc(e))return hF(e);let{rows:t,...n}=e;return{rows:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,hF(t)])),...n}}const _F=nA,vF=_F.segments,yF=_F.presets,bF=_F.root;function xF(e,t,n,r){if(!mF(e,t)&&n===void 0)throw new $(`cannot edit ${r}: neither the config file nor the bundled default declares ${t.join(`.`)}`)}function SF(e,t){let n=_x(t);return t.scope===`segment-palette`&&xF(e,[`segments`,t.segment],vF[t.segment],n.join(`.`)),n}function CF(e){return Lo(qo(e))}function wF(){return Object.entries(bF.rows).map(([e,t])=>{let n=hF(t);return{path:[`root`],fragment:CF({rows:{[e]:n}}),unit:{path:[`root`,`rows`,e],value:n}}})}function TF(e,t){let n=e===null?void 0:zo(e,t);return n===void 0?null:{path:t,fragment:n,unit:null}}function EF(e,t){if(t===void 0)return null;let n=gF(t);return{path:e,fragment:CF(n),unit:{path:e,value:n}}}function DF(e,t){let n=[`presets`,t],r=[...n,`root`],i=yF[t];xF(e,n,i,r.join(`.`));let a=TF(e,r)??EF(r,i?.root);return a!==null&&ms(a.fragment)?a:null}function OF(e,t){let n=ps(t.fragment);return n===null?new Map([[`#`,{path:t.path,unit:t.unit,node:t.fragment}]]):new Map([...e,...n.map(e=>[e.key,{path:[...t.path,`rows`,e.key],unit:t.unit,node:e.value}])])}function kF(e,t){return[...wF(),TF(e,[`root`]),DF(e,t)].filter(e=>e!==null).reduce(OF,new Map)}function AF(e,t,n){for(let{node:r,...i}of kF(e,t).values())if(gs(r,n))return i;throw new $(`${jF(e,t).join(`.`)} holds no placement "${n}" — the bar you clicked is stale (it reloads on the next render), or the action names a placement the layout never held`)}function jF(e,t){return DF(e,t)?.path??[`root`]}function MF(e,t){return t.scope===`preset-root`?jF(e,t.preset):_x(t)}function NF(e,{unit:t}){return t===null?e:ss(e,t.path,qo(t.value),Go)}function PF(e){let t=gx(e);if(t===null)throw Error(`"${e}" is not a valid persist target`);return t}function FF(e){let t=PF(e);if(t.scope===`preset-root`)throw Error(`"${e}" names a layout, not a value`);return t}function IF(e,t,n,r){LF(t,r),fF(t,r,e.logger),e.record(t,n,r)}function LF(e,t){try{return qT(GT(e,t,iA),e)}catch(e){throw e instanceof xs?new $(`refused: the config file would not load after this click — ${e.message}`):e}}function RF(e,t){let n=FF(t),r=pF(dF(e)??``),i=r===null?void 0:zo(r,_x(n));return i!==void 0&&`value`in i?i.value:void 0}function zF(e,t,n){BF(e,t,n,[])}function BF(e,t,n,r){let i=dF(t);IF(e,t,i,VF(n.reduce((e,[t,n])=>ss(e,SF(pF(e),FF(t)),uF(t,n),Go),i??``),t,r,e=>e))}function VF(e,t,n,r){return n.reduce((e,{preset:n,id:i,setting:a,value:o})=>{let s=r(e,n,i),c=AF(pF(s),n,i),l=bs(NF(s,c),c.path,i,a,qo(o));if(l===null)throw new $(`${c.path.join(`.`)} in ${t} has no placement "${i}" — the bar you clicked is stale (it reloads on the next render)`);return l},e)}function HF(e,t,n){let r=pF(e),i=[`presets`,t,`root`];for(let[a,{path:o,unit:s,node:c}]of kF(r,t)){if(!gs(c,n))continue;if(i.every((e,t)=>o[t]===e))return e;let l=s===null?Vo(e,c):qo(s.value);if(a!==`#`)return ss(e,[...i,`rows`,a],l,Go);if(DF(r,t)!==null)throw new $(`cannot give preset "${t}" its own copy of ${o.join(`.`)}: it already stages rows of its own over that tree`);return ss(e,i,l,Go)}return e}function UF(e,t){return ls(e,t,t[0]===`presets`&&t.length>2&&!oA(t[1])?2:0)}function WF(e,t,n){let r=n.map(PF),i=dF(t);if(i===null)return;let a=r.reduce((e,t)=>UF(e,MF(pF(e),t)),i);a!==i&&IF(e,t,i,a)}function GF(e){let t=e===null?void 0:zo(e,[`presets`]),n=new Set([...aA,...t?.kind===`object`?t.entries.map(e=>e.key):[]].map(yu));return Array.from({length:n.size+1},(e,t)=>`custom-${t+1}`).find(e=>!n.has(yu(e)))}function KF(e,t,n,r,i,a){let o=dF(t),s=pF(o??``),c=GF(s),l=[`presets`,c],u=DF(s,n),d=[...u===null?[]:[[[...l,`root`],u.unit===null?Vo(o??``,u.fragment):qo(u.unit.value)]],...Object.keys(r).length===0?[]:[[[...l,`globals`],qo(r)]]],f=i.map(([e,t])=>{let n=hx(c,e);return[SF(s,FF(n)),uF(n,t)]});return IF(e,t,o,VF([...d,...f].reduce((e,[t,n])=>ss(e,t,n,Go),ss(o??``,l,`{}`,Go)),t,a.map(e=>({...e,preset:c})),HF)),c}function qF(e,t,n){if(oA(n))throw new $(`cannot delete preset "${n}": it is bundled — reset its settings instead`);let r=[`presets`,n],i=dF(t),a=pF(i??``);if(i===null||a===null||zo(a,r)===void 0)throw new $(`cannot delete preset "${n}": ${t} declares no ${r.join(`.`)} — the bar you clicked is stale; it reloads on the next render`);let o=zo(a,[`globals`,`preset`]);IF(e,t,i,[r,...o?.kind===`string`&&o.value===n?[[`globals`,`preset`]]:[]].reduce((e,t)=>UF(e,t),i))}function JF(e,t,n,r){let i=PF(n);if(i.scope!==`preset-root`)throw Error(`"${n}" is not a "presets.<name>.root" target`);let a=dF(t),o=r.op===`remove`?r.target:r.anchor,s=AF(pF(a??``),i.preset,o),c=NF(a??``,s),{after:l,placed:u}=YF(c,s.path,r,()=>{let e=LF(t,c);return D_(e.presets).map(t=>A_(e,t).node)});if(l===null)throw new $(`${s.path.join(`.`)} in ${t} has no placement "${o}" — the bar you clicked is stale (it reloads on the next render), or the action names a placement the layout never held`);return IF(e,t,a,l),u}function YF(e,t,n,r){switch(n.op){case`remove`:return{after:vs(e,t,n.target),placed:null};case`insert`:{let i=kk(n.segment,n.anchor,r());return{after:ys(e,t,i,n.anchor,n.relation),placed:i}}}}const XF={load:()=>({}),save:()=>{}},ZF=new Set(Fb.map(e=>e.sessionKey)),QF=e=>ZF.has(e)||e.startsWith(Z_),$F=8*1024*1024,eI={past:[],future:[]},tI=e=>e.kind===`session`?`session:${e.key}`:`file:${e.file}`;var nI=class{state=new Map;constructor(e,t,n=XF){this.sessionState=e,this.logger=t,this.storage=n,this.state=new Map(Object.entries(n.load()))}useStorage(e){this.storage=e,this.state=new Map(Object.entries(e.load()))}depth(e){let{past:t,future:n,savepoint:r}=this.state.get(e)??eI;return{undo:t.length,redo:n.length,sinceEdit:r?.net.length??0}}history(e){return this.state.get(e)??eI}begin(){let e=new Map,t=(t,n)=>{let r=e.get(t)??new Map,i=r.get(tI(n));r.set(tI(n),i===void 0?n:{...n,before:i.before}),e.set(t,r)},n=new Map;return{sessionState:tF(this.sessionState,e=>QF(e)||e===`edit.mode`,(e,r,i,a)=>{if(r===`edit.mode`){let t=n.get(e);n.set(e,{before:t===void 0?i:t.before,after:a});return}t(e,{kind:`session`,key:r,before:i,after:a})}),file:(e,n,r,i)=>t(e,{kind:`file`,file:n,before:r,after:i}),commit:()=>{let t=new Map(e),r=new Map(n);e.clear(),n.clear();for(let e of new Set([...t.keys(),...r.keys()])){let n=[...t.get(e)?.values()??[]].filter(e=>e.before!==e.after),i=this.history(e),a=n.length===0?i:uI(i,n),o=r.get(e),s=o===void 0?a:mI(a,o);s!==i&&this.put(e,s)}}}}undo(e){let t=this.history(e),n=t.past.at(-1);if(n===void 0)throw new $(`undo: nothing to undo`);return this.apply(e,n,`before`,`undo`,fI(t,n)),n}rewind(e){let t=this.history(e),{savepoint:n}=t;if(n===void 0)throw new $(`rewind: edit mode has no savepoint — nothing to cancel`);let r=n.net.filter(t=>this.read(e,t)!==t.after),i=new Set(r.map(tI)),a=n.net.filter(e=>!i.has(tI(e))),o=aI(hI(pI(t,n),i));if(this.apply(e,a,`before`,`rewind`,{past:o,future:[],savepoint:{at:o.length,net:[],below:[]}}),r.length>0)throw new $(`rewind: ${r.map(_I).join(`, `)} changed since edit mode opened — kept as it is; everything else edit mode changed was put back`);return a}redo(e){let t=this.history(e),{past:n,future:r}=t,i=r.at(-1);if(i===void 0)throw new $(`redo: nothing to redo`);let a=[...n,i],o=aI(a);return this.apply(e,i,`after`,`redo`,{past:o,future:r.slice(0,-1),...sI(t.savepoint,a.length-o.length,i)}),i}apply(e,t,n,r,i){let a=n===`before`?`after`:`before`,o=t.filter(t=>this.read(e,t)!==t[a]);if(o.length>0){let t=new Set(o.map(tI)),{past:n,future:i,savepoint:a}=this.history(e);throw this.put(e,{past:hI(n,t),future:hI(i,t),...a!==void 0&&{savepoint:{at:hI([...n,...[...i].reverse()].slice(0,a.at),t).length,net:a.net.filter(e=>!t.has(tI(e))),below:hI(a.below,t)}}}),new $(`${r}: ${o.map(_I).join(`, `)} changed since that edit — refusing to overwrite it; this session's undo history no longer steps it`)}let s=[];try{for(let r of t)this.write(e,r,r[n]),s.push(r);this.put(e,i)}catch(t){try{for(let t of s.reverse())this.write(e,t,t[a])}catch(e){throw Error(`${t.message}; and putting the step back failed, so it is half-applied: ${e.message}`)}throw t}}read(e,t){return t.kind===`session`?this.sessionState.get(e,t.key):dF(t.file)}write(e,t,n){t.kind===`file`?fF(t.file,n,this.logger):n===null?this.sessionState.clear(e,t.key):this.sessionState.set(e,t.key,n)}put(e,t){let n=new Map(this.state);for(n.delete(e),(t.past.length>0||t.future.length>0||t.savepoint!==void 0)&&n.set(e,t);n.size>32||rI(n)>$F;){let[e,t]=n.entries().next().value;n.size>1?n.delete(e):t.past.length+t.future.length>0?n.set(e,iI(t)):(this.logger(`warn`,`settings-history: edit mode's changes for session ${e} exceed ${$F} bytes; cancel is no longer available`),n.delete(e))}this.storage.save(Object.fromEntries(n)),this.state=n}};function rI(e){let t=0;for(let{past:n,future:r,savepoint:i}of e.values())for(let e of[...n,...r,...i===void 0?[]:[i.net,...i.below]])for(let n of e)t+=(n.before?.length??0)+(n.after?.length??0);return t}function iI({past:e,future:t,savepoint:n}){return e.length>0?{past:e.slice(1),future:t,...sI(n,1,[])}:{past:e,future:t.slice(1),...sI(n,0,[])}}function aI(e){return e.slice(-50)}const oI=e=>e===$_.member;function sI(e,t,n){return e===void 0?{}:{savepoint:{at:Math.max(0,e.at-t),net:cI(e.net,n),below:e.below}}}function cI(e,t){let n=new Map(e.map(e=>[tI(e),e]));for(let e of t){let t=n.get(tI(e));n.set(tI(e),t===void 0?e:{...t,after:e.after})}return[...n.values()].filter(e=>e.before!==e.after)}const lI=e=>e.map(e=>({...e,before:e.after,after:e.before}));function uI(e,t){let n=[...e.past,t],r=aI(n),{savepoint:i}=e,a=i===void 0?0:Math.max(0,i.at-e.past.length);return{past:r,future:[],...sI(i&&{at:Math.min(i.at,e.past.length),net:i.net,below:[...dI(e.future,a),...i.below]},n.length-r.length,t)}}function dI(e,t){let n=Math.min(t,e.length);return e.slice(e.length-n).reverse()}function fI(e,t){return{past:e.past.slice(0,-1),future:aI([...e.future,t]),...sI(e.savepoint,0,lI(t))}}function pI(e,t){let{past:n,future:r}=e,i=n.slice(0,t.at);return[...i,...dI(r,t.at-i.length),...t.below]}function mI(e,t){if(oI(t.after)&&!oI(t.before))return{...e,savepoint:{at:e.past.length,net:[],below:[]}};if(!oI(t.after)&&oI(t.before)){let{past:t,future:n}=e;return{past:t,future:n}}return e}function hI(e,t){return e.map(e=>e.filter(e=>!t.has(tI(e)))).filter(e=>e.length>0)}function gI(e){return e.map(_I).join(`, `)}function _I(e){return e.kind===`session`?`session setting "${e.key}"`:e.file}function vI(e){if(typeof e!=`object`||!e)return!1;let t=e,n=e=>e===null||typeof e==`string`;return(t.kind===`session`&&typeof t.key==`string`||t.kind===`file`&&typeof t.file==`string`)&&n(t.before)&&n(t.after)}function yI(e){return Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(vI))}function bI(e){if(typeof e!=`object`||!e)return!1;let t=e;return Number.isInteger(t.at)&&t.at>=0&&Array.isArray(t.net)&&t.net.every(vI)&&yI(t.below)}function xI(e){if(typeof e!=`object`||!e)return!1;let t=e;return yI(t.past)&&yI(t.future)&&(t.savepoint===void 0||bI(t.savepoint))}function SI(e,t){return{load:()=>{let n;try{n=r.readFileSync(e,`utf8`)}catch(e){let n=e.code;return n!==`ENOENT`&&t(`warn`,`settings-history read failed (${n}); starting empty`),{}}try{let e=JSON.parse(n);if(typeof e==`object`&&e&&!Array.isArray(e)&&Object.values(e).every(xI))return e}catch{}return t(`warn`,`settings-history load: unexpected shape, starting empty`),{}},save:n=>{try{r.mkdirSync(c.dirname(e),{recursive:!0}),je(e,JSON.stringify(n),384)}catch(e){let n=`settings-history write failed — the change landed but is not undoable: ${e.message}`;throw t(`error`,n),Error(n)}}}}const CI=e=>!QF(e)&&!Wx(e)&&e!==`update.dismissed`;var wI=class{past=new Map;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:tF(e,CI,(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 $(`back: nothing to go back to${o>0?` (${o} step(s) over a view since gone, discarded)`:``}`);return(0,Dv.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){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)}};function TI(e){let t=qM(e,`doctor.tmux`,[`display`,`-p`,`-t`,e.pane,`#{client_termfeatures}`]);return t.kind===`ok`?{kind:`ok`,value:t.stdout.trim().split(`,`).filter(e=>e!==``)}:{kind:`failed`,reason:t.reason}}function EI(){return{probeTmux:TI}}function DI(e){let t=rS(e).env;if(t===void 0)return{path:e,env:{}};if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`cannot read ${e}: \`env\` is not an object`);return{path:e,env:t}}function OI(e,t){return t===void 0?{kind:`unreported`}:t===null?{kind:`outside`}:{kind:`inside`,hint:t,termfeatures:e.probeTmux(t)}}function kI(e,t){return{tmux:OI(e,t.tmux),claudeSettings:DI(eS($x(t.claudeConfigDir)))}}function AI(e,t){let n=t.claudeSettings.path;switch(e.kind){case`claude-settings-env`:{let i=ss(nS(n),[`env`,e.name],JSON.stringify(e.value),Ko);return r.mkdirSync(c.dirname(n),{recursive:!0}),je(n,i),{...t,claudeSettings:DI(n)}}default:return e.kind}}const jI=/^─{20,}/,MI=/^❯(\s|$)/,NI=/›\s*stashed$/;function PI(e){if(e.inMode)return{kind:`in-mode`};let t=e.screen.map(e=>e.trimEnd()),n=t.flatMap((e,t)=>jI.test(e)?[t]:[]).at(-2);return n===void 0||!MI.test(t[n+1]??``)?{kind:`no-prompt`}:NI.test(t[n-1]??``)?{kind:`stashed`}:{kind:`ready`}}const FI={"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 II(e,t,n){if(t===void 0)return{kind:`refused`,reason:`this session's statusline client reports no tmux facts (it predates this daemon) — rebuild or reinstall cc-candybar`};if(t===null)return{kind:`refused`,reason:`this Claude Code is not running inside tmux — the bar can only type into a tmux pane`};let r=PI(e.read(t));if(r.kind!==`ready`)return{kind:`refused`,reason:FI[r.kind]};let i=e.type(t,n);return i.kind===`typed`?{kind:`typed`,pane:t.pane}:i}const LI=`cc-candybar-slash`;function RI(e,t,n,r){let i=qM(e,t,n,r);if(i.kind===`failed`)throw Error(i.reason);return i}function zI(e){let t=RI(e,`claude-input.read`,[`display`,`-p`,`-t`,e.pane,`#{pane_in_mode}`,`;`,`capture-pane`,`-p`,`-t`,e.pane]);if(t.kind===`rate-limited`)throw Error(t.reason);let[n=``,...r]=t.stdout.split(`
197
- `);return{inMode:n!==`0`,screen:r}}function BI(e,t){let n=RI(e,`claude-input.type`,[`load-buffer`,`-b`,LI,`-`,`;`,`send-keys`,`-t`,e.pane,`C-s`,`;`,`paste-buffer`,`-p`,`-d`,`-b`,LI,`-t`,e.pane,`;`,`send-keys`,`-t`,e.pane,`Enter`],t);return n.kind===`ok`?{kind:`typed`}:{kind:`refused`,reason:`cc-candybar typed a command moments ago — click again in a second (${n.reason})`}}function VI(){return{read:zI,type:BI}}function HI(e){if(!e)throw new $(`session id is required`);if(e.includes(`/`)||e.includes(`..`))throw new $(`invalid session id "${e}"`);return e}function UI(e){return WI(()=>decodeURIComponent(e))}function WI(e){try{return e()}catch(e){throw e instanceof URIError?new $(`malformed wire encoding: ${e.message}`):e}}function GI(e,t){let n=ke({bin:`/usr/bin/pbcopy`,stdinInput:e,category:`click.pbcopy`});if(!n.ok){if(n.reason===`rate-limited`){t.dlog(`warn`,`click.pbcopy rate-limited: ${n.error??``}`);return}throw Error(`pbcopy failed (${n.reason}, exit ${n.exitCode??`null`})`)}}const KI=(e,t)=>GI(UI(e),t),qI=(e,t)=>{let n=ke({bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,UI(e)],category:`click.open`});if(!n.ok){if(n.reason===`rate-limited`){t.dlog(`warn`,`click.open rate-limited: ${n.error??``}`);return}throw Error(`open -a "Visual Studio Code" failed (${n.reason}, exit ${n.exitCode??`null`})`)}},JI=(e,t)=>GI(UI(e),t),YI=(e,t)=>GI(UI(e),t),XI=(e,t)=>{let n=HI(UI(e));t.navigating.get(n,`toolbar-expanded`)?t.navigating.clear(n,`toolbar-expanded`):t.navigating.set(n,`toolbar-expanded`,`1`)},ZI=(e,t)=>{let[n=``,...r]=WI(()=>MD(e)),i=HI(n),a=Fj(lL(t,i));if(r.length===0)throw new $(`set-state: <key>/<value> is required (have keys: ${a.listKeys().join(`, `)})`);if(r.length%2!=0)throw new $(`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 $(`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 $(`set-state: pair ${e/2+1}: ${i.reason}`);o.push({key:t,value:i.value})}tL(t,i,`set-state`,o),t.navigating.setBatch(i,o);let s=o.map(e=>`${e.key}=${e.value}`).join(` `);t.dlog(`info`,`set-state: ${s} (session=${i})`)},QI=/^-?\d+$/;function $I(e,t,n,r){let i=e+t;return i>r?e===r?n:r:i<n?e===n?r:n:i}const eL=(e,t)=>{let[n=``,r=``,i=``]=WI(()=>MD(e)),a=HI(n);if(!r)throw new $(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!QI.test(i))throw new $(`step-state: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=lL(t,a),c=Fj(s),l=c.rangeParamsFor(r);if(!l)throw new $(`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&&QI.test(u)?nL(l,parseInt(u,10)):rL(`step-state`,r,l,Rj(s,e=>t.sessionState.get(a,e),r)),f=$I(d,o,l.min,l.max),p=c.validate(r,String(f));if(!p.ok)throw new $(`step-state: ${p.reason}`);tL(t,a,`step-state`,[{key:r,value:p.value}]),t.navigating.set(a,r,p.value),t.dlog(`info`,`step-state: ${r} ${d}→${p.value} (by ${o}, session=${a})`)};function tL(e,t,n,r){let i=r.filter(e=>e.key.startsWith(Z_));if(i.length===0)return;let a=gj(lL(e,t),n=>e.sessionState.get(t,n),i);if(a.length>0)throw new $(`${n}: refused — ${a.join(`; `)}`)}function nL(e,t){return Math.max(e.min,Math.min(e.max,t))}function rL(e,t,n,r){if(r===null)return n.min;if(!QI.test(r))throw new $(`${e}: "${t}" shows ${JSON.stringify(r)} before any click, not an integer to step`);return nL(n,parseInt(r,10))}const iL=`render-origin`;function aL(e){return JSON.stringify(e)}function oL(e){let t;try{t=JSON.parse(e)}catch{throw new $(`render origin is not JSON: ${e}`)}if(typeof t!=`object`||!t)throw new $(`render origin is not an object: ${e}`);let{projectDir:n,cwd:r,configFile:i}=t;if(typeof n!=`string`||typeof r!=`string`||i!==null&&typeof i!=`string`)throw new $(`render origin has the wrong shape: ${e}`);return{projectDir:n,cwd:r,configFile:i}}function sL(e,t){let n=e.sessionState.get(t,iL);if(n===null)throw new $(`session ${t} has not rendered yet — no config to act on`);return oL(n)}function cL(e,t,n){let r=e.sessionState.get(t,iL);if(r===null)return;let i=oL(r),a=uL(i);n.some(e=>e.kind===`file`&&e.file===a)&&e.reloadConfig(i)}function lL(e,t){return e.configFor(sL(e,t))}function uL(e){return BT(e.projectDir,e.cwd,e.configFile??void 0)}function dL(e,t){return{record:(n,r,i)=>e.journal.file(t,n,r,i),logger:e.dlog}}const fL=(e,t)=>{let[n=``,r=``,i=``]=WI(()=>MD(e)),a=HI(n),o=sL(t,a),s=t.configFor(o),c=Hk(s);if(!r)throw new $(`set-config: <key>/<value> is required (have keys: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new $(`set-config: ${l.reason}`);let u=uL(o),d=mj(s,e=>t.sessionState.get(a,e),r);zF(dL(t,a),u,[[d.key,l.value]]),t.reloadConfig(o),t.dlog(`info`,`set-config: ${d.key}=${l.value} → ${u} (session=${a})`)},pL=(e,t)=>{let[n=``,r=``,i=``]=WI(()=>MD(e)),a=HI(n);if(!r)throw new $(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!QI.test(i))throw new $(`step-config: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=sL(t,a),c=t.configFor(s),l=Hk(c),u=l.rangeParamsFor(r);if(!u)throw new $(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${l.listKeys().join(`, `)})`);let d=uL(s),f=mj(c,e=>t.sessionState.get(a,e),r),p=RF(d,f.key),m=typeof p==`number`?nL(u,p):rL(`step-config`,r,u,Wk(f.globals,r)),h=$I(m,o,u.min,u.max),g=l.validate(r,String(h));if(!g.ok)throw new $(`step-config: ${g.reason}`);zF(dL(t,a),d,[[f.key,g.value]]),t.reloadConfig(s),t.dlog(`info`,`step-config: ${f.key} ${m}→${g.value} (by ${o}) → ${d} (session=${a})`)},mL=(e,t)=>{let[n=``]=WI(()=>MD(e)),r=HI(n),i=sL(t,r),a=t.configFor(i),o=e=>t.sessionState.get(r,e),s=fj(a,o),c=hj(a,o);if(s.length+c.length===0){t.dlog(`info`,`save: nothing unsaved (session=${r})`);return}let l=Fj(a),u=s.map(e=>{let t=l.validate(e.sessionKey,e.value);if(!t.ok)throw new $(`save: ${t.reason}`);return[e.target,t.value]});gL(`save`,l,c);let d=uL(i);BF(dL(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.dlog(`info`,`save: ${[...u.map(([e,t])=>`${e}=${t}`),...c.map(hL)].join(` `)} → ${d} (session=${r})`)},hL=e=>`${e.preset}/${e.id}.settings.${e.setting}=${Ks(e.value)}`;function gL(e,t,n){for(let r of n){let n=t.validate(r.key,Ks(r.value));if(!n.ok)throw new $(`${e}: ${n.reason}`)}}const _L=(e,t)=>{let[n=``]=WI(()=>MD(e)),r=HI(n),i=sL(t,r),a=t.configFor(i),o=yj(a,e=>t.sessionState.get(r,e)),s=Fj(a),c=o.picks.map(e=>{let t=s.validate(e.sessionKey,e.value);if(!t.ok)throw new $(`save-preset: ${t.reason}`);return[e.configKey,t.value]});gL(`save-preset`,s,o.placements);let l=uL(i),u=KF(dL(t,r),l,o.from,o.globals,c,o.placements);t.reloadConfig(i);for(let e of[...Fb.map(e=>e.sessionKey),...o.placements.map(e=>e.key)])t.sessionState.clear(r,e);t.sessionState.set(r,Pb.preset.sessionKey,u),t.dlog(`info`,`save-preset: ${[`${u} from=${o.from}`,...c.map(([e,t])=>`${e}=${t}`),...o.placements.map(hL)].join(` `)} → ${l} (session=${r})`)},vL=(e,t)=>{let[n=``,r=``]=WI(()=>MD(e)),i=HI(n);if(!r)throw new $(`delete-preset: <name> is required (shape: <sessionId>/<name>)`);let a=sL(t,i),o=uL(a);qF(dL(t,i),o,r),t.reloadConfig(a);let s=Pb.preset.sessionKey;t.sessionState.get(i,s)===r&&t.sessionState.clear(i,s),t.dlog(`info`,`delete-preset: ${r} ← ${o} (session=${i})`)},yL=(e,t)=>{let[n=``,...r]=WI(()=>MD(e)),i=HI(n),a=sL(t,i),o=Hk(t.configFor(a)).listKeys(),s=r.length===0?[``]:r.filter(e=>!o.includes(e));if(s.length>0)throw new $(`reset-config: unknown config key "${s.join(`", "`)}" (have: ${o.join(`, `)})`);let c=uL(a),l=r.map(bj),u=l.flatMap(e=>e.fileKeys),d=l.flatMap(e=>e.sessionKeys);WF(dL(t,i),c,u),t.reloadConfig(a);for(let e of d)t.sessionState.clear(i,e);t.dlog(`info`,`reset-config: ${[...u,...d.map(e=>`session:${e}`)].join(` `)} ← ${c} (session=${i})`)};function bL(e,t){let n=(e,t)=>[...Ms(A_(e,t).node)].filter(e=>e.kind===`segment`),r=new Set(D_(t.presets).flatMap(e=>n(t,e).map(t=>Q_(yu(e),Os(t)))));return D_(e.presets).flatMap(t=>n(e,t).map(e=>({member:Q_(yu(t),Os(e)),node:e})).filter(({member:e})=>!r.has(e)))}function xL(e,t){return e.flatMap(({member:e,node:n})=>[...Object.values(n.drafts??{}).map(e=>e.key),...e===t?[K_]:[]])}const SL=(e,t)=>{let[n=``,r=``,i=``]=WI(()=>MD(e)),a=HI(n),o=sL(t,a),s=t.configFor(o),c=Hk(s);if(!r)throw new $(`apply-layout-op: <key>/<op> is required (have: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new $(`apply-layout-op: ${l.reason}`);let u=Ok(l.value);if(u===null)throw new $(`apply-layout-op: "${l.value}" is not a layout op token`);let d=uL(o),f=JF(dL(t,a),d,r,u);t.reloadConfig(o);let p=xL(bL(s,t.configFor(o)),t.sessionState.get(a,K_)).filter(e=>t.sessionState.get(a,e)!==null);for(let e of p)t.sessionState.clear(a,e);t.dlog(`info`,`apply-layout-op: ${r} ${l.value} → ${d} placed=${JSON.stringify(f)} released=${JSON.stringify(p)} (session=${a})`)},CL=(e,t)=>{let[n=``]=WI(()=>MD(e)),r=HI(n);t.journal.commit();let i=t.history.undo(r);cL(t,r,i),t.dlog(`info`,`undo: restored ${gI(i)} (session=${r})`)},wL=(e,t)=>{let n=HI(UI(e)),{step:r,discarded:i}=t.navigation.back(n,t.sessionState,Fj(lL(t,n))),a=r.map(e=>`${e.key}=${e.before??`∅`}`).join(` `);t.dlog(`info`,`back: ${a} discarded=${i} (session=${n})`)},TL=(e,t)=>{let n=HI(UI(e));t.journal.commit();let r=t.history.rewind(n);cL(t,n,r),t.dlog(`info`,`rewind: put back ${gI(r)||`nothing`} as edit mode found it (session=${n})`)},EL=(e,t)=>{let[n=``]=WI(()=>MD(e)),r=HI(n);t.journal.commit();let i=t.history.redo(r);cL(t,r,i),t.dlog(`info`,`redo: re-applied ${gI(i)} (session=${r})`)},DL=(e,t)=>{HI(UI(e)),t.applyUpdate()},OL=`client-hints`;function kL(e,t){let n=e.sessionState.get(t,OL);if(n===null)throw new $(`session ${t} has not rendered yet — no client facts are recorded for it`);let r;try{r=JSON.parse(n)}catch{throw new $(`client hints record is not JSON: ${n}`)}if(typeof r!=`object`||!r)throw new $(`client hints record is not an object: ${n}`);return eE(r)}function AL(e,t,n){let r=Px(n);e.sessionState.setBatch(t,Rx(r)),e.dlog(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed`}`).join(` `)} (session=${t})`)}const jL=(e,t)=>{let n=HI(UI(e));AL(t,n,kI(t.doctor,kL(t,n)))},ML=(e,t)=>{let[n=``,r=``]=WI(()=>MD(e)),i=HI(n),a=Fx(r);if(a===void 0)throw new $(`doctor-fix: unknown check "${r}"`);let o=kI(t.doctor,kL(t,i)),s=a.probe(o);if(s.ok||s.fix===void 0)throw new $(`doctor-fix: ${a.label} — ${s.ok?`nothing to fix`:s.reason}`);let c=AI(s.fix,o);t.dlog(`info`,`doctor-fix: ${a.name} → ${s.fix.kind} ${s.fix.name}=${s.fix.value} (session=${i})`),AL(t,i,c)},NL=(e,t)=>{let[n=``,...r]=WI(()=>MD(e)),i=HI(n),a=sL(t,i),o=Object.values(t.configFor(a).actions).filter(e=>`ceiling`in e).find(e=>{let t=mw(e);return t.length===r.length&&t.every((e,t)=>e===r[t])});if(o===void 0)throw new $(`ceiling: "${r.join(` `)}" is not a move this config declares`);let s=o.ceiling===`set`?{kind:`set`,to:o.to}:{kind:`clear`},c=bA({sessionId:i,projectDir:a.projectDir,cwd:a.cwd},kL(t,i));t.memento.move(c,s),t.dlog(`info`,`ceiling: ${r.join(` `)} (session=${i} claudeConfigDir=${c.claudeConfigDir})`)},PL=(e,t)=>{let[n=``,r=``]=WI(()=>MD(e)),i=HI(n),a=Object.values(t.configFor(sL(t,i)).actions).filter(e=>`slash`in e),o=a.find(e=>e.slash===r);if(o===void 0)throw new $(`${JSON.stringify(r)} is not a command this config declares (it declares: ${[...new Set(a.map(e=>e.slash))].join(`, `)||`none`})`);let s=II(t.claudeInput,kL(t,i).tmux,o.slash);if(s.kind===`refused`)throw t.dlog(`warn`,`slash: ${r} refused — ${s.reason} (session=${i})`),new $(`${r} was not typed: ${s.reason}`);t.dlog(`info`,`slash: typed ${r} into ${s.pane} (session=${i})`)},FL=`config-override`,IL=new Map([[uD,KI],[`load-config`,(e,t)=>{let n=e.indexOf(`/`);if(n===-1)throw new $(`load-config: expected <sessionId>/<path> (missing separator)`);let r=HI(WI(()=>decodeURIComponent(e.slice(0,n)))),i=WI(()=>decodeURIComponent(e.slice(n+1))).trim();if(i!==``){if(!i.startsWith(`/`))throw new $(`load-config: path must be absolute, got "${i}"`);if(!/\.(json5?|json)$/.test(i))throw new $(`load-config: path must end with .json5 or .json, got "${i}"`)}i===``?(t.sessionState.clear(r,FL),t.dlog(`info`,`load-config: override cleared (session=${r})`)):(t.sessionState.set(r,FL,i),t.dlog(`info`,`load-config: ${i} (session=${r})`))}],[dD,qI],[cD,ZI],[lD,eL],[hD,fL],[gD,pL],[bD,yL],[_D,mL],[vD,_L],[yD,vL],[xD,SL],[SD,CL],[CD,EL],[wD,wL],[TD,TL],[pD,JI],[mD,YI],[fD,XI],[ED,DL],[DD,jL],[OD,ML],[kD,NL],[AD,PL]]),LL=new Set([cD,lD,hD,gD,bD,_D,vD,yD,xD,SD,CD,wD,TD,fD,ED,DD,OD,kD,AD]),RL=(e,t)=>{let n=[],r=!1,i=null;for(let{verb:a,value:o}of ID(PD(e))){if(!i&&LL.has(a)){let e=MD(o);e.length>0&&e[0]&&(i=e[0])}let e=IL.get(a);if(!e){n.push(`unknown effect verb "${a}"`);continue}try{e(o,t)}catch(e){e instanceof $||(r=!0),n.push(`${a}: ${e instanceof Error?e.message:String(e)}`)}}if(n.length>0){i&&t.sessionState.set(i,`click.error`,n.join(`
198
- `));let e=`dispatch: ${n.join(`; `)}`;throw r?Error(e):new $(e)}};function zL(e){return(t,n)=>{let r=n.history.begin(),i=n.navigation.begin(r.sessionState),a=[];try{e(t,{...n,sessionState:r.sessionState,journal:r,navigating:i.sessionState})}catch(e){a.push(e)}i.commit();try{r.commit()}catch(e){a.push(e)}if(a.length===1)throw a[0];if(a.length>1)throw Error(a.map(e=>String(e.message??e)).join(`; `))}}const BL=new Map([...IL,[sD,RL]].map(([e,t])=>[e,zL(t)]));Object.freeze([...BL.keys()]);const VL=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`]),HL=[[`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`]],UL=[[`workspace.added_dirs`,`string-list`]];function WL(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of HL){let i=qL(n,e);if(i==null)t.missingRequired.push(e);else{let n=GL(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of UL){let i=qL(n,e),a=i===void 0?r:KL(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))VL.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function GL(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function KL(e){return Array.isArray(e)&&e.every(e=>GL(e)===`string`)?`string-list`:GL(e)}function qL(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 JL(e,t){switch(e){case`vars`:return{what:e,vars:YL(t)};case`segments`:return{what:e,segments:eR(t)};case`config`:return{what:e,config:iR(t)}}}function YL(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=QL(r),a=t.names().sort(),o=[];for(let e of a){let r=t.getNode(e),a=n.getLastError(e);o.push({name:e,source:i.get(e)??null,...XL(r),lastError:a===void 0?null:{timestampMs:a.timestamp,message:a.message},ageMs:ZL(r.lastUpdatedMs())})}return o}function XL(e){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`absent`:return{type:`document`,value:`(not yet scanned)`};case`failed`:return{type:`document`,value:t.reason}}}function ZL(e){return e===null?null:Math.max(0,Date.now()-e)}function QL(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,$L(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}`,$L(i));return t}function $L(e){return e.kind}function eR(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=nR(n),o=tR(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:rR(t.template,n.helpers,i),placements:(o.get(e)??[]).map(e=>({id:e,lastRender:r.get(e)??null}))})}return s}function tR(e){let t=new Map;for(let n of D_(e.presets))for(let r of Ms(A_(e,n).node)){if(r.kind!==`segment`)continue;let e=t.get(r.name)??[],n=Os(r);e.includes(n)||t.set(r.name,[...e,n])}return t}function nR(e){let t=[],n=new Set;for(let r of Ms(Fc(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 rR(e,t,n){let r=new Set;for(let i of _v(e,t).keys()){if(n.has(i)){r.add(i);continue}let e=i.split(`.`);for(;e.length>1;){e.pop();let t=e.join(`.`);if(n.has(t)){r.add(t);break}}}return Array.from(r).sort()}function iR(e){return e===null?null:e.config}const aR=[`vars`,`segments`,`config`];function oR(e){return typeof e==`string`&&aR.includes(e)}function sR(e){return Math.max(1,e-2)}var cR=class{written=new Map;constructor(e){this.dir=e}pathFor(e){return c.join(this.dir,`${encodeURIComponent(e)}.txt`)}sync(e,t){let n=this.pathFor(e);if(t===(this.written.get(e)??null))return null;try{return t===null?(r.rmSync(n,{force:!0}),this.written.delete(e)):(r.mkdirSync(this.dir,{recursive:!0,mode:448}),r.writeFileSync(n,t,{mode:384}),this.written.set(e,t)),null}catch(e){return`${n}: ${e.message}`}}reset(){this.written.clear();try{return r.rmSync(this.dir,{recursive:!0,force:!0}),null}catch(e){return`${this.dir}: ${e.message}`}}};const lR=new eF;Ee(lR.launchStats);const uR=new tb({counters:lR,logger:Z}),dR=$M({watchers:uR,logger:Z}),{gitProvider:fR,usageStore:pR,mementoProvider:mR}=dR,hR=new iF,gR=new nI(hR,Z),_R=new wI,vR=new cR(qe()),yR=new QP({gitService:fR,sessionState:hR,watchers:uR},{observers:{onReload:e=>Z(`info`,`config loaded projectDir=${e.projectDir} cwd=${e.cwd} file=${e.configFilePath??`<bundled default>`} error=${e.lastError===null?`none`:JSON.stringify(e.lastError)} warning=${e.lastWarning===null?`none`:JSON.stringify(e.lastWarning)}`)}}),bR=60*1e3;function xR(){let e=import.meta.url,n=[];e.startsWith(`file://`)&&n.push(E(e)),t.argv[1]&&n.push(t.argv[1]);let i=new Map;for(let e of n)try{i.set(e,r.statSync(e).mtimeMs)}catch{}let a=null,o=()=>{for(let[e,t]of i)try{if(r.statSync(e).mtimeMs!==t){Z(`info`,`binary mtime changed (${e}); shutting down`),a&&clearInterval(a),LR(0);return}}catch(e){Z(`warn`,`bin stat failed: ${e.message}`)}};return{arm(){i.size!==0&&(a=setInterval(o,bR),a.unref())},checkNow:o}}const SR=xR(),CR=rM({entryUrl:import.meta.url,intervalMs:bR,releaseIntervalMs:216e5,registryUrl:t.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,fetchImpl:fetch,onApplied:()=>SR.checkNow(),log:Z});let wR=null,TR=null,ER=0;function DR(){t.on(`uncaughtException`,e=>{Z(`error`,`uncaughtException: ${e.stack||e.message}`),LR(1)}),t.on(`unhandledRejection`,e=>{Z(`error`,`unhandledRejection: ${String(e)}`),LR(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{Z(`info`,`received ${e}, shutting down`),LR(0)});try{ER=NE(t.env)}catch(e){Z(`error`,`refusing to boot: ${e.message}`),LR(1);return}wR=jO(t.pid);let e=VO(UO(wR));if(!e.decision.allow){Z(`warn`,`fork-bomb breaker: ${e.decision.reason}; refusing to boot`),LR(1);return}TR=e.registryPath,r.mkdirSync(Fe(),{recursive:!0}),Re(Ie()),hR.useStorage(new oF(Ve(),500,Z)),gR.useStorage(SI(He(),Z)),PO({anchor:NO(t.env),isAlive:FO,onOrphaned:e=>{Z(`info`,`parent watchdog: ${e}; shutting down`),LR(0)}}),OR(b.createServer({allowHalfOpen:!1},e=>{RR(e)}),Ie(),!1)}function OR(e,n,r){e.removeAllListeners(`error`),e.removeAllListeners(`listening`),e.once(`error`,i=>{if(i.code!==`EADDRINUSE`){Z(`error`,`server error: ${i.message}`),LR(1);return}if(r){Z(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}kR(e,n)}),e.listen(n,()=>AR(n))}function kR(e,n){let i=xO(SO(ze(n)),(e,t)=>AO(e,t,{readStartTime:kO,pidAlive:FO}));if(i.kind===`attach-and-exit`){Z(`info`,`EADDRINUSE: ${i.reason} — exiting`),t.exit(0);return}Z(`warn`,`EADDRINUSE: ${i.reason} — unlinking stale socket and rebinding`);try{r.unlinkSync(n)}catch(e){if(e.code!==`ENOENT`){Z(`error`,`cannot unlink stale socket ${n}: ${e.message}`),LR(1);return}}OR(e,n,!0)}function AR(e){let n=TO(e);if(n.kind!==`present`){Z(`warn`,`no ownable socket at bind callback (${n.kind}); exiting`),LR(0);return}PR(e);try{r.chmodSync(e,384)}catch(e){Z(`warn`,`chmod socket failed: ${e.message}`)}Z(`info`,`daemon up: pid=${t.pid} v=3 sock=${e} heapCap=${Math.round(ne.getHeapStatistics().heap_size_limit/1048576)}MB rssLimit=${Math.round(ER/1048576)}MB`),XE();let i=vR.reset();i!==null&&Z(`warn`,`diagnostic dump wipe failed: ${i}`),SR.arm(),CR.arm(),NR(),jR(e,n.identity)}function jR(e,n){OO({bound:n,myPid:t.pid,readIdentity:()=>TO(e),readLease:()=>SO(ze(e)),shutdown:e=>LR(e),log:Z}).arm()}let MR=null;function NR(){MR=LE(VE(lR.startedAt.getTime(),e=>LR(e),{rssLimitBytes:ER})),MR.arm()}function PR(e){let n=CO(ze(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:wR});n!==null&&Z(`warn`,`lease write failed: ${n}`)}let FR=0,IR=!1;function LR(e){if(!IR){IR=!0,setTimeout(()=>t.kill(t.pid,`SIGKILL`),500);try{fR.close()}catch(e){Z(`warn`,`gitService close failed: ${e.message}`)}try{pR.close()}catch(e){Z(`warn`,`usageStore close failed: ${e.message}`)}try{uR.closeAll()}catch(e){Z(`warn`,`watcherRegistry close failed: ${e.message}`)}try{hR.flush()}catch(e){Z(`warn`,`sessionState flush failed: ${e.message}`)}wO(Be(),t.pid),TR!==null&&HO(TR,t.pid,zO,e=>r.unlinkSync(e)),t.exit(e)}}function RR(e){FR++,lR.inFlight=FR;let t=!1,n=(n,r)=>{if(t){r!==null&&Z(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`);return}t=!0;let i=r===null?void 0:()=>LR(r);try{e.end(lE(n),i)}catch(e){Z(`warn`,`response write failed: ${e.message}`),i?.()}},r=setTimeout(()=>{lR.requestsTimedOut++,n({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null)},200),i=uE(e=>{BR(e).then(e=>n(e.resp,e.exitAfterFlush)).catch(e=>{Z(`error`,`handler threw: ${e?.stack||e}`),n({ok:!1,error:String(e?.message||e),code:`RENDER_FAILED`,daemonV:3},null)})},e=>{Z(`warn`,`frame parse failed: ${e.message}`),n({ok:!1,error:e.message,code:`BAD_REQUEST`,daemonV:3},null)});e.on(`data`,i),e.on(`error`,e=>{Z(`warn`,`socket error: ${e.message}`)}),e.on(`close`,()=>{clearTimeout(r),FR=Math.max(0,FR-1),lR.inFlight=FR})}const zR=e=>({resp:e,exitAfterFlush:null});async function BR(e){if(!e||typeof e!=`object`||typeof e.v!=`number`)return zR({ok:!1,error:`malformed request`,code:`BAD_REQUEST`,daemonV:3});if(e.v!==3)return e.v>3?Z(`info`,`version mismatch: client=${e.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):Z(`info`,`version mismatch: client=${e.v} < daemon=3; client is stale — staying up`),{resp:{ok:!1,error:`protocol v${e.v} not supported (daemon at v3)`,code:`VERSION_MISMATCH`,daemonV:3},exitAfterFlush:e.v>3?0:null};if(e.kind===`shutdown`)return{resp:{ok:!0,output:``},exitAfterFlush:0};if(e.kind===`stats`)return zR({ok:!0,stats:lR.snapshot({gitCache:fR.getStats(),usageCache:pR.getStats(),renderCacheSize:yR.size,watchersActive:uR.size(),nextRestartReason:MR?.describeNextRestart()??null})});if(e.kind===`render`){lR.requestsTotal++;let t=Date.now();try{let{report:n}=WL(e.hookData);for(let e of n.unknownTopLevelFields)Z(`info`,`schema: unknown field '${e}' — Anthropic may have added it`);let r=[];for(let e of n.missingRequired)r.push(`missing required field '${e}'`);for(let{path:e,expected:t,got:i}of n.typeMismatches)r.push(`field '${e}' expected ${t}, got ${i}`);if(e.cwd===``&&r.push(`request 'cwd' is empty`),r.length>0)return lR.requestsErrored++,Z(`warn`,`BAD_REQUEST: ${r.join(`; `)}`),zR({ok:!1,error:`malformed hookData: ${r.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3});let i=e.hookData.workspace.project_dir,{configFile:a,unknownFlagsError:o}=VR(e.args),s=e.hookData.session_id,c=eE(e),l=JSON.stringify(c);hR.get(s,`client-hints`)!==l&&hR.set(s,OL,l);let u=hR.get(s,`config-override`)??a??c.configEnv,d=yR.getOrCreate(i,e.cwd,u),f=aL({projectDir:i,cwd:e.cwd,configFile:u??null});hR.get(s,`render-origin`)!==f&&hR.set(s,iL,f);let p=c.termCols,m=sR(p??120),h=ok(c.termRows),{authoredRoots:g}=d.state,_=t=>hR.get(e.hookData.session_id,t),v=NA(d.state.config,_,e=>g.has(e)),y=await XA(e.hookData,{...KR,navigation:e=>_R.depth(e,hR,Fj(d.state.config))},e.cwd,d.state.neededInputPaths(v.preset),v,c,{...Sj(d.state.config,d.state.fileHeldSettings,_),configPath:d.configFilePath}),b=[],x=PA(v,m),S=LP(d.state.config,d.state.compiled,d.state.store,d.state.registry,y,x,{perSegmentSink:d.state.lastRenderCellsBySegment,onRenderWarning:e=>b.push(e)},FA(v)),C=hR.get(e.hookData.session_id,`click.error`);C&&hR.clear(e.hookData.session_id,`click.error`);let w=[o,d.lastError,C].filter(Boolean).join(`
199
- `),ee=CR.notice({sessionId:s,dismissed:hR.get(s,Vj),enabled:v.updateNotice}),te=d.lastError===null?null:d.configFilePath,ne=dk(w,ee,[d.lastWarning??``,...b].filter(Boolean).join(`
200
- `)),T=vR.sync(s,ne===null?null:pk(ne));T!==null&&Z(`warn`,`diagnostic dump failed: ${T}`);let re=mk(S,ne,{fullText:T===null?{kind:`file`,path:vR.pathFor(s)}:{kind:`unavailable`,reason:T},failedConfigFile:te},{width:m,rowCap:h,colorCompatibility:v.colorCompatibility}),E=Date.now()-t,D=fR.getStats(),ie=pR.getStats();return Z(`info`,`render sid=${e.hookData.session_id??`?`} took=${E}ms termCols=${p??`?`} termRows=${c.termRows??`?`} width=${m} git=${D.size}/${D.hits}h/${D.misses}m usage=${ie.size}/${ie.hits}h/${ie.misses}m err=${w?`Y`:`N`} upd=${ee.length} warn=${d.lastWarning?`Y`:`N`}`),zR({ok:!0,output:re+`
201
- `})}catch(e){throw lR.requestsErrored++,e}}if(e.kind===`click`)return zR(await qR(e.verb,e.value));if(e.kind===`debug`){if(!oR(e.what))return zR({ok:!1,error:`unknown debug 'what': ${String(e.what)} (have: ${aR.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let t=yR.firstState(),n=t===null?null:{store:t.store,registry:t.registry,config:t.config,compiled:t.compiled,lastRenderBySegment:e.what===`segments`?GR(t.lastRenderCellsBySegment,t.config.globals.charset??`unicode`,t.config.globals.colorCompatibility??`truecolor`):WR};return zR({ok:!0,debug:JL(e.what,n)})}return zR({ok:!1,error:`unknown kind`,code:`BAD_REQUEST`,daemonV:3})}function VR(e){let{values:t,tokens:n}=v({args:e.slice(1),options:{config:{type:`string`}},strict:!1,tokens:!0,allowPositionals:!0}),r=[...new Set((n??[]).filter(e=>e.kind===`option`&&e.name!==`config`).map(e=>`--${e.name}`))];return{configFile:rE(t.config),unknownFlagsError:r.length>0?`Unknown flags: ${r.join(`, `)}`:null}}const HR={sessionState:hR,dlog:Z,applyUpdate:()=>CR.act(),doctor:EI(),memento:mR,claudeInput:VI(),history:gR,navigation:_R,configFor:e=>yR.getOrCreate(e.projectDir,e.cwd,e.configFile??void 0).state.config,reloadConfig:e=>yR.reload(e.projectDir,e.cwd,e.configFile??void 0)};HR.reloadConfig;const UR={endcaps:`powerline`,colorCompatibility:`truecolor`,wrap:!0,padding:1,charset:go,width:1/0},WR=new Map;function GR(e,t,n){let r=new Map;for(let[i,a]of e)r.set(i,ak(a,{...UR,charset:t,colorCompatibility:n}));return r}const KR={...dR,clock:()=>new Date,history:e=>gR.depth(e)};function qR(e,t){let n=BL.get(e);if(!n)return{ok:!1,error:`unknown click verb: ${e}`,code:`BAD_REQUEST`,daemonV:3};try{return n(t,HR),{ok:!0,output:``}}catch(e){let t=e instanceof $?`BAD_REQUEST`:`RENDER_FAILED`;return{ok:!1,error:String(e instanceof Error?e.message:e),code:t,daemonV:3}}}const JR={connectMs:200,budgetMs:500};async function YR(e){let n=e.includes(`--json`),r=await XR();if(r.kind!==`ok`&&(t.stderr.write(`daemon-stats: ${vE(r)}\n`),t.exit(1)),n){t.stdout.write(JSON.stringify(r.value,null,2)+`
202
- `);return}t.stdout.write(ez(r.value))}function XR(){return fE({kind:`stats`},JR,e=>`stats`in e?e.stats:void 0)}function ZR(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function QR(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 ez(e){let t=[];t.push(`cc-candybar daemon stats`),t.push(``),t.push(`process`),t.push(` pid ${e.pid}`),t.push(` version ${e.version}`),t.push(` protocol ${e.protocolVersion}`),t.push(` startedAt ${e.startedAt}`),t.push(` uptime ${$R(e.uptimeSec)}`),t.push(` rss ${ZR(e.rssBytes)}`),t.push(` heapUsed ${ZR(e.heapUsedBytes)}`),t.push(` heapTotal ${ZR(e.heapTotalBytes)}`),t.push(` external ${ZR(e.externalBytes)}`),t.push(` arrayBuffers ${ZR(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(``),t.push(`gitCache`),t.push(` size ${e.gitCache.size}`),t.push(` hit rate ${QR(e.gitCache.hits,e.gitCache.misses)} (${e.gitCache.hits} / ${e.gitCache.hits+e.gitCache.misses})`),t.push(` invalidations ${e.gitCache.invalidations}`),t.push(``),t.push(`usageCache`),t.push(` size ${e.usageCache.size}`),t.push(` hit rate ${QR(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(`renderCache`),t.push(` size ${e.renderCache.size}`),t.push(`watchers`),t.push(` active ${e.watchers.active}`),t.push(` opened ${e.watchers.opened}`),t.push(` closed ${e.watchers.closed}`),t.push(` evicted ${e.watchers.evicted}`),t.push(``),t.push(`subprocesses`),t.push(` total ${e.subprocesses.total}`),t.push(` inFlight ${e.subprocesses.inFlight}`),t.push(` lastMinute ${e.subprocesses.lastMinute}`);let n=Object.entries(e.subprocesses.byCategory),r=n.reduce((e,[t])=>Math.max(e,t.length),13);for(let[i,a]of n){let n=e.subprocesses.p50DurationMs[i],o=e.subprocesses.p99DurationMs[i],s=n!==void 0&&o!==void 0?` (p50 ${n}ms · p99 ${o}ms)`:``;t.push(` ${i.padEnd(r)} ${a}${s}`)}return e.nextRestartReason&&(t.push(``),t.push(`nextRestart ${e.nextRestartReason}`)),t.join(`
198
+ `);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function SP(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,...CP(e,r)]}function CP(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 wP(e,t){let n=(e,r)=>t(e)?e.kind===`segment`?[{cells:[{name:e.name,address:r,settings:e.settings}],band:`own`,place:`flow`}]:SP(e.direction,e.children.map((t,i)=>n(t,[...r,TP(e,i)]))):[];return n(e,[]).map(e=>[...e.cells])}function TP(e,t){return{index:t,count:e.children.length,distribution:e.distribution,axis:Ds[e.direction]}}const EP={compile(e,t){return{kind:`container`,direction:e.direction,when:t.when,distribution:pa(e.distribution),children:e.children.map((e,n)=>t.compileChild(e,Ns(t.path,n)))}},render(e,t){return SP(e.direction,e.children.map((n,r)=>t.renderChild(n,t.visible,TP(e,r))))}},DP={drop:e=>e.place,above:()=>`above`},OP={drop:(e,t)=>({lead:t(),stays:e}),above:e=>({lead:e.slice(0,1).flatMap(e=>e.cells),stays:e.slice(1)})},kP={compile(e,t){return{kind:`segment`,when:t.when,name:e.name,id:Os(e),settings:t.placementSettings(e),...e.opens!==void 0&&{opens:{open:t.parse(Xc(e.opens.ref),`opens`),body:t.compileChild(e.opens.body,Ps(t.path)),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){let n=t.lookupSegment(e.name);if(!n)throw Error(`Layout segment "${e.name}" has no matching segment`);let{seg:r,compiled:i}=n;if(!t.visible)return[];let a=Ty(t.scope,e.settings);try{if(!oN(i.when,a))return[];let n=Jb(e.settings.theme,t.palette),o=e.opens!==void 0&&oN(e.opens.open,t.scope),{styles:s,fragments:c,lead:l,trail:u,drops:d,open:f}=t.evaluateSegment(e,a,n,t.region,{bg:i.bg,fg:i.fg,body:i.template,lead:e.lead,trail:e.trail},o),p=f?s.trigger:s.closed,m={width:r.width??`auto`,justify:r.justify??`left`,truncate:r.truncate??`right`,baseStyle:p,padding:t.padding},h=e.opens,g=h===void 0?[]:t.renderBody(h.body,o,s.disclosure).map(e=>({...e,place:DP[h.placement](e)})),_=xP(hN(c,p)).map((e,t)=>({cells:dN(e,{...m,lead:t===0?hN(l,p):[],trail:t===0?hN(u,p):[]}),band:`own`,place:`flow`})),v=d.map(e=>({cells:dN(hN([e],s.band),{...m,baseStyle:s.band}),band:`deeper`,place:`flow`})),y=(e,t,n)=>dN(hN([e],t),{...m,width:`auto`,baseStyle:t,padding:n}),b=g.findIndex(e=>e.band===`own`),{lead:x,stays:S}=h!==void 0&&b!==-1?OP[h.placement](_,()=>y(t.closeDisclosure(h.key),s.close,t.padding)):{lead:[],stays:_},C=x.flatMap(e=>y(new H(` `.repeat(lN(e).reduce((e,t)=>e+t.cellLength,0))),s.trigger,0)),w=(e,t)=>e.band===`own`?t===b?x:C:[],T=g.map((e,t)=>({cells:[...w(e,t),...e.cells],band:`deeper`,place:e.place})),ee=[...S,...v];return t.perSegmentSink!==void 0&&t.perSegmentSink.set(e.id,[...ee.flatMap(e=>e.cells),...g.flatMap(w)].flatMap(lN)),[...ee,...T]}catch(n){let r=n.message??String(n);t.onSegmentError?.(e.id,r);let i=r.replace(/\s*\n\s*/g,` `);return[{cells:dN([new H(`⚠ ${e.id}: ${i}`,{end:``})],{width:`auto`,justify:`left`,truncate:`right`,padding:0,lead:AP(e.lead,e,a,t),trail:AP(e.trail,e,a,t)}),band:`own`,place:`flow`}]}}};function AP(e,t,n,r){if(e===void 0)return[];try{return r.evaluateSegment(t,n,r.palette,r.region,{bg:void 0,fg:void 0,body:e,lead:void 0,trail:void 0},!1).fragments}catch(e){return r.onSegmentError?.(t.id,e.message??String(e)),[]}}const jP={container:EP,segment:kP};function MP(e){return jP[e]}function NP(e){if(`ttl`in e)return{kind:`ttl`,durationMs:hb(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 PP(e,t){switch(Ls(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 FP(e,t,n,r){switch(n.kind){case`literal`:e.declareLiteral(t,n.value);break;case`input`:e.declareInput(t,n.path,n.type??`string`,n.default);break;case`env`:e.declareEnv(t,n.name,n.default);break;case`file`:e.declareFile(t,n.path,{readMode:n.readMode,cache:NP(n.cache),parse:PP(n.parse,n.default)});break;case`shell`:e.declareShell(t,n.command,{cwd:r,cache:NP(n.cache),parse:PP(n.parse,n.default)});break;case`template`:e.declareTemplate(t,n.template,{varDefault:n.default});break;case`time`:e.declareTime(t,{format:n.layout,ttlMs:n.cache?hb(n.cache.ttl):void 0,varDefault:n.default});break;case`git`:e.declareGit(t,{field:n.field,cwd:r,varDefault:n.default});break;case`state`:e.declareState(t,{key:n.key,...n.default!==void 0&&{varDefault:n.default}});break}}function IP(e,t){let n=Yd.EMPTY;for(let[r,i]of Object.entries(t))try{n=e.parse(`{{ define "${r}" }}${i}{{ end }}`,n).defines()}catch(e){throw Error(`Template parse error in helpers.${r}: ${e.message}`,{cause:e})}return n}const LP=e=>xo(void 0,null,e.globals.variation);function RP(e,t,n){let r=n.cwd,i=tx(e.globals.palette),a={store:t.variableStore,compiled:new Map,chromeCols:lk({endcaps:`powerline`,charset:go}),width:80,basePalette:i,palette:i,variation:aa[LP(e)],padding:1,seamCols:uk({endcaps:`powerline`,charset:go}),layout:()=>[]},o=HN(t.drawnAt),s={action:a,activeSegment:o},c=Object.keys(e.styles),l=D_(e.presets),u=new Map([...ax(e),...tw(e)]),d=Sy({...jN(a),...eP(a,o),...rP(a,o),...sP(a,o),...fP(a,o),...gP(s),...yP(o),styles:{fn:()=>c,argTypes:[],arity:{kind:`exact`}},presets:{fn:()=>l,argTypes:[],arity:{kind:`exact`}}},n.clock,t.drawnAt),f=IP(d,e.helpers),p=e=>d.parse(e,f),m=new Map,h=e=>{let t=m.get(e);if(t!==void 0)return t;let n=p(e);return m.set(e,n),n},g=new Map;for(let[t,n]of Bb)n in e.variables&&g.set(t,n);for(let[t,n]of Object.entries(e.variables))n.kind===`state`&&!g.has(n.key)&&g.set(n.key,t);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))r.kind===`state`&&!g.has(r.key)&&g.set(r.key,`${t}.${e}`);a.compiled=yN(p,e.actions,g,u);let _=[];for(let[n,i]of Object.entries(e.variables))try{FP(t,n,i,r)}catch(e){_.push(`Variable "${n}": ${e.message??String(e)}`)}for(let[n,i]of Object.entries(e.segments))if(i.vars)for(let[e,a]of Object.entries(i.vars))try{FP(t,`${n}.${e}`,a,r)}catch(t){_.push(`Variable "${n}.${e}": ${t.message??String(t)}`)}let v=Object.create(null);for(let[t,n]of Object.entries(e.segments)){let e=(e,n,r=p)=>{try{return r(e)}catch(e){throw Error(`Template parse error in segments.${t}.${n}: ${e.message}`,{cause:e})}};v[t]={when:n.when===void 0?void 0:e(n.when,`when`,h),template:e(n.template,`template`),bg:n.bg===void 0?void 0:e(n.bg,`bg`),fg:n.fg===void 0?void 0:e(n.fg,`fg`)}}let y=(e,t,n)=>{try{return h(e)}catch(e){throw Error(`Template parse error in ${t}.${n}: ${e.message}`,{cause:e})}},b=t.variableStore,x=t=>{let n=Hs(e.segments[t.name]),r=Object.create(null);for(let[e,i]of Object.entries(n)){let n=t.settings?.[e]??i.default,a=t.drafts?.[e];Object.defineProperty(r,e,{enumerable:!0,get:a===void 0?()=>n:()=>qs(i,String(b.read(a.variable)))??n})}return Object.freeze(r)},S=(e,t)=>{let n={path:t,when:e.when===void 0?void 0:y(e.when,t,`when`),parse:(e,n)=>y(e,t,n),compileChild:S,placementSettings:x};return MP(e.kind).compile(e,n)},C=new Map;for(let t of l){let{node:n,path:r}=A_(e,t);C.set(t,S(n,r))}let w=new Map(ro.map(e=>[e,new Map])),T=[[`globals`,e.globals],...Object.entries(e.presets).map(([e,t])=>[`presets.${e}.globals`,t.globals??{}])];for(let[e,t]of T)for(let n of ro){let r=t[n];if(!io(r))continue;let i=`${e}.${n}`,a=w.get(n),o=a.get(r);a.set(r,o===void 0?{where:i,template:zP(p,i,r)}:{where:`${o.where}, ${i}`,template:o.template})}return{segments:v,roots:C,activeSegment:o,menuRuntime:s,globalExpressions:w,loadWarnings:_}}function zP(e,t,n){try{return e(n)}catch(e){throw Error(`${t} is not a valid template: ${e instanceof Error?e.message:String(e)}`)}}function BP(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 render but no compiled template exists — registerDslConfig and the resolution disagree about isExpression`);return r}function VP(e,t){return e.template.evaluate(t).map(e=>e.plain).join(``)}function HP(e,t){return e.kind===`decided`?e.name:t}function UP(e,t,n,r,i,a,o,s){let{perSegmentSink:c,onSegmentError:l,onRenderWarning:u}=o??{};r.drawAt(vo(a.colorCompatibility));let{preset:d=T_}=s??{},f=j_(e,d),p=aa[s?.variation??xo(void 0,null,f.variation)];t.menuRuntime.action.variation=p;let m=s?.style??lo(`none`,e.styles),h=s?.theme??$b(void 0,null,f.palette),g=(e,t)=>({...i,term:{cols:a.width},theme:{effective:e},style:{effective:t}});r.applyInput(g(HP(h,Xa),HP(m,so))),t.menuRuntime.action.chromeCols=lk(a),t.menuRuntime.action.padding=a.padding,t.menuRuntime.action.width=a.width,t.menuRuntime.action.seamCols=uk(a);let _=Cy(n),v=oo(h,e=>{let n=BP(t,`palette`,e);return Qb(VP(n,_),n.where,e=>u?.(e))}),y=oo(m,n=>lo(VP(BP(t,`style`,n),_),e.styles));(v!==h||y!==m)&&r.applyInput(g(v.name,y.name));let b=v.value;t.menuRuntime.action.basePalette=b;let x=Xb(b,y.value);t.menuRuntime.action.palette=x,c?.clear();let S=n=>{let r=e.segments[n],i=t.segments[n];return r!==void 0&&i!==void 0?{seg:r,compiled:i}:void 0},C=(e,n,i,a,o,s)=>{try{let c=r.drawnAt(),{tint:l,disclosure:u}=qa(i,a,c),d=UN(t.activeSegment,e.name,e.id,i,u,l),f=wx(d,c,o.bg,o.fg,n),p=()=>Ia(i,u,c).state;s&&(d.bg=p());let m=o.body.evaluate(n),h=d.drops.length>0||s;h&&(d.bg=p());let g=o.lead?.evaluate(n)??[],_=o.trail?.evaluate(n)??[];return{styles:{closed:f,get trigger(){return NN(i,p(),c)},get band(){return NN(i,Ia(i,u,c).plane,c)},get close(){return FN(i,p(),c)},disclosure:u},fragments:m,lead:g,trail:_,drops:d.drops,open:h}}finally{t.activeSegment.current=null}},w=(e,t,r)=>{let i=t&&oN(e.when,_),o={scope:_,palette:x,visible:i,padding:a.padding,region:r,perSegmentSink:c,onSegmentError:l,evaluateSegment:C,lookupSegment:S,renderChild:(e,t,n)=>w(e,t,Ga(r,n)),renderBody:(e,t,n)=>w(e,i&&t,Ka(n)),closeDisclosure:e=>MN(n,e)};return MP(e.kind).render(e,o)},T=t.roots.get(d);if(T===void 0)throw Error(`Preset "${d}" has no compiled layout — registerDslConfig compiles one per declared preset and effectivePresetName collapses unknown names to "${T_}"; a miss here is merge/policy drift (have: ${[...t.roots.keys()].join(`, `)})`);let ee=e=>{if(!oN(e.when,_))return!1;if(e.kind===`container`)return!0;if(uw(e.name)===void 0)return!1;try{return oN(t.segments[e.name].when,Ty(_,e.settings))}catch{return!0}};return t.menuRuntime.action.layout=()=>wP(T,ee).map(e=>e.flatMap(({name:e,address:t,settings:n})=>{let r=uw(e);return r===void 0?[]:[{name:r,address:t,palette:Jb(n.theme,x)}]})),w(T,!0,Wa(p)).map(e=>dk(mN(e.cells,a),a)).join(`
199
+ `)}function*WP(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*GP(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);for(let t of D_(e.presets)){for(let n of Ms(A_(e,t).node))n.when!==void 0&&(yield n.when);let n=j_(e,t);for(let e of ro){let t=n[e];io(t)&&(yield t)}}for(let[,t]of WP(e))t.kind===`template`&&(yield t.template),zs(t)&&t.cache&&`key`in t.cache&&(yield t.cache.key);for(let t of Object.values(e.actions))`copy`in t&&(yield t.copy),`open`in t&&(yield t.open),`preset`in t&&t.preset===`delete`&&(yield t.name)}function KP(e,t){return e===t||t.startsWith(`${e}.`)||e.startsWith(`${t}.`)}function qP(e,t){let n=new Set,r=new Set,i=new Set;for(let e of GP(t)){for(let r of _v(e,t.helpers).keys())n.add(r);for(let{name:n}of xv(e,t.helpers))r.add(n);for(let n of Sv(e,t.helpers))i.add(n)}for(let[,e]of WP(t))if(zs(e)&&e.cache&&`depends_on`in e.cache)for(let t of e.cache.depends_on)n.add(t);let a=new Set(r);for(let e of r){let n=t.actions[e];if(n!==void 0&&`do`in n)for(let e of n.do)a.add(e)}let o=new Set,s=new Set;for(let e of a){let n=t.actions[e];if(n!==void 0&&(`set`in n&&o.add(n.set),`insertSegment`in n&&s.add(n.insertSegment),`insertSegmentFrom`in n&&Array.isArray(n.insertSegmentFrom)))for(let e of n.insertSegmentFrom)s.add(e)}for(let e of D_(t.presets))for(let n of Ms(A_(t,e).node))n.kind===`segment`&&s.add(n.name);let c=(e,t)=>[...n].some(t=>KP(t,e))||t.kind===`state`&&o.has(t.key),l=e=>[...e].filter(e=>!wu(e)),u=(e,t,n)=>l(t).filter(e=>!n(e)).map(t=>({kind:e,name:t})),d=new Map(WP(e));return[...u(`variable`,d.keys(),e=>c(e,d.get(e))),...u(`action`,Object.keys(e.actions??{}),e=>a.has(e)),...u(`helper`,Object.keys(e.helpers??{}),e=>i.has(e)),...u(`segment`,Object.keys(e.segments??{}),e=>s.has(e))]}var JP=class{kind=`box`;cell;lastChangedAt;constructor(e,t,n){this.name=e,this.type=t,eF(e,t,n,`initial value`),this.cell=Ov.observable.box(n,{deep:!1}),this.lastChangedAt=Date.now()}read(){return this.cell.get()}set(e){eF(this.name,this.type,e,`set value`),!Object.is(this.cell.get(),e)&&(this.cell.set(e),this.lastChangedAt=Date.now())}lastUpdatedMs(){return this.lastChangedAt}},YP=class{kind=`computed`;cell;constructor(e,t,n){this.name=e,this.type=t,this.cell=(0,Ov.computed)(()=>{let e=n();return eF(this.name,this.type,e,`computed result`),e},{keepAlive:!0})}read(){return this.cell.get()}lastUpdatedMs(){return null}},XP=class{kind=`document`;cell;lastChangedAt;constructor(e,t){this.name=e,this.cell=Ov.observable.box($P(t),{deep:!1}),this.lastChangedAt=Date.now()}read(){return this.cell.get()}set(e){let t=$P(e);QP(this.cell.get(),t)||(this.cell.set(t),this.lastChangedAt=Date.now())}lastUpdatedMs(){return this.lastChangedAt}};function ZP(e){return JSON.stringify(e)}function QP(e,t){return ZP(e)===ZP(t)}function $P(e){return e.kind===`ok`?{kind:`ok`,value:kv(e.value)}:e}function eF(e,t,n,r){let i=Av(n);if(i!==t)throw TypeError(`Variable "${e}": ${r} type ${i} does not match declared type ${t}`)}var tF=class{nodes=new Map;defineBox(e,t,n){this.assertNotDefined(e),this.nodes.set(e,new JP(e,t,n))}defineDocument(e,t){this.assertNotDefined(e),this.nodes.set(e,new XP(e,t))}defineComputed(e,t,n){this.assertNotDefined(e);let r=e=>this.read(e);this.nodes.set(e,new YP(e,t,()=>n(r)))}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()}setDocument(e,t){let n=this.requireNode(e);if(n.kind!==`document`)throw TypeError(`Variable "${e}" is a ${n.kind}, not a document (use defineDocument to create one)`);(0,Ov.runInAction)(()=>n.set(t))}setBox(e,t){let n=this.requireNode(e);if(n.kind!==`box`)throw TypeError(`Variable "${e}" is a ${n.kind}, not a box (use defineBox to create a settable variable)`);(0,Ov.runInAction)(()=>n.set(t))}runInAction(e){(0,Ov.runInAction)(e)}has(e){return this.nodes.has(e)}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`)return ZP(t.read());try{return String(t.read())}catch(e){return`failed:${e instanceof Error?e.message:String(e)}`}}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.nodes.keys()]}requireNode(e){let t=this.nodes.get(e);if(!t)throw ReferenceError(`Unknown variable "${e}"`);return t}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}assertNotDefined(e){if(this.nodes.has(e))throw Error(`Variable "${e}" is already declared`)}};function nF(e,t,n){return e+`\0`+t+`\0`+(n??``)}function rF(e,t){return new Set(D_(e.presets).filter(n=>A_(e,n).path===`root`?t.root!==void 0:t.presets?.[n]?.root!==void 0))}function iF(e){let t=c.basename(e),n=c.dirname(e);for(;!r.existsSync(n);)t=c.basename(n),n=c.dirname(n);return{dir:n,name:t}}function aF(e,t){let n=new Map;for(let t of HT(e.projectDir,e.cwd,e.configFile)){let{dir:e,name:r}=iF(t);n.has(e)||n.set(e,new Set),n.get(e).add(r)}return{files:t===null?[]:[t],dirs:[...n.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({path:e,filenames:[...t].sort()}))}}function oF(e){return e.filter(Boolean).join(`
200
+ `)||null}function sF(e,t,n,r){let i=XT(t,uA),{config:a,raw:o}=i;n.push(...i.warnings);let s=$T(i,t??`<default>`),c=new tF,l=new Mb(c,s.globals.default_empty_value??``,r.gitService,r.sessionState),u;try{u=RP(s,l,{cwd:e}),n.push(...u.loadWarnings),Vj(s),Jk(s)}catch(e){throw l.dispose(),e}return{config:s,store:c,registry:l,compiled:u,neededInputPaths:QA(s),lastRenderCellsBySegment:new Map,authoredRoots:rF(a,o),fileHeldSettings:Dj(o),unused:qP(o,a)}}function cF(e,t,n,r){let i=WT(e,t,n),a=i.kind===`file`?i.path:null,o=[YT(e,t),KT(i)],s;try{s=sF(t,a,o,r)}catch(e){return e instanceof xs&&o.push(...e.warnings),{resolvedPath:a,warning:oF(o),state:null,error:e instanceof xs||e instanceof Error?e.message:String(e)}}return{resolvedPath:a,warning:oF(o),state:s,error:null}}var lF=class{entries=new Map;deps;maxEntries;observers;constructor(e,t={}){this.deps=e,this.maxEntries=t.maxEntries??256,this.observers=t.observers??{}}getOrCreate(e,t,n){let r=nF(e,t,n),i=this.entries.get(r);if(i)return this.entries.delete(r),this.entries.set(r,i),i;let a=cF(e,t,n,this.deps),o={projectDir:e,cwd:t,configFile:n,configFilePath:null,lastError:a.error,lastWarning:a.warning,state:a.state??sF(t,null,[],this.deps),watcher:null,watcherKey:null};if(this.entries.set(r,o),this.entries.size>this.maxEntries){let e=this.entries.entries().next().value;if(e!==void 0){let[t,n]=e;n.state.registry.dispose(),n.watcher?.release(),this.entries.delete(t)}}return this.refreshWatcher(o,a.resolvedPath),this.observers.onReload?.(o),o}reload(e,t,n){this.reloadInto(this.getOrCreate(e,t,n))}reloadInto(e){let t=cF(e.projectDir,e.cwd,e.configFile,this.deps);e.lastWarning=t.warning,e.lastError=t.error,t.state!==null&&(e.state.registry.dispose(),e.state=t.state),this.refreshWatcher(e,t.resolvedPath),this.observers.onReload?.(e)}refreshWatcher(e,t){e.configFilePath=t;let n=aF(e,t),r=`config:${e.projectDir}:${e.cwd}:${e.configFile??``}:${JSON.stringify(n)}`;e.watcher!==null&&e.watcherKey===r||(e.watcher?.release(),e.watcherKey=r,e.watcher=this.deps.watchers.acquire(r,n,()=>this.onConfigChanged(e)))}onConfigChanged(e){Z(`info`,`config change detected for entry projectDir=${e.projectDir} cwd=${e.cwd}`),this.reloadInto(e)}get size(){return this.entries.size}firstState(){return this.entries.values().next().value?.state??null}};const uF=16384;var dF=class{startedAt=new Date;requestsTotal=0;requestsErrored=0;requestsTimedOut=0;inFlight=0;watchersOpened=0;watchersClosed=0;watchersEvicted=0;subprocessTotal=0;subprocessInFlight=0;subprocessCount=new Map;subprocessHistogram=new Map;subprocessHistogramRotator=new Map;rollingTimestamps=[];rollingHead=0;launchStats={onStart:e=>{this.subprocessTotal++,this.subprocessInFlight++,this.subprocessCount.set(e,(this.subprocessCount.get(e)??0)+1),this.recordRollingNow()},onEnd:(e,t)=>{this.subprocessInFlight=Math.max(0,this.subprocessInFlight-1),this.recordDuration(e,t)}};recordRollingNow(){let e=Date.now();if(this.rollingTimestamps.length<uF){this.rollingTimestamps.push(e);return}this.rollingTimestamps[this.rollingHead]=e,this.rollingHead=(this.rollingHead+1)%uF}recordDuration(e,t){let n=this.subprocessHistogram.get(e);if(n||(n=[],this.subprocessHistogram.set(e,n)),n.length<16){n.push(t);return}let r=(this.subprocessHistogramRotator.get(e)??0)%16;n[r]=t,this.subprocessHistogramRotator.set(e,r+1)}snapshotSubprocesses(){let e=Date.now()-6e4,t=0;for(let n of this.rollingTimestamps)n>=e&&t++;let n={};for(let[e,t]of this.subprocessCount)t>0&&(n[e]=t);let r={},i={};for(let[e,t]of this.subprocessHistogram){if(t.length===0)continue;let n=[...t].sort((e,t)=>e-t),a=Math.floor(n.length*.5),o=Math.min(n.length-1,Math.floor(n.length*.99)),s=n[a],c=n[o];s!==void 0&&(r[e]=s),c!==void 0&&(i[e]=c)}return{total:this.subprocessTotal,inFlight:this.subprocessInFlight,lastMinute:t,byCategory:n,p50DurationMs:r,p99DurationMs:i}}snapshot(e){let t=process.memoryUsage();return{pid:process.pid,version:GD,protocolVersion:3,startedAt:this.startedAt.toISOString(),uptimeSec:Math.floor((Date.now()-this.startedAt.getTime())/1e3),rssBytes:t.rss,heapUsedBytes:t.heapUsed,heapTotalBytes:t.heapTotal,externalBytes:t.external,arrayBuffersBytes:t.arrayBuffers,requests:{total:this.requestsTotal,errored:this.requestsErrored,timedOut:this.requestsTimedOut,inFlight:this.inFlight},gitCache:e.gitCache,usageCache:e.usageCache,renderCache:{size:e.renderCacheSize},watchers:{active:e.watchersActive,opened:this.watchersOpened,closed:this.watchersClosed,evicted:this.watchersEvicted},subprocesses:this.snapshotSubprocesses(),nextRestartReason:e.nextRestartReason??null}}};function fF(e,t,n){let r=(r,i,a)=>{let o=i.filter(t).map(t=>({key:t,before:e.get(r,t)}));a();for(let{key:t,before:i}of o)n(r,t,i,e.get(r,t))};return{get:(t,n)=>e.get(t,n),set:(t,n,i)=>r(t,[n],()=>e.set(t,n,i)),setBatch:(t,n)=>r(t,n.map(e=>e.key),()=>e.setBatch(t,n)),clear:(t,n)=>r(t,[n],()=>e.clear(t,n))}}const pF={load:()=>({}),save:()=>{},flush:()=>{}};function mF(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,new Map(Object.entries(r)));return t}var hF=class{sessions;storage;atom=(0,Ov.createAtom)(`SessionState`);constructor(e=pF,t=256){this.maxSessions=t,this.storage=e,this.sessions=new Map,this.hydrateFromStorage()}useStorage(e){this.storage=e,this.hydrateFromStorage()}hydrateFromStorage(){this.sessions=mF(this.storage.load()),this.evictOldest(),this.persist()}get(e,t){this.atom.reportObserved();let n=this.sessions.get(e);return n?(this.touch(e,n),n.get(t)??null):null}set(e,t,n){this.setBatch(e,[{key:t,value:n}])}setBatch(e,t){t.length!==0&&(0,Ov.runInAction)(()=>{let n=this.sessions.get(e)??new Map;for(let{key:e,value:r}of t)n.set(e,r);this.touch(e,n),this.evictOldest(),this.persist(),this.atom.reportChanged()})}clear(e,t){(0,Ov.runInAction)(()=>{let n=this.sessions.get(e);n&&(n.delete(t),n.size===0?this.sessions.delete(e):this.touch(e,n)),this.persist(),this.atom.reportChanged()})}prune(e){(0,Ov.runInAction)(()=>{for(let t of this.sessions.keys())e.has(t)||this.sessions.delete(t);this.persist(),this.atom.reportChanged()})}touch(e,t){this.sessions.delete(e),this.sessions.set(e,t)}evictOldest(){let e=this.sessions.size-this.maxSessions;if(!(e<=0)){for(let t of this.sessions.keys())if(this.sessions.delete(t),--e===0)break}}flush(){this.storage.flush()}persist(){this.storage.save(this.serialize())}serialize(){let e=Object.create(null);for(let[t,n]of this.sessions)e[t]=Object.fromEntries(n);return e}};function gF(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 _F=class{timer=null;pending=null;constructor(e,t=500,n=eb){this.filePath=e,this.debounceMs=t,this.logger=n}load(){let e;try{e=r.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 gF(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.timer&&(this.timer=setTimeout(()=>this.flush(),this.debounceMs),this.timer.unref())}flush(){if(this.timer&&=(clearTimeout(this.timer),null),this.pending===null)return;let e=this.pending;try{r.mkdirSync(c.dirname(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp`;r.writeFileSync(t,JSON.stringify(e),{mode:384}),r.chmodSync(t,384),r.renameSync(t,this.filePath),this.pending=null}catch(e){this.logger(`warn`,`session-state save failed: ${e.message}`)}}};const vF={default_empty_value:`string`,default_separator:`string`,palette:`string`,style:`string`,preset:`string`,endcaps:`string`,variation:`string`,autoWrap:`boolean`,padding:`number`,charset:`string`,updateNotice:`boolean`,colorCompatibility:`string`,menuGlyph:`string`},yF=new Set([`1`,`true`]),bF=new Set([`0`,`false`,``]);function xF(e,t){let n=KF(e),r=n.scope===`segment-palette`?`string`:vF[n.field];if(r===`string`)return JSON.stringify(t);if(r===`number`){let n=Number(t);if(!Number.isFinite(n))throw Error(`persistValueText: "${e}" expects a number, got "${t}"`);return String(n)}if(yF.has(t))return`true`;if(bF.has(t))return`false`;throw Error(`persistValueText: "${e}" expects boolean-ish (1, 0, true, false), got "${t}"`)}function SF(e){try{return r.readFileSync(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return null;throw e}}function CF(e,t,n){try{if(t===null){r.rmSync(e,{force:!0});return}r.mkdirSync(c.dirname(e),{recursive:!0}),je(e,t)}catch(t){let r=`config write failed (${e}): ${t.message}`;throw n(`error`,r),Error(r)}}function wF(e){return/^\s*$/.test(e)?null:Lo(e)}function TF(e,t){return e!==null&&zo(e,t)!==void 0}function EF(e){if(e.kind===`segment`)return e.when===void 0?e.name:{seg:e.name,when:e.when};if(e.kind===`container`){let{kind:t,direction:n,children:r,...i}=e;return{[n===`horizontal`?`h`:`v`]:r.map(EF),...i}}return e}function DF(e){if(!Mc(e))return EF(e);let{rows:t,...n}=e;return{rows:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,EF(t)])),...n}}const OF=cA,kF=OF.segments,AF=OF.presets,jF=OF.root;function MF(e,t,n,r){if(!TF(e,t)&&n===void 0)throw new $(`cannot edit ${r}: neither the config file nor the bundled default declares ${t.join(`.`)}`)}function NF(e,t){let n=vx(t);return t.scope===`segment-palette`&&MF(e,[`segments`,t.segment],kF[t.segment],n.join(`.`)),n}function PF(e){return Lo(qo(e))}function FF(){return Object.entries(jF.rows).map(([e,t])=>{let n=EF(t);return{path:[`root`],fragment:PF({rows:{[e]:n}}),unit:{path:[`root`,`rows`,e],value:n}}})}function IF(e,t){let n=e===null?void 0:zo(e,t);return n===void 0?null:{path:t,fragment:n,unit:null}}function LF(e,t){if(t===void 0)return null;let n=DF(t);return{path:e,fragment:PF(n),unit:{path:e,value:n}}}function RF(e,t){let n=[`presets`,t],r=[...n,`root`],i=AF[t];MF(e,n,i,r.join(`.`));let a=IF(e,r)??LF(r,i?.root);return a!==null&&ms(a.fragment)?a:null}function zF(e,t){let n=ps(t.fragment);return n===null?new Map([[`#`,{path:t.path,unit:t.unit,node:t.fragment}]]):new Map([...e,...n.map(e=>[e.key,{path:[...t.path,`rows`,e.key],unit:t.unit,node:e.value}])])}function BF(e,t){return[...FF(),IF(e,[`root`]),RF(e,t)].filter(e=>e!==null).reduce(zF,new Map)}function VF(e,t,n){for(let{node:r,...i}of BF(e,t).values())if(gs(r,n))return i;throw new $(`${HF(e,t).join(`.`)} holds no placement "${n}" — the bar you clicked is stale (it reloads on the next render), or the action names a placement the layout never held`)}function HF(e,t){return RF(e,t)?.path??[`root`]}function UF(e,t){return t.scope===`preset-root`?HF(e,t.preset):vx(t)}function WF(e,{unit:t}){return t===null?e:ss(e,t.path,qo(t.value),Go)}function GF(e){let t=_x(e);if(t===null)throw Error(`"${e}" is not a valid persist target`);return t}function KF(e){let t=GF(e);if(t.scope===`preset-root`)throw Error(`"${e}" names a layout, not a value`);return t}function qF(e,t,n,r){JF(t,r),CF(t,r,e.logger),e.record(t,n,r)}function JF(e,t){try{return $T(ZT(e,t,uA),e)}catch(e){throw e instanceof xs?new $(`refused: the config file would not load after this click — ${e.message}`):e}}function YF(e,t){let n=KF(t),r=wF(SF(e)??``),i=r===null?void 0:zo(r,vx(n));return i!==void 0&&`value`in i?i.value:void 0}function XF(e,t,n){ZF(e,t,n,[])}function ZF(e,t,n,r){let i=SF(t);qF(e,t,i,QF(n.reduce((e,[t,n])=>ss(e,NF(wF(e),KF(t)),xF(t,n),Go),i??``),t,r,e=>e))}function QF(e,t,n,r){return n.reduce((e,{preset:n,id:i,setting:a,value:o})=>{let s=r(e,n,i),c=VF(wF(s),n,i),l=bs(WF(s,c),c.path,i,a,qo(o));if(l===null)throw new $(`${c.path.join(`.`)} in ${t} has no placement "${i}" — the bar you clicked is stale (it reloads on the next render)`);return l},e)}function $F(e,t,n){let r=wF(e),i=[`presets`,t,`root`];for(let[a,{path:o,unit:s,node:c}]of BF(r,t)){if(!gs(c,n))continue;if(i.every((e,t)=>o[t]===e))return e;let l=s===null?Vo(e,c):qo(s.value);if(a!==`#`)return ss(e,[...i,`rows`,a],l,Go);if(RF(r,t)!==null)throw new $(`cannot give preset "${t}" its own copy of ${o.join(`.`)}: it already stages rows of its own over that tree`);return ss(e,i,l,Go)}return e}function eI(e,t){return ls(e,t,t[0]===`presets`&&t.length>2&&!fA(t[1])?2:0)}function tI(e,t,n){let r=n.map(GF),i=SF(t);if(i===null)return;let a=r.reduce((e,t)=>eI(e,UF(wF(e),t)),i);a!==i&&qF(e,t,i,a)}function nI(e){let t=e===null?void 0:zo(e,[`presets`]),n=new Set([...dA,...t?.kind===`object`?t.entries.map(e=>e.key):[]].map(yu));return Array.from({length:n.size+1},(e,t)=>`custom-${t+1}`).find(e=>!n.has(yu(e)))}function rI(e,t,n,r,i,a){let o=SF(t),s=wF(o??``),c=nI(s),l=[`presets`,c],u=RF(s,n),d=[...u===null?[]:[[[...l,`root`],u.unit===null?Vo(o??``,u.fragment):qo(u.unit.value)]],...Object.keys(r).length===0?[]:[[[...l,`globals`],qo(r)]]],f=i.map(([e,t])=>{let n=gx(c,e);return[NF(s,KF(n)),xF(n,t)]});return qF(e,t,o,QF([...d,...f].reduce((e,[t,n])=>ss(e,t,n,Go),ss(o??``,l,`{}`,Go)),t,a.map(e=>({...e,preset:c})),$F)),c}function iI(e,t,n){if(fA(n))throw new $(`cannot delete preset "${n}": it is bundled — reset its settings instead`);let r=[`presets`,n],i=SF(t),a=wF(i??``);if(i===null||a===null||zo(a,r)===void 0)throw new $(`cannot delete preset "${n}": ${t} declares no ${r.join(`.`)} — the bar you clicked is stale; it reloads on the next render`);let o=zo(a,[`globals`,`preset`]);qF(e,t,i,[r,...o?.kind===`string`&&o.value===n?[[`globals`,`preset`]]:[]].reduce((e,t)=>eI(e,t),i))}function aI(e,t,n,r){let i=GF(n);if(i.scope!==`preset-root`)throw Error(`"${n}" is not a "presets.<name>.root" target`);let a=SF(t),o=r.op===`remove`?r.target:r.anchor,s=VF(wF(a??``),i.preset,o),c=WF(a??``,s),{after:l,placed:u}=oI(c,s.path,r,()=>{let e=JF(t,c);return D_(e.presets).map(t=>A_(e,t).node)});if(l===null)throw new $(`${s.path.join(`.`)} in ${t} has no placement "${o}" — the bar you clicked is stale (it reloads on the next render), or the action names a placement the layout never held`);return qF(e,t,a,l),u}function oI(e,t,n,r){switch(n.op){case`remove`:return{after:vs(e,t,n.target),placed:null};case`insert`:{let i=Fk(n.segment,n.anchor,r());return{after:ys(e,t,i,n.anchor,n.relation),placed:i}}}}const sI={load:()=>({}),save:()=>{}},cI=new Set(Ib.map(e=>e.sessionKey)),lI=e=>cI.has(e)||e.startsWith(Z_),uI=8*1024*1024,dI={past:[],future:[]},fI=e=>e.kind===`session`?`session:${e.key}`:`file:${e.file}`;var pI=class{state=new Map;constructor(e,t,n=sI){this.sessionState=e,this.logger=t,this.storage=n,this.state=new Map(Object.entries(n.load()))}useStorage(e){this.storage=e,this.state=new Map(Object.entries(e.load()))}depth(e){let{past:t,future:n,savepoint:r}=this.state.get(e)??dI;return{undo:t.length,redo:n.length,sinceEdit:r?.net.length??0}}history(e){return this.state.get(e)??dI}begin(){let e=new Map,t=(t,n)=>{let r=e.get(t)??new Map,i=r.get(fI(n));r.set(fI(n),i===void 0?n:{...n,before:i.before}),e.set(t,r)},n=new Map;return{sessionState:fF(this.sessionState,e=>lI(e)||e===`edit.mode`,(e,r,i,a)=>{if(r===`edit.mode`){let t=n.get(e);n.set(e,{before:t===void 0?i:t.before,after:a});return}t(e,{kind:`session`,key:r,before:i,after:a})}),file:(e,n,r,i)=>t(e,{kind:`file`,file:n,before:r,after:i}),commit:()=>{let t=new Map(e),r=new Map(n);e.clear(),n.clear();for(let e of new Set([...t.keys(),...r.keys()])){let n=[...t.get(e)?.values()??[]].filter(e=>e.before!==e.after),i=this.history(e),a=n.length===0?i:xI(i,n),o=r.get(e),s=o===void 0?a:TI(a,o);s!==i&&this.put(e,s)}}}}undo(e){let t=this.history(e),n=t.past.at(-1);if(n===void 0)throw new $(`undo: nothing to undo`);return this.apply(e,n,`before`,`undo`,CI(t,n)),n}rewind(e){let t=this.history(e),{savepoint:n}=t;if(n===void 0)throw new $(`rewind: edit mode has no savepoint — nothing to cancel`);let r=n.net.filter(t=>this.read(e,t)!==t.after),i=new Set(r.map(fI)),a=n.net.filter(e=>!i.has(fI(e))),o=gI(EI(wI(t,n),i));if(this.apply(e,a,`before`,`rewind`,{past:o,future:[],savepoint:{at:o.length,net:[],below:[]}}),r.length>0)throw new $(`rewind: ${r.map(OI).join(`, `)} changed since edit mode opened — kept as it is; everything else edit mode changed was put back`);return a}redo(e){let t=this.history(e),{past:n,future:r}=t,i=r.at(-1);if(i===void 0)throw new $(`redo: nothing to redo`);let a=[...n,i],o=gI(a);return this.apply(e,i,`after`,`redo`,{past:o,future:r.slice(0,-1),...vI(t.savepoint,a.length-o.length,i)}),i}apply(e,t,n,r,i){let a=n===`before`?`after`:`before`,o=t.filter(t=>this.read(e,t)!==t[a]);if(o.length>0){let t=new Set(o.map(fI)),{past:n,future:i,savepoint:a}=this.history(e);throw this.put(e,{past:EI(n,t),future:EI(i,t),...a!==void 0&&{savepoint:{at:EI([...n,...[...i].reverse()].slice(0,a.at),t).length,net:a.net.filter(e=>!t.has(fI(e))),below:EI(a.below,t)}}}),new $(`${r}: ${o.map(OI).join(`, `)} changed since that edit — refusing to overwrite it; this session's undo history no longer steps it`)}let s=[];try{for(let r of t)this.write(e,r,r[n]),s.push(r);this.put(e,i)}catch(t){try{for(let t of s.reverse())this.write(e,t,t[a])}catch(e){throw Error(`${t.message}; and putting the step back failed, so it is half-applied: ${e.message}`)}throw t}}read(e,t){return t.kind===`session`?this.sessionState.get(e,t.key):SF(t.file)}write(e,t,n){t.kind===`file`?CF(t.file,n,this.logger):n===null?this.sessionState.clear(e,t.key):this.sessionState.set(e,t.key,n)}put(e,t){let n=new Map(this.state);for(n.delete(e),(t.past.length>0||t.future.length>0||t.savepoint!==void 0)&&n.set(e,t);n.size>32||mI(n)>uI;){let[e,t]=n.entries().next().value;n.size>1?n.delete(e):t.past.length+t.future.length>0?n.set(e,hI(t)):(this.logger(`warn`,`settings-history: edit mode's changes for session ${e} exceed ${uI} bytes; cancel is no longer available`),n.delete(e))}this.storage.save(Object.fromEntries(n)),this.state=n}};function mI(e){let t=0;for(let{past:n,future:r,savepoint:i}of e.values())for(let e of[...n,...r,...i===void 0?[]:[i.net,...i.below]])for(let n of e)t+=(n.before?.length??0)+(n.after?.length??0);return t}function hI({past:e,future:t,savepoint:n}){return e.length>0?{past:e.slice(1),future:t,...vI(n,1,[])}:{past:e,future:t.slice(1),...vI(n,0,[])}}function gI(e){return e.slice(-50)}const _I=e=>e===$_.member;function vI(e,t,n){return e===void 0?{}:{savepoint:{at:Math.max(0,e.at-t),net:yI(e.net,n),below:e.below}}}function yI(e,t){let n=new Map(e.map(e=>[fI(e),e]));for(let e of t){let t=n.get(fI(e));n.set(fI(e),t===void 0?e:{...t,after:e.after})}return[...n.values()].filter(e=>e.before!==e.after)}const bI=e=>e.map(e=>({...e,before:e.after,after:e.before}));function xI(e,t){let n=[...e.past,t],r=gI(n),{savepoint:i}=e,a=i===void 0?0:Math.max(0,i.at-e.past.length);return{past:r,future:[],...vI(i&&{at:Math.min(i.at,e.past.length),net:i.net,below:[...SI(e.future,a),...i.below]},n.length-r.length,t)}}function SI(e,t){let n=Math.min(t,e.length);return e.slice(e.length-n).reverse()}function CI(e,t){return{past:e.past.slice(0,-1),future:gI([...e.future,t]),...vI(e.savepoint,0,bI(t))}}function wI(e,t){let{past:n,future:r}=e,i=n.slice(0,t.at);return[...i,...SI(r,t.at-i.length),...t.below]}function TI(e,t){if(_I(t.after)&&!_I(t.before))return{...e,savepoint:{at:e.past.length,net:[],below:[]}};if(!_I(t.after)&&_I(t.before)){let{past:t,future:n}=e;return{past:t,future:n}}return e}function EI(e,t){return e.map(e=>e.filter(e=>!t.has(fI(e)))).filter(e=>e.length>0)}function DI(e){return e.map(OI).join(`, `)}function OI(e){return e.kind===`session`?`session setting "${e.key}"`:e.file}function kI(e){if(typeof e!=`object`||!e)return!1;let t=e,n=e=>e===null||typeof e==`string`;return(t.kind===`session`&&typeof t.key==`string`||t.kind===`file`&&typeof t.file==`string`)&&n(t.before)&&n(t.after)}function AI(e){return Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(kI))}function jI(e){if(typeof e!=`object`||!e)return!1;let t=e;return Number.isInteger(t.at)&&t.at>=0&&Array.isArray(t.net)&&t.net.every(kI)&&AI(t.below)}function MI(e){if(typeof e!=`object`||!e)return!1;let t=e;return AI(t.past)&&AI(t.future)&&(t.savepoint===void 0||jI(t.savepoint))}function NI(e,t){return{load:()=>{let n;try{n=r.readFileSync(e,`utf8`)}catch(e){let n=e.code;return n!==`ENOENT`&&t(`warn`,`settings-history read failed (${n}); starting empty`),{}}try{let e=JSON.parse(n);if(typeof e==`object`&&e&&!Array.isArray(e)&&Object.values(e).every(MI))return e}catch{}return t(`warn`,`settings-history load: unexpected shape, starting empty`),{}},save:n=>{try{r.mkdirSync(c.dirname(e),{recursive:!0}),je(e,JSON.stringify(n),384)}catch(e){let n=`settings-history write failed — the change landed but is not undoable: ${e.message}`;throw t(`error`,n),Error(n)}}}}const PI=e=>!lI(e)&&!Yx(e)&&e!==`update.dismissed`;var FI=class{past=new Map;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:fF(e,PI,(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 $(`back: nothing to go back to${o>0?` (${o} step(s) over a view since gone, discarded)`:``}`);return(0,Ov.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){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)}};function II(e){let t=$M(e,`doctor.tmux`,[`display`,`-p`,`-t`,e.pane,`#{client_termfeatures}`]);return t.kind===`ok`?{kind:`ok`,value:t.stdout.trim().split(`,`).filter(e=>e!==``)}:{kind:`failed`,reason:t.reason}}function LI(e){return{probeTmux:II,loadConfig:e}}function RI(e,t){let n=e.loadConfig(t),r={path:n.path,warnings:n.warning===null?[]:n.warning.split(`
201
+ `)};return n.error===null?{...r,kind:`loaded`,shadowed:JT(t.projectDir,t.cwd,t.configFile??void 0),unused:n.unused}:{...r,kind:`failed`,error:n.error}}function zI(e){let t=cS(e).env;if(t===void 0)return{path:e,env:{}};if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`cannot read ${e}: \`env\` is not an object`);return{path:e,env:t}}function BI(e,t){return t===void 0?{kind:`unreported`}:t===null?{kind:`outside`}:{kind:`inside`,hint:t,termfeatures:e.probeTmux(t)}}function VI(e,t,n){return{tmux:BI(e,t.tmux),config:RI(e,n),claudeSettings:zI(aS(iS(t.claudeConfigDir)))}}function HI(e,t){let n=t.claudeSettings.path;switch(e.kind){case`claude-settings-env`:{let i=ss(sS(n),[`env`,e.name],JSON.stringify(e.value),Ko);return r.mkdirSync(c.dirname(n),{recursive:!0}),je(n,i),{...t,claudeSettings:zI(n)}}default:return e.kind}}const UI=/^─{20,}/,WI=/^❯(\s|$)/,GI=/›\s*stashed$/;function KI(e){if(e.inMode)return{kind:`in-mode`};let t=e.screen.map(e=>e.trimEnd()),n=t.flatMap((e,t)=>UI.test(e)?[t]:[]).at(-2);return n===void 0||!WI.test(t[n+1]??``)?{kind:`no-prompt`}:GI.test(t[n-1]??``)?{kind:`stashed`}:{kind:`ready`}}const qI={"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 JI(e,t,n){if(t===void 0)return{kind:`refused`,reason:`this session's statusline client reports no tmux facts (it predates this daemon) — rebuild or reinstall cc-candybar`};if(t===null)return{kind:`refused`,reason:`this Claude Code is not running inside tmux — the bar can only type into a tmux pane`};let r=KI(e.read(t));if(r.kind!==`ready`)return{kind:`refused`,reason:qI[r.kind]};let i=e.type(t,n);return i.kind===`typed`?{kind:`typed`,pane:t.pane}:i}const YI=`cc-candybar-slash`;function XI(e,t,n,r){let i=$M(e,t,n,r);if(i.kind===`failed`)throw Error(i.reason);return i}function ZI(e){let t=XI(e,`claude-input.read`,[`display`,`-p`,`-t`,e.pane,`#{pane_in_mode}`,`;`,`capture-pane`,`-p`,`-t`,e.pane]);if(t.kind===`rate-limited`)throw Error(t.reason);let[n=``,...r]=t.stdout.split(`
202
+ `);return{inMode:n!==`0`,screen:r}}function QI(e,t){let n=XI(e,`claude-input.type`,[`load-buffer`,`-b`,YI,`-`,`;`,`send-keys`,`-t`,e.pane,`C-s`,`;`,`paste-buffer`,`-p`,`-d`,`-b`,YI,`-t`,e.pane,`;`,`send-keys`,`-t`,e.pane,`Enter`],t);return n.kind===`ok`?{kind:`typed`}:{kind:`refused`,reason:`cc-candybar typed a command moments ago — click again in a second (${n.reason})`}}function $I(){return{read:ZI,type:QI}}function eL(e){if(!e)throw new $(`session id is required`);if(e.includes(`/`)||e.includes(`..`))throw new $(`invalid session id "${e}"`);return e}function tL(e){return nL(()=>decodeURIComponent(e))}function nL(e){try{return e()}catch(e){throw e instanceof URIError?new $(`malformed wire encoding: ${e.message}`):e}}function rL(e,t){let n=ke({bin:`/usr/bin/pbcopy`,stdinInput:e,category:`click.pbcopy`});if(!n.ok){if(n.reason===`rate-limited`){t.dlog(`warn`,`click.pbcopy rate-limited: ${n.error??``}`);return}throw Error(`pbcopy failed (${n.reason}, exit ${n.exitCode??`null`})`)}}const iL=(e,t)=>rL(tL(e),t),aL=(e,t)=>{let n=ke({bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,tL(e)],category:`click.open`});if(!n.ok){if(n.reason===`rate-limited`){t.dlog(`warn`,`click.open rate-limited: ${n.error??``}`);return}throw Error(`open -a "Visual Studio Code" failed (${n.reason}, exit ${n.exitCode??`null`})`)}},oL=(e,t)=>rL(tL(e),t),sL=(e,t)=>rL(tL(e),t),cL=(e,t)=>{let n=eL(tL(e));t.navigating.get(n,`toolbar-expanded`)?t.navigating.clear(n,`toolbar-expanded`):t.navigating.set(n,`toolbar-expanded`,`1`)},lL=(e,t)=>{let[n=``,...r]=nL(()=>RD(e)),i=eL(n),a=Vj(xL(t,i));if(r.length===0)throw new $(`set-state: <key>/<value> is required (have keys: ${a.listKeys().join(`, `)})`);if(r.length%2!=0)throw new $(`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 $(`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 $(`set-state: pair ${e/2+1}: ${i.reason}`);o.push({key:t,value:i.value})}pL(t,i,`set-state`,o),t.navigating.setBatch(i,o);let s=o.map(e=>`${e.key}=${e.value}`).join(` `);t.dlog(`info`,`set-state: ${s} (session=${i})`)},uL=/^-?\d+$/;function dL(e,t,n,r){let i=e+t;return i>r?e===r?n:r:i<n?e===n?r:n:i}const fL=(e,t)=>{let[n=``,r=``,i=``]=nL(()=>RD(e)),a=eL(n);if(!r)throw new $(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!uL.test(i))throw new $(`step-state: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=xL(t,a),c=Vj(s),l=c.rangeParamsFor(r);if(!l)throw new $(`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&&uL.test(u)?mL(l,parseInt(u,10)):hL(`step-state`,r,l,Wj(s,e=>t.sessionState.get(a,e),r)),f=dL(d,o,l.min,l.max),p=c.validate(r,String(f));if(!p.ok)throw new $(`step-state: ${p.reason}`);pL(t,a,`step-state`,[{key:r,value:p.value}]),t.navigating.set(a,r,p.value),t.dlog(`info`,`step-state: ${r} ${d}→${p.value} (by ${o}, session=${a})`)};function pL(e,t,n,r){let i=r.filter(e=>e.key.startsWith(Z_));if(i.length===0)return;let a=Sj(xL(e,t),n=>e.sessionState.get(t,n),i);if(a.length>0)throw new $(`${n}: refused — ${a.join(`; `)}`)}function mL(e,t){return Math.max(e.min,Math.min(e.max,t))}function hL(e,t,n,r){if(r===null)return n.min;if(!uL.test(r))throw new $(`${e}: "${t}" shows ${JSON.stringify(r)} before any click, not an integer to step`);return mL(n,parseInt(r,10))}const gL=`render-origin`;function _L(e){return JSON.stringify(e)}function vL(e){let t;try{t=JSON.parse(e)}catch{throw new $(`render origin is not JSON: ${e}`)}if(typeof t!=`object`||!t)throw new $(`render origin is not an object: ${e}`);let{projectDir:n,cwd:r,configFile:i}=t;if(typeof n!=`string`||typeof r!=`string`||i!==null&&typeof i!=`string`)throw new $(`render origin has the wrong shape: ${e}`);return{projectDir:n,cwd:r,configFile:i}}function yL(e,t){let n=e.sessionState.get(t,gL);if(n===null)throw new $(`session ${t} has not rendered yet — no config to act on`);return vL(n)}function bL(e,t,n){let r=e.sessionState.get(t,gL);if(r===null)return;let i=vL(r),a=SL(i);n.some(e=>e.kind===`file`&&e.file===a)&&e.reloadConfig(i)}function xL(e,t){return e.configFor(yL(e,t))}function SL(e){return GT(e.projectDir,e.cwd,e.configFile??void 0)}function CL(e,t){return{record:(n,r,i)=>e.journal.file(t,n,r,i),logger:e.dlog}}const wL=(e,t)=>{let[n=``,r=``,i=``]=nL(()=>RD(e)),a=eL(n),o=yL(t,a),s=t.configFor(o),c=Jk(s);if(!r)throw new $(`set-config: <key>/<value> is required (have keys: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new $(`set-config: ${l.reason}`);let u=SL(o),d=bj(s,e=>t.sessionState.get(a,e),r);XF(CL(t,a),u,[[d.key,l.value]]),t.reloadConfig(o),t.dlog(`info`,`set-config: ${d.key}=${l.value} → ${u} (session=${a})`)},TL=(e,t)=>{let[n=``,r=``,i=``]=nL(()=>RD(e)),a=eL(n);if(!r)throw new $(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!uL.test(i))throw new $(`step-config: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=yL(t,a),c=t.configFor(s),l=Jk(c),u=l.rangeParamsFor(r);if(!u)throw new $(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${l.listKeys().join(`, `)})`);let d=SL(s),f=bj(c,e=>t.sessionState.get(a,e),r),p=YF(d,f.key),m=typeof p==`number`?mL(u,p):hL(`step-config`,r,u,Xk(f.globals,r)),h=dL(m,o,u.min,u.max),g=l.validate(r,String(h));if(!g.ok)throw new $(`step-config: ${g.reason}`);XF(CL(t,a),d,[[f.key,g.value]]),t.reloadConfig(s),t.dlog(`info`,`step-config: ${f.key} ${m}→${g.value} (by ${o}) → ${d} (session=${a})`)},EL=(e,t)=>{let[n=``]=nL(()=>RD(e)),r=eL(n),i=yL(t,r),a=t.configFor(i),o=e=>t.sessionState.get(r,e),s=vj(a,o),c=xj(a,o);if(s.length+c.length===0){t.dlog(`info`,`save: nothing unsaved (session=${r})`);return}let l=Vj(a),u=s.map(e=>{let t=l.validate(e.sessionKey,e.value);if(!t.ok)throw new $(`save: ${t.reason}`);return[e.target,t.value]});OL(`save`,l,c);let d=SL(i);ZF(CL(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.dlog(`info`,`save: ${[...u.map(([e,t])=>`${e}=${t}`),...c.map(DL)].join(` `)} → ${d} (session=${r})`)},DL=e=>`${e.preset}/${e.id}.settings.${e.setting}=${Ks(e.value)}`;function OL(e,t,n){for(let r of n){let n=t.validate(r.key,Ks(r.value));if(!n.ok)throw new $(`${e}: ${n.reason}`)}}const kL=(e,t)=>{let[n=``]=nL(()=>RD(e)),r=eL(n),i=yL(t,r),a=t.configFor(i),o=Tj(a,e=>t.sessionState.get(r,e)),s=Vj(a),c=o.picks.map(e=>{let t=s.validate(e.sessionKey,e.value);if(!t.ok)throw new $(`save-preset: ${t.reason}`);return[e.configKey,t.value]});OL(`save-preset`,s,o.placements);let l=SL(i),u=rI(CL(t,r),l,o.from,o.globals,c,o.placements);t.reloadConfig(i);for(let e of[...Ib.map(e=>e.sessionKey),...o.placements.map(e=>e.key)])t.sessionState.clear(r,e);t.sessionState.set(r,Fb.preset.sessionKey,u),t.dlog(`info`,`save-preset: ${[`${u} from=${o.from}`,...c.map(([e,t])=>`${e}=${t}`),...o.placements.map(DL)].join(` `)} → ${l} (session=${r})`)},AL=(e,t)=>{let[n=``,r=``]=nL(()=>RD(e)),i=eL(n);if(!r)throw new $(`delete-preset: <name> is required (shape: <sessionId>/<name>)`);let a=yL(t,i),o=SL(a);iI(CL(t,i),o,r),t.reloadConfig(a);let s=Fb.preset.sessionKey;t.sessionState.get(i,s)===r&&t.sessionState.clear(i,s),t.dlog(`info`,`delete-preset: ${r} ← ${o} (session=${i})`)},jL=(e,t)=>{let[n=``,...r]=nL(()=>RD(e)),i=eL(n),a=yL(t,i),o=Jk(t.configFor(a)).listKeys(),s=r.length===0?[``]:r.filter(e=>!o.includes(e));if(s.length>0)throw new $(`reset-config: unknown config key "${s.join(`", "`)}" (have: ${o.join(`, `)})`);let c=SL(a),l=r.map(Ej),u=l.flatMap(e=>e.fileKeys),d=l.flatMap(e=>e.sessionKeys);tI(CL(t,i),c,u),t.reloadConfig(a);for(let e of d)t.sessionState.clear(i,e);t.dlog(`info`,`reset-config: ${[...u,...d.map(e=>`session:${e}`)].join(` `)} ← ${c} (session=${i})`)};function ML(e,t){let n=(e,t)=>[...Ms(A_(e,t).node)].filter(e=>e.kind===`segment`),r=new Set(D_(t.presets).flatMap(e=>n(t,e).map(t=>Q_(yu(e),Os(t)))));return D_(e.presets).flatMap(t=>n(e,t).map(e=>({member:Q_(yu(t),Os(e)),node:e})).filter(({member:e})=>!r.has(e)))}function NL(e,t){return e.flatMap(({member:e,node:n})=>[...Object.values(n.drafts??{}).map(e=>e.key),...e===t?[K_]:[]])}const PL=(e,t)=>{let[n=``,r=``,i=``]=nL(()=>RD(e)),a=eL(n),o=yL(t,a),s=t.configFor(o),c=Jk(s);if(!r)throw new $(`apply-layout-op: <key>/<op> is required (have: ${c.listKeys().join(`, `)})`);let l=c.validate(r,i);if(!l.ok)throw new $(`apply-layout-op: ${l.reason}`);let u=Pk(l.value);if(u===null)throw new $(`apply-layout-op: "${l.value}" is not a layout op token`);let d=SL(o),f=aI(CL(t,a),d,r,u);t.reloadConfig(o);let p=NL(ML(s,t.configFor(o)),t.sessionState.get(a,K_)).filter(e=>t.sessionState.get(a,e)!==null);for(let e of p)t.sessionState.clear(a,e);t.dlog(`info`,`apply-layout-op: ${r} ${l.value} → ${d} placed=${JSON.stringify(f)} released=${JSON.stringify(p)} (session=${a})`)},FL=(e,t)=>{let[n=``]=nL(()=>RD(e)),r=eL(n);t.journal.commit();let i=t.history.undo(r);bL(t,r,i),t.dlog(`info`,`undo: restored ${DI(i)} (session=${r})`)},IL=(e,t)=>{let n=eL(tL(e)),{step:r,discarded:i}=t.navigation.back(n,t.sessionState,Vj(xL(t,n))),a=r.map(e=>`${e.key}=${e.before??`∅`}`).join(` `);t.dlog(`info`,`back: ${a} discarded=${i} (session=${n})`)},LL=(e,t)=>{let n=eL(tL(e));t.journal.commit();let r=t.history.rewind(n);bL(t,n,r),t.dlog(`info`,`rewind: put back ${DI(r)||`nothing`} as edit mode found it (session=${n})`)},RL=(e,t)=>{let[n=``]=nL(()=>RD(e)),r=eL(n);t.journal.commit();let i=t.history.redo(r);bL(t,r,i),t.dlog(`info`,`redo: re-applied ${DI(i)} (session=${r})`)},zL=(e,t)=>{eL(tL(e)),t.applyUpdate()},BL=`client-hints`;function VL(e,t){let n=e.sessionState.get(t,BL);if(n===null)throw new $(`session ${t} has not rendered yet — no client facts are recorded for it`);let r;try{r=JSON.parse(n)}catch{throw new $(`client hints record is not JSON: ${n}`)}if(typeof r!=`object`||!r)throw new $(`client hints record is not an object: ${n}`);return oE(r)}function HL(e,t,n){let r=Rx(n);e.sessionState.setBatch(t,Ux(r)),e.dlog(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed(${1+(e.verdict.more?.length??0)})`}`).join(` `)} (session=${t})`)}const UL=(e,t)=>{let n=eL(tL(e));HL(t,n,VI(t.doctor,VL(t,n),yL(t,n)))},WL=(e,t)=>{let[n=``,r=``]=nL(()=>RD(e)),i=eL(n),a=zx(r);if(a===void 0)throw new $(`doctor-fix: unknown check "${r}"`);let o=VI(t.doctor,VL(t,i),yL(t,i)),s=a.probe(o);if(s.ok||s.fix===void 0)throw new $(`doctor-fix: ${a.label} — ${s.ok?`nothing to fix`:s.reason}`);let c=HI(s.fix,o);t.dlog(`info`,`doctor-fix: ${a.name} → ${s.fix.kind} ${s.fix.name}=${s.fix.value} (session=${i})`),HL(t,i,c)},GL=(e,t)=>{let[n=``,...r]=nL(()=>RD(e)),i=eL(n),a=yL(t,i),o=Object.values(t.configFor(a).actions).filter(e=>`ceiling`in e).find(e=>{let t=yw(e);return t.length===r.length&&t.every((e,t)=>e===r[t])});if(o===void 0)throw new $(`ceiling: "${r.join(` `)}" is not a move this config declares`);let s=o.ceiling===`set`?{kind:`set`,to:o.to}:{kind:`clear`},c=EA({sessionId:i,projectDir:a.projectDir,cwd:a.cwd},VL(t,i));t.memento.move(c,s),t.dlog(`info`,`ceiling: ${r.join(` `)} (session=${i} claudeConfigDir=${c.claudeConfigDir})`)},KL=(e,t)=>{let[n=``,r=``]=nL(()=>RD(e)),i=eL(n),a=Object.values(t.configFor(yL(t,i)).actions).filter(e=>`slash`in e),o=a.find(e=>e.slash===r);if(o===void 0)throw new $(`${JSON.stringify(r)} is not a command this config declares (it declares: ${[...new Set(a.map(e=>e.slash))].join(`, `)||`none`})`);let s=JI(t.claudeInput,VL(t,i).tmux,o.slash);if(s.kind===`refused`)throw t.dlog(`warn`,`slash: ${r} refused — ${s.reason} (session=${i})`),new $(`${r} was not typed: ${s.reason}`);t.dlog(`info`,`slash: typed ${r} into ${s.pane} (session=${i})`)},qL=`config-override`,JL=new Map([[gD,iL],[`load-config`,(e,t)=>{let n=e.indexOf(`/`);if(n===-1)throw new $(`load-config: expected <sessionId>/<path> (missing separator)`);let r=eL(nL(()=>decodeURIComponent(e.slice(0,n)))),i=nL(()=>decodeURIComponent(e.slice(n+1))).trim();if(i!==``){if(!i.startsWith(`/`))throw new $(`load-config: path must be absolute, got "${i}"`);if(!/\.(json5?|json)$/.test(i))throw new $(`load-config: path must end with .json5 or .json, got "${i}"`)}i===``?(t.sessionState.clear(r,qL),t.dlog(`info`,`load-config: override cleared (session=${r})`)):(t.sessionState.set(r,qL,i),t.dlog(`info`,`load-config: ${i} (session=${r})`))}],[_D,aL],[mD,lL],[hD,fL],[xD,wL],[SD,TL],[ED,jL],[CD,EL],[wD,kL],[TD,AL],[DD,PL],[OD,FL],[kD,RL],[AD,IL],[jD,LL],[yD,oL],[bD,sL],[vD,cL],[MD,zL],[ND,UL],[PD,WL],[FD,GL],[ID,KL]]),YL=new Set([mD,hD,xD,SD,ED,CD,wD,TD,DD,OD,kD,AD,jD,vD,MD,ND,PD,FD,ID]),XL=(e,t)=>{let n=[],r=!1,i=null;for(let{verb:a,value:o}of HD(BD(e))){if(!i&&YL.has(a)){let e=RD(o);e.length>0&&e[0]&&(i=e[0])}let e=JL.get(a);if(!e){n.push(`unknown effect verb "${a}"`);continue}try{e(o,t)}catch(e){e instanceof $||(r=!0),n.push(`${a}: ${e instanceof Error?e.message:String(e)}`)}}if(n.length>0){i&&t.sessionState.set(i,`click.error`,n.join(`
203
+ `));let e=`dispatch: ${n.join(`; `)}`;throw r?Error(e):new $(e)}};function ZL(e){return(t,n)=>{let r=n.history.begin(),i=n.navigation.begin(r.sessionState),a=[];try{e(t,{...n,sessionState:r.sessionState,journal:r,navigating:i.sessionState})}catch(e){a.push(e)}i.commit();try{r.commit()}catch(e){a.push(e)}if(a.length===1)throw a[0];if(a.length>1)throw Error(a.map(e=>String(e.message??e)).join(`; `))}}const QL=new Map([...JL,[pD,XL]].map(([e,t])=>[e,ZL(t)]));Object.freeze([...QL.keys()]);const $L=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`]),eR=[[`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`]],tR=[[`workspace.added_dirs`,`string-list`]];function nR(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of eR){let i=aR(n,e);if(i==null)t.missingRequired.push(e);else{let n=rR(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let[e,r]of tR){let i=aR(n,e),a=i===void 0?r:iR(i);a!==r&&t.typeMismatches.push({path:e,expected:r,got:a})}for(let e of Object.keys(n))$L.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function rR(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function iR(e){return Array.isArray(e)&&e.every(e=>rR(e)===`string`)?`string-list`:rR(e)}function aR(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 oR(e,t){switch(e){case`vars`:return{what:e,vars:sR(t)};case`segments`:return{what:e,segments:fR(t)};case`config`:return{what:e,config:gR(t)}}}function sR(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=uR(r),a=t.names().sort(),o=[];for(let e of a){let r=t.getNode(e),a=n.getLastError(e);o.push({name:e,source:i.get(e)??null,...cR(r),lastError:a===void 0?null:{timestampMs:a.timestamp,message:a.message},ageMs:lR(r.lastUpdatedMs())})}return o}function cR(e){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`absent`:return{type:`document`,value:`(not yet scanned)`};case`failed`:return{type:`document`,value:t.reason}}}function lR(e){return e===null?null:Math.max(0,Date.now()-e)}function uR(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,dR(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}`,dR(i));return t}function dR(e){return e.kind}function fR(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=mR(n),o=pR(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:hR(t.template,n.helpers,i),placements:(o.get(e)??[]).map(e=>({id:e,lastRender:r.get(e)??null}))})}return s}function pR(e){let t=new Map;for(let n of D_(e.presets))for(let r of Ms(A_(e,n).node)){if(r.kind!==`segment`)continue;let e=t.get(r.name)??[],n=Os(r);e.includes(n)||t.set(r.name,[...e,n])}return t}function mR(e){let t=[],n=new Set;for(let r of Ms(Fc(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 hR(e,t,n){let r=new Set;for(let i of _v(e,t).keys()){if(n.has(i)){r.add(i);continue}let e=i.split(`.`);for(;e.length>1;){e.pop();let t=e.join(`.`);if(n.has(t)){r.add(t);break}}}return Array.from(r).sort()}function gR(e){return e===null?null:e.config}const _R=[`vars`,`segments`,`config`];function vR(e){return typeof e==`string`&&_R.includes(e)}function yR(e){return Math.max(1,e-2)}var bR=class{written=new Map;constructor(e){this.dir=e}pathFor(e){return c.join(this.dir,`${encodeURIComponent(e)}.txt`)}sync(e,t){let n=this.pathFor(e);if(t===(this.written.get(e)??null))return null;try{return t===null?(r.rmSync(n,{force:!0}),this.written.delete(e)):(r.mkdirSync(this.dir,{recursive:!0,mode:448}),r.writeFileSync(n,t,{mode:384}),this.written.set(e,t)),null}catch(e){return`${n}: ${e.message}`}}reset(){this.written.clear();try{return r.rmSync(this.dir,{recursive:!0,force:!0}),null}catch(e){return`${this.dir}: ${e.message}`}}};const xR=new dF;Ee(xR.launchStats);const SR=new nb({counters:xR,logger:Z}),CR=aN({watchers:SR,logger:Z}),{gitProvider:wR,usageStore:TR,mementoProvider:ER}=CR,DR=new hF,OR=new pI(DR,Z),kR=new FI,AR=new bR(qe()),jR=new lF({gitService:wR,sessionState:DR,watchers:SR},{observers:{onReload:e=>Z(`info`,`config loaded projectDir=${e.projectDir} cwd=${e.cwd} file=${e.configFilePath??`<bundled default>`} error=${e.lastError===null?`none`:JSON.stringify(e.lastError)} warning=${e.lastWarning===null?`none`:JSON.stringify(e.lastWarning)}`)}}),MR=60*1e3;function NR(){let e=import.meta.url,n=[];e.startsWith(`file://`)&&n.push(E(e)),t.argv[1]&&n.push(t.argv[1]);let i=new Map;for(let e of n)try{i.set(e,r.statSync(e).mtimeMs)}catch{}let a=null,o=()=>{for(let[e,t]of i)try{if(r.statSync(e).mtimeMs!==t){Z(`info`,`binary mtime changed (${e}); shutting down`),a&&clearInterval(a),YR(0);return}}catch(e){Z(`warn`,`bin stat failed: ${e.message}`)}};return{arm(){i.size!==0&&(a=setInterval(o,MR),a.unref())},checkNow:o}}const PR=NR(),FR=lM({entryUrl:import.meta.url,intervalMs:MR,releaseIntervalMs:216e5,registryUrl:t.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,fetchImpl:fetch,onApplied:()=>PR.checkNow(),log:Z});let IR=null,LR=null,RR=0;function zR(){t.on(`uncaughtException`,e=>{Z(`error`,`uncaughtException: ${e.stack||e.message}`),YR(1)}),t.on(`unhandledRejection`,e=>{Z(`error`,`unhandledRejection: ${String(e)}`),YR(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{Z(`info`,`received ${e}, shutting down`),YR(0)});try{RR=zE(t.env)}catch(e){Z(`error`,`refusing to boot: ${e.message}`),YR(1);return}IR=LO(t.pid);let e=qO(YO(IR));if(!e.decision.allow){Z(`warn`,`fork-bomb breaker: ${e.decision.reason}; refusing to boot`),YR(1);return}LR=e.registryPath,r.mkdirSync(Fe(),{recursive:!0}),Re(Ie()),DR.useStorage(new _F(Ve(),500,Z)),OR.useStorage(NI(He(),Z)),BO({anchor:zO(t.env),isAlive:VO,onOrphaned:e=>{Z(`info`,`parent watchdog: ${e}; shutting down`),YR(0)}}),BR(b.createServer({allowHalfOpen:!1},e=>{XR(e)}),Ie(),!1)}function BR(e,n,r){e.removeAllListeners(`error`),e.removeAllListeners(`listening`),e.once(`error`,i=>{if(i.code!==`EADDRINUSE`){Z(`error`,`server error: ${i.message}`),YR(1);return}if(r){Z(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}VR(e,n)}),e.listen(n,()=>HR(n))}function VR(e,n){let i=DO(OO(ze(n)),(e,t)=>IO(e,t,{readStartTime:FO,pidAlive:VO}));if(i.kind===`attach-and-exit`){Z(`info`,`EADDRINUSE: ${i.reason} — exiting`),t.exit(0);return}Z(`warn`,`EADDRINUSE: ${i.reason} — unlinking stale socket and rebinding`);try{r.unlinkSync(n)}catch(e){if(e.code!==`ENOENT`){Z(`error`,`cannot unlink stale socket ${n}: ${e.message}`),YR(1);return}}BR(e,n,!0)}function HR(e){let n=jO(e);if(n.kind!==`present`){Z(`warn`,`no ownable socket at bind callback (${n.kind}); exiting`),YR(0);return}KR(e);try{r.chmodSync(e,384)}catch(e){Z(`warn`,`chmod socket failed: ${e.message}`)}Z(`info`,`daemon up: pid=${t.pid} v=3 sock=${e} heapCap=${Math.round(te.getHeapStatistics().heap_size_limit/1048576)}MB rssLimit=${Math.round(RR/1048576)}MB`),nD();let i=AR.reset();i!==null&&Z(`warn`,`diagnostic dump wipe failed: ${i}`),PR.arm(),FR.arm(),GR(),UR(e,n.identity)}function UR(e,n){PO({bound:n,myPid:t.pid,readIdentity:()=>jO(e),readLease:()=>OO(ze(e)),shutdown:e=>YR(e),log:Z}).arm()}let WR=null;function GR(){WR=UE(qE(xR.startedAt.getTime(),e=>YR(e),{rssLimitBytes:RR})),WR.arm()}function KR(e){let n=kO(ze(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:IR});n!==null&&Z(`warn`,`lease write failed: ${n}`)}let qR=0,JR=!1;function YR(e){if(!JR){JR=!0,setTimeout(()=>t.kill(t.pid,`SIGKILL`),500);try{wR.close()}catch(e){Z(`warn`,`gitService close failed: ${e.message}`)}try{TR.close()}catch(e){Z(`warn`,`usageStore close failed: ${e.message}`)}try{SR.closeAll()}catch(e){Z(`warn`,`watcherRegistry close failed: ${e.message}`)}try{DR.flush()}catch(e){Z(`warn`,`sessionState flush failed: ${e.message}`)}AO(Be(),t.pid),LR!==null&&JO(LR,t.pid,GO,e=>r.unlinkSync(e)),t.exit(e)}}function XR(e){qR++,xR.inFlight=qR;let t=!1,n=(n,r)=>{if(t){r!==null&&Z(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`);return}t=!0;let i=r===null?void 0:()=>YR(r);try{e.end(hE(n),i)}catch(e){Z(`warn`,`response write failed: ${e.message}`),i?.()}},r=setTimeout(()=>{xR.requestsTimedOut++,n({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null)},200),i=gE(e=>{QR(e).then(e=>n(e.resp,e.exitAfterFlush)).catch(e=>{Z(`error`,`handler threw: ${e?.stack||e}`),n({ok:!1,error:String(e?.message||e),code:`RENDER_FAILED`,daemonV:3},null)})},e=>{Z(`warn`,`frame parse failed: ${e.message}`),n({ok:!1,error:e.message,code:`BAD_REQUEST`,daemonV:3},null)});e.on(`data`,i),e.on(`error`,e=>{Z(`warn`,`socket error: ${e.message}`)}),e.on(`close`,()=>{clearTimeout(r),qR=Math.max(0,qR-1),xR.inFlight=qR})}const ZR=e=>({resp:e,exitAfterFlush:null});async function QR(e){if(!e||typeof e!=`object`||typeof e.v!=`number`)return ZR({ok:!1,error:`malformed request`,code:`BAD_REQUEST`,daemonV:3});if(e.v!==3)return e.v>3?Z(`info`,`version mismatch: client=${e.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):Z(`info`,`version mismatch: client=${e.v} < daemon=3; client is stale — staying up`),{resp:{ok:!1,error:`protocol v${e.v} not supported (daemon at v3)`,code:`VERSION_MISMATCH`,daemonV:3},exitAfterFlush:e.v>3?0:null};if(e.kind===`shutdown`)return{resp:{ok:!0,output:``},exitAfterFlush:0};if(e.kind===`stats`)return ZR({ok:!0,stats:xR.snapshot({gitCache:wR.getStats(),usageCache:TR.getStats(),renderCacheSize:jR.size,watchersActive:SR.size(),nextRestartReason:WR?.describeNextRestart()??null})});if(e.kind===`render`){xR.requestsTotal++;let t=Date.now();try{let{report:n}=nR(e.hookData);for(let e of n.unknownTopLevelFields)Z(`info`,`schema: unknown field '${e}' — Anthropic may have added it`);let r=[];for(let e of n.missingRequired)r.push(`missing required field '${e}'`);for(let{path:e,expected:t,got:i}of n.typeMismatches)r.push(`field '${e}' expected ${t}, got ${i}`);if(e.cwd===``&&r.push(`request 'cwd' is empty`),r.length>0)return xR.requestsErrored++,Z(`warn`,`BAD_REQUEST: ${r.join(`; `)}`),ZR({ok:!1,error:`malformed hookData: ${r.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3});let i=e.hookData.workspace.project_dir,{configFile:a,unknownFlagsError:o}=$R(e.args),s=e.hookData.session_id,c=oE(e),l=JSON.stringify(c);DR.get(s,`client-hints`)!==l&&DR.set(s,BL,l);let u=DR.get(s,`config-override`)??a??c.configEnv,d=jR.getOrCreate(i,e.cwd,u),f=_L({projectDir:i,cwd:e.cwd,configFile:u??null});DR.get(s,`render-origin`)!==f&&DR.set(s,gL,f);let p=c.termCols,m=yR(p??120),h=fk(c.termRows),{authoredRoots:g}=d.state,_=t=>DR.get(e.hookData.session_id,t),v=zA(d.state.config,_,e=>g.has(e)),y=await nj(e.hookData,{...iz,navigation:e=>kR.depth(e,DR,Vj(d.state.config))},e.cwd,d.state.neededInputPaths(v.preset),v,c,{...Oj(d.state.config,d.state.fileHeldSettings,_),configPath:d.configFilePath}),b=[],x=BA(v,m),S=UP(d.state.config,d.state.compiled,d.state.store,d.state.registry,y,x,{perSegmentSink:d.state.lastRenderCellsBySegment,onRenderWarning:e=>b.push(e)},VA(v)),C=DR.get(e.hookData.session_id,`click.error`);C&&DR.clear(e.hookData.session_id,`click.error`);let w=[o,d.lastError,C].filter(Boolean).join(`
204
+ `),T=FR.notice({sessionId:s,dismissed:DR.get(s,qj),enabled:v.updateNotice}),ee=d.lastError===null?null:d.configFilePath,te=_k(w,T,[d.lastWarning??``,...b].filter(Boolean).join(`
205
+ `)),ne=AR.sync(s,te===null?null:yk(te));ne!==null&&Z(`warn`,`diagnostic dump failed: ${ne}`);let re=bk(S,te,{fullText:ne===null?{kind:`file`,path:AR.pathFor(s)}:{kind:`unavailable`,reason:ne},failedConfigFile:ee},{width:m,rowCap:h,colorCompatibility:v.colorCompatibility}),E=Date.now()-t,D=wR.getStats(),ie=TR.getStats();return Z(`info`,`render sid=${e.hookData.session_id??`?`} took=${E}ms termCols=${p??`?`} termRows=${c.termRows??`?`} width=${m} git=${D.size}/${D.hits}h/${D.misses}m usage=${ie.size}/${ie.hits}h/${ie.misses}m err=${w?`Y`:`N`} upd=${T.length} warn=${d.lastWarning?`Y`:`N`}`),ZR({ok:!0,output:re+`
206
+ `})}catch(e){throw xR.requestsErrored++,e}}if(e.kind===`click`)return ZR(await az(e.verb,e.value));if(e.kind===`debug`){if(!vR(e.what))return ZR({ok:!1,error:`unknown debug 'what': ${String(e.what)} (have: ${_R.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let t=jR.firstState(),n=t===null?null:{store:t.store,registry:t.registry,config:t.config,compiled:t.compiled,lastRenderBySegment:e.what===`segments`?rz(t.lastRenderCellsBySegment,t.config.globals.charset??`unicode`,t.config.globals.colorCompatibility??`truecolor`):nz};return ZR({ok:!0,debug:oR(e.what,n)})}return ZR({ok:!1,error:`unknown kind`,code:`BAD_REQUEST`,daemonV:3})}function $R(e){let{values:t,tokens:n}=v({args:e.slice(1),options:{config:{type:`string`}},strict:!1,tokens:!0,allowPositionals:!0}),r=[...new Set((n??[]).filter(e=>e.kind===`option`&&e.name!==`config`).map(e=>`--${e.name}`))];return{configFile:lE(t.config),unknownFlagsError:r.length>0?`Unknown flags: ${r.join(`, `)}`:null}}const ez={sessionState:DR,dlog:Z,applyUpdate:()=>FR.act(),doctor:LI(e=>{let t=[e.projectDir,e.cwd,e.configFile??void 0];jR.reload(...t);let n=jR.getOrCreate(...t);return{path:n.configFilePath,error:n.lastError,warning:n.lastWarning,unused:n.state.unused}}),memento:ER,claudeInput:$I(),history:OR,navigation:kR,configFor:e=>jR.getOrCreate(e.projectDir,e.cwd,e.configFile??void 0).state.config,reloadConfig:e=>jR.reload(e.projectDir,e.cwd,e.configFile??void 0)};ez.reloadConfig;const tz={endcaps:`powerline`,colorCompatibility:`truecolor`,wrap:!0,padding:1,charset:go,width:1/0},nz=new Map;function rz(e,t,n){let r=new Map;for(let[i,a]of e)r.set(i,dk(a,{...tz,charset:t,colorCompatibility:n}));return r}const iz={...CR,clock:()=>new Date,history:e=>OR.depth(e)};function az(e,t){let n=QL.get(e);if(!n)return{ok:!1,error:`unknown click verb: ${e}`,code:`BAD_REQUEST`,daemonV:3};try{return n(t,ez),{ok:!0,output:``}}catch(e){let t=e instanceof $?`BAD_REQUEST`:`RENDER_FAILED`;return{ok:!1,error:String(e instanceof Error?e.message:e),code:t,daemonV:3}}}const oz={connectMs:200,budgetMs:500};async function sz(e){let n=e.includes(`--json`),r=await cz();if(r.kind!==`ok`&&(t.stderr.write(`daemon-stats: ${wE(r)}\n`),t.exit(1)),n){t.stdout.write(JSON.stringify(r.value,null,2)+`
207
+ `);return}t.stdout.write(fz(r.value))}function cz(){return vE({kind:`stats`},oz,e=>`stats`in e?e.stats:void 0)}function lz(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function uz(e,t){let n=e+t;return n===0?`n/a`:`${(e/n*100).toFixed(1)}%`}function dz(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 fz(e){let t=[];t.push(`cc-candybar daemon stats`),t.push(``),t.push(`process`),t.push(` pid ${e.pid}`),t.push(` version ${e.version}`),t.push(` protocol ${e.protocolVersion}`),t.push(` startedAt ${e.startedAt}`),t.push(` uptime ${dz(e.uptimeSec)}`),t.push(` rss ${lz(e.rssBytes)}`),t.push(` heapUsed ${lz(e.heapUsedBytes)}`),t.push(` heapTotal ${lz(e.heapTotalBytes)}`),t.push(` external ${lz(e.externalBytes)}`),t.push(` arrayBuffers ${lz(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(``),t.push(`gitCache`),t.push(` size ${e.gitCache.size}`),t.push(` hit rate ${uz(e.gitCache.hits,e.gitCache.misses)} (${e.gitCache.hits} / ${e.gitCache.hits+e.gitCache.misses})`),t.push(` invalidations ${e.gitCache.invalidations}`),t.push(``),t.push(`usageCache`),t.push(` size ${e.usageCache.size}`),t.push(` hit rate ${uz(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(`renderCache`),t.push(` size ${e.renderCache.size}`),t.push(`watchers`),t.push(` active ${e.watchers.active}`),t.push(` opened ${e.watchers.opened}`),t.push(` closed ${e.watchers.closed}`),t.push(` evicted ${e.watchers.evicted}`),t.push(``),t.push(`subprocesses`),t.push(` total ${e.subprocesses.total}`),t.push(` inFlight ${e.subprocesses.inFlight}`),t.push(` lastMinute ${e.subprocesses.lastMinute}`);let n=Object.entries(e.subprocesses.byCategory),r=n.reduce((e,[t])=>Math.max(e,t.length),13);for(let[i,a]of n){let n=e.subprocesses.p50DurationMs[i],o=e.subprocesses.p99DurationMs[i],s=n!==void 0&&o!==void 0?` (p50 ${n}ms · p99 ${o}ms)`:``;t.push(` ${i.padEnd(r)} ${a}${s}`)}return e.nextRestartReason&&(t.push(``),t.push(`nextRestart ${e.nextRestartReason}`)),t.join(`
203
208
  `)+`
204
- `}const tz={connectMs:200,budgetMs:500};async function nz(e,n){let r=n.includes(`--json`),i=await rz(e);if(i.kind!==`ok`&&(t.stderr.write(`${e}: ${vE(i)}\n`),t.exit(1)),r){t.stdout.write(JSON.stringify(i.value,null,2)+`
205
- `);return}t.stdout.write(iz(i.value))}function rz(e){return fE({kind:`debug`,what:e},tz,e=>`debug`in e?e.debug:void 0)}function iz(e){switch(e.what){case`vars`:return az(e.vars);case`segments`:return oz(e.segments);case`config`:return sz(e.config);default:return e}}function az(e){if(e.length===0)return`no variables (DSL not active)
206
- `;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?``:` ${lz(a.ageMs)}`,o=a.lastError?` ✗ ${a.lastError.message}`:``;t.push(` ${a.name.padEnd(n)} ${(a.source??`—`).padEnd(r)} ${a.type.padEnd(i)} ${cz(a.value)}${e}${o}`)}return t.join(`
209
+ `}const pz={connectMs:200,budgetMs:500};async function mz(e,n){let r=n.includes(`--json`),i=await hz(e);if(i.kind!==`ok`&&(t.stderr.write(`${e}: ${wE(i)}\n`),t.exit(1)),r){t.stdout.write(JSON.stringify(i.value,null,2)+`
210
+ `);return}t.stdout.write(gz(i.value))}function hz(e){return vE({kind:`debug`,what:e},pz,e=>`debug`in e?e.debug:void 0)}function gz(e){switch(e.what){case`vars`:return _z(e.vars);case`segments`:return vz(e.segments);case`config`:return yz(e.config);default:return e}}function _z(e){if(e.length===0)return`no variables (DSL not active)
211
+ `;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?``:` ${xz(a.ageMs)}`,o=a.lastError?` ✗ ${a.lastError.message}`:``;t.push(` ${a.name.padEnd(n)} ${(a.source??`—`).padEnd(r)} ${a.type.padEnd(i)} ${bz(a.value)}${e}${o}`)}return t.join(`
207
212
  `)+`
208
- `}function oz(e){if(e.length===0)return`no segments (DSL not active)
213
+ `}function vz(e){if(e.length===0)return`no segments (DSL not active)
209
214
  `;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(`
210
215
  `)+`
211
- `}function sz(e){return e===null?`config: DSL not active
216
+ `}function yz(e){return e===null?`config: DSL not active
212
217
  `:JSON.stringify(e,null,2)+`
213
- `}function cz(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function lz(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function uz(){let e=fz();return e===null?null:r.readFileSync(e,`utf-8`)}function dz(){let e;try{e=uz()}catch(e){t.stderr.write(`schema: cannot read bundled schema: ${e instanceof Error?e.message:String(e)}\n`),t.exit(2)}e===null&&(t.stderr.write("schema: bundled schema not found (expected schema/cc-candybar.schema.json). Run `pnpm gen:schema` from a source checkout.\n"),t.exit(2)),t.stdout.write(e),t.exit(0)}function fz(){let e=c.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let i=c.dirname(c.resolve(n));for(;;){let t=c.join(i,e);if(r.existsSync(t))return t;let n=c.dirname(i);if(n===i)return null;i=n}}function pz(e){let t=e.CC_CANDYBAR_CONFIG??``;return t===``?void 0:t}const mz=5e3;function hz(e){let t=`/home/tester`,n=Math.floor(Date.now()/1e3),r=`test0a1b-2c3d-4e5f-6a7b-8c9d0e1f2a3b`,i={current_dir:`${t}/code/cc-candybar/src`,project_dir:`${t}/code/cc-candybar`,added_dirs:[]};return{hook_event_name:`Status`,session_id:r,version:`1.15.0`,home:t,cwd:`${t}/code/cc-candybar/src`,transcript_path:`${t}/.claude/projects/x/test.jsonl`,model:{id:`claude-opus-4-8`,display_name:`Opus 4.8`},workspace:i,git:{repoName:`cc-candybar`,repoUrl:`https://github.com/promptctl/cc-candybar`,branch:`main`,sha:`abc1234`,ahead:2,behind:1,staged:3,unstaged:2,untracked:1,conflicts:0,upstream:`origin/main`,stash:1,status:`dirty`,operation:`rebase`,timeSinceCommit:780},session:{cost:.39,tokens:241400},today:{cost:12.5,tokens:34e5},context:{totalTokens:48487,contextLeft:24},metrics:{lastResponseTime:8.2,responseTime:4.2,sessionDuration:930,messageCount:8,linesAdded:512,linesRemoved:88},block:{nativeUtilization:63,resetsAt:n+2*3600},weekly:{percentage:21,resetsAt:n+5*86400},cache:{expiresAt:n+900},tmux:{pane:`%0`,session:`work`},host:{name:`tester-box`,user:`tester`,ssh:!0},autocompact:lS(4e5,1e6),...IA(e),history:{undo:1,redo:1,sinceEdit:1},navigation:{back:1},unsaved:1,resettable:Bb(()=>!0),resumeCommand:MA(i,r,void 0),configPath:`${t}/.config/cc-candybar/config.json5`}}function gz(e,t){let n=zT(e,e),r=VT(n);return r!==null&&t.push(r),n.kind===`file`?n.path:null}async function _z(e,n=t.cwd()){let i=[],a=e===void 0?gz(n,i):c.resolve(IT(e));if(e!==void 0&&a!==null){let e;try{e=r.statSync(a,{throwIfNoEntry:!1})}catch(e){return{kind:`unreadable`,path:a,message:e instanceof Error?e.message:String(e)}}if(e!==void 0&&!e.isFile())return{kind:`unreadable`,path:a,message:`not a file`}}let o=UT(n,n);o!==null&&i.push(o);try{return{kind:`clean`,configPath:a,warnings:i,rendered:await bz(a,n,i)}}catch(e){let t=e;return a!==null&&typeof t==`object`&&t&&typeof t.code==`string`&&t.path===a&&typeof t.message==`string`?{kind:`unreadable`,path:a,message:t.message}:(e instanceof xs&&i.push(...e.warnings),{kind:`fatal`,configPath:a,message:e instanceof xs||e instanceof Error?e.message:String(e),warnings:i})}}async function vz(e,t,n){let r=WT(e,iA);n.push(...r.warnings);let i=qT(r,e??`<default>`),a=new GP,o=new jb(a,i.globals.default_empty_value??``,void 0,new iF);try{let e=MP(i,o,{cwd:t});n.push(...e.loadWarnings);let r=await o.settled(mz);return r.length>0&&n.push(`source${r.length===1?``:`s`} still running after ${mz} ms, rendered with fallback values: ${r.join(`, `)}`),{config:i,compiled:e,store:a,registry:o}}catch(e){throw o.dispose(),e}}function yz({config:e,compiled:t,store:n,registry:r},i,a){let o=new Map;return{rendered:LP(e,t,n,r,hz(i),PA(i,a),{onSegmentError:(e,t)=>o.set(`segment "${e}"`,t),onRenderWarning:e=>o.set(`theme rule`,e)},FA(i)),failures:o}}async function bz(e,t,n){let r=await vz(e,t,n),{config:i}=r;try{let e=nM();try{Fj(i),Hk(i)}finally{e()}let t=NA(i,()=>null,()=>!1),n=e=>yz(r,e,200),a=n(t),o=n({...t,presetCustomized:!0}),s=[...[...a.failures].map(([e,t])=>`${e}: ${t}`),...[...o.failures].filter(([e])=>!a.failures.has(e)).map(([e,t])=>`${e}: ${t} (under .preset.customized = true)`)];if(s.length>0)throw Error(`config renders with ${s.length} render error${s.length===1?``:`s`} (the daemon would show them on the bar):\n`+s.map(e=>` ${e}`).join(`
214
- `));return a.rendered}finally{r.registry.dispose()}}function xz(e){return e.map(e=>`warning: ${e}\n`).join(``)}function Sz(e,t=!1){switch(e.kind){case`clean`:return{stdout:`✓ ${e.configPath??`bundled default (no config file found)`}: config OK${e.warnings.length>0?` (${e.warnings.length} warning${e.warnings.length===1?``:`s`})`:``}\n`+(t?`${e.rendered}\n`:``),stderr:xz(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:xz(e.warnings)+`✗ ${e.configPath??`<default>`}\n${e.message}\n`,code:1};case`unreadable`:return{stdout:``,stderr:`check: cannot read ${e.path}: ${e.message}\n`,code:2}}}const Cz=`--render`,wz=`Usage: cc-candybar check [${Cz}] [config-file]\n`;function Tz(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`)),r=t.filter(e=>e!==Cz);return r.length>0?{kind:`usage`,message:`check: unknown option ${r.join(` `)}\n${wz}`}:n.length>1||n[0]===``?{kind:`usage`,message:`check: expected at most one non-empty path\n${wz}`}:{kind:`run`,target:n[0],render:t.includes(Cz)}}async function Ez(e){let n=Tz(e),r=n.kind===`usage`?{stdout:``,stderr:n.message,code:2}:Sz(await _z(n.target??pz(t.env)),n.render);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}const Dz=`${JO}${qO}`;function Oz(e){return`${Dz}⚠ cc-candybar: ${kz(e)}\n`}function kz(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: ${KO(e.message,60)}`;case`render_failed`:return`render failed: ${KO(e.message,60)}`;case`malformed_response`:return`malformed daemon response: ${KO(e.message,60)}`}}function Az(e){switch(e.kind){case`ok`:return{output:e.value,kick:!1,debug:null};case`transient`:return{output:`
215
- `,kick:!0,debug:`daemon unavailable (transient: ${e.cause}: ${e.message}) — kicking daemon`};case`permanent`:return{output:Oz(e),kick:!1,debug:`daemon refused request (permanent: ${e.cause}) — not kicking`}}}function jz(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 Mz=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`];function Nz(e,t,n){return{termCols:jz(e.COLUMNS,n.columns),termRows:jz(e.LINES,n.rows),ssh:Mz.some(t=>(e[t]??``)!==``),tmux:jx(e),configEnv:pz(e),claudeConfigDir:Qx(e,t),mementoEnv:Xe(e,t)}}const Pz=` (fix: click the settings menu (${Gc} by default) › 🧰 tools › 🩺 doctor, then [fix] on the bar)`;function Fz({check:e,verdict:t}){return t.ok?`✓ ${e.label}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:Pz}\n`}function Iz(e,t,n){let r;try{r=kI(e,{tmux:jx(t),claudeConfigDir:Qx(t,n)})}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let i=Px(r);return{stdout:i.map(Fz).join(``),stderr:``,code:+!i.every(e=>e.verdict.ok)}}function Lz(e){e.length>0&&(t.stderr.write(`doctor: takes no arguments
216
- Usage: cc-candybar doctor
217
- `),t.exit(2));let n=Iz(EI(),t.env,t.cwd());t.stdout.write(n.stdout),t.stderr.write(n.stderr),t.exit(n.code)}const Rz=e=>e.some(e=>t.argv.includes(e));function zz(){console.log(Ox)}async function Bz(){try{Rz(Ex.help)&&(zz(),t.exit(0)),Rz(Ex.version)&&(console.log(`cc-candybar ${zD}`),t.exit(0));let e=t.argv[2];if(e===`install`&&(await yO(t.argv.slice(3)),t.exit(0)),e===`install-url-handler`&&(mO(),t.exit(0)),e===`url-handle`){await gO(t.argv[3]);return}if(e===`daemon`){DR();return}if(e===`daemon-stats`&&(await YR(t.argv.slice(3)),t.exit(0)),e===`check`||e===`lint`){await Ez(t.argv.slice(3));return}if(e===`schema`){dz();return}if(e===`doctor`){Lz(t.argv.slice(3));return}oR(e)&&(await nz(e,t.argv.slice(3)),t.exit(0)),t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
218
+ `}function bz(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function xz(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function Sz(){let e=wz();return e===null?null:r.readFileSync(e,`utf-8`)}function Cz(){let e;try{e=Sz()}catch(e){t.stderr.write(`schema: cannot read bundled schema: ${e instanceof Error?e.message:String(e)}\n`),t.exit(2)}e===null&&(t.stderr.write("schema: bundled schema not found (expected schema/cc-candybar.schema.json). Run `pnpm gen:schema` from a source checkout.\n"),t.exit(2)),t.stdout.write(e),t.exit(0)}function wz(){let e=c.join(`schema`,`cc-candybar.schema.json`),n=t.argv[1];if(n===void 0)return null;let i=c.dirname(c.resolve(n));for(;;){let t=c.join(i,e);if(r.existsSync(t))return t;let n=c.dirname(i);if(n===i)return null;i=n}}function Tz(e){let t=e.CC_CANDYBAR_CONFIG??``;return t===``?void 0:t}const Ez=5e3;function Dz(e,t){let n=`/home/tester`,r=Math.floor(Date.now()/1e3),i=`test0a1b-2c3d-4e5f-6a7b-8c9d0e1f2a3b`,a={current_dir:`${n}/code/cc-candybar/src`,project_dir:`${n}/code/cc-candybar`,added_dirs:[]};return{hook_event_name:`Status`,session_id:i,version:`1.15.0`,home:n,cwd:`${n}/code/cc-candybar/src`,transcript_path:`${n}/.claude/projects/x/test.jsonl`,model:{id:`claude-opus-4-8`,display_name:`Opus 4.8`},workspace:a,git:{repoName:`cc-candybar`,repoUrl:`https://github.com/promptctl/cc-candybar`,branch:`main`,sha:`abc1234`,ahead:2,behind:1,staged:3,unstaged:2,untracked:1,conflicts:0,upstream:`origin/main`,stash:1,status:`dirty`,operation:`rebase`,timeSinceCommit:780},session:{cost:.39,tokens:241400},today:{cost:12.5,tokens:34e5},context:{totalTokens:48487,contextLeft:24},metrics:{lastResponseTime:8.2,responseTime:4.2,sessionDuration:930,messageCount:8,linesAdded:512,linesRemoved:88},block:{nativeUtilization:63,resetsAt:r+2*3600},weekly:{percentage:21,resetsAt:r+5*86400},cache:{expiresAt:r+900},tmux:{pane:`%0`,session:`work`},host:{name:`tester-box`,user:`tester`,ssh:!0},autocompact:mS(4e5,1e6),...HA(e),history:{undo:1,redo:1,sinceEdit:1},navigation:{back:1},unsaved:1,resettable:Vb(()=>!0),resumeCommand:RA(a,i,void 0),configPath:t??`${n}/.config/cc-candybar/config.json5`}}function Oz(e,t){let n=WT(e,e),r=KT(n);return r!==null&&t.push(r),n.kind===`file`?n.path:null}async function kz(e,n=t.cwd()){let i=[],a=e===void 0?Oz(n,i):c.resolve(VT(e));if(e!==void 0&&a!==null){let e;try{e=r.statSync(a,{throwIfNoEntry:!1})}catch(e){return{kind:`unreadable`,path:a,message:e instanceof Error?e.message:String(e)}}if(e!==void 0&&!e.isFile())return{kind:`unreadable`,path:a,message:`not a file`}}let o=YT(n,n);o!==null&&i.push(o);try{return{kind:`clean`,configPath:a,warnings:i,rendered:await Mz(a,n,i)}}catch(e){let t=e;return a!==null&&typeof t==`object`&&t&&typeof t.code==`string`&&t.path===a&&typeof t.message==`string`?{kind:`unreadable`,path:a,message:t.message}:(e instanceof xs&&i.push(...e.warnings),{kind:`fatal`,configPath:a,message:e instanceof xs||e instanceof Error?e.message:String(e),warnings:i})}}async function Az(e,t,n){let r=XT(e,uA);n.push(...r.warnings);let i=$T(r,e??`<default>`),a=new tF,o=new Mb(a,i.globals.default_empty_value??``,void 0,new hF);try{let r=RP(i,o,{cwd:t});n.push(...r.loadWarnings);let s=await o.settled(Ez);return s.length>0&&n.push(`source${s.length===1?``:`s`} still running after ${Ez} ms, rendered with fallback values: ${s.join(`, `)}`),{configPath:e,config:i,compiled:r,store:a,registry:o}}catch(e){throw o.dispose(),e}}function jz({configPath:e,config:t,compiled:n,store:r,registry:i},a,o){let s=new Map;return{rendered:UP(t,n,r,i,Dz(a,e),BA(a,o),{onSegmentError:(e,t)=>s.set(`segment "${e}"`,t),onRenderWarning:e=>s.set(`theme rule`,e)},VA(a)),failures:s}}async function Mz(e,t,n){let r=await Az(e,t,n),{config:i}=r;try{let e=cM();try{Vj(i),Jk(i)}finally{e()}let t=O_(null,i.globals.preset,i.presets),n=(e,t)=>{let n=zA(i,t=>t===`preset`?e:null,()=>t),a;try{a=jz(r,n,200)}catch(e){a={failures:new Map([[`render`,e instanceof Error?e.message:String(e)]])}}return{preset:e,customized:t,...a}},a=n(t,!1),o=[a,n(t,!0),...D_(i.presets).filter(e=>e!==t).flatMap(e=>[n(e,!1),n(e,!0)])],s=new Map;for(let{preset:e,customized:t,failures:n}of o)for(let[r,i]of n){let n=`${r}: ${i}`,a=s.get(n)??new Map;a.set(e,(a.get(e)??new Set).add(t)),s.set(n,a)}let c=[...s].map(([e,n])=>n.get(t)?.has(!1)?e:`${e} (under ${[...n].map(([e,n])=>[...e===t?[]:[`preset "${e}"`],...n.has(!1)?[]:[`.preset.customized = true`]].join(`, `)).join(`; `)})`),l=a.rendered;if(c.length>0||l===void 0)throw Error(`config renders with ${c.length} render error${c.length===1?``:`s`} (the daemon would show them on the bar):\n`+c.map(e=>` ${e}`).join(`
219
+ `));return l}finally{r.registry.dispose()}}function Nz(e){return e.map(e=>`warning: ${e}\n`).join(``)}function Pz(e,t=!1){switch(e.kind){case`clean`:return{stdout:`✓ ${e.configPath??`bundled default (no config file found)`}: config OK${e.warnings.length>0?` (${e.warnings.length} warning${e.warnings.length===1?``:`s`})`:``}\n`+(t?`${e.rendered}\n`:``),stderr:Nz(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:Nz(e.warnings)+`✗ ${e.configPath??`<default>`}\n${e.message}\n`,code:1};case`unreadable`:return{stdout:``,stderr:`check: cannot read ${e.path}: ${e.message}\n`,code:2}}}const Fz=`--render`,Iz=`Usage: cc-candybar check [${Fz}] [config-file]\n`;function Lz(e){let t=e.filter(e=>e.startsWith(`--`)),n=e.filter(e=>!e.startsWith(`--`)),r=t.filter(e=>e!==Fz);return r.length>0?{kind:`usage`,message:`check: unknown option ${r.join(` `)}\n${Iz}`}:n.length>1||n[0]===``?{kind:`usage`,message:`check: expected at most one non-empty path\n${Iz}`}:{kind:`run`,target:n[0],render:t.includes(Fz)}}async function Rz(e){let n=Lz(e),r=n.kind===`usage`?{stdout:``,stderr:n.message,code:2}:Pz(await kz(n.target??Tz(t.env)),n.render);t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}const zz=`${ek}${$O}`;function Bz(e){return`${zz}⚠ cc-candybar: ${Vz(e)}\n`}function Vz(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: ${QO(e.message,60)}`;case`render_failed`:return`render failed: ${QO(e.message,60)}`;case`malformed_response`:return`malformed daemon response: ${QO(e.message,60)}`}}function Hz(e){switch(e.kind){case`ok`:return{output:e.value,kick:!1,debug:null};case`transient`:return{output:`
220
+ `,kick:!0,debug:`daemon unavailable (transient: ${e.cause}: ${e.message}) — kicking daemon`};case`permanent`:return{output:Bz(e),kick:!1,debug:`daemon refused request (permanent: ${e.cause}) — not kicking`}}}function Uz(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 Wz=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`];function Gz(e,t,n){return{termCols:Uz(e.COLUMNS,n.columns),termRows:Uz(e.LINES,n.rows),ssh:Wz.some(t=>(e[t]??``)!==``),tmux:Mx(e),configEnv:Tz(e),claudeConfigDir:rS(e,t),mementoEnv:Xe(e,t)}}const Kz=` (fix: click the settings menu (${Gc} by default) › 🧰 tools › 🩺 doctor, then [fix] on the bar)`;function qz({check:e,verdict:t}){return t.ok?`✓ ${e.label}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:Kz}\n`+(t.more??[]).map(e=>` ${e}\n`).join(``)}function Jz(e){let t=cF(e.projectDir,e.cwd,e.configFile??void 0,{sessionState:new hF});return t.state?.registry.dispose(),{path:t.resolvedPath,error:t.error,warning:t.warning,unused:t.state?.unused??[]}}function Yz(e,t,n,r=void 0){let i;try{i=VI(e,{tmux:Mx(t),claudeConfigDir:rS(t,n)},{projectDir:n,cwd:n,configFile:lE(r??Tz(t))??null})}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let a=Rx(i);return{stdout:a.map(qz).join(``),stderr:``,code:+!a.every(e=>e.verdict.ok)}}function Xz(e){(e.length>1||e[0]===``||e[0]?.startsWith(`--`))&&(t.stderr.write(`doctor: expected at most one config file
221
+ Usage: cc-candybar doctor [config-file]
222
+ `),t.exit(2));let n=t.cwd(),r=Yz(LI(Jz),t.env,n,e[0]===void 0?void 0:c.resolve(n,VT(e[0])));t.stdout.write(r.stdout),t.stderr.write(r.stderr),t.exit(r.code)}const Zz=e=>e.some(e=>t.argv.includes(e));function Qz(){console.log(kx)}async function $z(){try{Zz(Dx.help)&&(Qz(),t.exit(0)),Zz(Dx.version)&&(console.log(`cc-candybar ${GD}`),t.exit(0));let e=t.argv[2];if(e===`install`&&(await TO(t.argv.slice(3)),t.exit(0)),e===`install-url-handler`&&(bO(),t.exit(0)),e===`url-handle`){await SO(t.argv[3]);return}if(e===`daemon`){zR();return}if(e===`daemon-stats`&&(await sz(t.argv.slice(3)),t.exit(0)),e===`check`||e===`lint`){await Rz(t.argv.slice(3));return}if(e===`schema`){Cz();return}if(e===`doctor`){Xz(t.argv.slice(3));return}vR(e)&&(await mz(e,t.argv.slice(3)),t.exit(0)),t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
218
223
 
219
224
  cc-candybar is designed to be used as a Claude Code statusLine command.
220
225
  It reads hook data from stdin and outputs formatted statusline.
@@ -230,4 +235,4 @@ Add to ~/.claude/settings.json:
230
235
  Run with --help for more options.
231
236
 
232
237
  To test output manually:
233
- echo '{"session_id":"test-session","workspace":{"project_dir":"/path/to/project"},"model":{"id":"claude-sonnet-4-5","display_name":"Claude"}}' | cc-candybar --style=powerline`),t.exit(1)),O(`Working directory: ${t.cwd()}`),O(`Process args:`,t.argv);let r=await n(t.stdin);O(`Received hook data:`,JSON.stringify(r,null,2)),r||(console.error(`Error: No input data received from stdin`),zz(),t.exit(1));let i=Az(await SE(r,t.argv,t.cwd(),Nz(t.env,t.cwd(),t.stderr)));i.debug!==null&&O(i.debug),i.kick&&HE(),t.stdout.write(i.output),t.exit(0)}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`Error generating statusline:`,n),t.exit(1)}}Bz();export{};
238
+ echo '{"session_id":"test-session","workspace":{"project_dir":"/path/to/project"},"model":{"id":"claude-sonnet-4-5","display_name":"Claude"}}' | cc-candybar --style=powerline`),t.exit(1)),O(`Working directory: ${t.cwd()}`),O(`Process args:`,t.argv);let r=await n(t.stdin);O(`Received hook data:`,JSON.stringify(r,null,2)),r||(console.error(`Error: No input data received from stdin`),Qz(),t.exit(1));let i=Hz(await OE(r,t.argv,t.cwd(),Gz(t.env,t.cwd(),t.stderr)));i.debug!==null&&O(i.debug),i.kick&&JE(),t.stdout.write(i.output),t.exit(0)}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`Error generating statusline:`,n),t.exit(1)}}$z();export{};