@promptctl/cc-candybar 1.61.0 → 1.61.2
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/README.md +35 -18
- package/dist/index.mjs +26 -26
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -118,7 +118,7 @@ Config tooling:
|
|
|
118
118
|
Replace: layout: [["seg1", "seg2"], ["seg3"]]
|
|
119
119
|
With: root: { v: [{ h: ["seg1", "seg2"] }, "seg3"] }
|
|
120
120
|
Single-row example: root: { h: ["seg1", "seg2"] }`,line:G(e.source,[`layout`])}),t.root!==void 0&&(r.root=Dc(e,`root`,t.root)),t.actions!==void 0&&(r.actions=Mg(e,t.actions)),t.looks!==void 0&&(r.looks=b_(e,t.looks)),t.presets!==void 0&&(r.presets=S_(e,t.presets)),t.editGlobals!==void 0&&(r.editGlobals=So(e,`editGlobals`,t.editGlobals)),t.helpers!==void 0&&(r.helpers=C_(e,t.helpers)),Fc(e,r),Rm(e,r),Km(e,r),hs(e,r,fs,`the global settings menu`),r}const bv=new Set([`globals`,`variables`,`segments`,`layout`,`root`,`actions`,`looks`,`presets`,`editGlobals`,`helpers`]);function xv(e){let t=Tv(e.termCols),n=Tv(e.termRows),r=Ev(e.ssh),i=Cv(e.tmux),a=Sv(e.configEnv);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}}}function Sv(e){return typeof e==`string`&&e!==``?rv(e):void 0}function Cv(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 wv=1e4;function Tv(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>wv?wv:t}function Ev(e){return typeof e==`boolean`?e:void 0}var Dv=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function Ov(e){let t=Buffer.from(JSON.stringify(e),`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function kv(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 Dv(`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 Dv(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function Av(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=kv(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(Ov(t))})}async function jv(e,t,n){let r=null;try{r=await Iv(Ne(),t.connectMs);let i=await Av(r,{v:3,...e},t.budgetMs);return Pv(e.kind,i,n)}catch(e){return Fv(e)}finally{r&&r.destroy()}}function Mv(e,t){return typeof e==`string`?e:t}function Nv(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function Pv(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=Mv(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:Nv(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 Fv(e){if(e instanceof Dv||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 Iv(e,t){return new Promise((n,r)=>{let i=g.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 Lv(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 Rv={connectMs:50,budgetMs:150},zv={connectMs:50,budgetMs:200};function Bv(e){let t=e.output;return typeof t==`string`?t:void 0}function Vv(e,t,n,r){return jv({kind:`render`,hookData:e,args:t,cwd:n,...r},Rv,Bv)}function Hv(e,t){return jv({kind:`click`,verb:e,value:t},zv,Bv)}let Uv=null;function Wv(e){if(Uv!==null)return Uv;r.mkdirSync(c.dirname(e),{recursive:!0});try{Uv=r.statSync(e).size}catch{Uv=0}return Uv}function Gv(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{}Uv=0}function Y(e,t){let n=`${new Date().toISOString()} [${e}] ${t}\n`;try{let e=Ge(),t=Wv(e);r.appendFileSync(e,n),Uv=t+Buffer.byteLength(n,`utf8`),Uv>=5242880&&Gv(e)}catch(e){Uv=null;try{process.stderr.write(`${n}cc-candybar: daemon.log unwritable: ${e.message}\n`)}catch{}}}const Kv=`CC_CANDYBAR_RSS_LIMIT_MB`;function qv(e){let t=e[Kv];if(t===void 0)return 512;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${Kv} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function Jv(e){return qv(e)*2}const Yv=1024*1024;function Xv(e){return qv(e)*Yv}function Zv(e){let t=e.rssLimitBytes??512*Yv,n=e.snapshotsKeep??3,r=!1;function i(){if(r)return!0;let i=e.rssBytes();if(i<=t)return!1;r=!0,e.log(`warn`,`RSS ${i} > limit ${t}; writing heap snapshot then shutting down`);try{let t=new Date(e.now()).toISOString().replace(/[:.]/g,`-`),r=c.join(e.snapshotDir,`heap-${t}-${e.pid}.heapsnapshot`),i=e.writeHeapSnapshot(r);e.log(`info`,`heap snapshot written: ${i}`),Qv(e.listSnapshots(),n,e.removeFile)}catch(t){e.log(`warn`,`heap snapshot failed: ${t.message}`)}return e.shutdown(0),!0}function a(){let n=e.rssBytes();return n>t*.75?`rss ${n} approaching limit ${t}`:null}function o(e=6e4){let t=setInterval(()=>{i()},e);return t.unref(),{disarm:()=>clearInterval(t)}}return{checkRss:i,describeNextRestart:a,arm:o}}function Qv(e,t,n){let r=[...e].sort((e,t)=>{let n=e.slice(e.lastIndexOf(`/`)+1);return t.slice(t.lastIndexOf(`/`)+1).localeCompare(n)});for(let e of r.slice(t))try{n(e)}catch{}}function $v(e,t,n={}){let i=Me();return{now:()=>Date.now(),pid:process.pid,snapshotDir:i,log:Y,rssBytes:()=>process.memoryUsage().rss,writeHeapSnapshot:e=>_.writeHeapSnapshot(e),listSnapshots:()=>{try{return r.readdirSync(i).filter(e=>e.startsWith(`heap-`)&&e.endsWith(`.heapsnapshot`)).map(e=>c.join(i,e))}catch{return[]}},removeFile:e=>r.unlinkSync(e),shutdown:t,startedAtMs:e,...n}}function ey(e={}){if(gy()!==null)return;let n=e.spawn??_y,r=py();if(r.kind===`contended`){let e=ny();e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),ty(n));return}if(r.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${r.reason}) — spawning unlocked\n`),ty(n);return}try{ty(n)}finally{hy()}}function ty(e){ly()&&ry(e)}function ny(){try{let e=r.statSync(Ve());return Date.now()-e.mtimeMs}catch{return null}}function ry(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
|
|
121
|
-
`)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function iy(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function ay(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function oy(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 sy(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 cy(){try{r.unlinkSync(Ue())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function ly(){let e=He(),n=Ue(),r=oy(n),i=iy(uy(e),ay(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`),dy(e),sy(n,Math.min(r+1,5)),!0)}function uy(e){try{return Date.now()-r.statSync(e).mtimeMs}catch{return null}}function dy(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 fy=null;function py(){let e=Ve();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 fy={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(!my(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 my(e){try{let t=r.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function hy(){if(!fy)return;let{fd:e,path:t}=fy;fy=null;try{r.closeSync(e)}catch{}try{r.unlinkSync(t)}catch{}}function gy(){try{return r.mkdirSync(Me(),{recursive:!0}),null}catch(e){return`mkdir ${Me()}: ${e.message}`}}function _y(){let e=t.execPath,n=t.argv[1];return n?De({bin:e,args:[`--max-old-space-size=${Jv(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const vy=`cc-candybar`,yy=`dispatch`,by=`set-state`,xy=`step-state`,Sy=`copy`,Cy=`open-vscode`,wy=`toolbar-toggle`,Ty=`show-config-error`,Ey=`show-config-warning`,Dy=`set-config`,Oy=`step-config`,ky=`reset-config`,Ay=`apply-layout-op`,jy=`undo`,My=`redo`,Ny=`apply-update`,Py=`doctor-run`,Fy=`doctor-fix`;function Iy(e){return e.map(encodeURIComponent).join(`/`)}function Ly(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function Ry(e){return`${vy}://${yy}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${Iy(e.args)}`)}`).join(`&`)}`}function zy(e){return new y(e).getAll(`e`).map(By)}function By(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const Vy=`1.61.
|
|
121
|
+
`)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function iy(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function ay(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function oy(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 sy(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 cy(){try{r.unlinkSync(Ue())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function ly(){let e=He(),n=Ue(),r=oy(n),i=iy(uy(e),ay(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`),dy(e),sy(n,Math.min(r+1,5)),!0)}function uy(e){try{return Date.now()-r.statSync(e).mtimeMs}catch{return null}}function dy(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 fy=null;function py(){let e=Ve();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 fy={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(!my(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 my(e){try{let t=r.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function hy(){if(!fy)return;let{fd:e,path:t}=fy;fy=null;try{r.closeSync(e)}catch{}try{r.unlinkSync(t)}catch{}}function gy(){try{return r.mkdirSync(Me(),{recursive:!0}),null}catch(e){return`mkdir ${Me()}: ${e.message}`}}function _y(){let e=t.execPath,n=t.argv[1];return n?De({bin:e,args:[`--max-old-space-size=${Jv(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const vy=`cc-candybar`,yy=`dispatch`,by=`set-state`,xy=`step-state`,Sy=`copy`,Cy=`open-vscode`,wy=`toolbar-toggle`,Ty=`show-config-error`,Ey=`show-config-warning`,Dy=`set-config`,Oy=`step-config`,ky=`reset-config`,Ay=`apply-layout-op`,jy=`undo`,My=`redo`,Ny=`apply-update`,Py=`doctor-run`,Fy=`doctor-fix`;function Iy(e){return e.map(encodeURIComponent).join(`/`)}function Ly(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function Ry(e){return`${vy}://${yy}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${Iy(e.args)}`)}`).join(`&`)}`}function zy(e){return new y(e).getAll(`e`).map(By)}function By(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const Vy=`1.61.2`;function Hy(){return c.join(f.homedir(),`.claude`,`settings.json`)}function X(e){return{kind:`ok`,value:e}}const Z={kind:`absent`};function Q(e){return{kind:`failed`,reason:e}}function Uy(e,t){return e?.kind===`ok`?e.value:t}const Wy=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function Gy(e){let t=Wy.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 Ky(e){return e.join(`.`)}function qy([e,t,n],[r,i,a]){return e-r||t-i||n-a}const Jy=`@promptctl/cc-candybar`;async function Yy(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 Q(`registry responded ${e.status} for ${r}`);let n=await e.json();return typeof n.latest==`string`?Gy(n.latest):Z}catch(e){return Q(e instanceof Error?e.message:String(e))}}function Xy(e,t){let n=Gy(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=qy(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 Zy(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${Ky(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${Ky(t.installed)} is newer than the registry's latest release (${Ky(t.latest)}): an unpublished build.\n`};case`stale`:{let n=Ky(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${Ky(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 Qy=`CCCandybarURLHandler`,$y=[],eb={"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 tb(e){return/^[A-Za-z0-9_./=,:-]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function nb(e,t){return[e,...t].map(tb).join(` `)}function rb(){return c.join(f.homedir(),`Applications`,`${Qy}.app`)}function ib(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function ab(){if(process.platform===`darwin`)return c.join(f.homedir(),`Library`,`Application Support`,`CCCandybar`);let e=process.env.XDG_DATA_HOME??c.join(f.homedir(),`.local`,`share`);return c.join(e,`cc-candybar`)}function ob(){return c.join(ab(),`bin`,`cc-candybar`)}function sb(){return c.join(ab(),`dist`,`index.mjs`)}function cb(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(`
|
|
122
122
|
`)}function lb(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 ub(t){let n=eb[`${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 db(e,t){c.resolve(e)!==c.resolve(t)&&r.copyFileSync(e,t)}function fb(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 ${Jy}@latest install`);return n.toString(`latin1`)===`#!`?`node-shim`:`native`}finally{r.closeSync(t)}}function pb(){let e=lb(process.argv[1]);if(!r.existsSync(e))throw Error(`install: bundled dist not found at ${e}. Reinstall the package.`);let t=ub(e);if(!r.existsSync(t.sourcePath))throw Error(`install: render entry not found at ${t.sourcePath}. Reinstall the package.`);r.mkdirSync(c.dirname(sb()),{recursive:!0}),r.mkdirSync(c.dirname(ob()),{recursive:!0}),db(e,sb()),db(t.sourcePath,ob()),r.chmodSync(ob(),493),r.rmSync(c.join(ab(),`url-handler.mjs`),{force:!0});let n=fb(ob());return process.stdout.write(`Staged cc-candybar v${Vy} runtime at ${ab()}\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:ob(),distPath:sb(),entryKind:n}}function mb(){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>${vy}</string>`,` </array>`,` </dict>`,`</array>`].join(`
|
|
123
123
|
`)}]}function hb(e){let t=rb();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=Ee({bin:`/usr/bin/osacompile`,args:[`-o`,t,`-e`,cb(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 mb())Ee({bin:`/usr/bin/plutil`,args:[`-remove`,e,i],category:`install.plutil`});for(let{key:e,xml:t}of mb()){let n=Ee({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 ${vy}:// with Launch Services\n`);let a=Ee({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(`✓ ${Qy}.app installed and registered.\n`),process.stdout.write(` Test: open '${vy}://hello-world' && pbpaste\n`)}function gb(){ib(),hb(pb().distPath)}function _b(e,t=vy){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:Sy,value:r}:{verb:decodeURIComponent(r.slice(0,i)),value:r.slice(i+1)}}async function vb(e){e||(process.stderr.write(`url-handle: missing URL argument.
|
|
124
124
|
`),process.exit(1));let t;try{t=_b(e)}catch(e){process.stderr.write(`url-handle: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)}let n=await Hv(t.verb,t.value);n.kind===`ok`&&process.exit(0),n.kind===`transient`&&(ey(),process.stderr.write(`url-handle: daemon unavailable (${n.cause}: ${n.message})\n`),process.exit(1)),process.stderr.write(yb(n)+`
|
|
@@ -131,17 +131,17 @@ Config tooling:
|
|
|
131
131
|
`)?r.slice(0,-1):r}return Vr(new jr([...e],n),{colorSystem:t.colorCompatibility})}function ax(e){return Math.min(20,e??20)}const ox={heading:`ERROR`,glyph:`⚠`,colors:Qb},sx={heading:`WARNING`,glyph:`⚠`,colors:$b},cx={heading:`UPDATE`,glyph:`⬆`,colors:$b};function lx(e,t){return{text:qb(e),link:t}}function ux(e,t,n){let[r,...i]=[dx(e,ox,Ty),t,dx(n,sx,Ey)].flat();return r===void 0?null:{channels:[r,...i]}}function dx(e,t,n){let r=Ry([{verb:n,args:[e]}]),[i,...a]=e.split(/\r\n|\r|\n/).map(e=>lx(e,r)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:t,message:e,lines:[i,...a]}]}function fx(e){return e.channels.map(e=>`${e.severity.heading}\n${e.message}\n`).join(`
|
|
132
132
|
`)}function px(e,t,n,r){if(t===null)return e;let i=mx(r),a=t.channels.flatMap(e=>hx(e,i)),o=n.failedConfigFile!==null||a.length>r.rowCap,s=a.slice(0,r.rowCap-Number(o)),c=o?[gx(t,n,a.length-s.length,i)]:[],l=[...s,...c].join(`
|
|
133
133
|
`);return e?`${l}\n${e}`:l}function mx(e){return{style:`plain`,separator:``,width:e.width,wrap:!0,padding:0,charset:`unicode`,colorCompatibility:e.colorCompatibility}}function hx(e,t){let n=new H({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=j(Math.max(2,t.width-1)),i=(e,t)=>new Ar(`${e} `,{style:t,end:``,noWrap:!0});return e.lines.flatMap((a,o)=>ix([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=>Bt(e,r)).map(e=>i(e,t))})],t).split(`
|
|
134
|
-
`))}function gx(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:a,failedConfigFile:o}=t,s=new H({bgcolor:i.bg,color:i.fg}),c=(e,t)=>new Ar(e,{style:t,end:``,noWrap:!0}),l=n>0?[c(`${n} more rows · `,s),a.kind===`file`?c(`open full text`,s.withLink(x(a.path).href)):c(`full text unavailable: ${qb(a.reason)}`,s)]:[],u=o===null?[]:[c(`${l.length>0?` · `:``}open `,s),c(qb(o),s.withLink(x(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=Ar.fromFragments([...d,...p]).truncate(r.width,{overflow:`ellipsis`});return m.noWrap=!0,ix([m],r)}const _x=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function vx(e,t){return t.isSymbolicLink()?Buffer.from(r.readlinkSync(e)):r.readFileSync(e)}function yx(e,t){return r.readdirSync(t).filter(_x).sort().flatMap(n=>{let i=c.join(t,n),a=r.lstatSync(i,{throwIfNoEntry:!1});return a===void 0?[]:a.isDirectory()?yx(e,i):[[c.relative(e,i).split(c.sep).join(`/`),vx(i,a)]]})}function bx(e){let t=C.createHash(`sha256`);for(let[n,r]of yx(e,e))t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}const xx=e=>e.slice(0,7);function Sx(e){return c.dirname(c.dirname(e))}function Cx(){return{version:Vy,digest:`13b802d4fb858b9f683517e403ca68985b893eb84377267abcb8ff16b45788bc`}}function wx(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 Tx(e,t){try{let n=Sx(b(e)),i=c.join(n,`src`);if(!r.existsSync(i))return{kind:`not-source-checkout`};let a=t(),o=bx(i);return o===a.digest?{kind:`current`,root:n,stamp:a}:{kind:`stale`,root:n,source:{version:wx(n),digest:o},running:a}}catch(e){return{kind:`unchecked`,reason:e.message}}}var $=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const Ex=/^-?\d+$/;function Dx(e,t,n){return e===void 0?t:Math.max(t,Math.min(n,e))}function Ox(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 kx(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!Ex.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 Ax(e,t,n){return r=>r?Ex.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 jx(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=>!Ex.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,seed:Dx(r[0].seed,t,i)}}return{kind:`int`}}function Mx(e){return e===`config`?`set-config`:`set-state`}function Nx(e,t,n){return t.kind===`int`?kx(`menu page "${e}"`):t.kind===`range`?Ax(t.min,t.max,`${n} stepper "${e}"`):Ox(t.allowed,`${n} "${e}"`,Mx(n))}function Px(e,t,n){return Nx(e,jx(e,t,n),n)}function Fx(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:jx(e,n,t)}))}function Ix(e,t=`state`){let n=new Map(Object.entries(e).map(([e,t])=>[e,{validator:t,permanent:!0}]));function r(){let e=[];for(let[t,r]of n)r.permanent&&e.push(t);return e}return{register(e,i){if(!e)throw Error(`register: key is required`);if(e.includes(`/`))throw Error(`register: key "${e}" contains "/" — the wire shape splits on "/" so a slash-bearing key cannot be addressed. Use a slash-free key.`);let a=n.get(e);if(a){if(a.permanent)throw Error(`register: key "${e}" is a built-in ${t} key and cannot be re-claimed (built-in keys: ${[...r()].join(`, `)})`);if(a.kind!==i.kind)throw Error(`register: key "${e}" is already a ${a.kind} ${t} key; cannot also register it as ${i.kind}. A ${t} key has one key shape — a menu page index (int) and a button allow-list cannot share a key.`);a.specs.push(i),a.validator=Px(e,a.specs,t)}else{let r=[i];n.set(e,{permanent:!1,kind:i.kind,validator:Px(e,r,t),specs:r})}let o=!0;return()=>{if(!o)return;o=!1;let r=n.get(e);if(!r||r.permanent)return;let a=r.specs.indexOf(i);a>=0&&r.specs.splice(a,1),r.specs.length===0?n.delete(e):r.validator=Px(e,r.specs,t)}},validate(e,r){let i=n.get(e);return i?i.validator(r):{ok:!1,reason:`unknown ${t} key "${e}" (have: ${[...n.keys()].join(`, `)})`}},listKeys(){return[...n.keys()]},listBaselineKeys(){return r()},rangeParamsFor(e){let r=n.get(e);if(!r||r.permanent||r.kind!==`range`)return null;let i=jx(e,r.specs,t);if(i.kind!==`range`)throw Error(`rangeParamsFor: key "${e}" holds range specs but the merge produced a ${i.kind} spec — the entry-kind invariant is broken.`);return{min:i.min,max:i.max,seed:i.seed}}}}const Lx=Ix({},`config`);function Rx(){return Lx.listKeys()}function zx(e,t){return Lx.validate(e,t)}function Bx(e){return Lx.rangeParamsFor(e)}function Vx(e,t,n){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:O_(e.from,n)}}]:`cycle`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:e.cycle}}]:`removeSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[qm({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[qm({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:O_(e.insertSegmentFrom,n).map(t=>qm({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max,seed:Dx(t.get(e.persist),e.min,e.max)}}]:[]}function Hx(e){return Do(e.globals)}function Ux(e){let t=new Set;for(let n of Gx(e)){let e=`persist`in n?n.persist:`reset`in n?n.reset:null;if(e===null)continue;let r=oh(e);r?.scope===`preset-root`&&t.add(r.preset)}return[...t].map(e=>({key:ah(e),spec:{kind:`allow-list`,allowed:[]}}))}function Wx(e){let t=Hx(e),n=new Map([...E_(e),...yh(e)]);return[...Ux(e),...Gx(e).flatMap(e=>Vx(e,t,n))]}function Gx(e){return Object.values(e.actions).flatMap(Tg)}function Kx(e){return Fx(Wx(e),`config`)}function qx(e,t){return Lx.register(e,t)}const Jx=li(),Yx=new Set(Jx),Xx=new Set(pi),Zx=e=>e?Yx.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${Jx.join(`, `)})`}:{ok:!1,reason:`theme name is required`},Qx=e=>e?Xx.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown style "${e}" (have: ${pi.join(`, `)})`}:{ok:!1,reason:`style name is required`},$x=new Set([`1`,`true`]),eS=new Set([`0`,`false`]),tS=Ix({style:Qx,theme:Zx,"toolbar-expanded":e=>$x.has(e)?{ok:!0,value:`1`}:eS.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}});function nS(){return tS.listKeys()}function rS(e,t){return tS.register(e,t)}function iS(e,t){return tS.validate(e,t)}function aS(e){return tS.rangeParamsFor(e)}function oS(e,t,n){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:O_(e.from,n)}}]:`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,seed:Dx(t.get(e.set),e.min,e.max)}}]:[]}function sS(e){let t=new Set(tS.listBaselineKeys());return e.filter(e=>e.spec.kind!==`allow-list`||!t.has(e.key))}function cS(e){let t=new Map,n=/^-?\d+$/;for(let r of Object.values(e.variables)){if(r.kind!==`state`)continue;let e=r.default;e!==void 0&&n.test(e)&&t.set(r.key,parseInt(e,10))}for(let[n,r]of Do(e.globals))t.set(n,r);return t}function lS(e){let t=cS(e),n=E_(e);return sS(Object.values(e.actions).flatMap(Tg).flatMap(e=>oS(e,t,n)))}function uS(e){return Fx(lS(e))}const dS=`update.dismissed`,fS=`updateNotice`;function pS(e){return e.kind===`source`?e.newer.digest:Ky(e.newer)}const mS=e=>`${e.version} [${xx(e.digest)}]`;function hS(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:mS(e.newer),running:mS(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:Ky(e.newer),running:Ky(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${Jy}@${Ky(e.newer)}`,`install`]}}}}const gS={kind:`idle`},_S={kind:`running`};function vS(e,t,n){if(e===null)return[];let r=pS(e);if(!n.enabled||n.dismissed===r)return[];let i=hS(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(`
|
|
134
|
+
`))}function gx(e,t,n,r){let{colors:i}=e.channels[0].severity,{fullText:a,failedConfigFile:o}=t,s=new H({bgcolor:i.bg,color:i.fg}),c=(e,t)=>new Ar(e,{style:t,end:``,noWrap:!0}),l=n>0?[c(`${n} more rows · `,s),a.kind===`file`?c(`open full text`,s.withLink(x(a.path).href)):c(`full text unavailable: ${qb(a.reason)}`,s)]:[],u=o===null?[]:[c(`${l.length>0?` · `:``}open `,s),c(qb(o),s.withLink(x(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=Ar.fromFragments([...d,...p]).truncate(r.width,{overflow:`ellipsis`});return m.noWrap=!0,ix([m],r)}const _x=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function vx(e,t){return t.isSymbolicLink()?Buffer.from(r.readlinkSync(e)):r.readFileSync(e)}function yx(e,t){return r.readdirSync(t).filter(_x).sort().flatMap(n=>{let i=c.join(t,n),a=r.lstatSync(i,{throwIfNoEntry:!1});return a===void 0?[]:a.isDirectory()?yx(e,i):[[c.relative(e,i).split(c.sep).join(`/`),vx(i,a)]]})}function bx(e){let t=C.createHash(`sha256`);for(let[n,r]of yx(e,e))t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}const xx=e=>e.slice(0,7);function Sx(e){return c.dirname(c.dirname(e))}function Cx(){return{version:Vy,digest:`e75baf58dbcde89ab29c419addbff8fbf8d1b68027099846befc2ae4df6464a3`}}function wx(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 Tx(e,t){try{let n=Sx(b(e)),i=c.join(n,`src`);if(!r.existsSync(i))return{kind:`not-source-checkout`};let a=t(),o=bx(i);return o===a.digest?{kind:`current`,root:n,stamp:a}:{kind:`stale`,root:n,source:{version:wx(n),digest:o},running:a}}catch(e){return{kind:`unchecked`,reason:e.message}}}var $=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};const Ex=/^-?\d+$/;function Dx(e,t,n){return e===void 0?t:Math.max(t,Math.min(n,e))}function Ox(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 kx(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!Ex.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 Ax(e,t,n){return r=>r?Ex.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 jx(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=>!Ex.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,seed:Dx(r[0].seed,t,i)}}return{kind:`int`}}function Mx(e){return e===`config`?`set-config`:`set-state`}function Nx(e,t,n){return t.kind===`int`?kx(`menu page "${e}"`):t.kind===`range`?Ax(t.min,t.max,`${n} stepper "${e}"`):Ox(t.allowed,`${n} "${e}"`,Mx(n))}function Px(e,t,n){return Nx(e,jx(e,t,n),n)}function Fx(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:jx(e,n,t)}))}function Ix(e,t=`state`){let n=new Map(Object.entries(e).map(([e,t])=>[e,{validator:t,permanent:!0}]));function r(){let e=[];for(let[t,r]of n)r.permanent&&e.push(t);return e}return{register(e,i){if(!e)throw Error(`register: key is required`);if(e.includes(`/`))throw Error(`register: key "${e}" contains "/" — the wire shape splits on "/" so a slash-bearing key cannot be addressed. Use a slash-free key.`);let a=n.get(e);if(a){if(a.permanent)throw Error(`register: key "${e}" is a built-in ${t} key and cannot be re-claimed (built-in keys: ${[...r()].join(`, `)})`);if(a.kind!==i.kind)throw Error(`register: key "${e}" is already a ${a.kind} ${t} key; cannot also register it as ${i.kind}. A ${t} key has one key shape — a menu page index (int) and a button allow-list cannot share a key.`);a.specs.push(i),a.validator=Px(e,a.specs,t)}else{let r=[i];n.set(e,{permanent:!1,kind:i.kind,validator:Px(e,r,t),specs:r})}let o=!0;return()=>{if(!o)return;o=!1;let r=n.get(e);if(!r||r.permanent)return;let a=r.specs.indexOf(i);a>=0&&r.specs.splice(a,1),r.specs.length===0?n.delete(e):r.validator=Px(e,r.specs,t)}},validate(e,r){let i=n.get(e);return i?i.validator(r):{ok:!1,reason:`unknown ${t} key "${e}" (have: ${[...n.keys()].join(`, `)})`}},listKeys(){return[...n.keys()]},listBaselineKeys(){return r()},rangeParamsFor(e){let r=n.get(e);if(!r||r.permanent||r.kind!==`range`)return null;let i=jx(e,r.specs,t);if(i.kind!==`range`)throw Error(`rangeParamsFor: key "${e}" holds range specs but the merge produced a ${i.kind} spec — the entry-kind invariant is broken.`);return{min:i.min,max:i.max,seed:i.seed}}}}const Lx=Ix({},`config`);function Rx(){return Lx.listKeys()}function zx(e,t){return Lx.validate(e,t)}function Bx(e){return Lx.rangeParamsFor(e)}function Vx(e,t,n){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:O_(e.from,n)}}]:`cycle`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:e.cycle}}]:`removeSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[qm({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[qm({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:O_(e.insertSegmentFrom,n).map(t=>qm({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max,seed:Dx(t.get(e.persist),e.min,e.max)}}]:[]}function Hx(e){return Do(e.globals)}function Ux(e){let t=new Set;for(let n of Gx(e)){let e=`persist`in n?n.persist:`reset`in n?n.reset:null;if(e===null)continue;let r=oh(e);r?.scope===`preset-root`&&t.add(r.preset)}return[...t].map(e=>({key:ah(e),spec:{kind:`allow-list`,allowed:[]}}))}function Wx(e){let t=Hx(e),n=new Map([...E_(e),...yh(e)]);return[...Ux(e),...Gx(e).flatMap(e=>Vx(e,t,n))]}function Gx(e){return Object.values(e.actions).flatMap(Tg)}function Kx(e){return Fx(Wx(e),`config`)}function qx(e,t){return Lx.register(e,t)}const Jx=li(),Yx=new Set(Jx),Xx=new Set(pi),Zx=e=>e?Yx.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown theme "${e}" (have: ${Jx.join(`, `)})`}:{ok:!1,reason:`theme name is required`},Qx=e=>e?Xx.has(e)?{ok:!0,value:e}:{ok:!1,reason:`unknown style "${e}" (have: ${pi.join(`, `)})`}:{ok:!1,reason:`style name is required`},$x=new Set([`1`,`true`]),eS=new Set([`0`,`false`]),tS=Ix({style:Qx,theme:Zx,"toolbar-expanded":e=>$x.has(e)?{ok:!0,value:`1`}:eS.has(e)?{ok:!0,value:``}:{ok:!1,reason:`expected boolean-ish (1, 0, true, false), got "${e}"`}});function nS(){return tS.listKeys()}function rS(e,t){return tS.register(e,t)}function iS(e,t){return tS.validate(e,t)}function aS(e){return tS.rangeParamsFor(e)}function oS(e,t,n){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:O_(e.from,n)}}]:`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,seed:Dx(t.get(e.set),e.min,e.max)}}]:[]}function sS(e){let t=new Set(tS.listBaselineKeys());return e.filter(e=>e.spec.kind!==`allow-list`||!t.has(e.key))}function cS(e){let t=new Map,n=/^-?\d+$/;for(let r of Object.values(e.variables)){if(r.kind!==`state`)continue;let e=r.default;e!==void 0&&n.test(e)&&t.set(r.key,parseInt(e,10))}for(let[n,r]of Do(e.globals))t.set(n,r);return t}function lS(e){let t=cS(e),n=E_(e);return sS(Object.values(e.actions).flatMap(Tg).flatMap(e=>oS(e,t,n)))}function uS(e){return Fx(lS(e))}const dS=`update.dismissed`,fS=`updateNotice`;function pS(e){return e.kind===`source`?e.newer.digest:Ky(e.newer)}const mS=e=>`${e.version} [${xx(e.digest)}]`;function hS(e){switch(e.kind){case`source`:return{headline:`Newer source`,newer:mS(e.newer),running:mS(e.running),act:`rebuild`,busy:`rebuilding…`,command:{bin:`pnpm`,args:[`build`],cwd:e.root}};case`release`:return{headline:`Newer release`,newer:Ky(e.newer),running:Ky(e.running),act:`upgrade`,busy:`upgrading…`,command:{bin:`pnpm`,args:[`dlx`,`${Jy}@${Ky(e.newer)}`,`install`]}}}}const gS={kind:`idle`},_S={kind:`running`};function vS(e,t,n){if(e===null)return[];let r=pS(e);if(!n.enabled||n.dismissed===r)return[];let i=hS(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(`
|
|
135
135
|
`),c=Ry([{verb:Ey,args:[s]}]),l=t.kind===`running`?lx(`[${i.busy}]`,c):lx(`[${i.act}]`,Ry([{verb:Ny,args:[n.sessionId]}]));return[{severity:cx,message:s,lines:[[lx(a,c),l,lx(`[dismiss]`,Ry([{verb:by,args:[n.sessionId,dS,r]}])),lx(`[disable]`,Ry([{verb:Dy,args:[n.sessionId,fS,`false`]}]))],...o.map(e=>[lx(e,c)])]}]}function yS(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 bS(e){switch(e.kind){case`current`:return[`info`,`build: current ${mS(e.stamp)}`];case`stale`:return[`info`,`build: stale — source ${mS(e.source)}, running ${mS(e.running)}`];case`not-source-checkout`:return[`info`,`build: not a source checkout`];case`unchecked`:return[`warn`,`build: unchecked: ${e.reason}`]}}function xS(e){switch(e.kind){case`current`:return[`info`,`release: current ${Ky(e.installed)}`];case`stale`:return[`info`,`release: stale — latest ${Ky(e.latest)}, running ${Ky(e.installed)}`];case`ahead`:return[`info`,`release: ahead — running ${Ky(e.installed)}, latest ${Ky(e.latest)}`];case`unchecked`:return[`warn`,`release: unchecked: ${e.reason}`]}}function SS(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const CS=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e!==``).at(-1);function wS(e){let t=e.exitCode===null?``:` (exit ${e.exitCode})`,n=CS(e.stderr)??e.error??CS(e.stdout)??`no output`;return`${e.reason}${t}: ${n}`}function TS(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=gS,d=null,f=SS(s),p=SS(s),m=()=>yS(c,l);function h(){let e=m(),t=e===null?null:pS(e);(d===null?null:d.identity)!==t&&(d?.dispose(),d=t===null?null:{identity:t,dispose:rS(dS,{kind:`allow-list`,allowed:[t]})})}function g(){c=Tx(t,Cx),f(bS(c)),h()}async function _(){l=Xy(Vy,await Yy(Jy,a,i)),p(xS(l)),h()}return{arm(){qx(fS,{kind:`allow-list`,allowed:[`false`]}),g(),setInterval(g,n).unref(),c.kind===`not-source-checkout`&&(_(),setInterval(()=>void _(),r).unref())},notice:e=>vS(m(),u,e),act(){let e=m();if(e===null)throw new $(`apply-update: nothing newer is known to apply`);let t=hS(e);if(u.kind===`running`)throw new $(`apply-update: already ${t.busy}`);u=_S,s(`info`,`apply-update: ${t.act} — ${t.command.bin} ${t.command.args?.join(` `)??``}`),Te({...t.command,category:`update.apply`,timeoutMs:6e5}).then(n=>{if(n.ok){u=gS,s(`info`,`apply-update: ${t.act} succeeded`),g(),o();return}let r=wS(n);u={kind:`failed`,identity:pS(e),reason:r},s(`error`,`apply-update: ${t.act} failed: ${r}`)})}}}function ES(e,t,n){return t.ok?X(t.stdout):t.reason===`non-zero`&&n===`absent`||t.reason===`non-zero`&&n===t.exitCode?Z:Q(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??DS(t.stderr)].filter(Boolean).join(`, `)}`)}function DS(e){return e.trim().split(`
|
|
136
136
|
`,1)[0]??``}function OS(e,t){if(e.kind!==`ok`)return e;let n=t(e.value);return n===null?Z:X(n)}function kS(e){if(e.kind!==`ok`)return e;let t=e.value.trim();return t?X(t):Z}const AS=/^[A-Za-z]:[\\/]/;function jS(e){let t=e.trim();if(AS.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 MS(e){return jS(e)?.host||null}function NS(e){let t=MS(e);return t?t===`github.com`||t.endsWith(`.github.com`)?`github`:/(^|\.)gitlab\./.test(t)?`gitlab`:null:null}function PS(e){let t=new Map;for(let n of e.split(`
|
|
137
137
|
`)){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 FS(e){return e.urls.find(e=>BS(e)!==null)??e.urls[0]??null}function IS(e){return e.find(e=>e.name===`origin`)??e[0]??null}function LS(e){let t=IS(e);return t?FS(t):null}function RS(e){let t=IS(e);return t?t.urls.find(e=>NS(e)!==null)??FS(t):null}function zS(e){let t=(jS(e)?.path??e.replace(/[\\/]+$/,``)).split(`/`);return(t[t.length-1]??``).replace(/\.git$/,``)||null}function BS(e){let t=jS(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 VS(e){let t=LS(e);return t===null?null:BS(t)}function HS(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)?Z:Q(`${e}: ${[t.reason,t.exitCode==null?null:`exit ${t.exitCode}`,t.error??DS(t.stderr)].filter(Boolean).join(`, `)}`)}function US(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function WS(e){let t=`detached`,n=Z,r=Z,i=Z,a=0,o=0,s=0,c=0;for(let l of e.split(`
|
|
138
138
|
`)){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)`?Z:X(t.slice(0,7))}else if(e.startsWith(`branch.head `)){let n=e.slice(12).trim();t=n===`(detached)`?`detached`:n}else if(e.startsWith(`branch.upstream `))r=X(e.slice(16).trim());else if(e.startsWith(`branch.ab `)){let t=e.slice(10).trim().match(/^\+(\d+)\s+-(\d+)$/);t&&(i=X({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,sha:n,upstream:r,workingTree:{staged:a,unstaged:o,untracked:s,conflicts:c}}}function GS(e){let t;try{t=JSON.parse(e)}catch(e){return Q(`gh pr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`)}if(!US(t))return Q(`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`?Q(`gh pr view: missing number/state/url`):r.toUpperCase()===`OPEN`?X({number:n,state:r,url:i}):Z}function KS(e){let t;try{t=JSON.parse(e)}catch(e){return Q(`glab mr view: unparseable JSON (${e instanceof Error?e.message:String(e)})`)}if(!US(t))return Q(`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`?Q(`glab mr view: missing iid/state/web_url`):r.toLowerCase()===`opened`?X({number:n,state:r,url:i}):Z}var qS=class{isGitRepo(e){try{return r.existsSync(c.join(e,`.git`))}catch{return!1}}async execGitAsync(e,t){return Te({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)?X(e):t&&this.isGitRepo(t)?X(t):this.isGitRepo(e)?X(e):this.findGitRoot(e)}async findGitRoot(e){return kS(ES(`git rev-parse --show-toplevel`,await this.execGitAsync([`rev-parse`,`--show-toplevel`],{cwd:e,timeout:2e3}),`absent`))}async getGitInfo(e,t={},n){try{return await this.computeGitInfo(e,t,n)}catch(e){return Q(`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=a.value.sha),t.showUpstream&&(o.upstream=a.value.upstream),t.showTag&&(o.tag=await this.getNearestTagAsync(r)),t.showTimeSinceCommit&&(o.timeSinceCommit=await this.getTimeSinceLastCommitAsync(r));let[s,c]=await Promise.all([t.showStashCount?this.getStashCountAsync(r):void 0,t.showRepoName||t.showRepoUrl?this.getRemotesAsync(r):void 0]);return s!==void 0&&(o.stashCount=s),c!==void 0&&t.showRepoName&&(o.repoName=OS(c,e=>this.repoNameFrom(e,r)),o.isWorktree=i),c!==void 0&&t.showRepoUrl&&(o.repoUrl=OS(c,VS)),t.showOperation&&(o.operation=this.getOngoingOperation(r)),X(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`))?X(`MERGE`):r.existsSync(c.join(t,`CHERRY_PICK_HEAD`))?X(`CHERRY-PICK`):r.existsSync(c.join(t,`REVERT_HEAD`))?X(`REVERT`):r.existsSync(c.join(t,`BISECT_LOG`))?X(`BISECT`):r.existsSync(c.join(t,`rebase-merge`))||r.existsSync(c.join(t,`rebase-apply`))?X(`REBASE`):Z}catch(e){return Q(`git operation probe: ${e instanceof Error?e.message:String(e)}`)}}async getNearestTagAsync(e){return kS(ES(`git describe --tags`,await this.execGitAsync([`describe`,`--tags`,`--abbrev=0`],{cwd:e,timeout:2e3}),`absent`))}async getTimeSinceLastCommitAsync(e){let t=kS(ES(`git log -1`,await this.execGitAsync([`log`,`-1`,`--format=%ct`],{cwd:e,timeout:2e3}),`absent`));if(t.kind!==`ok`)return t;let n=parseInt(t.value)*1e3;return Number.isNaN(n)?Q(`git log -1: unparseable timestamp "${t.value}"`):X(Math.floor((Date.now()-n)/1e3))}async getStashCountAsync(e){let t=ES(`git stash list`,await this.execGitAsync([`stash`,`list`],{cwd:e,timeout:2e3}),`failed`);if(t.kind!==`ok`)return t;let n=t.value.trim();return X(n?n.split(`
|
|
139
|
-
`).length:0)}async getRemotesAsync(e){let t=ES(`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:X(t.kind===`ok`?PS(t.value):[])}repoNameFrom(e,t){let n=LS(e);return(n===null?null:zS(n))??c.basename(t)}async getRepoRemoteUrl(e){let t=await this.getRemotesAsync(e);if(t.kind!==`ok`)return t;let n=RS(t.value);return n===null?Z:X(n)}async execForgeAsync(e,t,n){return Te({bin:e,args:[...t],cwd:n.cwd,env:{...process.env},timeoutMs:n.timeout,category:`forge`})}async resolvePullRequest(e,t){let n=NS(t);return n===`github`?HS(`gh pr view`,await this.execForgeAsync(`gh`,[`pr`,`view`,`--json`,`number,state,url`],{cwd:e,timeout:5e3}),/no (open )?pull requests? found/i,GS):n===`gitlab`?HS(`glab mr view`,await this.execForgeAsync(`glab`,[`mr`,`view`,`--output`,`json`],{cwd:e,timeout:5e3}),/no (open )?merge requests? (found|available)/i,KS):Z}isWorktree(e){try{let t=c.join(e,`.git`);return!!(r.existsSync(t)&&r.statSync(t).isFile())}catch{return!1}}async getCoreAsync(e){D(`[GIT-EXEC] Running git status --porcelain=v2 in ${e}`);let t=ES(`git status --porcelain=v2 --branch`,await this.execGitAsync([`status`,`--porcelain=v2`,`--branch`],{cwd:e,timeout:2e3}),`failed`);return t.kind===`ok`?X(WS(t.value)):t}};const JS=(e,t)=>D(t);var YS=class{slots=new Map;maxWatchers;counters;logger;closed=!1;constructor(e={}){this.maxWatchers=e.maxWatchers??128,this.counters=e.counters,this.logger=e.logger??JS}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()}};const XS=(e,t)=>D(t),ZS={showSha:!0,showStashCount:!0};function QS(e){let t=Object.keys(e).sort(),n={};for(let r of t)n[r]=e[r];return JSON.stringify(n)}function $S(e){let t=t=>{try{return r.statSync(c.join(e,t)).mtimeMs}catch{return 0}};return{head:t(`HEAD`),index:t(`index`)}}function eC(e,t){return e.head!==t.head||e.index!==t.index}function tC(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 nC=class extends qS{entries=new Map;subscribersByRepo=new Map;fetchInFlight=new Map;prCache=new Map;prFetchInFlight=new Map;refreshing=new Set;refreshAgain=new Set;hits=0;misses=0;invalidations=0;inner;ttlMs;maxEntries;watchers;ownsWatchers;logger;sanityTimer=null;constructor(e={}){super(),this.inner=e.inner??new qS,this.ttlMs=e.ttlMs??3e4,this.maxEntries=e.maxEntries??64,this.logger=e.logger??XS,e.watchers?(this.watchers=e.watchers,this.ownsWatchers=!1):(this.watchers=new YS({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()}}async getGitInfo(e,t={},n){let r=await this.inner.resolveEffectiveGitDir(e,n);return r.kind===`ok`?this.getGitInfoForRoot(r.value,t):r}getGitInfoForRoot(e,t){let n=`${e}|${QS(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(X(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=$S(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}`,tC(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 Z;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(async()=>{let i=await this.inner.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}`,tC(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,{...ZS});n||this.safeInvoke(t,this.deliverable(s,a))})(),()=>{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){if(this.refreshing.has(e)){this.refreshAgain.add(e);return}let t=this.subscribersByRepo.get(e);!t||t.callbacks.size===0||(this.refreshing.add(e),this.doRefreshLoop(e))}async doRefreshLoop(e){try{do{this.refreshAgain.delete(e);let t=this.subscribersByRepo.get(e);if(!t||t.callbacks.size===0)return;let n=await this.getGitInfoForRoot(e,{...ZS}),r=this.deliverable(n,e),i=this.subscribersByRepo.get(e);if(!i||i.callbacks.size===0)return;for(let e of[...i.callbacks])i.callbacks.has(e)&&this.safeInvoke(e,r)}while(this.refreshAgain.has(e))}finally{this.refreshing.delete(e),this.refreshAgain.delete(e)}}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=$S(this.inner.resolveGitDir(t.repoRoot)),e.set(t.repoRoot,n)),eC(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.refreshing.clear(),this.refreshAgain.clear(),this.fetchInFlight.clear(),this.prCache.clear(),this.prFetchInFlight.clear(),this.ownsWatchers&&this.watchers.closeAll()}},rC=class{static CACHE_DIR=O();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 D(`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`?(D(`Removing stale lock file ${e} for dead process ${i}`),r.unlinkSync(t),!1):(D(`Error checking process ${i} for lock ${e}:`,n),!0)}}catch(t){return D(`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`}),D(`Lock acquired for ${e}`),!0}catch(e){if(e.code===`EEXIST`)await ne(50);else throw e}return D(`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),D(`Lock released for ${e}`)}catch(t){t.code!==`ENOENT`&&D(`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){D(`Failed to create cache directories:`,e)}}static createProjectHash(e){return ee(`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)){D(`Cache for ${e} is locked, waiting...`),await ne(75);continue}try{let i=await r.promises.readFile(n,`utf-8`),a=JSON.parse(i);return!t||a.timestamp>=t?(D(`[CACHE-HIT] ${e} disk cache: found`),this.deserializeDates(a.data)):(D(`${e} cache outdated: cache=${a.timestamp}, latest=${t}`),null)}catch(t){if(t.code===`ENOENT`)return D(`No shared ${e} usage cache found`),null;D(`Attempt ${a+1} failed to read ${e} cache: ${t.message}. Retrying...`),await ne(75)}}return D(`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)){D(`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`),D(`[CACHE-SET] ${e} disk cache stored`)}catch(t){D(`Failed to save ${e} usage cache:`,t)}finally{await this.releaseLock(i)}}};const iC={"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 aC=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 rC.getUsageCache(`pricing`,e)}static async saveDiskCache(e){await rC.setUsageCache(`pricing`,e)}static async fetchPricingData(){return new Promise(e=>{let t=new v(this.GITHUB_PRICING_URL),n=te({hostname:t.hostname,path:t.pathname,headers:{"User-Agent":`cc-candybar`,"Cache-Control":`no-cache`},timeout:5e3},t=>{if(t.statusCode!==200){D(`HTTP ${t.statusCode}: ${t.statusMessage}`),e(null);return}let r=``,i=0;t.on(`data`,t=>{if(i+=t.length,i>1048576){D(`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)?(D(`Fetched fresh pricing from GitHub for ${Object.keys(i).length} models`),D(`Pricing last updated: ${n?.updated||`unknown`}`),e(i)):(D(`Invalid pricing data structure`),e(null))}catch(t){D(`Failed to parse JSON:`,t),e(null)}}),t.on(`error`,t=>{D(`Response error:`,t),e(null)})});n.on(`error`,t=>{D(`Request error:`,t),e(null)}),n.on(`timeout`,()=>{D(`Request timeout`),n.destroy(),e(null)}),n.end()})}static async getCurrentPricing(){if(this.executionCache!==null)return D(`[CACHE-HIT] Pricing execution cache: ${Object.keys(this.executionCache).length} models`),this.executionCache;let e=await this.loadDiskCache();if(e)return D(`[CACHE-HIT] Pricing disk cache: ${Object.keys(e).length} models`),this.executionCache=e,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(e).length} models`),e;let t=await this.fetchPricingData();return t?(await this.saveDiskCache(t),D(`[CACHE-SET] Pricing disk cache stored: ${Object.keys(t).length} models`),this.executionCache=t,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(t).length} models`),t):(D(`[CACHE-FALLBACK] Using offline pricing data: ${Object.keys(iC).length} models`),this.executionCache=iC,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(iC).length} models`),iC)}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 D(`[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),D(`[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`}};function oC(e){if(!e)return 0;try{return o(e).mtimeMs}catch{return 0}}const sC=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 cC(e){return((...t)=>sC.run(()=>e(...t)))}const lC=cC(ie),uC=cC(w),dC=cC(T);async function fC(e,t){return sC.run(async()=>{let n=null;try{n=await re(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 X({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 X({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`?Z:Q(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{D(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}async function pC(e,t){return sC.run(async()=>{let n=null;try{n=await re(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 X({buf:o===a.length?a:a.subarray(0,o),fromStart:i===0})}catch(t){return t.code===`ENOENT`?Z:Q(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{D(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}function mC(){let e=[],t=process.env.CLAUDE_CONFIG_DIR;if(t&&t.split(`,`).forEach(t=>{let n=t.trim();a(n)&&e.push(n)}),e.length===0){let t=p(),n=d(t,`.config`,`claude`),r=d(t,`.claude`);a(n)&&e.push(n),a(r)&&e.push(r)}return e}async function hC(e){let t=[];for(let n of e){let e=d(n,`projects`);if(a(e))try{let n=await lC(e,{withFileTypes:!0});for(let r of n)if(r.isDirectory()){let n=d(e,r.name);t.push(n)}}catch(t){D(`Failed to read projects directory ${e}:`,t)}}return t}async function gC(e,t,n){let r=[],i=d(t,e,`subagents`);try{let t=(await lC(i)).filter(e=>e.startsWith(`agent-`)&&e.endsWith(`.jsonl`));for(let a of t){let t=d(i,a);if(n?.has(t)){r.push(t);continue}try{let n=(await uC(t,`utf-8`)).split(`
|
|
140
|
-
`)[0];n&&JSON.parse(n).sessionId===e&&r.push(t)}catch{D(`Failed to check agent file ${t}`)}}}catch(e){D(`Failed to read subagents directory ${i}:`,e)}return r}const
|
|
141
|
-
`))if(n.trim())try{let e=
|
|
142
|
-
`),r=+!t;for(let e=n.length-1;e>=r;e--){let t=n[e];if(!t||!FC.test(t))continue;let r=IC(t);if(r!=null)return r}return null}function BC(e,t,n){let r=$m(t(`preset`),e.globals.preset,e.presets),i=nh(e,r),a=t(`edit.mode`)===`open`?e.editGlobals:{};return{preset:r,presetCustomized:n(r),theme:si(a.palette,t(`theme`),i.palette),look:di(a.look,t(`look`),i.look,e.looks),style:hi(a.style,t(`style`),i.style),separator:a.default_separator??i.default_separator,autoWrap:wi(a.autoWrap,t(`autoWrap`),i.autoWrap),padding:Ti(a.padding,t(`padding`),i.padding),charset:a.charset??i.charset??`unicode`,updateNotice:a.updateNotice??i.updateNotice??!0,colorCompatibility:a.colorCompatibility??i.colorCompatibility??`truecolor`}}const VC=10*1e3;function HC(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 UC(e,t){if(!(t<60))return e*3600/t}function WC(e,t,n,r){let i=r-t;if(i<50||i>VC)return;let a=n-e;if(!(a<=0))return a*1e3/i}function GC(e){let{prev:t,cur:n}=e;if(t===void 0)return;let r=WC(t.input,t.atMs,n.input,n.atMs),i=WC(t.output,t.atMs,n.output,n.atMs),a=WC(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 KC(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>VC)continue;let o=WC(r.total,r.atMs,i.total,i.atMs);n.push(o??0)}if(n.length!==0)return n.join(`,`)}function qC(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}function JC(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`,()=>qC(f.hostname())),i=n(`user`,()=>f.userInfo().username);return{host:{...r!==void 0&&{name:r},...i!==void 0&&{user:i},...e.ssh!==void 0&&{ssh:e.ssh}},failures:t}}function YC(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,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}`,i);let n=[],r=new Set;for(let t of va(oo(e.root))){if(t.when)for(let e of M_(t.when))n.push(e);if(t.kind!==`segment`)continue;let r=e.segments[t.name];if(r){for(let e of[r.template,r.when,r.bg,r.fg])if(e)for(let t of M_(e))n.push(t)}}let i=new Set;for(;n.length>0;){let e=n.pop();for(let a of XC(t,e)){if(r.has(a))continue;r.add(a);let e=t.get(a);if(e){if(e.kind===`input`)i.add(e.path);else if(e.kind===`template`)for(let t of M_(e.template))n.push(t)}}}return i}function XC(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 ZC(e,t){for(let n of e)if(n===t||n.startsWith(t+`.`))return!0;return!1}function QC(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 $C(e,t,n,r,i,a){let o=e=>ZC(r,e),s=(t.clock??(()=>new Date))().getTime(),c=(e,t,n)=>t?n().catch(t=>Q(`${e}: ${String(t)}`)):Promise.resolve(Z),[l,u,d,f,p,m,h,g]=await Promise.all([c(`git`,o(`git`),()=>t.gitProvider.getGitInfo(n??e.workspace?.current_dir,QC(r),e.workspace?.project_dir)),c(`session`,o(`session.cost`)||o(`session.tokens`)||o(`burn`),()=>t.usageStore.getUsageInfo(e.session_id,e)),c(`today`,o(`today`),()=>t.usageStore.getTodayInfo(e)),c(`context`,o(`context`),()=>t.contextProvider.getContextInfo(e)),c(`metrics`,o(`metrics`)||o(`burn`),()=>t.metricsProvider.getMetricsInfo(e.session_id,e)),c(`tmux`,o(`tmux`),()=>t.tmuxService.getSessionId()),c(`cache`,o(`cache`),()=>LC(e.transcript_path)),c(`speed`,o(`speed`),()=>t.usageStore.observeSpeed(e.session_id,e.transcript_path,s))]),_=[],v=e=>{if(e.kind===`failed`){_.push(e.reason);return}return e.kind===`ok`?e.value:void 0},y=nw(l);_.push(...y.failures);let b=JC(a);_.push(...b.failures);let x=v(u),S=v(d),C=v(f),ee=v(p),te=v(m),ne=v(h);for(let e of _)t.log(`warn`,`provider fetch failed: ${e}`);let re=e.rate_limits?.five_hour,w=e.rate_limits?.seven_day,ie=re?HC(re.used_percentage,re.resets_at,18e6,s):void 0,T=w?HC(w.used_percentage,w.resets_at,6048e5,s):void 0,E=x?.session.cost,ae=ee?.sessionDuration,oe=o(`burn`)&&E!=null&&ae!=null?UC(E,ae):void 0,se=v(g),ce=se===void 0?void 0:GC(se),le=se===void 0?void 0:KC(se),ue=ce!==void 0||le!==void 0?{...ce,...le!==void 0&&{history:le}}:void 0,de=tw(process.env.HOME??process.env.USERPROFILE),fe=e.workspace?{...e.workspace,current_dir:tw(e.workspace.current_dir)??``,project_dir:tw(e.workspace.project_dir)??``}:e.workspace,pe=x===void 0?void 0:ew({cost:x.session.cost,tokens:x.session.tokens}),me=S===void 0?void 0:{cost:S.cost,tokens:S.tokens},he=ee===void 0?void 0:ew({lastResponseTime:ee.lastResponseTime,responseTime:ee.responseTime,sessionDuration:ee.sessionDuration,messageCount:ee.messageCount,linesAdded:ee.linesAdded,linesRemoved:ee.linesRemoved});return{...e,...fe!==void 0&&{workspace:fe},...de!==void 0&&{home:de},...y.git!==void 0&&{git:y.git},...te!==void 0&&{tmux:{session:te}},host:b.host,theme:{effective:i.theme},look:{effective:i.look},preset:{effective:i.preset,customized:i.presetCustomized},style:{effective:i.style},charset:{effective:i.charset},colorCompatibility:{effective:i.colorCompatibility},autoWrap:{effective:i.autoWrap},padding:{effective:i.padding},...pe!==void 0&&{session:pe},...me!==void 0&&{today:me},...oe!==void 0&&{burn:{costPerHour:oe}},...ue!==void 0&&{speed:ue},...o(`block`)&&re!==void 0&&{block:{nativeUtilization:re.used_percentage,resetsAt:re.resets_at,...ie!==void 0&&{etaMinutes:ie}}},...w!==void 0&&{weekly:{percentage:w.used_percentage,resetsAt:w.resets_at,...T!==void 0&&{etaMinutes:T}}},...ne!==void 0&&{cache:{expiresAt:ne}},...C!==void 0&&{context:{totalTokens:C.totalTokens,contextLeft:C.contextLeftPercentage}},...he!==void 0&&{metrics:he}}}function ew(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 tw(e){return e===void 0||e.length===0||c.sep!==`\\`?e:e.replace(/\\/g,`/`)}function nw(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 rw=`trimPrefix "/" (trimPrefix .project_dir .current_dir)`,iw=`{{ \$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 (${rw}) (basename .project_dir) (ne (${rw}) "") }}{{ end }}{{ end }}{{ abbreviatePath \$dir }}`,aw={branch:`primary`,staged:`success`,unstaged:`warning`,untracked:`accent`,conflicts:`error`,ahead:`success`,behind:`warning`,stash:`accent`},ow=(e,t)=>`{{ fg (color "${aw[e]}") ${t} }}`,sw=`{{ readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3 }}`,cw=`{{ if or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0) }} ({{ \$first := true }}{{ if gt .git.staged 0 }}${ow(`staged`,`(printf "+%v" .git.staged)`)}{{ $first = false }}{{ end }}{{ if gt .git.unstaged 0 }}{{ if not $first }} {{ end }}${ow(`unstaged`,`(printf "~%v" .git.unstaged)`)}{{ $first = false }}{{ end }}{{ if gt .git.untracked 0 }}{{ if not $first }} {{ end }}${ow(`untracked`,`(printf "?%v" .git.untracked)`)}{{ $first = false }}{{ end }}{{ if gt .git.conflicts 0 }}{{ if not $first }} {{ end }}${ow(`conflicts`,`(printf "!%v" .git.conflicts)`)}{{ $first = false }}{{ end }}){{ end }}`,lw=`{{ if ne .git.repoName "" }}{{ .git.repoName }} {{ end }}⎇ ${ow(`branch`,`.git.branch`)}{{ if .git.sha }} ♯ {{ .git.sha }}{{ end }}{{ if or (gt .git.ahead 0) (gt .git.behind 0) }} {{ if gt .git.ahead 0 }}${ow(`ahead`,`(printf "↑%v" .git.ahead)`)}{{ end }}{{ if gt .git.behind 0 }}${ow(`behind`,`(printf "↓%v" .git.behind)`)}{{ end }}{{ end }}`+cw+`{{ if .git.upstream }} →{{ .git.upstream }}{{ end }}{{ if gt .git.stash 0 }} ${ow(`stash`,`(printf "⧇ %v" .git.stash)`)}{{ end }} {{ if eq .git.status "conflicts" }}{{ fg (color "error") "⚠" }}{{ else }}{{ if eq .git.status "dirty" }}{{ fg (color "warning") "●" }}{{ else }}{{ fg (color "success") "✓" }}{{ end }}{{ end }}`,uw={globals:{palette:`tokyo-night`},variables:{current_dir:{kind:`input`,path:`workspace.current_dir`,default:`?`},project_dir:{kind:`input`,path:`workspace.project_dir`,default:``},transcript_path:{kind:`input`,path:`transcript_path`,default:``},"model.display_name":{kind:`input`,path:`model.display_name`,default:``},"session.id":{kind:`input`,path:`session_id`,default:``},version:{kind:`input`,path:`version`,default:``},"theme.effective":{kind:`input`,path:`theme.effective`,default:``},"look.effective":{kind:`input`,path:`look.effective`,default:``},"preset.effective":{kind:`input`,path:`preset.effective`,default:``},"preset.customized":{kind:`input`,path:`preset.customized`,type:`boolean`,default:!1},"style.effective":{kind:`input`,path:`style.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},"term.cols":{kind:`input`,path:`term.cols`,type:`number`,default:80},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.repoUrl":{kind:`input`,path:`git.repoUrl`,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.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},"session.budget.amount":{kind:`literal`,value:0},"session.budget.warningThreshold":{kind:`literal`,value:80},"today.cost":{kind:`input`,path:`today.cost`,type:`number`,default:0},"today.tokens":{kind:`input`,path:`today.tokens`,type:`number`,default:0},"today.budget.amount":{kind:`literal`,value:50},"today.budget.warningThreshold":{kind:`literal`,value:80},"block.nativeUtilization":{kind:`input`,path:`block.nativeUtilization`,type:`number`,default:0},"block.resetsAt":{kind:`input`,path:`block.resetsAt`,type:`number`,default:0},"block.budget.warningThreshold":{kind:`literal`,value:80},"block.budget.heatThreshold":{kind:`literal`,value:50},"weekly.percentage":{kind:`input`,path:`weekly.percentage`,type:`number`,default:0},"weekly.resetsAt":{kind:`input`,path:`weekly.resetsAt`,type:`number`,default:0},"weekly.budget.warningThreshold":{kind:`literal`,value:80},"weekly.budget.heatThreshold":{kind:`literal`,value:50},"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},"burn.eta.warnMinutes":{kind:`literal`,value:60},"burn.eta.errorMinutes":{kind:`literal`,value:30},"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},"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}},segments:{directory:{template:iw,fg:`foreground`},model:{template:`✱ {{ formatModelName .model.display_name }}`,fg:`foreground`,when:`{{ ne .model.display_name "" }}`},sessionId:{template:`⌗{{ trunc 8 .session.id }}`,fg:`foreground`,when:`{{ ne .session.id "" }}`},version:{template:`◈ v{{ .version }}`,fg:`foreground`,when:`{{ ne .version "" }}`},tmux:{template:`tmux:{{ .tmux.session | default "none" }}`,fg:`foreground`,when:`{{ ne .tmux.session "" }}`},host:{template:`⇄ {{ .host.user | default "?" }}@{{ .host.name | default "?" }}`,bg:`warning`,fg:`{{ contrastOn (bgOf) }}`,when:`{{ .host.ssh }}`},git:{template:lw,fg:sw,when:`{{ ne .git.branch "" }}`},gitaculous:{template:`(git){{ if ne .git.repoName "" }} {{ .git.repoName }}{{ end }}{{ if ne .git.operation "" }} [{{ .git.operation }}]{{ end }}{{ if ne .git.sha "" }} {{ .git.sha }}{{ end }}{{ if or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0) }} {{ if gt .git.staged 0 }}${ow(`staged`,`"S"`)}{{ end }}{{ if gt .git.unstaged 0 }}${ow(`unstaged`,`"U"`)}{{ end }}{{ if gt .git.untracked 0 }}${ow(`untracked`,`"?"`)}{{ end }}{{ if gt .git.conflicts 0 }}${ow(`conflicts`,`(printf "!%v" .git.conflicts)`)}{{ end }}{{ end }} ⎇ ${ow(`branch`,`.git.branch`)}{{ if ne .git.upstream "" }} [{{ .git.upstream }}{{ if or (gt .git.ahead 0) (gt .git.behind 0) }} {{ if gt .git.ahead 0 }}${ow(`ahead`,`(printf "+%v" .git.ahead)`)}{{ end }}{{ if and (gt .git.ahead 0) (gt .git.behind 0) }}/{{ end }}{{ if gt .git.behind 0 }}${ow(`behind`,`(printf "-%v" .git.behind)`)}{{ end }}{{ end }}]{{ end }}{{ if gt .git.stash 0 }} ${ow(`stash`,`(printf "(%v stashed)" .git.stash)`)}{{ end }}{{ if gt .git.timeSinceCommit 0 }} ◷ {{ template "formatTimeSince" .git.timeSinceCommit }}{{ end }}`,fg:sw,when:`{{ ne .git.branch "" }}`},gitPr:{template:`{{ if ne .git.prUrl "" }}{{ link .git.prUrl (printf "⇆ #%v" .git.prNumber) }}{{ else }}⚠ PR{{ end }}`,fg:`foreground`,when:`{{ or (ne .git.prUrl "") (ne .git.prError "") }}`},toolbar:{template:`{{ action "copySession" "⎘ id" }} {{ action "openProject" "↗ proj" }} {{ action "openTranscript" "↗ log" }}{{ if ne .git.repoUrl "" }} {{ link .git.repoUrl "↗ repo" }}{{ end }} {{ action "edit.toggle" "✎ edit" "✎ done" }}`,fg:`foreground`},session:{template:`§ {{ template "formatCost" .session.cost }} ({{ template "formatTokens" .session.tokens }}){{ template "budgetStatus" (dict "cost" .session.cost "budget" .session.budget.amount "warn" .session.budget.warningThreshold) }}`,fg:`foreground`},today:{template:`☉ {{ template "formatCost" .today.cost }} ({{ template "formatTokens" .today.tokens }}){{ template "budgetStatus" (dict "cost" .today.cost "budget" .today.budget.amount "warn" .today.budget.warningThreshold) }}`,fg:`foreground`},block:{template:`◱ {{ round .block.nativeUtilization }}% ({{ template "formatResetCountdown" .block.resetsAt }})`,bg:`{{ ramp (round .block.nativeUtilization) "step" 0 "panel" .block.budget.heatThreshold "warning" .block.budget.warningThreshold "error" }}`,fg:`{{ ramp (round .block.nativeUtilization) "step" 0 "foreground" .block.budget.heatThreshold "button-color-foreground" }}`,when:`{{ gt .block.resetsAt 0 }}`},weekly:{template:`◑ {{ round .weekly.percentage }}% ({{ template "formatResetCountdown" .weekly.resetsAt }})`,bg:`{{ ramp (round .weekly.percentage) "step" 0 "panel" .weekly.budget.heatThreshold "warning" .weekly.budget.warningThreshold "error" }}`,fg:`{{ ramp (round .weekly.percentage) "step" 0 "foreground" .weekly.budget.heatThreshold "button-color-foreground" }}`,when:`{{ gt .weekly.resetsAt 0 }}`},burnrate:{template:`⚡ {{ template "formatRate" .burn.costPerHour }} · {{ template "formatEta" .block.etaMinutes }} to 5h · {{ template "formatEta" .weekly.etaMinutes }} to wk`,bg:`{{ ramp .block.etaMinutes "step" -1 "panel" 0 "error" .burn.eta.errorMinutes "warning" .burn.eta.warnMinutes "panel" }}`,fg:`{{ ramp .block.etaMinutes "step" -1 "foreground" 0 "button-color-foreground" .burn.eta.warnMinutes "foreground" }}`,when:`{{ or (gt .block.resetsAt 0) (gt .weekly.resetsAt 0) }}`},speed:{template:`⇅ out {{ template "formatSpeed" .speed.output }} · in {{ template "formatSpeed" .speed.input }} · tot {{ template "formatSpeed" .speed.total }}`,fg:`foreground`,when:`{{ gt .session.tokens 0 }}`},tokenSparkline:{template:`⚡ {{ sparkline .speed.history 24 }}`,fg:`foreground`,when:`{{ ne .speed.history "" }}`},cacheTimer:{template:`◴ {{ if le (minutesUntilReset .cache.expiresAt) 0 }}cold{{ else }}{{ minutesUntilReset .cache.expiresAt }}m{{ end }}`,fg:`{{ if le (minutesUntilReset .cache.expiresAt) 8 }}error{{ else }}{{ if le (minutesUntilReset .cache.expiresAt) 20 }}warning{{ else }}foreground{{ end }}{{ end }}`,when:`{{ gt .cache.expiresAt 0 }}`},context:{template:`◔ {{ formatInteger .context.totalTokens }} ({{ .context.contextLeft }}%)`,bg:`{{ ramp .context.contextLeft "step" 0 "error" 21 "warning" 41 "surface-active" }}`,fg:`{{ ramp .context.contextLeft "step" 0 "button-color-foreground" 41 "foreground" }}`,when:`{{ gt .context.totalTokens 0 }}`},metrics:{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 }} `,fg:`foreground`,when:`{{ or .metrics.lastResponseTime .metrics.responseTime .metrics.sessionDuration .metrics.messageCount .metrics.linesAdded .metrics.linesRemoved }}`},charsetControl:{template:`{{ .charset.effective }} {{ menu "applyCharsetForever" "▸" "▾" }} {{ action "resetCharset" "↺" }}`,fg:`foreground`},colorCompatControl:{template:`{{ .colorCompatibility.effective }} {{ menu "applyColorCompatForever" "▸" "▾" }} {{ action "resetColorCompat" "↺" }}`,fg:`foreground`},directoryPaletteControl:{template:`🎨 directory {{ menu "applyDirectoryPaletteForever" "▸" "▾" }} {{ action "resetDirectoryPalette" "↺" }}`,fg:`foreground`}},root:{rows:{identity:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`toolbar`},{kind:`group`,name:`settings`,label:`⚙ terminal`,direction:`horizontal`,children:[`charsetControl`,`colorCompatControl`,`directoryPaletteControl`]}]},status:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`}]}}},actions:{copySession:{copy:`{{ .session.id }}`},copyDir:{copy:`{{ .current_dir }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},applyCharsetForever:{persist:`charset`,from:`charsets`},resetCharset:{reset:`charset`},applyColorCompatForever:{persist:`colorCompatibility`,from:`colorCompatibilities`},resetColorCompat:{reset:`colorCompatibility`},applyDirectoryPaletteForever:{persist:`segments.directory.palette`,from:`themes`},resetDirectoryPalette:{reset:`segments.directory.palette`}},looks:{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:`git`},{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:`segment`,name:`toolbar`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{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`}]}]}}},editGlobals:{style:`plain`,default_separator:` | `},helpers:{formatCost:'{{ if lt . 0.01 }}<$0.01{{ else }}${{ printf "%.2f" . }}{{ end }}',formatTokenCount:`{{ if ge . 1000000 }}{{ printf "%.1f" (divf . 1000000) }}M{{ else if ge . 1000 }}{{ printf "%.1f" (divf . 1000) }}K{{ else }}{{ . }}{{ end }}`,formatTokens:`{{ template "formatTokenCount" . }} tokens`,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 .)) }}`}},dw=new Set([uw.globals.palette,...Object.values(uw.segments).map(e=>e.palette)].filter(e=>e!==void 0)),fw=uo(hv(`<default>`,JSON.stringify(uw),dw),uw);var pw=pe((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:en}function r(){sn||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()===cn}function l(e){var t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function u(e,t,n){nn(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function d(e,t,n){nn(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 rn.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(re())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&w(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,ie(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.
|
|
139
|
+
`).length:0)}async getRemotesAsync(e){let t=ES(`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:X(t.kind===`ok`?PS(t.value):[])}repoNameFrom(e,t){let n=LS(e);return(n===null?null:zS(n))??c.basename(t)}async getRepoRemoteUrl(e){let t=await this.getRemotesAsync(e);if(t.kind!==`ok`)return t;let n=RS(t.value);return n===null?Z:X(n)}async execForgeAsync(e,t,n){return Te({bin:e,args:[...t],cwd:n.cwd,env:{...process.env},timeoutMs:n.timeout,category:`forge`})}async resolvePullRequest(e,t){let n=NS(t);return n===`github`?HS(`gh pr view`,await this.execForgeAsync(`gh`,[`pr`,`view`,`--json`,`number,state,url`],{cwd:e,timeout:5e3}),/no (open )?pull requests? found/i,GS):n===`gitlab`?HS(`glab mr view`,await this.execForgeAsync(`glab`,[`mr`,`view`,`--output`,`json`],{cwd:e,timeout:5e3}),/no (open )?merge requests? (found|available)/i,KS):Z}isWorktree(e){try{let t=c.join(e,`.git`);return!!(r.existsSync(t)&&r.statSync(t).isFile())}catch{return!1}}async getCoreAsync(e){D(`[GIT-EXEC] Running git status --porcelain=v2 in ${e}`);let t=ES(`git status --porcelain=v2 --branch`,await this.execGitAsync([`status`,`--porcelain=v2`,`--branch`],{cwd:e,timeout:2e3}),`failed`);return t.kind===`ok`?X(WS(t.value)):t}};const JS=(e,t)=>D(t);var YS=class{slots=new Map;maxWatchers;counters;logger;closed=!1;constructor(e={}){this.maxWatchers=e.maxWatchers??128,this.counters=e.counters,this.logger=e.logger??JS}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()}},XS=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 ZS=(e,t)=>D(t),QS={showSha:!0,showStashCount:!0};function $S(e){let t=Object.keys(e).sort(),n={};for(let r of t)n[r]=e[r];return JSON.stringify(n)}function eC(e){let t=t=>{try{return r.statSync(c.join(e,t)).mtimeMs}catch{return 0}};return{head:t(`HEAD`),index:t(`index`)}}function tC(e,t){return e.head!==t.head||e.index!==t.index}function nC(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 rC=class extends qS{entries=new Map;subscribersByRepo=new Map;fetchInFlight=new Map;prCache=new Map;prFetchInFlight=new Map;refreshes=new XS;hits=0;misses=0;invalidations=0;inner;ttlMs;maxEntries;watchers;ownsWatchers;logger;sanityTimer=null;constructor(e={}){super(),this.inner=e.inner??new qS,this.ttlMs=e.ttlMs??3e4,this.maxEntries=e.maxEntries??64,this.logger=e.logger??ZS,e.watchers?(this.watchers=e.watchers,this.ownsWatchers=!1):(this.watchers=new YS({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()}}async getGitInfo(e,t={},n){let r=await this.inner.resolveEffectiveGitDir(e,n);return r.kind===`ok`?this.getGitInfoForRoot(r.value,t):r}getGitInfoForRoot(e,t){let n=`${e}|${$S(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(X(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=eC(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}`,nC(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 Z;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.inner.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}`,nC(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,{...QS});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,{...QS}),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=eC(this.inner.resolveGitDir(t.repoRoot)),e.set(t.repoRoot,n)),tC(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.ownsWatchers&&this.watchers.closeAll()}},iC=class{static CACHE_DIR=O();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 D(`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`?(D(`Removing stale lock file ${e} for dead process ${i}`),r.unlinkSync(t),!1):(D(`Error checking process ${i} for lock ${e}:`,n),!0)}}catch(t){return D(`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`}),D(`Lock acquired for ${e}`),!0}catch(e){if(e.code===`EEXIST`)await ne(50);else throw e}return D(`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),D(`Lock released for ${e}`)}catch(t){t.code!==`ENOENT`&&D(`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){D(`Failed to create cache directories:`,e)}}static createProjectHash(e){return ee(`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)){D(`Cache for ${e} is locked, waiting...`),await ne(75);continue}try{let i=await r.promises.readFile(n,`utf-8`),a=JSON.parse(i);return!t||a.timestamp>=t?(D(`[CACHE-HIT] ${e} disk cache: found`),this.deserializeDates(a.data)):(D(`${e} cache outdated: cache=${a.timestamp}, latest=${t}`),null)}catch(t){if(t.code===`ENOENT`)return D(`No shared ${e} usage cache found`),null;D(`Attempt ${a+1} failed to read ${e} cache: ${t.message}. Retrying...`),await ne(75)}}return D(`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)){D(`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`),D(`[CACHE-SET] ${e} disk cache stored`)}catch(t){D(`Failed to save ${e} usage cache:`,t)}finally{await this.releaseLock(i)}}};const aC={"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 oC=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 iC.getUsageCache(`pricing`,e)}static async saveDiskCache(e){await iC.setUsageCache(`pricing`,e)}static async fetchPricingData(){return new Promise(e=>{let t=new v(this.GITHUB_PRICING_URL),n=te({hostname:t.hostname,path:t.pathname,headers:{"User-Agent":`cc-candybar`,"Cache-Control":`no-cache`},timeout:5e3},t=>{if(t.statusCode!==200){D(`HTTP ${t.statusCode}: ${t.statusMessage}`),e(null);return}let r=``,i=0;t.on(`data`,t=>{if(i+=t.length,i>1048576){D(`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)?(D(`Fetched fresh pricing from GitHub for ${Object.keys(i).length} models`),D(`Pricing last updated: ${n?.updated||`unknown`}`),e(i)):(D(`Invalid pricing data structure`),e(null))}catch(t){D(`Failed to parse JSON:`,t),e(null)}}),t.on(`error`,t=>{D(`Response error:`,t),e(null)})});n.on(`error`,t=>{D(`Request error:`,t),e(null)}),n.on(`timeout`,()=>{D(`Request timeout`),n.destroy(),e(null)}),n.end()})}static async getCurrentPricing(){if(this.executionCache!==null)return D(`[CACHE-HIT] Pricing execution cache: ${Object.keys(this.executionCache).length} models`),this.executionCache;let e=await this.loadDiskCache();if(e)return D(`[CACHE-HIT] Pricing disk cache: ${Object.keys(e).length} models`),this.executionCache=e,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(e).length} models`),e;let t=await this.fetchPricingData();return t?(await this.saveDiskCache(t),D(`[CACHE-SET] Pricing disk cache stored: ${Object.keys(t).length} models`),this.executionCache=t,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(t).length} models`),t):(D(`[CACHE-FALLBACK] Using offline pricing data: ${Object.keys(aC).length} models`),this.executionCache=aC,D(`[CACHE-SET] Pricing execution cache stored: ${Object.keys(aC).length} models`),aC)}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 D(`[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),D(`[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`}};function sC(e){if(!e)return 0;try{return o(e).mtimeMs}catch{return 0}}const cC=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 lC(e){return((...t)=>cC.run(()=>e(...t)))}const uC=lC(ie),dC=lC(w),fC=lC(T);async function pC(e,t){return cC.run(async()=>{let n=null;try{n=await re(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 X({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 X({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`?Z:Q(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{D(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}async function mC(e,t){return cC.run(async()=>{let n=null;try{n=await re(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 X({buf:o===a.length?a:a.subarray(0,o),fromStart:i===0})}catch(t){return t.code===`ENOENT`?Z:Q(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{D(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}function hC(){let e=[],t=process.env.CLAUDE_CONFIG_DIR;if(t&&t.split(`,`).forEach(t=>{let n=t.trim();a(n)&&e.push(n)}),e.length===0){let t=p(),n=d(t,`.config`,`claude`),r=d(t,`.claude`);a(n)&&e.push(n),a(r)&&e.push(r)}return e}async function gC(e){let t=[];for(let n of e){let e=d(n,`projects`);if(a(e))try{let n=await uC(e,{withFileTypes:!0});for(let r of n)if(r.isDirectory()){let n=d(e,r.name);t.push(n)}}catch(t){D(`Failed to read projects directory ${e}:`,t)}}return t}async function _C(e,t,n){let r=[],i=d(t,e,`subagents`);try{let t=(await uC(i)).filter(e=>e.startsWith(`agent-`)&&e.endsWith(`.jsonl`));for(let a of t){let t=d(i,a);if(n?.has(t)){r.push(t);continue}try{let n=(await dC(t,`utf-8`)).split(`
|
|
140
|
+
`)[0];n&&JSON.parse(n).sessionId===e&&r.push(t)}catch{D(`Failed to check agent file ${t}`)}}}catch(e){D(`Failed to read subagents directory ${i}:`,e)}return r}const vC=new Map;async function yC(e){try{let t=await fC(e),n=t.size,r=vC.get(e);if(r&&r.mtime===t.mtimeMs&&r.size===n)return D(`[parse-cache] hit ${e}`),vC.delete(e),vC.set(e,r),r.entries;let i;return n>1048576?(D(`Using streaming parser for large file ${e} (${Math.round(n/1024)}KB)`),i=await wC(e)):i=await SC(e),D(`Parsed ${i.length} entries from ${e}`),n>5242880?i:(vC.delete(e),vC.size>=16&&vC.delete(vC.keys().next().value),vC.set(e,{mtime:t.mtimeMs,size:n,entries:i}),i)}catch(t){if(t.code===`ENOENT`)return D(`Transcript not present yet: ${e}`),[];throw t}}function bC(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,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 xC(e){let t=[];for(let n of e.split(`
|
|
141
|
+
`))if(n.trim())try{let e=bC(JSON.parse(n));e&&t.push(e)}catch(e){D(`Failed to parse JSONL line: ${e}`);continue}return t}async function SC(e){return xC(await dC(e,`utf-8`))}async function CC(e,t){let n=await pC(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 X(c<0?{entries:[],cursor:{offset:i,mtimeMs:a,ino:o},reset:s}:{entries:xC(r.subarray(0,c+1).toString(`utf-8`)),cursor:{offset:i+c+1,mtimeMs:a,ino:o},reset:s})}async function wC(e){return new Promise((t,n)=>{let r=[],a=i(e,{encoding:`utf8`}),o=E({input:a,crlfDelay:1/0});o.on(`line`,e=>{let t=e.trim();if(t)try{let e=bC(JSON.parse(t));e&&r.push(e)}catch(e){D(`Failed to parse JSONL line: ${e}`)}}),o.on(`close`,()=>{t(r)}),o.on(`error`,t=>{D(`Streaming parser error for ${e}:`,t),n(t)}),a.on(`error`,t=>{D(`File stream error for ${e}:`,t),n(t)})})}var TC=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 EC(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 DC={cost:0,input:0,output:0,cacheCreation:0,cacheRead:0},OC={cost:null,calculatedCost:null,officialCost:null,tokens:null,tokenBreakdown:null};function kC(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function AC(){let e=new Date;return e.setHours(0,0,0,0),e.setDate(e.getDate()-1),e.getTime()}function jC(){return{input:0,output:0,cacheCreation:0,cacheRead:0}}async function MC(e,t,n,r){let i=kC(new Date(AC())),a=e&&!t?e:void 0,o=a?.entries??0,s=a?.cost??0,c=a?{...a.breakdown}:jC(),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 oC.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=kC(new Date(e.timestamp));if(r<i)continue;let a=l.get(r)??{...DC};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 NC(e){let t=0,n=0,r=jC(),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)??{...DC};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:OC,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 PC(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 FC=class{entries=new Map;flight=new TC;seeded=new Map;speedRings=new Map;speedFlight=new TC;maxEntries;staleAgeMs;hits=0;misses=0;sweeps=0;seeds=0;sweepTimer=null;constructor(e={}){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:OC,i=t?.cost?.total_cost_usd??null;return X({session:{...r,cost:i??r.cost,officialCost:i}})}async getTodayInfo(e){let t=kC(new Date);try{await this.ensureSeeded(t)}catch(e){return Q(`usage seed: ${e instanceof Error?e.message:String(e)}`)}let n=await this.ingest(e?.session_id??``,e?.transcript_path);if(n.kind===`failed`)return n;let r={...DC},i=!1;for(let e of this.entries.values()){i||=e.days.has(t);let n=e.days.get(t)??DC;r.cost+=n.cost,r.input+=n.input,r.output+=n.output,r.cacheCreation+=n.cacheCreation,r.cacheRead+=n.cacheRead}return i?X({cost:r.cost,tokens:r.input+r.output+r.cacheCreation+r.cacheRead,tokenBreakdown:{input:r.input,output:r.output,cacheCreation:r.cacheCreation,cacheRead:r.cacheRead},date:t}):Z}async observeSpeed(e,t,n){let r=sC(t);return this.speedFlight.run(`${e}:${r}`,async()=>{let i=await this.ingest(e,t,r);if(i.kind===`failed`)return i;let a=EC(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),X({...s!==void 0&&{prev:s},cur:a,samples:[...o]})})}async ingest(e,t,n){if(!e)return Z;let r=n??sC(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++,X(i);if(!t)return i?X(i):Z;this.misses++;let a;try{a=await this.flight.run(`${e}:${r}`,()=>this.refold(e,t,this.entries.get(e)))}catch(t){return Q(`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(),X(o)}async refold(e,t,n){let r=await _C(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 CC(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 MC(r,l,s,c)),e===t&&(a=c.mtimeMs)}return X({files:i,...NC(i),mainMtime:a})}ensureSeeded(e){let t=this.seeded.get(e);if(t)return t;this.seeded.clear();let n=this.seed(e);return this.seeded.set(e,n),n.catch(()=>{this.seeded.get(e)===n&&this.seeded.delete(e)}),n}async seed(e){let t=AC(),n=await gC(hC()),r=[];for(let e of n){let n;try{n=await uC(e)}catch{continue}for(let i of n){if(!i.endsWith(`.jsonl`))continue;let n=d(e,i),a;try{a=(await fC(n)).mtimeMs}catch{continue}a<t||r.push({sessionId:i.slice(0,-6),path:n,mtime:a})}}await PC(r,8,async e=>{let t=await this.ingest(e.sessionId,e.path,e.mtime);t.kind===`failed`&&Y(`warn`,`usageStore seed: ${t.reason}`)}),this.seeds++,Y(`info`,`usageStore seed sessions=${r.length}`)}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++,Y(`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),Y(`info`,`usageStore evict ${e}`)}}close(){this.sweepTimer&&=(clearInterval(this.sweepTimer),null),this.entries.clear(),this.seeded.clear(),this.speedRings.clear()}};const IC=/"(?:cache_read_input_tokens|cache_creation_input_tokens)":[1-9]/;function LC(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 RC(e){let t=await zC(e);return t.kind===`ok`?X(Math.floor((t.value+36e5)/1e3)):t}async function zC(e){for(let t of[65536,1048576]){let n=await mC(e,t);if(n.kind!==`ok`)return n;let r=BC(n.value.buf,n.value.fromStart);if(r!=null)return X(r);if(n.value.fromStart)return Z}return Z}function BC(e,t){let n=e.toString(`utf8`).split(`
|
|
142
|
+
`),r=+!t;for(let e=n.length-1;e>=r;e--){let t=n[e];if(!t||!IC.test(t))continue;let r=LC(t);if(r!=null)return r}return null}function VC(e,t,n){let r=$m(t(`preset`),e.globals.preset,e.presets),i=nh(e,r),a=t(`edit.mode`)===`open`?e.editGlobals:{};return{preset:r,presetCustomized:n(r),theme:si(a.palette,t(`theme`),i.palette),look:di(a.look,t(`look`),i.look,e.looks),style:hi(a.style,t(`style`),i.style),separator:a.default_separator??i.default_separator,autoWrap:wi(a.autoWrap,t(`autoWrap`),i.autoWrap),padding:Ti(a.padding,t(`padding`),i.padding),charset:a.charset??i.charset??`unicode`,updateNotice:a.updateNotice??i.updateNotice??!0,colorCompatibility:a.colorCompatibility??i.colorCompatibility??`truecolor`}}const HC=10*1e3;function UC(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 WC(e,t){if(!(t<60))return e*3600/t}function GC(e,t,n,r){let i=r-t;if(i<50||i>HC)return;let a=n-e;if(!(a<=0))return a*1e3/i}function KC(e){let{prev:t,cur:n}=e;if(t===void 0)return;let r=GC(t.input,t.atMs,n.input,n.atMs),i=GC(t.output,t.atMs,n.output,n.atMs),a=GC(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 qC(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>HC)continue;let o=GC(r.total,r.atMs,i.total,i.atMs);n.push(o??0)}if(n.length!==0)return n.join(`,`)}function JC(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}function YC(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`,()=>JC(f.hostname())),i=n(`user`,()=>f.userInfo().username);return{host:{...r!==void 0&&{name:r},...i!==void 0&&{user:i},...e.ssh!==void 0&&{ssh:e.ssh}},failures:t}}function XC(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,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}`,i);let n=[],r=new Set;for(let t of va(oo(e.root))){if(t.when)for(let e of M_(t.when))n.push(e);if(t.kind!==`segment`)continue;let r=e.segments[t.name];if(r){for(let e of[r.template,r.when,r.bg,r.fg])if(e)for(let t of M_(e))n.push(t)}}let i=new Set;for(;n.length>0;){let e=n.pop();for(let a of ZC(t,e)){if(r.has(a))continue;r.add(a);let e=t.get(a);if(e){if(e.kind===`input`)i.add(e.path);else if(e.kind===`template`)for(let t of M_(e.template))n.push(t)}}}return i}function ZC(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 QC(e,t){for(let n of e)if(n===t||n.startsWith(t+`.`))return!0;return!1}function $C(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 ew(e,t,n,r,i,a){let o=e=>QC(r,e),s=(t.clock??(()=>new Date))().getTime(),c=(e,t,n)=>t?n().catch(t=>Q(`${e}: ${String(t)}`)):Promise.resolve(Z),[l,u,d,f,p,m,h,g]=await Promise.all([c(`git`,o(`git`),()=>t.gitProvider.getGitInfo(n??e.workspace?.current_dir,$C(r),e.workspace?.project_dir)),c(`session`,o(`session.cost`)||o(`session.tokens`)||o(`burn`),()=>t.usageStore.getUsageInfo(e.session_id,e)),c(`today`,o(`today`),()=>t.usageStore.getTodayInfo(e)),c(`context`,o(`context`),()=>t.contextProvider.getContextInfo(e)),c(`metrics`,o(`metrics`)||o(`burn`),()=>t.metricsProvider.getMetricsInfo(e.session_id,e)),c(`tmux`,o(`tmux`),()=>t.tmuxService.getSessionId()),c(`cache`,o(`cache`),()=>RC(e.transcript_path)),c(`speed`,o(`speed`),()=>t.usageStore.observeSpeed(e.session_id,e.transcript_path,s))]),_=[],v=e=>{if(e.kind===`failed`){_.push(e.reason);return}return e.kind===`ok`?e.value:void 0},y=rw(l);_.push(...y.failures);let b=YC(a);_.push(...b.failures);let x=v(u),S=v(d),C=v(f),ee=v(p),te=v(m),ne=v(h);for(let e of _)t.log(`warn`,`provider fetch failed: ${e}`);let re=e.rate_limits?.five_hour,w=e.rate_limits?.seven_day,ie=re?UC(re.used_percentage,re.resets_at,18e6,s):void 0,T=w?UC(w.used_percentage,w.resets_at,6048e5,s):void 0,E=x?.session.cost,ae=ee?.sessionDuration,oe=o(`burn`)&&E!=null&&ae!=null?WC(E,ae):void 0,se=v(g),ce=se===void 0?void 0:KC(se),le=se===void 0?void 0:qC(se),ue=ce!==void 0||le!==void 0?{...ce,...le!==void 0&&{history:le}}:void 0,de=nw(process.env.HOME??process.env.USERPROFILE),fe=e.workspace?{...e.workspace,current_dir:nw(e.workspace.current_dir)??``,project_dir:nw(e.workspace.project_dir)??``}:e.workspace,pe=x===void 0?void 0:tw({cost:x.session.cost,tokens:x.session.tokens}),me=S===void 0?void 0:{cost:S.cost,tokens:S.tokens},he=ee===void 0?void 0:tw({lastResponseTime:ee.lastResponseTime,responseTime:ee.responseTime,sessionDuration:ee.sessionDuration,messageCount:ee.messageCount,linesAdded:ee.linesAdded,linesRemoved:ee.linesRemoved});return{...e,...fe!==void 0&&{workspace:fe},...de!==void 0&&{home:de},...y.git!==void 0&&{git:y.git},...te!==void 0&&{tmux:{session:te}},host:b.host,theme:{effective:i.theme},look:{effective:i.look},preset:{effective:i.preset,customized:i.presetCustomized},style:{effective:i.style},charset:{effective:i.charset},colorCompatibility:{effective:i.colorCompatibility},autoWrap:{effective:i.autoWrap},padding:{effective:i.padding},...pe!==void 0&&{session:pe},...me!==void 0&&{today:me},...oe!==void 0&&{burn:{costPerHour:oe}},...ue!==void 0&&{speed:ue},...o(`block`)&&re!==void 0&&{block:{nativeUtilization:re.used_percentage,resetsAt:re.resets_at,...ie!==void 0&&{etaMinutes:ie}}},...w!==void 0&&{weekly:{percentage:w.used_percentage,resetsAt:w.resets_at,...T!==void 0&&{etaMinutes:T}}},...ne!==void 0&&{cache:{expiresAt:ne}},...C!==void 0&&{context:{totalTokens:C.totalTokens,contextLeft:C.contextLeftPercentage}},...he!==void 0&&{metrics:he}}}function tw(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 nw(e){return e===void 0||e.length===0||c.sep!==`\\`?e:e.replace(/\\/g,`/`)}function rw(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 iw=`trimPrefix "/" (trimPrefix .project_dir .current_dir)`,aw=`{{ \$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 (${iw}) (basename .project_dir) (ne (${iw}) "") }}{{ end }}{{ end }}{{ abbreviatePath \$dir }}`,ow={branch:`primary`,staged:`success`,unstaged:`warning`,untracked:`accent`,conflicts:`error`,ahead:`success`,behind:`warning`,stash:`accent`},sw=(e,t)=>`{{ fg (color "${ow[e]}") ${t} }}`,cw=`{{ readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3 }}`,lw=`{{ if or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0) }} ({{ \$first := true }}{{ if gt .git.staged 0 }}${sw(`staged`,`(printf "+%v" .git.staged)`)}{{ $first = false }}{{ end }}{{ if gt .git.unstaged 0 }}{{ if not $first }} {{ end }}${sw(`unstaged`,`(printf "~%v" .git.unstaged)`)}{{ $first = false }}{{ end }}{{ if gt .git.untracked 0 }}{{ if not $first }} {{ end }}${sw(`untracked`,`(printf "?%v" .git.untracked)`)}{{ $first = false }}{{ end }}{{ if gt .git.conflicts 0 }}{{ if not $first }} {{ end }}${sw(`conflicts`,`(printf "!%v" .git.conflicts)`)}{{ $first = false }}{{ end }}){{ end }}`,uw=`{{ if ne .git.repoName "" }}{{ .git.repoName }} {{ end }}⎇ ${sw(`branch`,`.git.branch`)}{{ if .git.sha }} ♯ {{ .git.sha }}{{ end }}{{ if or (gt .git.ahead 0) (gt .git.behind 0) }} {{ if gt .git.ahead 0 }}${sw(`ahead`,`(printf "↑%v" .git.ahead)`)}{{ end }}{{ if gt .git.behind 0 }}${sw(`behind`,`(printf "↓%v" .git.behind)`)}{{ end }}{{ end }}`+lw+`{{ if .git.upstream }} →{{ .git.upstream }}{{ end }}{{ if gt .git.stash 0 }} ${sw(`stash`,`(printf "⧇ %v" .git.stash)`)}{{ end }} {{ if eq .git.status "conflicts" }}{{ fg (color "error") "⚠" }}{{ else }}{{ if eq .git.status "dirty" }}{{ fg (color "warning") "●" }}{{ else }}{{ fg (color "success") "✓" }}{{ end }}{{ end }}`,dw={globals:{palette:`tokyo-night`},variables:{current_dir:{kind:`input`,path:`workspace.current_dir`,default:`?`},project_dir:{kind:`input`,path:`workspace.project_dir`,default:``},transcript_path:{kind:`input`,path:`transcript_path`,default:``},"model.display_name":{kind:`input`,path:`model.display_name`,default:``},"session.id":{kind:`input`,path:`session_id`,default:``},version:{kind:`input`,path:`version`,default:``},"theme.effective":{kind:`input`,path:`theme.effective`,default:``},"look.effective":{kind:`input`,path:`look.effective`,default:``},"preset.effective":{kind:`input`,path:`preset.effective`,default:``},"preset.customized":{kind:`input`,path:`preset.customized`,type:`boolean`,default:!1},"style.effective":{kind:`input`,path:`style.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},"term.cols":{kind:`input`,path:`term.cols`,type:`number`,default:80},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.repoUrl":{kind:`input`,path:`git.repoUrl`,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.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},"session.budget.amount":{kind:`literal`,value:0},"session.budget.warningThreshold":{kind:`literal`,value:80},"today.cost":{kind:`input`,path:`today.cost`,type:`number`,default:0},"today.tokens":{kind:`input`,path:`today.tokens`,type:`number`,default:0},"today.budget.amount":{kind:`literal`,value:50},"today.budget.warningThreshold":{kind:`literal`,value:80},"block.nativeUtilization":{kind:`input`,path:`block.nativeUtilization`,type:`number`,default:0},"block.resetsAt":{kind:`input`,path:`block.resetsAt`,type:`number`,default:0},"block.budget.warningThreshold":{kind:`literal`,value:80},"block.budget.heatThreshold":{kind:`literal`,value:50},"weekly.percentage":{kind:`input`,path:`weekly.percentage`,type:`number`,default:0},"weekly.resetsAt":{kind:`input`,path:`weekly.resetsAt`,type:`number`,default:0},"weekly.budget.warningThreshold":{kind:`literal`,value:80},"weekly.budget.heatThreshold":{kind:`literal`,value:50},"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},"burn.eta.warnMinutes":{kind:`literal`,value:60},"burn.eta.errorMinutes":{kind:`literal`,value:30},"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},"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}},segments:{directory:{template:aw,fg:`foreground`},model:{template:`✱ {{ formatModelName .model.display_name }}`,fg:`foreground`,when:`{{ ne .model.display_name "" }}`},sessionId:{template:`⌗{{ trunc 8 .session.id }}`,fg:`foreground`,when:`{{ ne .session.id "" }}`},version:{template:`◈ v{{ .version }}`,fg:`foreground`,when:`{{ ne .version "" }}`},tmux:{template:`tmux:{{ .tmux.session | default "none" }}`,fg:`foreground`,when:`{{ ne .tmux.session "" }}`},host:{template:`⇄ {{ .host.user | default "?" }}@{{ .host.name | default "?" }}`,bg:`warning`,fg:`{{ contrastOn (bgOf) }}`,when:`{{ .host.ssh }}`},git:{template:uw,fg:cw,when:`{{ ne .git.branch "" }}`},gitaculous:{template:`(git){{ if ne .git.repoName "" }} {{ .git.repoName }}{{ end }}{{ if ne .git.operation "" }} [{{ .git.operation }}]{{ end }}{{ if ne .git.sha "" }} {{ .git.sha }}{{ end }}{{ if or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0) }} {{ if gt .git.staged 0 }}${sw(`staged`,`"S"`)}{{ end }}{{ if gt .git.unstaged 0 }}${sw(`unstaged`,`"U"`)}{{ end }}{{ if gt .git.untracked 0 }}${sw(`untracked`,`"?"`)}{{ end }}{{ if gt .git.conflicts 0 }}${sw(`conflicts`,`(printf "!%v" .git.conflicts)`)}{{ end }}{{ end }} ⎇ ${sw(`branch`,`.git.branch`)}{{ if ne .git.upstream "" }} [{{ .git.upstream }}{{ if or (gt .git.ahead 0) (gt .git.behind 0) }} {{ if gt .git.ahead 0 }}${sw(`ahead`,`(printf "+%v" .git.ahead)`)}{{ end }}{{ if and (gt .git.ahead 0) (gt .git.behind 0) }}/{{ end }}{{ if gt .git.behind 0 }}${sw(`behind`,`(printf "-%v" .git.behind)`)}{{ end }}{{ end }}]{{ end }}{{ if gt .git.stash 0 }} ${sw(`stash`,`(printf "(%v stashed)" .git.stash)`)}{{ end }}{{ if gt .git.timeSinceCommit 0 }} ◷ {{ template "formatTimeSince" .git.timeSinceCommit }}{{ end }}`,fg:cw,when:`{{ ne .git.branch "" }}`},gitPr:{template:`{{ if ne .git.prUrl "" }}{{ link .git.prUrl (printf "⇆ #%v" .git.prNumber) }}{{ else }}⚠ PR{{ end }}`,fg:`foreground`,when:`{{ or (ne .git.prUrl "") (ne .git.prError "") }}`},toolbar:{template:`{{ action "copySession" "⎘ id" }} {{ action "openProject" "↗ proj" }} {{ action "openTranscript" "↗ log" }}{{ if ne .git.repoUrl "" }} {{ link .git.repoUrl "↗ repo" }}{{ end }} {{ action "edit.toggle" "✎ edit" "✎ done" }}`,fg:`foreground`},session:{template:`§ {{ template "formatCost" .session.cost }} ({{ template "formatTokens" .session.tokens }}){{ template "budgetStatus" (dict "cost" .session.cost "budget" .session.budget.amount "warn" .session.budget.warningThreshold) }}`,fg:`foreground`},today:{template:`☉ {{ template "formatCost" .today.cost }} ({{ template "formatTokens" .today.tokens }}){{ template "budgetStatus" (dict "cost" .today.cost "budget" .today.budget.amount "warn" .today.budget.warningThreshold) }}`,fg:`foreground`},block:{template:`◱ {{ round .block.nativeUtilization }}% ({{ template "formatResetCountdown" .block.resetsAt }})`,bg:`{{ ramp (round .block.nativeUtilization) "step" 0 "panel" .block.budget.heatThreshold "warning" .block.budget.warningThreshold "error" }}`,fg:`{{ ramp (round .block.nativeUtilization) "step" 0 "foreground" .block.budget.heatThreshold "button-color-foreground" }}`,when:`{{ gt .block.resetsAt 0 }}`},weekly:{template:`◑ {{ round .weekly.percentage }}% ({{ template "formatResetCountdown" .weekly.resetsAt }})`,bg:`{{ ramp (round .weekly.percentage) "step" 0 "panel" .weekly.budget.heatThreshold "warning" .weekly.budget.warningThreshold "error" }}`,fg:`{{ ramp (round .weekly.percentage) "step" 0 "foreground" .weekly.budget.heatThreshold "button-color-foreground" }}`,when:`{{ gt .weekly.resetsAt 0 }}`},burnrate:{template:`⚡ {{ template "formatRate" .burn.costPerHour }} · {{ template "formatEta" .block.etaMinutes }} to 5h · {{ template "formatEta" .weekly.etaMinutes }} to wk`,bg:`{{ ramp .block.etaMinutes "step" -1 "panel" 0 "error" .burn.eta.errorMinutes "warning" .burn.eta.warnMinutes "panel" }}`,fg:`{{ ramp .block.etaMinutes "step" -1 "foreground" 0 "button-color-foreground" .burn.eta.warnMinutes "foreground" }}`,when:`{{ or (gt .block.resetsAt 0) (gt .weekly.resetsAt 0) }}`},speed:{template:`⇅ out {{ template "formatSpeed" .speed.output }} · in {{ template "formatSpeed" .speed.input }} · tot {{ template "formatSpeed" .speed.total }}`,fg:`foreground`,when:`{{ gt .session.tokens 0 }}`},tokenSparkline:{template:`⚡ {{ sparkline .speed.history 24 }}`,fg:`foreground`,when:`{{ ne .speed.history "" }}`},cacheTimer:{template:`◴ {{ if le (minutesUntilReset .cache.expiresAt) 0 }}cold{{ else }}{{ minutesUntilReset .cache.expiresAt }}m{{ end }}`,fg:`{{ if le (minutesUntilReset .cache.expiresAt) 8 }}error{{ else }}{{ if le (minutesUntilReset .cache.expiresAt) 20 }}warning{{ else }}foreground{{ end }}{{ end }}`,when:`{{ gt .cache.expiresAt 0 }}`},context:{template:`◔ {{ formatInteger .context.totalTokens }} ({{ .context.contextLeft }}%)`,bg:`{{ ramp .context.contextLeft "step" 0 "error" 21 "warning" 41 "surface-active" }}`,fg:`{{ ramp .context.contextLeft "step" 0 "button-color-foreground" 41 "foreground" }}`,when:`{{ gt .context.totalTokens 0 }}`},metrics:{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 }} `,fg:`foreground`,when:`{{ or .metrics.lastResponseTime .metrics.responseTime .metrics.sessionDuration .metrics.messageCount .metrics.linesAdded .metrics.linesRemoved }}`},charsetControl:{template:`{{ .charset.effective }} {{ menu "applyCharsetForever" "▸" "▾" }} {{ action "resetCharset" "↺" }}`,fg:`foreground`},colorCompatControl:{template:`{{ .colorCompatibility.effective }} {{ menu "applyColorCompatForever" "▸" "▾" }} {{ action "resetColorCompat" "↺" }}`,fg:`foreground`},directoryPaletteControl:{template:`🎨 directory {{ menu "applyDirectoryPaletteForever" "▸" "▾" }} {{ action "resetDirectoryPalette" "↺" }}`,fg:`foreground`}},root:{rows:{identity:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`toolbar`},{kind:`group`,name:`settings`,label:`⚙ terminal`,direction:`horizontal`,children:[`charsetControl`,`colorCompatControl`,`directoryPaletteControl`]}]},status:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`}]}}},actions:{copySession:{copy:`{{ .session.id }}`},copyDir:{copy:`{{ .current_dir }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},applyCharsetForever:{persist:`charset`,from:`charsets`},resetCharset:{reset:`charset`},applyColorCompatForever:{persist:`colorCompatibility`,from:`colorCompatibilities`},resetColorCompat:{reset:`colorCompatibility`},applyDirectoryPaletteForever:{persist:`segments.directory.palette`,from:`themes`},resetDirectoryPalette:{reset:`segments.directory.palette`}},looks:{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:`git`},{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:`segment`,name:`toolbar`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{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`}]}]}}},editGlobals:{style:`plain`,default_separator:` | `},helpers:{formatCost:'{{ if lt . 0.01 }}<$0.01{{ else }}${{ printf "%.2f" . }}{{ end }}',formatTokenCount:`{{ if ge . 1000000 }}{{ printf "%.1f" (divf . 1000000) }}M{{ else if ge . 1000 }}{{ printf "%.1f" (divf . 1000) }}K{{ else }}{{ . }}{{ end }}`,formatTokens:`{{ template "formatTokenCount" . }} tokens`,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 .)) }}`}},fw=new Set([dw.globals.palette,...Object.values(dw.segments).map(e=>e.palette)].filter(e=>e!==void 0)),pw=uo(hv(`<default>`,JSON.stringify(dw),fw),dw);var mw=pe((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:en}function r(){sn||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()===cn}function l(e){var t=e?.constructor;return!!t&&(t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`)}function u(e,t,n){nn(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function d(e,t,n){nn(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 rn.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(re())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&w(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,ie(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.
|
|
143
143
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ee(){return(ee=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 te(e){return(te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ne(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,w(e,t)}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch{}return(re=function(){return!!e})()}function w(e,t){return(w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function ie(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 T(e){var t=typeof Map==`function`?new Map:void 0;return(T=function(e){function n(){return b(e,arguments,te(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}}),w(n,e)})(e)}function E(e){return Object.assign((function(t,n){if(oe(n))return e.t(t,n);ae(t,n,e)}),e)}function ae(e,t,n){g(e,pn)||u(e,pn,ee({},e[pn])),function(e){return e.i===`override`}(n)||(e[pn][t]=n)}function oe(e){return typeof e==`object`&&typeof e.kind==`string`}function se(e,t,n){t===void 0&&(t=ln),n===void 0&&(n=ln);var r=new mn(e);return t!==ln&&dt(r,t),n!==ln&&ft(r,n),r}function ce(e,t,n){return xt(e)?e:Array.isArray(e)?R.array(e,{name:n}):c(e)?R.object(e,void 0,{name:n}):p(e)?R.map(e,{name:n}):m(e)?R.set(e,{name:n}):typeof e!=`function`||ct(e)||vt(e)?e:l(e)?tr(e):Yn(n,e)}function le(e){return e}function ue(e,t){return{i:e,u:t,o:de,s:fe,t:pe}}function de(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:ct(n.value)?1:(nn(r,t,me(e,this,t,n,!1)),2)}function fe(e,t,n,r){var i=me(e,this,t,n);return e.l(t,i,r)}function pe(e,n){var r,i=n.kind,a=n.name,o=n.addInitializer,s=this,c=function(e){var t;return Ne(s.u?.name??a.toString(),e,(t=s.u?.autoAction)!=null&&t)};return i==`field`?function(e){var t,n=e;return ct(n)||(n=c(n)),(t=s.u)!=null&&t.bound&&((n=n.bind(this)).isMobxAction=!0),n}:i==`method`?(ct(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+`):
|
|
144
|
-
'`+s.i+`' can only be used on properties with a function value.`)}function me(e,t,n,r,i){var a,o,s;i===void 0&&(i=B.safeDescriptors);var c=r.value;return(a=t.u)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:Ne(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 he(e,t){return{i:e,u:t,o:D,s:ge,t:_e}}function D(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)||!vt(e.h[t]))&&this.s(e,t,n,!1)===null?0:vt(n.value)?1:(nn(r,t,ve(e,0,0,n,!1,!1)),2)}function ge(e,t,n,r){var i=ve(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 vt(e)||(e=tr(e)),(n=this.u)!=null&&n.bound&&i((function(){var e=this[r].bind(this);e.isMobXFlow=!0,this[r]=e})),e}function ve(e,t,n,r,i,a){a===void 0&&(a=B.safeDescriptors);var o=r.value;return vt(o)||(o=tr(o)),i&&((o=o.bind(e.v??e.h)).isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function ye(e,t){return{i:e,u:t,o:be,s:xe,t:Se}}function be(e,t,n){return this.s(e,t,n,!1)===null?0:1}function xe(e,t,n,r){return e.m(t,ee({},this.u,{get:n.get,set:n.set}),r)}function Se(e,t){var n=this,r=t.name;return(0,t.addInitializer)((function(){var t=Vt(this)[I],i=ee({},n.u,{get:e,context:this});i.name||=`ObservableObject.`+r.toString(),t.j.set(r,new Pn(i))})),function(){return this[I].O(r)}}function Ce(e,t){return{i:e,u:t,o:we,s:Te,t:Ee}}function we(e,t,n){return this.s(e,t,n,!1)===null?0:1}function Te(e,t,n,r){return e.g(t,n.value,this.u?.enhancer??ce,r)}function Ee(e,t){function n(e,t){var n=Vt(e)[I],i=new Mn(t,r.u?.enhancer??ce,`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 De(e){return{i:`true`,u:e,o:Oe,s:ke,t:Ae}}function Oe(e,t,n,r){var i,a,o;if(n.get)return Dn.o(e,t,n,r);if(n.set){var s=ct(n.set)?n.set:Ne(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!B.safeDescriptors||e.p,set:s})===null?0:2:(nn(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?tr.bound:tr).o(e,t,n,r):((a=this.u)!=null&&a.autoBind?Yn.bound:Yn).o(e,t,n,r);var c=!1===this.u?.deep?R.ref:R;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 ke(e,t,n,r){var i;return n.get?Dn.s(e,t,n,r):n.set?e.l(t,{configurable:!B.safeDescriptors||e.p,set:Ne(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?R.ref:R).s(e,t,n,r))}function Ae(){t(`'`+this.i+`' cannot be used as a decorator`)}function je(e){return e||yn}function O(e){return!0===e.deep?ce:!1===e.deep?le:(t=e.defaultDecorator)&&(n=(r=t.u)?.enhancer)!=null?n:ce;var t,n,r}function Me(e,t,n){return oe(t)?bn.t(e,t):o(t)?void ae(e,t,bn):xt(e)?e:c(e)?R.object(e,t,n):Array.isArray(e)?R.array(e,t):p(e)?R.map(e,t):m(e)?R.set(e,t):typeof e==`object`&&e?e:R.box(e,t)}function Ne(e,t,n,r){function i(){return Pe(0,n,t,r||this,arguments)}return n===void 0&&(n=!1),i.isMobxAction=!0,i.toString=function(){return t.toString()},An&&(jn.value=e,nn(i,`name`,jn)),i}function Pe(e,t,n,r,i){var a=Fe(0,t);try{return n.apply(r,i)}catch(e){throw a._=e,e}finally{Ie(a)}}function Fe(e,t){var n=B.trackingDerivation,r=!t||!n;$e();var i=B.allowStateChanges;r&&(Ge(),i=Re(!0));var a={A:r,k:n,M:i,V:qe(!0),R:!1,N:0,T:kn++,C:On};return On=a.T,a}function Ie(e){On!==e.T&&t(30),On=e.C,e._!==void 0&&(B.suppressReactionErrors=!0),ze(e.M),Je(e.V),et(),e.A&&Ke(e.k),B.suppressReactionErrors=!1}function Le(e,t){var n=Re(e);try{return t()}finally{ze(n)}}function Re(e){var t=B.allowStateChanges;return B.allowStateChanges=e,t}function ze(e){B.allowStateChanges=e}function Be(e){return e instanceof Ln}function Ve(e){switch(e.I){case z.L:return!1;case z.P:case z.K:return!0;case z.B:for(var t=qe(!0),n=Ge(),r=e.D,i=r.length,a=0;a<i;a++){var o=r[a];if(In(o)){if(B.disableErrorBoundaries)o.get();else try{o.get()}catch{return Ke(n),Je(t),!0}if(e.I===z.K)return Ke(n),Je(t),!0}}return Ye(e),Ke(n),Je(t),!1}}function He(e,t,n){var r=qe(!0);Ye(e),e.W=Array(e.q===0?100:e.D.length),e.G=0,e.q=++B.runId;var i,a=B.trackingDerivation;if(B.trackingDerivation=e,B.inBatch++,!0===B.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new Ln(e)}return B.inBatch--,B.trackingDerivation=a,function(e){for(var t=e.D,n=e.D=e.W,r=z.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&&Ze(c,e),c.diffValue=0}for(;i--;){var l=n[i];l.diffValue===1&&(l.diffValue=0,Xe(l,e))}r!==z.L&&(e.I=r,e.H())}(e),Je(r),i}function Ue(e){var t=e.D;e.D=[];for(var n=t.length;n--;)Ze(t[n],e);e.I=z.P}function We(e){var t=Ge();try{return e()}finally{Ke(t)}}function Ge(){var e=B.trackingDerivation;return B.trackingDerivation=null,e}function Ke(e){B.trackingDerivation=e}function qe(e){var t=B.allowStateReads;return B.allowStateReads=e,t}function Je(e){B.allowStateReads=e}function Ye(e){if(e.I!==z.L){e.I=z.L;for(var t=e.D,n=t.length;n--;)t[n].U=z.L}}function Xe(e,t){e.F.add(t),e.U>t.I&&(e.U=t.I)}function Ze(e,t){e.F.delete(t),e.F.size===0&&Qe(e)}function Qe(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,B.pendingUnobservations.push(e))}function $e(){B.inBatch++}function et(){if(--B.inBatch==0){rt();for(var e=B.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 Pn&&n.X())}B.pendingUnobservations=[]}}function tt(e){var t=B.trackingDerivation;return t===null?(e.F.size===0&&B.inBatch>0&&Qe(e),!1):(t.q!==e.$&&(e.$=t.q,t.W[t.G++]=e,!e.isBeingObserved&&B.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function nt(e){e.U!==z.K&&(e.U=z.K,e.F.forEach((function(e){e.I===z.L&&e.H(),e.I=z.K})))}function rt(){B.inBatch>0||B.isRunningReactions||Un(it)}function it(){B.isRunningReactions=!0;for(var e=B.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()}B.isRunningReactions=!1}function at(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}}function ot(e){return function(t,n){return a(t)?Ne(t.name||`<unnamed action>`,t,e):a(n)?Ne(t,n,e):oe(n)?(e?V:Gn).t(t,n):o(n)?ae(t,n,e?V:Gn):o(t)?E(ue(e?`autoAction`:`action`,{name:t,autoAction:e})):void 0}}function st(e){return Pe(0,!1,e,this,void 0)}function ct(e){return a(e)&&!0===e.isMobxAction}function lt(e,t){function n(){e(i)}var r;t===void 0&&(t=on);var i,a=t?.name??`Autorun`;if(t.scheduler||t.delay){var o=ut(t),s=!1;i=new Hn(a,(function(){s||(s=!0,o((function(){s=!1,i.isDisposed||i.track(n)})))}),t.onError,t.requiresObservable)}else i=new Hn(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 ut(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:Xn}function dt(e,t,n){return pt(`onBO`,e,t,n)}function ft(e,t,n){return pt(`onBUO`,e,t,n)}function pt(e,t,n,r){var i=typeof r==`function`?Jt(t,n):Jt(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 mt(e,t,n,r){var i=fn(t);return Xt((function(){var t=Vt(e,r)[I];dn(i).forEach((function(e){t.s(e,i[e],!n||!(e in n)||n[e])}))})),e}function ht(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(ht)),n}function gt(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(gt)),t}function _t(e){a(e.cancel)&&e.cancel()}function vt(e){return!0===e?.isMobXFlow}function yt(e,t){return t===void 0?In(e):!1===Ut(e)||!e[I].j.has(t)?!1:In(Jt(e,t))}function bt(e,t){return!!e&&(t===void 0?Ut(e)||!!e[I]||hn(e)||Wn(e)||In(e):!!Ut(e)&&e[I].j.has(t))}function xt(e){return bt(e)}function St(e){return Ut(e)?e[I].nt():H(e)||gr(e)?Array.from(e.keys()):Rt(e)?e.map((function(e,t){return t})):void t(5)}function Ct(e,n){return Ut(e)?e[I].it(n):H(e)||gr(e)?e.has(n):Rt(e)?n>=0&&n<e.length:void t(10)}function wt(e){if(Ut(e))return e[I].rt();t(38)}function Tt(e,t,n){return e.set(t,n),n}function Et(e,t){t===void 0&&(t=void 0),$e();try{return e.apply(t)}finally{et()}}function Dt(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=Ne(`When-effect`,t),o=lt((function(t){Le(!1,e)&&(t.dispose(),r&&clearTimeout(r),a())}),n);return o}function Ot(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=Dt(e,n,ee({},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 kt(e){return e[I]}function At(e){return e.et!==void 0&&e.et.length>0}function jt(e,t){var n=e.et||=[];return n.push(t),i((function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)}))}function Mt(e,n){var r=Ge();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{Ke(r)}}function Nt(e){return e.ut!==void 0&&e.ut.length>0}function Pt(e,t){var n=e.ut||=[];return n.push(t),i((function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)}))}function Ft(e,t){var n=Ge(),r=e.ut;if(r){for(var i=0,a=(r=r.slice()).length;i<a;i++)r[i](t);Ke(n)}}function It(e,t,n,i){return n===void 0&&(n=`ObservableArray`),i===void 0&&(i=!1),r(),Xt((function(){var r=new or(n,t,i,!1);d(r.j,I,r);var a=new Proxy(r.j,ar);return r.v=a,e&&e.length&&r.ot(0,0,e),a}))}function k(e,t){typeof Array.prototype[e]==`function`&&(sr[e]=t(e))}function A(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)&&ur(e[I])}function zt(e){return e[Symbol.toStringTag]=`MapIterator`,$t(e)}function Bt(e){return e[Symbol.toStringTag]=`SetIterator`,$t(e)}function Vt(e,t){if(g(e,I))return e;var n=t?.name??`ObservableObject`;return u(e,I,new vr(e,new Map,String(n),function(e){return e?e.defaultDecorator??De(e):void 0}(t))),e}function Ht(e){return _r[e]||(_r[e]={get:function(){return this[I].O(e)},set:function(t){return this[I].S(e,t)}})}function Ut(e){return!!s(e)&&yr(e[I])}function Wt(e,t,n){var r;(r=e.h[pn])==null||delete r[n]}function Gt(e){return{enumerable:!1,configurable:!0,get:function(){return this[I].ct(e)},set:function(t){this[I].ht(e,t)}}}function Kt(e){nn(Cr.prototype,``+e,Gt(e))}function qt(e){if(e>xr){for(var t=xr;t<e+100;t++)Kt(t);xr=e}}function M(e,t,n){return new Cr(e,t,n)}function Jt(e,n){if(typeof e==`object`&&e){if(Rt(e))return n!==void 0&&t(23),e[I].st;if(gr(e))return e.st;if(H(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(Ut(e)){if(!n)return t(26);var i=e[I].j.get(n);return i||t(27,n,Yt(e)),i}if(hn(e)||In(e)||Wn(e))return e}else if(a(e)&&Wn(e[I]))return e[I];t(28)}function N(e,n){return e||t(29),n===void 0?hn(e)||In(e)||Wn(e)||H(e)||gr(e)?e:e[I]?e[I]:void t(24,e):N(Jt(e,n))}function Yt(e,t){var n;if(t!==void 0)n=Jt(e,t);else{if(ct(e))return e.name;n=Ut(e)||H(e)||gr(e)?N(e):Jt(e)}return n.tt}function Xt(e){var t=Ge(),n=Re(!0);$e();try{return e()}finally{et(),ze(n),Ke(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=wr.call(t);if(c!==wr.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)||H(e)||m(e)||gr(e)?Array.from(e.entries()):e}function $t(e){return e[Symbol.iterator]=P,Object.assign(Object.create(Tr),e)}function P(){return this}Object.defineProperty(e,`__esModule`,{value:!0});var en={},F=Object.assign,tn=Object.getOwnPropertyDescriptor,nn=Object.defineProperty,rn=Object.prototype,an=[];Object.freeze(an);var on={};Object.freeze(on);var sn=typeof Proxy<`u`,cn=Object.toString(),ln=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]=tn(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=z.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 tt(this)},t.reportChanged=function(){$e(),nt(this),et()},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=E({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=De(),yn={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(yn);var bn=Ce(`observable`),xn=Ce(`observable.ref`,{enhancer:le}),L=Ce(`observable.shallow`,{enhancer:function(e,t,n){return e==null||Ut(e)||Rt(e)||H(e)||gr(e)?e:Array.isArray(e)?R.array(e,{name:n,deep:!1}):c(e)?R.object(e,void 0,{name:n,deep:!1}):p(e)?R.map(e,{name:n,deep:!1}):m(e)?R.set(e,{name:n,deep:!1}):void 0}}),Sn=Ce(`observable.struct`,{enhancer:function(e,t){return Zt(e,t)?t:e}}),Cn=E(bn);F(Me,Cn);var wn,R=F(Me,{box:function(e,t){var n=je(t);return new Mn(e,O(n),n.name,!0,n.equals)},array:function(e,t){var n=je(t);return(!1===B.useProxies||!1===n.proxy?M:It)(e,O(n),n.name)},map:function(e,t){var n=je(t);return new pr(e,O(n),n.name)},set:function(e,t){var n=je(t);return new hr(e,O(n),n.name)},object:function(e,t,n){return Xt((function(){return mt(!1===B.useProxies||!1===n?.proxy?Vt({},n):function(e,t){var n;return r(),(n=(e=Vt(e,t))[I]).v??(n.v=new Proxy(e,nr))}({},n),e,t)}))},ref:E(xn),shallow:E(L),deep:Cn,struct:E(Sn)}),Tn=ye(`computed`),En=ye(`computed.struct`,{equals:gn.structural}),Dn=function(e,t){if(oe(t))return Tn.t(e,t);if(o(t))return ae(e,t,Tn);if(c(e))return E(ye(`computed`,e));var n=c(t)?t:{};return n.get=e,n.name||=e.name||``,new Pn(n)};Object.assign(Dn,Tn),Dn.struct=E(En);var On=0,kn=1,An=(wn=tn((function(){}),`name`)?.configurable)!=null&&wn,jn={value:`action`,configurable:!0,writable:!1,enumerable:!1},Mn=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}ne(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))!==B.UNCHANGED&&this.gt(e)},n.xt=function(e){if(At(this)){var t=Mt(this,{object:this,type:ir,newValue:e});if(!t)return B.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.Ot,this.tt),this.equals(this.Ot,e)?B.UNCHANGED:e},n.gt=function(e){var t=this.Ot;this.Ot=e,this.reportChanged(),Nt(this)&&Ft(this,{type:ir,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.Ot)},n.St=function(e){return jt(this,e)},n._t=function(e,t){return t&&e({observableKind:`value`,debugObjectName:this.tt,object:this,type:ir,newValue:this.Ot,oldValue:void 0}),Pt(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),Nn=f(`ObservableValue`,Mn),Pn=function(){function e(e){this.I=z.P,this.D=[],this.W=null,this.F=new Set,this.q=0,this.$=0,this.U=z.L,this.G=0,this.Ot=new Ln(null),this.tt=void 0,this.At=void 0,this.bt=0,this.derivation=void 0,this.kt=void 0,this.Mt=Fn.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=Ne(`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===z.L&&(e.U=z.B,e.F.forEach((function(e){e.I===z.L&&(e.I=z.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),B.inBatch!==0||this.F.size!==0||this.Nt){if(tt(this),Ve(this)){var e=B.trackingContext;this.Nt&&!e&&(B.trackingContext=this),this.trackAndCompute()&&function(e){e.U!==z.K&&(e.U=z.K,e.F.forEach((function(t){t.I===z.B?t.I=z.K:t.I===z.L&&(e.U=z.L)})))}(this),B.trackingContext=e}}else Ve(this)&&(this.Tt(),$e(),this.Ot=this.Ct(!1),et());var n=this.Ot;if(Be(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===z.P,n=this.Ct(!0),r=t||Be(e)||Be(n)||!this.Vt(e,n);return r&&(this.Ot=n),r},n.Ct=function(e){this.isComputing=!0;var t,n=Re(!1);if(e)t=He(this,this.derivation,this.Et);else if(!0===B.disableErrorBoundaries)t=this.derivation.call(this.Et);else try{t=this.derivation.call(this.Et)}catch(e){t=new Ln(e)}return ze(n),this.isComputing=!1,t},n.X=function(){this.Nt||(Ue(this),this.Ot=void 0)},n._t=function(e,t){var n=this,r=!0,i=void 0;return lt((function(){var a=n.get();if(!r||t){var o=Ge();e({observableKind:`computed`,debugObjectName:n.tt,type:ir,object:n,newValue:a,oldValue:i}),Ke(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)}}])}();Pn.It=1,Pn.Lt=2,Pn.pt=4,Pn.yt=8,Pn.wt=16;var z,Fn,In=f(`ComputedValue`,Pn);(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_`})(z||={}),function(e){e[e.NONE=0]=`NONE`,e[e.LOG=1]=`LOG`,e[e.BREAK=2]=`BREAK`}(Fn||={});var Ln=function(e){this.cause=void 0,this.cause=e},Rn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`,`useProxies`],zn=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,Vn=!1,B=function(){var e=n();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Bn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==new zn().version&&(Bn=!1),Bn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new zn):(setTimeout((function(){Vn||t(35)}),1),new zn)}(),Hn=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=z.P,this.q=0,this.G=0,this.bt=0,this.Mt=Fn.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,B.pendingReactions.push(this),rt())},t.J=function(){if(!this.isDisposed){$e(),this.isScheduled=!1;var e=B.trackingContext;if(B.trackingContext=this,Ve(this)){this.isTrackPending=!0;try{this.Pt()}catch(e){this.Dt(e)}}B.trackingContext=e,et()}},t.track=function(e){if(!this.isDisposed){$e(),this.isRunning=!0;var t=B.trackingContext;B.trackingContext=this;var n=He(this,e,void 0);B.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Ue(this),Be(n)&&this.Dt(n.cause),et()}},t.Dt=function(e){var t=this;if(this.Kt)this.Kt(e,this);else{if(B.disableErrorBoundaries)throw e;B.suppressReactionErrors||console.error(`[mobx] uncaught error in '`+this+`'`,e),B.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},t.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||($e(),Ue(this),et()))},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)}}])}();Hn.Wt=1,Hn.qt=2,Hn.Gt=4,Hn.Ht=8,Hn.wt=16;var Un=function(e){return e()},Wn=f(`Reaction`,Hn),Gn=ue(`action`),Kn=ue(`action.bound`,{bound:!0}),V=ue(`autoAction`,{autoAction:!0}),qn=ue(`autoAction.bound`,{autoAction:!0,bound:!0}),Jn=ot(!1);Object.assign(Jn,Gn);var Yn=ot(!0);Object.assign(Yn,V),Jn.bound=E(Kn),Yn.bound=E(qn);var Xn=function(e){return e()},Zn=0,Qn=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 ne(t,e),t.prototype.toString=function(){return`Error: `+this.message},t}(T(Error)),$n=he(`flow`),er=he(`flow.bound`,{bound:!0}),tr=Object.assign((function(e,t){if(oe(t))return $n.t(e,t);if(o(t))return ae(e,t,$n);var n=e,r=n.name||`<unnamed flow>`,i=function(){var e,t=this,i=arguments,o=++Zn,s=Jn(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=Jn(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=Jn(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=Jn(r+` - runid: `+o+` - cancel`,(function(){try{c&&_t(c);var t=s.return(void 0),n=Promise.resolve(t.value);n.then(ln,ln),_t(n),e(new Qn)}catch(t){e(t)}})),l};return i.isMobXFlow=!0,i}),$n);tr.bound=E(er);var nr={has:function(e,t){return kt(e).it(t)},get:function(e,t){return kt(e).ct(t)},set:function(e,t,n){var r;return!!o(t)&&((r=kt(e).ht(t,n,!0))==null||r)},deleteProperty:function(e,t){var n;return!!o(t)&&((n=kt(e).Ut(t,!0))==null||n)},defineProperty:function(e,t,n){var r;return(r=kt(e).l(t,n))==null||r},ownKeys:function(e){return kt(e).rt()},preventExtensions:function(){t(13)}},rr=Symbol(`mobx-keys`),ir=`update`,ar={get:function(e,t){var n=e[I];return t===I?n:t===`length`?n.Ft():typeof t!=`string`||isNaN(t)?g(sr,t)?sr[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)}},or=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 jt(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}),Pt(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&&qt(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=an),At(this)){var a=Mt(this,{object:this.v,type:`splice`,index:e,removedCount:t,added:n});if(!a)return an;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=Nt(this),a=i||r?{observableKind:`array`,object:this.v,type:ir,debugObjectName:this.st.tt,index:e,newValue:t,oldValue:n}:null;this.st.reportChanged(),i&&Ft(this,a)},n.nn=function(e,t,n){var r=!this.zt&&!1,i=Nt(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&&Ft(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(At(this)){var a=Mt(this,{type:ir,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}(),sr={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 B.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort:function(){B.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)}};k(`at`,A),k(`concat`,A),k(`flat`,A),k(`includes`,A),k(`indexOf`,A),k(`join`,A),k(`lastIndexOf`,A),k(`slice`,A),k(`toString`,A),k(`toLocaleString`,A),k(`toSorted`,A),k(`toSpliced`,A),k(`with`,A),k(`every`,j),k(`filter`,j),k(`find`,j),k(`findIndex`,j),k(`findLast`,j),k(`findLastIndex`,j),k(`flatMap`,j),k(`forEach`,j),k(`map`,j),k(`some`,j),k(`toReversed`,j),k(`reduce`,Lt),k(`reduceRight`,Lt);var cr,lr,ur=f(`ObservableArrayAdministration`,or),dr={},fr=`add`,pr=function(){function e(e,n,r){var i=this;n===void 0&&(n=ce),r===void 0&&(r=`ObservableMap`),this.Jt=void 0,this.tt=void 0,this[I]=dr,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=se(`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(!B.trackingDerivation)return this.it(e);var n=this.dt.get(e);if(!n){var r=n=new Mn(this.it(e),le,`ObservableMap.key?`,!1);this.dt.set(e,r),ft(r,(function(){return t.dt.delete(e)}))}return n.get()},n.set=function(e,t){var n=this.it(e);if(At(this)){var r=Mt(this,{type:n?ir:fr,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(At(this)&&!Mt(this,{type:`delete`,object:this,name:e}))return!1;if(this.it(e)){var n=Nt(this),r=n?{observableKind:`map`,debugObjectName:this.tt,type:`delete`,object:this,oldValue:this.vt.get(e).Ot,name:e}:null;return Et((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&&Ft(this,r),!0}return!1},n.rn=function(e,t){var n=this.vt.get(e);if((t=n.xt(t))!==B.UNCHANGED){var r=Nt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:ir,object:this,oldValue:n.Ot,name:e,newValue:t}:null;n.gt(t),r&&Ft(this,i)}},n.en=function(e,t){var n=this;Et((function(){var r,i=new Mn(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=Nt(this);r&&Ft(this,r?{observableKind:`map`,debugObjectName:this.tt,type:fr,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 H(e)&&(e=new Map(e)),Et((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 rn.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;Et((function(){We((function(){for(var t,n=C(e.keys());!(t=n()).done;)e.delete(t.value)}))}))},n.replace=function(e){var n=this;return Et((function(){for(var r,i=function(e){if(p(e)||H(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 Pt(this,e)},n.St=function(e){return jt(this,e)},S(e,[{key:`size`,get:function(){return this.lt.reportObserved(),this.vt.size}},{key:Symbol.toStringTag,get:function(){return`Map`}}])}(),H=f(`ObservableMap`,pr),mr={},hr=function(){function e(e,n,r){var i=this;n===void 0&&(n=ce),r===void 0&&(r=`ObservableSet`),this.tt=void 0,this[I]=mr,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=se(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;Et((function(){We((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(At(this)){var n=Mt(this,{type:fr,object:this,newValue:e});if(!n)return this;e=n.newValue}if(!this.has(e)){Et((function(){t.vt.add(t.Jt(e,void 0)),t.st.reportChanged()}));var r=Nt(this);r&&Ft(this,r?{observableKind:`set`,debugObjectName:this.tt,type:fr,object:this,newValue:e}:null)}return this},n.delete=function(e){var t=this;if(At(this)&&!Mt(this,{type:`delete`,object:this,oldValue:e}))return!1;if(this.has(e)){var n=Nt(this),r=n?{observableKind:`set`,debugObjectName:this.tt,type:`delete`,object:this,oldValue:e}:null;return Et((function(){t.st.reportChanged(),t.vt.delete(e)})),n&&Ft(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 Bt({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 Bt({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)&&!gr(e)?e.intersection(this):new Set(this).intersection(e)},n.union=function(e){return m(e)&&!gr(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)&&!gr(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)&&!gr(e)?e.isDisjointFrom(this):new Set(this).isDisjointFrom(e)},n.replace=function(e){var n=this;return gr(e)&&(e=new Set(e)),Et((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 Pt(this,e)},n.St=function(e){return jt(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`}}])}(),gr=f(`ObservableSet`,hr),_r=Object.create(null),vr=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 Pn)return n.set(t),!0;if(At(this)){var r=Mt(this,{type:ir,object:this.v||this.h,name:e,newValue:t});if(!r)return null;t=r.newValue}if((t=n.xt(t))!==B.UNCHANGED){var i=Nt(this),a=i?{type:ir,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.Ot,name:e,newValue:t}:null;n.gt(t),i&&Ft(this,a)}return!0},n.ct=function(e){return B.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(!B.trackingDerivation)return e in this.h;this.sn||=new Map;var t=this.sn.get(e);return t||(t=new Mn(e in this.h,le,`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!==rn;){var a=tn(i,e);if(a){var o=n.o(this,e,a,i);if(o===0)return;if(o===1)break}i=Object.getPrototypeOf(i)}Wt(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&&Wt(this,0,e),i},n.l=function(e,t,n){n===void 0&&(n=!1);try{$e();var r=this.Ut(e);if(!r)return r;if(At(this)){var i=Mt(this,{object:this.v||this.h,name:e,type:fr,newValue:t.value});if(!i)return null;var a=i.newValue;t.value!==a&&(t=ee({},t,{value:a}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else nn(this.h,e,t);this.fn(e,t.value)}finally{et()}return!0},n.g=function(e,t,n,r){r===void 0&&(r=!1);try{$e();var i=this.Ut(e);if(!i)return i;if(At(this)){var a=Mt(this,{object:this.v||this.h,name:e,type:fr,newValue:t});if(!a)return null;t=a.newValue}var o=Ht(e),s={configurable:!B.safeDescriptors||this.p,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.h,e,s))return!1}else nn(this.h,e,s);var c=new Mn(t,n,`ObservableObject.key`,!1);this.j.set(e,c),this.fn(e,c.Ot)}finally{et()}return!0},n.m=function(e,t,n){n===void 0&&(n=!1);try{$e();var r=this.Ut(e);if(!r)return r;if(At(this)&&!Mt(this,{object:this.v||this.h,name:e,type:fr,newValue:void 0}))return null;t.name||=`ObservableObject.key`,t.context=this.v||this.h;var i=Ht(e),a={configurable:!B.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else nn(this.h,e,a);this.j.set(e,new Pn(t)),this.fn(e,void 0)}finally{et()}return!0},n.Ut=function(e,t){if(t===void 0&&(t=!1),!g(this.h,e))return!0;if(At(this)&&!Mt(this,{object:this.v||this.h,name:e,type:`remove`}))return null;try{var n;$e();var r=Nt(this),i=this.j.get(e),a=void 0;if(!i&&r&&(a=tn(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 Mn&&(a=i.Ot),nt(i)),this.lt.reportChanged(),(n=this.sn)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&Ft(this,{type:`remove`,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{et()}return!0},n._t=function(e){return Pt(this,e)},n.St=function(e){return jt(this,e)},n.fn=function(e,t){var n,r=Nt(this);r&&r&&Ft(this,r?{type:fr,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}(),yr=f(`ObservableObjectAdministration`,vr),br=Gt(0),U=function(){var e=!1,t={};return Object.defineProperty(t,`0`,{set:function(){e=!0}}),Object.create(t)[0]=1,!1===e}(),xr=0,Sr=function(){};cr=Sr,lr=Array.prototype,Object.setPrototypeOf?Object.setPrototypeOf(cr.prototype,lr):cr.prototype.__proto__===void 0?cr.prototype=lr:cr.prototype.__proto__=lr;var Cr=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 or(r,n,i,!0);e.v=a,d(a,I,e),t&&t.length&&a.spliceWithArray(0,0,t),U&&Object.defineProperty(a,`0`,br)})),a}ne(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`}}])}(Sr);Object.entries(sr).forEach((function(e){var t=e[0];t!==`concat`&&u(Cr.prototype,t,e[1])})),qt(1e3);var wr=rn.toString,Tr=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:at,extras:{getDebugName:Yt},$mobx:I}),e.$mobx=I,e.FlowCancellationError=Qn,e.ObservableMap=pr,e.ObservableSet=hr,e.Reaction=Hn,e._allowStateChanges=Le,e._allowStateChangesInsideComputed=st,e._allowStateReadsEnd=Je,e._allowStateReadsStart=qe,e._autoAction=Yn,e._endAction=Ie,e._getAdministration=N,e._getGlobalState=function(){return B},e._interceptReads=function(e,t,n){var r;return H(e)||Rt(e)||Nn(e)?r=N(e):Ut(e)&&(r=N(e,t)),r.dehancer=typeof t==`function`?t:n,function(){r.dehancer=void 0}},e._isComputingDerivation=function(){return B.trackingDerivation!==null},e._resetGlobalState=function(){var e=new zn;for(var t in e)Rn.indexOf(t)===-1&&(B[t]=e[t]);B.allowStateChanges=!B.enforceActions},e._startAction=Fe,e.action=Jn,e.autorun=lt,e.comparer=gn,e.computed=Dn,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((B.pendingReactions.length||B.inBatch||B.isRunningReactions)&&t(36),Vn=!0,Bn){var e=n();--e.__mobxInstanceCount==0&&(e.__mobxGlobals=void 0),B=new zn}}();var r,i,a=e.useProxies,o=e.enforceActions;if(a!==void 0&&(B.useProxies=a===`always`||a!==`never`&&typeof Proxy<`u`),a===`ifavailable`&&(B.verifyProxies=!0),o!==void 0){var s=o===`always`?`always`:o===`observed`;B.enforceActions=s,B.allowStateChanges=!0!==s&&s!==`always`}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach((function(t){t in e&&(B[t]=!!e[t])})),B.allowStateReads=!B.observableRequiresReaction,e.reactionScheduler&&(r=e.reactionScheduler,i=Un,Un=function(e){return r((function(){return i(e)}))})},e.createAtom=se,e.defineProperty=function(e,n,r){if(Ut(e))return e[I].l(n,r);t(39)},e.entries=function(e){return Ut(e)?St(e).map((function(t){return[t,e[t]]})):H(e)?St(e).map((function(t){return[t,e.get(t)]})):gr(e)?Array.from(e.entries()):Rt(e)?e.map((function(e,t){return[t,e]})):void t(7)},e.extendObservable=mt,e.flow=tr,e.flowResult=function(e){return e},e.get=function(e,n){if(Ct(e,n))return Ut(e)?e[I].ct(n):H(e)?e.get(n):Rt(e)?e[n]:void t(11)},e.getAtom=Jt,e.getDebugName=Yt,e.getDependencyTree=function(e,t){return ht(Jt(e,t))},e.getObserverTree=function(e,t){return gt(Jt(e,t))},e.has=Ct,e.intercept=function(e,t,n){return a(n)?function(e,t,n){return N(e,t).St(n)}(e,t,n):function(e,t){return N(e).St(t)}(e,t)},e.isAction=ct,e.isBoxedObservable=Nn,e.isComputed=function(e){return yt(e)},e.isComputedProp=function(e,t){return yt(e,t)},e.isFlow=vt,e.isFlowCancellationError=function(e){return e instanceof Qn},e.isObservable=xt,e.isObservableArray=Rt,e.isObservableMap=H,e.isObservableObject=Ut,e.isObservableProp=function(e,t){return bt(e,t)},e.isObservableSet=gr,e.keys=St,e.makeAutoObservable=function(e,t,n){return c(e)?mt(e,e,t,n):(Xt((function(){var r=Vt(e,n)[I];if(!e[rr]){var i=Object.getPrototypeOf(e),a=new Set([].concat(dn(e),dn(i)));a.delete(`constructor`),a.delete(I),u(i,rr,a)}e[rr].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=Vt(e,n)[I];t??=function(e){return g(e,pn)||u(e,pn,ee({},e[pn])),e[pn]}(e),dn(t).forEach((function(e){return r.o(e,t[e])}))})),e},e.observable=R,e.observe=function(e,t,n,r){return a(n)?function(e,t,n,r){return N(e,t)._t(n,r)}(e,t,n,r):function(e,t,n){return N(e)._t(t,n)}(e,t,n)},e.onBecomeObserved=dt,e.onBecomeUnobserved=ft,e.onReactionError=function(e){return B.globalReactionErrorHandlers.push(e),function(){var t=B.globalReactionErrorHandlers.indexOf(e);t>=0&&B.globalReactionErrorHandlers.splice(t,1)}},e.override=_n,e.ownKeys=wt,e.reaction=function(e,t,n){function r(){if(p=!1,!h.isDisposed){var t=!1,r=s;h.track((function(){var n=Le(!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=on);var a,o,s,c=n.name??`Reaction`,l=Jn(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=ut(n),f=!0,p=!1,m=n.compareStructural?gn.structural:n.equals||gn.default,h=new Hn(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){Ut(e)?e[I].Ut(n):H(e)||gr(e)?e.delete(n):Rt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=st,e.set=function e(n,r,i){if(arguments.length!==2||gr(n))Ut(n)?n[I].ht(r,i):H(n)?n.set(r,i):gr(n)?n.add(r):Rt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(`Invalid index: '`+r+`'`),$e(),r>=n.length&&(n.length=r+1),n[r]=i,et()):t(8);else{$e();var a=r;try{for(var o in a)e(n,o,a[o])}finally{et()}}},e.spy=at,e.toJS=function(e){return function e(t,n){if(typeof t!=`object`||!t||t instanceof Date||!xt(t))return t;if(Nn(t)||In(t))return e(t.get(),n);if(n.has(t))return n.get(t);if(Rt(t)){var r=Tt(n,t,Array(t.length));return t.forEach((function(t,i){r[i]=e(t,n)})),r}if(gr(t)){var i=Tt(n,t,new Set);return t.forEach((function(t){i.add(e(t,n))})),i}if(H(t)){var a=Tt(n,t,new Map);return t.forEach((function(t,r){a.set(r,e(t,n))})),a}var o=Tt(n,t,{});return wt(t).forEach((function(r){rn.propertyIsEnumerable.call(t,r)&&(o[r]=e(t[r],n))})),o}(e,new Map)},e.trace=function(){},e.transaction=Et,e.untracked=We,e.values=function(e){return Ut(e)?St(e).map((function(t){return e[t]})):H(e)?St(e).map((function(t){return e.get(t)})):gr(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`?Ot(e,t):Dt(e,t,n||{})}})),mw=pe((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 ee(e,t,n){s(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function te(e,t){var n=`isMobX`+e;return t.prototype[n]=!0,function(e){return b(e)&&e[n]===!0}}function ne(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function re(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function w(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}var ie=Object.getOwnPropertySymbols!==void 0;function T(e){var t=Object.keys(e);if(!ie)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter(function(t){return c.propertyIsEnumerable.call(e,t)})):t}var E=typeof Reflect<`u`&&Reflect.ownKeys?Reflect.ownKeys:ie?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function ae(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function oe(e){return e===null?null:typeof e==`object`?``+e:e}function se(e,t){return c.hasOwnProperty.call(e,t)}var ce=Object.getOwnPropertyDescriptors||function(e){var t={};return E(e).forEach(function(n){t[n]=o(e,n)}),t};function le(e,t){return!!(e&t)}function ue(e,t,n){return n?e|=t:e&=~t,e}function de(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 fe(e,t,n){if(ye())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&be(i,n.prototype),i}function pe(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,Se(r.key),r)}}function me(e,t,n){return t&&pe(e.prototype,t),n&&pe(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function he(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=Ce(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.
|
|
144
|
+
'`+s.i+`' can only be used on properties with a function value.`)}function me(e,t,n,r,i){var a,o,s;i===void 0&&(i=B.safeDescriptors);var c=r.value;return(a=t.u)!=null&&a.bound&&(c=c.bind(e.v??e.h)),{value:Ne(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 he(e,t){return{i:e,u:t,o:D,s:ge,t:_e}}function D(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)||!vt(e.h[t]))&&this.s(e,t,n,!1)===null?0:vt(n.value)?1:(nn(r,t,ve(e,0,0,n,!1,!1)),2)}function ge(e,t,n,r){var i=ve(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 vt(e)||(e=tr(e)),(n=this.u)!=null&&n.bound&&i((function(){var e=this[r].bind(this);e.isMobXFlow=!0,this[r]=e})),e}function ve(e,t,n,r,i,a){a===void 0&&(a=B.safeDescriptors);var o=r.value;return vt(o)||(o=tr(o)),i&&((o=o.bind(e.v??e.h)).isMobXFlow=!0),{value:o,configurable:!a||e.p,enumerable:!1,writable:!a}}function ye(e,t){return{i:e,u:t,o:be,s:xe,t:Se}}function be(e,t,n){return this.s(e,t,n,!1)===null?0:1}function xe(e,t,n,r){return e.m(t,ee({},this.u,{get:n.get,set:n.set}),r)}function Se(e,t){var n=this,r=t.name;return(0,t.addInitializer)((function(){var t=Vt(this)[I],i=ee({},n.u,{get:e,context:this});i.name||=`ObservableObject.`+r.toString(),t.j.set(r,new Pn(i))})),function(){return this[I].O(r)}}function Ce(e,t){return{i:e,u:t,o:we,s:Te,t:Ee}}function we(e,t,n){return this.s(e,t,n,!1)===null?0:1}function Te(e,t,n,r){return e.g(t,n.value,this.u?.enhancer??ce,r)}function Ee(e,t){function n(e,t){var n=Vt(e)[I],i=new Mn(t,r.u?.enhancer??ce,`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 De(e){return{i:`true`,u:e,o:Oe,s:ke,t:Ae}}function Oe(e,t,n,r){var i,a,o;if(n.get)return Dn.o(e,t,n,r);if(n.set){var s=ct(n.set)?n.set:Ne(t.toString(),n.set);return r===e.h?e.l(t,{configurable:!B.safeDescriptors||e.p,set:s})===null?0:2:(nn(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?tr.bound:tr).o(e,t,n,r):((a=this.u)!=null&&a.autoBind?Yn.bound:Yn).o(e,t,n,r);var c=!1===this.u?.deep?R.ref:R;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 ke(e,t,n,r){var i;return n.get?Dn.s(e,t,n,r):n.set?e.l(t,{configurable:!B.safeDescriptors||e.p,set:Ne(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?R.ref:R).s(e,t,n,r))}function Ae(){t(`'`+this.i+`' cannot be used as a decorator`)}function je(e){return e||yn}function O(e){return!0===e.deep?ce:!1===e.deep?le:(t=e.defaultDecorator)&&(n=(r=t.u)?.enhancer)!=null?n:ce;var t,n,r}function Me(e,t,n){return oe(t)?bn.t(e,t):o(t)?void ae(e,t,bn):xt(e)?e:c(e)?R.object(e,t,n):Array.isArray(e)?R.array(e,t):p(e)?R.map(e,t):m(e)?R.set(e,t):typeof e==`object`&&e?e:R.box(e,t)}function Ne(e,t,n,r){function i(){return Pe(0,n,t,r||this,arguments)}return n===void 0&&(n=!1),i.isMobxAction=!0,i.toString=function(){return t.toString()},An&&(jn.value=e,nn(i,`name`,jn)),i}function Pe(e,t,n,r,i){var a=Fe(0,t);try{return n.apply(r,i)}catch(e){throw a._=e,e}finally{Ie(a)}}function Fe(e,t){var n=B.trackingDerivation,r=!t||!n;$e();var i=B.allowStateChanges;r&&(Ge(),i=Re(!0));var a={A:r,k:n,M:i,V:qe(!0),R:!1,N:0,T:kn++,C:On};return On=a.T,a}function Ie(e){On!==e.T&&t(30),On=e.C,e._!==void 0&&(B.suppressReactionErrors=!0),ze(e.M),Je(e.V),et(),e.A&&Ke(e.k),B.suppressReactionErrors=!1}function Le(e,t){var n=Re(e);try{return t()}finally{ze(n)}}function Re(e){var t=B.allowStateChanges;return B.allowStateChanges=e,t}function ze(e){B.allowStateChanges=e}function Be(e){return e instanceof Ln}function Ve(e){switch(e.I){case z.L:return!1;case z.P:case z.K:return!0;case z.B:for(var t=qe(!0),n=Ge(),r=e.D,i=r.length,a=0;a<i;a++){var o=r[a];if(In(o)){if(B.disableErrorBoundaries)o.get();else try{o.get()}catch{return Ke(n),Je(t),!0}if(e.I===z.K)return Ke(n),Je(t),!0}}return Ye(e),Ke(n),Je(t),!1}}function He(e,t,n){var r=qe(!0);Ye(e),e.W=Array(e.q===0?100:e.D.length),e.G=0,e.q=++B.runId;var i,a=B.trackingDerivation;if(B.trackingDerivation=e,B.inBatch++,!0===B.disableErrorBoundaries)i=t.call(n);else try{i=t.call(n)}catch(e){i=new Ln(e)}return B.inBatch--,B.trackingDerivation=a,function(e){for(var t=e.D,n=e.D=e.W,r=z.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&&Ze(c,e),c.diffValue=0}for(;i--;){var l=n[i];l.diffValue===1&&(l.diffValue=0,Xe(l,e))}r!==z.L&&(e.I=r,e.H())}(e),Je(r),i}function Ue(e){var t=e.D;e.D=[];for(var n=t.length;n--;)Ze(t[n],e);e.I=z.P}function We(e){var t=Ge();try{return e()}finally{Ke(t)}}function Ge(){var e=B.trackingDerivation;return B.trackingDerivation=null,e}function Ke(e){B.trackingDerivation=e}function qe(e){var t=B.allowStateReads;return B.allowStateReads=e,t}function Je(e){B.allowStateReads=e}function Ye(e){if(e.I!==z.L){e.I=z.L;for(var t=e.D,n=t.length;n--;)t[n].U=z.L}}function Xe(e,t){e.F.add(t),e.U>t.I&&(e.U=t.I)}function Ze(e,t){e.F.delete(t),e.F.size===0&&Qe(e)}function Qe(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,B.pendingUnobservations.push(e))}function $e(){B.inBatch++}function et(){if(--B.inBatch==0){rt();for(var e=B.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 Pn&&n.X())}B.pendingUnobservations=[]}}function tt(e){var t=B.trackingDerivation;return t===null?(e.F.size===0&&B.inBatch>0&&Qe(e),!1):(t.q!==e.$&&(e.$=t.q,t.W[t.G++]=e,!e.isBeingObserved&&B.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function nt(e){e.U!==z.K&&(e.U=z.K,e.F.forEach((function(e){e.I===z.L&&e.H(),e.I=z.K})))}function rt(){B.inBatch>0||B.isRunningReactions||Un(it)}function it(){B.isRunningReactions=!0;for(var e=B.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()}B.isRunningReactions=!1}function at(){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}}function ot(e){return function(t,n){return a(t)?Ne(t.name||`<unnamed action>`,t,e):a(n)?Ne(t,n,e):oe(n)?(e?V:Gn).t(t,n):o(n)?ae(t,n,e?V:Gn):o(t)?E(ue(e?`autoAction`:`action`,{name:t,autoAction:e})):void 0}}function st(e){return Pe(0,!1,e,this,void 0)}function ct(e){return a(e)&&!0===e.isMobxAction}function lt(e,t){function n(){e(i)}var r;t===void 0&&(t=on);var i,a=t?.name??`Autorun`;if(t.scheduler||t.delay){var o=ut(t),s=!1;i=new Hn(a,(function(){s||(s=!0,o((function(){s=!1,i.isDisposed||i.track(n)})))}),t.onError,t.requiresObservable)}else i=new Hn(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 ut(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:Xn}function dt(e,t,n){return pt(`onBO`,e,t,n)}function ft(e,t,n){return pt(`onBUO`,e,t,n)}function pt(e,t,n,r){var i=typeof r==`function`?Jt(t,n):Jt(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 mt(e,t,n,r){var i=fn(t);return Xt((function(){var t=Vt(e,r)[I];dn(i).forEach((function(e){t.s(e,i[e],!n||!(e in n)||n[e])}))})),e}function ht(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(ht)),n}function gt(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(gt)),t}function _t(e){a(e.cancel)&&e.cancel()}function vt(e){return!0===e?.isMobXFlow}function yt(e,t){return t===void 0?In(e):!1===Ut(e)||!e[I].j.has(t)?!1:In(Jt(e,t))}function bt(e,t){return!!e&&(t===void 0?Ut(e)||!!e[I]||hn(e)||Wn(e)||In(e):!!Ut(e)&&e[I].j.has(t))}function xt(e){return bt(e)}function St(e){return Ut(e)?e[I].nt():H(e)||gr(e)?Array.from(e.keys()):Rt(e)?e.map((function(e,t){return t})):void t(5)}function Ct(e,n){return Ut(e)?e[I].it(n):H(e)||gr(e)?e.has(n):Rt(e)?n>=0&&n<e.length:void t(10)}function wt(e){if(Ut(e))return e[I].rt();t(38)}function Tt(e,t,n){return e.set(t,n),n}function Et(e,t){t===void 0&&(t=void 0),$e();try{return e.apply(t)}finally{et()}}function Dt(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=Ne(`When-effect`,t),o=lt((function(t){Le(!1,e)&&(t.dispose(),r&&clearTimeout(r),a())}),n);return o}function Ot(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=Dt(e,n,ee({},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 kt(e){return e[I]}function At(e){return e.et!==void 0&&e.et.length>0}function jt(e,t){var n=e.et||=[];return n.push(t),i((function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)}))}function Mt(e,n){var r=Ge();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{Ke(r)}}function Nt(e){return e.ut!==void 0&&e.ut.length>0}function Pt(e,t){var n=e.ut||=[];return n.push(t),i((function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)}))}function Ft(e,t){var n=Ge(),r=e.ut;if(r){for(var i=0,a=(r=r.slice()).length;i<a;i++)r[i](t);Ke(n)}}function It(e,t,n,i){return n===void 0&&(n=`ObservableArray`),i===void 0&&(i=!1),r(),Xt((function(){var r=new or(n,t,i,!1);d(r.j,I,r);var a=new Proxy(r.j,ar);return r.v=a,e&&e.length&&r.ot(0,0,e),a}))}function k(e,t){typeof Array.prototype[e]==`function`&&(sr[e]=t(e))}function A(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)&&ur(e[I])}function zt(e){return e[Symbol.toStringTag]=`MapIterator`,$t(e)}function Bt(e){return e[Symbol.toStringTag]=`SetIterator`,$t(e)}function Vt(e,t){if(g(e,I))return e;var n=t?.name??`ObservableObject`;return u(e,I,new vr(e,new Map,String(n),function(e){return e?e.defaultDecorator??De(e):void 0}(t))),e}function Ht(e){return _r[e]||(_r[e]={get:function(){return this[I].O(e)},set:function(t){return this[I].S(e,t)}})}function Ut(e){return!!s(e)&&yr(e[I])}function Wt(e,t,n){var r;(r=e.h[pn])==null||delete r[n]}function Gt(e){return{enumerable:!1,configurable:!0,get:function(){return this[I].ct(e)},set:function(t){this[I].ht(e,t)}}}function Kt(e){nn(Cr.prototype,``+e,Gt(e))}function qt(e){if(e>xr){for(var t=xr;t<e+100;t++)Kt(t);xr=e}}function M(e,t,n){return new Cr(e,t,n)}function Jt(e,n){if(typeof e==`object`&&e){if(Rt(e))return n!==void 0&&t(23),e[I].st;if(gr(e))return e.st;if(H(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(Ut(e)){if(!n)return t(26);var i=e[I].j.get(n);return i||t(27,n,Yt(e)),i}if(hn(e)||In(e)||Wn(e))return e}else if(a(e)&&Wn(e[I]))return e[I];t(28)}function N(e,n){return e||t(29),n===void 0?hn(e)||In(e)||Wn(e)||H(e)||gr(e)?e:e[I]?e[I]:void t(24,e):N(Jt(e,n))}function Yt(e,t){var n;if(t!==void 0)n=Jt(e,t);else{if(ct(e))return e.name;n=Ut(e)||H(e)||gr(e)?N(e):Jt(e)}return n.tt}function Xt(e){var t=Ge(),n=Re(!0);$e();try{return e()}finally{et(),ze(n),Ke(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=wr.call(t);if(c!==wr.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)||H(e)||m(e)||gr(e)?Array.from(e.entries()):e}function $t(e){return e[Symbol.iterator]=P,Object.assign(Object.create(Tr),e)}function P(){return this}Object.defineProperty(e,`__esModule`,{value:!0});var en={},F=Object.assign,tn=Object.getOwnPropertyDescriptor,nn=Object.defineProperty,rn=Object.prototype,an=[];Object.freeze(an);var on={};Object.freeze(on);var sn=typeof Proxy<`u`,cn=Object.toString(),ln=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]=tn(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=z.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 tt(this)},t.reportChanged=function(){$e(),nt(this),et()},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=E({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=De(),yn={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(yn);var bn=Ce(`observable`),xn=Ce(`observable.ref`,{enhancer:le}),L=Ce(`observable.shallow`,{enhancer:function(e,t,n){return e==null||Ut(e)||Rt(e)||H(e)||gr(e)?e:Array.isArray(e)?R.array(e,{name:n,deep:!1}):c(e)?R.object(e,void 0,{name:n,deep:!1}):p(e)?R.map(e,{name:n,deep:!1}):m(e)?R.set(e,{name:n,deep:!1}):void 0}}),Sn=Ce(`observable.struct`,{enhancer:function(e,t){return Zt(e,t)?t:e}}),Cn=E(bn);F(Me,Cn);var wn,R=F(Me,{box:function(e,t){var n=je(t);return new Mn(e,O(n),n.name,!0,n.equals)},array:function(e,t){var n=je(t);return(!1===B.useProxies||!1===n.proxy?M:It)(e,O(n),n.name)},map:function(e,t){var n=je(t);return new pr(e,O(n),n.name)},set:function(e,t){var n=je(t);return new hr(e,O(n),n.name)},object:function(e,t,n){return Xt((function(){return mt(!1===B.useProxies||!1===n?.proxy?Vt({},n):function(e,t){var n;return r(),(n=(e=Vt(e,t))[I]).v??(n.v=new Proxy(e,nr))}({},n),e,t)}))},ref:E(xn),shallow:E(L),deep:Cn,struct:E(Sn)}),Tn=ye(`computed`),En=ye(`computed.struct`,{equals:gn.structural}),Dn=function(e,t){if(oe(t))return Tn.t(e,t);if(o(t))return ae(e,t,Tn);if(c(e))return E(ye(`computed`,e));var n=c(t)?t:{};return n.get=e,n.name||=e.name||``,new Pn(n)};Object.assign(Dn,Tn),Dn.struct=E(En);var On=0,kn=1,An=(wn=tn((function(){}),`name`)?.configurable)!=null&&wn,jn={value:`action`,configurable:!0,writable:!1,enumerable:!1},Mn=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}ne(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))!==B.UNCHANGED&&this.gt(e)},n.xt=function(e){if(At(this)){var t=Mt(this,{object:this,type:ir,newValue:e});if(!t)return B.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.Ot,this.tt),this.equals(this.Ot,e)?B.UNCHANGED:e},n.gt=function(e){var t=this.Ot;this.Ot=e,this.reportChanged(),Nt(this)&&Ft(this,{type:ir,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.Ot)},n.St=function(e){return jt(this,e)},n._t=function(e,t){return t&&e({observableKind:`value`,debugObjectName:this.tt,object:this,type:ir,newValue:this.Ot,oldValue:void 0}),Pt(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),Nn=f(`ObservableValue`,Mn),Pn=function(){function e(e){this.I=z.P,this.D=[],this.W=null,this.F=new Set,this.q=0,this.$=0,this.U=z.L,this.G=0,this.Ot=new Ln(null),this.tt=void 0,this.At=void 0,this.bt=0,this.derivation=void 0,this.kt=void 0,this.Mt=Fn.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=Ne(`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===z.L&&(e.U=z.B,e.F.forEach((function(e){e.I===z.L&&(e.I=z.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),B.inBatch!==0||this.F.size!==0||this.Nt){if(tt(this),Ve(this)){var e=B.trackingContext;this.Nt&&!e&&(B.trackingContext=this),this.trackAndCompute()&&function(e){e.U!==z.K&&(e.U=z.K,e.F.forEach((function(t){t.I===z.B?t.I=z.K:t.I===z.L&&(e.U=z.L)})))}(this),B.trackingContext=e}}else Ve(this)&&(this.Tt(),$e(),this.Ot=this.Ct(!1),et());var n=this.Ot;if(Be(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===z.P,n=this.Ct(!0),r=t||Be(e)||Be(n)||!this.Vt(e,n);return r&&(this.Ot=n),r},n.Ct=function(e){this.isComputing=!0;var t,n=Re(!1);if(e)t=He(this,this.derivation,this.Et);else if(!0===B.disableErrorBoundaries)t=this.derivation.call(this.Et);else try{t=this.derivation.call(this.Et)}catch(e){t=new Ln(e)}return ze(n),this.isComputing=!1,t},n.X=function(){this.Nt||(Ue(this),this.Ot=void 0)},n._t=function(e,t){var n=this,r=!0,i=void 0;return lt((function(){var a=n.get();if(!r||t){var o=Ge();e({observableKind:`computed`,debugObjectName:n.tt,type:ir,object:n,newValue:a,oldValue:i}),Ke(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)}}])}();Pn.It=1,Pn.Lt=2,Pn.pt=4,Pn.yt=8,Pn.wt=16;var z,Fn,In=f(`ComputedValue`,Pn);(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_`})(z||={}),function(e){e[e.NONE=0]=`NONE`,e[e.LOG=1]=`LOG`,e[e.BREAK=2]=`BREAK`}(Fn||={});var Ln=function(e){this.cause=void 0,this.cause=e},Rn=[`mobxGuid`,`spyListeners`,`enforceActions`,`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`allowStateReads`,`disableErrorBoundaries`,`runId`,`UNCHANGED`,`useProxies`],zn=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,Vn=!1,B=function(){var e=n();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(Bn=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==new zn().version&&(Bn=!1),Bn?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new zn):(setTimeout((function(){Vn||t(35)}),1),new zn)}(),Hn=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=z.P,this.q=0,this.G=0,this.bt=0,this.Mt=Fn.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,B.pendingReactions.push(this),rt())},t.J=function(){if(!this.isDisposed){$e(),this.isScheduled=!1;var e=B.trackingContext;if(B.trackingContext=this,Ve(this)){this.isTrackPending=!0;try{this.Pt()}catch(e){this.Dt(e)}}B.trackingContext=e,et()}},t.track=function(e){if(!this.isDisposed){$e(),this.isRunning=!0;var t=B.trackingContext;B.trackingContext=this;var n=He(this,e,void 0);B.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&Ue(this),Be(n)&&this.Dt(n.cause),et()}},t.Dt=function(e){var t=this;if(this.Kt)this.Kt(e,this);else{if(B.disableErrorBoundaries)throw e;B.suppressReactionErrors||console.error(`[mobx] uncaught error in '`+this+`'`,e),B.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},t.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||($e(),Ue(this),et()))},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)}}])}();Hn.Wt=1,Hn.qt=2,Hn.Gt=4,Hn.Ht=8,Hn.wt=16;var Un=function(e){return e()},Wn=f(`Reaction`,Hn),Gn=ue(`action`),Kn=ue(`action.bound`,{bound:!0}),V=ue(`autoAction`,{autoAction:!0}),qn=ue(`autoAction.bound`,{autoAction:!0,bound:!0}),Jn=ot(!1);Object.assign(Jn,Gn);var Yn=ot(!0);Object.assign(Yn,V),Jn.bound=E(Kn),Yn.bound=E(qn);var Xn=function(e){return e()},Zn=0,Qn=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 ne(t,e),t.prototype.toString=function(){return`Error: `+this.message},t}(T(Error)),$n=he(`flow`),er=he(`flow.bound`,{bound:!0}),tr=Object.assign((function(e,t){if(oe(t))return $n.t(e,t);if(o(t))return ae(e,t,$n);var n=e,r=n.name||`<unnamed flow>`,i=function(){var e,t=this,i=arguments,o=++Zn,s=Jn(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=Jn(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=Jn(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=Jn(r+` - runid: `+o+` - cancel`,(function(){try{c&&_t(c);var t=s.return(void 0),n=Promise.resolve(t.value);n.then(ln,ln),_t(n),e(new Qn)}catch(t){e(t)}})),l};return i.isMobXFlow=!0,i}),$n);tr.bound=E(er);var nr={has:function(e,t){return kt(e).it(t)},get:function(e,t){return kt(e).ct(t)},set:function(e,t,n){var r;return!!o(t)&&((r=kt(e).ht(t,n,!0))==null||r)},deleteProperty:function(e,t){var n;return!!o(t)&&((n=kt(e).Ut(t,!0))==null||n)},defineProperty:function(e,t,n){var r;return(r=kt(e).l(t,n))==null||r},ownKeys:function(e){return kt(e).rt()},preventExtensions:function(){t(13)}},rr=Symbol(`mobx-keys`),ir=`update`,ar={get:function(e,t){var n=e[I];return t===I?n:t===`length`?n.Ft():typeof t!=`string`||isNaN(t)?g(sr,t)?sr[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)}},or=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 jt(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}),Pt(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&&qt(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=an),At(this)){var a=Mt(this,{object:this.v,type:`splice`,index:e,removedCount:t,added:n});if(!a)return an;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=Nt(this),a=i||r?{observableKind:`array`,object:this.v,type:ir,debugObjectName:this.st.tt,index:e,newValue:t,oldValue:n}:null;this.st.reportChanged(),i&&Ft(this,a)},n.nn=function(e,t,n){var r=!this.zt&&!1,i=Nt(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&&Ft(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(At(this)){var a=Mt(this,{type:ir,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}(),sr={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 B.trackingDerivation&&t(37,`reverse`),this.replace(this.slice().reverse()),this},sort:function(){B.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)}};k(`at`,A),k(`concat`,A),k(`flat`,A),k(`includes`,A),k(`indexOf`,A),k(`join`,A),k(`lastIndexOf`,A),k(`slice`,A),k(`toString`,A),k(`toLocaleString`,A),k(`toSorted`,A),k(`toSpliced`,A),k(`with`,A),k(`every`,j),k(`filter`,j),k(`find`,j),k(`findIndex`,j),k(`findLast`,j),k(`findLastIndex`,j),k(`flatMap`,j),k(`forEach`,j),k(`map`,j),k(`some`,j),k(`toReversed`,j),k(`reduce`,Lt),k(`reduceRight`,Lt);var cr,lr,ur=f(`ObservableArrayAdministration`,or),dr={},fr=`add`,pr=function(){function e(e,n,r){var i=this;n===void 0&&(n=ce),r===void 0&&(r=`ObservableMap`),this.Jt=void 0,this.tt=void 0,this[I]=dr,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=se(`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(!B.trackingDerivation)return this.it(e);var n=this.dt.get(e);if(!n){var r=n=new Mn(this.it(e),le,`ObservableMap.key?`,!1);this.dt.set(e,r),ft(r,(function(){return t.dt.delete(e)}))}return n.get()},n.set=function(e,t){var n=this.it(e);if(At(this)){var r=Mt(this,{type:n?ir:fr,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(At(this)&&!Mt(this,{type:`delete`,object:this,name:e}))return!1;if(this.it(e)){var n=Nt(this),r=n?{observableKind:`map`,debugObjectName:this.tt,type:`delete`,object:this,oldValue:this.vt.get(e).Ot,name:e}:null;return Et((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&&Ft(this,r),!0}return!1},n.rn=function(e,t){var n=this.vt.get(e);if((t=n.xt(t))!==B.UNCHANGED){var r=Nt(this),i=r?{observableKind:`map`,debugObjectName:this.tt,type:ir,object:this,oldValue:n.Ot,name:e,newValue:t}:null;n.gt(t),r&&Ft(this,i)}},n.en=function(e,t){var n=this;Et((function(){var r,i=new Mn(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=Nt(this);r&&Ft(this,r?{observableKind:`map`,debugObjectName:this.tt,type:fr,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 H(e)&&(e=new Map(e)),Et((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 rn.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;Et((function(){We((function(){for(var t,n=C(e.keys());!(t=n()).done;)e.delete(t.value)}))}))},n.replace=function(e){var n=this;return Et((function(){for(var r,i=function(e){if(p(e)||H(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 Pt(this,e)},n.St=function(e){return jt(this,e)},S(e,[{key:`size`,get:function(){return this.lt.reportObserved(),this.vt.size}},{key:Symbol.toStringTag,get:function(){return`Map`}}])}(),H=f(`ObservableMap`,pr),mr={},hr=function(){function e(e,n,r){var i=this;n===void 0&&(n=ce),r===void 0&&(r=`ObservableSet`),this.tt=void 0,this[I]=mr,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=se(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;Et((function(){We((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(At(this)){var n=Mt(this,{type:fr,object:this,newValue:e});if(!n)return this;e=n.newValue}if(!this.has(e)){Et((function(){t.vt.add(t.Jt(e,void 0)),t.st.reportChanged()}));var r=Nt(this);r&&Ft(this,r?{observableKind:`set`,debugObjectName:this.tt,type:fr,object:this,newValue:e}:null)}return this},n.delete=function(e){var t=this;if(At(this)&&!Mt(this,{type:`delete`,object:this,oldValue:e}))return!1;if(this.has(e)){var n=Nt(this),r=n?{observableKind:`set`,debugObjectName:this.tt,type:`delete`,object:this,oldValue:e}:null;return Et((function(){t.st.reportChanged(),t.vt.delete(e)})),n&&Ft(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 Bt({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 Bt({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)&&!gr(e)?e.intersection(this):new Set(this).intersection(e)},n.union=function(e){return m(e)&&!gr(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)&&!gr(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)&&!gr(e)?e.isDisjointFrom(this):new Set(this).isDisjointFrom(e)},n.replace=function(e){var n=this;return gr(e)&&(e=new Set(e)),Et((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 Pt(this,e)},n.St=function(e){return jt(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`}}])}(),gr=f(`ObservableSet`,hr),_r=Object.create(null),vr=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 Pn)return n.set(t),!0;if(At(this)){var r=Mt(this,{type:ir,object:this.v||this.h,name:e,newValue:t});if(!r)return null;t=r.newValue}if((t=n.xt(t))!==B.UNCHANGED){var i=Nt(this),a=i?{type:ir,observableKind:`object`,debugObjectName:this.tt,object:this.v||this.h,oldValue:n.Ot,name:e,newValue:t}:null;n.gt(t),i&&Ft(this,a)}return!0},n.ct=function(e){return B.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(!B.trackingDerivation)return e in this.h;this.sn||=new Map;var t=this.sn.get(e);return t||(t=new Mn(e in this.h,le,`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!==rn;){var a=tn(i,e);if(a){var o=n.o(this,e,a,i);if(o===0)return;if(o===1)break}i=Object.getPrototypeOf(i)}Wt(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&&Wt(this,0,e),i},n.l=function(e,t,n){n===void 0&&(n=!1);try{$e();var r=this.Ut(e);if(!r)return r;if(At(this)){var i=Mt(this,{object:this.v||this.h,name:e,type:fr,newValue:t.value});if(!i)return null;var a=i.newValue;t.value!==a&&(t=ee({},t,{value:a}))}if(n){if(!Reflect.defineProperty(this.h,e,t))return!1}else nn(this.h,e,t);this.fn(e,t.value)}finally{et()}return!0},n.g=function(e,t,n,r){r===void 0&&(r=!1);try{$e();var i=this.Ut(e);if(!i)return i;if(At(this)){var a=Mt(this,{object:this.v||this.h,name:e,type:fr,newValue:t});if(!a)return null;t=a.newValue}var o=Ht(e),s={configurable:!B.safeDescriptors||this.p,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.h,e,s))return!1}else nn(this.h,e,s);var c=new Mn(t,n,`ObservableObject.key`,!1);this.j.set(e,c),this.fn(e,c.Ot)}finally{et()}return!0},n.m=function(e,t,n){n===void 0&&(n=!1);try{$e();var r=this.Ut(e);if(!r)return r;if(At(this)&&!Mt(this,{object:this.v||this.h,name:e,type:fr,newValue:void 0}))return null;t.name||=`ObservableObject.key`,t.context=this.v||this.h;var i=Ht(e),a={configurable:!B.safeDescriptors||this.p,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.h,e,a))return!1}else nn(this.h,e,a);this.j.set(e,new Pn(t)),this.fn(e,void 0)}finally{et()}return!0},n.Ut=function(e,t){if(t===void 0&&(t=!1),!g(this.h,e))return!0;if(At(this)&&!Mt(this,{object:this.v||this.h,name:e,type:`remove`}))return null;try{var n;$e();var r=Nt(this),i=this.j.get(e),a=void 0;if(!i&&r&&(a=tn(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 Mn&&(a=i.Ot),nt(i)),this.lt.reportChanged(),(n=this.sn)==null||(n=n.get(e))==null||n.set(e in this.h),r&&r&&Ft(this,{type:`remove`,observableKind:`object`,object:this.v||this.h,debugObjectName:this.tt,oldValue:a,name:e})}finally{et()}return!0},n._t=function(e){return Pt(this,e)},n.St=function(e){return jt(this,e)},n.fn=function(e,t){var n,r=Nt(this);r&&r&&Ft(this,r?{type:fr,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}(),yr=f(`ObservableObjectAdministration`,vr),br=Gt(0),U=function(){var e=!1,t={};return Object.defineProperty(t,`0`,{set:function(){e=!0}}),Object.create(t)[0]=1,!1===e}(),xr=0,Sr=function(){};cr=Sr,lr=Array.prototype,Object.setPrototypeOf?Object.setPrototypeOf(cr.prototype,lr):cr.prototype.__proto__===void 0?cr.prototype=lr:cr.prototype.__proto__=lr;var Cr=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 or(r,n,i,!0);e.v=a,d(a,I,e),t&&t.length&&a.spliceWithArray(0,0,t),U&&Object.defineProperty(a,`0`,br)})),a}ne(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`}}])}(Sr);Object.entries(sr).forEach((function(e){var t=e[0];t!==`concat`&&u(Cr.prototype,t,e[1])})),qt(1e3);var wr=rn.toString,Tr=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:at,extras:{getDebugName:Yt},$mobx:I}),e.$mobx=I,e.FlowCancellationError=Qn,e.ObservableMap=pr,e.ObservableSet=hr,e.Reaction=Hn,e._allowStateChanges=Le,e._allowStateChangesInsideComputed=st,e._allowStateReadsEnd=Je,e._allowStateReadsStart=qe,e._autoAction=Yn,e._endAction=Ie,e._getAdministration=N,e._getGlobalState=function(){return B},e._interceptReads=function(e,t,n){var r;return H(e)||Rt(e)||Nn(e)?r=N(e):Ut(e)&&(r=N(e,t)),r.dehancer=typeof t==`function`?t:n,function(){r.dehancer=void 0}},e._isComputingDerivation=function(){return B.trackingDerivation!==null},e._resetGlobalState=function(){var e=new zn;for(var t in e)Rn.indexOf(t)===-1&&(B[t]=e[t]);B.allowStateChanges=!B.enforceActions},e._startAction=Fe,e.action=Jn,e.autorun=lt,e.comparer=gn,e.computed=Dn,e.configure=function(e){!0===e.isolateGlobalState&&function(){if((B.pendingReactions.length||B.inBatch||B.isRunningReactions)&&t(36),Vn=!0,Bn){var e=n();--e.__mobxInstanceCount==0&&(e.__mobxGlobals=void 0),B=new zn}}();var r,i,a=e.useProxies,o=e.enforceActions;if(a!==void 0&&(B.useProxies=a===`always`||a!==`never`&&typeof Proxy<`u`),a===`ifavailable`&&(B.verifyProxies=!0),o!==void 0){var s=o===`always`?`always`:o===`observed`;B.enforceActions=s,B.allowStateChanges=!0!==s&&s!==`always`}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach((function(t){t in e&&(B[t]=!!e[t])})),B.allowStateReads=!B.observableRequiresReaction,e.reactionScheduler&&(r=e.reactionScheduler,i=Un,Un=function(e){return r((function(){return i(e)}))})},e.createAtom=se,e.defineProperty=function(e,n,r){if(Ut(e))return e[I].l(n,r);t(39)},e.entries=function(e){return Ut(e)?St(e).map((function(t){return[t,e[t]]})):H(e)?St(e).map((function(t){return[t,e.get(t)]})):gr(e)?Array.from(e.entries()):Rt(e)?e.map((function(e,t){return[t,e]})):void t(7)},e.extendObservable=mt,e.flow=tr,e.flowResult=function(e){return e},e.get=function(e,n){if(Ct(e,n))return Ut(e)?e[I].ct(n):H(e)?e.get(n):Rt(e)?e[n]:void t(11)},e.getAtom=Jt,e.getDebugName=Yt,e.getDependencyTree=function(e,t){return ht(Jt(e,t))},e.getObserverTree=function(e,t){return gt(Jt(e,t))},e.has=Ct,e.intercept=function(e,t,n){return a(n)?function(e,t,n){return N(e,t).St(n)}(e,t,n):function(e,t){return N(e).St(t)}(e,t)},e.isAction=ct,e.isBoxedObservable=Nn,e.isComputed=function(e){return yt(e)},e.isComputedProp=function(e,t){return yt(e,t)},e.isFlow=vt,e.isFlowCancellationError=function(e){return e instanceof Qn},e.isObservable=xt,e.isObservableArray=Rt,e.isObservableMap=H,e.isObservableObject=Ut,e.isObservableProp=function(e,t){return bt(e,t)},e.isObservableSet=gr,e.keys=St,e.makeAutoObservable=function(e,t,n){return c(e)?mt(e,e,t,n):(Xt((function(){var r=Vt(e,n)[I];if(!e[rr]){var i=Object.getPrototypeOf(e),a=new Set([].concat(dn(e),dn(i)));a.delete(`constructor`),a.delete(I),u(i,rr,a)}e[rr].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=Vt(e,n)[I];t??=function(e){return g(e,pn)||u(e,pn,ee({},e[pn])),e[pn]}(e),dn(t).forEach((function(e){return r.o(e,t[e])}))})),e},e.observable=R,e.observe=function(e,t,n,r){return a(n)?function(e,t,n,r){return N(e,t)._t(n,r)}(e,t,n,r):function(e,t,n){return N(e)._t(t,n)}(e,t,n)},e.onBecomeObserved=dt,e.onBecomeUnobserved=ft,e.onReactionError=function(e){return B.globalReactionErrorHandlers.push(e),function(){var t=B.globalReactionErrorHandlers.indexOf(e);t>=0&&B.globalReactionErrorHandlers.splice(t,1)}},e.override=_n,e.ownKeys=wt,e.reaction=function(e,t,n){function r(){if(p=!1,!h.isDisposed){var t=!1,r=s;h.track((function(){var n=Le(!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=on);var a,o,s,c=n.name??`Reaction`,l=Jn(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=ut(n),f=!0,p=!1,m=n.compareStructural?gn.structural:n.equals||gn.default,h=new Hn(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){Ut(e)?e[I].Ut(n):H(e)||gr(e)?e.delete(n):Rt(e)?(typeof n!=`number`&&(n=parseInt(n,10)),e.splice(n,1)):t(9)},e.runInAction=st,e.set=function e(n,r,i){if(arguments.length!==2||gr(n))Ut(n)?n[I].ht(r,i):H(n)?n.set(r,i):gr(n)?n.add(r):Rt(n)?(typeof r!=`number`&&(r=parseInt(r,10)),r<0&&t(`Invalid index: '`+r+`'`),$e(),r>=n.length&&(n.length=r+1),n[r]=i,et()):t(8);else{$e();var a=r;try{for(var o in a)e(n,o,a[o])}finally{et()}}},e.spy=at,e.toJS=function(e){return function e(t,n){if(typeof t!=`object`||!t||t instanceof Date||!xt(t))return t;if(Nn(t)||In(t))return e(t.get(),n);if(n.has(t))return n.get(t);if(Rt(t)){var r=Tt(n,t,Array(t.length));return t.forEach((function(t,i){r[i]=e(t,n)})),r}if(gr(t)){var i=Tt(n,t,new Set);return t.forEach((function(t){i.add(e(t,n))})),i}if(H(t)){var a=Tt(n,t,new Map);return t.forEach((function(t,r){a.set(r,e(t,n))})),a}var o=Tt(n,t,{});return wt(t).forEach((function(r){rn.propertyIsEnumerable.call(t,r)&&(o[r]=e(t[r],n))})),o}(e,new Map)},e.trace=function(){},e.transaction=Et,e.untracked=We,e.values=function(e){return Ut(e)?St(e).map((function(t){return e[t]})):H(e)?St(e).map((function(t){return e.get(t)})):gr(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`?Ot(e,t):Dt(e,t,n||{})}})),hw=pe((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 ee(e,t,n){s(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function te(e,t){var n=`isMobX`+e;return t.prototype[n]=!0,function(e){return b(e)&&e[n]===!0}}function ne(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function re(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function w(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}var ie=Object.getOwnPropertySymbols!==void 0;function T(e){var t=Object.keys(e);if(!ie)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter(function(t){return c.propertyIsEnumerable.call(e,t)})):t}var E=typeof Reflect<`u`&&Reflect.ownKeys?Reflect.ownKeys:ie?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function ae(e){return typeof e==`string`?e:typeof e==`symbol`?e.toString():new String(e).toString()}function oe(e){return e===null?null:typeof e==`object`?``+e:e}function se(e,t){return c.hasOwnProperty.call(e,t)}var ce=Object.getOwnPropertyDescriptors||function(e){var t={};return E(e).forEach(function(n){t[n]=o(e,n)}),t};function le(e,t){return!!(e&t)}function ue(e,t,n){return n?e|=t:e&=~t,e}function de(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 fe(e,t,n){if(ye())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&be(i,n.prototype),i}function pe(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,Se(r.key),r)}}function me(e,t,n){return t&&pe(e.prototype,t),n&&pe(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function he(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=Ce(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.
|
|
145
145
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function D(){return D=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},D.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,be(e,t)}function ve(e){try{return Function.toString.call(e).indexOf(`[native code]`)!==-1}catch{return typeof e==`function`}}function ye(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ye=function(){return!!e})()}function be(e,t){return be=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},be(e,t)}function xe(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 Se(e){var t=xe(e,`string`);return typeof t==`symbol`?t:t+``}function Ce(e,t){if(e){if(typeof e==`string`)return de(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)?de(e,t):void 0}}function we(e){var t=typeof Map==`function`?new Map:void 0;return we=function(e){if(e===null||!ve(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 fe(e,arguments,ge(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),be(n,e)},we(e)}var Te=Symbol(`mobx-stored-annotations`);function Ee(e){function t(t,n){if(Ae(n))return e.decorate_20223_(t,n);De(t,n,e)}return Object.assign(t,e)}function De(e,t,r){se(e,Te)||C(e,Te,D({},e[Te])),Ke(r)&&!se(e[Te],t)&&n(`'`+(e.constructor.name+`.prototype.`+t.toString())+`' is decorated with 'override', but no such decorated member was found on prototype.`),Oe(e,r,t),Ke(r)||(e[Te][t]=r)}function Oe(e,t,r){if(!Ke(t)&&se(e[Te],r)){var i=e.constructor.name+`.prototype.`+r.toString(),a=e[Te][r].annotationType_,o=t.annotationType_;n(`Cannot apply '@`+o+`' to '`+i+`':`+(`
|
|
146
146
|
The field is already decorated with '@`+a+`'.`)+`
|
|
147
147
|
Re-decorating fields is not allowed.
|
|
@@ -171,32 +171,32 @@ The target is already observable of different type.
|
|
|
171
171
|
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,O,new Yi(e,new Map,String(r),It(t))),e}var Zi=te(`ObservableObjectAdministration`,Yi);function Qi(e){return qi[e]||(qi[e]={get:function(){return this[O].getObservablePropValue_(e)},set:function(t){return this[O].setObservablePropValue_(e,t)}})}function $i(e){return b(e)?Zi(e[O]):!1}function ea(e,t,n){var r;e.appliedAnnotations_[n]=t,(r=e.target_[Te])==null||delete r[n]}function ta(e,t,r){if(Sa(t)||n(`Cannot annotate '`+e.name_+`.`+r.toString()+`': Invalid annotation.`),!Ke(t)&&se(e.appliedAnnotations_,r)){var i=e.name_+`.`+r.toString(),a=e.appliedAnnotations_[r].annotationType_,o=t.annotationType_;n(`Cannot apply '`+o+`' to '`+i+`':`+(`
|
|
172
172
|
The field is already annotated with '`+a+`'.`)+`
|
|
173
173
|
Re-annotating fields is not allowed.
|
|
174
|
-
Use 'override' annotation for methods overridden by subclass.`)}}var na=ca(0),ra=function(){var e=!1,t={};return Object.defineProperty(t,`0`,{set:function(){e=!0}}),Object.create(t)[0]=1,e===!1}(),ia=0,aa=function(){};function oa(e,t){Object.setPrototypeOf?Object.setPrototypeOf(e.prototype,t):e.prototype.__proto__===void 0?e.prototype=t:e.prototype.__proto__=t}oa(aa,Array.prototype);var sa=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,ma(function(){var e=new Oi(r,n,i,!0);e.proxy_=a,ee(a,O,e),t&&t.length&&a.spliceWithArray(0,0,t),ra&&Object.defineProperty(a,`0`,na)}),a}_e(t,e);var n=t.prototype;return n.concat=function(){this[O].atom_.reportObserved();var e=[...arguments];return Array.prototype.concat.apply(this.slice(),e.map(function(e){return Fi(e)?e.slice():e}))},n[Symbol.iterator]=function(){var e=this,t=0;return ba({next:function(){return t<e.length?{value:e[t++],done:!1}:{done:!0,value:void 0}}})},me(t,[{key:`length`,get:function(){return this[O].getArrayLength_()},set:function(e){this[O].setArrayLength_(e)}},{key:Symbol.toStringTag,get:function(){return`Array`}}])}(aa);Object.entries(Ai).forEach(function(e){var t=e[0],n=e[1];t!==`concat`&&C(sa.prototype,t,n)});function ca(e){return{enumerable:!1,configurable:!0,get:function(){return this[O].get_(e)},set:function(t){this[O].set_(e,t)}}}function la(e){s(sa.prototype,``+e,ca(e))}function ua(e){if(e>ia){for(var t=ia;t<e+100;t++)la(t);ia=e}}ua(1e3);function da(e,t,n){return new sa(e,t,n)}function G(e,t){if(typeof e==`object`&&e){if(Fi(e))return t!==void 0&&n(23),e[O].atom_;if(Gi(e))return e.atom_;if(Bi(e)){if(t===void 0)return e.keysAtom_;var r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,pa(e)),r}if($i(e)){if(!t)return n(26);var i=e[O].values_.get(t);return i||n(27,t,pa(e)),i}if(Ne(e)||en(e)||B(e))return e}else if(v(e)&&B(e[O]))return e[O];n(28)}function fa(e,t){if(e||n(29),t!==void 0)return fa(G(e,t));if(Ne(e)||en(e)||B(e)||Bi(e)||Gi(e))return e;if(e[O])return e[O];n(24,e)}function pa(e,t){var n;if(t!==void 0)n=G(e,t);else if(sr(e))return e.name;else n=$i(e)||Bi(e)||Gi(e)?fa(e):G(e);return n.name_}function ma(e){var t=I(),n=Yt(!0);kn();try{return e()}finally{An(),Xt(n),mn(t)}}var ha=c.toString;function ga(e,t,n){return n===void 0&&(n=-1),_a(e,t,n)}function _a(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=ha.call(e);if(o!==ha.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=va(e),t=va(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(!_a(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(!(se(t,m)&&_a(e[m],t[m],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function va(e){return Fi(e)?e.slice():ne(e)||Bi(e)||w(e)||Gi(e)?Array.from(e.entries()):e}var ya=i().Iterator?.prototype||{};function ba(e){return e[Symbol.iterator]=xa,Object.assign(Object.create(ya),e)}function xa(){return this}function Sa(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:qn,extras:{getDebugName:pa},$mobx:O}),e.$mobx=O,e.FlowCancellationError=Dr,e.ObservableMap=zi,e.ObservableSet=Wi,e.Reaction=In,e._allowStateChanges=N,e._allowStateChangesInsideComputed=or,e._allowStateReadsEnd=gn,e._allowStateReadsStart=hn,e._autoAction=ar,e._endAction=Jt,e._getAdministration=fa,e._getGlobalState=Cn,e._interceptReads=Fr,e._isComputingDerivation=on,e._resetGlobalState=wn,e._startAction=M,e.action=ir,e.autorun=cr,e.comparer=ze,e.computed=Vt,e.configure=br,e.createAtom=Pe,e.defineProperty=Qr,e.entries=qr,e.extendObservable=U,e.flow=jr,e.flowResult=Nr,e.get=Zr,e.getAtom=G,e.getDebugName=pa,e.getDependencyTree=xr,e.getObserverTree=Cr,e.has=Xr,e.intercept=Ir,e.isAction=sr,e.isBoxedObservable=$t,e.isComputed=Br,e.isComputedProp=Vr,e.isFlow=Pr,e.isFlowCancellationError=Or,e.isObservable=Ur,e.isObservableArray=Fi,e.isObservableMap=Bi,e.isObservableObject=$i,e.isObservableProp=Wr,e.isObservableSet=Gi,e.keys=Gr,e.makeAutoObservable=Ci,e.makeObservable=xi,e.observable=j,e.observe=ei,e.onBecomeObserved=mr,e.onBecomeUnobserved=hr,e.onReactionError=Ln,e.override=Ge,e.ownKeys=$r,e.reaction=dr,e.remove=Yr,e.runInAction=or,e.set=Jr,e.spy=qn,e.toJS=ai,e.trace=oi,e.transaction=ci,e.untracked=pn,e.values=Kr,e.when=li})),hw=pe(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=pw():t.exports=mw()}))();function gw(e){if(Array.isArray(e))return Object.freeze(e.map(gw));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]=gw(r);return Object.freeze(t)}return e}function _w(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 vw(e){return typeof e==`string`?e:String(e)}function yw(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 bw(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 xw(e,t){if(!(e instanceof Ar))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=e.style.add(t),n}function Sw(e){return{fn:(t=>xw(t,e)),argTypes:[`liftable`],returnType:`T`}}function Cw(e){return{fn:((t,n)=>xw(n,new H({[e]:P.parse(t)}))),argTypes:[`string`,`liftable`],returnType:`T`}}function ww(e,t){return new H({[e]:t})}function Tw(){let e={};for(let t of lr)e[t]=Sw(ww(t,!0)),e[`not_${t}`]=Sw(ww(t,!1));for(let[t,n]of Object.entries(dr))e[t]=Sw(ww(n,!0));return e}const Ew={fn:((e,t)=>xw(t,H.parse(e))),argTypes:[`string`,`liftable`],returnType:`T`},Dw={fn:((e,t)=>xw(t,new H({link:e}))),argTypes:[`string`,`liftable`],returnType:`T`};function Ow(){return{fg:Cw(`color`),bg:Cw(`bgcolor`),...Tw(),link:Dw,style:Ew}}function kw(e,t){if(!En.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 Dn(e)}function Aw(e,t){return{fn:t,argTypes:e,returnType:`string`}}function jw(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}`+(e===void 0?` — ${t} takes it as its last argument`:``))}return e}const Mw=Aw([`string`,`int`],((e,t)=>Pn(kw(e,`darken`),jw(t,`darken`,`levels`)).hex)),Nw=Aw([`string`,`int`],((e,t)=>Pn(kw(e,`lighten`),-jw(t,`lighten`,`levels`)).hex)),Pw={min:0,max:100,note:`0 = from, 100 = toward`},Fw=Aw([`string`,`string`,`float`],((e,t,n)=>sn(kw(e,`mix`),kw(t,`mix`),jw(n,`mix`,`percentage`,Pw)/100).hex)),Iw={min:1,max:21,note:`4.5 = AA body text, 3 = AA large text`},Lw=Aw([`string`],(e=>Fn(kw(e,`contrastOn`)).hex)),Rw=Aw([`string`,`string`,`float`],((e,t,n)=>Rn(kw(e,`readableOn`),kw(t,`readableOn`),jw(n,`readableOn`,`ratio`,Iw)).hex)),zw={hueShift:`shiftHue`,chromaScale:`scaleChroma`,lightnessScale:`scaleLightness`,lightnessShift:`shiftLightness`};function Bw(){let e={};for(let[t,n]of Object.entries(zw)){let r=t;e[n]=Aw([`string`,`float`],((e,t)=>{let i={...hn,[r]:jw(t,n,`amount`)};return R.fromRgba(kw(e,n)).applyKey(i).toRgba().hex}))}return e}function Vw(){return{darken:Mw,lighten:Nw,mix:Fw,contrastOn:Lw,readableOn:Rw,...Bw()}}function Hw(e,t){if(e.length===0)throw RangeError(`ramp needs at least one stop after the easing: ramp <value> <easing> <position> <color> …`);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:On(t,e[r+1])});return n}function Uw(e){return{color:{fn:(t=>On(e(),t).hex),argTypes:[`string`],returnType:`string`},ramp:{fn:((...t)=>{if(t.length<2)throw RangeError(`ramp needs a value and an easing before its stops (got ${t.length}): ramp <value> "linear"|"step" <position> <color> …`);let[n,r,...i]=t;return new ar(ir(r),Hw(i,e())).at(n).hex}),argTypes:[`float`,`string`],argTypePattern:`alternating`,returnType:`string`}}}function Ww(){return{...Ow(),...Vw()}}new H({color:`red`,dim:!0});const Gw=/^(?:(?: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,Kw=/^(?<family>opus|sonnet|haiku)\s+(?<major>\d+)(?:\.(?<minor>\d))?$/i;function qw(e){if(!e)return`Claude`;let t=e.trim().replace(/\s*\([^)]*\)\s*$/,``).replace(/\s*\[[^\]]*\]\s*$/,``).trim(),n=t.match(Gw);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(Kw);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 Jw(e){let t=e.match(Kw);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 Yw(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 Xw(e){return e.toLocaleString()}const Zw=[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],Qw=Zw.length;function $w(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*(Qw-1));o+=Zw[t]}return o}function eT(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}const tT=li(),nT=[...pi];function rT(){return{basename:{fn:e=>l(e),argTypes:[`string`]},dirname:{fn:e=>u(e),argTypes:[`string`]},abbreviatePath:{fn:e=>Yw(e),argTypes:[`string`]},int:{fn:e=>yw(e),argTypes:[`value`]},string:{fn:e=>vw(e),argTypes:[`value`]},bool:{fn:e=>bw(e),argTypes:[`value`]},urlEncode:{fn:e=>encodeURIComponent(e),argTypes:[`string`]},themes:{fn:()=>tT,argTypes:[]},styles:{fn:()=>nT,argTypes:[]},sparkline:{fn:(e,t)=>$w(eT(e),t),argTypes:[`string`,`int`]}}}function iT(e=()=>new Date){return{minutesUntilReset:{fn:t=>Math.round(Math.max(0,t*1e3-e().getTime())/6e4),argTypes:[`int`]},formatInteger:{fn:e=>Xw(e),argTypes:[`int`]},round:{fn:e=>Math.round(e),argTypes:[`float`]},formatModelName:{fn:e=>qw(e),argTypes:[`string`]},shortenModelName:{fn:e=>Jw(e),argTypes:[`string`]}}}function aT(e,t=()=>new Date){return xu({fromString:e=>new Ar(e),toString:e=>e.plain,isT:e=>e instanceof Ar,clock:t,missingKey:`error`,funcs:{...lf(),...ym(),...Yf(),..._p(),...ef(t),...Wu(),...Cf(),...Ww(),...rT(),...iT(t),...e??{}}})}function oT(e){return sT(e,new Set(e.names()),``)}function sT(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`?cT(a,e.readDocument(a)):e.read(a);let o=`${a}.`;for(let n of t)if(n.startsWith(o))return sT(e,t,a)}})}function cT(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}`)}}const lT=/\r\n|\r|\n/g,uT=e=>X(e.replace(lT,` `).trim());function dT(e){return t=>{let n=e.exec(t)?.[1];return n===void 0?Q(`regex no-match`):X(n.replace(lT,` `))}}const fT=e=>{try{return X(JSON.parse(e))}catch(e){return Q(`JSON parse failed: ${e.message}`)}};function pT(e,t){return t.kind!==`ttl`||t.durationMs>=500?t:(D(`declareShell "${e}": ttl ${t.durationMs}ms below floor 500ms; clamping`),{kind:`ttl`,durationMs:500})}function mT(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]}"`)}}function hT(e,t){return{where:`output of "${e}"`,read:async()=>{let n=await Te({bin:`/bin/sh`,args:[`-c`,e],category:`user-shell`,signal:t});if(!n.ok&&n.reason===`aborted`)throw t.reason;return n.ok?X(n.stdout):Q(`shell "${e}" ${n.exitCode===null?[n.reason,n.error].filter(e=>e!==void 0).join(`: `):`exited with code ${n.exitCode}`}`)}}}function gT(e,t,n){return{where:`"${e}"`,read:async()=>{try{let r=await w(e,{encoding:`utf8`,signal:n});return X(t===`first-line`?r.split(/\r?\n/)[0]??``:r)}catch{if(n.aborted)throw n.reason;return Q(`file unreadable: ${e}`)}}}}function _T(e,t,n){if(e.kind!==`ok`)return e;let r=t(e.value);return r.kind===`failed`?Q(`${r.reason} in ${n}`):r}const vT=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],yT=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],bT=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],xT=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function ST(e,t){let n=[[`2006`,e=>String(e.getFullYear())],[`January`,e=>vT[e.getMonth()]],[`Monday`,e=>bT[e.getDay()]],[`Jan`,e=>yT[e.getMonth()]],[`Mon`,e=>xT[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 CT={branch:`string`,sha:`string`,dirty:`boolean`,ahead:`number`,behind:`number`,stash:`number`};function wT(e,t,n,r){if(e===null){if(n!==void 0)return n;let e=CT[t];try{return OT(r,e)}catch{return kT(e)}}switch(t){case`branch`:return e.branch===`detached`?``:e.branch;case`sha`:return Uy(e.sha,``);case`dirty`:return e.status!==`clean`;case`ahead`:return Uy(e.aheadBehind,{ahead:0,behind:0}).ahead;case`behind`:return Uy(e.aheadBehind,{ahead:0,behind:0}).behind;case`stash`:return Uy(e.stashCount,0)}}var TT=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}},ET=class{buckets=new Map;subscribe(e,t){let n=this.buckets.get(e);if(!n){let t=new Set;n={timer:oe(()=>{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&&(ae(n.timer),this.buckets.delete(e)))}dispose(){for(let{timer:e}of this.buckets.values())ae(e);this.buckets.clear()}bucketCount(){return this.buckets.size}};function DT(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function OT(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`?vw(e):t===`number`?yw(e):bw(e)}function kT(e){return e===`number`?0:e===`boolean`?!1:``}var AT=class{inputMetas=new Map;lastErrors=new Map;watchMgr=new TT;ttlMgr=new ET;gitSubscriptions=new Map;cleanups=[];inFlight=new Map;abort=new AbortController;engine=aT();gitProvider;ownsGitProvider;sessionState;constructor(e,t=``,n,r){this.store=e,this.defaultEmptyValue=t,n?(this.gitProvider=n,this.ownsGitProvider=!1):(this.gitProvider=new nC({sanityIntervalMs:0}),this.ownsGitProvider=!0),this.sessionState=r}get variableStore(){return this.store}declareLiteral(e,t){this.store.defineBox(e,_w(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,hT(t,this.abort.signal),pT(e,n.cache),n.parse)}declareFile(e,t,n){this.declareSource(e,gT(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,uT,t.default,n);case`regex`:return this.scalarPublisher(e,dT(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=_T(n,t,r);this.noteOutcome(e,a),this.store.setBox(e,Uy(a,i))}}documentPublisher(e,t,n){let r=t===void 0?Z:X(t);return this.store.defineDocument(e,r),i=>{let a=_T(i,fT,n);this.noteOutcome(e,a),this.store.setDocument(e,a.kind===`ok`||t===void 0?a:r)}}runSource(e,t,n){if(this.inFlight.has(e))return;let r=t.read().then(n,e=>{if(e!==this.abort.signal.reason)throw e}).finally(()=>this.inFlight.delete(e));this.inFlight.set(e,r)}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=oT(this.store);try{let t=r.evaluate(i).map(e=>e.plain).join(``);return this.lastErrors.delete(e),t}catch(t){return this.recordError(e,t instanceof Error?t.message:String(t)),this.stringInitial(n.varDefault)}}),this.store.read(e)}declareTime(e,t){let n=t.ttlMs??1e3;this.store.defineBox(e,`string`,(e=>{try{return ST(t.format,e)}catch{return this.stringInitial(t.varDefault)}})(new Date));let r=this.ttlMgr.subscribe(n,()=>{try{this.store.setBox(e,ST(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=CT[t.field],r=t.varDefault===void 0?kT(n):OT(t.varDefault,n);this.store.defineBox(e,n,r);let i=this.gitSubscriptions.get(t.cwd);if(!i){let e=new Map;i={fieldSubs:e,unsubscribe: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,wT(t,n,i,this.defaultEmptyValue))})})},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})}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(`session.id`);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=DT(e,n.path),i=this.store.getType(t);if(r!==void 0)try{this.store.setBox(t,OT(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`)}})}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.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,hw.reaction)(()=>{let t=oT(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,hw.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,OT(this.defaultEmptyValue,t))}catch{this.store.setBox(e,kT(t))}}defaultFor(e){try{return OT(this.defaultEmptyValue,e)}catch{return kT(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 jT=new Map,MT=new Map;function NT(e){let t=ai(e),n=jT.get(t);if(n!==void 0)return n;let r=Gn(t);if(r===null)throw Error(`Palette "${e}" (resolved "${t}") did not resolve in the theme registry — allowed names and the registry are inconsistent`);return jT.set(t,r),r}function PT(e,t){let n=`${e.name} ${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,r=MT.get(n);if(r!==void 0)return r;let i=tr(e,t);return MT.set(n,i),i}function FT(e,t){let n=[],r=[],i=()=>{if(!r.length)return;let e=IT(r,t);e.plain.length>0&&n.push(e),r=[]};for(let a of e)if(a.style.link){i();let e=IT([a],t);e.plain.length>0&&n.push(e)}else r.push(a);return i(),n}function IT(e,t){let n=t!==void 0&&!t.isNull?e.map(e=>LT(e,t)):e,r=Ar.fromFragments(n);return r.end=``,r.noWrap=!0,n.length===1?r.style=n[0].style:t!==void 0&&!t.isNull&&(r.style=t),r}function LT(e,t){let n=e.copy();return n.style=t.add(e.style),n}function RT(e,t){return e===void 0?!0:e.evaluate(t).map(e=>e.plain).join(``)!==`false`}function zT(e,t){let n=Ar.fromFragments(e);return n.end=``,n.noWrap=!0,t!==void 0&&!t.isNull&&(n.style=t),n}function BT(e,t){let{width:n,justify:r,truncate:i,truncateMarker:a=`…`,baseStyle:o,padding:s}=t;if(e.length===0)return[];let c=zT(e,o).pad(s);return n===`auto`||(c.cellLength>n?c.truncate(n,{mode:i,marker:a}):c.cellLength<n&&c.align(r,n)),[c]}var VT=class extends Error{constructor(e,t,n){super(`Invalid ${t} color ${JSON.stringify(e)}: ${n}`),this.name=`ColorSpecError`}};function HT(e,t,n,r,i,a,o,s,c){let l={segName:t,palette:n,disclosure:r,bg:void 0};e.current=l;let u=UT(o,c),d=u===void 0?i:WT(n,u,`bg`);l.bg=d;let f=UT(s,c),p=f===void 0?a(d):WT(n,f,`fg`);return new H({bgcolor:P.fromRgba(d),color:p===void 0?void 0:P.fromRgba(p)})}function UT(e,t){if(e!==void 0)return e.evaluate(t).map(e=>e.plain).join(``)}function WT(e,t,n){try{return On(e,t)}catch(e){throw e instanceof Tn?new VT(t,n,e.message):e}}const GT=new Map([[`palette`,`theme.effective`],[`preset`,`preset.effective`],[`look`,`look.effective`],[`style`,`style.effective`],[`charset`,`charset.effective`],[`colorCompatibility`,`colorCompatibility.effective`],[`autoWrap`,`autoWrap.effective`],[`padding`,`padding.effective`]]);function KT(e,t,n,r){let i=new Map;for(let[a,o]of Object.entries(t))i.set(a,qT(e,a,o,n,r));return i}function qT(e,t,n,r,i){if(wg(n)){let[a,o]=Tg(n);return JT(r.get(n.persistWhen)??n.persistWhen,n.set,qT(e,t,a,r,i),qT(e,t,o,r,i))}if(`set`in n){let e=r.get(n.set)??n.set;return`to`in n?{kind:`set-literal`,key:n.set,value:n.to,stateVar:e}:`from`in n?{kind:`set-option`,key:n.set,stateVar:e,options:[...O_(n.from,i)]}:`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=GT.get(n.persist)??n.persist;return`to`in n?{kind:`persist-literal`,key:n.persist,value:n.to,stateVar:e}:`from`in n?{kind:`persist-option`,key:n.persist,stateVar:e,options:[...O_(n.from,i)]}:`cycle`in n?{kind:`persist-cycle`,key:n.persist,stateVar:e,members:n.cycle}:`removeSegment`in n?{kind:`layout-op`,key:n.persist,op:{op:`remove`,target:n.removeSegment}}:`insertSegment`in n?{kind:`layout-op`,key:n.persist,op:{op:`insert`,segment:n.insertSegment,anchor:n.anchor,relation:n.relation}}:`insertSegmentFrom`in n?{kind:`layout-op-option`,key:n.persist,anchor:n.anchor,relation:n.relation,options:[...O_(n.insertSegmentFrom,i)]}:{kind:`persist-bounded`,key:n.persist,by:n.by}}return`copy`in n?{kind:`copy`,text:XT(e,n.copy,t)}:`open`in n?{kind:`open`,target:XT(e,n.open,t)}:`reset`in n?{kind:`reset`,key:n.reset}:`doctor`in n?n.doctor===`run`?{kind:`doctor-run`}:{kind:`doctor-fix`,check:n.check}:`undo`in n?{kind:`undo`}:{kind:`redo`}}function JT(e,t,n,r){return{kind:`dual`,selector:e,session:`stateVar`in n&&`stateVar`in r?{...n,stateVar:r.stateVar}:n,durable:r,sessionKey:t}}function YT(e,t){return e.kind===`dual`?Si(ZT(t,e.selector))===!0?e.durable:e.session:e}function XT(e,t,n){try{return e(t)}catch(e){throw Error(`Template parse error in actions.${n}: ${e.message}`,{cause:e})}}function ZT(e,t){return e.has(t)?vw(e.read(t)):``}function QT(e,t){return e.evaluate(t).map(e=>e.plain).join(``)}function $T(e,t,n,r){let i=new Ar(e,{style:H.combine([r,new H({link:t,bold:n})])});return i.noWrap=!0,i.end=``,i}function eE(e,t){return Math.max(e.members.indexOf(ZT(t,e.stateVar)),0)}function tE(e,t,n,r,i){switch(e.kind){case`set-literal`:{let t=ZT(r,e.stateVar);return{effects:[{verb:by,args:[i,e.key,e.value]}],active:t===e.value}}case`set-option`:{let a=n??t,o=ZT(r,e.stateVar);return{effects:[{verb:by,args:[i,e.key,a]}],active:o===a}}case`set-int`:{let a=n??t,o=ZT(r,e.stateVar);return{effects:[{verb:by,args:[i,e.key,a]}],active:o===a}}case`set-cycle`:{let t=e.members[(eE(e,r)+1)%e.members.length];return{effects:[{verb:by,args:[i,e.key,t]}],active:!1}}case`set-bounded`:return{effects:[{verb:xy,args:[i,e.key,String(e.by)]}],active:!1};case`copy`:return{effects:[{verb:Sy,args:[QT(e.text,oT(r))]}],active:!1};case`open`:return{effects:[{verb:Cy,args:[QT(e.target,oT(r))]}],active:!1};case`persist-literal`:{let t=ZT(r,e.stateVar);return{effects:[{verb:Dy,args:[i,e.key,e.value]}],active:t===e.value}}case`persist-option`:{let a=n??t,o=ZT(r,e.stateVar);return{effects:[{verb:Dy,args:[i,e.key,a]}],active:o===a}}case`persist-cycle`:{let t=e.members[(eE(e,r)+1)%e.members.length];return{effects:[{verb:Dy,args:[i,e.key,t]}],active:!1}}case`persist-bounded`:return{effects:[{verb:Oy,args:[i,e.key,String(e.by)]}],active:!1};case`reset`:return{effects:[{verb:ky,args:[i,e.key]}],active:!1};case`undo`:return{effects:[{verb:jy,args:[i]}],active:!1};case`redo`:return{effects:[{verb:My,args:[i]}],active:!1};case`doctor-run`:return{effects:[{verb:Py,args:[i]}],active:!1};case`doctor-fix`:return{effects:[{verb:Fy,args:[i,e.check]}],active:!1};case`layout-op`:return{effects:[{verb:Ay,args:[i,e.key,qm(e.op)]}],active:!1};case`dual`:{let a=YT(e,r),{effects:o,active:s}=tE(a,t,n,r,i);return a===e.durable?{effects:o.map(t=>({...t,args:[...t.args,e.sessionKey]})),active:s}:{effects:o,active:s}}case`layout-op-option`:{let r={op:`insert`,segment:n??t,anchor:e.anchor,relation:e.relation};return{effects:[{verb:Ay,args:[i,e.key,qm(r)]}],active:!1}}}}function nE(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:rc(`action "${e}"`,n,t.members.length,eE(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 rE(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}=nE(e,YT(r,i),t,i),{effects:s,active:c}=tE(r,a,o,i,ZT(i,`session.id`));return $T(a,Ry(s),c)}function iE(e){return{action:{fn:(t,...n)=>rE(t,n,e),argTypes:[`string`,`string`],returnType:`T`}}}function aE(e,t){return new H({bgcolor:P.fromRgba(t),color:P.fromRgba(Us(e,t))})}function oE(e,t){return aE(e.palette,Ys(e.palette,e.disclosure,[t]))}function sE(){return{current:null}}function cE(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 lE(e){return new Ar(e).cellLength}function uE(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 dE(e,t){let n=[];for(let t of e)n.length>0&&n.push(new Ar(` `)),n.push(t);let r=Ar.fromFragments(n);return r.noWrap=t,r.end=``,r}function fE(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 pE(e,t){let n=e.compiled.get(t),r=n&&YT(n,e.store);if(!r||r.kind!==`set-option`&&r.kind!==`persist-option`&&r.kind!==`layout-op-option`)throw Error(`picker 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 ${r?`a ${r.kind} action`:`no such action`}`);return r}function mE(e,t,n,r,i,a,o){let s=pE(a,e),c=a.compiled.get(e),l=a.store,u=ZT(l,`session.id`),d=`stateVar`in s?ZT(l,s.stateVar):void 0,f=s.options.map(lE),p=i?Math.max(1,yw(l.read(`term.cols`))-rx(a.stripStyle)-2*a.padding):1/0,m=lE(`✕`)+1,h=lE(`←`)+1+lE(`→`)+1,g=uE(f,p,m),_=g.length>1?uE(f,p,m+h):g,v=parseInt(ZT(l,t.stateVar),10),y=Number.isInteger(v)?Math.max(0,Math.min(v,_.length-1)):0,b=_[y]??[],x=e=>Ry([{verb:by,args:[u,t.key,String(e)]}]),S=n.flatMap(([e,t])=>[e,t]),C=Ry([{verb:by,args:[u,...S]}]),ee=r?[{verb:by,args:[u,...S]}]:[],te=e=>{let{effects:t}=tE(c,e,e,l,u),n=t.length===1?t[0]:void 0;return n?.verb===`set-state`?Ry([{verb:by,args:[...n.args,...r?S:[]]}]):Ry([...t,...ee])},ne=[$T(`✕`,C,!1)];y>0&&ne.push($T(`←`,x(y-1),!1));for(let e of b){let t=s.options[e];ne.push($T(t,te(t),t===d,o({index:e,count:s.options.length})))}return y<_.length-1&&ne.push($T(`→`,x(y+1),!1)),dE(ne,i)}function hE(e,t){return{picker:{fn:(n,r,i,a)=>{let o=fE(e,r,`set-int`,`an int action ({ set, int: true })`);return mE(n,{key:o.key,stateVar:o.stateVar},[[o.key,`-1`]],i===!0,a===!0,e,e=>oE(cE(t,`{{ picker }}`),{...e,distribution:Ns(void 0)}))},argTypes:[`string`,`string`,`bool`,`bool`],returnType:`T`}}}const gE=Symbol(`cc-candybar.menuDrop`);function _E(e){return e.flatMap(e=>e[gE]??[])}function vE(e,t,n,r){let i=r.activeSegment.current;if(i===null)throw Error(`{{ menu }} rendered with no active segment placement — the render walk must publish one before evaluating a segment template`);let a=r.action,o=Sm(i.segName,e,n.key),s=wm(o),c=xm(e),l=ZT(a.store,o)===c,u=ZT(a.store,`session.id`),d=l?tc:c,f=$T(rc(`{{ menu "${e}" }}`,t,2,+!!l),Ry([{verb:by,args:[u,o,d,s,`0`]}]),!1);return f[gE]=l?[mE(e,{key:s,stateVar:s},[[o,tc],[s,`0`]],n.closeOnPick,n.paged,a,e=>oE(i,{...e,distribution:n.distribution}))]:[],f}const yE=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function bE(e,t){let n=t[t.length-1],r=yE(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:Om(r??{})}}function xE(e){return{menu:{fn:(t,...n)=>{let{displays:r,options:i}=bE(t,n);return vE(t,r,i,e)},argTypes:[`string`,`value`],returnType:`T`}}}function SE(e){let t={fn:(()=>{let t=cE(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:[],returnType:`string`};return{...Uw(()=>cE(e,`{{ color }} / {{ ramp }}`).palette),bgOf:t}}function CE(e){let t=[],n=[];for(let r of e){if(!r.contains(`
|
|
174
|
+
Use 'override' annotation for methods overridden by subclass.`)}}var na=ca(0),ra=function(){var e=!1,t={};return Object.defineProperty(t,`0`,{set:function(){e=!0}}),Object.create(t)[0]=1,e===!1}(),ia=0,aa=function(){};function oa(e,t){Object.setPrototypeOf?Object.setPrototypeOf(e.prototype,t):e.prototype.__proto__===void 0?e.prototype=t:e.prototype.__proto__=t}oa(aa,Array.prototype);var sa=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,ma(function(){var e=new Oi(r,n,i,!0);e.proxy_=a,ee(a,O,e),t&&t.length&&a.spliceWithArray(0,0,t),ra&&Object.defineProperty(a,`0`,na)}),a}_e(t,e);var n=t.prototype;return n.concat=function(){this[O].atom_.reportObserved();var e=[...arguments];return Array.prototype.concat.apply(this.slice(),e.map(function(e){return Fi(e)?e.slice():e}))},n[Symbol.iterator]=function(){var e=this,t=0;return ba({next:function(){return t<e.length?{value:e[t++],done:!1}:{done:!0,value:void 0}}})},me(t,[{key:`length`,get:function(){return this[O].getArrayLength_()},set:function(e){this[O].setArrayLength_(e)}},{key:Symbol.toStringTag,get:function(){return`Array`}}])}(aa);Object.entries(Ai).forEach(function(e){var t=e[0],n=e[1];t!==`concat`&&C(sa.prototype,t,n)});function ca(e){return{enumerable:!1,configurable:!0,get:function(){return this[O].get_(e)},set:function(t){this[O].set_(e,t)}}}function la(e){s(sa.prototype,``+e,ca(e))}function ua(e){if(e>ia){for(var t=ia;t<e+100;t++)la(t);ia=e}}ua(1e3);function da(e,t,n){return new sa(e,t,n)}function G(e,t){if(typeof e==`object`&&e){if(Fi(e))return t!==void 0&&n(23),e[O].atom_;if(Gi(e))return e.atom_;if(Bi(e)){if(t===void 0)return e.keysAtom_;var r=e.data_.get(t)||e.hasMap_.get(t);return r||n(25,t,pa(e)),r}if($i(e)){if(!t)return n(26);var i=e[O].values_.get(t);return i||n(27,t,pa(e)),i}if(Ne(e)||en(e)||B(e))return e}else if(v(e)&&B(e[O]))return e[O];n(28)}function fa(e,t){if(e||n(29),t!==void 0)return fa(G(e,t));if(Ne(e)||en(e)||B(e)||Bi(e)||Gi(e))return e;if(e[O])return e[O];n(24,e)}function pa(e,t){var n;if(t!==void 0)n=G(e,t);else if(sr(e))return e.name;else n=$i(e)||Bi(e)||Gi(e)?fa(e):G(e);return n.name_}function ma(e){var t=I(),n=Yt(!0);kn();try{return e()}finally{An(),Xt(n),mn(t)}}var ha=c.toString;function ga(e,t,n){return n===void 0&&(n=-1),_a(e,t,n)}function _a(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=ha.call(e);if(o!==ha.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=va(e),t=va(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(!_a(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(!(se(t,m)&&_a(e[m],t[m],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function va(e){return Fi(e)?e.slice():ne(e)||Bi(e)||w(e)||Gi(e)?Array.from(e.entries()):e}var ya=i().Iterator?.prototype||{};function ba(e){return e[Symbol.iterator]=xa,Object.assign(Object.create(ya),e)}function xa(){return this}function Sa(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:qn,extras:{getDebugName:pa},$mobx:O}),e.$mobx=O,e.FlowCancellationError=Dr,e.ObservableMap=zi,e.ObservableSet=Wi,e.Reaction=In,e._allowStateChanges=N,e._allowStateChangesInsideComputed=or,e._allowStateReadsEnd=gn,e._allowStateReadsStart=hn,e._autoAction=ar,e._endAction=Jt,e._getAdministration=fa,e._getGlobalState=Cn,e._interceptReads=Fr,e._isComputingDerivation=on,e._resetGlobalState=wn,e._startAction=M,e.action=ir,e.autorun=cr,e.comparer=ze,e.computed=Vt,e.configure=br,e.createAtom=Pe,e.defineProperty=Qr,e.entries=qr,e.extendObservable=U,e.flow=jr,e.flowResult=Nr,e.get=Zr,e.getAtom=G,e.getDebugName=pa,e.getDependencyTree=xr,e.getObserverTree=Cr,e.has=Xr,e.intercept=Ir,e.isAction=sr,e.isBoxedObservable=$t,e.isComputed=Br,e.isComputedProp=Vr,e.isFlow=Pr,e.isFlowCancellationError=Or,e.isObservable=Ur,e.isObservableArray=Fi,e.isObservableMap=Bi,e.isObservableObject=$i,e.isObservableProp=Wr,e.isObservableSet=Gi,e.keys=Gr,e.makeAutoObservable=Ci,e.makeObservable=xi,e.observable=j,e.observe=ei,e.onBecomeObserved=mr,e.onBecomeUnobserved=hr,e.onReactionError=Ln,e.override=Ge,e.ownKeys=$r,e.reaction=dr,e.remove=Yr,e.runInAction=or,e.set=Jr,e.spy=qn,e.toJS=ai,e.trace=oi,e.transaction=ci,e.untracked=pn,e.values=Kr,e.when=li})),gw=pe(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=mw():t.exports=hw()}))();function _w(e){if(Array.isArray(e))return Object.freeze(e.map(_w));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]=_w(r);return Object.freeze(t)}return e}function vw(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 yw(e){return typeof e==`string`?e:String(e)}function bw(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 xw(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 Sw(e,t){if(!(e instanceof Ar))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=e.style.add(t),n}function Cw(e){return{fn:(t=>Sw(t,e)),argTypes:[`liftable`],returnType:`T`}}function ww(e){return{fn:((t,n)=>Sw(n,new H({[e]:P.parse(t)}))),argTypes:[`string`,`liftable`],returnType:`T`}}function Tw(e,t){return new H({[e]:t})}function Ew(){let e={};for(let t of lr)e[t]=Cw(Tw(t,!0)),e[`not_${t}`]=Cw(Tw(t,!1));for(let[t,n]of Object.entries(dr))e[t]=Cw(Tw(n,!0));return e}const Dw={fn:((e,t)=>Sw(t,H.parse(e))),argTypes:[`string`,`liftable`],returnType:`T`},Ow={fn:((e,t)=>Sw(t,new H({link:e}))),argTypes:[`string`,`liftable`],returnType:`T`};function kw(){return{fg:ww(`color`),bg:ww(`bgcolor`),...Ew(),link:Ow,style:Dw}}function Aw(e,t){if(!En.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 Dn(e)}function jw(e,t){return{fn:t,argTypes:e,returnType:`string`}}function Mw(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}`+(e===void 0?` — ${t} takes it as its last argument`:``))}return e}const Nw=jw([`string`,`int`],((e,t)=>Pn(Aw(e,`darken`),Mw(t,`darken`,`levels`)).hex)),Pw=jw([`string`,`int`],((e,t)=>Pn(Aw(e,`lighten`),-Mw(t,`lighten`,`levels`)).hex)),Fw={min:0,max:100,note:`0 = from, 100 = toward`},Iw=jw([`string`,`string`,`float`],((e,t,n)=>sn(Aw(e,`mix`),Aw(t,`mix`),Mw(n,`mix`,`percentage`,Fw)/100).hex)),Lw={min:1,max:21,note:`4.5 = AA body text, 3 = AA large text`},Rw=jw([`string`],(e=>Fn(Aw(e,`contrastOn`)).hex)),zw=jw([`string`,`string`,`float`],((e,t,n)=>Rn(Aw(e,`readableOn`),Aw(t,`readableOn`),Mw(n,`readableOn`,`ratio`,Lw)).hex)),Bw={hueShift:`shiftHue`,chromaScale:`scaleChroma`,lightnessScale:`scaleLightness`,lightnessShift:`shiftLightness`};function Vw(){let e={};for(let[t,n]of Object.entries(Bw)){let r=t;e[n]=jw([`string`,`float`],((e,t)=>{let i={...hn,[r]:Mw(t,n,`amount`)};return R.fromRgba(Aw(e,n)).applyKey(i).toRgba().hex}))}return e}function Hw(){return{darken:Nw,lighten:Pw,mix:Iw,contrastOn:Rw,readableOn:zw,...Vw()}}function Uw(e,t){if(e.length===0)throw RangeError(`ramp needs at least one stop after the easing: ramp <value> <easing> <position> <color> …`);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:On(t,e[r+1])});return n}function Ww(e){return{color:{fn:(t=>On(e(),t).hex),argTypes:[`string`],returnType:`string`},ramp:{fn:((...t)=>{if(t.length<2)throw RangeError(`ramp needs a value and an easing before its stops (got ${t.length}): ramp <value> "linear"|"step" <position> <color> …`);let[n,r,...i]=t;return new ar(ir(r),Uw(i,e())).at(n).hex}),argTypes:[`float`,`string`],argTypePattern:`alternating`,returnType:`string`}}}function Gw(){return{...kw(),...Hw()}}new H({color:`red`,dim:!0});const Kw=/^(?:(?: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,qw=/^(?<family>opus|sonnet|haiku)\s+(?<major>\d+)(?:\.(?<minor>\d))?$/i;function Jw(e){if(!e)return`Claude`;let t=e.trim().replace(/\s*\([^)]*\)\s*$/,``).replace(/\s*\[[^\]]*\]\s*$/,``).trim(),n=t.match(Kw);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(qw);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 Yw(e){let t=e.match(qw);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 Xw(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 Zw(e){return e.toLocaleString()}const Qw=[`▁`,`▂`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],$w=Qw.length;function eT(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*($w-1));o+=Qw[t]}return o}function tT(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}const nT=li(),rT=[...pi];function iT(){return{basename:{fn:e=>l(e),argTypes:[`string`]},dirname:{fn:e=>u(e),argTypes:[`string`]},abbreviatePath:{fn:e=>Xw(e),argTypes:[`string`]},int:{fn:e=>bw(e),argTypes:[`value`]},string:{fn:e=>yw(e),argTypes:[`value`]},bool:{fn:e=>xw(e),argTypes:[`value`]},urlEncode:{fn:e=>encodeURIComponent(e),argTypes:[`string`]},themes:{fn:()=>nT,argTypes:[]},styles:{fn:()=>rT,argTypes:[]},sparkline:{fn:(e,t)=>eT(tT(e),t),argTypes:[`string`,`int`]}}}function aT(e=()=>new Date){return{minutesUntilReset:{fn:t=>Math.round(Math.max(0,t*1e3-e().getTime())/6e4),argTypes:[`int`]},formatInteger:{fn:e=>Zw(e),argTypes:[`int`]},round:{fn:e=>Math.round(e),argTypes:[`float`]},formatModelName:{fn:e=>Jw(e),argTypes:[`string`]},shortenModelName:{fn:e=>Yw(e),argTypes:[`string`]}}}function oT(e,t=()=>new Date){return xu({fromString:e=>new Ar(e),toString:e=>e.plain,isT:e=>e instanceof Ar,clock:t,missingKey:`error`,funcs:{...lf(),...ym(),...Yf(),..._p(),...ef(t),...Wu(),...Cf(),...Gw(),...iT(),...aT(t),...e??{}}})}function sT(e){return cT(e,new Set(e.names()),``)}function cT(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`?lT(a,e.readDocument(a)):e.read(a);let o=`${a}.`;for(let n of t)if(n.startsWith(o))return cT(e,t,a)}})}function lT(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}`)}}const uT=/\r\n|\r|\n/g,dT=e=>X(e.replace(uT,` `).trim());function fT(e){return t=>{let n=e.exec(t)?.[1];return n===void 0?Q(`regex no-match`):X(n.replace(uT,` `))}}const pT=e=>{try{return X(JSON.parse(e))}catch(e){return Q(`JSON parse failed: ${e.message}`)}};function mT(e,t){return t.kind!==`ttl`||t.durationMs>=500?t:(D(`declareShell "${e}": ttl ${t.durationMs}ms below floor 500ms; clamping`),{kind:`ttl`,durationMs:500})}function hT(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]}"`)}}function gT(e,t){return{where:`output of "${e}"`,read:async()=>{let n=await Te({bin:`/bin/sh`,args:[`-c`,e],category:`user-shell`,signal:t});if(!n.ok&&n.reason===`aborted`)throw t.reason;return n.ok?X(n.stdout):Q(`shell "${e}" ${n.exitCode===null?[n.reason,n.error].filter(e=>e!==void 0).join(`: `):`exited with code ${n.exitCode}`}`)}}}function _T(e,t,n){return{where:`"${e}"`,read:async()=>{try{let r=await w(e,{encoding:`utf8`,signal:n});return X(t===`first-line`?r.split(/\r?\n/)[0]??``:r)}catch{if(n.aborted)throw n.reason;return Q(`file unreadable: ${e}`)}}}}function vT(e,t,n){if(e.kind!==`ok`)return e;let r=t(e.value);return r.kind===`failed`?Q(`${r.reason} in ${n}`):r}const yT=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],bT=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],xT=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],ST=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function CT(e,t){let n=[[`2006`,e=>String(e.getFullYear())],[`January`,e=>yT[e.getMonth()]],[`Monday`,e=>xT[e.getDay()]],[`Jan`,e=>bT[e.getMonth()]],[`Mon`,e=>ST[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 wT={branch:`string`,sha:`string`,dirty:`boolean`,ahead:`number`,behind:`number`,stash:`number`};function TT(e,t,n,r){if(e===null){if(n!==void 0)return n;let e=wT[t];try{return kT(r,e)}catch{return AT(e)}}switch(t){case`branch`:return e.branch===`detached`?``:e.branch;case`sha`:return Uy(e.sha,``);case`dirty`:return e.status!==`clean`;case`ahead`:return Uy(e.aheadBehind,{ahead:0,behind:0}).ahead;case`behind`:return Uy(e.aheadBehind,{ahead:0,behind:0}).behind;case`stash`:return Uy(e.stashCount,0)}}var ET=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}},DT=class{buckets=new Map;subscribe(e,t){let n=this.buckets.get(e);if(!n){let t=new Set;n={timer:oe(()=>{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&&(ae(n.timer),this.buckets.delete(e)))}dispose(){for(let{timer:e}of this.buckets.values())ae(e);this.buckets.clear()}bucketCount(){return this.buckets.size}};function OT(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function kT(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`?yw(e):t===`number`?bw(e):xw(e)}function AT(e){return e===`number`?0:e===`boolean`?!1:``}var jT=class{inputMetas=new Map;lastErrors=new Map;watchMgr=new ET;ttlMgr=new DT;gitSubscriptions=new Map;cleanups=[];inFlight=new Map;reads=new XS;abort=new AbortController;engine=oT();gitProvider;ownsGitProvider;sessionState;constructor(e,t=``,n,r){this.store=e,this.defaultEmptyValue=t,n?(this.gitProvider=n,this.ownsGitProvider=!1):(this.gitProvider=new rC({sanityIntervalMs:0}),this.ownsGitProvider=!0),this.sessionState=r}get variableStore(){return this.store}declareLiteral(e,t){this.store.defineBox(e,vw(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,gT(t,this.abort.signal),mT(e,n.cache),n.parse)}declareFile(e,t,n){this.declareSource(e,_T(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,dT,t.default,n);case`regex`:return this.scalarPublisher(e,fT(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=vT(n,t,r);this.noteOutcome(e,a),this.store.setBox(e,Uy(a,i))}}documentPublisher(e,t,n){let r=t===void 0?Z:X(t);return this.store.defineDocument(e,r),i=>{let a=vT(i,pT,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=sT(this.store);try{let t=r.evaluate(i).map(e=>e.plain).join(``);return this.lastErrors.delete(e),t}catch(t){return this.recordError(e,t instanceof Error?t.message:String(t)),this.stringInitial(n.varDefault)}}),this.store.read(e)}declareTime(e,t){let n=t.ttlMs??1e3;this.store.defineBox(e,`string`,(e=>{try{return CT(t.format,e)}catch{return this.stringInitial(t.varDefault)}})(new Date));let r=this.ttlMgr.subscribe(n,()=>{try{this.store.setBox(e,CT(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=wT[t.field],r=t.varDefault===void 0?AT(n):kT(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,TT(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(`session.id`);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=OT(e,n.path),i=this.store.getType(t);if(r!==void 0)try{this.store.setBox(t,kT(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`)}})}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,gw.reaction)(()=>{let t=sT(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,gw.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,kT(this.defaultEmptyValue,t))}catch{this.store.setBox(e,AT(t))}}defaultFor(e){try{return kT(this.defaultEmptyValue,e)}catch{return AT(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 MT=new Map,NT=new Map;function PT(e){let t=ai(e),n=MT.get(t);if(n!==void 0)return n;let r=Gn(t);if(r===null)throw Error(`Palette "${e}" (resolved "${t}") did not resolve in the theme registry — allowed names and the registry are inconsistent`);return MT.set(t,r),r}function FT(e,t){let n=`${e.name} ${t.hueShift} ${t.chromaScale} ${t.lightnessScale} ${t.lightnessShift}`,r=NT.get(n);if(r!==void 0)return r;let i=tr(e,t);return NT.set(n,i),i}function IT(e,t){let n=[],r=[],i=()=>{if(!r.length)return;let e=LT(r,t);e.plain.length>0&&n.push(e),r=[]};for(let a of e)if(a.style.link){i();let e=LT([a],t);e.plain.length>0&&n.push(e)}else r.push(a);return i(),n}function LT(e,t){let n=t!==void 0&&!t.isNull?e.map(e=>RT(e,t)):e,r=Ar.fromFragments(n);return r.end=``,r.noWrap=!0,n.length===1?r.style=n[0].style:t!==void 0&&!t.isNull&&(r.style=t),r}function RT(e,t){let n=e.copy();return n.style=t.add(e.style),n}function zT(e,t){return e===void 0?!0:e.evaluate(t).map(e=>e.plain).join(``)!==`false`}function BT(e,t){let n=Ar.fromFragments(e);return n.end=``,n.noWrap=!0,t!==void 0&&!t.isNull&&(n.style=t),n}function VT(e,t){let{width:n,justify:r,truncate:i,truncateMarker:a=`…`,baseStyle:o,padding:s}=t;if(e.length===0)return[];let c=BT(e,o).pad(s);return n===`auto`||(c.cellLength>n?c.truncate(n,{mode:i,marker:a}):c.cellLength<n&&c.align(r,n)),[c]}var HT=class extends Error{constructor(e,t,n){super(`Invalid ${t} color ${JSON.stringify(e)}: ${n}`),this.name=`ColorSpecError`}};function UT(e,t,n,r,i,a,o,s,c){let l={segName:t,palette:n,disclosure:r,bg:void 0};e.current=l;let u=WT(o,c),d=u===void 0?i:GT(n,u,`bg`);l.bg=d;let f=WT(s,c),p=f===void 0?a(d):GT(n,f,`fg`);return new H({bgcolor:P.fromRgba(d),color:p===void 0?void 0:P.fromRgba(p)})}function WT(e,t){if(e!==void 0)return e.evaluate(t).map(e=>e.plain).join(``)}function GT(e,t,n){try{return On(e,t)}catch(e){throw e instanceof Tn?new HT(t,n,e.message):e}}const KT=new Map([[`palette`,`theme.effective`],[`preset`,`preset.effective`],[`look`,`look.effective`],[`style`,`style.effective`],[`charset`,`charset.effective`],[`colorCompatibility`,`colorCompatibility.effective`],[`autoWrap`,`autoWrap.effective`],[`padding`,`padding.effective`]]);function qT(e,t,n,r){let i=new Map;for(let[a,o]of Object.entries(t))i.set(a,JT(e,a,o,n,r));return i}function JT(e,t,n,r,i){if(wg(n)){let[a,o]=Tg(n);return YT(r.get(n.persistWhen)??n.persistWhen,n.set,JT(e,t,a,r,i),JT(e,t,o,r,i))}if(`set`in n){let e=r.get(n.set)??n.set;return`to`in n?{kind:`set-literal`,key:n.set,value:n.to,stateVar:e}:`from`in n?{kind:`set-option`,key:n.set,stateVar:e,options:[...O_(n.from,i)]}:`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=KT.get(n.persist)??n.persist;return`to`in n?{kind:`persist-literal`,key:n.persist,value:n.to,stateVar:e}:`from`in n?{kind:`persist-option`,key:n.persist,stateVar:e,options:[...O_(n.from,i)]}:`cycle`in n?{kind:`persist-cycle`,key:n.persist,stateVar:e,members:n.cycle}:`removeSegment`in n?{kind:`layout-op`,key:n.persist,op:{op:`remove`,target:n.removeSegment}}:`insertSegment`in n?{kind:`layout-op`,key:n.persist,op:{op:`insert`,segment:n.insertSegment,anchor:n.anchor,relation:n.relation}}:`insertSegmentFrom`in n?{kind:`layout-op-option`,key:n.persist,anchor:n.anchor,relation:n.relation,options:[...O_(n.insertSegmentFrom,i)]}:{kind:`persist-bounded`,key:n.persist,by:n.by}}return`copy`in n?{kind:`copy`,text:ZT(e,n.copy,t)}:`open`in n?{kind:`open`,target:ZT(e,n.open,t)}:`reset`in n?{kind:`reset`,key:n.reset}:`doctor`in n?n.doctor===`run`?{kind:`doctor-run`}:{kind:`doctor-fix`,check:n.check}:`undo`in n?{kind:`undo`}:{kind:`redo`}}function YT(e,t,n,r){return{kind:`dual`,selector:e,session:`stateVar`in n&&`stateVar`in r?{...n,stateVar:r.stateVar}:n,durable:r,sessionKey:t}}function XT(e,t){return e.kind===`dual`?Si(QT(t,e.selector))===!0?e.durable:e.session:e}function ZT(e,t,n){try{return e(t)}catch(e){throw Error(`Template parse error in actions.${n}: ${e.message}`,{cause:e})}}function QT(e,t){return e.has(t)?yw(e.read(t)):``}function $T(e,t){return e.evaluate(t).map(e=>e.plain).join(``)}function eE(e,t,n,r){let i=new Ar(e,{style:H.combine([r,new H({link:t,bold:n})])});return i.noWrap=!0,i.end=``,i}function tE(e,t){return Math.max(e.members.indexOf(QT(t,e.stateVar)),0)}function nE(e,t,n,r,i){switch(e.kind){case`set-literal`:{let t=QT(r,e.stateVar);return{effects:[{verb:by,args:[i,e.key,e.value]}],active:t===e.value}}case`set-option`:{let a=n??t,o=QT(r,e.stateVar);return{effects:[{verb:by,args:[i,e.key,a]}],active:o===a}}case`set-int`:{let a=n??t,o=QT(r,e.stateVar);return{effects:[{verb:by,args:[i,e.key,a]}],active:o===a}}case`set-cycle`:{let t=e.members[(tE(e,r)+1)%e.members.length];return{effects:[{verb:by,args:[i,e.key,t]}],active:!1}}case`set-bounded`:return{effects:[{verb:xy,args:[i,e.key,String(e.by)]}],active:!1};case`copy`:return{effects:[{verb:Sy,args:[$T(e.text,sT(r))]}],active:!1};case`open`:return{effects:[{verb:Cy,args:[$T(e.target,sT(r))]}],active:!1};case`persist-literal`:{let t=QT(r,e.stateVar);return{effects:[{verb:Dy,args:[i,e.key,e.value]}],active:t===e.value}}case`persist-option`:{let a=n??t,o=QT(r,e.stateVar);return{effects:[{verb:Dy,args:[i,e.key,a]}],active:o===a}}case`persist-cycle`:{let t=e.members[(tE(e,r)+1)%e.members.length];return{effects:[{verb:Dy,args:[i,e.key,t]}],active:!1}}case`persist-bounded`:return{effects:[{verb:Oy,args:[i,e.key,String(e.by)]}],active:!1};case`reset`:return{effects:[{verb:ky,args:[i,e.key]}],active:!1};case`undo`:return{effects:[{verb:jy,args:[i]}],active:!1};case`redo`:return{effects:[{verb:My,args:[i]}],active:!1};case`doctor-run`:return{effects:[{verb:Py,args:[i]}],active:!1};case`doctor-fix`:return{effects:[{verb:Fy,args:[i,e.check]}],active:!1};case`layout-op`:return{effects:[{verb:Ay,args:[i,e.key,qm(e.op)]}],active:!1};case`dual`:{let a=XT(e,r),{effects:o,active:s}=nE(a,t,n,r,i);return a===e.durable?{effects:o.map(t=>({...t,args:[...t.args,e.sessionKey]})),active:s}:{effects:o,active:s}}case`layout-op-option`:{let r={op:`insert`,segment:n??t,anchor:e.anchor,relation:e.relation};return{effects:[{verb:Ay,args:[i,e.key,qm(r)]}],active:!1}}}}function rE(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:rc(`action "${e}"`,n,t.members.length,tE(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 iE(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}=rE(e,XT(r,i),t,i),{effects:s,active:c}=nE(r,a,o,i,QT(i,`session.id`));return eE(a,Ry(s),c)}function aE(e){return{action:{fn:(t,...n)=>iE(t,n,e),argTypes:[`string`,`string`],returnType:`T`}}}function oE(e,t){return new H({bgcolor:P.fromRgba(t),color:P.fromRgba(Us(e,t))})}function sE(e,t){return oE(e.palette,Ys(e.palette,e.disclosure,[t]))}function cE(){return{current:null}}function lE(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 uE(e){return new Ar(e).cellLength}function dE(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 fE(e,t){let n=[];for(let t of e)n.length>0&&n.push(new Ar(` `)),n.push(t);let r=Ar.fromFragments(n);return r.noWrap=t,r.end=``,r}function pE(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 mE(e,t){let n=e.compiled.get(t),r=n&&XT(n,e.store);if(!r||r.kind!==`set-option`&&r.kind!==`persist-option`&&r.kind!==`layout-op-option`)throw Error(`picker 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 ${r?`a ${r.kind} action`:`no such action`}`);return r}function hE(e,t,n,r,i,a,o){let s=mE(a,e),c=a.compiled.get(e),l=a.store,u=QT(l,`session.id`),d=`stateVar`in s?QT(l,s.stateVar):void 0,f=s.options.map(uE),p=i?Math.max(1,bw(l.read(`term.cols`))-rx(a.stripStyle)-2*a.padding):1/0,m=uE(`✕`)+1,h=uE(`←`)+1+uE(`→`)+1,g=dE(f,p,m),_=g.length>1?dE(f,p,m+h):g,v=parseInt(QT(l,t.stateVar),10),y=Number.isInteger(v)?Math.max(0,Math.min(v,_.length-1)):0,b=_[y]??[],x=e=>Ry([{verb:by,args:[u,t.key,String(e)]}]),S=n.flatMap(([e,t])=>[e,t]),C=Ry([{verb:by,args:[u,...S]}]),ee=r?[{verb:by,args:[u,...S]}]:[],te=e=>{let{effects:t}=nE(c,e,e,l,u),n=t.length===1?t[0]:void 0;return n?.verb===`set-state`?Ry([{verb:by,args:[...n.args,...r?S:[]]}]):Ry([...t,...ee])},ne=[eE(`✕`,C,!1)];y>0&&ne.push(eE(`←`,x(y-1),!1));for(let e of b){let t=s.options[e];ne.push(eE(t,te(t),t===d,o({index:e,count:s.options.length})))}return y<_.length-1&&ne.push(eE(`→`,x(y+1),!1)),fE(ne,i)}function gE(e,t){return{picker:{fn:(n,r,i,a)=>{let o=pE(e,r,`set-int`,`an int action ({ set, int: true })`);return hE(n,{key:o.key,stateVar:o.stateVar},[[o.key,`-1`]],i===!0,a===!0,e,e=>sE(lE(t,`{{ picker }}`),{...e,distribution:Ns(void 0)}))},argTypes:[`string`,`string`,`bool`,`bool`],returnType:`T`}}}const _E=Symbol(`cc-candybar.menuDrop`);function vE(e){return e.flatMap(e=>e[_E]??[])}function yE(e,t,n,r){let i=r.activeSegment.current;if(i===null)throw Error(`{{ menu }} rendered with no active segment placement — the render walk must publish one before evaluating a segment template`);let a=r.action,o=Sm(i.segName,e,n.key),s=wm(o),c=xm(e),l=QT(a.store,o)===c,u=QT(a.store,`session.id`),d=l?tc:c,f=eE(rc(`{{ menu "${e}" }}`,t,2,+!!l),Ry([{verb:by,args:[u,o,d,s,`0`]}]),!1);return f[_E]=l?[hE(e,{key:s,stateVar:s},[[o,tc],[s,`0`]],n.closeOnPick,n.paged,a,e=>sE(i,{...e,distribution:n.distribution}))]:[],f}const bE=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function xE(e,t){let n=t[t.length-1],r=bE(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:Om(r??{})}}function SE(e){return{menu:{fn:(t,...n)=>{let{displays:r,options:i}=xE(t,n);return yE(t,r,i,e)},argTypes:[`string`,`value`],returnType:`T`}}}function CE(e){let t={fn:(()=>{let t=lE(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:[],returnType:`string`};return{...Ww(()=>lE(e,`{{ color }} / {{ ramp }}`).palette),bgOf:t}}function wE(e){let t=[],n=[];for(let r of e){if(!r.contains(`
|
|
175
175
|
`)){n.push(r);continue}let e=r.split(`
|
|
176
|
-
`);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function
|
|
177
|
-
`)}var
|
|
178
|
-
`)||null}var WE=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=zE(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??this.buildState(t,null,[]),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.state.validatorDisposers.forEach(e=>e()),n.watcher?.release(),this.entries.delete(t)}}return this.refreshWatcher(o,a.resolvedPath),this.observers.onReload?.(o),o}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.validatorDisposers.forEach(e=>e()),e.state=t.state),this.refreshWatcher(e,t.resolvedPath),this.observers.onReload?.(e)}loadFromDisk(e,t,n){let r=ov(e,t,n),i=r.kind===`file`?r.path:null,a=[uv(e,t),cv(r)],o;try{o=this.buildState(t,i,a)}catch(e){return e instanceof da&&a.push(...e.warnings),{resolvedPath:i,warning:UE(a),state:null,error:e instanceof da||e instanceof Error?e.message:String(e)}}return{resolvedPath:i,warning:UE(a),state:o,error:null}}buildState(e,t,n){let{config:r,raw:i,source:a,warnings:o}=dv(t,fw);n.push(...o);let s=mv(r,t??`<default>`,a),c=new RE,l=new AT(c,s.globals.default_empty_value??``,this.deps.gitService,this.deps.sessionState),u,d=[];try{u=jE(s,l,{cwd:e}),n.push(...u.loadWarnings);for(let{key:e,spec:t}of uS(s))d.push(rS(e,t));for(let{key:e,spec:t}of Kx(s))d.push(qx(e,t))}catch(e){for(let e of d)e();throw l.dispose(),e}return{config:s,store:c,registry:l,compiled:u,neededInputPaths:YC(s),lastRenderCellsBySegment:new Map,validatorDisposers:d,authoredRoots:BE(r,i)}}refreshWatcher(e,t){e.configFilePath=t;let n=HE(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){Y(`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 GE=16384;var KE=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<GE){this.rollingTimestamps.push(e);return}this.rollingTimestamps[this.rollingHead]=e,this.rollingHead=(this.rollingHead+1)%GE}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:Vy,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}}};const qE={load:()=>({}),save:()=>{},flush:()=>{}};function JE(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,new Map(Object.entries(r)));return t}var YE=class{sessions;storage;atom=(0,hw.createAtom)(`SessionState`);constructor(e=qE,t=256){this.maxSessions=t,this.storage=e,this.sessions=new Map,this.hydrateFromStorage()}useStorage(e){this.storage=e,this.hydrateFromStorage()}hydrateFromStorage(){this.sessions=JE(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,hw.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,hw.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,hw.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}};const XE=(e,t)=>D(t);function ZE(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 QE=class{timer=null;pending=null;constructor(e,t=500,n=XE){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 ZE(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 $E={default_bg:`string`,default_fg:`string`,default_empty_value:`string`,default_separator:`string`,default_truncate_marker:`string`,palette:`string`,look:`string`,preset:`string`,style:`string`,autoWrap:`boolean`,padding:`number`,charset:`string`,updateNotice:`boolean`,colorCompatibility:`string`},eD=new Set([`1`,`true`]),tD=new Set([`0`,`false`,``]);function nD(e,t){let n=DD(e),r=n.scope===`globals`?$E[n.field]:`string`;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(eD.has(t))return`true`;if(tD.has(t))return`false`;throw Error(`persistValueText: "${e}" expects boolean-ish (1, 0, true, false), got "${t}"`)}function rD(e){try{return r.readFileSync(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return null;throw e}}function iD(e,t,n){try{if(t===null){r.rmSync(e,{force:!0});return}r.mkdirSync(c.dirname(e),{recursive:!0}),ke(e,t)}catch(t){let r=`config write failed (${e}): ${t.message}`;throw n(`error`,r),Error(r)}}function aD(e){return/^\s*$/.test(e)?null:ji(e)}function oD(e,t){return e!==null&&Ni(e,t)!==void 0}function sD(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(sD),...i}}return e}function cD(e){if(!ro(e))return sD(e);let{rows:t,...n}=e;return{rows:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,sD(t)])),...n}}const lD=uw,uD=lD.segments,dD=lD.presets,fD=lD.root;function pD(e,t,n,r){if(!oD(e,t)&&n===void 0)throw new $(`cannot edit ${r}: neither the config file nor the bundled default declares ${t.join(`.`)}`)}function mD(e,t){let n=sh(t);return t.scope===`segment-palette`&&pD(e,[`segments`,t.segment],uD[t.segment],n.join(`.`)),n}function hD(e){return ji(zi(e))}function gD(){return Object.entries(fD.rows).map(([e,t])=>{let n=sD(t);return{path:[`root`],fragment:hD({rows:{[e]:n}}),unit:{path:[`root`,`rows`,e],value:n}}})}function _D(e,t){let n=e===null?void 0:Ni(e,t);return n===void 0?null:{path:t,fragment:n,unit:null}}function vD(e,t){if(t===void 0)return null;let n=cD(t);return{path:e,fragment:hD(n),unit:{path:e,value:n}}}function yD(e,t){let n=[`presets`,t],r=[...n,`root`],i=dD[t];pD(e,n,i,r.join(`.`));let a=_D(e,r)??vD(r,i?.root);return a!==null&&aa(a.fragment)?a:null}function bD(e,t){let n=ia(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 xD(e,t){return[...gD(),_D(e,[`root`]),yD(e,t)].filter(e=>e!==null).reduce(bD,new Map)}function SD(e,t,n){for(let{node:r,...i}of xD(e,t).values())if(sa(r,n))return i;throw new $(`${CD(e,t).join(`.`)} holds no segment "${n}" — the bar you clicked is stale; it reloads on the next render`)}function CD(e,t){return yD(e,t)?.path??[`root`]}function wD(e,t){return t.scope===`preset-root`?CD(e,t.preset):sh(t)}function TD(e,{unit:t}){return t===null?e:$i(e,t.path,zi(t.value),Li)}function ED(e){let t=oh(e);if(t===null)throw Error(`"${e}" is not a valid persist target`);return t}function DD(e){let t=ED(e);if(t.scope===`preset-root`)throw Error(`"${e}" names a layout, not a value`);return t}function OD(e,t){let n=DD(t),r=aD(rD(e)??``),i=r===null?void 0:Ni(r,sh(n));return i!==void 0&&`value`in i?i.value:void 0}function kD(e,t,n,r){let i=DD(n),a=rD(t);zD(e,t,{before:a,after:$i(a??``,mD(aD(a??``),i),nD(n,r),Li)})}function AD(e,t,n){let r=ED(n),i=rD(t);if(i===null)return;let a=ea(i,wD(aD(i),r));a!==i&&zD(e,t,{before:i,after:a})}function jD(e,t,n,r){let i=ED(n);if(i.scope!==`preset-root`)throw Error(`"${n}" is not a "presets.<name>.root" target`);let a=rD(t),o=r.op===`remove`?r.target:r.anchor,s=SD(aD(a??``),i.preset,o),c=TD(a??``,s),l=r.op===`remove`?la(c,s.path,r.target):ua(c,s.path,r.segment,r.anchor,r.relation);if(l===null)throw new $(`${s.path.join(`.`)} in ${t} has no segment "${o}" — the bar you clicked is stale; it reloads on the next render`);zD(e,t,{before:a,after:l})}const MD={past:[],future:[]};function ND(e){if(typeof e!=`object`||!e)return!1;let t=e;return(t.before===null||typeof t.before==`string`)&&typeof t.after==`string`}function PD(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.past)&&t.past.every(ND)&&Array.isArray(t.future)&&t.future.every(ND)}function FD(e){let t;try{t=r.readFileSync(e.historyPath,`utf8`)}catch(t){let n=t.code;return n!==`ENOENT`&&e.logger(`warn`,`config-edit-history read failed (${n}); starting empty`),{}}try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e)&&Object.values(e).every(PD))return e}catch{}return e.logger(`warn`,`config-edit-history load: unexpected shape, starting empty`),{}}function ID(e,t){try{r.mkdirSync(c.dirname(e.historyPath),{recursive:!0}),ke(e.historyPath,JSON.stringify(t),384)}catch(t){let n=`config-edit-history write failed: ${t.message}`;throw e.logger(`error`,n),Error(n)}}function LD(e,t){let n=[...e,t];return n.length>50?n.slice(-50):n}function RD(e,t,n,r,i){iD(t,n,e.logger);try{ID(e,r)}catch(e){throw Error(`${i} landed in ${t} but recording it failed — it is not undoable: ${e.message}`)}}function zD(e,t,n){let r=FD(e),{past:i}=r[t]??MD;RD(e,t,n.after,{...r,[t]:{past:LD(i,n),future:[]}},`edit`)}function BD(e,t){let n=FD(e),{past:r,future:i}=n[t]??MD,a=r[r.length-1];return a===void 0?null:(HD(t,a.after,`undo`),RD(e,t,a.before,{...n,[t]:{past:r.slice(0,-1),future:LD(i,a)}},`undo`),a)}function VD(e,t){let n=FD(e),{past:r,future:i}=n[t]??MD,a=i[i.length-1];return a===void 0?null:(HD(t,a.before,`redo`),RD(e,t,a.after,{...n,[t]:{past:LD(r,a),future:i.slice(0,-1)}},`redo`),a)}function HD(e,t,n){if(rD(e)!==t)throw new $(`${n}: ${e} has changed since that edit — refusing to overwrite it`)}function UD(e){let t=Ee({bin:`tmux`,args:[`-S`,e.socket,`display`,`-p`,`-t`,e.pane,`#{client_termfeatures}`],timeoutMs:2e3,category:`doctor.tmux`});return t.ok?{kind:`ok`,value:t.stdout.trim().split(`,`).filter(e=>e!==``)}:{kind:`failed`,reason:`tmux display -p failed (${t.error??[t.reason,t.stderr.trim()].filter(e=>e!==``).join(`: `)})`}}function WD(){return{probeTmux:UD,claudeSettingsPath:Hy()}}function GD(e){return r.existsSync(e.claudeSettingsPath)?r.readFileSync(e.claudeSettingsPath,`utf8`):``}function KD(e){if(/^\s*$/.test(e))return{};let t=Ri.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`not a JSON object`);let n=t.env;if(n===void 0)return{};if(typeof n!=`object`||!n||Array.isArray(n))throw Error("`env` is not an object");return n}function qD(e,t){return t===void 0?{kind:`unreported`}:t===null?{kind:`outside`}:{kind:`inside`,hint:t,termfeatures:e.probeTmux(t)}}function JD(e){try{return KD(GD(e))}catch(t){throw Error(`cannot read ${e.claudeSettingsPath}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}function YD(e,t){return{tmux:qD(e,t),claudeSettingsEnv:JD(e)}}function XD(e,t,n){switch(t.kind){case`claude-settings-env`:{let i=$i(GD(e),[`env`,t.name],JSON.stringify(t.value),Ri);return r.mkdirSync(c.dirname(e.claudeSettingsPath),{recursive:!0}),ke(e.claudeSettingsPath,i),{...n,claudeSettingsEnv:JD(e)}}default:return t.kind}}function ZD(e){if(!e)throw new $(`session id is required`);if(e.includes(`/`)||e.includes(`..`))throw new $(`invalid session id "${e}"`);return e}function QD(e){return $D(()=>decodeURIComponent(e))}function $D(e){try{return e()}catch(e){throw e instanceof URIError?new $(`malformed wire encoding: ${e.message}`):e}}function eO(e,t){let n=Ee({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 tO=(e,t)=>eO(QD(e),t),nO=(e,t)=>{let n=Ee({bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,QD(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`})`)}},rO=(e,t)=>eO(QD(e),t),iO=(e,t)=>eO(QD(e),t),aO=(e,t)=>{let n=ZD(QD(e));t.sessionState.get(n,`toolbar-expanded`)?t.sessionState.clear(n,`toolbar-expanded`):t.sessionState.set(n,`toolbar-expanded`,`1`)},oO=(e,t)=>{let[n=``,...r]=$D(()=>Ly(e)),i=ZD(n);if(r.length===0)throw new $(`set-state: <key>/<value> is required (have keys: ${nS().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: ${nS().join(`, `)})`);let a=[];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=iS(t,n);if(!i.ok)throw new $(`set-state: pair ${e/2+1}: ${i.reason}`);a.push({key:t,value:i.value})}t.sessionState.setBatch(i,a);let o=a.map(e=>`${e.key}=${e.value}`).join(` `);t.dlog(`info`,`set-state: ${o} (session=${i})`)},sO=/^-?\d+$/;function cO(e,t,n){return e>n?t:e<t?n:e}function lO(e,t){if(!e)return null;if(!nS().includes(e))throw new $(`${t}: unknown session key "${e}" to release (have: ${nS().join(`, `)})`);return e}function uO(e,t,n,r){e!==null&&(n.sessionState.clear(t,e),n.dlog(`info`,`${r}: released session key ${e} (session=${t})`))}const dO=(e,t)=>{let[n=``,r=``,i=``]=$D(()=>Ly(e)),a=ZD(n);if(!r)throw new $(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!sO.test(i))throw new $(`step-state: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=aS(r);if(!s)throw new $(`step-state: key "${r}" is not a bounded (range) state key (have keys: ${nS().join(`, `)})`);let c=t.sessionState.get(a,r),l=c&&sO.test(c)?Math.max(s.min,Math.min(s.max,parseInt(c,10))):s.seed,u=cO(l+o,s.min,s.max),d=iS(r,String(u));if(!d.ok)throw new $(`step-state: ${d.reason}`);t.sessionState.set(a,r,d.value),t.dlog(`info`,`step-state: ${r} ${l}→${d.value} (by ${o}, session=${a})`)},fO=`render-origin`;function pO(e){return JSON.stringify(e)}function mO(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 hO(e,t){let n=e.sessionState.get(t,fO);if(n===null)throw new $(`session ${t} has not rendered yet — no config file to write`);let r=mO(n);return sv(r.projectDir,r.cwd,r.configFile??void 0)}function gO(e){return{historyPath:ze(),logger:e.dlog}}const _O=(e,t)=>{let[n=``,r=``,i=``,a=``]=$D(()=>Ly(e)),o=ZD(n);if(!r)throw new $(`set-config: <key>/<value> is required (have keys: ${Rx().join(`, `)})`);let s=zx(r,i);if(!s.ok)throw new $(`set-config: ${s.reason}`);let c=lO(a,`set-config`),l=hO(t,o);kD(gO(t),l,r,s.value),t.dlog(`info`,`set-config: ${r}=${s.value} → ${l} (session=${o})`),uO(c,o,t,`set-config`)},vO=(e,t)=>{let[n=``,r=``,i=``,a=``]=$D(()=>Ly(e)),o=ZD(n);if(!r)throw new $(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!sO.test(i))throw new $(`step-config: delta must be an integer, got "${i}"`);let s=parseInt(i,10),c=lO(a,`step-config`),l=Bx(r);if(!l)throw new $(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${Rx().join(`, `)})`);let u=hO(t,o),d=OD(u,r),f=typeof d==`number`?Math.max(l.min,Math.min(l.max,d)):l.seed,p=cO(f+s,l.min,l.max),m=zx(r,String(p));if(!m.ok)throw new $(`step-config: ${m.reason}`);kD(gO(t),u,r,m.value),t.dlog(`info`,`step-config: ${r} ${f}→${m.value} (by ${s}) → ${u} (session=${o})`),uO(c,o,t,`step-config`)},yO=(e,t)=>{let[n=``,r=``]=$D(()=>Ly(e)),i=ZD(n);if(!r||!Rx().includes(r))throw new $(`reset-config: unknown config key "${r}" (have: ${Rx().join(`, `)})`);let a=hO(t,i);AD(gO(t),a,r),t.dlog(`info`,`reset-config: ${r} ← ${a} (session=${i})`)},bO=(e,t)=>{let[n=``,r=``,i=``]=$D(()=>Ly(e)),a=ZD(n);if(!r)throw new $(`apply-layout-op: <key>/<op> is required (have: ${Rx().join(`, `)})`);let o=zx(r,i);if(!o.ok)throw new $(`apply-layout-op: ${o.reason}`);let s=Jm(o.value);if(s===null)throw new $(`apply-layout-op: "${o.value}" is not a layout op token`);let c=hO(t,a);jD(gO(t),c,r,s),t.dlog(`info`,`apply-layout-op: ${r} ${o.value} → ${c} (session=${a})`)},xO=(e,t)=>{let[n=``]=$D(()=>Ly(e)),r=ZD(n),i=hO(t,r);if(BD(gO(t),i)===null)throw new $(`undo: history is empty, nothing to undo`);t.dlog(`info`,`undo: ${i} (session=${r})`)},SO=(e,t)=>{let[n=``]=$D(()=>Ly(e)),r=ZD(n),i=hO(t,r);if(VD(gO(t),i)===null)throw new $(`redo: nothing to redo`);t.dlog(`info`,`redo: ${i} (session=${r})`)},CO=(e,t)=>{ZD(QD(e)),t.applyUpdate()},wO=`client-hints`;function TO(e,t){let n=e.sessionState.get(t,wO);if(n===null)throw new $(`session ${t} has not rendered yet — no client facts to diagnose`);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 xv(r)}function EO(e,t,n){let r=jh(n);e.sessionState.setBatch(t,Ph(r)),e.dlog(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed`}`).join(` `)} (session=${t})`)}const DO=(e,t)=>{let n=ZD(QD(e));EO(t,n,YD(t.doctor,TO(t,n).tmux))},OO=(e,t)=>{let[n=``,r=``]=$D(()=>Ly(e)),i=ZD(n),a=Mh(r);if(a===void 0)throw new $(`doctor-fix: unknown check "${r}"`);let o=YD(t.doctor,TO(t,i).tmux),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=XD(t.doctor,s.fix,o);t.dlog(`info`,`doctor-fix: ${a.name} → ${s.fix.kind} ${s.fix.name}=${s.fix.value} (session=${i})`),EO(t,i,c)},kO=`config-override`,AO=new Map([[Sy,tO],[`load-config`,(e,t)=>{let n=e.indexOf(`/`);if(n===-1)throw new $(`load-config: expected <sessionId>/<path> (missing separator)`);let r=ZD($D(()=>decodeURIComponent(e.slice(0,n)))),i=$D(()=>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,kO),t.dlog(`info`,`load-config: override cleared (session=${r})`)):(t.sessionState.set(r,kO,i),t.dlog(`info`,`load-config: ${i} (session=${r})`))}],[Cy,nO],[by,oO],[xy,dO],[Dy,_O],[Oy,vO],[ky,yO],[Ay,bO],[jy,xO],[My,SO],[Ty,rO],[Ey,iO],[wy,aO],[Ny,CO],[Py,DO],[Fy,OO]]),jO=new Set([by,xy,Dy,Oy,ky,Ay,jy,My,wy,Ny,Py,Fy]),MO=(e,t)=>{let n=[],r=!1,i=null;for(let{verb:a,value:o}of zy(e)){if(!i&&jO.has(a)){let e=Ly(o);e.length>0&&e[0]&&(i=e[0])}let e=AO.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(`
|
|
179
|
-
`));let e=`dispatch: ${n.join(`; `)}`;throw r?Error(e):new $(e)}},NO=new Map([...AO,[yy,MO]]);Object.freeze([...NO.keys()]);const PO=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`]),FO=[[`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`]];function IO(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of FO){let i=RO(n,e);if(i==null)t.missingRequired.push(e);else{let n=LO(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let e of Object.keys(n))PO.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function LO(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function RO(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 zO(e,t){switch(e){case`vars`:return{what:e,vars:BO(t)};case`segments`:return{what:e,segments:GO(t)};case`config`:return{what:e,config:JO(t)}}}function BO(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=UO(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,...VO(r),lastError:a===void 0?null:{timestampMs:a.timestamp,message:a.message},ageMs:HO(r.lastUpdatedMs())})}return o}function VO(e){if(e.kind!==`document`)return{type:e.type,value:e.read()};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 HO(e){return e===null?null:Math.max(0,Date.now()-e)}function UO(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,WO(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}`,WO(i));return t}function WO(e){return e.kind}function GO(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=KO(n),o=[];for(let e of a){let t=n.segments[e];t&&o.push({name:e,template:t.template,referencedVars:qO(t.template,i),lastRender:r.get(e)??null})}return o}function KO(e){let t=[],n=new Set;for(let r of va(oo(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 qO(e,t){let n=new Set;for(let r of M_(e)){if(t.has(r)){n.add(r);continue}let e=r.split(`.`);for(;e.length>1;){e.pop();let r=e.join(`.`);if(t.has(r)){n.add(r);break}}}return Array.from(n).sort()}function JO(e){return e===null?null:e.config}const YO=[`vars`,`segments`,`config`];function XO(e){return typeof e==`string`&&YO.includes(e)}function ZO(e){return Math.max(1,e-2)}var QO=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 D(`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);D(`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{D(`Calculating context tokens from transcript: ${e}`);let n=await vC(e);if(n.length===0)return D(`No entries in transcript`),Z;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,D(`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 D(`Most recent main chain context: ${n} tokens (limit: ${t})`),X({totalTokens:n,maxTokens:t,...this.ratioPercentages(n,t)})}return D(`No main chain entries with usage data found`),Z}catch(e){return Q(`context transcript: ${e instanceof Error?e.message:String(e)}`)}}async getContextInfo(e){let t=this.calculateContextFromHookData(e);if(t)return X(t);let n=e.context_window?.context_window_size??2e5;return this.calculateContextTokensFromTranscript(e.transcript_path,n)}};function $O(e){let t=e.type||e.message?.role||e.message?.type,n=e.type===`user`&&e.message?.firstContentType===`tool_result`;return t===`user`&&!n}var ek=class{state=new Map;calculateLastResponseTime(e){if(e.length===0)return null;let t=null,n=null;for(let r of e){let e=r.type||r.message?.role||r.message?.type;if($O(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}async foldMetrics(e,t){let n=this.state.get(e),r=oC(t);if(n&&r!==0&&n.cursor.mtimeMs===r)return this.state.delete(e),this.state.set(e,n),{kind:`ok`,value:{messageCount:n.messageCount,recent:[...n.recent]}};let i=await SC(t,n?.cursor);if(i.kind===`failed`)return i;if(i.kind===`absent`)return{kind:`ok`,value:{messageCount:n?.messageCount??0,recent:[...n?.recent??[]]}};let{entries:a,cursor:o,reset:s}=i.value,c=n&&!s?n:void 0,l=c?.messageCount??0,u=c?[...c.recent]:[];for(let e of a)e.isSidechain||($O(e)&&l++,u.push(e));for(u.length>20&&(u=u.slice(-20)),this.state.delete(e),this.state.set(e,{cursor:o,messageCount:l,recent:u});this.state.size>256;){let e=this.state.keys().next().value;if(e===void 0)break;this.state.delete(e)}return{kind:`ok`,value:{messageCount:l,recent:[...u]}}}async getMetricsInfo(e,t){if(D(`Getting metrics from hook data for session: ${e}`),!t.cost)return Z;let n=await this.foldMetrics(e,t.transcript_path);return n.kind===`failed`?Q(`metrics (${e}): ${n.reason}`):X({responseTime:t.cost.total_api_duration_ms/1e3,lastResponseTime:this.calculateLastResponseTime(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 tk=new Map;function nk(e){if(!e)return``;let t=e.indexOf(`,`);return t<0?e:e.slice(0,t)}var rk=class{async getSessionId(){if(!process.env.TMUX_PANE)return Z;let e=nk(process.env.TMUX),t=tk.get(e);if(t!==void 0)return t;D(`Getting tmux session ID, TMUX_PANE: ${process.env.TMUX_PANE}`);let n=await Te({bin:`tmux`,args:[`display-message`,`-p`,`#S`],timeoutMs:1e3,category:`tmux`}),r=n.ok?n.stdout.trim()?X(n.stdout.trim()):Z:Q(`tmux display-message: ${n.reason}`);return tk.set(e,r),r}isInTmux(){return!!process.env.TMUX_PANE}},ik=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 ak=new KE;Ce(ak.launchStats);const ok=new YS({counters:ak,logger:Y}),sk=new nC({watchers:ok,logger:Y}),ck=new PC,lk=new YE,uk=new ik(We()),dk=new QO,fk=new ek,pk=new rk,mk=new WE({gitService:sk,sessionState:lk,watchers:ok},{observers:{onReload:e=>Y(`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)}`)}}),hk=60*1e3;function gk(){let e=import.meta.url,n=[];e.startsWith(`file://`)&&n.push(b(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){Y(`info`,`binary mtime changed (${e}); shutting down`),a&&clearInterval(a),Mk(0);return}}catch(e){Y(`warn`,`bin stat failed: ${e.message}`)}};return{arm(){i.size!==0&&(a=setInterval(o,hk),a.unref())},checkNow:o}}const _k=gk(),vk=TS({entryUrl:import.meta.url,intervalMs:hk,releaseIntervalMs:216e5,registryUrl:t.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,fetchImpl:fetch,onApplied:()=>_k.checkNow(),log:Y});let yk=null,bk=null,xk=0;function Sk(){t.on(`uncaughtException`,e=>{Y(`error`,`uncaughtException: ${e.stack||e.message}`),Mk(1)}),t.on(`unhandledRejection`,e=>{Y(`error`,`unhandledRejection: ${String(e)}`),Mk(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{Y(`info`,`received ${e}, shutting down`),Mk(0)});try{xk=Xv(t.env)}catch(e){Y(`error`,`refusing to boot: ${e.message}`),Mk(1);return}yk=Nb(t.pid);let e=Ub(Gb(yk));if(!e.decision.allow){Y(`warn`,`fork-bomb breaker: ${e.decision.reason}; refusing to boot`),Mk(1);return}bk=e.registryPath,r.mkdirSync(Me(),{recursive:!0}),Fe(Ne()),lk.useStorage(new QE(Re(),500,Y)),Ib({anchor:Fb(t.env),isAlive:Lb,onOrphaned:e=>{Y(`info`,`parent watchdog: ${e}; shutting down`),Mk(0)}}),Ck(g.createServer({allowHalfOpen:!1},e=>{Nk(e)}),Ne(),!1)}function Ck(e,n,r){e.removeAllListeners(`error`),e.removeAllListeners(`listening`),e.once(`error`,i=>{if(i.code!==`EADDRINUSE`){Y(`error`,`server error: ${i.message}`),Mk(1);return}if(r){Y(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}wk(e,n)}),e.listen(n,()=>Tk(n))}function wk(e,n){let i=Cb(wb(Ie(n)),(e,t)=>Mb(e,t,{readStartTime:jb,pidAlive:Lb}));if(i.kind===`attach-and-exit`){Y(`info`,`EADDRINUSE: ${i.reason} — exiting`),t.exit(0);return}Y(`warn`,`EADDRINUSE: ${i.reason} — unlinking stale socket and rebinding`);try{r.unlinkSync(n)}catch(e){if(e.code!==`ENOENT`){Y(`error`,`cannot unlink stale socket ${n}: ${e.message}`),Mk(1);return}}Ck(e,n,!0)}function Tk(e){let n=Db(e);if(n.kind!==`present`){Y(`warn`,`no ownable socket at bind callback (${n.kind}); exiting`),Mk(0);return}kk(e);try{r.chmodSync(e,384)}catch(e){Y(`warn`,`chmod socket failed: ${e.message}`)}Y(`info`,`daemon up: pid=${t.pid} v=3 sock=${e} heapCap=${Math.round(_.getHeapStatistics().heap_size_limit/1048576)}MB rssLimit=${Math.round(xk/1048576)}MB`),cy();let i=uk.reset();i!==null&&Y(`warn`,`diagnostic dump wipe failed: ${i}`),_k.arm(),vk.arm(),Ok(),Ek(e,n.identity)}function Ek(e,n){Ab({bound:n,myPid:t.pid,readIdentity:()=>Db(e),readLease:()=>wb(Ie(e)),shutdown:e=>Mk(e),log:Y}).arm()}let Dk=null;function Ok(){Dk=Zv($v(ak.startedAt.getTime(),e=>Mk(e),{rssLimitBytes:xk})),Dk.arm()}function kk(e){let n=Tb(Ie(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:yk});n!==null&&Y(`warn`,`lease write failed: ${n}`)}let Ak=0,jk=!1;function Mk(e){if(!jk){jk=!0,setTimeout(()=>t.kill(t.pid,`SIGKILL`),500);try{sk.close()}catch(e){Y(`warn`,`gitService close failed: ${e.message}`)}try{ck.close()}catch(e){Y(`warn`,`usageStore close failed: ${e.message}`)}try{ok.closeAll()}catch(e){Y(`warn`,`watcherRegistry close failed: ${e.message}`)}try{lk.flush()}catch(e){Y(`warn`,`sessionState flush failed: ${e.message}`)}Eb(Le(),t.pid),bk!==null&&Wb(bk,t.pid,Vb,e=>r.unlinkSync(e)),t.exit(e)}}function Nk(e){Ak++,ak.inFlight=Ak;let t=!1,n=(n,r)=>{if(t){r!==null&&Y(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`);return}t=!0;let i=r===null?void 0:()=>Mk(r);try{e.end(Ov(n),i)}catch(e){Y(`warn`,`response write failed: ${e.message}`),i?.()}},r=setTimeout(()=>{ak.requestsTimedOut++,n({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null)},200),i=kv(e=>{Fk(e).then(e=>n(e.resp,e.exitAfterFlush)).catch(e=>{Y(`error`,`handler threw: ${e?.stack||e}`),n({ok:!1,error:String(e?.message||e),code:`RENDER_FAILED`,daemonV:3},null)})},e=>{Y(`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=>{Y(`warn`,`socket error: ${e.message}`)}),e.on(`close`,()=>{clearTimeout(r),Ak=Math.max(0,Ak-1),ak.inFlight=Ak})}const Pk=e=>({resp:e,exitAfterFlush:null});async function Fk(e){if(!e||typeof e!=`object`||typeof e.v!=`number`)return Pk({ok:!1,error:`malformed request`,code:`BAD_REQUEST`,daemonV:3});if(e.v!==3)return e.v>3?Y(`info`,`version mismatch: client=${e.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):Y(`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 Pk({ok:!0,stats:ak.snapshot({gitCache:sk.getStats(),usageCache:ck.getStats(),renderCacheSize:mk.size,watchersActive:ok.size(),nextRestartReason:Dk?.describeNextRestart()??null})});if(e.kind===`render`){ak.requestsTotal++;let t=Date.now();try{let{report:n}=IO(e.hookData);for(let e of n.unknownTopLevelFields)Y(`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 ak.requestsErrored++,Y(`warn`,`BAD_REQUEST: ${r.join(`; `)}`),Pk({ok:!1,error:`malformed hookData: ${r.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3});let i=e.hookData.workspace.project_dir,{configFile:a,unknownFlagsError:o}=Ik(e.args),s=e.hookData.session_id,c=xv(e),l=JSON.stringify(c);lk.get(s,`client-hints`)!==l&&lk.set(s,wO,l);let u=lk.get(s,`config-override`)??a??c.configEnv,d=mk.getOrCreate(i,e.cwd,u),f=pO({projectDir:i,cwd:e.cwd,configFile:u??null});lk.get(s,`render-origin`)!==f&&lk.set(s,fO,f);let p=c.termCols,m=ZO(p??120),h=ax(c.termRows),g={...Rk,width:m},{authoredRoots:_}=d.state,v=BC(d.state.config,t=>lk.get(e.hookData.session_id,t),e=>_.has(e)),y=await $C(e.hookData,Hk,e.cwd,d.state.neededInputPaths,v,c),b=NT(v.theme);g.style=v.style,g.separator=v.separator,g.wrap=v.autoWrap,g.padding=v.padding,g.charset=v.charset,g.colorCompatibility=v.colorCompatibility;let x=ME(d.state.config,d.state.compiled,d.state.store,d.state.registry,y,b,g,{perSegmentSink:d.state.lastRenderCellsBySegment},{look:fi(d.state.config.looks,v.look),preset:v.preset}),S=lk.get(e.hookData.session_id,`click.error`);S&&lk.clear(e.hookData.session_id,`click.error`);let C=[o,d.lastError,S].filter(Boolean).join(`
|
|
180
|
-
`),ee=
|
|
181
|
-
`})}catch(e){throw
|
|
182
|
-
`);return}t.stdout.write(
|
|
176
|
+
`);n.push(e[0]);for(let r=1;r<e.length;r++)t.push(n),n=[e[r]]}return t.push(n),t}function TE(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?[]:[t.flatMap(e=>e[0]??[]),...t.flatMap(e=>e.slice(1))]}}const EE={container:{compile(e,t){return{kind:`container`,direction:e.direction,when:t.when,distribution:Ns(e.distribution),children:e.children.map((e,n)=>t.compileChild(e,`${t.path}.children[${n}]`))}},render(e,t){return TE(e.direction,e.children.map((n,r)=>t.renderChild(n,t.visible,{index:r,count:e.children.length,distribution:e.distribution})))}},segment:{compile(e,t){return{kind:`segment`,when:t.when,name:e.name,...e.opens!==void 0&&{opens:{open:t.parse(oc(e.opens.ref),`opens`),body:t.compileChild(e.opens.body,`${t.path}.opens.body`)}}}},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[];try{if(!zT(i.when,t.scope))return[];let n=i.palette??t.palette,a=t.enterSegment(e.name,n,t.region,i.bg,i.fg),o=i.template.evaluate(t.scope),s=t.exitSegment(o),c=e.opens!==void 0&&zT(e.opens.open,t.scope),l=e.opens===void 0?[]:t.renderBody(e.opens.body,c,a.disclosure),u=s.length>0||c?a.trigger:a.closed,d={width:r.width??`auto`,justify:r.justify??`left`,truncate:r.truncate??`right`,baseStyle:u,padding:t.padding},f=wE(IT(o,u)).map(e=>VT(e,d)),p=s.map(e=>VT(IT([e],a.band),{...d,baseStyle:a.band})),m=[...f,...p];return t.perSegmentSink!==void 0&&t.perSegmentSink.set(e.name,m.flat()),[...m,...l]}catch(n){let r=n.message??String(n);return t.onSegmentError?.(e.name,r),[[new Ar(`⚠ ${e.name}: ${r}`)]]}}}};function DE(e){return EE[e]}function OE(e){if(`ttl`in e)return{kind:`ttl`,durationMs:hT(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 kE(e,t){switch(ba(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 AE(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:OE(n.cache),parse:kE(n.parse,n.default)});break;case`shell`:e.declareShell(t,n.command,{cache:OE(n.cache),parse:kE(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?hT(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 jE(e,t){let n=cl.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}function ME(e,t,n){let r=n?.cwd??process.cwd(),i={store:t.variableStore,compiled:new Map,stripStyle:`powerline`,padding:1},a=cE(),o={action:i,activeSegment:a},s=Object.keys(e.looks),c=Qm(e.presets),l=new Map([...E_(e),...yh(e)]),u=oT({...aE(i),...gE(i,a),...SE(o),...CE(a),looks:{fn:()=>s,argTypes:[]},presets:{fn:()=>c,argTypes:[]}},n?.clock),d=jE(u,e.helpers),f=e=>u.parse(e,d),p=new Map;for(let[t,n]of Object.entries(e.variables))n.kind===`state`&&!p.has(n.key)&&p.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`&&!p.has(r.key)&&p.set(r.key,`${t}.${e}`);i.compiled=qT(f,e.actions,p,l);let m=[];for(let[n,i]of Object.entries(e.variables))try{AE(t,n,i,r)}catch(e){m.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{AE(t,`${n}.${e}`,a,r)}catch(t){m.push(`Variable "${n}.${e}": ${t.message??String(t)}`)}let h=Object.create(null);for(let[t,n]of Object.entries(e.segments)){let e=(e,n)=>{try{return f(e)}catch(e){throw Error(`Template parse error in segments.${t}.${n}: ${e.message}`,{cause:e})}};h[t]={when:n.when===void 0?void 0:e(n.when,`when`),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`),palette:n.palette===void 0?void 0:PT(n.palette)}}let g=(e,t,n)=>{try{return f(e)}catch(e){throw Error(`Template parse error in ${t}.${n}: ${e.message}`,{cause:e})}},_=(e,t)=>{let n={path:t,when:e.when===void 0?void 0:g(e.when,t,`when`),parse:(e,n)=>g(e,t,n),compileChild:_};return DE(e.kind).compile(e,n)},v=new Map;for(let t of c){let{node:n,path:r}=th(e,t);v.set(t,_(n,r))}return{segments:h,roots:v,activeSegment:a,menuRuntime:o,loadWarnings:m}}function NE(e,t,n,r,i,a,o,s,c){let{perSegmentSink:l,onSegmentError:u}=s??{},{look:d=hn,preset:f=Xm}=c??{};r.applyInput({...i,term:{cols:o.width}}),t.menuRuntime.action.stripStyle=o.style,t.menuRuntime.action.padding=o.padding;let p=sT(n),m=FT(a,d);l?.clear();let h=n=>{let r=e.segments[n],i=t.segments[n];return r!==void 0&&i!==void 0?{seg:r,compiled:i}:void 0},g=(e,n,r,i,a)=>{let{tint:o,text:s,disclosure:c}=ec(n,r),l=UT(t.activeSegment,e,n,c,o,s,i,a,p),u=qs(n,c);return{closed:l,trigger:oE(n,u.state),band:oE(n,u.plane),disclosure:c}},_=e=>(t.activeSegment.current=null,vE(e)),v=(e,t,n)=>{let r=t&&zT(e.when,p),i={scope:p,palette:m,visible:r,padding:o.padding,region:n,perSegmentSink:l,onSegmentError:u,enterSegment:g,exitSegment:_,lookupSegment:h,renderChild:(e,t,r)=>v(e,t,Zs(n,r)),renderBody:(e,t,n)=>v(e,r&&t,Qs(n))};return DE(e.kind).render(e,i)},y=t.roots.get(f);if(y===void 0)throw Error(`Preset "${f}" has no compiled layout — registerDslConfig compiles one per declared preset and effectivePresetName collapses unknown names to "${Xm}"; a miss here is merge/policy drift (have: ${[...t.roots.keys()].join(`, `)})`);return v(y,!0,Xs).map(e=>ix(e,o)).join(`
|
|
177
|
+
`)}var PE=class{kind=`box`;cell;lastSetAt;constructor(e,t,n){this.name=e,this.type=t,RE(e,t,n,`initial value`),this.cell=gw.observable.box(n,{deep:!1}),this.lastSetAt=Date.now()}read(){return this.cell.get()}set(e){RE(this.name,this.type,e,`set value`),this.cell.set(e),this.lastSetAt=Date.now()}lastUpdatedMs(){return this.lastSetAt}},FE=class{kind=`computed`;cell;constructor(e,t,n){this.name=e,this.type=t,this.cell=(0,gw.computed)(()=>{let e=n();return RE(this.name,this.type,e,`computed result`),e},{keepAlive:!0})}read(){return this.cell.get()}lastUpdatedMs(){return null}},IE=class{kind=`document`;cell;lastSetAt;constructor(e,t){this.name=e,this.cell=gw.observable.box(LE(t),{deep:!1}),this.lastSetAt=Date.now()}read(){return this.cell.get()}set(e){this.cell.set(LE(e)),this.lastSetAt=Date.now()}lastUpdatedMs(){return this.lastSetAt}};function LE(e){return e.kind===`ok`?{kind:`ok`,value:_w(e.value)}:e}function RE(e,t,n,r){let i=vw(n);if(i!==t)throw TypeError(`Variable "${e}": ${r} type ${i} does not match declared type ${t}`)}var zE=class{nodes=new Map;defineBox(e,t,n){this.assertNotDefined(e),this.nodes.set(e,new PE(e,t,n))}defineDocument(e,t){this.assertNotDefined(e),this.nodes.set(e,new IE(e,t))}defineComputed(e,t,n){this.assertNotDefined(e);let r=e=>this.read(e);this.nodes.set(e,new FE(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,gw.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,gw.runInAction)(()=>n.set(t))}runInAction(e){(0,gw.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);return t.kind===`document`?JSON.stringify(t.read()):String(t.read())}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 BE(e,t,n){return e+`\0`+t+`\0`+(n??``)}function VE(e,t){return new Set(Qm(e.presets).filter(n=>th(e,n).path===`root`?t.root!==void 0:t.presets?.[n]?.root!==void 0))}function HE(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 UE(e,t){let n=new Map;for(let t of iv(e.projectDir,e.cwd,e.configFile)){let{dir:e,name:r}=HE(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 WE(e){return e.filter(Boolean).join(`
|
|
178
|
+
`)||null}var GE=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=BE(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??this.buildState(t,null,[]),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.state.validatorDisposers.forEach(e=>e()),n.watcher?.release(),this.entries.delete(t)}}return this.refreshWatcher(o,a.resolvedPath),this.observers.onReload?.(o),o}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.validatorDisposers.forEach(e=>e()),e.state=t.state),this.refreshWatcher(e,t.resolvedPath),this.observers.onReload?.(e)}loadFromDisk(e,t,n){let r=ov(e,t,n),i=r.kind===`file`?r.path:null,a=[uv(e,t),cv(r)],o;try{o=this.buildState(t,i,a)}catch(e){return e instanceof da&&a.push(...e.warnings),{resolvedPath:i,warning:WE(a),state:null,error:e instanceof da||e instanceof Error?e.message:String(e)}}return{resolvedPath:i,warning:WE(a),state:o,error:null}}buildState(e,t,n){let{config:r,raw:i,source:a,warnings:o}=dv(t,pw);n.push(...o);let s=mv(r,t??`<default>`,a),c=new zE,l=new jT(c,s.globals.default_empty_value??``,this.deps.gitService,this.deps.sessionState),u,d=[];try{u=ME(s,l,{cwd:e}),n.push(...u.loadWarnings);for(let{key:e,spec:t}of uS(s))d.push(rS(e,t));for(let{key:e,spec:t}of Kx(s))d.push(qx(e,t))}catch(e){for(let e of d)e();throw l.dispose(),e}return{config:s,store:c,registry:l,compiled:u,neededInputPaths:XC(s),lastRenderCellsBySegment:new Map,validatorDisposers:d,authoredRoots:VE(r,i)}}refreshWatcher(e,t){e.configFilePath=t;let n=UE(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){Y(`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 KE=16384;var qE=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<KE){this.rollingTimestamps.push(e);return}this.rollingTimestamps[this.rollingHead]=e,this.rollingHead=(this.rollingHead+1)%KE}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:Vy,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}}};const JE={load:()=>({}),save:()=>{},flush:()=>{}};function YE(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,new Map(Object.entries(r)));return t}var XE=class{sessions;storage;atom=(0,gw.createAtom)(`SessionState`);constructor(e=JE,t=256){this.maxSessions=t,this.storage=e,this.sessions=new Map,this.hydrateFromStorage()}useStorage(e){this.storage=e,this.hydrateFromStorage()}hydrateFromStorage(){this.sessions=YE(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,gw.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,gw.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,gw.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}};const ZE=(e,t)=>D(t);function QE(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 $E=class{timer=null;pending=null;constructor(e,t=500,n=ZE){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 QE(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 eD={default_bg:`string`,default_fg:`string`,default_empty_value:`string`,default_separator:`string`,default_truncate_marker:`string`,palette:`string`,look:`string`,preset:`string`,style:`string`,autoWrap:`boolean`,padding:`number`,charset:`string`,updateNotice:`boolean`,colorCompatibility:`string`},tD=new Set([`1`,`true`]),nD=new Set([`0`,`false`,``]);function rD(e,t){let n=OD(e),r=n.scope===`globals`?eD[n.field]:`string`;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(tD.has(t))return`true`;if(nD.has(t))return`false`;throw Error(`persistValueText: "${e}" expects boolean-ish (1, 0, true, false), got "${t}"`)}function iD(e){try{return r.readFileSync(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return null;throw e}}function aD(e,t,n){try{if(t===null){r.rmSync(e,{force:!0});return}r.mkdirSync(c.dirname(e),{recursive:!0}),ke(e,t)}catch(t){let r=`config write failed (${e}): ${t.message}`;throw n(`error`,r),Error(r)}}function oD(e){return/^\s*$/.test(e)?null:ji(e)}function sD(e,t){return e!==null&&Ni(e,t)!==void 0}function cD(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(cD),...i}}return e}function lD(e){if(!ro(e))return cD(e);let{rows:t,...n}=e;return{rows:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,cD(t)])),...n}}const uD=dw,dD=uD.segments,fD=uD.presets,pD=uD.root;function mD(e,t,n,r){if(!sD(e,t)&&n===void 0)throw new $(`cannot edit ${r}: neither the config file nor the bundled default declares ${t.join(`.`)}`)}function hD(e,t){let n=sh(t);return t.scope===`segment-palette`&&mD(e,[`segments`,t.segment],dD[t.segment],n.join(`.`)),n}function gD(e){return ji(zi(e))}function _D(){return Object.entries(pD.rows).map(([e,t])=>{let n=cD(t);return{path:[`root`],fragment:gD({rows:{[e]:n}}),unit:{path:[`root`,`rows`,e],value:n}}})}function vD(e,t){let n=e===null?void 0:Ni(e,t);return n===void 0?null:{path:t,fragment:n,unit:null}}function yD(e,t){if(t===void 0)return null;let n=lD(t);return{path:e,fragment:gD(n),unit:{path:e,value:n}}}function bD(e,t){let n=[`presets`,t],r=[...n,`root`],i=fD[t];mD(e,n,i,r.join(`.`));let a=vD(e,r)??yD(r,i?.root);return a!==null&&aa(a.fragment)?a:null}function xD(e,t){let n=ia(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 SD(e,t){return[..._D(),vD(e,[`root`]),bD(e,t)].filter(e=>e!==null).reduce(xD,new Map)}function CD(e,t,n){for(let{node:r,...i}of SD(e,t).values())if(sa(r,n))return i;throw new $(`${wD(e,t).join(`.`)} holds no segment "${n}" — the bar you clicked is stale; it reloads on the next render`)}function wD(e,t){return bD(e,t)?.path??[`root`]}function TD(e,t){return t.scope===`preset-root`?wD(e,t.preset):sh(t)}function ED(e,{unit:t}){return t===null?e:$i(e,t.path,zi(t.value),Li)}function DD(e){let t=oh(e);if(t===null)throw Error(`"${e}" is not a valid persist target`);return t}function OD(e){let t=DD(e);if(t.scope===`preset-root`)throw Error(`"${e}" names a layout, not a value`);return t}function kD(e,t){let n=OD(t),r=oD(iD(e)??``),i=r===null?void 0:Ni(r,sh(n));return i!==void 0&&`value`in i?i.value:void 0}function AD(e,t,n,r){let i=OD(n),a=iD(t);BD(e,t,{before:a,after:$i(a??``,hD(oD(a??``),i),rD(n,r),Li)})}function jD(e,t,n){let r=DD(n),i=iD(t);if(i===null)return;let a=ea(i,TD(oD(i),r));a!==i&&BD(e,t,{before:i,after:a})}function MD(e,t,n,r){let i=DD(n);if(i.scope!==`preset-root`)throw Error(`"${n}" is not a "presets.<name>.root" target`);let a=iD(t),o=r.op===`remove`?r.target:r.anchor,s=CD(oD(a??``),i.preset,o),c=ED(a??``,s),l=r.op===`remove`?la(c,s.path,r.target):ua(c,s.path,r.segment,r.anchor,r.relation);if(l===null)throw new $(`${s.path.join(`.`)} in ${t} has no segment "${o}" — the bar you clicked is stale; it reloads on the next render`);BD(e,t,{before:a,after:l})}const ND={past:[],future:[]};function PD(e){if(typeof e!=`object`||!e)return!1;let t=e;return(t.before===null||typeof t.before==`string`)&&typeof t.after==`string`}function FD(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.past)&&t.past.every(PD)&&Array.isArray(t.future)&&t.future.every(PD)}function ID(e){let t;try{t=r.readFileSync(e.historyPath,`utf8`)}catch(t){let n=t.code;return n!==`ENOENT`&&e.logger(`warn`,`config-edit-history read failed (${n}); starting empty`),{}}try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e)&&Object.values(e).every(FD))return e}catch{}return e.logger(`warn`,`config-edit-history load: unexpected shape, starting empty`),{}}function LD(e,t){try{r.mkdirSync(c.dirname(e.historyPath),{recursive:!0}),ke(e.historyPath,JSON.stringify(t),384)}catch(t){let n=`config-edit-history write failed: ${t.message}`;throw e.logger(`error`,n),Error(n)}}function RD(e,t){let n=[...e,t];return n.length>50?n.slice(-50):n}function zD(e,t,n,r,i){aD(t,n,e.logger);try{LD(e,r)}catch(e){throw Error(`${i} landed in ${t} but recording it failed — it is not undoable: ${e.message}`)}}function BD(e,t,n){let r=ID(e),{past:i}=r[t]??ND;zD(e,t,n.after,{...r,[t]:{past:RD(i,n),future:[]}},`edit`)}function VD(e,t){let n=ID(e),{past:r,future:i}=n[t]??ND,a=r[r.length-1];return a===void 0?null:(UD(t,a.after,`undo`),zD(e,t,a.before,{...n,[t]:{past:r.slice(0,-1),future:RD(i,a)}},`undo`),a)}function HD(e,t){let n=ID(e),{past:r,future:i}=n[t]??ND,a=i[i.length-1];return a===void 0?null:(UD(t,a.before,`redo`),zD(e,t,a.after,{...n,[t]:{past:RD(r,a),future:i.slice(0,-1)}},`redo`),a)}function UD(e,t,n){if(iD(e)!==t)throw new $(`${n}: ${e} has changed since that edit — refusing to overwrite it`)}function WD(e){let t=Ee({bin:`tmux`,args:[`-S`,e.socket,`display`,`-p`,`-t`,e.pane,`#{client_termfeatures}`],timeoutMs:2e3,category:`doctor.tmux`});return t.ok?{kind:`ok`,value:t.stdout.trim().split(`,`).filter(e=>e!==``)}:{kind:`failed`,reason:`tmux display -p failed (${t.error??[t.reason,t.stderr.trim()].filter(e=>e!==``).join(`: `)})`}}function GD(){return{probeTmux:WD,claudeSettingsPath:Hy()}}function KD(e){return r.existsSync(e.claudeSettingsPath)?r.readFileSync(e.claudeSettingsPath,`utf8`):``}function qD(e){if(/^\s*$/.test(e))return{};let t=Ri.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`not a JSON object`);let n=t.env;if(n===void 0)return{};if(typeof n!=`object`||!n||Array.isArray(n))throw Error("`env` is not an object");return n}function JD(e,t){return t===void 0?{kind:`unreported`}:t===null?{kind:`outside`}:{kind:`inside`,hint:t,termfeatures:e.probeTmux(t)}}function YD(e){try{return qD(KD(e))}catch(t){throw Error(`cannot read ${e.claudeSettingsPath}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}function XD(e,t){return{tmux:JD(e,t),claudeSettingsEnv:YD(e)}}function ZD(e,t,n){switch(t.kind){case`claude-settings-env`:{let i=$i(KD(e),[`env`,t.name],JSON.stringify(t.value),Ri);return r.mkdirSync(c.dirname(e.claudeSettingsPath),{recursive:!0}),ke(e.claudeSettingsPath,i),{...n,claudeSettingsEnv:YD(e)}}default:return t.kind}}function QD(e){if(!e)throw new $(`session id is required`);if(e.includes(`/`)||e.includes(`..`))throw new $(`invalid session id "${e}"`);return e}function $D(e){return eO(()=>decodeURIComponent(e))}function eO(e){try{return e()}catch(e){throw e instanceof URIError?new $(`malformed wire encoding: ${e.message}`):e}}function tO(e,t){let n=Ee({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 nO=(e,t)=>tO($D(e),t),rO=(e,t)=>{let n=Ee({bin:`/usr/bin/open`,args:[`-a`,`Visual Studio Code`,$D(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`})`)}},iO=(e,t)=>tO($D(e),t),aO=(e,t)=>tO($D(e),t),oO=(e,t)=>{let n=QD($D(e));t.sessionState.get(n,`toolbar-expanded`)?t.sessionState.clear(n,`toolbar-expanded`):t.sessionState.set(n,`toolbar-expanded`,`1`)},sO=(e,t)=>{let[n=``,...r]=eO(()=>Ly(e)),i=QD(n);if(r.length===0)throw new $(`set-state: <key>/<value> is required (have keys: ${nS().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: ${nS().join(`, `)})`);let a=[];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=iS(t,n);if(!i.ok)throw new $(`set-state: pair ${e/2+1}: ${i.reason}`);a.push({key:t,value:i.value})}t.sessionState.setBatch(i,a);let o=a.map(e=>`${e.key}=${e.value}`).join(` `);t.dlog(`info`,`set-state: ${o} (session=${i})`)},cO=/^-?\d+$/;function lO(e,t,n){return e>n?t:e<t?n:e}function uO(e,t){if(!e)return null;if(!nS().includes(e))throw new $(`${t}: unknown session key "${e}" to release (have: ${nS().join(`, `)})`);return e}function dO(e,t,n,r){e!==null&&(n.sessionState.clear(t,e),n.dlog(`info`,`${r}: released session key ${e} (session=${t})`))}const fO=(e,t)=>{let[n=``,r=``,i=``]=eO(()=>Ly(e)),a=QD(n);if(!r)throw new $(`step-state: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!cO.test(i))throw new $(`step-state: delta must be an integer, got "${i}"`);let o=parseInt(i,10),s=aS(r);if(!s)throw new $(`step-state: key "${r}" is not a bounded (range) state key (have keys: ${nS().join(`, `)})`);let c=t.sessionState.get(a,r),l=c&&cO.test(c)?Math.max(s.min,Math.min(s.max,parseInt(c,10))):s.seed,u=lO(l+o,s.min,s.max),d=iS(r,String(u));if(!d.ok)throw new $(`step-state: ${d.reason}`);t.sessionState.set(a,r,d.value),t.dlog(`info`,`step-state: ${r} ${l}→${d.value} (by ${o}, session=${a})`)},pO=`render-origin`;function mO(e){return JSON.stringify(e)}function hO(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 gO(e,t){let n=e.sessionState.get(t,pO);if(n===null)throw new $(`session ${t} has not rendered yet — no config file to write`);let r=hO(n);return sv(r.projectDir,r.cwd,r.configFile??void 0)}function _O(e){return{historyPath:ze(),logger:e.dlog}}const vO=(e,t)=>{let[n=``,r=``,i=``,a=``]=eO(()=>Ly(e)),o=QD(n);if(!r)throw new $(`set-config: <key>/<value> is required (have keys: ${Rx().join(`, `)})`);let s=zx(r,i);if(!s.ok)throw new $(`set-config: ${s.reason}`);let c=uO(a,`set-config`),l=gO(t,o);AD(_O(t),l,r,s.value),t.dlog(`info`,`set-config: ${r}=${s.value} → ${l} (session=${o})`),dO(c,o,t,`set-config`)},yO=(e,t)=>{let[n=``,r=``,i=``,a=``]=eO(()=>Ly(e)),o=QD(n);if(!r)throw new $(`step-config: <key> is required (shape: <sessionId>/<key>/<by>)`);if(!cO.test(i))throw new $(`step-config: delta must be an integer, got "${i}"`);let s=parseInt(i,10),c=uO(a,`step-config`),l=Bx(r);if(!l)throw new $(`step-config: key "${r}" is not a bounded (range) config key (have keys: ${Rx().join(`, `)})`);let u=gO(t,o),d=kD(u,r),f=typeof d==`number`?Math.max(l.min,Math.min(l.max,d)):l.seed,p=lO(f+s,l.min,l.max),m=zx(r,String(p));if(!m.ok)throw new $(`step-config: ${m.reason}`);AD(_O(t),u,r,m.value),t.dlog(`info`,`step-config: ${r} ${f}→${m.value} (by ${s}) → ${u} (session=${o})`),dO(c,o,t,`step-config`)},bO=(e,t)=>{let[n=``,r=``]=eO(()=>Ly(e)),i=QD(n);if(!r||!Rx().includes(r))throw new $(`reset-config: unknown config key "${r}" (have: ${Rx().join(`, `)})`);let a=gO(t,i);jD(_O(t),a,r),t.dlog(`info`,`reset-config: ${r} ← ${a} (session=${i})`)},xO=(e,t)=>{let[n=``,r=``,i=``]=eO(()=>Ly(e)),a=QD(n);if(!r)throw new $(`apply-layout-op: <key>/<op> is required (have: ${Rx().join(`, `)})`);let o=zx(r,i);if(!o.ok)throw new $(`apply-layout-op: ${o.reason}`);let s=Jm(o.value);if(s===null)throw new $(`apply-layout-op: "${o.value}" is not a layout op token`);let c=gO(t,a);MD(_O(t),c,r,s),t.dlog(`info`,`apply-layout-op: ${r} ${o.value} → ${c} (session=${a})`)},SO=(e,t)=>{let[n=``]=eO(()=>Ly(e)),r=QD(n),i=gO(t,r);if(VD(_O(t),i)===null)throw new $(`undo: history is empty, nothing to undo`);t.dlog(`info`,`undo: ${i} (session=${r})`)},CO=(e,t)=>{let[n=``]=eO(()=>Ly(e)),r=QD(n),i=gO(t,r);if(HD(_O(t),i)===null)throw new $(`redo: nothing to redo`);t.dlog(`info`,`redo: ${i} (session=${r})`)},wO=(e,t)=>{QD($D(e)),t.applyUpdate()},TO=`client-hints`;function EO(e,t){let n=e.sessionState.get(t,TO);if(n===null)throw new $(`session ${t} has not rendered yet — no client facts to diagnose`);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 xv(r)}function DO(e,t,n){let r=jh(n);e.sessionState.setBatch(t,Ph(r)),e.dlog(`info`,`doctor: ${r.map(e=>`${e.check.name}=${e.verdict.ok?`ok`:`failed`}`).join(` `)} (session=${t})`)}const OO=(e,t)=>{let n=QD($D(e));DO(t,n,XD(t.doctor,EO(t,n).tmux))},kO=(e,t)=>{let[n=``,r=``]=eO(()=>Ly(e)),i=QD(n),a=Mh(r);if(a===void 0)throw new $(`doctor-fix: unknown check "${r}"`);let o=XD(t.doctor,EO(t,i).tmux),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=ZD(t.doctor,s.fix,o);t.dlog(`info`,`doctor-fix: ${a.name} → ${s.fix.kind} ${s.fix.name}=${s.fix.value} (session=${i})`),DO(t,i,c)},AO=`config-override`,jO=new Map([[Sy,nO],[`load-config`,(e,t)=>{let n=e.indexOf(`/`);if(n===-1)throw new $(`load-config: expected <sessionId>/<path> (missing separator)`);let r=QD(eO(()=>decodeURIComponent(e.slice(0,n)))),i=eO(()=>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,AO),t.dlog(`info`,`load-config: override cleared (session=${r})`)):(t.sessionState.set(r,AO,i),t.dlog(`info`,`load-config: ${i} (session=${r})`))}],[Cy,rO],[by,sO],[xy,fO],[Dy,vO],[Oy,yO],[ky,bO],[Ay,xO],[jy,SO],[My,CO],[Ty,iO],[Ey,aO],[wy,oO],[Ny,wO],[Py,OO],[Fy,kO]]),MO=new Set([by,xy,Dy,Oy,ky,Ay,jy,My,wy,Ny,Py,Fy]),NO=(e,t)=>{let n=[],r=!1,i=null;for(let{verb:a,value:o}of zy(e)){if(!i&&MO.has(a)){let e=Ly(o);e.length>0&&e[0]&&(i=e[0])}let e=jO.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(`
|
|
179
|
+
`));let e=`dispatch: ${n.join(`; `)}`;throw r?Error(e):new $(e)}},PO=new Map([...jO,[yy,NO]]);Object.freeze([...PO.keys()]);const FO=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`]),IO=[[`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`]];function LO(e){let t={missingRequired:[],typeMismatches:[],unknownTopLevelFields:[]},n=typeof e==`object`&&e&&!Array.isArray(e)?e:{};for(let[e,r]of IO){let i=zO(n,e);if(i==null)t.missingRequired.push(e);else{let n=RO(i);n!==r&&t.typeMismatches.push({path:e,expected:r,got:n})}}for(let e of Object.keys(n))FO.has(e)||t.unknownTopLevelFields.push(e);return{data:e,report:t}}function RO(e){return Array.isArray(e)?`array`:typeof e==`string`&&!e.isWellFormed()?`ill-formed string`:typeof e}function zO(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 BO(e,t){switch(e){case`vars`:return{what:e,vars:VO(t)};case`segments`:return{what:e,segments:KO(t)};case`config`:return{what:e,config:YO(t)}}}function VO(e){if(e===null)return[];let{store:t,registry:n,config:r}=e,i=WO(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,...HO(r),lastError:a===void 0?null:{timestampMs:a.timestamp,message:a.message},ageMs:UO(r.lastUpdatedMs())})}return o}function HO(e){if(e.kind!==`document`)return{type:e.type,value:e.read()};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 UO(e){return e===null?null:Math.max(0,Date.now()-e)}function WO(e){let t=new Map;for(let[n,r]of Object.entries(e.variables))t.set(n,GO(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}`,GO(i));return t}function GO(e){return e.kind}function KO(e){if(e===null)return[];let{store:t,config:n,lastRenderBySegment:r}=e,i=new Set(t.names()),a=qO(n),o=[];for(let e of a){let t=n.segments[e];t&&o.push({name:e,template:t.template,referencedVars:JO(t.template,i),lastRender:r.get(e)??null})}return o}function qO(e){let t=[],n=new Set;for(let r of va(oo(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 JO(e,t){let n=new Set;for(let r of M_(e)){if(t.has(r)){n.add(r);continue}let e=r.split(`.`);for(;e.length>1;){e.pop();let r=e.join(`.`);if(t.has(r)){n.add(r);break}}}return Array.from(n).sort()}function YO(e){return e===null?null:e.config}const XO=[`vars`,`segments`,`config`];function ZO(e){return typeof e==`string`&&XO.includes(e)}function QO(e){return Math.max(1,e-2)}var $O=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 D(`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);D(`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{D(`Calculating context tokens from transcript: ${e}`);let n=await yC(e);if(n.length===0)return D(`No entries in transcript`),Z;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,D(`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 D(`Most recent main chain context: ${n} tokens (limit: ${t})`),X({totalTokens:n,maxTokens:t,...this.ratioPercentages(n,t)})}return D(`No main chain entries with usage data found`),Z}catch(e){return Q(`context transcript: ${e instanceof Error?e.message:String(e)}`)}}async getContextInfo(e){let t=this.calculateContextFromHookData(e);if(t)return X(t);let n=e.context_window?.context_window_size??2e5;return this.calculateContextTokensFromTranscript(e.transcript_path,n)}};function ek(e){let t=e.type||e.message?.role||e.message?.type,n=e.type===`user`&&e.message?.firstContentType===`tool_result`;return t===`user`&&!n}var tk=class{state=new Map;calculateLastResponseTime(e){if(e.length===0)return null;let t=null,n=null;for(let r of e){let e=r.type||r.message?.role||r.message?.type;if(ek(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}async foldMetrics(e,t){let n=this.state.get(e),r=sC(t);if(n&&r!==0&&n.cursor.mtimeMs===r)return this.state.delete(e),this.state.set(e,n),{kind:`ok`,value:{messageCount:n.messageCount,recent:[...n.recent]}};let i=await CC(t,n?.cursor);if(i.kind===`failed`)return i;if(i.kind===`absent`)return{kind:`ok`,value:{messageCount:n?.messageCount??0,recent:[...n?.recent??[]]}};let{entries:a,cursor:o,reset:s}=i.value,c=n&&!s?n:void 0,l=c?.messageCount??0,u=c?[...c.recent]:[];for(let e of a)e.isSidechain||(ek(e)&&l++,u.push(e));for(u.length>20&&(u=u.slice(-20)),this.state.delete(e),this.state.set(e,{cursor:o,messageCount:l,recent:u});this.state.size>256;){let e=this.state.keys().next().value;if(e===void 0)break;this.state.delete(e)}return{kind:`ok`,value:{messageCount:l,recent:[...u]}}}async getMetricsInfo(e,t){if(D(`Getting metrics from hook data for session: ${e}`),!t.cost)return Z;let n=await this.foldMetrics(e,t.transcript_path);return n.kind===`failed`?Q(`metrics (${e}): ${n.reason}`):X({responseTime:t.cost.total_api_duration_ms/1e3,lastResponseTime:this.calculateLastResponseTime(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 nk=new Map;function rk(e){if(!e)return``;let t=e.indexOf(`,`);return t<0?e:e.slice(0,t)}var ik=class{async getSessionId(){if(!process.env.TMUX_PANE)return Z;let e=rk(process.env.TMUX),t=nk.get(e);if(t!==void 0)return t;D(`Getting tmux session ID, TMUX_PANE: ${process.env.TMUX_PANE}`);let n=await Te({bin:`tmux`,args:[`display-message`,`-p`,`#S`],timeoutMs:1e3,category:`tmux`}),r=n.ok?n.stdout.trim()?X(n.stdout.trim()):Z:Q(`tmux display-message: ${n.reason}`);return nk.set(e,r),r}isInTmux(){return!!process.env.TMUX_PANE}},ak=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 ok=new qE;Ce(ok.launchStats);const sk=new YS({counters:ok,logger:Y}),ck=new rC({watchers:sk,logger:Y}),lk=new FC,uk=new XE,dk=new ak(We()),fk=new $O,pk=new tk,mk=new ik,hk=new GE({gitService:ck,sessionState:uk,watchers:sk},{observers:{onReload:e=>Y(`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)}`)}}),gk=60*1e3;function _k(){let e=import.meta.url,n=[];e.startsWith(`file://`)&&n.push(b(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){Y(`info`,`binary mtime changed (${e}); shutting down`),a&&clearInterval(a),Nk(0);return}}catch(e){Y(`warn`,`bin stat failed: ${e.message}`)}};return{arm(){i.size!==0&&(a=setInterval(o,gk),a.unref())},checkNow:o}}const vk=_k(),yk=TS({entryUrl:import.meta.url,intervalMs:gk,releaseIntervalMs:216e5,registryUrl:t.env.CC_CANDYBAR_REGISTRY_URL??`https://registry.npmjs.org`,fetchImpl:fetch,onApplied:()=>vk.checkNow(),log:Y});let bk=null,xk=null,Sk=0;function Ck(){t.on(`uncaughtException`,e=>{Y(`error`,`uncaughtException: ${e.stack||e.message}`),Nk(1)}),t.on(`unhandledRejection`,e=>{Y(`error`,`unhandledRejection: ${String(e)}`),Nk(1)});for(let e of[`SIGINT`,`SIGTERM`,`SIGHUP`])t.on(e,()=>{Y(`info`,`received ${e}, shutting down`),Nk(0)});try{Sk=Xv(t.env)}catch(e){Y(`error`,`refusing to boot: ${e.message}`),Nk(1);return}bk=Nb(t.pid);let e=Ub(Gb(bk));if(!e.decision.allow){Y(`warn`,`fork-bomb breaker: ${e.decision.reason}; refusing to boot`),Nk(1);return}xk=e.registryPath,r.mkdirSync(Me(),{recursive:!0}),Fe(Ne()),uk.useStorage(new $E(Re(),500,Y)),Ib({anchor:Fb(t.env),isAlive:Lb,onOrphaned:e=>{Y(`info`,`parent watchdog: ${e}; shutting down`),Nk(0)}}),wk(g.createServer({allowHalfOpen:!1},e=>{Pk(e)}),Ne(),!1)}function wk(e,n,r){e.removeAllListeners(`error`),e.removeAllListeners(`listening`),e.once(`error`,i=>{if(i.code!==`EADDRINUSE`){Y(`error`,`server error: ${i.message}`),Nk(1);return}if(r){Y(`info`,`lost rebind race; another daemon is alive — exiting`),t.exit(0);return}Tk(e,n)}),e.listen(n,()=>Ek(n))}function Tk(e,n){let i=Cb(wb(Ie(n)),(e,t)=>Mb(e,t,{readStartTime:jb,pidAlive:Lb}));if(i.kind===`attach-and-exit`){Y(`info`,`EADDRINUSE: ${i.reason} — exiting`),t.exit(0);return}Y(`warn`,`EADDRINUSE: ${i.reason} — unlinking stale socket and rebinding`);try{r.unlinkSync(n)}catch(e){if(e.code!==`ENOENT`){Y(`error`,`cannot unlink stale socket ${n}: ${e.message}`),Nk(1);return}}wk(e,n,!0)}function Ek(e){let n=Db(e);if(n.kind!==`present`){Y(`warn`,`no ownable socket at bind callback (${n.kind}); exiting`),Nk(0);return}Ak(e);try{r.chmodSync(e,384)}catch(e){Y(`warn`,`chmod socket failed: ${e.message}`)}Y(`info`,`daemon up: pid=${t.pid} v=3 sock=${e} heapCap=${Math.round(_.getHeapStatistics().heap_size_limit/1048576)}MB rssLimit=${Math.round(Sk/1048576)}MB`),cy();let i=dk.reset();i!==null&&Y(`warn`,`diagnostic dump wipe failed: ${i}`),vk.arm(),yk.arm(),kk(),Dk(e,n.identity)}function Dk(e,n){Ab({bound:n,myPid:t.pid,readIdentity:()=>Db(e),readLease:()=>wb(Ie(e)),shutdown:e=>Nk(e),log:Y}).arm()}let Ok=null;function kk(){Ok=Zv($v(ok.startedAt.getTime(),e=>Nk(e),{rssLimitBytes:Sk})),Ok.arm()}function Ak(e){let n=Tb(Ie(e),{pid:t.pid,version:3,binPath:t.argv[1],startTime:bk});n!==null&&Y(`warn`,`lease write failed: ${n}`)}let jk=0,Mk=!1;function Nk(e){if(!Mk){Mk=!0,setTimeout(()=>t.kill(t.pid,`SIGKILL`),500);try{ck.close()}catch(e){Y(`warn`,`gitService close failed: ${e.message}`)}try{lk.close()}catch(e){Y(`warn`,`usageStore close failed: ${e.message}`)}try{sk.closeAll()}catch(e){Y(`warn`,`watcherRegistry close failed: ${e.message}`)}try{uk.flush()}catch(e){Y(`warn`,`sessionState flush failed: ${e.message}`)}Eb(Le(),t.pid),xk!==null&&Wb(xk,t.pid,Vb,e=>r.unlinkSync(e)),t.exit(e)}}function Pk(e){jk++,ok.inFlight=jk;let t=!1,n=(n,r)=>{if(t){r!==null&&Y(`warn`,`exit-after-flush dropped: an earlier responder settled this socket`);return}t=!0;let i=r===null?void 0:()=>Nk(r);try{e.end(Ov(n),i)}catch(e){Y(`warn`,`response write failed: ${e.message}`),i?.()}},r=setTimeout(()=>{ok.requestsTimedOut++,n({ok:!1,error:`request exceeded 200ms`,code:`TIMEOUT`,daemonV:3},null)},200),i=kv(e=>{Ik(e).then(e=>n(e.resp,e.exitAfterFlush)).catch(e=>{Y(`error`,`handler threw: ${e?.stack||e}`),n({ok:!1,error:String(e?.message||e),code:`RENDER_FAILED`,daemonV:3},null)})},e=>{Y(`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=>{Y(`warn`,`socket error: ${e.message}`)}),e.on(`close`,()=>{clearTimeout(r),jk=Math.max(0,jk-1),ok.inFlight=jk})}const Fk=e=>({resp:e,exitAfterFlush:null});async function Ik(e){if(!e||typeof e!=`object`||typeof e.v!=`number`)return Fk({ok:!1,error:`malformed request`,code:`BAD_REQUEST`,daemonV:3});if(e.v!==3)return e.v>3?Y(`info`,`version mismatch: client=${e.v} > daemon=3; binary likely upgraded — exiting after the response flushes`):Y(`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 Fk({ok:!0,stats:ok.snapshot({gitCache:ck.getStats(),usageCache:lk.getStats(),renderCacheSize:hk.size,watchersActive:sk.size(),nextRestartReason:Ok?.describeNextRestart()??null})});if(e.kind===`render`){ok.requestsTotal++;let t=Date.now();try{let{report:n}=LO(e.hookData);for(let e of n.unknownTopLevelFields)Y(`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 ok.requestsErrored++,Y(`warn`,`BAD_REQUEST: ${r.join(`; `)}`),Fk({ok:!1,error:`malformed hookData: ${r.join(`; `)}`,code:`BAD_REQUEST`,daemonV:3});let i=e.hookData.workspace.project_dir,{configFile:a,unknownFlagsError:o}=Lk(e.args),s=e.hookData.session_id,c=xv(e),l=JSON.stringify(c);uk.get(s,`client-hints`)!==l&&uk.set(s,TO,l);let u=uk.get(s,`config-override`)??a??c.configEnv,d=hk.getOrCreate(i,e.cwd,u),f=mO({projectDir:i,cwd:e.cwd,configFile:u??null});uk.get(s,`render-origin`)!==f&&uk.set(s,pO,f);let p=c.termCols,m=QO(p??120),h=ax(c.termRows),g={...zk,width:m},{authoredRoots:_}=d.state,v=VC(d.state.config,t=>uk.get(e.hookData.session_id,t),e=>_.has(e)),y=await ew(e.hookData,Uk,e.cwd,d.state.neededInputPaths,v,c),b=PT(v.theme);g.style=v.style,g.separator=v.separator,g.wrap=v.autoWrap,g.padding=v.padding,g.charset=v.charset,g.colorCompatibility=v.colorCompatibility;let x=NE(d.state.config,d.state.compiled,d.state.store,d.state.registry,y,b,g,{perSegmentSink:d.state.lastRenderCellsBySegment},{look:fi(d.state.config.looks,v.look),preset:v.preset}),S=uk.get(e.hookData.session_id,`click.error`);S&&uk.clear(e.hookData.session_id,`click.error`);let C=[o,d.lastError,S].filter(Boolean).join(`
|
|
180
|
+
`),ee=yk.notice({sessionId:s,dismissed:uk.get(s,dS),enabled:v.updateNotice}),te=d.lastError===null?null:d.configFilePath,ne=ux(C,ee,d.lastWarning??``),re=dk.sync(s,ne===null?null:fx(ne));re!==null&&Y(`warn`,`diagnostic dump failed: ${re}`);let w=px(x,ne,{fullText:re===null?{kind:`file`,path:dk.pathFor(s)}:{kind:`unavailable`,reason:re},failedConfigFile:te},{width:m,rowCap:h,colorCompatibility:v.colorCompatibility}),ie=Date.now()-t,T=ck.getStats(),E=lk.getStats();return Y(`info`,`render sid=${e.hookData.session_id??`?`} took=${ie}ms termCols=${p??`?`} termRows=${c.termRows??`?`} width=${m} git=${T.size}/${T.hits}h/${T.misses}m usage=${E.size}/${E.hits}h/${E.misses}m err=${C?`Y`:`N`} upd=${ee.length} warn=${d.lastWarning?`Y`:`N`}`),Fk({ok:!0,output:w+`
|
|
181
|
+
`})}catch(e){throw ok.requestsErrored++,e}}if(e.kind===`click`)return Fk(await Wk(e.verb,e.value));if(e.kind===`debug`){if(!ZO(e.what))return Fk({ok:!1,error:`unknown debug 'what': ${String(e.what)} (have: ${XO.join(`, `)})`,code:`BAD_REQUEST`,daemonV:3});let t=hk.firstState(),n=t===null?null:{store:t.store,registry:t.registry,config:t.config,compiled:t.compiled,lastRenderBySegment:e.what===`segments`?Hk(t.lastRenderCellsBySegment,t.config.globals.charset??`unicode`,t.config.globals.colorCompatibility??`truecolor`):Vk};return Fk({ok:!0,debug:BO(e.what,n)})}return Fk({ok:!1,error:`unknown kind`,code:`BAD_REQUEST`,daemonV:3})}function Lk(e){let{values:t,tokens:n}=S({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:Sv(t.config),unknownFlagsError:r.length>0?`Unknown flags: ${r.join(`, `)}`:null}}const Rk={sessionState:uk,dlog:Y,applyUpdate:()=>yk.act(),doctor:GD()},zk={style:`powerline`,colorCompatibility:`truecolor`,wrap:!0,padding:1,charset:`unicode`},Bk={...zk,width:1/0},Vk=new Map;function Hk(e,t,n){let r=new Map;for(let[i,a]of e)r.set(i,ix(a,{...Bk,charset:t,colorCompatibility:n}));return r}const Uk={gitProvider:ck,usageStore:lk,contextProvider:fk,metricsProvider:pk,tmuxService:mk,log:Y,clock:()=>new Date};function Wk(e,t){let n=PO.get(e);if(!n)return{ok:!1,error:`unknown click verb: ${e}`,code:`BAD_REQUEST`,daemonV:3};try{return n(t,Rk),{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 Gk={connectMs:200,budgetMs:500};async function Kk(e){let n=e.includes(`--json`),r=await qk();if(r.kind!==`ok`&&(t.stderr.write(`daemon-stats: ${Lv(r)}\n`),t.exit(1)),n){t.stdout.write(JSON.stringify(r.value,null,2)+`
|
|
182
|
+
`);return}t.stdout.write(Zk(r.value))}function qk(){return jv({kind:`stats`},Gk,e=>`stats`in e?e.stats:void 0)}function Jk(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function Yk(e,t){let n=e+t;return n===0?`n/a`:`${(e/n*100).toFixed(1)}%`}function Xk(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 Zk(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 ${Xk(e.uptimeSec)}`),t.push(` rss ${Jk(e.rssBytes)}`),t.push(` heapUsed ${Jk(e.heapUsedBytes)}`),t.push(` heapTotal ${Jk(e.heapTotalBytes)}`),t.push(` external ${Jk(e.externalBytes)}`),t.push(` arrayBuffers ${Jk(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 ${Yk(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 ${Yk(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(`
|
|
183
183
|
`)+`
|
|
184
|
-
`}const
|
|
185
|
-
`);return}t.stdout.write(
|
|
186
|
-
`;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?``:` ${
|
|
184
|
+
`}const Qk={connectMs:200,budgetMs:500};async function $k(e,n){let r=n.includes(`--json`),i=await eA(e);if(i.kind!==`ok`&&(t.stderr.write(`${e}: ${Lv(i)}\n`),t.exit(1)),r){t.stdout.write(JSON.stringify(i.value,null,2)+`
|
|
185
|
+
`);return}t.stdout.write(tA(i.value))}function eA(e){return jv({kind:`debug`,what:e},Qk,e=>`debug`in e?e.debug:void 0)}function tA(e){switch(e.what){case`vars`:return nA(e.vars);case`segments`:return rA(e.segments);case`config`:return iA(e.config);default:return e}}function nA(e){if(e.length===0)return`no variables (DSL not active)
|
|
186
|
+
`;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?``:` ${oA(a.ageMs)}`,o=a.lastError?` ✗ ${a.lastError.message}`:``;t.push(` ${a.name.padEnd(n)} ${(a.source??`—`).padEnd(r)} ${a.type.padEnd(i)} ${aA(a.value)}${e}${o}`)}return t.join(`
|
|
187
187
|
`)+`
|
|
188
|
-
`}function
|
|
188
|
+
`}function rA(e){if(e.length===0)return`no segments (DSL not active)
|
|
189
189
|
`;let t=[`segments (${e.length})`,``];for(let n of e)t.push(` ${n.name}`),t.push(` template ${n.template}`),n.referencedVars.length>0&&t.push(` vars ${n.referencedVars.join(`, `)}`),n.lastRender!==null&&t.push(` last ${n.lastRender}`);return t.join(`
|
|
190
190
|
`)+`
|
|
191
|
-
`}function
|
|
191
|
+
`}function iA(e){return e===null?`config: DSL not active
|
|
192
192
|
`:JSON.stringify(e,null,2)+`
|
|
193
|
-
`}function
|
|
194
|
-
`));return l.rendered}finally{c.dispose()}}function
|
|
193
|
+
`}function aA(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>60?t.slice(0,57)+`…`:t}function oA(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m`}function sA(){let e=lA();return e===null?null:r.readFileSync(e,`utf-8`)}function cA(){let e;try{e=sA()}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 lA(){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 uA(e){let t=e.CC_CANDYBAR_CONFIG??``;return t===``?void 0:t}const dA=5e3;function fA(e){let t=`/home/tester`,n=Math.floor(Date.now()/1e3);return{hook_event_name:`Status`,session_id:`test0a1b-2c3d-4e5f-6a7b-8c9d0e1f2a3b`,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:{current_dir:`${t}/code/cc-candybar/src`,project_dir:`${t}/code/cc-candybar`},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:{session:`work`},host:{name:`tester-box`,user:`tester`,ssh:!0},theme:{effective:e.theme},look:{effective:e.look},preset:{effective:e.preset,customized:e.presetCustomized},style:{effective:e.style},charset:{effective:e.charset},colorCompatibility:{effective:e.colorCompatibility},autoWrap:{effective:e.autoWrap},padding:{effective:e.padding}}}function pA(e,t){let n=ov(e,e),r=cv(n);return r!==null&&t.push(r),n.kind===`file`?n.path:null}async function mA(e,n=t.cwd()){let i=[],a=e===void 0?pA(n,i):c.resolve(rv(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=uv(n,n);o!==null&&i.push(o);try{return{kind:`clean`,configPath:a,warnings:i,rendered:await hA(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 da&&i.push(...e.warnings),{kind:`fatal`,configPath:a,message:e instanceof da||e instanceof Error?e.message:String(e),warnings:i})}}async function hA(e,t,n){let{config:r,source:i,warnings:a}=dv(e,pw);n.push(...a);let o=mv(r,e??`<default>`,i),s=new zE,c=new jT(s,o.globals.default_empty_value??``,void 0,new XE);try{let e=ME(o,c,{cwd:t});n.push(...e.loadWarnings);let r=await c.settled(dA);r.length>0&&n.push(`source${r.length===1?``:`s`} still running after ${dA} ms, rendered with fallback values: ${r.join(`, `)}`),uS(o);let i=VC(o,()=>null,()=>!1),a=t=>{let n=new Map;return{rendered:NE(o,e,s,c,fA(t),PT(t.theme),{style:t.style,separator:t.separator,width:200,colorCompatibility:t.colorCompatibility,wrap:t.autoWrap,padding:t.padding,charset:t.charset},{onSegmentError:(e,t)=>n.set(e,t)},{look:fi(o.looks,t.look),preset:t.preset}),segmentErrors:n}},l=a(i),u=a({...i,presetCustomized:!0}),d=[...[...l.segmentErrors].map(([e,t])=>`segment "${e}": ${t}`),...[...u.segmentErrors].filter(([e])=>!l.segmentErrors.has(e)).map(([e,t])=>`segment "${e}": ${t} (under .preset.customized = true)`)];if(d.length>0)throw Error(`config renders with ${d.length} segment error${d.length===1?``:`s`} (the daemon would render ⚠ error cells):\n`+d.map(e=>` ${e}`).join(`
|
|
194
|
+
`));return l.rendered}finally{c.dispose()}}function gA(e){return e.map(e=>`warning: ${e}\n`).join(``)}function _A(e){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`,stderr:gA(e.warnings),code:0};case`fatal`:return{stdout:``,stderr:gA(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}}}async function vA(e){(e.length>1||e[0]===``)&&(t.stderr.write(`check: expected at most one non-empty path
|
|
195
195
|
Usage: cc-candybar check [config-file]
|
|
196
|
-
`),t.exit(2));let n=
|
|
197
|
-
`,kick:!0,debug:`daemon unavailable (transient: ${e.cause}: ${e.message}) — kicking daemon`};case`permanent`:return{output:
|
|
196
|
+
`),t.exit(2));let n=_A(await mA(e[0]??uA(t.env)));t.stdout.write(n.stdout),t.stderr.write(n.stderr),t.exit(n.code)}const yA=`${Xb}${Yb}`;function bA(e){return`${yA}⚠ cc-candybar: ${xA(e)}[0m\n`}function xA(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: ${Jb(e.message,60)}`;case`render_failed`:return`render failed: ${Jb(e.message,60)}`;case`malformed_response`:return`malformed daemon response: ${Jb(e.message,60)}`}}function SA(e){switch(e.kind){case`ok`:return{output:e.value,kick:!1,debug:null};case`transient`:return{output:`
|
|
197
|
+
`,kick:!0,debug:`daemon unavailable (transient: ${e.cause}: ${e.message}) — kicking daemon`};case`permanent`:return{output:bA(e),kick:!1,debug:`daemon refused request (permanent: ${e.cause}) — not kicking`}}}function CA(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}function wA({check:e,verdict:t}){return t.ok?`✓ ${e.label}\n`:`✗ ${e.label} — ${t.reason}${t.fix===void 0?``:` (fix: click ☰ 🧰 tools ▸ 🩺 doctor, then [fix] on the bar)`}\n`}function TA(e,t){let n;try{n=XD(e,Oh(t))}catch(e){return{stdout:``,stderr:`doctor: ${e instanceof Error?e.message:String(e)}\n`,code:2}}let r=jh(n);return{stdout:r.map(wA).join(``),stderr:``,code:+!r.every(e=>e.verdict.ok)}}function EA(e){e.length>0&&(t.stderr.write(`doctor: takes no arguments
|
|
198
198
|
Usage: cc-candybar doctor
|
|
199
|
-
`),t.exit(2));let n=
|
|
199
|
+
`),t.exit(2));let n=TA(GD(),t.env);t.stdout.write(n.stdout),t.stderr.write(n.stderr),t.exit(n.code)}function DA(){return CA(t.env.COLUMNS,t.stderr.columns)}function OA(){return CA(t.env.LINES,t.stderr.rows)}const kA=[`SSH_CONNECTION`,`SSH_CLIENT`,`SSH_TTY`],AA=e=>e.some(e=>t.argv.includes(e));function jA(){return kA.some(e=>(t.env[e]??``)!==``)}function MA(){console.log(mh)}async function NA(){try{AA(dh.help)&&(MA(),t.exit(0)),AA(dh.version)&&(console.log(`cc-candybar ${Vy}`),t.exit(0));let e=t.argv[2];if(e===`install`&&(await xb(t.argv.slice(3)),t.exit(0)),e===`install-url-handler`&&(gb(),t.exit(0)),e===`url-handle`){await vb(t.argv[3]);return}if(e===`daemon`){Ck();return}if(e===`daemon-stats`&&(await Kk(t.argv.slice(3)),t.exit(0)),e===`check`||e===`lint`){await vA(t.argv.slice(3));return}if(e===`schema`){cA();return}if(e===`doctor`){EA(t.argv.slice(3));return}ZO(e)&&(await $k(e,t.argv.slice(3)),t.exit(0)),t.stdin.isTTY===!0&&(console.error(`Error: This tool requires input from Claude Code
|
|
200
200
|
|
|
201
201
|
cc-candybar is designed to be used as a Claude Code statusLine command.
|
|
202
202
|
It reads hook data from stdin and outputs formatted statusline.
|
|
@@ -212,4 +212,4 @@ Add to ~/.claude/settings.json:
|
|
|
212
212
|
Run with --help for more options.
|
|
213
213
|
|
|
214
214
|
To test output manually:
|
|
215
|
-
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)),D(`Working directory: ${t.cwd()}`),D(`Process args:`,t.argv);let r=await n(t.stdin);D(`Received hook data:`,JSON.stringify(r,null,2)),r||(console.error(`Error: No input data received from stdin`),
|
|
215
|
+
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)),D(`Working directory: ${t.cwd()}`),D(`Process args:`,t.argv);let r=await n(t.stdin);D(`Received hook data:`,JSON.stringify(r,null,2)),r||(console.error(`Error: No input data received from stdin`),MA(),t.exit(1));let i=SA(await Vv(r,t.argv,t.cwd(),{termCols:DA(),termRows:OA(),ssh:jA(),tmux:Oh(t.env),configEnv:uA(t.env)}));i.debug!==null&&D(i.debug),i.kick&&ey(),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)}}NA();export{};
|