@promptctl/cc-candybar 1.129.0 → 1.129.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +3 -3
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -161,11 +161,11 @@ Config tooling:
|
|
|
161
161
|
running daemon; none spawn one.)
|
|
162
162
|
|
|
163
163
|
`,nT=`readableOn (mix (color "foreground") (bgOf) 60) (bgOf) 3`,rT={socket:`TMUX`,pane:`TMUX_PANE`,truecolor:`CLAUDE_CODE_TMUX_TRUECOLOR`};function iT(e){let t=e[rT.socket]??``,n=e[rT.pane]??``;if(t===``||n===``)return null;let r=e[rT.truecolor]??``;return{socket:t.split(`,`)[0],pane:n,truecolor:r===``?null:r}}function aT(e){let[t,...n]=e;return t===void 0?{ok:!0}:{ok:!1,reason:t,more:n}}const oT=rT.truecolor,sT={name:`tmuxTruecolor`,label:`tmux truecolor`,probe:({tmux:e,claudeSettings:t})=>{switch(e.kind){case`unreported`:return{ok:!1,reason:"the client reported no tmux facts — re-run `cc-candybar install` to stage a current client"};case`outside`:return{ok:!0};case`inside`:{if(e.termfeatures.kind===`failed`)return{ok:!1,reason:`tmux could not be asked: ${e.termfeatures.reason}`};if(!e.termfeatures.value.includes(`RGB`)||e.hint.truecolor!==null)return{ok:!0};let n=t.env[oT];return typeof n==`string`&&n!==``?{ok:!1,reason:`${oT} is set in ${t.path} — restart Claude Code to apply`}:{ok:!1,reason:`Claude Code renders the bar in 256 colours inside tmux`,fix:{kind:`claude-settings`,path:[`env`,oT],value:`1`}}}}}},cT={variable:`is never read`,action:`is never clicked`,helper:`is never called`,segment:`is in no preset`},lT={name:`config`,label:`config`,probe:({config:e})=>{switch(e.kind){case`failed`:{let[t=`the config failed to load`,...n]=[...e.error.split(`
|
|
164
|
-
`).map(e=>e.trim()).filter(e=>e!==``),...e.warnings];return{ok:!1,reason:t,more:n}}case`loaded`:return aT([...e.warnings,...e.unused.map(({kind:e,name:t})=>`${e} "${t}" ${cT[e]}`)])}}},uT="re-run `cc-candybar install`";function dT(e){if(e.kind===`failed`)return[`Launch Services could not be asked which app opens cc-candybar:// — ${e.reason}`];if(e.value===null)return[`no app is registered for cc-candybar:// — ${uT}`];let{app:t,missing:n}=e.value;return n.kind===`failed`?[`${t} opens cc-candybar://, but ${n.reason} — ${uT}`]:n.value.map(e=>`${e} is missing, and ${t} runs it — ${uT}`)}const fT=[lT,{name:`urlHandler`,label:`URL handler`,probe:({urlHandler:e})=>{switch(e.kind){case`unsupported`:return{ok:!0};case`unprobed`:return{ok:!1,reason:e.reason};case`arrived`:return e.handler===e.bar?{ok:!0}:{ok:!1,reason:e.handler===null?`the URL handler does not report its version, so it is older than the bar (${e.bar}) — ${uT}`:`the URL handler runs cc-candybar ${e.handler}; the bar runs ${e.bar} — ${uT}`};case`lost`:return aT([...dT(e.opener),e.unopened===null?`a cc-candybar:// link was opened and did not arrive at the daemon`:`a cc-candybar:// link could not be opened — ${e.unopened}`])}}},sT,{name:`effectRefresh`,label:`effect refresh`,probe:({effect:e,placementEffects:t,transitions:n,claudeSettings:r})=>{let i=[...e.kind===`decided`?e.value===`none`?[]:[`the bar wears the ${e.name} effect`]:[`a globals.effect rule can give the bar an effect`],...t.map(({placement:e,effect:t})=>`${e} wears the ${t} effect`),...n?[`placements fade in and dissolve out as they come and go`]:[]];if(i.length===0)return{ok:!0};let a=i.join(` and `),{path:o,statusLine:s}=r;switch(s.kind){case`absent`:return{ok:!1,reason:`${a}, and ${o} sets no statusLine — set "refreshInterval": 1 beside the statusLine command that runs the bar`};case`not-an-object`:return{ok:!1,reason:`${a}, and ${o} sets statusLine to ${JSON.stringify(s.value)}, not a statusLine object — re-run \`cc-candybar install\` to write one`};case`present`:break}let c=s.refreshInterval;return c===1?{ok:!0}:{ok:!1,reason:c===void 0?`${a}, but Claude Code redraws it only on events`:typeof c==`number`&&c>1?`${a}, but Claude Code redraws it only every ${c} s`:`${a}, but statusLine.refreshInterval is ${JSON.stringify(c)}, not a number of seconds Claude Code accepts (its minimum is 1)`,fix:{kind:`claude-settings`,path:[`statusLine`,`refreshInterval`],value:1}}}}];function pT(e){return fT.map(t=>({check:t,verdict:t.probe(e)}))}function mT(e){return fT.find(t=>t.name===e)}const hT=`${wp}doctor.`;function gT(e){let t=`${hT}${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`}}function _T(e,t=[]){return t.length===0?e:`${e} (+${t.length} more — run \`cc-candybar doctor\`)`}function vT(e){return e.flatMap(({check:e,verdict:t})=>{let n=gT(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:``},{key:n.fixable,value:pl}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:_T(t.reason,t.more)},{key:n.fixable,value:t.fix===void 0?pl:fl}]})}const yT={copySession:{copy:`{{ .session.id }}`},copyResume:{copy:`{{ .resume_command }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},openConfig:{open:`{{ .config_path }}`}};function bT(e){let t=t=>`${e}${t}`;return{template:`{{ action "${t(`copySession`)}" "⎘ id" }}{{ if ne .resume_command "" }} {{ action "${t(`copyResume`)}" "⎘ resume" }}{{ end }} {{ action "${t(`openProject`)}" "↗ proj" }} {{ action "${t(`openTranscript`)}" "↗ log" }}{{ if ne .git.repoUrl "" }} {{ link .git.repoUrl "↗ repo" }}{{ end }}{{ if ne .config_path "" }} {{ action "${t(`openConfig`)}" "↗ config" }}{{ end }}`,actions:Object.fromEntries(Object.entries(yT).map(([t,n])=>[`${e}${t}`,n]))}}const xT=`armed`,ST=`disarmed`,CT=`.armed`,wT=e=>e.endsWith(CT);function TT(e,t,n){let r=`${e}${CT}`,i=`${e}.arm`,a=`${e}.disarm`,o=`(eq .${e} "${xT}")`;return{template:`{{ if ${o} }}{{ action "${e}" "${t.confirm}" }} {{ action "${a}" "✕" }}{{ else }}{{ action "${i}" "${t.arm}" }}{{ end }}`,actions:{[i]:{set:r,to:xT},[a]:{set:r,to:ST},[e]:{do:[a,...n]}},armed:o,variables:{[e]:{kind:`state`,key:r,default:ST}},disarm:a}}const ET=RegExp(`^/[^\\s\\x00-\\x1f\\x7f-\\x9f/][^\\x00-\\x1f\\x7f-\\x9f]*$`);function DT(e){return typeof e==`string`&&ET.test(e)?{kind:`line`,line:e}:{kind:`refused`,reason:`a slash command is "/" then its name, e.g. "/compact" or "/model opus", on one line with no control characters, got ${JSON.stringify(e)}`}}function OT(e){let t=DT(e);if(t.kind===`refused`)throw Error(t.reason);return t.line}const kT=[`/compact`,`/model`],AT=`/clear`;function jT(e){let t=t=>`${e}${t.slice(1)}`,n=`${e}clear.slash`,r=TT(`${e}clear`,{arm:AT,confirm:`${AT} ✓ confirm`},[n]);return{template:kT.map(e=>`{{ action "${t(e)}" "${e}" }} `).join(``)+r.template,when:`{{ ${$C} }}`,actions:{...Object.fromEntries(kT.map(e=>[t(e),{slash:OT(e)}])),...r.actions,[n]:{slash:OT(AT)}},variables:r.variables,disarm:r.disarm}}function MT(e,t){let n=(e.CLAUDE_CONFIG_DIR??``).split(`,`)[0].trim();return n===``?void 0:l.resolve(t,n)}function NT(e){return e??l.join(h.homedir(),`.claude`)}function PT(e){return l.join(e,`settings.json`)}function FT(e){return l.join(e,`plugins`,`installed_plugins.json`)}function IT(e){return r.existsSync(e)?r.readFileSync(e,`utf8`):``}function LT(e){let t;try{let n=IT(e);if(/^\s*$/.test(n))return{};t=Rl.parse(n)}catch(t){throw Error(`cannot read ${e}: ${zT(t)}`,{cause:t})}if(!RT(t))throw Error(`cannot read ${e}: not a JSON object`);return t}const RT=e=>typeof e==`object`&&!!e&&!Array.isArray(e),zT=e=>e instanceof Error?e.message:String(e),BT=Array.from({length:10},(e,t)=>(t+1)*1e5),VT=BT[0],HT=BT[BT.length-1];function UT(e){let t;try{t=LT(e)}catch(e){return X(e instanceof Error?e.message:String(e))}let n=t.autoCompactWindow;return n===void 0?J(`auto`):typeof n==`number`&&Number.isInteger(n)&&n>=VT&&n<=HT?J(n):X(`${e}: autoCompactWindow is ${JSON.stringify(n)}, not a window /autocompact accepts (${VT}–${HT} tokens)`)}function WT(e,t){let n=Math.min(t??HT,HT),r=e===`auto`?n:Math.min(e,n);return{window:e===`auto`?0:e,applied:e===`auto`?0:r,lower:BT.filter(e=>e<r).at(-1)??0,higher:BT.find(e=>e>r&&e<=n)??0}}function GT(e,t){return{template:`{{ if ne .autocompact.error "" }}⇲ ⚠ {{ .autocompact.error }}{{ else }}⇲ {{ if eq .autocompact.window 0 }}auto{{ else }}${t(`.autocompact.applied`)}{{ end }}{{ if ${$C} }}{{ if gt .autocompact.lower 0 }} {{ action (printf "${e}%d" .autocompact.lower) "−" }}{{ end }}{{ if gt .autocompact.higher 0 }} {{ action (printf "${e}%d" .autocompact.higher) "+" }}{{ end }}{{ if gt .autocompact.window 0 }} {{ action "${e}auto" "↺" }}{{ end }}{{ end }}{{ end }}`,bg:`{{ if ne .autocompact.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .autocompact.window 0) (ne .autocompact.error "") }}`,actions:{[`${e}auto`]:{slash:OT(`/autocompact auto`)},...Object.fromEntries(BT.map(t=>[`${e}${t}`,{slash:OT(`/autocompact ${t}`)}]))}}}const KT=e=>`{{ if ge ${e} 1000000 }}{{ printf "%.1f" (divf ${e} 1000000) }}M{{ else if ge ${e} 1000 }}{{ printf "%.1f" (divf ${e} 1000) }}K{{ else }}{{ ${e} }}{{ end }}`,qT=`${wp}menu`,JT=`open`,YT=`${wp}edit`,XT=`${wp}toolbar`,ZT=bT(wp),QT=`${wp}commands`,$T=jT(`${QT}.`),eE=`${wp}autocompact`,tE=GT(`${eE}.`,KT),nE=e=>({kind:`segment`,name:e}),rE=`${wp}tab`,iE=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],aE=e=>`${rE}.${e}`,oE=e=>`${aE(e)}.toggle`,sE=e=>({variable:rE,key:rE,member:e}),cE=`${wp}save`,lE=`${wp}preset.save`,uE=`${wp}preset.delete`,dE=`${wp}themeDefault.save`,fE=`${wp}themeDefault.differs`,pE=`${wp}themeDefault.theme`,mE={when:`{{ .${fE} }}`,template:`{{ action "${dE}" (printf "⤓ default for %s" .${pE}) }}`},hE=`${wp}resetAll`,gE=`${qT}.toggle`,_E={variable:qT,key:qT,member:JT},vE=`${wp}undo`,yE=`${wp}back`,bE=`${yE}.step`,xE=`${wp}navigation.back`,SE=yE,CE={template:`{{ if gt .${xE} 0 }}{{ action "${yE}" "◁" }}{{ else }}{{ fg (${nT}) "◁" }}{{ end }}`},wE=`${wp}redo`,TE=`${wp}doctor`,EE=`${TE}.run`,DE=e=>`${TE}.fix.${e}`,OE=e=>`${TE}.${e}`,kE=wb(`${wp}pickers`),AE=[{template:`{{ themePreview }}`}],jE={template:`{{ layoutPreview }}`},ME={preset:[jE,{when:`{{ not .preset.bundled }}`,template:`{{ action "${uE}" (printf "🗑 delete %s" .${ew.preset.effectiveVar}) }}`}],theme:AE,style:AE,variation:[jE],shade:[jE]},NE=e=>`${wp}${e}`,PE=e=>`${wp}apply.${e}`,FE=e=>`${wp}reset.${e}`,IE=e=>`${wp}list.${e}`,LE=(e,t)=>`${IE(e)}.${t}`,RE=e=>`${wp}resettable.${e}`,zE=e=>e.length===0?`false`:`(or ${e.map(e=>`.${RE(e)}`).join(` `)})`,BE=Object.keys(ew).map(e=>{let t=ew[e],n=ff(t.configKey),r=Mw({label:t.label,domain:n},t.sessionKey,t.effectiveVar,PE(e),kE);return{...t,name:e,control:r,beneath:ME[e]??[]}}),VE={preset:`door`,theme:`look`,style:`look`,effect:`look`,variation:`look`,shade:`look`,endcaps:`look`,transitions:`look`,autoWrap:`layout`,padding:`layout`,updateNotice:`config`},HE=e=>BE.filter(t=>VE[t.name]===e),UE=e=>HE(e).map(tD);new Set(BE.flatMap(e=>[e.sessionKey,e.configKey]));const WE=TT(hE,{arm:`⟲`,confirm:`⟲ reset all?`},BE.map(e=>FE(e.name))),GE=[`unsaved`,`history.undo`,`history.redo`],KE=e=>`${wp}${e}`,qE=KE(`unsaved`),JE=(e,t)=>({body:t,shown:`(gt .${KE(e)} 0)`}),YE=[JE(`unsaved`,`{{ action "${cE}" (printf "💾 save %d" .${qE}) }}`),JE(`history.undo`,`{{ action "${vE}" "↶" }}`),JE(`history.redo`,`{{ action "${wE}" "↷" }}`),{body:WE.template,shown:`(or ${zE(BE.map(e=>e.name))} ${WE.armed})`}],XE={when:`{{ or ${YE.map(e=>e.shown).join(` `)} }}`,template:`{{ $sep := "" }}`+YE.map(e=>`{{ if ${e.shown} }}{{ $sep }}${e.body}{{ $sep = " " }}{{ end }}`).join(``)},ZE=[{step:WE,place:`door`},{step:$T,place:`session`}],QE=e=>e.map(e=>e.step.disarm),$E=QE(ZE),eD=QE(ZE.filter(e=>e.place!==`door`));function tD(e){let t=NE(e.name);return e.control.kind===`inline`?nE(t):Gd(t,e.control.list.ref,{kind:`container`,direction:`vertical`,children:[nE(IE(e.name)),...e.beneath.map((t,n)=>nE(LE(e.name,n)))]},`drop`)}function nD(e){return e===qT}function rD(e){let t=nE(qT);if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[rD(n),...r]}:{kind:`container`,direction:`vertical`,children:[t,e]}}return e.kind===`container`&&e.when===void 0?{...e,children:[t,...e.children]}:{kind:`container`,direction:`horizontal`,children:[t,e]}}function iD(e){return aD(e)>0?e:rD(e)}function aD(e){let t=0;for(let n of wu(e))n.kind===`segment`&&nD(n.name)&&(t+=1);return t}function oD(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&nD(e.name)||e.opens!==void 0&&oD(e.opens.body,!0):e.children.some(e=>oD(e,n))}const sD={session:{direction:`vertical`,content:[nE(XT),{kind:`container`,direction:`horizontal`,children:[nE(QT),nE(eE)]}],after:[]},look:{direction:`horizontal`,content:[],after:[nE(dE)]},layout:{direction:`horizontal`,content:[nE(lE),nE(YT)],after:[]},config:{direction:`horizontal`,content:[],after:[]},tools:{direction:`vertical`,content:[nE(TE),...fT.map(e=>nE(OE(e.name)))],after:[]}},cD=e=>({kind:`container`,direction:sD[e].direction,children:[...sD[e].content,...UE(e),...sD[e].after]});function lD(e){return e.kind===`segment`?nD(e.name)?Gd(e.name,_E,dD,`above`):e:pD(e)}function uD(){return{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[nE(SE),...UE(`door`),nE(cE)]},{kind:`container`,direction:`horizontal`,children:iE.map(({member:e})=>Gd(aE(e),sE(e),cD(e),`drop`))}]}}const dD=uD();function fD(e){let t=new Map;for(let e of wu(dD))e.kind===`segment`&&e.opens!==void 0&&t.set(e.opens.ref.key,e.opens.ref.variable);return[...t].map(([t,n])=>{let r=e.variables[n];if(r?.kind!==`state`||r.default===void 0)throw Error(`settings menu: the door folds "${t}", but "${n}" is not a state variable the menu declares with a default`);let i=`${qT}.fold.${bp(t)}`;return e.actions[i]={set:t,to:r.default},i})}function pD(e){return{...e,children:e.children.map(e=>lD(e))}}function mD(e){let t={variables:{[qT]:Zd(qT,Bd)},actions:{[gE]:Qd(qT,JT),[EE]:{doctor:`run`},[YT]:{do:[...tx]},...ZT.actions,...$T.actions,...tE.actions,[cE]:{save:!0},[vE]:{undo:!0},[bE]:{back:!0},[yE]:{do:[bE,...$E]},[wE]:{redo:!0},[lE]:{preset:`save`},[dE]:{themeDefault:`save`},[uE]:{preset:`delete`,name:`{{ .${ew.preset.effectiveVar} }}`}},segments:{[qT]:{template:`{{ $door := ${Yd(qT,Xd(e),Xd(`✖`))} }}{{ if ${qd(_E)} }}{{ fg (keptOn (color "error") (bgOf)) $door }}{{ else }}{{ $door }}{{ end }}`},[XT]:{template:ZT.template},[QT]:{template:$T.template,when:$T.when},[eE]:{template:tE.template,bg:tE.bg,when:tE.when},[SE]:CE,[cE]:XE,[dE]:mE,[lE]:{template:`{{ action "${lE}" "+ preset" }}`},[TE]:{template:`{{ action "${EE}" "🩺 doctor" }}`},[YT]:{template:`{{ action "${YT}" "✎ arrange" "✎ done" }}`}}};t.variables[fE]={kind:`input`,path:`themeDefault.differs`,type:`boolean`,default:!1},t.variables[pE]={kind:`input`,path:`themeDefault.theme`,type:`string`,default:``},t.variables[xE]={kind:`input`,path:`navigation.back`,type:`number`,default:0};for(let e of GE)t.variables[KE(e)]={kind:`input`,path:e,type:`number`,default:0};t.variables[rE]=Zd(rE,`session`);for(let{member:e,label:n}of iE){t.actions[oE(e)]=Qd(rE,e),t.actions[aE(e)]={do:[oE(e),...eD]};let r=zE(HE(e).map(e=>e.name)),i=`(ternary ${Xd(` •`)} "" ${r})`,a=e=>`(print ${Xd(e)} ${i})`;t.segments[aE(e)]={template:`{{ ${Yd(aE(e),a(n),a(`▾ ${n}`))} }}`}}return Object.assign(t.variables,$T.variables,WE.variables),gD(t),hD(t),t.actions[qT]={do:[gE,...$E,...fD(t)]},t}function hD(e){for(let t of fT){let n=gT(t.name),r=DE(t.name);for(let t of Object.values(n))e.variables[t]={kind:`state`,key:t,default:``};e.actions[r]={doctor:`fix`,check:t.name},e.segments[OE(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${fl}" }} {{ action "${r}" "[fix]" }}{{ end }}{{ end }}`}}}function gD(e){for(let t of BE){Object.assign(e.actions,t.control.actions);let n=FE(t.name);e.actions[n]={reset:t.configKey},e.variables[RE(t.name)]={kind:`input`,path:`resettable.${t.name}`,type:`boolean`,default:!1};let r=`{{ if .${RE(t.name)} }} {{ action "${n}" "↺" }}{{ end }}`;Object.assign(e.variables,t.control.variables),e.segments[NE(t.name)]={template:`${t.control.template}${r}`},t.control.kind===`picker`&&(e.segments[IE(t.name)]={template:t.control.list.template}),t.beneath.forEach((n,r)=>{e.segments[LE(t.name,r)]=n})}Object.assign(e.actions,WE.actions)}function _D(e){let{variables:t,actions:n}=ux();Object.assign(e.variables,t),Object.assign(e.actions,n)}function vD(e){let t=mD(e.globals.menuGlyph??`🍫`);_D(t);let n={...e.presets},r=[];for(let t of Nb(e.presets)){let{node:i}=Ib(e,t),a=lD(iD(i));r.push(a),n[t]={...Fb(e.presets,t),root:a}}let i=lw(t,r,e);return{...e,variables:{...i,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:n}}const yD=`${Cp}live`,bD=[`☐ live`,`☑ live`],xD=`${Cp}done`,SD=`${Cp}cancel`,CD=`${Cp}rewind`,wD=`${Cp}changes`,TD=`(gt .${wD} 0)`,ED=`(or ${TD} (gt .${qE} 0))`,DD={variable:yD,key:yD,member:`open`};function OD(e){return`${Cp}configuring.p${e}`}function kD(e){return`and ${qd(ax)} (not ${qd(DD)}) (ne .${OD(e)} "true")`}function AD(e){return{kind:`template`,template:`{{ or ${e.map(e=>`(eq .${Qb} "${Wd(e)}")`).join(` `)} false }}`}}function jD(e,t,n){return`{{ if ${kD(e)} }}${t}{{ else }}${n}{{ end }}`}const MD=`{{ and ${qd(ax)} .preset.customized }}`,ND=Ep;function PD(e){return new Map([...Cw(e),...ID(e)])}const FD=`${Cp}addable`;function ID(e){return new Map([[FD,{members:Object.keys(e.segments).filter(e=>!ND(e)),library:{groups:vp.map(e=>({id:e,label:yp[e]})),entry:t=>{let n=e.segments[t];return{group:n.group??`other`,...n.description!==void 0&&{description:n.description}}}}}]])}function LD(e,t,n){return n.segments[e]={template:t,when:ox,bg:qw},{kind:`segment`,name:e}}function RD(e,t,n){let r=`${Cp}${e.presetIdent}.remove.${t}`;return e.artifacts.actions[r]={persist:e.rootKey,removeSegment:n},`{{ fg (${`readableOn (color "error") (bgOf) ${tc}`}) (action "${r}" "✖") }}`}function zD(e){return`{{ if ${qd(ax)} }}${e}{{ end }}`}function BD(e,t){return e.reduce((e,t)=>`{{ if and ${qd(ax)} ${qd(t)} }}true{{ else }}${e}{{ end }}`,t)}function VD(e){return e.flatMap(e=>[...wu(e)].flatMap(e=>e.kind===`segment`&&e.opens?.ref.key===`edit.configure`?[e.opens.ref]:[]))}function HD(e,t,n){return`${rx}${e}.${t}.${n}`}function UD(e,t,n,r){let i=bu(n),a=`${Cp}${e.presetIdent}`,o=ix(e.presetIdent,i);e.configured.push(o);let s=`${a}.configure.${t}`,c=wb(s),l=`${s}.fold`;e.artifacts.actions[l]={set:c,to:Bd},e.artifacts.actions[s]={do:[`${s}.open`,l]},e.artifacts.actions[`${s}.open`]={set:Qb,to:o};let u={},d=Object.entries(r).map(([r,o])=>{let s=HD(e.presetIdent,i,r),l=`${rx}p${e.presetIdent}.d${t}.${r}`;e.artifacts.variables[l]={kind:`state`,key:s,default:Vu(n.settings?.[r]??o.default)},u[r]={id:i,key:s,variable:l};let d=`${a}.setting.${t}.${r}`,f=Mw(Aw(o),s,l,d,c);if(Object.assign(e.artifacts.actions,f.actions),Object.assign(e.artifacts.variables,f.variables),f.kind===`inline`)return e.artifacts.segments[d]={template:f.template},{kind:`segment`,name:d};let p=`${d}.list`;return e.artifacts.segments[d]={template:f.template},e.artifacts.segments[p]={template:f.list.template},Gd(d,f.list.ref,{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:p}]},`drop`)});return{term:`{{ action "${s}" "⚙️" }}`,ref:{variable:Qb,key:Qb,member:o},body:{kind:`container`,direction:`vertical`,children:d},drafts:u}}const WD=`${Cp}label:`;function GD(e){if(e.startsWith(WD)){let t=e.slice(WD.length);return t.slice(t.indexOf(`:`)+1)}return e.startsWith(`edit.`)?void 0:e}function KD(e,t,n,r){let{artifacts:i}=n,a=bu(e),o=`${WD}${a}:${e.name}`;i.segments[o]={template:`{{ "${Wd(a)}" }}`,...t.palette!==void 0&&{palette:t.palette}};let s=Object.fromEntries(Iu.flatMap(t=>{let n=e.settings?.[t];return n===void 0?[]:[[t,n]]}));return{...Gd(o,r.ref,r.body,`drop`,BD([r.ref],`{{ ${kD(n.presetIdent)} }}`)),...Object.keys(s).length>0&&{settings:s},drafts:Object.fromEntries(Iu.map(e=>[e,r.drafts[e]]))}}function qD(e,t,n,r){let{presetIdent:i,artifacts:a}=e,o=`${Cp}${i}.insert.${t}`,s=`${Cp}${i}.insertSeg.${t}`;a.actions[o]={persist:e.rootKey,insertSegmentFrom:FD,anchor:n,relation:r};let c=Sb(o),l=Cb(s,o,void 0),u=Eb(l),d=Tb(l,c);return a.variables[l]=Zd(l,Bd),a.variables[u]={kind:`state`,key:u,default:`0`},a.actions[d]=Qd(l,c),a.actions[u]={set:u,int:!0},{host:s,template:`{{ $m := menu "${o}" "✚" "✕" }}{{ if ${qd({variable:l,key:l,member:c})} }}{{ $m }}{{ else }}{{ fg (${`readableOn (color "success") (bgOf) ${tc}`}) $m }}{{ end }}`}}function JD(e,t){let n=[],r=e.children.findIndex(e=>e.kind===`segment`&&!ND(e.name)),i=e=>JD(e,t);for(let[a,o]of e.children.entries()){if(o.kind===`container`){n.push(i(o));continue}let s=Cu(o,i);if(ND(o.name)){n.push(s);continue}let c=bu(o),l=a===r?[qD(t,String(t.posCounter.n++),c,`before`)]:[],u=String(t.posCounter.n++),d=qD(t,u,c,`after`),f=RD(t,u,c),p=t.segments[o.name],m=UD(t,u,o,Lu(p)),h=zD(f),g=zD(m.term),_={kind:`container`,direction:`horizontal`,children:[...l.map(e=>LD(e.host,e.template,t.artifacts)),{...KD(o,p,t,m),lead:h,trail:g},{...s,when:jD(t.presetIdent,`false`,o.when??`true`),lead:h,trail:g,drafts:m.drafts},LD(d.host,d.template,t.artifacts)]};n.push(e.direction===`vertical`?{kind:`container`,direction:`horizontal`,children:[_]}:_)}return{...e,children:n,...e.when!==void 0&&{when:BD(VD(n),jD(t.presetIdent,`true`,e.when))}}}function YD(e,t,n,r,i,a,o){let s=`${Cp}${t}.resetLayout`,c=`${Cp}${t}.customized`;return r.actions[s]={reset:n},r.segments[c]={template:`{{ action "${s}" "↺ reset layout" }}`,when:MD},{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[...i,{kind:`segment`,name:c},a]},XD(e,o)]}}function XD(e,t){if(e.kind===`segment`)return{kind:`container`,direction:`horizontal`,children:[e,t]};let n=e.children.at(-1);return e.direction===`vertical`&&n!==void 0&&(n.kind===`segment`||n.when===void 0)?{...e,children:[...e.children.slice(0,-1),XD(n,t)]}:{...e,children:[...e.children,t]}}function ZD(e,t,n,r,i,a){let{node:o}=Ib(e,t),s={presetIdent:bp(t),rootKey:Rw(t),segments:e.segments,artifacts:n,posCounter:{n:0},configured:[]},c=JD(o,s);return n.variables[OD(s.presetIdent)]=AD(s.configured),YD(c,s.presetIdent,s.rootKey,n,r,i,a)}function QD(e){let t={variables:{},actions:{},segments:{}},n=Gw(`${Cp}help`,eT,[ax],t);t.variables[yD]=Zd(yD,Bd),t.actions[yD]=Qd(yD,DD.member),t.segments[yD]={template:Jd(yD,...bD),when:ox};let r={kind:`segment`,name:yD},i=n;t.variables[wD]={kind:`input`,path:`history.sinceEdit`,type:`number`,default:0},t.actions[xD]={do:[cE,...tx]},t.segments[xD]={template:`{{ if ${ED} }}{{ action "${xD}" "✓ save" }}{{ else }}{{ action "${xD}" "✓ done" }}{{ end }}`,when:ox},t.actions[CD]={rewind:!0},t.actions[SD]={do:[CD,...tx]},t.segments[SD]={template:`{{ action "${SD}" "↩ cancel" }}`,when:`{{ and ${qd(ax)} ${TD} }}`};let a=[{kind:`segment`,name:xD},{kind:`segment`,name:SD}],o={...e.presets},s=[];for(let n of Nb(e.presets)){let c=ZD(e,n,t,a,r,i);s.push(c),o[n]={...Fb(e.presets,n),root:c}}let c=lw(t,s,e);return{...e,variables:{...c,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:o}}const $D=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`themeDefault`,`doctor`,`ceiling`,`slash`,`do`];function eO(e){return e.ceiling===`set`?[`set`,e.to]:[`clear`]}function tO(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function nO(e,t){if(t===void 0)return{};if(!Qu(t))return Q(e,`actions`,`actions must be an object, got ${$u(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=rO(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function Q(e,t,n){e.issues.push({path:t,message:n,line:G(e.source,t.split(`.`))})}function rO(e,t,n){if(!Qu(n))return Q(e,t,`${t} must be an action object, got ${$u(n)}`),null;if(`persistWhen`in n)return Q(e,t,`${t}.persistWhen was removed: declare the \`set\` alone — a session pick is a draft until a \`{ save: true }\` action writes every unsaved setting to the config file`),null;let r=$D.filter(e=>e in n);return r.length===1?iO[r[0]](e,t,n):(Q(e,t,`action must declare exactly one of: ${$D.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const iO={set:(e,t,n)=>LO(e,t,n,`set`,NO),persist:(e,t,n)=>LO(e,t,n,`persist`,PO),copy:aO(`copy`),open:aO(`open`),reset:oO,undo:cO(`undo`),redo:cO(`redo`),back:cO(`back`),rewind:cO(`rewind`),save:cO(`save`),preset:lO,themeDefault:uO,doctor:dO,ceiling:fO,slash:pO,do:mO};function aO(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Q(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=qu(t,n,r,e);return i===null?null:{[e]:i}}}function oO(e,t,n){for(let r of Object.keys(n))r!==`reset`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=hO(e,t,`reset`,n,`reset key must be non-empty (the config globals field to clear)`,e=>`reset key "${e}" contains "/" — keys must be slash-free`);return r===null?null:{reset:r}}const sO={undo:`it steps the session's settings history`,redo:`it steps the session's settings history`,back:`it steps the session's navigation history`,rewind:`it steps the session's settings history back to where edit mode opened`,save:`it saves the session's unsaved settings`};function cO(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Q(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(Q(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — ${sO[e]}), got ${K(r[e])}`),null)}}function lO(e,t,n){let r=n.preset,i=r===`save`?[`preset`]:[`preset`,`name`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a preset action. Expected only: ${i.join(`, `)}`);if(r!==`save`&&r!==`delete`)return Q(e,`${t}.preset`,`preset must be "save" or "delete", got ${K(r)}`),null;if(r===`save`)return{preset:`save`};let a=qu(e,t,n,`name`);return a===null?null:{preset:`delete`,name:a}}function uO(e,t,n){for(let r of Object.keys(n))r!==`themeDefault`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a themeDefault action. Expected only: themeDefault`);return n.themeDefault===`save`?{themeDefault:`save`}:(Q(e,`${t}.themeDefault`,`themeDefault must be "save" (it saves the look the session draws as the active theme's default), got ${K(n.themeDefault)}`),null)}function dO(e,t,n){let r=n.doctor,i=r===`run`?[`doctor`]:[`doctor`,`check`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${i.join(`, `)}`);if(r!==`run`&&r!==`fix`)return Q(e,`${t}.doctor`,`doctor must be "run" or "fix", got ${K(r)}`),null;if(r===`run`)return{doctor:`run`};let a=n.check;return typeof a!=`string`||mT(a)===void 0?(Q(e,`${t}.check`,`doctor fix must name a check (have: ${fT.map(e=>e.name).join(`, `)}), got ${K(a)}`),null):{doctor:`fix`,check:a}}function fO(e,t,n){let r=n.ceiling,i=r===`clear`?[`ceiling`]:[`ceiling`,`to`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a ceiling action. Expected only: ${i.join(`, `)}`);if(r===`clear`)return{ceiling:`clear`};if(r!==`set`)return Q(e,`${t}.ceiling`,`ceiling must be "set" or "clear", got ${K(r)}`),null;let a=n.to;return typeof a!=`string`||a.trim()===``?(Q(e,`${t}.to`,`ceiling set needs \`to\`: a memento ceiling value such as "+100_000", "400000" or "off", got ${K(a)}`),null):{ceiling:`set`,to:a}}function pO(e,t,n){for(let r of Object.keys(n))r!==`slash`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a slash action. Expected only: slash`);let r=DT(n.slash);return r.kind===`refused`?(Q(e,`${t}.slash`,r.reason),null):{slash:r.line}}function mO(e,t,n){for(let r of Object.keys(n))r!==`do`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a do action. Expected only: do`);let r=n.do;return!Array.isArray(r)||r.length<2||r.some(e=>typeof e!=`string`||e===``)?(Q(e,`${t}.do`,`do must list at least two action names (the first is the click's face, the rest ride along in the same click), got ${K(r)}`),null):{do:r}}function hO(e,t,n,r,i,a){let o=qu(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(Q(e,s,i),null):o.includes(`/`)?(Q(e,s,a(o)),null):o}const gO={set:`the SessionState key to write`,persist:`the config globals field to write`};function _O(e,t,n,r){let i=gO[r],a=hO(e,t,r,n,`${r} key must be non-empty (${i})`,e=>`${r} key "${e}" contains "/" — keys must be slash-free`);return a===null?null:{[r]:a}}function vO(e){return e===`set`?`set-state`:`set-config`}const yO={to:RO(`set`)},bO={to:RO(`persist`)},xO={from:zO(`set`)},SO={from:zO(`persist`)},CO={min:WO(),max:WO(),by:WO()},wO={int:VO()},TO={cycle:BO(`set`)},EO={cycle:BO(`persist`)},DO={removeSegment:HO(`removeSegment`)},OO={insertSegment:HO(`insertSegment`),anchor:HO(`anchor`),relation:UO()},kO={insertSegmentFrom:zO(`persist`),anchor:HO(`anchor`),relation:UO()},AO={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},jO={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function MO(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=[e],s=(e,n,r)=>nd(e,t,n,r),c=bd(t);return{detect:a,allowed:[...o,...i],label:i.join(`/`),json:{type:`object`,properties:{...Object.fromEntries(o.map(e=>[e,{type:`string`}])),...c.properties},required:[...o,...c.required??[]],additionalProperties:!1},parse:n.length?ud(s,...n):s}}const NO=[MO(`set`,yO),MO(`set`,xO),MO(`set`,CO,[AO,jO]),MO(`set`,wO),MO(`set`,TO)],PO=[MO(`persist`,bO),MO(`persist`,SO),MO(`persist`,CO,[AO,jO]),MO(`persist`,EO),MO(`persist`,DO),MO(`persist`,OO,[],[`insertSegment`]),MO(`persist`,kO,[],[`insertSegmentFrom`])];function FO(e){let t=[`"to" (a literal value)`,`"from" (an option domain — a registered domain name like "themes"/"endcaps"/"styles", or an inline array of literal values)`,`"min"/"max"/"by" (a bounded step)`];return e===`set`&&t.push(`"int" (an unbounded integer cursor)`),t.push(`"cycle" (an enumerated domain stepped in order)`),e===`persist`&&t.push(`"removeSegment" (remove a named segment from the layout)`,`"insertSegment"/"anchor"/"relation" (insert a named segment before/after an existing one)`,`"insertSegmentFrom"/"anchor"/"relation" (insert a segment PICKED from an option domain before/after an existing one)`),t}function IO(e){let t=FO(e),n=t[t.length-1];return`a ${e} action declares exactly one value source: ${t.length===1?n:`${t.slice(0,-1).join(`, `)}, or ${n}`}`}function LO(e,t,n,r,i){let a=_O(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return Q(e,t,`${IO(r)}${o.length>1?` — found: ${o.map(e=>e.label).join(`, `)}`:``}`),null;let s=o[0];for(let i of Object.keys(n))s.allowed.includes(i)||Q(e,`${t}.${i}`,`Unknown key "${i}" on this ${r} action. Expected one of: ${s.allowed.join(`, `)}`);let c=s.parse(e,t,n);return a===null||c===null?null:{...a,...c}}function RO(e){let t=vO(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>hO(n,r,i,a,`${e} value must be non-empty — an empty value cannot be delivered on the ${t} wire`,t=>`${e} value "${t}" contains "/" — ${e} values must be slash-free`)??void 0}}function zO(e){let t=vO(e);return{required:!0,json:{anyOf:[{type:`string`,minLength:1},{type:`array`,items:{type:`string`,minLength:1},minItems:1,uniqueItems:!0}]},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(typeof o==`string`){if(o===``){Q(n,s,`${i} must be a non-empty domain name`);return}return o}if(Array.isArray(o)&&o.every(e=>typeof e==`string`)){let r=o;if(r.length===0){Q(n,s,`${i} must name a domain (a non-empty string) or declare an inline domain (a non-empty array of values)`);return}if(r.some(e=>e===``)){Q(n,s,`${i} array members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}let a=r.filter(e=>e.includes(`/`));if(a.length>0){Q(n,s,`${i} array member(s) ${a.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(r).size!==r.length){Q(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}Q(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${K(o)}`)}}}function BO(e){let t=vO(e);return{required:!0,json:{type:`array`,items:{type:`string`,minLength:1},minItems:2,uniqueItems:!0},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(!Array.isArray(o)||o.some(e=>typeof e!=`string`)){Q(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${$u(o)}`);return}let c=o;if(c.length<2){Q(n,s,`cycle needs at least two members (one member has no successor — use a literal "to")`);return}let l=c.some(e=>e===``),u=c.filter(e=>e.includes(`/`));if(l){Q(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){Q(n,s,`cycle member(s) ${u.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(c).size!==c.length){Q(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function VO(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){Q(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${K(r[n])}`);return}return!0}}}function HO(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=qu(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){Q(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){Q(t,o,`${e} "${a}" contains "/" or ":" — segment names in a layout op must be free of both (the click wire's own delimiter and layout-ops.ts's op-token delimiter)`);return}return a}}}function UO(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){Q(e,`${t}.${n}`,`relation must be "before" or "after", got ${K(i)}`);return}return i}}}function WO(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){Q(e,`${t}.${n}`,`${n} must be an integer, got ${K(i)}`);return}return i}}}function GO(e,t,n){return`${e}: "${t}" is an endcaps shape, not a style — endcaps were renamed from "style" to "endcaps"; write ${n}: "${t}"`}const KO={noun:`style key`,fields:{hueShift:md(),chromaScale:md({min:0}),lightnessScale:md(),lightnessShift:md()}};function qO(e,t){if(!Qu(t))return e.issues.push({path:`styles`,message:`styles must be an object mapping style names to adaptation objects, got ${$u(t)}`,line:G(e.source,[`styles`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)){e.issues.push({path:`styles.${r}`,message:`style name ${JSON.stringify(r)} must be non-empty and slash-free — a style picker writes the name on the set-state wire, which rejects empty values and splits on "/"`,line:G(e.source,[`styles`,r])});continue}if($c(r)){e.issues.push({path:`styles.${r}`,message:GO(`styles.${r}`,r,`globals.endcaps`),line:G(e.source,[`styles`,r])});continue}let t=ed(e,KO,`styles.${r}`,i);t!==null&&(n[r]={...sr,...t})}return n}const JO={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:_m(e,`${t}.${n}`,r[n])},globals:{required:!1,json:Of(),parse:(e,t,n,r)=>r[n]===void 0?void 0:Df(e,`${t}.${n}`,r[n])}}};function YO(e,t){if(!Qu(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${$u(t)}`,line:G(e.source,[`presets`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)||/[\n\r]/.test(r)){e.issues.push({path:`presets.${r}`,message:`preset name ${JSON.stringify(r)} must be non-empty, slash-free, and newline-free — a preset picker writes the name on the set-state wire (which rejects empty values and splits on "/"), and edit mode splices it into a synthesized template string`,line:G(e.source,[`presets`,r])});continue}let t=ed(e,JO,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function XO(e,t){if(t===void 0)return{};if(!Qu(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${$u(t)}`,line:G(e.source,[`helpers`])}),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){if(typeof i!=`string`){e.issues.push({path:`helpers.${r}`,message:`helpers.${r} must be a string template body, got ${K(i)}`,line:G(e.source,[`helpers`,r])});continue}n[r]=i}return n}const ZO=new Map([[`session.budget.amount`,{segment:`session`,setting:`budget`}],[`session.budget.warningThreshold`,{segment:`session`,setting:`warnAt`}],[`today.budget.amount`,{segment:`today`,setting:`budget`}],[`today.budget.warningThreshold`,{segment:`today`,setting:`warnAt`}],[`block.budget.heatThreshold`,{segment:`block`,setting:`warnAt`}],[`block.budget.warningThreshold`,{segment:`block`,setting:`errorAt`}],[`weekly.budget.heatThreshold`,{segment:`weekly`,setting:`warnAt`}],[`weekly.budget.warningThreshold`,{segment:`weekly`,setting:`errorAt`}],[`burn.eta.errorMinutes`,{segment:`burnrate`,setting:`errorWithin`}],[`burn.eta.warnMinutes`,{segment:`burnrate`,setting:`warnWithin`}]]);function QO(e){return`it became the "${e.setting}" setting of each "${e.segment}" placement — set it on the placement where a row places "${e.segment}" ({ seg: "${e.segment}", settings: { ${e.setting}: <value> } }), or redeclare segments.${e.segment}.settings.${e.setting} with the default every placement should start from`}function $O(e){let t=ZO.get(e);return t===void 0?void 0:`variables.${e} is no longer read: ${QO(t)}`}function ek(e){let t=ZO.get(e);return t===void 0?``:` — ".${e}" is no longer a variable: ${QO(t)}; a "${t.segment}" template reads it as ".settings.${t.setting}"`}function tk(e,t){let n=new Map;for(let e of Object.keys(t)){let t=bp(e),r=n.get(t);r?r.push(e):n.set(t,[e])}for(let[t,r]of n)r.length<2||e.issues.push({path:`presets`,message:`preset names ${r.map(e=>JSON.stringify(e)).join(` and `)} both collapse to the same synthesis identifier "${t}" — edit mode's synthesized reset affordance would silently steal one preset's action for the other. Rename one.`,line:G(e.source,[`presets`])})}function nk(e,t,n){let r=[[[`globals`],t.globals.style,`globals.endcaps`],[[`editGlobals`],t.editGlobals.style,`editGlobals.endcaps`],...Object.entries(t.presets).map(([e,t])=>[[`presets`,e,`globals`],t.globals?.style,`presets.${e}.globals.endcaps`]),...Object.entries(t.themeDefaults).map(([e,t])=>[[`themeDefaults`,e],t.style,`globals.endcaps`])];for(let[n,i,a]of r){if(i===void 0||Lc(i)||Object.prototype.hasOwnProperty.call(t.styles,i))continue;let r=`${n.join(`.`)}.style`;e.issues.push({path:r,message:$c(i)?GO(r,i,a):`${r} "${i}" does not match any declared style (have: ${Object.keys(t.styles).join(`, `)})`,line:G(e.source,[...n,`style`])})}t.globals.preset!==void 0&&!Object.prototype.hasOwnProperty.call(t.presets,t.globals.preset)&&e.issues.push({path:`globals.preset`,message:`globals.preset "${t.globals.preset}" does not match any declared preset (have: ${Object.keys(t.presets).join(`, `)})`,line:G(e.source,[`globals`,`preset`])}),tk(e,t.presets),Tk(e,t);let i=jx(t);for(let t of i.names)t!==`settings`&&!t.startsWith(ak)||e.issues.push({path:`variables`,message:`variable "${t}" is named under "settings", which a segment's templates read as its placement's own settings (.settings.<name>) — rename it`,line:G(e.source,[`variables`,t])});let a=(t,n,r)=>{aD(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${qT}" ${aD(t)} times — it may appear at most once per layout (it is one disclosure, and one state key holds one open state). Remove all but the placement you want; removing every placement puts the menu at its default position.`,line:r}),oD(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${qT}" under a \`when\` or inside a disclosure body — the menu is visible under every condition, so its placement may not be gated. Move it to an ungated position, or remove it to put the menu at its default position.`,line:r}),o(t)&&e.issues.push({path:n,message:`${n} sets "distribution" on a container inside a bar cell — everything inside a cell wears that cell's hue and shade, so it would place nothing. Set it on the row whose children are the cells (the horizontal container) or on the root, which places the rows.`,line:r});let i=new Map;for(let e of wu(t)){if(e.kind!==`segment`)continue;let t=bu(e);i.set(t,[...i.get(t)??[],e])}for(let[t,a]of i){if(a.length<2)continue;let o=a[1].name,s=Su(o,new Set(i.keys()));e.issues.push({path:n,message:`${n} has ${a.length} placements with the id "${t}" — an id names one placement (its settings, its menus' open state, and edit mode all address it), so give each its own: { seg: "${o}", id: "${s}" }. A placement without an "id" takes its segment's name.`,line:r})}};function o(e,t=!1){return e.kind===`segment`?!1:t&&e.distribution!==void 0||e.children.some(n=>o(n,t||yu[e.direction]===`cell`))}let s=(n,r)=>{for(let[a,o]of Nd(n,r)){let n=G(e.source,o.split(`.`));if(a.when!==void 0&&(_k(e,`${o}.when`,a.when,i,{line:n}),gk(e,`${o}.when`,a.when,n)),a.kind===`segment`){if(nD(a.name)){(a.id!==void 0||a.settings!==void 0)&&e.issues.push({path:o,message:`${r} gives the global settings menu anchor "${qT}" an id or settings — the anchor only marks where the menu goes, so place it as the bare name "${qT}"`,line:n});continue}Object.prototype.hasOwnProperty.call(t.segments,a.name)||e.issues.push({path:o,message:`${r} entry "${a.name}" does not match any declared segment${Ap(a.name)}`,line:n}),pk(e,t,a,o,n)}}};n.root!==void 0&&s(n.root,`root`);for(let[e,t]of Object.entries(n.presets??{}))t.root!==void 0&&s(t.root,`presets.${e}.root`);let c=new Map([[`root`,jd(t.root)]]);for(let e of Nb(t.presets)){let{node:n,path:r}=Ib(t,e);c.set(r,n)}for(let[t,n]of c)a(n,t,G(e.source,t.split(`.`)));wk(e,t,i,()=>!0)}const rk=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function ik(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=G(e.source,[`actions`,n,r]);if(!Nb(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${Nb(t.presets).join(`, `)})`,line:c});return}if(r===`reset`)return;let l=`removeSegment`in o,u=`insertSegment`in o,d=`insertSegmentFrom`in o;if(!l&&!u&&!d){e.issues.push({path:s,message:`actions.${n}: "${i}" is a "presets.<name>.root" target and can only be paired with "removeSegment", "insertSegment", or "insertSegmentFrom" (not "to"/"from"/"cycle"/bounded — those have no meaning as a tree op)`,line:c});return}let f=(r,i)=>{Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})${Ap(i)}`,line:c})},p=new Set(xu(Ib(t,a).node)),m=(r,i)=>{!kp.has(i)||p.has(i)||Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" names no placement${Ap(i)}`,line:c})};`removeSegment`in o&&m(`removeSegment`,o.removeSegment),`insertSegment`in o&&f(`insertSegment`,o.insertSegment),(`insertSegment`in o||`insertSegmentFrom`in o)&&m(`anchor`,o.anchor)}const ak=`settings.`;function ok(e,t){return{...e,names:new Set([...e.names,...Object.keys(t).map(e=>ak+e)])}}function sk(e,t,n){let r=e=>`segments.${t}.settings.${e}`,i=(n,i)=>{e.issues.push({path:r(n),message:`${r(n)}: ${i}`,line:G(e.source,[`segments`,t,`settings`,n])})},a=uk(n);for(let{setting:e,message:t}of a)i(e,t);if(!(a.length>0))for(let{setting:e,message:t}of zu(n,lk(n)))i(e,`the defaults do not stand together: ${t}`)}function ck(e){return uk(e).length>0||zu(e,lk(e)).length>0}function lk(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default]))}function uk(e){let t=t=>Ru(dk(e,t))?.atLeast;return Object.keys(e).flatMap(n=>{let r=t(n);if(r===void 0)return[];if(r===n||Ru(dk(e,r))===void 0)return[{setting:n,message:`atLeast "${r}" must name another range setting of this segment (its range settings: ${fk(e,n).join(`, `)||`none`})`}];let i=[n];for(let e=r;e!==void 0;e=t(e)){if(e===n)return i.every(e=>n<=e)?[{setting:n,message:`atLeast closes a cycle (${[...i,n].join(` ≥ `)}) — every setting on it could only ever equal the rest`}]:[];if(i.includes(e))return[];i.push(e)}return[]})}function dk(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function fk(e,t){return Object.entries(e).filter(([e,n])=>e!==t&&Ru(n)!==void 0).map(([e])=>e)}function pk(e,t,n,r,i){let a=Object.prototype.hasOwnProperty.call(t.segments,n.name)?t.segments[n.name]:void 0;if(a===void 0)return;let o=Lu(a),s=`${r}: placement "${bu(n)}" of segment "${n.name}"`;for(let[t,a]of Object.entries(n.settings??{})){let c=Object.prototype.hasOwnProperty.call(o,t)?o[t]:void 0,l=c===void 0?`sets "${t}", which segment "${n.name}" does not declare (it has: ${Object.keys(o).join(`, `)})`:Bu(c,a)?void 0:`sets "${t}" to ${JSON.stringify(a)}${c.domain===`theme`?Oc(a):``}, but it must be ${Wu(c)}`;l!==void 0&&e.issues.push({path:r,message:`${s} ${l}`,line:i})}let c=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,n.settings?.[e]??t.default]));if(!(!Object.entries(c).every(([e,t])=>Bu(o[e],t))||ck(o)))for(let{message:t}of zu(o,c))e.issues.push({path:r,message:`${s}: ${t}`,line:i})}function mk(e,t,n,r,i){n.kind===`template`&&_k(e,`${t}.template`,n.template,r,{segCtx:i}),Mu(n)&&n.cache&&`key`in n.cache&&_k(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function hk(e,t,n,r,i){if(Mu(n)&&n.cache&&`depends_on`in n.cache)for(let a=0;a<n.cache.depends_on.length;a++){let o=n.cache.depends_on[a];if(r.names.has(o))continue;let s=i===void 0?void 0:`${i}.${o}`,c=s!==void 0&&r.names.has(s)?` (segment-local vars are namespaced — write "${s}")`:``;e.issues.push({path:`${t}.cache.depends_on[${a}]`,message:`cache.depends_on references unknown variable "${o}"${c}`,line:G(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function gk(e,t,n,r){try{Xb.parse(n)}catch(n){e.issues.push({path:t,message:`Template parse error in ${t}: ${n.message}`,line:r})}}function _k(e,t,n,r,i){for(let[a,o]of Cx(n,r.helpers)){if(Ax(a,r))continue;if(a.startsWith(ak)){let n=o===null?``:` through helper "${o}"`,r=a.slice(9),s=i?.segCtx===void 0||i.settings===void 0?`Template reads ".${a}"${n}, but only a segment's own templates have settings — call it from a segment that declares "${r}"`:`Template reads ".${a}"${n}, but segment "${i.segCtx}" has no setting "${r}" (it has: ${Object.keys(i.settings).join(`, `)}) — declare it under segments.${i.segCtx}.settings`;e.issues.push({path:t,message:s,line:i?.line??G(e.source,t.split(`.`))});continue}if(o!==null){vk(e,o,`Template references unknown variable ".${a}"${ek(a)}`);continue}let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,s=n!==void 0&&Ax(n,r)?` (segment-local vars are namespaced — write ".${n}")`:ek(a);e.issues.push({path:t,message:`Template references unknown variable ".${a}"${s}`,line:i?.line??G(e.source,t.split(`.`))})}}function vk(e,t,n){let r=`helpers.${t}`;e.issues.some(e=>e.path===r&&e.message===n)||e.issues.push({path:r,message:n,line:G(e.source,[`helpers`,t])})}function yk(e,t,n,r,i){let a=n.set,o=ff(ew[r].configKey),s=`${a} takes ${kw(o,i)}`;if(`min`in n&&(o===`bool`||`from`in o)){e.issues.push({path:`actions.${t}.min`,message:`actions.${t}: a stepper writes the integers from ${n.min} to ${n.max}, and ${a} is not an integer range; ${s}`,line:G(e.source,[`actions`,t,`min`])});return}let c=Sk(n,i);if(c===xk){e.issues.push({path:`actions.${t}.int`,message:`actions.${t}.int: an int cursor writes whatever integer the template binds, and a click outside the ${a} domain would change nothing; ${s}`,line:G(e.source,[`actions`,t,`int`])});return}let l=c.filter(e=>!Ow(o,e.value,i));if(l.length!==0){if(a===ew.style.sessionKey&&(`from`in n&&n.from===`endcaps`||c.every(e=>$c(e.value)))){let r=ew.endcaps.sessionKey;e.issues.push(`to`in n?{path:`actions.${t}.to`,message:GO(`actions.${t}.to`,n.to,`set: "${r}", to`),line:G(e.source,[`actions`,t,`to`])}:{path:`actions.${t}.set`,message:`actions.${t}.set: "${a}" here writes only endcaps shapes, not styles — endcaps were renamed from "style" to "endcaps"; write set: "${r}"`,line:G(e.source,[`actions`,t,`set`])});return}for(let n of new Set(l.map(e=>e.field))){let r=l.filter(e=>e.field===n).map(e=>JSON.stringify(e.value)),i=r.length<=bk?r.join(`, `):`${r.slice(0,bk).join(`, `)} and ${r.length-bk} more`,o=`actions.${t}.${n}`;e.issues.push({path:o,message:`${o}: ${i} ${r.length===1?`is`:`are`} outside the ${a} domain — a click would write it and nothing would change; ${s}`,line:G(e.source,[`actions`,t,n])})}}}const bk=3,xk=Symbol(`any integer`);function Sk(e,t){return`to`in e?[{field:`to`,value:e.to}]:`cycle`in e?e.cycle.map(e=>({field:`cycle`,value:e})):`from`in e?Tw(e.from,t).members.map(e=>({field:`from`,value:e})):`min`in e?[{field:`min`,value:String(e.min)},{field:`max`,value:String(e.max)}]:xk}function Ck(e,t){return Object.entries(e).filter(([e])=>t(e))}function wk(e,t,n,r){let i=PD(t),a=ww(i);for(let[n,o]of Ck(t.actions,r)){let[t,r]=`from`in o?[`from`,o.from]:`insertSegmentFrom`in o?[`insertSegmentFrom`,o.insertSegmentFrom]:[null,null];if(t!==null&&typeof r==`string`&&!a.includes(r)){e.issues.push({path:`actions.${n}.${t}`,message:`actions.${n} ${t}: references ${Dw(r,i)}`,line:G(e.source,[`actions`,n,t])});continue}if(!(`set`in o))continue;rw.has(o.set)&&e.issues.push({path:`actions.${n}.set`,message:`actions.${n} sets "${o.set}", which has no session pick — globals.${o.set} is set in the config file only, so a click would change nothing; write it with { persist: "${o.set}", … } instead`,line:G(e.source,[`actions`,n,`set`])});let s=sw.get(o.set);s!==void 0&&yk(e,n,o,s,i)}for(let[n,i]of Ck(t.actions,r))`do`in i&&i.do.forEach((r,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,r)?t.actions[r]:void 0,s=o===void 0?`references unknown action "${r}"`:`do`in o?`"${r}" is itself a do action — list its members here instead`:i.do.indexOf(r)===a?a>0&&tO(o)?`"${r}" takes its value from the template (from/int/insertSegmentFrom), so it can only be the first member — only the first is bound the region's display`:void 0:`"${r}" is listed twice — each member fires once per click`;s!==void 0&&e.issues.push({path:`actions.${n}.do`,message:`actions.${n} do: ${s}`,line:G(e.source,[`actions`,n,`do`])})});for(let[n,i]of Ck(t.actions,r)){let r=`persist`in i?i.persist:`reset`in i?i.reset:null;if(r===null)continue;let a=`persist`in i?`persist`:`reset`,o=Hw(r);if(o===null){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is not a config globals field (have: ${Mf().join(`, `)}), a "segments.<name>.palette" target, a "presets.<name>.globals.<field>" target, a "themeDefaults.<theme>.<shade|variation|style>" target, or a "presets.<name>.root" target`,line:G(e.source,[`actions`,n,a])});continue}let s=rk.filter(e=>e in i);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:G(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){ik(e,t,n,a,r,o.preset,i);continue}if(o.scope===`preset-globals`&&!Nb(t.presets).includes(o.preset)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names preset "${o.preset}" which is not declared (have: ${Nb(t.presets).join(`, `)})`,line:G(e.source,[`actions`,n,a])});continue}if(o.scope===`theme-default`&&!e.allowedPalettes.has(o.theme)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names theme "${o.theme}" which is not installed${Oc(o.theme)} (have: ${[...e.allowedPalettes].sort().join(`, `)})`,line:G(e.source,[`actions`,n,a])});continue}if(o.scope===`segment-palette`){if(!Object.prototype.hasOwnProperty.call(t.segments,o.segment)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})${Ap(o.segment)}`,line:G(e.source,[`actions`,n,a])});continue}`min`in i&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:G(e.source,[`actions`,n,a])})}}for(let[i,a]of Ck(t.variables,r)){mk(e,`variables.${i}`,a,n);let t=$O(i);t!==void 0&&e.issues.push({path:`variables.${i}`,message:t,line:G(e.source,[`variables`,i])})}for(let[i,a]of Ck(t.segments,r)){if(a.vars)for(let[t,r]of Object.entries(a.vars))mk(e,`segments.${i}.vars.${t}`,r,n,i);let r=Lu(a);sk(e,i,r);let o=ok(n,r);for(let n of[`template`,`bg`,`fg`,`when`]){let s=a[n];if(typeof s==`string`){_k(e,`segments.${i}.${n}`,s,o,{segCtx:i,settings:r});for(let{name:r,site:a,via:o}of Dx(s,t.helpers)){if(Object.prototype.hasOwnProperty.call(t.actions,r))continue;let s=a===`options`?` (in a picker, menu or carousel)`:``;if(o!==null){vk(e,o,`Template references unknown action "${r}"${s}`);continue}e.issues.push({path:`segments.${i}.${n}`,message:`${n} references unknown action "${r}"${s}`,line:G(e.source,[`segments`,i,n])})}}}}for(let[i,a]of Ck(t.variables,r))hk(e,`variables.${i}`,a,n);for(let[i,a]of Ck(t.segments,r))if(a.vars)for(let[t,r]of Object.entries(a.vars))hk(e,`segments.${i}.vars.${t}`,r,n,i)}function Tk(e,t){let n=new Set;for(let r of Nb(t.presets)){let i=Lb(t,r),a=[{},t.editGlobals];for(let o of a){let a=o.charset??i.charset??`unicode`,s=o.default_separator??i.default_separator;if(a!==`ascii`||nl(s??``))continue;let c=o.default_separator===void 0?Fb(t.presets,r).globals?.default_separator===void 0?[`globals`]:[`presets`,r,`globals`]:[`editGlobals`],l=[...c,`default_separator`].join(`.`);n.has(l)||(n.add(l),e.issues.push({path:l,message:`${l} ${JSON.stringify(s)} is not ASCII, but charset is "ascii" — under ascii a joiner draws only ASCII; write an ASCII separator or set charset: "unicode"`,line:G(e.source,[...c,`default_separator`])}))}}}function Ek(e,t,n=()=>!0){let{graph:r,nodeInfo:i}=Dk(t),a=new Map,o=[];for(let e of r.keys())a.set(e,0);for(let e of r.keys())if(!(!n(e)||a.get(e)!==0)&&s(e))return;function s(t){a.set(t,1),o.push(t);for(let c of r.get(t)??[]){if(!n(c))continue;let t=a.get(c);if(t===1){let t=o.indexOf(c),n=[...o.slice(t),c],r=n[0],a=i.get(r);return e.issues.push({path:a?.declarationPath??`variables.${r}`,message:`Dependency cycle: ${n.join(` → `)}`,line:G(e.source,a?.linePathParts??[`variables`,r])}),!0}if(t===0&&s(c))return!0}return a.set(t,2),o.pop(),!1}}function Dk(e){let t=new Set(Object.keys(e.variables)),n=new Map;for(let t of Object.keys(e.variables))n.set(t,{declarationPath:`variables.${t}`,linePathParts:[`variables`,t]});for(let[r,i]of Object.entries(e.segments))if(i.vars)for(let e of Object.keys(i.vars)){let i=`${r}.${e}`;t.add(i),n.set(i,{declarationPath:`segments.${r}.vars.${e}`,linePathParts:[`segments`,r,`vars`,e]})}let r=new Map;for(let e of t)r.set(e,new Set);let i=(n,i)=>{for(let a of Cx(i,e.helpers).keys()){if(t.has(a)){r.get(n).add(a);continue}let e=a.split(`.`)[0];e!==a&&t.has(e)&&r.get(n).add(e)}},a=(e,n)=>{if(n.kind===`template`&&i(e,n.template),Mu(n)&&(n.cache&&`key`in n.cache&&i(e,n.cache.key),n.cache&&`depends_on`in n.cache))for(let i of n.cache.depends_on)t.has(i)&&r.get(e).add(i)};for(let[t,n]of Object.entries(e.variables))a(t,n);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))a(`${t}.${e}`,r);return{graph:r,nodeInfo:n}}const Ok=[`json5`,`json`];function kk(e){try{return r.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function Ak(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?h.homedir()+e.slice(1):e}function jk(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?Ok.map(t=>l.join(e,`.cc-candybar.${t}`)):[],...Ok.map(e=>l.join(r,`.cc-candybar.${e}`)),...Ok.map(e=>`${Mk()}.${e}`)])]}function Mk(){let e=process.env.XDG_CONFIG_HOME??l.join(h.homedir(),`.config`);return l.join(e,`cc-candybar`,`config`)}function Nk(e,t,n){let i=[],a=new Map;for(let o of jk(e,t,n)){let e=kk(o);if(e===`absent`)continue;if(e!==`present`){i.push(e);continue}let t=l.join(r.realpathSync(l.dirname(o)),l.basename(o).replace(/\.(json5|json)$/,``));a.has(t)||a.set(t,o)}let o=[...a.values()].reverse();if(n===void 0)return{kind:`chain`,layers:o,home:Pk(o),unchecked:i};let[s]=i,c=n;return o.length>0?{kind:`chain`,layers:o,home:c,unchecked:i}:s===void 0?{kind:`missing`,path:n,home:c}:{kind:`unreadable`,...s,home:c}}function Pk(e){let t=Mk();return e.find(e=>Ok.some(n=>e===`${t}.${n}`))??`${t}.${Ok[0]}`}function Fk(e,t,n){let r=Nk(e,t,n),i=r.kind===`chain`?r.layers:[];return{path:r.home,above:i.filter(e=>e!==r.home),projectDir:e??null,cwd:t??null}}function Ik(e){return Lk(e).join(`
|
|
164
|
+
`).map(e=>e.trim()).filter(e=>e!==``),...e.warnings];return{ok:!1,reason:t,more:n}}case`loaded`:return aT([...e.warnings,...e.unused.map(({kind:e,name:t})=>`${e} "${t}" ${cT[e]}`)])}}},uT="re-run `cc-candybar install`";function dT(e){if(e.kind===`failed`)return[`Launch Services could not be asked which app opens cc-candybar:// — ${e.reason}`];if(e.value===null)return[`no app is registered for cc-candybar:// — ${uT}`];let{app:t,missing:n}=e.value;return n.kind===`failed`?[`${t} opens cc-candybar://, but ${n.reason} — ${uT}`]:n.value.map(e=>`${e} is missing, and ${t} runs it — ${uT}`)}const fT=[lT,{name:`urlHandler`,label:`URL handler`,probe:({urlHandler:e})=>{switch(e.kind){case`unsupported`:return{ok:!0};case`unprobed`:return{ok:!1,reason:e.reason};case`arrived`:return e.handler===e.bar?{ok:!0}:{ok:!1,reason:e.handler===null?`the URL handler does not report its version, so it is older than the bar (${e.bar}) — ${uT}`:`the URL handler runs cc-candybar ${e.handler}; the bar runs ${e.bar} — ${uT}`};case`lost`:return aT([...dT(e.opener),e.unopened===null?`a cc-candybar:// link was opened and did not arrive at the daemon`:`a cc-candybar:// link could not be opened — ${e.unopened}`])}}},sT,{name:`effectRefresh`,label:`effect refresh`,probe:({effect:e,placementEffects:t,transitions:n,claudeSettings:r})=>{let i=[...e.kind===`decided`?e.value===`none`?[]:[`the bar wears the ${e.name} effect`]:[`a globals.effect rule can give the bar an effect`],...t.map(({placement:e,effect:t})=>`${e} wears the ${t} effect`),...n?[`placements fade in and dissolve out as they come and go`]:[]];if(i.length===0)return{ok:!0};let a=i.join(` and `),{path:o,statusLine:s}=r;switch(s.kind){case`absent`:return{ok:!1,reason:`${a}, and ${o} sets no statusLine — set "refreshInterval": 1 beside the statusLine command that runs the bar`};case`not-an-object`:return{ok:!1,reason:`${a}, and ${o} sets statusLine to ${JSON.stringify(s.value)}, not a statusLine object — re-run \`cc-candybar install\` to write one`};case`present`:break}let c=s.refreshInterval;return c===1?{ok:!0}:{ok:!1,reason:c===void 0?`${a}, but Claude Code redraws it only on events`:typeof c==`number`&&c>1?`${a}, but Claude Code redraws it only every ${c} s`:`${a}, but statusLine.refreshInterval is ${JSON.stringify(c)}, not a number of seconds Claude Code accepts (its minimum is 1)`,fix:{kind:`claude-settings`,path:[`statusLine`,`refreshInterval`],value:1}}}}];function pT(e){return fT.map(t=>({check:t,verdict:t.probe(e)}))}function mT(e){return fT.find(t=>t.name===e)}const hT=`${wp}doctor.`;function gT(e){let t=`${hT}${e}.`;return{verdict:`${t}verdict`,reason:`${t}reason`,fixable:`${t}fixable`}}function _T(e,t=[]){return t.length===0?e:`${e} (+${t.length} more — run \`cc-candybar doctor\`)`}function vT(e){return e.flatMap(({check:e,verdict:t})=>{let n=gT(e.name);return t.ok?[{key:n.verdict,value:`ok`},{key:n.reason,value:``},{key:n.fixable,value:pl}]:[{key:n.verdict,value:`failed`},{key:n.reason,value:_T(t.reason,t.more)},{key:n.fixable,value:t.fix===void 0?pl:fl}]})}const yT={copySession:{copy:`{{ .session.id }}`},copyResume:{copy:`{{ .resume_command }}`},openProject:{open:`{{ .project_dir }}`},openTranscript:{open:`{{ .transcript_path }}`},openConfig:{open:`{{ .config_path }}`}};function bT(e){let t=t=>`${e}${t}`;return{template:`{{ action "${t(`copySession`)}" "⎘ id" }}{{ if ne .resume_command "" }} {{ action "${t(`copyResume`)}" "⎘ resume" }}{{ end }} {{ action "${t(`openProject`)}" "↗ proj" }} {{ action "${t(`openTranscript`)}" "↗ log" }}{{ if ne .git.repoUrl "" }} {{ link .git.repoUrl "↗ repo" }}{{ end }}{{ if ne .config_path "" }} {{ action "${t(`openConfig`)}" "↗ config" }}{{ end }}`,actions:Object.fromEntries(Object.entries(yT).map(([t,n])=>[`${e}${t}`,n]))}}const xT=`armed`,ST=`disarmed`,CT=`.armed`,wT=e=>e.endsWith(CT);function TT(e,t,n){let r=`${e}${CT}`,i=`${e}.arm`,a=`${e}.disarm`,o=`(eq .${e} "${xT}")`;return{template:`{{ if ${o} }}{{ action "${e}" "${t.confirm}" }} {{ action "${a}" "✕" }}{{ else }}{{ action "${i}" "${t.arm}" }}{{ end }}`,actions:{[i]:{set:r,to:xT},[a]:{set:r,to:ST},[e]:{do:[a,...n]}},armed:o,variables:{[e]:{kind:`state`,key:r,default:ST}},disarm:a}}const ET=RegExp(`^/[^\\s\\x00-\\x1f\\x7f-\\x9f/][^\\x00-\\x1f\\x7f-\\x9f]*$`);function DT(e){return typeof e==`string`&&ET.test(e)?{kind:`line`,line:e}:{kind:`refused`,reason:`a slash command is "/" then its name, e.g. "/compact" or "/model opus", on one line with no control characters, got ${JSON.stringify(e)}`}}function OT(e){let t=DT(e);if(t.kind===`refused`)throw Error(t.reason);return t.line}const kT=[`/compact`,`/model`],AT=`/clear`;function jT(e){let t=t=>`${e}${t.slice(1)}`,n=`${e}clear.slash`,r=TT(`${e}clear`,{arm:AT,confirm:`${AT} ✓ confirm`},[n]);return{template:kT.map(e=>`{{ action "${t(e)}" "${e}" }} `).join(``)+r.template,when:`{{ ${$C} }}`,actions:{...Object.fromEntries(kT.map(e=>[t(e),{slash:OT(e)}])),...r.actions,[n]:{slash:OT(AT)}},variables:r.variables,disarm:r.disarm}}function MT(e,t){let n=(e.CLAUDE_CONFIG_DIR??``).split(`,`)[0].trim();return n===``?void 0:l.resolve(t,n)}function NT(e){return e??l.join(h.homedir(),`.claude`)}function PT(e){return l.join(e,`settings.json`)}function FT(e){return l.join(e,`plugins`,`installed_plugins.json`)}function IT(e){return r.existsSync(e)?r.readFileSync(e,`utf8`):``}function LT(e){let t;try{let n=IT(e);if(/^\s*$/.test(n))return{};t=Rl.parse(n)}catch(t){throw Error(`cannot read ${e}: ${zT(t)}`,{cause:t})}if(!RT(t))throw Error(`cannot read ${e}: not a JSON object`);return t}const RT=e=>typeof e==`object`&&!!e&&!Array.isArray(e),zT=e=>e instanceof Error?e.message:String(e),BT=Array.from({length:10},(e,t)=>(t+1)*1e5),VT=BT[0],HT=BT[BT.length-1];function UT(e){let t;try{t=LT(e)}catch(e){return X(e instanceof Error?e.message:String(e))}let n=t.autoCompactWindow;return n===void 0?J(`auto`):typeof n==`number`&&Number.isInteger(n)&&n>=VT&&n<=HT?J(n):X(`${e}: autoCompactWindow is ${JSON.stringify(n)}, not a window /autocompact accepts (${VT}–${HT} tokens)`)}function WT(e,t){let n=Math.min(t??HT,HT),r=e===`auto`?n:Math.min(e,n);return{window:e===`auto`?0:e,applied:e===`auto`?0:r,lower:BT.filter(e=>e<r).at(-1)??0,higher:BT.find(e=>e>r&&e<=n)??0}}function GT(e,t){return{template:`{{ if ne .autocompact.error "" }}⇲ ⚠ {{ .autocompact.error }}{{ else }}⇲ {{ if eq .autocompact.window 0 }}auto{{ else }}${t(`.autocompact.applied`)}{{ end }}{{ if ${$C} }}{{ if gt .autocompact.lower 0 }} {{ action (printf "${e}%d" .autocompact.lower) "−" }}{{ end }}{{ if gt .autocompact.higher 0 }} {{ action (printf "${e}%d" .autocompact.higher) "+" }}{{ end }}{{ if gt .autocompact.window 0 }} {{ action "${e}auto" "↺" }}{{ end }}{{ end }}{{ end }}`,bg:`{{ if ne .autocompact.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .autocompact.window 0) (ne .autocompact.error "") }}`,actions:{[`${e}auto`]:{slash:OT(`/autocompact auto`)},...Object.fromEntries(BT.map(t=>[`${e}${t}`,{slash:OT(`/autocompact ${t}`)}]))}}}const KT=e=>`{{ if ge ${e} 1000000 }}{{ printf "%.1f" (divf ${e} 1000000) }}M{{ else if ge ${e} 1000 }}{{ printf "%.1f" (divf ${e} 1000) }}K{{ else }}{{ ${e} }}{{ end }}`,qT=`${wp}menu`,JT=`open`,YT=`${wp}edit`,XT=`${wp}toolbar`,ZT=bT(wp),QT=`${wp}commands`,$T=jT(`${QT}.`),eE=`${wp}autocompact`,tE=GT(`${eE}.`,KT),nE=e=>({kind:`segment`,name:e}),rE=`${wp}tab`,iE=[{member:`session`,label:`⚡ session`},{member:`look`,label:`🎨 look`},{member:`layout`,label:`📐 layout`},{member:`config`,label:`⚙ config`},{member:`tools`,label:`🧰 tools`}],aE=e=>`${rE}.${e}`,oE=e=>`${aE(e)}.toggle`,sE=e=>({variable:rE,key:rE,member:e}),cE=`${wp}save`,lE=`${wp}preset.save`,uE=`${wp}preset.delete`,dE=`${wp}themeDefault.save`,fE=`${wp}themeDefault.differs`,pE=`${wp}themeDefault.theme`,mE={when:`{{ .${fE} }}`,template:`{{ action "${dE}" (printf "⤓ default for %s" .${pE}) }}`},hE=`${wp}resetAll`,gE=`${qT}.toggle`,_E={variable:qT,key:qT,member:JT},vE=`${wp}undo`,yE=`${wp}back`,bE=`${yE}.step`,xE=`${wp}navigation.back`,SE=yE,CE={template:`{{ if gt .${xE} 0 }}{{ action "${yE}" "◁" }}{{ else }}{{ fg (${nT}) "◁" }}{{ end }}`},wE=`${wp}redo`,TE=`${wp}doctor`,EE=`${TE}.run`,DE=e=>`${TE}.fix.${e}`,OE=e=>`${TE}.${e}`,kE=wb(`${wp}pickers`),AE=[{template:`{{ themePreview }}`}],jE={template:`{{ layoutPreview }}`},ME={preset:[jE,{when:`{{ not .preset.bundled }}`,template:`{{ action "${uE}" (printf "🚮 delete %s" .${ew.preset.effectiveVar}) }}`}],theme:AE,style:AE,variation:[jE],shade:[jE]},NE=e=>`${wp}${e}`,PE=e=>`${wp}apply.${e}`,FE=e=>`${wp}reset.${e}`,IE=e=>`${wp}list.${e}`,LE=(e,t)=>`${IE(e)}.${t}`,RE=e=>`${wp}resettable.${e}`,zE=e=>e.length===0?`false`:`(or ${e.map(e=>`.${RE(e)}`).join(` `)})`,BE=Object.keys(ew).map(e=>{let t=ew[e],n=ff(t.configKey),r=Mw({label:t.label,domain:n},t.sessionKey,t.effectiveVar,PE(e),kE);return{...t,name:e,control:r,beneath:ME[e]??[]}}),VE={preset:`door`,theme:`look`,style:`look`,effect:`look`,variation:`look`,shade:`look`,endcaps:`look`,transitions:`look`,autoWrap:`layout`,padding:`layout`,updateNotice:`config`},HE=e=>BE.filter(t=>VE[t.name]===e),UE=e=>HE(e).map(tD);new Set(BE.flatMap(e=>[e.sessionKey,e.configKey]));const WE=TT(hE,{arm:`⟲`,confirm:`⟲ reset all?`},BE.map(e=>FE(e.name))),GE=[`unsaved`,`history.undo`,`history.redo`],KE=e=>`${wp}${e}`,qE=KE(`unsaved`),JE=(e,t)=>({body:t,shown:`(gt .${KE(e)} 0)`}),YE=[JE(`unsaved`,`{{ action "${cE}" (printf "💾 save %d" .${qE}) }}`),JE(`history.undo`,`{{ action "${vE}" "↶" }}`),JE(`history.redo`,`{{ action "${wE}" "↷" }}`),{body:WE.template,shown:`(or ${zE(BE.map(e=>e.name))} ${WE.armed})`}],XE={when:`{{ or ${YE.map(e=>e.shown).join(` `)} }}`,template:`{{ $sep := "" }}`+YE.map(e=>`{{ if ${e.shown} }}{{ $sep }}${e.body}{{ $sep = " " }}{{ end }}`).join(``)},ZE=[{step:WE,place:`door`},{step:$T,place:`session`}],QE=e=>e.map(e=>e.step.disarm),$E=QE(ZE),eD=QE(ZE.filter(e=>e.place!==`door`));function tD(e){let t=NE(e.name);return e.control.kind===`inline`?nE(t):Gd(t,e.control.list.ref,{kind:`container`,direction:`vertical`,children:[nE(IE(e.name)),...e.beneath.map((t,n)=>nE(LE(e.name,n)))]},`drop`)}function nD(e){return e===qT}function rD(e){let t=nE(qT);if(e.kind===`container`&&e.direction===`vertical`){let[n,...r]=e.children;return e.when===void 0&&n!==void 0?{...e,children:[rD(n),...r]}:{kind:`container`,direction:`vertical`,children:[t,e]}}return e.kind===`container`&&e.when===void 0?{...e,children:[t,...e.children]}:{kind:`container`,direction:`horizontal`,children:[t,e]}}function iD(e){return aD(e)>0?e:rD(e)}function aD(e){let t=0;for(let n of wu(e))n.kind===`segment`&&nD(n.name)&&(t+=1);return t}function oD(e,t=!1){let n=t||e.when!==void 0;return e.kind===`segment`?n&&nD(e.name)||e.opens!==void 0&&oD(e.opens.body,!0):e.children.some(e=>oD(e,n))}const sD={session:{direction:`vertical`,content:[nE(XT),{kind:`container`,direction:`horizontal`,children:[nE(QT),nE(eE)]}],after:[]},look:{direction:`horizontal`,content:[],after:[nE(dE)]},layout:{direction:`horizontal`,content:[nE(lE),nE(YT)],after:[]},config:{direction:`horizontal`,content:[],after:[]},tools:{direction:`vertical`,content:[nE(TE),...fT.map(e=>nE(OE(e.name)))],after:[]}},cD=e=>({kind:`container`,direction:sD[e].direction,children:[...sD[e].content,...UE(e),...sD[e].after]});function lD(e){return e.kind===`segment`?nD(e.name)?Gd(e.name,_E,dD,`above`):e:pD(e)}function uD(){return{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[nE(SE),...UE(`door`),nE(cE)]},{kind:`container`,direction:`horizontal`,children:iE.map(({member:e})=>Gd(aE(e),sE(e),cD(e),`drop`))}]}}const dD=uD();function fD(e){let t=new Map;for(let e of wu(dD))e.kind===`segment`&&e.opens!==void 0&&t.set(e.opens.ref.key,e.opens.ref.variable);return[...t].map(([t,n])=>{let r=e.variables[n];if(r?.kind!==`state`||r.default===void 0)throw Error(`settings menu: the door folds "${t}", but "${n}" is not a state variable the menu declares with a default`);let i=`${qT}.fold.${bp(t)}`;return e.actions[i]={set:t,to:r.default},i})}function pD(e){return{...e,children:e.children.map(e=>lD(e))}}function mD(e){let t={variables:{[qT]:Zd(qT,Bd)},actions:{[gE]:Qd(qT,JT),[EE]:{doctor:`run`},[YT]:{do:[...tx]},...ZT.actions,...$T.actions,...tE.actions,[cE]:{save:!0},[vE]:{undo:!0},[bE]:{back:!0},[yE]:{do:[bE,...$E]},[wE]:{redo:!0},[lE]:{preset:`save`},[dE]:{themeDefault:`save`},[uE]:{preset:`delete`,name:`{{ .${ew.preset.effectiveVar} }}`}},segments:{[qT]:{template:`{{ $door := ${Yd(qT,Xd(e),Xd(`✖`))} }}{{ if ${qd(_E)} }}{{ fg (keptOn (color "error") (bgOf)) $door }}{{ else }}{{ $door }}{{ end }}`},[XT]:{template:ZT.template},[QT]:{template:$T.template,when:$T.when},[eE]:{template:tE.template,bg:tE.bg,when:tE.when},[SE]:CE,[cE]:XE,[dE]:mE,[lE]:{template:`{{ action "${lE}" "+ preset" }}`},[TE]:{template:`{{ action "${EE}" "🩺 doctor" }}`},[YT]:{template:`{{ action "${YT}" "✎ arrange" "✎ done" }}`}}};t.variables[fE]={kind:`input`,path:`themeDefault.differs`,type:`boolean`,default:!1},t.variables[pE]={kind:`input`,path:`themeDefault.theme`,type:`string`,default:``},t.variables[xE]={kind:`input`,path:`navigation.back`,type:`number`,default:0};for(let e of GE)t.variables[KE(e)]={kind:`input`,path:e,type:`number`,default:0};t.variables[rE]=Zd(rE,`session`);for(let{member:e,label:n}of iE){t.actions[oE(e)]=Qd(rE,e),t.actions[aE(e)]={do:[oE(e),...eD]};let r=zE(HE(e).map(e=>e.name)),i=`(ternary ${Xd(` •`)} "" ${r})`,a=e=>`(print ${Xd(e)} ${i})`;t.segments[aE(e)]={template:`{{ ${Yd(aE(e),a(n),a(`▾ ${n}`))} }}`}}return Object.assign(t.variables,$T.variables,WE.variables),gD(t),hD(t),t.actions[qT]={do:[gE,...$E,...fD(t)]},t}function hD(e){for(let t of fT){let n=gT(t.name),r=DE(t.name);for(let t of Object.values(n))e.variables[t]={kind:`state`,key:t,default:``};e.actions[r]={doctor:`fix`,check:t.name},e.segments[OE(t.name)]={when:`{{ ne .${n.verdict} "" }}`,template:`{{ if eq .${n.verdict} "ok" }}✓ ${t.label}{{ else }}✗ ${t.label} — {{ .${n.reason} }}{{ if eq .${n.fixable} "${fl}" }} {{ action "${r}" "[fix]" }}{{ end }}{{ end }}`}}}function gD(e){for(let t of BE){Object.assign(e.actions,t.control.actions);let n=FE(t.name);e.actions[n]={reset:t.configKey},e.variables[RE(t.name)]={kind:`input`,path:`resettable.${t.name}`,type:`boolean`,default:!1};let r=`{{ if .${RE(t.name)} }} {{ action "${n}" "↺" }}{{ end }}`;Object.assign(e.variables,t.control.variables),e.segments[NE(t.name)]={template:`${t.control.template}${r}`},t.control.kind===`picker`&&(e.segments[IE(t.name)]={template:t.control.list.template}),t.beneath.forEach((n,r)=>{e.segments[LE(t.name,r)]=n})}Object.assign(e.actions,WE.actions)}function _D(e){let{variables:t,actions:n}=ux();Object.assign(e.variables,t),Object.assign(e.actions,n)}function vD(e){let t=mD(e.globals.menuGlyph??`🍫`);_D(t);let n={...e.presets},r=[];for(let t of Nb(e.presets)){let{node:i}=Ib(e,t),a=lD(iD(i));r.push(a),n[t]={...Fb(e.presets,t),root:a}}let i=lw(t,r,e);return{...e,variables:{...i,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:n}}const yD=`${Cp}live`,bD=[`☐ live`,`☑ live`],xD=`${Cp}done`,SD=`${Cp}cancel`,CD=`${Cp}rewind`,wD=`${Cp}changes`,TD=`(gt .${wD} 0)`,ED=`(or ${TD} (gt .${qE} 0))`,DD={variable:yD,key:yD,member:`open`};function OD(e){return`${Cp}configuring.p${e}`}function kD(e){return`and ${qd(ax)} (not ${qd(DD)}) (ne .${OD(e)} "true")`}function AD(e){return{kind:`template`,template:`{{ or ${e.map(e=>`(eq .${Qb} "${Wd(e)}")`).join(` `)} false }}`}}function jD(e,t,n){return`{{ if ${kD(e)} }}${t}{{ else }}${n}{{ end }}`}const MD=`{{ and ${qd(ax)} .preset.customized }}`,ND=Ep;function PD(e){return new Map([...Cw(e),...ID(e)])}const FD=`${Cp}addable`;function ID(e){return new Map([[FD,{members:Object.keys(e.segments).filter(e=>!ND(e)),library:{groups:vp.map(e=>({id:e,label:yp[e]})),entry:t=>{let n=e.segments[t];return{group:n.group??`other`,...n.description!==void 0&&{description:n.description}}}}}]])}function LD(e,t,n){return n.segments[e]={template:t,when:ox,bg:qw},{kind:`segment`,name:e}}function RD(e,t,n){let r=`${Cp}${e.presetIdent}.remove.${t}`;return e.artifacts.actions[r]={persist:e.rootKey,removeSegment:n},`{{ fg (${`readableOn (color "error") (bgOf) ${tc}`}) (action "${r}" "✖") }}`}function zD(e){return`{{ if ${qd(ax)} }}${e}{{ end }}`}function BD(e,t){return e.reduce((e,t)=>`{{ if and ${qd(ax)} ${qd(t)} }}true{{ else }}${e}{{ end }}`,t)}function VD(e){return e.flatMap(e=>[...wu(e)].flatMap(e=>e.kind===`segment`&&e.opens?.ref.key===`edit.configure`?[e.opens.ref]:[]))}function HD(e,t,n){return`${rx}${e}.${t}.${n}`}function UD(e,t,n,r){let i=bu(n),a=`${Cp}${e.presetIdent}`,o=ix(e.presetIdent,i);e.configured.push(o);let s=`${a}.configure.${t}`,c=wb(s),l=`${s}.fold`;e.artifacts.actions[l]={set:c,to:Bd},e.artifacts.actions[s]={do:[`${s}.open`,l]},e.artifacts.actions[`${s}.open`]={set:Qb,to:o};let u={},d=Object.entries(r).map(([r,o])=>{let s=HD(e.presetIdent,i,r),l=`${rx}p${e.presetIdent}.d${t}.${r}`;e.artifacts.variables[l]={kind:`state`,key:s,default:Vu(n.settings?.[r]??o.default)},u[r]={id:i,key:s,variable:l};let d=`${a}.setting.${t}.${r}`,f=Mw(Aw(o),s,l,d,c);if(Object.assign(e.artifacts.actions,f.actions),Object.assign(e.artifacts.variables,f.variables),f.kind===`inline`)return e.artifacts.segments[d]={template:f.template},{kind:`segment`,name:d};let p=`${d}.list`;return e.artifacts.segments[d]={template:f.template},e.artifacts.segments[p]={template:f.list.template},Gd(d,f.list.ref,{kind:`container`,direction:`vertical`,children:[{kind:`segment`,name:p}]},`drop`)});return{term:`{{ action "${s}" "⚙️" }}`,ref:{variable:Qb,key:Qb,member:o},body:{kind:`container`,direction:`vertical`,children:d},drafts:u}}const WD=`${Cp}label:`;function GD(e){if(e.startsWith(WD)){let t=e.slice(WD.length);return t.slice(t.indexOf(`:`)+1)}return e.startsWith(`edit.`)?void 0:e}function KD(e,t,n,r){let{artifacts:i}=n,a=bu(e),o=`${WD}${a}:${e.name}`;i.segments[o]={template:`{{ "${Wd(a)}" }}`,...t.palette!==void 0&&{palette:t.palette}};let s=Object.fromEntries(Iu.flatMap(t=>{let n=e.settings?.[t];return n===void 0?[]:[[t,n]]}));return{...Gd(o,r.ref,r.body,`drop`,BD([r.ref],`{{ ${kD(n.presetIdent)} }}`)),...Object.keys(s).length>0&&{settings:s},drafts:Object.fromEntries(Iu.map(e=>[e,r.drafts[e]]))}}function qD(e,t,n,r){let{presetIdent:i,artifacts:a}=e,o=`${Cp}${i}.insert.${t}`,s=`${Cp}${i}.insertSeg.${t}`;a.actions[o]={persist:e.rootKey,insertSegmentFrom:FD,anchor:n,relation:r};let c=Sb(o),l=Cb(s,o,void 0),u=Eb(l),d=Tb(l,c);return a.variables[l]=Zd(l,Bd),a.variables[u]={kind:`state`,key:u,default:`0`},a.actions[d]=Qd(l,c),a.actions[u]={set:u,int:!0},{host:s,template:`{{ $m := menu "${o}" "✚" "✕" }}{{ if ${qd({variable:l,key:l,member:c})} }}{{ $m }}{{ else }}{{ fg (${`readableOn (color "success") (bgOf) ${tc}`}) $m }}{{ end }}`}}function JD(e,t){let n=[],r=e.children.findIndex(e=>e.kind===`segment`&&!ND(e.name)),i=e=>JD(e,t);for(let[a,o]of e.children.entries()){if(o.kind===`container`){n.push(i(o));continue}let s=Cu(o,i);if(ND(o.name)){n.push(s);continue}let c=bu(o),l=a===r?[qD(t,String(t.posCounter.n++),c,`before`)]:[],u=String(t.posCounter.n++),d=qD(t,u,c,`after`),f=RD(t,u,c),p=t.segments[o.name],m=UD(t,u,o,Lu(p)),h=zD(f),g=zD(m.term),_={kind:`container`,direction:`horizontal`,children:[...l.map(e=>LD(e.host,e.template,t.artifacts)),{...KD(o,p,t,m),lead:h,trail:g},{...s,when:jD(t.presetIdent,`false`,o.when??`true`),lead:h,trail:g,drafts:m.drafts},LD(d.host,d.template,t.artifacts)]};n.push(e.direction===`vertical`?{kind:`container`,direction:`horizontal`,children:[_]}:_)}return{...e,children:n,...e.when!==void 0&&{when:BD(VD(n),jD(t.presetIdent,`true`,e.when))}}}function YD(e,t,n,r,i,a,o){let s=`${Cp}${t}.resetLayout`,c=`${Cp}${t}.customized`;return r.actions[s]={reset:n},r.segments[c]={template:`{{ action "${s}" "↺ reset layout" }}`,when:MD},{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[...i,{kind:`segment`,name:c},a]},XD(e,o)]}}function XD(e,t){if(e.kind===`segment`)return{kind:`container`,direction:`horizontal`,children:[e,t]};let n=e.children.at(-1);return e.direction===`vertical`&&n!==void 0&&(n.kind===`segment`||n.when===void 0)?{...e,children:[...e.children.slice(0,-1),XD(n,t)]}:{...e,children:[...e.children,t]}}function ZD(e,t,n,r,i,a){let{node:o}=Ib(e,t),s={presetIdent:bp(t),rootKey:Rw(t),segments:e.segments,artifacts:n,posCounter:{n:0},configured:[]},c=JD(o,s);return n.variables[OD(s.presetIdent)]=AD(s.configured),YD(c,s.presetIdent,s.rootKey,n,r,i,a)}function QD(e){let t={variables:{},actions:{},segments:{}},n=Gw(`${Cp}help`,eT,[ax],t);t.variables[yD]=Zd(yD,Bd),t.actions[yD]=Qd(yD,DD.member),t.segments[yD]={template:Jd(yD,...bD),when:ox};let r={kind:`segment`,name:yD},i=n;t.variables[wD]={kind:`input`,path:`history.sinceEdit`,type:`number`,default:0},t.actions[xD]={do:[cE,...tx]},t.segments[xD]={template:`{{ if ${ED} }}{{ action "${xD}" "✓ save" }}{{ else }}{{ action "${xD}" "✓ done" }}{{ end }}`,when:ox},t.actions[CD]={rewind:!0},t.actions[SD]={do:[CD,...tx]},t.segments[SD]={template:`{{ action "${SD}" "↩ cancel" }}`,when:`{{ and ${qd(ax)} ${TD} }}`};let a=[{kind:`segment`,name:xD},{kind:`segment`,name:SD}],o={...e.presets},s=[];for(let n of Nb(e.presets)){let c=ZD(e,n,t,a,r,i);s.push(c),o[n]={...Fb(e.presets,n),root:c}}let c=lw(t,s,e);return{...e,variables:{...c,...e.variables,...t.variables},actions:{...e.actions,...t.actions},segments:{...e.segments,...t.segments},presets:o}}const $D=[`set`,`persist`,`copy`,`open`,`reset`,`undo`,`redo`,`back`,`rewind`,`save`,`preset`,`themeDefault`,`doctor`,`ceiling`,`slash`,`do`];function eO(e){return e.ceiling===`set`?[`set`,e.to]:[`clear`]}function tO(e){return`from`in e||`int`in e||`insertSegmentFrom`in e}function nO(e,t){if(t===void 0)return{};if(!Qu(t))return Q(e,`actions`,`actions must be an object, got ${$u(t)}`),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){let t=rO(e,`actions.${r}`,i);t!==null&&(n[r]=t)}return n}function Q(e,t,n){e.issues.push({path:t,message:n,line:G(e.source,t.split(`.`))})}function rO(e,t,n){if(!Qu(n))return Q(e,t,`${t} must be an action object, got ${$u(n)}`),null;if(`persistWhen`in n)return Q(e,t,`${t}.persistWhen was removed: declare the \`set\` alone — a session pick is a draft until a \`{ save: true }\` action writes every unsaved setting to the config file`),null;let r=$D.filter(e=>e in n);return r.length===1?iO[r[0]](e,t,n):(Q(e,t,`action must declare exactly one of: ${$D.join(`, `)}${r.length>1?` (found: ${r.join(`, `)})`:``}`),null)}const iO={set:(e,t,n)=>LO(e,t,n,`set`,NO),persist:(e,t,n)=>LO(e,t,n,`persist`,PO),copy:aO(`copy`),open:aO(`open`),reset:oO,undo:cO(`undo`),redo:cO(`redo`),back:cO(`back`),rewind:cO(`rewind`),save:cO(`save`),preset:lO,themeDefault:uO,doctor:dO,ceiling:fO,slash:pO,do:mO};function aO(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Q(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);let i=qu(t,n,r,e);return i===null?null:{[e]:i}}}function oO(e,t,n){for(let r of Object.keys(n))r!==`reset`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a reset action. Expected only: reset`);let r=hO(e,t,`reset`,n,`reset key must be non-empty (the config globals field to clear)`,e=>`reset key "${e}" contains "/" — keys must be slash-free`);return r===null?null:{reset:r}}const sO={undo:`it steps the session's settings history`,redo:`it steps the session's settings history`,back:`it steps the session's navigation history`,rewind:`it steps the session's settings history back to where edit mode opened`,save:`it saves the session's unsaved settings`};function cO(e){return(t,n,r)=>{for(let i of Object.keys(r))i!==e&&Q(t,`${n}.${i}`,`Unknown key "${i}" on a ${e} action. Expected only: ${e}`);return r[e]===!0?{[e]:!0}:(Q(t,`${n}.${e}`,`${e} must be the literal true (it takes no key — ${sO[e]}), got ${K(r[e])}`),null)}}function lO(e,t,n){let r=n.preset,i=r===`save`?[`preset`]:[`preset`,`name`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a preset action. Expected only: ${i.join(`, `)}`);if(r!==`save`&&r!==`delete`)return Q(e,`${t}.preset`,`preset must be "save" or "delete", got ${K(r)}`),null;if(r===`save`)return{preset:`save`};let a=qu(e,t,n,`name`);return a===null?null:{preset:`delete`,name:a}}function uO(e,t,n){for(let r of Object.keys(n))r!==`themeDefault`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a themeDefault action. Expected only: themeDefault`);return n.themeDefault===`save`?{themeDefault:`save`}:(Q(e,`${t}.themeDefault`,`themeDefault must be "save" (it saves the look the session draws as the active theme's default), got ${K(n.themeDefault)}`),null)}function dO(e,t,n){let r=n.doctor,i=r===`run`?[`doctor`]:[`doctor`,`check`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a doctor action. Expected only: ${i.join(`, `)}`);if(r!==`run`&&r!==`fix`)return Q(e,`${t}.doctor`,`doctor must be "run" or "fix", got ${K(r)}`),null;if(r===`run`)return{doctor:`run`};let a=n.check;return typeof a!=`string`||mT(a)===void 0?(Q(e,`${t}.check`,`doctor fix must name a check (have: ${fT.map(e=>e.name).join(`, `)}), got ${K(a)}`),null):{doctor:`fix`,check:a}}function fO(e,t,n){let r=n.ceiling,i=r===`clear`?[`ceiling`]:[`ceiling`,`to`];for(let r of Object.keys(n))i.includes(r)||Q(e,`${t}.${r}`,`Unknown key "${r}" on a ceiling action. Expected only: ${i.join(`, `)}`);if(r===`clear`)return{ceiling:`clear`};if(r!==`set`)return Q(e,`${t}.ceiling`,`ceiling must be "set" or "clear", got ${K(r)}`),null;let a=n.to;return typeof a!=`string`||a.trim()===``?(Q(e,`${t}.to`,`ceiling set needs \`to\`: a memento ceiling value such as "+100_000", "400000" or "off", got ${K(a)}`),null):{ceiling:`set`,to:a}}function pO(e,t,n){for(let r of Object.keys(n))r!==`slash`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a slash action. Expected only: slash`);let r=DT(n.slash);return r.kind===`refused`?(Q(e,`${t}.slash`,r.reason),null):{slash:r.line}}function mO(e,t,n){for(let r of Object.keys(n))r!==`do`&&Q(e,`${t}.${r}`,`Unknown key "${r}" on a do action. Expected only: do`);let r=n.do;return!Array.isArray(r)||r.length<2||r.some(e=>typeof e!=`string`||e===``)?(Q(e,`${t}.do`,`do must list at least two action names (the first is the click's face, the rest ride along in the same click), got ${K(r)}`),null):{do:r}}function hO(e,t,n,r,i,a){let o=qu(e,t,r,n);if(o===null)return null;let s=`${t}.${n}`;return o===``?(Q(e,s,i),null):o.includes(`/`)?(Q(e,s,a(o)),null):o}const gO={set:`the SessionState key to write`,persist:`the config globals field to write`};function _O(e,t,n,r){let i=gO[r],a=hO(e,t,r,n,`${r} key must be non-empty (${i})`,e=>`${r} key "${e}" contains "/" — keys must be slash-free`);return a===null?null:{[r]:a}}function vO(e){return e===`set`?`set-state`:`set-config`}const yO={to:RO(`set`)},bO={to:RO(`persist`)},xO={from:zO(`set`)},SO={from:zO(`persist`)},CO={min:WO(),max:WO(),by:WO()},wO={int:VO()},TO={cycle:BO(`set`)},EO={cycle:BO(`persist`)},DO={removeSegment:HO(`removeSegment`)},OO={insertSegment:HO(`insertSegment`),anchor:HO(`anchor`),relation:UO()},kO={insertSegmentFrom:zO(`persist`),anchor:HO(`anchor`),relation:UO()},AO={ok:e=>e.min<e.max,issue:e=>({field:`min`,message:`min (${e.min}) must be less than max (${e.max})`})},jO={ok:e=>e.by!==0,issue:()=>({field:`by`,message:`by must be a non-zero integer (the per-click increment; negative steps down)`})};function MO(e,t,n=[],r){let i=Object.keys(t),a=r??i,o=[e],s=(e,n,r)=>nd(e,t,n,r),c=bd(t);return{detect:a,allowed:[...o,...i],label:i.join(`/`),json:{type:`object`,properties:{...Object.fromEntries(o.map(e=>[e,{type:`string`}])),...c.properties},required:[...o,...c.required??[]],additionalProperties:!1},parse:n.length?ud(s,...n):s}}const NO=[MO(`set`,yO),MO(`set`,xO),MO(`set`,CO,[AO,jO]),MO(`set`,wO),MO(`set`,TO)],PO=[MO(`persist`,bO),MO(`persist`,SO),MO(`persist`,CO,[AO,jO]),MO(`persist`,EO),MO(`persist`,DO),MO(`persist`,OO,[],[`insertSegment`]),MO(`persist`,kO,[],[`insertSegmentFrom`])];function FO(e){let t=[`"to" (a literal value)`,`"from" (an option domain — a registered domain name like "themes"/"endcaps"/"styles", or an inline array of literal values)`,`"min"/"max"/"by" (a bounded step)`];return e===`set`&&t.push(`"int" (an unbounded integer cursor)`),t.push(`"cycle" (an enumerated domain stepped in order)`),e===`persist`&&t.push(`"removeSegment" (remove a named segment from the layout)`,`"insertSegment"/"anchor"/"relation" (insert a named segment before/after an existing one)`,`"insertSegmentFrom"/"anchor"/"relation" (insert a segment PICKED from an option domain before/after an existing one)`),t}function IO(e){let t=FO(e),n=t[t.length-1];return`a ${e} action declares exactly one value source: ${t.length===1?n:`${t.slice(0,-1).join(`, `)}, or ${n}`}`}function LO(e,t,n,r,i){let a=_O(e,t,n,r),o=i.filter(e=>e.detect.some(e=>e in n));if(o.length!==1)return Q(e,t,`${IO(r)}${o.length>1?` — found: ${o.map(e=>e.label).join(`, `)}`:``}`),null;let s=o[0];for(let i of Object.keys(n))s.allowed.includes(i)||Q(e,`${t}.${i}`,`Unknown key "${i}" on this ${r} action. Expected one of: ${s.allowed.join(`, `)}`);let c=s.parse(e,t,n);return a===null||c===null?null:{...a,...c}}function RO(e){let t=vO(e);return{required:!0,json:{type:`string`},parse:(n,r,i,a)=>hO(n,r,i,a,`${e} value must be non-empty — an empty value cannot be delivered on the ${t} wire`,t=>`${e} value "${t}" contains "/" — ${e} values must be slash-free`)??void 0}}function zO(e){let t=vO(e);return{required:!0,json:{anyOf:[{type:`string`,minLength:1},{type:`array`,items:{type:`string`,minLength:1},minItems:1,uniqueItems:!0}]},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(typeof o==`string`){if(o===``){Q(n,s,`${i} must be a non-empty domain name`);return}return o}if(Array.isArray(o)&&o.every(e=>typeof e==`string`)){let r=o;if(r.length===0){Q(n,s,`${i} must name a domain (a non-empty string) or declare an inline domain (a non-empty array of values)`);return}if(r.some(e=>e===``)){Q(n,s,`${i} array members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}let a=r.filter(e=>e.includes(`/`));if(a.length>0){Q(n,s,`${i} array member(s) ${a.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(r).size!==r.length){Q(n,s,`${i} array members must be unique — a duplicated value would render the same picker option twice`);return}return r}Q(n,s,`${i} must be a domain name (a string) or an inline domain (an array of strings), got ${K(o)}`)}}}function BO(e){let t=vO(e);return{required:!0,json:{type:`array`,items:{type:`string`,minLength:1},minItems:2,uniqueItems:!0},parse:(n,r,i,a)=>{let o=a[i],s=`${r}.${i}`;if(!Array.isArray(o)||o.some(e=>typeof e!=`string`)){Q(n,s,`cycle must be an array of strings (the enumerated values a click steps through), got ${$u(o)}`);return}let c=o;if(c.length<2){Q(n,s,`cycle needs at least two members (one member has no successor — use a literal "to")`);return}let l=c.some(e=>e===``),u=c.filter(e=>e.includes(`/`));if(l){Q(n,s,`cycle members must be non-empty — an empty value cannot be delivered on the ${t} wire`);return}if(u.length>0){Q(n,s,`cycle member(s) ${u.map(e=>`"${e}"`).join(`, `)} contain "/" — ${e} values must be slash-free`);return}if(new Set(c).size!==c.length){Q(n,s,`cycle members must be unique — the successor of a duplicated member is ambiguous`);return}return c}}}function VO(){return{required:!0,json:{const:!0},parse:(e,t,n,r)=>{if(r[n]!==!0){Q(e,`${t}.${n}`,`int must be the literal true (declares the key an unbounded integer cursor — a paged picker's page key), got ${K(r[n])}`);return}return!0}}}function HO(e){return{required:!0,json:{type:`string`},parse:(t,n,r,i)=>{let a=qu(t,n,i,r);if(a===null)return;let o=`${n}.${r}`;if(a===``){Q(t,o,`${e} must be non-empty (a segment name)`);return}if(a.includes(`/`)||a.includes(`:`)){Q(t,o,`${e} "${a}" contains "/" or ":" — segment names in a layout op must be free of both (the click wire's own delimiter and layout-ops.ts's op-token delimiter)`);return}return a}}}function UO(){return{required:!0,json:{enum:[`before`,`after`]},parse:(e,t,n,r)=>{let i=r[n];if(i!==`before`&&i!==`after`){Q(e,`${t}.${n}`,`relation must be "before" or "after", got ${K(i)}`);return}return i}}}function WO(){return{required:!0,json:{type:`integer`},parse:(e,t,n,r)=>{let i=r[n];if(typeof i!=`number`||!Number.isInteger(i)){Q(e,`${t}.${n}`,`${n} must be an integer, got ${K(i)}`);return}return i}}}function GO(e,t,n){return`${e}: "${t}" is an endcaps shape, not a style — endcaps were renamed from "style" to "endcaps"; write ${n}: "${t}"`}const KO={noun:`style key`,fields:{hueShift:md(),chromaScale:md({min:0}),lightnessScale:md(),lightnessShift:md()}};function qO(e,t){if(!Qu(t))return e.issues.push({path:`styles`,message:`styles must be an object mapping style names to adaptation objects, got ${$u(t)}`,line:G(e.source,[`styles`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)){e.issues.push({path:`styles.${r}`,message:`style name ${JSON.stringify(r)} must be non-empty and slash-free — a style picker writes the name on the set-state wire, which rejects empty values and splits on "/"`,line:G(e.source,[`styles`,r])});continue}if($c(r)){e.issues.push({path:`styles.${r}`,message:GO(`styles.${r}`,r,`globals.endcaps`),line:G(e.source,[`styles`,r])});continue}let t=ed(e,KO,`styles.${r}`,i);t!==null&&(n[r]={...sr,...t})}return n}const JO={noun:`preset key`,fields:{root:{required:!1,json:{$ref:`#/definitions/RootFragment`},parse:(e,t,n,r)=>r[n]===void 0?void 0:_m(e,`${t}.${n}`,r[n])},globals:{required:!1,json:Of(),parse:(e,t,n,r)=>r[n]===void 0?void 0:Df(e,`${t}.${n}`,r[n])}}};function YO(e,t){if(!Qu(t))return e.issues.push({path:`presets`,message:`presets must be an object mapping preset names to config fragments, got ${$u(t)}`,line:G(e.source,[`presets`])}),{};let n={};for(let[r,i]of Object.entries(t)){if(r===``||r.includes(`/`)||/[\n\r]/.test(r)){e.issues.push({path:`presets.${r}`,message:`preset name ${JSON.stringify(r)} must be non-empty, slash-free, and newline-free — a preset picker writes the name on the set-state wire (which rejects empty values and splits on "/"), and edit mode splices it into a synthesized template string`,line:G(e.source,[`presets`,r])});continue}let t=ed(e,JO,`presets.${r}`,i);t!==null&&(n[r]=t)}return n}function XO(e,t){if(t===void 0)return{};if(!Qu(t))return e.issues.push({path:`helpers`,message:`helpers must be an object, got ${$u(t)}`,line:G(e.source,[`helpers`])}),{};let n=Object.create(null);for(let[r,i]of Object.entries(t)){if(typeof i!=`string`){e.issues.push({path:`helpers.${r}`,message:`helpers.${r} must be a string template body, got ${K(i)}`,line:G(e.source,[`helpers`,r])});continue}n[r]=i}return n}const ZO=new Map([[`session.budget.amount`,{segment:`session`,setting:`budget`}],[`session.budget.warningThreshold`,{segment:`session`,setting:`warnAt`}],[`today.budget.amount`,{segment:`today`,setting:`budget`}],[`today.budget.warningThreshold`,{segment:`today`,setting:`warnAt`}],[`block.budget.heatThreshold`,{segment:`block`,setting:`warnAt`}],[`block.budget.warningThreshold`,{segment:`block`,setting:`errorAt`}],[`weekly.budget.heatThreshold`,{segment:`weekly`,setting:`warnAt`}],[`weekly.budget.warningThreshold`,{segment:`weekly`,setting:`errorAt`}],[`burn.eta.errorMinutes`,{segment:`burnrate`,setting:`errorWithin`}],[`burn.eta.warnMinutes`,{segment:`burnrate`,setting:`warnWithin`}]]);function QO(e){return`it became the "${e.setting}" setting of each "${e.segment}" placement — set it on the placement where a row places "${e.segment}" ({ seg: "${e.segment}", settings: { ${e.setting}: <value> } }), or redeclare segments.${e.segment}.settings.${e.setting} with the default every placement should start from`}function $O(e){let t=ZO.get(e);return t===void 0?void 0:`variables.${e} is no longer read: ${QO(t)}`}function ek(e){let t=ZO.get(e);return t===void 0?``:` — ".${e}" is no longer a variable: ${QO(t)}; a "${t.segment}" template reads it as ".settings.${t.setting}"`}function tk(e,t){let n=new Map;for(let e of Object.keys(t)){let t=bp(e),r=n.get(t);r?r.push(e):n.set(t,[e])}for(let[t,r]of n)r.length<2||e.issues.push({path:`presets`,message:`preset names ${r.map(e=>JSON.stringify(e)).join(` and `)} both collapse to the same synthesis identifier "${t}" — edit mode's synthesized reset affordance would silently steal one preset's action for the other. Rename one.`,line:G(e.source,[`presets`])})}function nk(e,t,n){let r=[[[`globals`],t.globals.style,`globals.endcaps`],[[`editGlobals`],t.editGlobals.style,`editGlobals.endcaps`],...Object.entries(t.presets).map(([e,t])=>[[`presets`,e,`globals`],t.globals?.style,`presets.${e}.globals.endcaps`]),...Object.entries(t.themeDefaults).map(([e,t])=>[[`themeDefaults`,e],t.style,`globals.endcaps`])];for(let[n,i,a]of r){if(i===void 0||Lc(i)||Object.prototype.hasOwnProperty.call(t.styles,i))continue;let r=`${n.join(`.`)}.style`;e.issues.push({path:r,message:$c(i)?GO(r,i,a):`${r} "${i}" does not match any declared style (have: ${Object.keys(t.styles).join(`, `)})`,line:G(e.source,[...n,`style`])})}t.globals.preset!==void 0&&!Object.prototype.hasOwnProperty.call(t.presets,t.globals.preset)&&e.issues.push({path:`globals.preset`,message:`globals.preset "${t.globals.preset}" does not match any declared preset (have: ${Object.keys(t.presets).join(`, `)})`,line:G(e.source,[`globals`,`preset`])}),tk(e,t.presets),Tk(e,t);let i=jx(t);for(let t of i.names)t!==`settings`&&!t.startsWith(ak)||e.issues.push({path:`variables`,message:`variable "${t}" is named under "settings", which a segment's templates read as its placement's own settings (.settings.<name>) — rename it`,line:G(e.source,[`variables`,t])});let a=(t,n,r)=>{aD(t)>1&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${qT}" ${aD(t)} times — it may appear at most once per layout (it is one disclosure, and one state key holds one open state). Remove all but the placement you want; removing every placement puts the menu at its default position.`,line:r}),oD(t)&&e.issues.push({path:n,message:`${n} places the global settings menu anchor "${qT}" under a \`when\` or inside a disclosure body — the menu is visible under every condition, so its placement may not be gated. Move it to an ungated position, or remove it to put the menu at its default position.`,line:r}),o(t)&&e.issues.push({path:n,message:`${n} sets "distribution" on a container inside a bar cell — everything inside a cell wears that cell's hue and shade, so it would place nothing. Set it on the row whose children are the cells (the horizontal container) or on the root, which places the rows.`,line:r});let i=new Map;for(let e of wu(t)){if(e.kind!==`segment`)continue;let t=bu(e);i.set(t,[...i.get(t)??[],e])}for(let[t,a]of i){if(a.length<2)continue;let o=a[1].name,s=Su(o,new Set(i.keys()));e.issues.push({path:n,message:`${n} has ${a.length} placements with the id "${t}" — an id names one placement (its settings, its menus' open state, and edit mode all address it), so give each its own: { seg: "${o}", id: "${s}" }. A placement without an "id" takes its segment's name.`,line:r})}};function o(e,t=!1){return e.kind===`segment`?!1:t&&e.distribution!==void 0||e.children.some(n=>o(n,t||yu[e.direction]===`cell`))}let s=(n,r)=>{for(let[a,o]of Nd(n,r)){let n=G(e.source,o.split(`.`));if(a.when!==void 0&&(_k(e,`${o}.when`,a.when,i,{line:n}),gk(e,`${o}.when`,a.when,n)),a.kind===`segment`){if(nD(a.name)){(a.id!==void 0||a.settings!==void 0)&&e.issues.push({path:o,message:`${r} gives the global settings menu anchor "${qT}" an id or settings — the anchor only marks where the menu goes, so place it as the bare name "${qT}"`,line:n});continue}Object.prototype.hasOwnProperty.call(t.segments,a.name)||e.issues.push({path:o,message:`${r} entry "${a.name}" does not match any declared segment${Ap(a.name)}`,line:n}),pk(e,t,a,o,n)}}};n.root!==void 0&&s(n.root,`root`);for(let[e,t]of Object.entries(n.presets??{}))t.root!==void 0&&s(t.root,`presets.${e}.root`);let c=new Map([[`root`,jd(t.root)]]);for(let e of Nb(t.presets)){let{node:n,path:r}=Ib(t,e);c.set(r,n)}for(let[t,n]of c)a(n,t,G(e.source,t.split(`.`)));wk(e,t,i,()=>!0)}const rk=[`removeSegment`,`insertSegment`,`insertSegmentFrom`];function ik(e,t,n,r,i,a,o){let s=`actions.${n}.${r}`,c=G(e.source,[`actions`,n,r]);if(!Nb(t.presets).includes(a)){e.issues.push({path:s,message:`actions.${n}: "${i}" names preset "${a}" which is not declared (have: ${Nb(t.presets).join(`, `)})`,line:c});return}if(r===`reset`)return;let l=`removeSegment`in o,u=`insertSegment`in o,d=`insertSegmentFrom`in o;if(!l&&!u&&!d){e.issues.push({path:s,message:`actions.${n}: "${i}" is a "presets.<name>.root" target and can only be paired with "removeSegment", "insertSegment", or "insertSegmentFrom" (not "to"/"from"/"cycle"/bounded — those have no meaning as a tree op)`,line:c});return}let f=(r,i)=>{Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" is not a declared segment (have: ${Object.keys(t.segments).join(`, `)})${Ap(i)}`,line:c})},p=new Set(xu(Ib(t,a).node)),m=(r,i)=>{!kp.has(i)||p.has(i)||Object.prototype.hasOwnProperty.call(t.segments,i)||e.issues.push({path:s,message:`actions.${n}: ${r} "${i}" names no placement${Ap(i)}`,line:c})};`removeSegment`in o&&m(`removeSegment`,o.removeSegment),`insertSegment`in o&&f(`insertSegment`,o.insertSegment),(`insertSegment`in o||`insertSegmentFrom`in o)&&m(`anchor`,o.anchor)}const ak=`settings.`;function ok(e,t){return{...e,names:new Set([...e.names,...Object.keys(t).map(e=>ak+e)])}}function sk(e,t,n){let r=e=>`segments.${t}.settings.${e}`,i=(n,i)=>{e.issues.push({path:r(n),message:`${r(n)}: ${i}`,line:G(e.source,[`segments`,t,`settings`,n])})},a=uk(n);for(let{setting:e,message:t}of a)i(e,t);if(!(a.length>0))for(let{setting:e,message:t}of zu(n,lk(n)))i(e,`the defaults do not stand together: ${t}`)}function ck(e){return uk(e).length>0||zu(e,lk(e)).length>0}function lk(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default]))}function uk(e){let t=t=>Ru(dk(e,t))?.atLeast;return Object.keys(e).flatMap(n=>{let r=t(n);if(r===void 0)return[];if(r===n||Ru(dk(e,r))===void 0)return[{setting:n,message:`atLeast "${r}" must name another range setting of this segment (its range settings: ${fk(e,n).join(`, `)||`none`})`}];let i=[n];for(let e=r;e!==void 0;e=t(e)){if(e===n)return i.every(e=>n<=e)?[{setting:n,message:`atLeast closes a cycle (${[...i,n].join(` ≥ `)}) — every setting on it could only ever equal the rest`}]:[];if(i.includes(e))return[];i.push(e)}return[]})}function dk(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function fk(e,t){return Object.entries(e).filter(([e,n])=>e!==t&&Ru(n)!==void 0).map(([e])=>e)}function pk(e,t,n,r,i){let a=Object.prototype.hasOwnProperty.call(t.segments,n.name)?t.segments[n.name]:void 0;if(a===void 0)return;let o=Lu(a),s=`${r}: placement "${bu(n)}" of segment "${n.name}"`;for(let[t,a]of Object.entries(n.settings??{})){let c=Object.prototype.hasOwnProperty.call(o,t)?o[t]:void 0,l=c===void 0?`sets "${t}", which segment "${n.name}" does not declare (it has: ${Object.keys(o).join(`, `)})`:Bu(c,a)?void 0:`sets "${t}" to ${JSON.stringify(a)}${c.domain===`theme`?Oc(a):``}, but it must be ${Wu(c)}`;l!==void 0&&e.issues.push({path:r,message:`${s} ${l}`,line:i})}let c=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,n.settings?.[e]??t.default]));if(!(!Object.entries(c).every(([e,t])=>Bu(o[e],t))||ck(o)))for(let{message:t}of zu(o,c))e.issues.push({path:r,message:`${s}: ${t}`,line:i})}function mk(e,t,n,r,i){n.kind===`template`&&_k(e,`${t}.template`,n.template,r,{segCtx:i}),Mu(n)&&n.cache&&`key`in n.cache&&_k(e,`${t}.cache.key`,n.cache.key,r,{segCtx:i})}function hk(e,t,n,r,i){if(Mu(n)&&n.cache&&`depends_on`in n.cache)for(let a=0;a<n.cache.depends_on.length;a++){let o=n.cache.depends_on[a];if(r.names.has(o))continue;let s=i===void 0?void 0:`${i}.${o}`,c=s!==void 0&&r.names.has(s)?` (segment-local vars are namespaced — write "${s}")`:``;e.issues.push({path:`${t}.cache.depends_on[${a}]`,message:`cache.depends_on references unknown variable "${o}"${c}`,line:G(e.source,[...t.split(`.`),`cache`,`depends_on`])})}}function gk(e,t,n,r){try{Xb.parse(n)}catch(n){e.issues.push({path:t,message:`Template parse error in ${t}: ${n.message}`,line:r})}}function _k(e,t,n,r,i){for(let[a,o]of Cx(n,r.helpers)){if(Ax(a,r))continue;if(a.startsWith(ak)){let n=o===null?``:` through helper "${o}"`,r=a.slice(9),s=i?.segCtx===void 0||i.settings===void 0?`Template reads ".${a}"${n}, but only a segment's own templates have settings — call it from a segment that declares "${r}"`:`Template reads ".${a}"${n}, but segment "${i.segCtx}" has no setting "${r}" (it has: ${Object.keys(i.settings).join(`, `)}) — declare it under segments.${i.segCtx}.settings`;e.issues.push({path:t,message:s,line:i?.line??G(e.source,t.split(`.`))});continue}if(o!==null){vk(e,o,`Template references unknown variable ".${a}"${ek(a)}`);continue}let n=i?.segCtx===void 0?void 0:`${i.segCtx}.${a}`,s=n!==void 0&&Ax(n,r)?` (segment-local vars are namespaced — write ".${n}")`:ek(a);e.issues.push({path:t,message:`Template references unknown variable ".${a}"${s}`,line:i?.line??G(e.source,t.split(`.`))})}}function vk(e,t,n){let r=`helpers.${t}`;e.issues.some(e=>e.path===r&&e.message===n)||e.issues.push({path:r,message:n,line:G(e.source,[`helpers`,t])})}function yk(e,t,n,r,i){let a=n.set,o=ff(ew[r].configKey),s=`${a} takes ${kw(o,i)}`;if(`min`in n&&(o===`bool`||`from`in o)){e.issues.push({path:`actions.${t}.min`,message:`actions.${t}: a stepper writes the integers from ${n.min} to ${n.max}, and ${a} is not an integer range; ${s}`,line:G(e.source,[`actions`,t,`min`])});return}let c=Sk(n,i);if(c===xk){e.issues.push({path:`actions.${t}.int`,message:`actions.${t}.int: an int cursor writes whatever integer the template binds, and a click outside the ${a} domain would change nothing; ${s}`,line:G(e.source,[`actions`,t,`int`])});return}let l=c.filter(e=>!Ow(o,e.value,i));if(l.length!==0){if(a===ew.style.sessionKey&&(`from`in n&&n.from===`endcaps`||c.every(e=>$c(e.value)))){let r=ew.endcaps.sessionKey;e.issues.push(`to`in n?{path:`actions.${t}.to`,message:GO(`actions.${t}.to`,n.to,`set: "${r}", to`),line:G(e.source,[`actions`,t,`to`])}:{path:`actions.${t}.set`,message:`actions.${t}.set: "${a}" here writes only endcaps shapes, not styles — endcaps were renamed from "style" to "endcaps"; write set: "${r}"`,line:G(e.source,[`actions`,t,`set`])});return}for(let n of new Set(l.map(e=>e.field))){let r=l.filter(e=>e.field===n).map(e=>JSON.stringify(e.value)),i=r.length<=bk?r.join(`, `):`${r.slice(0,bk).join(`, `)} and ${r.length-bk} more`,o=`actions.${t}.${n}`;e.issues.push({path:o,message:`${o}: ${i} ${r.length===1?`is`:`are`} outside the ${a} domain — a click would write it and nothing would change; ${s}`,line:G(e.source,[`actions`,t,n])})}}}const bk=3,xk=Symbol(`any integer`);function Sk(e,t){return`to`in e?[{field:`to`,value:e.to}]:`cycle`in e?e.cycle.map(e=>({field:`cycle`,value:e})):`from`in e?Tw(e.from,t).members.map(e=>({field:`from`,value:e})):`min`in e?[{field:`min`,value:String(e.min)},{field:`max`,value:String(e.max)}]:xk}function Ck(e,t){return Object.entries(e).filter(([e])=>t(e))}function wk(e,t,n,r){let i=PD(t),a=ww(i);for(let[n,o]of Ck(t.actions,r)){let[t,r]=`from`in o?[`from`,o.from]:`insertSegmentFrom`in o?[`insertSegmentFrom`,o.insertSegmentFrom]:[null,null];if(t!==null&&typeof r==`string`&&!a.includes(r)){e.issues.push({path:`actions.${n}.${t}`,message:`actions.${n} ${t}: references ${Dw(r,i)}`,line:G(e.source,[`actions`,n,t])});continue}if(!(`set`in o))continue;rw.has(o.set)&&e.issues.push({path:`actions.${n}.set`,message:`actions.${n} sets "${o.set}", which has no session pick — globals.${o.set} is set in the config file only, so a click would change nothing; write it with { persist: "${o.set}", … } instead`,line:G(e.source,[`actions`,n,`set`])});let s=sw.get(o.set);s!==void 0&&yk(e,n,o,s,i)}for(let[n,i]of Ck(t.actions,r))`do`in i&&i.do.forEach((r,a)=>{let o=Object.prototype.hasOwnProperty.call(t.actions,r)?t.actions[r]:void 0,s=o===void 0?`references unknown action "${r}"`:`do`in o?`"${r}" is itself a do action — list its members here instead`:i.do.indexOf(r)===a?a>0&&tO(o)?`"${r}" takes its value from the template (from/int/insertSegmentFrom), so it can only be the first member — only the first is bound the region's display`:void 0:`"${r}" is listed twice — each member fires once per click`;s!==void 0&&e.issues.push({path:`actions.${n}.do`,message:`actions.${n} do: ${s}`,line:G(e.source,[`actions`,n,`do`])})});for(let[n,i]of Ck(t.actions,r)){let r=`persist`in i?i.persist:`reset`in i?i.reset:null;if(r===null)continue;let a=`persist`in i?`persist`:`reset`,o=Hw(r);if(o===null){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is not a config globals field (have: ${Mf().join(`, `)}), a "segments.<name>.palette" target, a "presets.<name>.globals.<field>" target, a "themeDefaults.<theme>.<shade|variation|style>" target, or a "presets.<name>.root" target`,line:G(e.source,[`actions`,n,a])});continue}let s=rk.filter(e=>e in i);if(o.scope!==`preset-root`&&s.length>0){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is not a "presets.<name>.root" target — ${s.map(e=>`"${e}"`).join(`/`)} is a tree op and applies only to one`,line:G(e.source,[`actions`,n,a])});continue}if(o.scope===`preset-root`){ik(e,t,n,a,r,o.preset,i);continue}if(o.scope===`preset-globals`&&!Nb(t.presets).includes(o.preset)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names preset "${o.preset}" which is not declared (have: ${Nb(t.presets).join(`, `)})`,line:G(e.source,[`actions`,n,a])});continue}if(o.scope===`theme-default`&&!e.allowedPalettes.has(o.theme)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names theme "${o.theme}" which is not installed${Oc(o.theme)} (have: ${[...e.allowedPalettes].sort().join(`, `)})`,line:G(e.source,[`actions`,n,a])});continue}if(o.scope===`segment-palette`){if(!Object.prototype.hasOwnProperty.call(t.segments,o.segment)){e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" names segment "${o.segment}" which is not declared (have segments: ${Object.keys(t.segments).join(`, `)})${Ap(o.segment)}`,line:G(e.source,[`actions`,n,a])});continue}`min`in i&&e.issues.push({path:`actions.${n}.${a}`,message:`actions.${n}: "${r}" is a segment palette target and cannot use a bounded stepper (min/max/by) — use "to", "from", or "cycle" instead`,line:G(e.source,[`actions`,n,a])})}}for(let[i,a]of Ck(t.variables,r)){mk(e,`variables.${i}`,a,n);let t=$O(i);t!==void 0&&e.issues.push({path:`variables.${i}`,message:t,line:G(e.source,[`variables`,i])})}for(let[i,a]of Ck(t.segments,r)){if(a.vars)for(let[t,r]of Object.entries(a.vars))mk(e,`segments.${i}.vars.${t}`,r,n,i);let r=Lu(a);sk(e,i,r);let o=ok(n,r);for(let n of[`template`,`bg`,`fg`,`when`]){let s=a[n];if(typeof s==`string`){_k(e,`segments.${i}.${n}`,s,o,{segCtx:i,settings:r});for(let{name:r,site:a,via:o}of Dx(s,t.helpers)){if(Object.prototype.hasOwnProperty.call(t.actions,r))continue;let s=a===`options`?` (in a picker, menu or carousel)`:``;if(o!==null){vk(e,o,`Template references unknown action "${r}"${s}`);continue}e.issues.push({path:`segments.${i}.${n}`,message:`${n} references unknown action "${r}"${s}`,line:G(e.source,[`segments`,i,n])})}}}}for(let[i,a]of Ck(t.variables,r))hk(e,`variables.${i}`,a,n);for(let[i,a]of Ck(t.segments,r))if(a.vars)for(let[t,r]of Object.entries(a.vars))hk(e,`segments.${i}.vars.${t}`,r,n,i)}function Tk(e,t){let n=new Set;for(let r of Nb(t.presets)){let i=Lb(t,r),a=[{},t.editGlobals];for(let o of a){let a=o.charset??i.charset??`unicode`,s=o.default_separator??i.default_separator;if(a!==`ascii`||nl(s??``))continue;let c=o.default_separator===void 0?Fb(t.presets,r).globals?.default_separator===void 0?[`globals`]:[`presets`,r,`globals`]:[`editGlobals`],l=[...c,`default_separator`].join(`.`);n.has(l)||(n.add(l),e.issues.push({path:l,message:`${l} ${JSON.stringify(s)} is not ASCII, but charset is "ascii" — under ascii a joiner draws only ASCII; write an ASCII separator or set charset: "unicode"`,line:G(e.source,[...c,`default_separator`])}))}}}function Ek(e,t,n=()=>!0){let{graph:r,nodeInfo:i}=Dk(t),a=new Map,o=[];for(let e of r.keys())a.set(e,0);for(let e of r.keys())if(!(!n(e)||a.get(e)!==0)&&s(e))return;function s(t){a.set(t,1),o.push(t);for(let c of r.get(t)??[]){if(!n(c))continue;let t=a.get(c);if(t===1){let t=o.indexOf(c),n=[...o.slice(t),c],r=n[0],a=i.get(r);return e.issues.push({path:a?.declarationPath??`variables.${r}`,message:`Dependency cycle: ${n.join(` → `)}`,line:G(e.source,a?.linePathParts??[`variables`,r])}),!0}if(t===0&&s(c))return!0}return a.set(t,2),o.pop(),!1}}function Dk(e){let t=new Set(Object.keys(e.variables)),n=new Map;for(let t of Object.keys(e.variables))n.set(t,{declarationPath:`variables.${t}`,linePathParts:[`variables`,t]});for(let[r,i]of Object.entries(e.segments))if(i.vars)for(let e of Object.keys(i.vars)){let i=`${r}.${e}`;t.add(i),n.set(i,{declarationPath:`segments.${r}.vars.${e}`,linePathParts:[`segments`,r,`vars`,e]})}let r=new Map;for(let e of t)r.set(e,new Set);let i=(n,i)=>{for(let a of Cx(i,e.helpers).keys()){if(t.has(a)){r.get(n).add(a);continue}let e=a.split(`.`)[0];e!==a&&t.has(e)&&r.get(n).add(e)}},a=(e,n)=>{if(n.kind===`template`&&i(e,n.template),Mu(n)&&(n.cache&&`key`in n.cache&&i(e,n.cache.key),n.cache&&`depends_on`in n.cache))for(let i of n.cache.depends_on)t.has(i)&&r.get(e).add(i)};for(let[t,n]of Object.entries(e.variables))a(t,n);for(let[t,n]of Object.entries(e.segments))if(n.vars)for(let[e,r]of Object.entries(n.vars))a(`${t}.${e}`,r);return{graph:r,nodeInfo:n}}const Ok=[`json5`,`json`];function kk(e){try{return r.statSync(e,{throwIfNoEntry:!1})===void 0?`absent`:`present`}catch(t){return{path:e,error:t.message}}}function Ak(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)?h.homedir()+e.slice(1):e}function jk(e,t,n){if(n!==void 0)return[n];let r=t??process.cwd();return[...new Set([...e?Ok.map(t=>l.join(e,`.cc-candybar.${t}`)):[],...Ok.map(e=>l.join(r,`.cc-candybar.${e}`)),...Ok.map(e=>`${Mk()}.${e}`)])]}function Mk(){let e=process.env.XDG_CONFIG_HOME??l.join(h.homedir(),`.config`);return l.join(e,`cc-candybar`,`config`)}function Nk(e,t,n){let i=[],a=new Map;for(let o of jk(e,t,n)){let e=kk(o);if(e===`absent`)continue;if(e!==`present`){i.push(e);continue}let t=l.join(r.realpathSync(l.dirname(o)),l.basename(o).replace(/\.(json5|json)$/,``));a.has(t)||a.set(t,o)}let o=[...a.values()].reverse();if(n===void 0)return{kind:`chain`,layers:o,home:Pk(o),unchecked:i};let[s]=i,c=n;return o.length>0?{kind:`chain`,layers:o,home:c,unchecked:i}:s===void 0?{kind:`missing`,path:n,home:c}:{kind:`unreadable`,...s,home:c}}function Pk(e){let t=Mk();return e.find(e=>Ok.some(n=>e===`${t}.${n}`))??`${t}.${Ok[0]}`}function Fk(e,t,n){let r=Nk(e,t,n),i=r.kind===`chain`?r.layers:[];return{path:r.home,above:i.filter(e=>e!==r.home),projectDir:e??null,cwd:t??null}}function Ik(e){return Lk(e).join(`
|
|
165
165
|
`)||null}function Lk(e){switch(e.kind){case`chain`:return e.unchecked.map(e=>`Config location could not be checked: ${e.path} — ${e.error}`);case`missing`:return[`Config file not found: ${e.path} — rendering the bundled default until it appears`];case`unreadable`:return[`Config file could not be read: ${e.path} — ${e.error} — rendering the bundled default until it can be`]}}function Rk(e,t){let n=jk(e,t).filter(e=>kk(e)===`present`),r=new Map;for(let e of n){let t=l.dirname(e),n=l.basename(e).replace(/\.(json5|json)$/,``),i=l.join(t,n);r.has(i)||r.set(i,[]),r.get(i).push(e)}let i=[...r.values()].filter(e=>e.length>1);return i.length===0?null:`config-extension collision: ${i.map(e=>{let[t,...n]=e;return`${t} shadows ${n.join(`, `)}`}).join(`; `)} — remove the duplicate`}function zk(e){return`plugin ${e.path} was not loaded: ${e.reason}`}const Bk=new Set([`data`,`segments`,`helpers`,`actions`]),Vk=`plugin.json5`,Hk=/^[a-z][a-z0-9_]*$/;function Uk(e){let t=l.basename(l.dirname(e));return Hk.test(t)?t:void 0}const Wk=`plugins.`;function Gk(e){return`${Wk}${e}.data`}function Kk(e){try{return{ok:!0,value:e()}}catch(e){return{ok:!1,reason:qk(e)}}}function qk(e){return e instanceof pu?e.issues.map(e=>e.path===``||e.message.includes(e.path)?e.message:`${e.path}: ${e.message}`).join(`; `):e instanceof Error?e.message:String(e)}function Jk(e,t){return e.map(e=>l.resolve(l.dirname(t),Ak(e)))}function Yk(e,t,n,i){let a=new Map;return e.reduce((e,n)=>{let o=Uk(n),s=(t,r)=>{let i=new Map(e.rendering);return o!==void 0&&r!==e.config&&i.delete(o),{...e,config:r,rendering:i,dropped:[...e.dropped,{path:n,plugin:o,reason:t}]}};if(l.basename(n)!==`plugin.json5`){let t=`a plugin is a folder holding its ${Vk}, and the folder's name is the plugin's: move this file to <dir>/<name>/${Vk} and list that`;return s(t,o===void 0?e.config:Qk(Zk(e.config,o),o,{path:n,plugin:o,reason:t}))}if(o===void 0)return s(`its folder "${l.basename(l.dirname(n))}" is not a plugin name (one matching ${Hk}: it prefixes every name the plugin declares)`,e.config);let c=a.get(o);if(c!==void 0)return s(`plugin "${o}" is already listed, from ${c}`,e.config);a.set(o,n);let u=Zk(e.config,o),d=Kk(()=>{let a=r.readFileSync(n,`utf-8`),s=Id(iA(n,o,{source:a,json:at.default.parse(a)},t),u);return i(s,o,u!==e.config),s});if(d.ok)return{...e,config:d.value,loaded:[...e.loaded,n],rendering:new Map([...e.rendering,[o,n]])};let f={path:n,plugin:o,reason:d.reason};return s(d.reason,Qk(u,o,f))},{config:n.config,rendering:n.rendering,loaded:[],dropped:[]})}function Xk(e){let t=`${Wk}${e}.`;return e=>e.startsWith(t)}function Zk(e,t){let n=Xk(t),r=e=>Object.fromEntries(Object.entries(e).filter(([e])=>!n(e)));return[e.variables,e.segments,e.helpers,e.actions].some(e=>Object.keys(e).some(n))?{...e,variables:r(e.variables),segments:r(e.segments),helpers:r(e.helpers),actions:r(e.actions)}:e}function Qk(e,t,n){return{...e,variables:{...e.variables,[Gk(t)]:{kind:`dropped`,reason:zk(n),definition:n.path}}}}function $k(e){return e.startsWith(`plugins.`)?e.slice(8).split(`.`)[0]:void 0}function eA(e,t){let n=new Set([...Object.keys(e.config.variables),...Object.keys(e.config.segments)].map($k)),r=[...t,...e.dropped].filter(e=>e.plugin===void 0).map(e=>({definition:e.path,notice:zk(e)}));return t=>{let i=$k(t);if(i===void 0)return[];let a=e.config.variables[Gk(i)];return a?.kind===`dropped`?[{definition:a.definition,notice:a.reason}]:n.has(i)?[]:r}}function tA(e,t){let n=Nb(e.presets).flatMap(t=>[...wu(Ib(e,t).node)]).flatMap(e=>e.kind===`segment`?[e]:[]),r=[...new Set([...n.map(e=>e.name),...Object.keys(e.segments)])].map(e=>({name:e,cause:t(e)})).filter(({cause:e})=>e.length>0),i=Object.fromEntries(r.map(({name:e,cause:t})=>[e,nA(e,t.map(e=>e.notice),n.filter(t=>t.name===e))])),a=t=>{let n=$k(t),r=n===void 0?void 0:e.variables[Gk(n)];return r?.kind===`dropped`?{definition:r.definition,notice:r.reason}:void 0},o=Object.values(e.variables).some(e=>e.kind===`dropped`),s=o?Object.values(e.segments).flatMap(e=>[`template`,`bg`,`fg`,`when`].flatMap(t=>e[t]===void 0?[]:[e[t]])):[],c=o?Object.values(e.actions).flatMap(e=>`do`in e?[...e.do]:[]):[],l=(e,t)=>[...new Set(e)].flatMap(e=>{let n=e in t?void 0:a(e);return n===void 0?[]:[[e,n]]}),u=l([...s.flatMap(t=>Dx(t,e.helpers).map(e=>e.name)),...c],e.actions),d=l(s.flatMap(t=>[...kx(t,e.helpers)]),e.helpers),f=new Set([...r.flatMap(({cause:e})=>e.map(e=>e.definition)),...[...u,...d].map(([,e])=>e.definition)]);return{config:{...e,segments:{...e.segments,...i},actions:{...e.actions,...Object.fromEntries(u.map(([e])=>[e,{copy:`{{ .${Gk($k(e)??``)} }}`}]))},helpers:{...e.helpers,...Object.fromEntries(d.map(([e,t])=>[e,`{{ fail ${JSON.stringify(t.notice)} }}`]))}},reached:f}}function nA(e,t,n){let r=`⚠ ${e}: ${t.join(`; `)}`,i=new Map;for(let e of n)for(let[t,n]of Object.entries(e.settings??{})){let e=i.get(t);i.set(t,e===void 0?[n]:[...e,n])}let a=Object.fromEntries([...i].map(([e,t])=>[e,rA(e,t)]));return{template:`{{ ${JSON.stringify(r)} }}`,bg:`error`,description:`stands in for a segment whose plugin did not load`,settings:a}}function rA(e,t){let[n]=t,r=t.filter(e=>typeof e==`number`);return typeof n==`boolean`?{label:e,domain:`bool`,default:n}:typeof n==`number`?{label:e,domain:{min:Math.min(...r),max:Math.max(...r),step:1},default:n}:{label:e,domain:[...new Set(t.map(String))],default:n}}function iA(e,t,{source:n,json:r},{checkout:i}){let a=[],o=()=>{throw new pu(e,a)};if(!Qu(r))return a.push({path:``,message:`a plugin definition must be an object, got ${$u(r)}`}),o();for(let e of Object.keys(r))Bk.has(e)||a.push({path:e,message:e===`plugin`?`a plugin definition does not name itself: its name is its folder's ("${t}") — remove "plugin"`:`a plugin definition may not declare "${e}". Expected only: ${[...Bk].join(`, `)}`});let s=sA(r.data,e,i,a);if(Qu(r.segments)||a.push({path:`segments`,message:`"segments" must be an object naming the plugin's segments`}),a.length>0||s===void 0)return o();let c={source:n,issues:a,allowedPalettes:new Set(jc()),groups:[]},l=Wf(c,`data`,{[Gk(t)]:{kind:`file`,path:s,parse:{json:!0},cache:{watch_file:s},default:{}}});for(let[e,t]of Object.entries(r.segments))Qu(t)&&`vars`in t&&a.push({path:`segments.${e}.vars`,message:`a plugin segment may not declare "vars": a plugin's only source is its data file`});let u={variables:l,segments:oA(t,Jp(c,r.segments,new Set)),helpers:oA(t,XO(c,r.helpers)),actions:oA(t,nO(c,r.actions))};for(let[e,t]of aA(u))try{Xb.parse(t)}catch(t){a.push({path:e,message:`Template parse error in ${e}: ${t.message}`})}return a.length>0&&o(),u}function*aA(e){for(let[t,n]of Object.entries(e.segments??{}))for(let e of[`template`,`bg`,`fg`,`when`]){let r=n[e];r!==void 0&&(yield[`segments.${t}.${e}`,r])}for(let[t,n]of Object.entries(e.helpers??{}))yield[`helpers.${t}`,`{{ define "${t}" }}${n}{{ end }}`];for(let[t,n]of Object.entries(e.actions??{}))`copy`in n&&(yield[`actions.${t}.copy`,n.copy]),`open`in n&&(yield[`actions.${t}.open`,n.open]),`preset`in n&&n.preset===`delete`&&(yield[`actions.${t}.name`,n.name])}function oA(e,t){return Object.fromEntries(Object.entries(t).map(([t,n])=>[`${Wk}${e}.${t}`,n]))}function sA(e,t,n,r){if(typeof e==`string`&&e!==``)return l.resolve(l.dirname(t),Ak(e));if(Qu(e)&&Object.keys(e).length===1&&typeof e.checkout==`string`&&e.checkout!==``){let t=e.checkout;if(l.isAbsolute(t)||t.startsWith(`~`)||l.normalize(t).split(l.sep)[0]===`..`){r.push({path:`data.checkout`,message:`data.checkout "${t}" must be a path inside the checkout, relative to its root (like ".lit/statusline.json"): no absolute path, "~" or ".."`});return}if(n===null){r.push({path:`data.checkout`,message:`data is read from the session's checkout, and this load has no session`});return}return l.resolve(n.root,t)}if(Qu(e)&&`project`in e){r.push({path:`data.project`,message:`data: { project } is now data: { checkout }: the same path, relative to the root of the git checkout the session works in (a linked worktree is its own checkout)`});return}r.push({path:`data`,message:`"data" must be the path of the plugin's JSON data file relative to this definition, or { checkout: "<path>" } relative to the root of the session's checkout`})}function cA(e){let t=(process.env.XDG_DATA_DIRS||lA()).split(`:`).filter(e=>e!==``),n=process.env.XDG_DATA_HOME||l.join(h.homedir(),`.local`,`share`),r=[...[...t].reverse().map(e=>l.join(e,`cc-candybar`,`plugins`)),l.join(n,`cc-candybar`,`plugins`),...e===null?[]:[l.join(e,`.cc-candybar`,`plugins`)]];return r.filter((e,t)=>r.lastIndexOf(e)===t)}function lA(){let e=`/usr/local/share:/usr/share`;return process.platform===`darwin`?`${l.join(process.env.HOMEBREW_PREFIX||`/opt/homebrew`,`share`)}:${e}`:e}function uA(e){let t=cA(e),n=new Map,r=[],i=[];for(let e of t){let t=dA(e);if(`error`in t){r.push(t);continue}for(let r of t.folders)n.delete(r),n.set(r,l.join(e,r,Vk));for(let n of t.files)i.push({path:l.join(e,n),plugin:void 0,reason:`a plugin is a folder holding its ${Vk}: move this file to ${l.join(e,`<name>`,Vk)}`})}return{roots:t,definitions:[...n.values()],unchecked:r,strays:i}}function dA(e){try{let t=r.readdirSync(e,{withFileTypes:!0}).filter(e=>!e.name.startsWith(`.`)).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)),n=t=>t.isDirectory()||fA(e,t);return{folders:t.filter(n).map(e=>e.name),files:t.filter(e=>!n(e)).map(e=>e.name)}}catch(t){return t.code===`ENOENT`?{folders:[],files:[]}:{path:e,error:t.message}}}function fA(e,t){if(!t.isSymbolicLink())return!1;try{return r.statSync(l.join(e,t.name)).isDirectory()}catch{return!0}}function pA(e,t,n,i){return e===null?{...SA,config:Id(SA.raw,t)}:hA(e,r.readFileSync(e,`utf-8`),t,n,i)}const mA={projectDir:null,checkout:null,beneath:{dropped:[],rendering:new Map}};function hA(e,t,n,r,i){let a=TA(e,t,i,(t,a)=>{let o=Yk(Jk(t,e),r,{config:n,rendering:r.beneath.rendering},(t,n,r)=>bA(t,n,r,e,i)),s=eA(o,r.beneath.dropped);return{inherited:new Set([...qp(o.config),...a.filter(e=>s(e).length>0)]),layer:{plugins:o,owning:s}}}),{plugins:o,owning:s}=a.layer,c=tA(Id(a.raw,o.config),s);return{source:t,raw:a.raw,warnings:[...a.warnings,...o.dropped.map(zk)],plugins:{loaded:o.loaded,dropped:o.dropped,reached:c.reached,rendering:o.rendering},config:c.config}}const gA=new WeakMap;function _A(e,t,n,r){let i=JSON.stringify([[...r??[]].sort(),e.map(e=>[e,vA(e)])]),a=gA.get(n)??new Map;gA.set(n,a);let o=JSON.stringify([t.projectDir,t.checkout?.root??null]),s=a.get(o);if(s?.key===i)return s.layer;let c=Yk(e,t,{config:n,rendering:new Map},(e,t,n)=>bA(e,t,n,`<installed plugins>`,r));return a.set(o,{key:i,layer:c}),c}function vA(e){try{let t=r.statSync(e);return`${t.ino}:${t.size}:${t.mtimeMs}`}catch(e){return e.code??`unreadable`}}function yA(e,t,n,i,a=e=>r.readFileSync(e,`utf-8`),o){let s={projectDir:i.projectDir,checkout:i.cwd===null?null:BS(i.cwd)},c=uA(s.projectDir),l=_A(c.definitions,s,t,o),u={...l,dropped:[...l.dropped,...c.strays]};n.warned(c.unchecked.map(e=>`Plugin folder could not be listed: ${e.path} — ${e.error}`));let d=u.config,f=[];for(let t of e){n.entered(t);let e=f.at(-1)?.plugins,r=hA(t,a(t),f.at(-1)?.config??d,{...s,beneath:{dropped:[...u.dropped,...f.flatMap(e=>e.plugins.dropped)],rendering:e?.rendering??u.rendering}},o);n.warned(r.warnings),f.push({...r,path:t})}let p=new Set(f.flatMap(e=>[...e.plugins.reached])),m=e=>p.has(e.path),h=u.dropped.filter(m),g=u.dropped.filter(e=>!m(e));n.warned(h.map(zk));let _={checkout:s.checkout,roots:c.roots,loaded:u.loaded,dropped:h,unreached:g,reached:p,rendering:f.at(-1)?.plugins.rendering??u.rendering},v=f.at(-1);if(v===void 0)return{layers:f,base:d,installed:_,config:CA(pA(null,d,mA),`<default>`,o)};try{return{layers:f,base:d,installed:_,config:CA(v,v.path,o)}}catch(e){for(let e of f.slice(0,-1))n.entered(e.path),CA(e,e.path,o);throw n.entered(v.path),e}}function bA(e,t,n,r,i){if(n){CA(xA(e),r,i);return}let a=Xk(t),o=[],s={source:``,issues:o,allowedPalettes:new Set,groups:[]};if(wk(s,e,jx(e),a),Ek(s,e,a),o.length>0)throw new pu(r,o)}function xA(e){return{config:e,raw:{root:e.root,presets:e.presets},source:``}}const SA={raw:{},source:``,warnings:[],plugins:{loaded:[],dropped:[],reached:new Set,rendering:new Map}};function CA({config:e,raw:t,source:n},r=`<config>`,i=new Set(jc())){let a=[],o={source:n,issues:a,allowedPalettes:i,groups:[]};if(nk(o,e,t),Ek(o,e),a.length>0)throw new pu(r,a);let s=Yb(e,a);if(a.length>0)throw new pu(r,a);return QD(vD(s))}function wA(e,t,n=new Set(jc()),r=EA){return TA(e,t,n,()=>({inherited:r,layer:null})).raw}function TA(e,t,n,r){let i=DA(e,t),a=gu(e,t),o=a===null?[]:[a],s=[],c={source:t,issues:s,allowedPalettes:n??new Set(jc()),groups:[]};if(!Qu(i))throw new pu(e,[{path:``,message:`Config root must be an object, got ${$u(i)}`}],o);let{inherited:l,layer:u}=r(i.plugins===void 0?[]:AA({...c,issues:[]},i.plugins)??[],Qu(i.segments)?Object.keys(i.segments):[]),d=OA(c,i,l);if(s.length>0)throw new pu(e,s,o);return{raw:d,warnings:o,layer:u}}const EA=new Set;function DA(e,t){try{return at.default.parse(t)}catch(t){let n=t;throw new pu(e,[{path:``,message:`JSON5 syntax error: ${n.message}`,line:n.lineNumber,col:n.columnNumber}])}}function OA(e,t,n){for(let n of Object.keys(t))kA.has(n)||e.issues.push({path:n,message:`Unknown top-level key "${n}". Expected one of: ${[...kA].join(`, `)}`,line:G(e.source,[n])});let r={};return t.globals!==void 0&&(r.globals=Ef(e,`globals`,t.globals)),t.variables!==void 0&&(r.variables=Wf(e,`variables`,t.variables)),t.segments!==void 0&&(r.segments=Jp(e,t.segments,n)),t.layout!==void 0&&e.issues.push({path:`layout`,message:`"layout" is no longer supported — use "root" with the A-grammar instead.
|
|
166
166
|
Replace: layout: [["seg1", "seg2"], ["seg3"]]
|
|
167
167
|
With: root: { v: [{ h: ["seg1", "seg2"] }, "seg3"] }
|
|
168
|
-
Single-row example: root: { h: ["seg1", "seg2"] }`,line:G(e.source,[`layout`])}),t.root!==void 0&&(r.root=_m(e,`root`,t.root)),t.actions!==void 0&&(r.actions=nO(e,t.actions)),t.looks!==void 0&&e.issues.push({path:`looks`,message:`"looks" was renamed "styles" — move the block under styles: { … } (and globals.look to globals.style)`,line:G(e.source,[`looks`])}),t.styles!==void 0&&(r.styles=qO(e,t.styles)),t.themeDefaults!==void 0&&(r.themeDefaults=Tf(e,t.themeDefaults)),t.presets!==void 0&&(r.presets=YO(e,t.presets)),t.editGlobals!==void 0&&(r.editGlobals=kf(e,`editGlobals`,t.editGlobals)),t.helpers!==void 0&&(r.helpers=XO(e,t.helpers)),t.plugins!==void 0&&(r.plugins=AA(e,t.plugins)),Tm(e,r),qb(e,r),lx(e,r),Op(e,r,wp,`the global settings menu`),r}const kA=new Set([`globals`,`variables`,`segments`,`layout`,`looks`,`root`,`actions`,`styles`,`themeDefaults`,`presets`,`editGlobals`,`helpers`,`plugins`]);function AA(e,t){if(Array.isArray(t)&&t.every(e=>typeof e==`string`&&e!==``))return t;e.issues.push({path:`plugins`,message:`"plugins" must be a list of plugin definition paths, got ${$u(t)}`,line:G(e.source,[`plugins`])})}function jA(e){let t=LA(e.termCols),n=LA(e.termRows),r=RA(e.ssh),i=FA(e.tmux),a=PA(e.configEnv),o=NA(e.claudeConfigDir),s=MA(e.mementoEnv);return{...t!==void 0&&{termCols:t},...n!==void 0&&{termRows:n},...r!==void 0&&{ssh:r},...i!==void 0&&{tmux:i},...a!==void 0&&{configEnv:a},...o!==void 0&&{claudeConfigDir:o},...s!==void 0&&{mementoEnv:s}}}function MA(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=$e.filter(e=>t[e]!==void 0);return n.every(e=>NA(t[e])!==void 0)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function NA(e){return typeof e==`string`&&l.isAbsolute(e)?e:void 0}function PA(e){return typeof e==`string`&&e!==``?Ak(e):void 0}function FA(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 IA=1e4;function LA(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>IA?IA:t}function RA(e){return typeof e==`boolean`?e:void 0}function zA(e){return typeof e==`string`&&e!==``&&e.length<=64?e:null}var BA=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function VA(e){let t=Buffer.from(JSON.stringify(e),`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function HA(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 BA(`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 BA(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function UA(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=HA(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(VA(t))})}async function WA(e,t,n){let r=null;try{r=await YA(ze(),t.connectMs);let i=await UA(r,{v:3,...e},t.budgetMs);return qA(e.kind,i,n)}catch(e){return JA(e)}finally{r&&r.destroy()}}function GA(e,t){return typeof e==`string`?e:t}function KA(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function qA(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=GA(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:KA(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 JA(e){if(e instanceof BA||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 YA(e,t){return new Promise((n,r)=>{let i=x.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 XA(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 ZA=`1.129.
|
|
168
|
+
Single-row example: root: { h: ["seg1", "seg2"] }`,line:G(e.source,[`layout`])}),t.root!==void 0&&(r.root=_m(e,`root`,t.root)),t.actions!==void 0&&(r.actions=nO(e,t.actions)),t.looks!==void 0&&e.issues.push({path:`looks`,message:`"looks" was renamed "styles" — move the block under styles: { … } (and globals.look to globals.style)`,line:G(e.source,[`looks`])}),t.styles!==void 0&&(r.styles=qO(e,t.styles)),t.themeDefaults!==void 0&&(r.themeDefaults=Tf(e,t.themeDefaults)),t.presets!==void 0&&(r.presets=YO(e,t.presets)),t.editGlobals!==void 0&&(r.editGlobals=kf(e,`editGlobals`,t.editGlobals)),t.helpers!==void 0&&(r.helpers=XO(e,t.helpers)),t.plugins!==void 0&&(r.plugins=AA(e,t.plugins)),Tm(e,r),qb(e,r),lx(e,r),Op(e,r,wp,`the global settings menu`),r}const kA=new Set([`globals`,`variables`,`segments`,`layout`,`looks`,`root`,`actions`,`styles`,`themeDefaults`,`presets`,`editGlobals`,`helpers`,`plugins`]);function AA(e,t){if(Array.isArray(t)&&t.every(e=>typeof e==`string`&&e!==``))return t;e.issues.push({path:`plugins`,message:`"plugins" must be a list of plugin definition paths, got ${$u(t)}`,line:G(e.source,[`plugins`])})}function jA(e){let t=LA(e.termCols),n=LA(e.termRows),r=RA(e.ssh),i=FA(e.tmux),a=PA(e.configEnv),o=NA(e.claudeConfigDir),s=MA(e.mementoEnv);return{...t!==void 0&&{termCols:t},...n!==void 0&&{termRows:n},...r!==void 0&&{ssh:r},...i!==void 0&&{tmux:i},...a!==void 0&&{configEnv:a},...o!==void 0&&{claudeConfigDir:o},...s!==void 0&&{mementoEnv:s}}}function MA(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=$e.filter(e=>t[e]!==void 0);return n.every(e=>NA(t[e])!==void 0)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function NA(e){return typeof e==`string`&&l.isAbsolute(e)?e:void 0}function PA(e){return typeof e==`string`&&e!==``?Ak(e):void 0}function FA(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 IA=1e4;function LA(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>IA?IA:t}function RA(e){return typeof e==`boolean`?e:void 0}function zA(e){return typeof e==`string`&&e!==``&&e.length<=64?e:null}var BA=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function VA(e){let t=Buffer.from(JSON.stringify(e),`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function HA(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 BA(`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 BA(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function UA(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=HA(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(VA(t))})}async function WA(e,t,n){let r=null;try{r=await YA(ze(),t.connectMs);let i=await UA(r,{v:3,...e},t.budgetMs);return qA(e.kind,i,n)}catch(e){return JA(e)}finally{r&&r.destroy()}}function GA(e,t){return typeof e==`string`?e:t}function KA(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function qA(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=GA(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:KA(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 JA(e){if(e instanceof BA||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 YA(e,t){return new Promise((n,r)=>{let i=x.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 XA(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 ZA=`1.129.1`,QA={connectMs:50,budgetMs:150},$A={connectMs:50,budgetMs:200};function ej(e){let t=e.output;return typeof t==`string`?t:void 0}function tj(e,t,n,r){return WA({kind:`render`,hookData:e,args:t,cwd:n,...r},QA,ej)}function nj(e,t){return WA({kind:`click`,verb:e,value:t,clientVersion:ZA},$A,ej)}function rj(e){let t=[];for(let n of e){let e=n.read();if(e.kind===`text`)return`# memory report from: ${n.name}\n${e.text}`;t.push(`# ${n.name}: unavailable — ${e.reason}`)}return[`# memory report: no probe answered`,...t.length>0?t:[`# no probe is known for this platform`]].join(`
|
|
169
169
|
`)}function ij(e,t){return e===`darwin`?[aj(`footprint`,[`-p`,String(t)]),aj(`vmmap`,[`--summary`,String(t)])]:e===`linux`?[oj(`/proc/self/smaps_rollup`),oj(`/proc/self/status`)]:[]}function aj(e,t){return{name:`${e} ${t.join(` `)}`,read:()=>{let n=O({bin:e,args:[...t],timeoutMs:5e3,category:`limits.memory-report`});return n.ok?n.stdout.trim().length>0?{kind:`text`,text:n.stdout}:{kind:`unavailable`,reason:`exited 0 but printed nothing`}:{kind:`unavailable`,reason:`${n.reason}${n.error===void 0?``:`: ${n.error}`}${sj(n.stderr)}`}}}}function oj(e){return{name:e,read:()=>{try{let t=r.readFileSync(e,`utf8`);return t.trim().length>0?{kind:`text`,text:t}:{kind:`unavailable`,reason:`empty file`}}catch(e){return{kind:`unavailable`,reason:e.message}}}}}function sj(e){let t=e.split(`
|
|
170
170
|
`).map(e=>e.trim()).find(e=>e.length>0);return t===void 0?``:` (${t})`}const cj=`CC_CANDYBAR_RSS_LIMIT_MB`;function lj(e){let t=e[cj];if(t===void 0)return 512;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${cj} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function uj(e){return lj(e)*2}const dj=1024*1024;function fj(e){return lj(e)*dj}const pj={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function mj(e,t,n){let{prefix:r,suffix:i}=pj[t];return l.join(e,`${r}${n}${i}`)}function hj(e){for(let t of Object.keys(pj)){let{prefix:n,suffix:r}=pj[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function gj(e){let t=e.rssLimitBytes??512*dj,n=e.snapshotsKeep??3,r=!1;function i(){if(r)return!0;let{rss:i,heapTotal:a}=e.memoryBytes();if(i<=t)return!1;r=!0,e.log(`warn`,`RSS ${i} > limit ${t} (v8 heap ${a}); recording memory then shutting down`);let o=`${new Date(e.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return _j(e.log,`memory report`,()=>{let t=mj(e.snapshotDir,`memoryReport`,o);e.writeMemoryReport(t,e.captureMemoryReport()),e.log(`info`,`memory report written: ${t}`)}),_j(e.log,`heap snapshot`,()=>{let t=mj(e.snapshotDir,`heapSnapshot`,o);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),_j(e.log,`artifact rotation`,()=>{yj(e.listArtifacts(),n,e.removeFile)}),e.shutdown(0),!0}function a(){let{rss:n,heapTotal:r}=e.memoryBytes();return n>t*.75?`rss ${n} approaching limit ${t} (v8 heap ${r})`:null}function o(e=6e4){let t=setInterval(()=>{i()},e);return t.unref(),{disarm:()=>clearInterval(t)}}return{checkRss:i,describeNextRestart:a,arm:o}}function _j(e,t,n){try{n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function vj(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=hj(t);if(n===null)return t;let{prefix:r,suffix:i}=pj[n];return t.slice(r.length,t.length-i.length)}function yj(e,t,n){let r=new Map;for(let t of e){let e=vj(t),n=r.get(e);n===void 0?r.set(e,[t]):n.push(t)}let i=[...r.keys()].sort((e,t)=>t.localeCompare(e));for(let e of i.slice(t))for(let t of r.get(e)??[])try{n(t)}catch{}}function bj(e,t,n={}){let i=Re();return{now:()=>Date.now(),pid:process.pid,snapshotDir:i,log:Z,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},captureMemoryReport:()=>rj(ij(process.platform,process.pid)),writeMemoryReport:(e,t)=>r.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>re.writeHeapSnapshot(e),listArtifacts:()=>{try{return r.readdirSync(i).filter(e=>hj(e)!==null).map(e=>l.join(i,e))}catch{return[]}},removeFile:e=>r.unlinkSync(e),shutdown:t,startedAtMs:e,...n}}function xj(e={}){if(Lj()!==null)return;let n=e.spawn??Rj,r=Pj();if(r.kind===`contended`){let e=Cj();e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),Sj(n));return}if(r.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${r.reason}) — spawning unlocked\n`),Sj(n);return}try{Sj(n)}finally{Ij()}}function Sj(e){Aj()&&wj(e)}function Cj(){try{let e=r.statSync(Je());return Date.now()-e.mtimeMs}catch{return null}}function wj(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
|
|
171
171
|
`)}catch(e){t.stderr.write(`cc-candybar: daemon spawn failed: ${e.message}\n`)}}function Tj(e,t){return e===null?{kind:`allow`}:e<-1e4?{kind:`allow-future-garbage`,futureMs:-e}:e<t?{kind:`deny`}:{kind:`allow`}}function Ej(e){return Math.min(3e3*2**Math.min(Math.max(e,0),5),6e4)}function Dj(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 Oj(e,n){try{r.mkdirSync(l.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 kj(){try{r.unlinkSync(Xe())}catch(e){e.code!==`ENOENT`&&t.stderr.write(`cc-candybar: could not reset spawn.backoff: ${e.message}\n`)}}function Aj(){let e=Ye(),n=Xe(),r=Dj(n),i=Tj(jj(e),Ej(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`),Mj(e),Oj(n,Math.min(r+1,5)),!0)}function jj(e){try{return Date.now()-r.statSync(e).mtimeMs}catch{return null}}function Mj(e){try{r.mkdirSync(l.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 Nj=null;function Pj(){let e=Je();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 Nj={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(!Fj(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 Fj(e){try{let t=r.statSync(e);return Date.now()-t.mtimeMs>1e4}catch{return!0}}function Ij(){if(!Nj)return;let{fd:e,path:t}=Nj;Nj=null;try{r.closeSync(e)}catch{}try{r.unlinkSync(t)}catch{}}function Lj(){try{return r.mkdirSync(Re(),{recursive:!0}),null}catch(e){return`mkdir ${Re()}: ${e.message}`}}function Rj(){let e=t.execPath,n=t.argv[1];return n?Me({bin:e,args:[`--max-old-space-size=${uj(t.env)}`,n,`daemon`],category:`daemon-spawn`}).ok:!1}const zj=`cc-candybar`,Bj=`dispatch`,Vj=`set-state`,Hj=`step-state`,Uj=`copy`,Wj=`open-vscode`,Gj=`toolbar-toggle`,Kj=`show-config-error`,qj=`show-config-warning`,Jj=`set-config`,Yj=`step-config`,Xj=`save`,Zj=`save-preset`,Qj=`save-theme-default`,$j=`delete-preset`,eM=`reset-config`,tM=`apply-layout-op`,nM=`undo`,rM=`redo`,iM=`back`,aM=`rewind`,oM=`apply-update`,sM=`doctor-run`,cM=`doctor-fix`,lM=`doctor-probe`,uM=`ceiling`,dM=`slash`;function fM(e){return e.map(encodeURIComponent).join(`/`)}function pM(e){return e.length===0?[]:e.split(`/`).map(decodeURIComponent)}function mM(e){return`${zj}://${Bj}/${e.map(e=>`e=${encodeURIComponent(`${e.verb}/${fM(e.args)}`)}`).join(`&`)}`}function hM(e){return new T(e).getAll(`e`).map(yM)}const gM=new Set([Vj,eM]);function _M(e){return e.reduce((e,t)=>{let n=e.at(-1),r=n&&vM(n,t);return r?[...e.slice(0,-1),r]:[...e,t]},[])}function vM(e,t){if(e.verb!==t.verb||!gM.has(e.verb))return;let[n,r]=[yM(e.value),yM(t.value)];return n.verb===r.verb?{verb:e.verb,value:`${n.verb}/${n.value}/${r.value}`}:void 0}function yM(e){let t=e.indexOf(`/`);return t===-1?{verb:e,value:``}:{verb:e.slice(0,t),value:e.slice(t+1)}}const bM=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function xM(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function SM(e){return bM.test(e)?e:xM(e)}const CM=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function wM(e){let t=CM.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 TM(e){return e.join(`.`)}function EM([e,t,n],[r,i,a]){return e-r||t-i||n-a}const DM=`@promptctl/cc-candybar`;async function OM(e,t,n){let r=`${n}/-/package/${encodeURIComponent(e)}/dist-tags`;try{let e=await t(r,{signal:AbortSignal.timeout(5e3)});if(!e.ok)return X(`registry responded ${e.status} for ${r}`);let n=await e.json();return typeof n.latest==`string`?wM(n.latest):Y}catch(e){return X(e instanceof Error?e.message:String(e))}}function kM(e,t){let n=wM(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=EM(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 AM(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${TM(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${TM(t.installed)} is newer than the registry's latest release (${TM(t.latest)}): an unpublished build.\n`};case`stale`:{let n=TM(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${TM(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 jM=`CCCandybarURLHandler`,MM=[],NM={"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 PM(e,t){return[e,...t].map(SM).join(` `)}function FM(){return l.join(h.homedir(),`Applications`,`${jM}.app`)}function IM(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function LM(){if(process.platform===`darwin`)return l.join(h.homedir(),`Library`,`Application Support`,`CCCandybar`);let e=process.env.XDG_DATA_HOME??l.join(h.homedir(),`.local`,`share`);return l.join(e,`cc-candybar`)}function RM(){return l.join(LM(),`bin`,`cc-candybar`)}function zM(){return l.join(LM(),`dist`,`index.mjs`)}function BM(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(`
|
|
@@ -180,7 +180,7 @@ Config tooling:
|
|
|
180
180
|
`))throw Error(`renderStripCells: rich-js strip output did not end its last line`);return s.slice(0,-1)}function iP(e){return Math.min(20,e??20)}const aP={heading:`ERROR`,glyph:`⚠`,colors:MN},oP={heading:`WARNING`,glyph:`⚠`,colors:NN},sP={heading:`UPDATE`,glyph:`⬆`,colors:NN};function cP(e,t){return{text:DN(e),link:t}}function lP(e,t,n){let[r,...i]=[uP(e,aP,Kj),t,uP(n,oP,qj)].flat();return r===void 0?null:{channels:[r,...i]}}function uP(e,t,n){let r=mM([{verb:n,args:[e]}]),[i,...a]=e.split(/\r\n|\r|\n/).map(e=>cP(e,r)).filter(e=>e.text!==``).map(e=>[e]);return i===void 0?[]:[{severity:t,message:e,lines:[i,...a]}]}function dP(e){return e.channels.map(e=>`${e.severity.heading}\n${e.message}\n`).join(`
|
|
181
181
|
`)}function fP(e,t,n,r){if(t===null)return e;let i=pP(r),a=t.channels.flatMap(e=>mP(e,i)),o=n.failedConfigFile!==null||a.length>r.rowCap,s=a.slice(0,r.rowCap-Number(o)),c=o?[hP(t,n,a.length-s.length,i)]:[],l=[...s,...c].join(`
|
|
182
182
|
`);return e?`${l}\n${e}`:l}function pP(e){return{endcaps:`plain`,separator:``,width:e.width,wrap:!0,padding:0,charset:`unicode`,colorCompatibility:e.colorCompatibility}}function mP(e,t){let n=new H({bgcolor:e.severity.colors.bg,color:e.severity.colors.fg}),r=Kt(Math.max(2,t.width-1)),i=(e,t)=>new W(`${e} `,{style:t,end:``,overflow:`ignore`});return e.lines.flatMap((a,o)=>rP([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=>Zt(e,r)).map(e=>i(e,t))})],t).split(`
|
|
183
|
-
`))}function hP(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 W(e,{style:t,end:``,overflow:`ignore`}),l=n>0?[c(`${n} more rows · `,s),a.kind===`file`?c(`open full text`,s.withLink(ae(a.path).href)):c(`full text unavailable: ${DN(a.reason)}`,s)]:[],u=o===null?[]:[c(`${l.length>0?` · `:``}open `,s),c(DN(o),s.withLink(ae(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=W.fromFragments([...d,...p]).truncate(r.width);return m.overflow=`ignore`,rP([m],r)}const gP=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function _P(e,t){return t.isSymbolicLink()?Buffer.from(r.readlinkSync(e)):r.readFileSync(e)}function vP(e,t){return r.readdirSync(t).filter(gP).sort().flatMap(n=>{let i=l.join(t,n),a=r.lstatSync(i,{throwIfNoEntry:!1});return a===void 0?[]:a.isDirectory()?vP(e,i):[[l.relative(e,i).split(l.sep).join(`/`),_P(i,a)]]})}function yP(e){let t=oe.createHash(`sha256`);for(let[n,r]of vP(e,e))t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}const bP=e=>e.slice(0,7);function xP(e){return l.dirname(l.dirname(e))}function SP(){return{version:ZA,digest:`d2ae072fb0b93288bb99e7d67aaeb91ec81c6b7b308525be61f2282f4ec774bb`}}function CP(e){let t=JSON.parse(r.readFileSync(l.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${l.join(e,`package.json`)} has no version string`);return n}function wP(e,t){try{let n=xP(E(e)),i=l.join(n,`src`);if(!r.existsSync(i))return{kind:`not-source-checkout`};let a=t(),o=yP(i);return o===a.digest?{kind:`current`,root:n,stamp:a}:{kind:`stale`,root:n,source:{version:CP(n),digest:o},running:a}}catch(e){return{kind:`unchecked`,reason:e.message}}}var $=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};function TP(e){return e.op===`remove`?`remove:${e.target}`:`insert:${e.segment}:${e.anchor}:${e.relation}`}function EP(e){let t=e.split(`:`);return t[0]===`remove`&&t.length===2&&t[1]?{op:`remove`,target:t[1]}:t[0]===`insert`&&t.length===4&&t[1]&&t[2]&&(t[3]===`before`||t[3]===`after`)?{op:`insert`,segment:t[1],anchor:t[2],relation:t[3]}:null}function DP(e,t,n){let r=Su(e,new Set(n.map(xu).filter(e=>e.includes(t)).flat()));return r===e?{seg:e}:{seg:e,id:r}}const OP=/^-?\d+$/;function kP(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 AP(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!OP.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 jP(e,t,n){return r=>r?OP.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 MP(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=>!OP.test(e));if(o.length>0)throw Error(`${n} action table: key "${e}" is an integer spec (a paged cursor or a bounded value) but a click writes non-integer value(s) to it (${o.join(`, `)}). A ${n} key has one key shape — point that click at a distinct key, or write an integer.`);if(i&&r.length>0)throw Error(`${n} action table: key "${e}" is declared as both a paged cursor (int) and a bounded value (range) — a ${n} key has one key shape. Use distinct keys.`);if(r.length>0){let t=Math.min(...r.map(e=>e.min)),i=Math.max(...r.map(e=>e.max)),o=a.filter(e=>{let n=parseInt(e,10);return n<t||n>i});if(o.length>0)throw Error(`${n} action table: key "${e}" is a bounded range [${t},${i}] but a click writes out-of-range value(s) to it (${o.join(`, `)}). The range gate would clamp them, storing a different value than the click renders — write an in-range integer, or point that click at a distinct key.`);return{kind:`range`,min:t,max:i}}return{kind:`int`}}function NP(e){return e===`config`?`set-config`:`set-state`}function PP(e,t,n){return t.kind===`int`?AP(`menu page "${e}"`):t.kind===`range`?jP(t.min,t.max,`${n} stepper "${e}"`):kP(t.allowed,`${n} "${e}"`,NP(n))}function FP(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:MP(e,n,t)}))}function IP(e,t,n,r){let i=new Map(Object.entries(e)),a=new Map,o=new Set(t.map(e=>e.key));for(let{key:e,spec:t}of n)if(o.has(e)&&t.kind!==`allow-list`)throw Error(`${r} gate: key "${e}" is written by the daemon's own links as one of a list of values, and cannot be declared as ${t.kind===`int`?`a paged cursor (int)`:`a bounded value (range)`}. Use a distinct key.`);let s=[...t.map(({key:e,allowed:t})=>({key:e,spec:{kind:`allow-list`,allowed:t}})),...n];for(let{key:t,spec:n}of FP(s,r)){if(!t)throw Error(`${r} gate: key is required`);if(t.includes(`/`))throw Error(`${r} gate: key "${t}" contains "/" — the wire shape splits on "/" so a slash-bearing key cannot be addressed. Use a slash-free key.`);if(Object.hasOwn(e,t))throw Error(`${r} gate: key "${t}" is a built-in ${r} key and cannot be re-claimed (built-in keys: ${Object.keys(e).join(`, `)})`);i.set(t,PP(t,n,r)),n.kind===`range`&&a.set(t,{min:n.min,max:n.max})}return{validate(e,t){let n=i.get(e);return n?n(t):{ok:!1,reason:`unknown ${r} key "${e}" (have: ${[...i.keys()].join(`, `)})`}},listKeys:()=>[...i.keys()],rangeParamsFor:e=>a.get(e)??null}}function LP(e,t,n){let r=[],i=0,a=new WeakMap;return{register(n,a){let o={key:n,allowed:a};IP(e,[o],[],t),r.push(o),i++;let s=!0;return()=>{s&&(s=!1,r.splice(r.indexOf(o),1),i++)}},gateFor(o){let s=a.get(o);if(s?.epoch===i)return s.gate;let c=IP(e,r,n(o),t);return a.set(o,{epoch:i,gate:c}),c}}}const RP=LP({},`config`,GP);function zP(e,t){return RP.register(e,t)}function BP(e){return RP.gateFor(e)}function VP(e,t){return`persist`in e?`to`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:Tw(e.from,t).members}}]:`cycle`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:e.cycle}}]:`removeSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[TP({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[TP({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:Tw(e.insertSegmentFrom,t).members.map(t=>TP({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function HP(e,t){let n=Pf(e).get(t);return n===void 0?null:String(n)}function UP(e){let t=new Set;for(let n of Object.values(e.actions)){`reset`in n&&t.add(n.reset);let e=`persist`in n?Hw(n.persist):null;e?.scope===`preset-root`&&t.add(Rw(e.preset))}return[...t].map(e=>({key:e,spec:{kind:`allow-list`,allowed:[]}}))}function WP(e){let t=PD(e);return[...UP(e),...Object.values(e.actions).flatMap(e=>VP(e,t))]}function GP(e){return FP(WP(e),`config`)}const KP={},qP=jT(`commands.`),JP=GT(`autocompact.`,e=>`{{ template "formatTokenCount" ${e} }}`),YP=`trimPrefix "/" (trimPrefix .project_dir .current_dir)`,XP=`{{ \$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 (${YP}) (basename .project_dir) (ne (${YP}) "") }}{{ end }}{{ end }}{{ action "copyDir" (abbreviatePath \$dir) }}`,ZP=`{{ ${nT} }}`,QP={min:0,max:100,step:5},$P={warnAt:{label:`warning at %`,domain:QP,default:50},errorAt:{label:`error at %`,domain:{...QP,atLeast:`warnAt`},default:80}};function eF(e){return{budget:{label:`budget $`,domain:{min:0,max:1e4,step:5},default:e},warnAt:{label:`warning at %`,domain:QP,default:80}}}const tF={globals:{palette:`tokyo-night`},variables:{...qP.variables,...QC,current_dir:{kind:`input`,path:`workspace.current_dir`,default:`?`},"model.display_name":{kind:`input`,path:`model.display_name`,default:``},version:{kind:`input`,path:`version`,default:``},home:{kind:`input`,path:`home`,default:``},"tmux.session":{kind:`input`,path:`tmux.session`,default:``},"host.name":{kind:`input`,path:`host.name`,default:``},"host.user":{kind:`input`,path:`host.user`,default:``},"host.ssh":{kind:`input`,path:`host.ssh`,type:`boolean`,default:!1},"git.repoName":{kind:`input`,path:`git.repoName`,default:``},"git.branch":{kind:`input`,path:`git.branch`,default:``},"git.sha":{kind:`input`,path:`git.sha`,default:``},"git.ahead":{kind:`input`,path:`git.ahead`,type:`number`,default:0},"git.behind":{kind:`input`,path:`git.behind`,type:`number`,default:0},"git.staged":{kind:`input`,path:`git.staged`,type:`number`,default:0},"git.unstaged":{kind:`input`,path:`git.unstaged`,type:`number`,default:0},"git.untracked":{kind:`input`,path:`git.untracked`,type:`number`,default:0},"git.conflicts":{kind:`input`,path:`git.conflicts`,type:`number`,default:0},"git.upstream":{kind:`input`,path:`git.upstream`,default:``},"git.stash":{kind:`input`,path:`git.stash`,type:`number`,default:0},"git.status":{kind:`input`,path:`git.status`,default:`clean`},"git.operation":{kind:`input`,path:`git.operation`,default:``},"git.timeSinceCommit":{kind:`input`,path:`git.timeSinceCommit`,type:`number`,default:0},"git.color.branch":{kind:`literal`,value:`primary`},"git.color.staged":{kind:`literal`,value:`success`},"git.color.unstaged":{kind:`literal`,value:`warning`},"git.color.untracked":{kind:`literal`,value:`accent`},"git.color.conflicts":{kind:`literal`,value:`error`},"git.color.ahead":{kind:`literal`,value:`success`},"git.color.behind":{kind:`literal`,value:`warning`},"git.color.stash":{kind:`literal`,value:`accent`},"git.detail":{kind:`state`,key:`git-detail`,default:`collapsed`},"git.prNumber":{kind:`input`,path:`git.prNumber`,type:`number`,default:0},"git.prState":{kind:`input`,path:`git.prState`,default:``},"git.prUrl":{kind:`input`,path:`git.prUrl`,default:``},"git.prError":{kind:`input`,path:`git.prError`,default:``},"cache.expiresAt":{kind:`input`,path:`cache.expiresAt`,type:`number`,default:0},"session.cost":{kind:`input`,path:`session.cost`,type:`number`,default:0},"session.tokens":{kind:`input`,path:`session.tokens`,type:`number`,default:0},"today.cost":{kind:`input`,path:`today.cost`,type:`number`,default:0},"today.tokens":{kind:`input`,path:`today.tokens`,type:`number`,default:0},"block.nativeUtilization":{kind:`input`,path:`block.nativeUtilization`,type:`number`,default:0},"block.resetsAt":{kind:`input`,path:`block.resetsAt`,type:`number`,default:0},"weekly.percentage":{kind:`input`,path:`weekly.percentage`,type:`number`,default:0},"weekly.resetsAt":{kind:`input`,path:`weekly.resetsAt`,type:`number`,default:0},"burn.costPerHour":{kind:`input`,path:`burn.costPerHour`,type:`number`,default:-1},"block.etaMinutes":{kind:`input`,path:`block.etaMinutes`,type:`number`,default:-1},"weekly.etaMinutes":{kind:`input`,path:`weekly.etaMinutes`,type:`number`,default:-1},"speed.input":{kind:`input`,path:`speed.input`,type:`number`,default:-1},"speed.output":{kind:`input`,path:`speed.output`,type:`number`,default:-1},"speed.total":{kind:`input`,path:`speed.total`,type:`number`,default:-1},"speed.history":{kind:`input`,path:`speed.history`,type:`string`,default:``},"context.totalTokens":{kind:`input`,path:`context.totalTokens`,type:`number`,default:0},"context.contextLeft":{kind:`input`,path:`context.contextLeft`,type:`number`,default:100},"memento.ceiling":{kind:`input`,path:`memento.ceiling`,type:`number`,default:-1},"memento.off":{kind:`input`,path:`memento.off`,type:`boolean`,default:!1},"memento.session":{kind:`input`,path:`memento.session`,default:``},"memento.error":{kind:`input`,path:`memento.error`,default:``},"metrics.lastResponseTime":{kind:`input`,path:`metrics.lastResponseTime`,type:`number`,default:0},"metrics.responseTime":{kind:`input`,path:`metrics.responseTime`,type:`number`,default:0},"metrics.sessionDuration":{kind:`input`,path:`metrics.sessionDuration`,type:`number`,default:0},"metrics.messageCount":{kind:`input`,path:`metrics.messageCount`,type:`number`,default:0},"metrics.linesAdded":{kind:`input`,path:`metrics.linesAdded`,type:`number`,default:0},"metrics.linesRemoved":{kind:`input`,path:`metrics.linesRemoved`,type:`number`,default:0},"activity.command":{kind:`input`,path:`activity.command`,type:`string`,default:``},"activity.todo.total":{kind:`input`,path:`activity.todo.total`,type:`number`,default:0},"activity.todo.completed":{kind:`input`,path:`activity.todo.completed`,type:`number`,default:0},"activity.todo.position":{kind:`input`,path:`activity.todo.position`,type:`number`,default:0},"activity.todo.active":{kind:`input`,path:`activity.todo.active`,type:`string`,default:``},"activity.tool.running":{kind:`input`,path:`activity.tool.running`,type:`string`,default:``},"activity.tool.done":{kind:`input`,path:`activity.tool.done`,type:`string`,default:``}},segments:{directory:{group:`location`,description:"The current directory, shortened fish-style — `~` under home, project-relative inside the project. Click to copy the full path.",template:XP},model:{group:`model-context`,description:`The active model's display name.`,template:`✱ {{ formatModelName .model.display_name }}`,when:`{{ ne .model.display_name "" }}`},sessionId:{group:`session-tools`,description:`The session id, truncated to 8 characters.`,template:`⌗{{ trunc 8 .session.id }}`,when:`{{ ne .session.id "" }}`},version:{group:`model-context`,description:`The Claude Code version reported in the hook payload.`,template:`◈ v{{ .version }}`,when:`{{ ne .version "" }}`},tmux:{group:`location`,description:`The tmux session name; hidden when not inside tmux.`,template:`tmux:{{ .tmux.session | default "none" }}`,when:`{{ ne .tmux.session "" }}`},host:{group:`location`,description:`user@host on a warning background, shown only over SSH.`,template:`⇄ {{ .host.user | default "?" }}@{{ .host.name | default "?" }}`,bg:`warning`,when:`{{ .host.ssh }}`},gitaculous:{group:`git`,description:`The git state: a summary (branch, ahead/behind, S/U/? flags) that the arrow at its right edge expands to every fact — repo, in-progress operation, sha, upstream ±, stash count, time since the last commit.`,template:`{{ if eq .git.detail "expanded" }}{{ template "gitExpanded" . }}{{ else }}{{ template "gitCollapsed" . }}{{ end }} {{ action "gitDetail" "▸" "◂" }}`,fg:ZP,when:`{{ ne .git.branch "" }}`,settings:{aheadBehind:{label:`ahead/behind`,domain:`bool`,default:!0},flags:{label:`dirty flags`,domain:`bool`,default:!0},operation:{label:`operation`,domain:`bool`,default:!0},repo:{label:`repo name`,domain:`bool`,default:!0},sha:{label:`commit hash`,domain:`bool`,default:!0},stash:{label:`stash`,domain:`bool`,default:!0},upstream:{label:`upstream`,domain:`bool`,default:!0},age:{label:`time since commit`,domain:`bool`,default:!0}}},gitPr:{group:`git`,description:"The pull request open for this branch, as a link; `⚠ PR` when the forge lookup failed.",template:`{{ if ne .git.prUrl "" }}{{ link .git.prUrl (printf "⇆ #%v" .git.prNumber) }}{{ else }}⚠ PR{{ end }}`,when:`{{ or (ne .git.prUrl "") (ne .git.prError "") }}`},toolbar:{group:`session-tools`,description:`Quick actions: copy the session id, and open the project, transcript or repo.`,template:bT(``).template},commands:{group:`session-tools`,description:`Type /compact, /model or /clear into this session; /clear asks for a second click. Hidden when not inside tmux.`,template:qP.template,when:qP.when},themeSwitcher:{group:`session-tools`,description:"`◀ <theme> ▶`: the theme the bar is wearing; ◀ and ▶ switch this session to the previous or next theme, wrapping at the ends.",template:`{{ carousel "stepTheme" 0 }}`},session:{group:`cost-limits`,description:`This session's cost and token total, with a budget warning once a budget is configured.`,template:`§ {{ template "formatCost" .session.cost }} ({{ template "formatTokens" .session.tokens }}){{ template "budgetStatus" (dict "cost" .session.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:eF(0)},today:{group:`cost-limits`,description:`Today's cost and tokens across every session, with a budget warning once a budget is configured.`,template:`☉ {{ template "formatCost" .today.cost }} ({{ template "formatTokens" .today.tokens }}){{ template "budgetStatus" (dict "cost" .today.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:eF(50)},block:{group:`cost-limits`,description:`The 5-hour rate-limit block: percent used and time to reset, heating to warning then error.`,template:`◱ {{ round .block.nativeUtilization }}% ({{ template "formatResetCountdown" .block.resetsAt }})`,bg:`{{ ramp (round .block.nativeUtilization) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:$P,when:`{{ gt .block.resetsAt 0 }}`},weekly:{group:`cost-limits`,description:`The weekly rate-limit quota: percent used and time to reset, heating to warning then error.`,template:`◑ {{ round .weekly.percentage }}% ({{ template "formatResetCountdown" .weekly.resetsAt }})`,bg:`{{ ramp (round .weekly.percentage) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:$P,when:`{{ gt .weekly.resetsAt 0 }}`},burnrate:{group:`cost-limits`,description:`Spend per hour, with the projected time to the 5-hour and weekly limits.`,template:`⚡ {{ template "formatRate" .burn.costPerHour }} · {{ template "formatEta" .block.etaMinutes }} to 5h · {{ template "formatEta" .weekly.etaMinutes }} to wk`,bg:`{{ ramp .block.etaMinutes "step" -1 (tint) 0 "error" .settings.errorWithin "warning" .settings.warnWithin (tint) }}`,settings:{errorWithin:{label:`error within (min)`,domain:{min:0,max:300,step:5},default:30},warnWithin:{label:`warning within (min)`,domain:{min:0,max:300,step:5,atLeast:`errorWithin`},default:60}},when:`{{ or (gt .block.resetsAt 0) (gt .weekly.resetsAt 0) }}`},speed:{group:`activity`,description:`Token throughput for the latest exchange: output, input, and total.`,template:`⇅ out {{ template "formatSpeed" .speed.output }} · in {{ template "formatSpeed" .speed.input }} · tot {{ template "formatSpeed" .speed.total }}`,when:`{{ gt .session.tokens 0 }}`},tokenSparkline:{group:`activity`,description:`A sparkline of recent token throughput.`,template:`⚡ {{ sparkline .speed.history 24 }}`,when:`{{ ne .speed.history "" }}`},cacheTimer:{group:`activity`,description:"Minutes until the prompt cache expires, or `cold` once it has.",template:`◴ {{ if le (minutesUntilReset .cache.expiresAt) 0 }}cold{{ else }}{{ minutesUntilReset .cache.expiresAt }}m{{ end }}`,fg:`{{ readableOn (color (cascade (minutesUntilReset .cache.expiresAt) "0:error" "9:warning" "21:foreground")) (bgOf) ${tc} }}`,when:`{{ gt .cache.expiresAt 0 }}`},context:{group:`model-context`,description:`Context used, in tokens and percent remaining, heating as it fills.`,template:`◔ {{ formatInteger .context.totalTokens }} ({{ .context.contextLeft }}%)`,bg:`{{ ramp .context.contextLeft "step" 0 "error" 21 "warning" 41 (tint) }}`,when:`{{ gt .context.totalTokens 0 }}`},ceiling:{group:`model-context`,description:`The memento plugin's context ceiling for this session: − and + move it by 100K, ∞ lifts it, ↺ drops this session's own setting.`,template:`{{ if ne .memento.error "" }}⌈ ⚠ {{ .memento.error }} {{ action "ceiling.clear" "↺" }}{{ else }}⌈ {{ if .memento.off }}off{{ else }}{{ template "formatTokenCount" .memento.ceiling }} {{ action "ceiling.lower" "−" }} {{ action "ceiling.raise" "+" }} {{ action "ceiling.off" "∞" }}{{ end }}{{ if ne .memento.session "" }} {{ action "ceiling.clear" "↺" }}{{ end }}{{ end }}`,bg:`{{ if ne .memento.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .memento.ceiling 0) (ne .memento.error "") }}`},autocompact:{group:`model-context`,description:`Claude Code's auto-compact window: − and + move it by 100K, ↺ returns it to auto. Clicks type /autocompact into this session, so the controls show only inside tmux.`,template:JP.template,bg:JP.bg,when:JP.when},metrics:{group:`activity`,description:`Response times, session duration, message count, and lines added/removed.`,template:`{{ if .metrics.lastResponseTime }} Δ {{ template "formatResponseTime" .metrics.lastResponseTime }}{{ end }}{{ if .metrics.responseTime }} ⧖ {{ template "formatResponseTime" .metrics.responseTime }}{{ end }}{{ if .metrics.sessionDuration }} ⧗ {{ template "formatDuration" .metrics.sessionDuration }}{{ end }}{{ if .metrics.messageCount }} ◆ {{ .metrics.messageCount }}{{ end }}{{ if .metrics.linesAdded }} + {{ .metrics.linesAdded }}{{ end }}{{ if .metrics.linesRemoved }} - {{ .metrics.linesRemoved }}{{ end }} `,when:`{{ or (gt .metrics.lastResponseTime 0.0) (gt .metrics.responseTime 0.0) (gt .metrics.sessionDuration 0.0) (gt .metrics.messageCount 0) (gt .metrics.linesAdded 0) (gt .metrics.linesRemoved 0) }}`},activity:{group:`activity`,description:`What Claude is doing: the slash command that opened the turn, the in-progress todo, and the tools in flight.`,template:`{{ if .activity.command }} ⌘ {{ .activity.command }}{{ end }}{{ if .activity.todo.total }}{{ if .activity.todo.active }} ☐ {{ .activity.todo.position }}/{{ .activity.todo.total }} {{ abbrev 32 .activity.todo.active }}{{ else }} ☑ {{ .activity.todo.completed }}/{{ .activity.todo.total }}{{ end }}{{ end }}{{ if .activity.tool.running }} ⟳ {{ template "formatToolTally" .activity.tool.running }}{{ end }}{{ if .activity.tool.done }} ✓ {{ template "formatToolTally" .activity.tool.done }}{{ end }} `,when:`{{ or (ne .activity.command "") (gt .activity.todo.total 0) (ne .activity.tool.running "") (ne .activity.tool.done "") }}`}},root:{rows:{identity:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`}]},status:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`activity`}]}}},actions:{...bT(``).actions,...qP.actions,copyDir:{copy:`{{ .current_dir }}`},stepTheme:{set:`theme`,from:`themes`},gitDetail:{set:`git-detail`,cycle:[`collapsed`,`expanded`]},"ceiling.raise":{ceiling:`set`,to:`+100_000`},"ceiling.lower":{ceiling:`set`,to:`-100_000`},"ceiling.off":{ceiling:`set`,to:`off`},"ceiling.clear":{ceiling:`clear`},...JP.actions},styles:{none:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:0},vivid:{hueShift:0,chromaScale:1.35,lightnessScale:1,lightnessShift:0},muted:{hueShift:0,chromaScale:.55,lightnessScale:1,lightnessShift:0},dim:{hueShift:0,chromaScale:1,lightnessScale:.85,lightnessShift:0},bright:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:.08},inverted:{hueShift:0,chromaScale:1,lightnessScale:-1,lightnessShift:1}},themeDefaults:KP,presets:{default:{},compact:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`context`}]},globals:{padding:0}},verbose:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},zen:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`context`}]},globals:{endcaps:`plain`,style:`dim`}},git:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{kind:`segment`,name:`activity`}]}]}},usage:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`session`},{kind:`segment`,name:`today`},{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},dense:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`session`},{kind:`segment`,name:`activity`}]},globals:{padding:0}}},editGlobals:{endcaps:`plain`,default_separator:` | `},helpers:{gitPaint:`{{ fg (readableOn (color .color) (bgOf) ${tc}) .text }}`,gitCollapsed:`{{ template "gitBranch" . }}{{ template "gitAheadBehind" . }}{{ template "gitFlags" . }}`,gitExpanded:`(git){{ template "gitRepo" . }}{{ template "gitOperation" . }}{{ template "gitSha" . }}{{ template "gitFlags" . }} {{ template "gitBranch" . }}{{ template "gitUpstream" . }}{{ template "gitStash" . }}{{ template "gitAge" . }}`,gitBranch:`⎇ {{ template "gitPaint" (dict "color" .git.color.branch "text" .git.branch) }}`,gitRepo:`{{ if and .settings.repo (ne .git.repoName "") }} {{ .git.repoName }}{{ end }}`,gitOperation:`{{ if and .settings.operation (ne .git.operation "") }} [{{ .git.operation }}]{{ end }}`,gitSha:`{{ if and .settings.sha (ne .git.sha "") }} {{ .git.sha }}{{ end }}`,gitFlags:`{{ if and .settings.flags (or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0)) }} {{ if gt .git.staged 0 }}{{ template "gitPaint" (dict "color" .git.color.staged "text" "S") }}{{ end }}{{ if gt .git.unstaged 0 }}{{ template "gitPaint" (dict "color" .git.color.unstaged "text" "U") }}{{ end }}{{ if gt .git.untracked 0 }}{{ template "gitPaint" (dict "color" .git.color.untracked "text" "?") }}{{ end }}{{ if gt .git.conflicts 0 }}{{ template "gitPaint" (dict "color" .git.color.conflicts "text" (printf "!%v" .git.conflicts)) }}{{ end }}{{ end }}`,gitAheadBehind:`{{ if and .settings.aheadBehind (or (gt .git.ahead 0) (gt .git.behind 0)) }} {{ if gt .git.ahead 0 }}{{ template "gitPaint" (dict "color" .git.color.ahead "text" (printf "+%v" .git.ahead)) }}{{ end }}{{ if and (gt .git.ahead 0) (gt .git.behind 0) }}/{{ end }}{{ if gt .git.behind 0 }}{{ template "gitPaint" (dict "color" .git.color.behind "text" (printf "-%v" .git.behind)) }}{{ end }}{{ end }}`,gitUpstream:`{{ if and .settings.upstream (ne .git.upstream "") }} [{{ .git.upstream }}{{ template "gitAheadBehind" . }}]{{ end }}`,gitStash:`{{ if and .settings.stash (gt .git.stash 0) }} {{ template "gitPaint" (dict "color" .git.color.stash "text" (printf "(%v stashed)" .git.stash)) }}{{ end }}`,gitAge:`{{ if and .settings.age (gt .git.timeSinceCommit 0) }} ◷ {{ template "formatTimeSince" .git.timeSinceCommit }}{{ end }}`,formatCost:'{{ if lt . 0.01 }}<$0.01{{ else }}${{ printf "%.2f" . }}{{ end }}',formatTokenCount:KT(`.`),formatTokens:`{{ template "formatTokenCount" . }} tokens`,formatToolTally:`{{ $names := splitList "," . }}{{ range $i, $pair := $names }}{{ if lt $i 2 }}{{ if $i }} {{ end }}{{ $kv := splitList ":" $pair }}{{ index $kv 0 }}{{ if ne (index $kv 1) "1" }}×{{ index $kv 1 }}{{ end }}{{ end }}{{ end }}{{ if gt (len $names) 2 }} +{{ sub (len $names) 2 }}{{ end }}`,formatRate:`{{ if lt . 0 }}—/hr{{ else }}{{ template "formatCost" . }}/hr{{ end }}`,formatEta:`{{ if lt . 0 }}—{{ else }}{{ template "formatLongTimeRemaining" . }}{{ end }}`,formatSpeed:`{{ if lt . 0 }}—{{ else }}{{ template "formatTokenCount" (round .) }}/s{{ end }}`,formatTokenBreakdown:`{{ $first := true }}{{ if gt .input 0 }}{{ template "formatTokenCount" .input }} in{{ $first = false }}{{ end }}{{ if gt .output 0 }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" .output }} out{{ $first = false }}{{ end }}{{ if or (gt .cacheCreation 0) (gt .cacheRead 0) }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" (add .cacheCreation .cacheRead) }} cached{{ $first = false }}{{ end }}{{ if $first }}0 tokens{{ end }}`,budgetStatus:`{{ if or (le .budget 0) (lt .cost 0) }}{{ else }}{{ $pct := minf 100 (mulf (divf .cost .budget) 100) }}{{ $p := printf "%.0f%%" $pct }}{{ if ge $pct .warn }} !{{ $p }}{{ else }}{{ if ge $pct 50 }} +{{ $p }}{{ else }} {{ $p }}{{ end }}{{ end }}{{ end }}`,formatTimeSince:`{{ if lt . 60 }}{{ . }}s{{ else if lt . 3600 }}{{ div . 60 }}m{{ else if lt . 86400 }}{{ div . 3600 }}h{{ else if lt . 604800 }}{{ div . 86400 }}d{{ else }}{{ div . 604800 }}w{{ end }}`,formatDuration:`{{ if lt . 60 }}{{ printf "%.0f" . }}s{{ else if lt . 3600 }}{{ printf "%.0f" (divf . 60) }}m{{ else if lt . 86400 }}{{ printf "%.1f" (divf . 3600) }}h{{ else }}{{ printf "%.1f" (divf . 86400) }}d{{ end }}`,formatResponseTime:`{{ if lt . 60 }}{{ printf "%.1f" . }}s{{ else }}{{ printf "%.1f" (divf . 60) }}m{{ end }}`,formatLongTimeRemaining:`{{ if ge . 1440 }}{{ $d := div . 1440 }}{{ $h := div (mod . 1440) 60 }}{{ if gt $h 0 }}{{ $d }}d {{ $h }}h{{ else }}{{ $d }}d{{ end }}{{ else if ge . 60 }}{{ $h := div . 60 }}{{ $m := mod . 60 }}{{ if gt $m 0 }}{{ $h }}h {{ $m }}m{{ else }}{{ $h }}h{{ end }}{{ else }}{{ . }}m{{ end }}`,formatResetCountdown:`{{ template "formatLongTimeRemaining" (add 1 (minutesUntilReset .)) }}`}},nF=new Set([tF.globals.palette,...Object.keys(tF.themeDefaults),...Object.values(tF.segments).map(e=>e.palette)].filter(e=>e!==void 0)),rF=Id(wA(`<default>`,JSON.stringify(tF),nF),tF),iF=Nb(rF.presets);function aF(e){return iF.includes(e)}const oF=Object.freeze({});function sF(e,t){return e.kind===`decided`?t[e.name]??oF:oF}function cF(e,t){return{...e,...Object.fromEntries(ku.map(n=>[n,e[n]??t[n]]))}}function lF(e){if(!e)return 0;try{return s(e).mtimeMs}catch{return 0}}const uF=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 dF(e){return((...t)=>uF.run(()=>e(...t)))}const fF=dF(ee),pF=dF(C),mF=dF(w);async function hF(e,t){return uF.run(async()=>{let n=null;try{n=await S(e,`r`);let{size:r,mtimeMs:i,ino:a}=await n.stat(),o=t!==void 0&&(a!==t.ino||r<t.offset),s=o||t===void 0?0:t.offset;if(s>=r)return J({buf:Buffer.alloc(0),start:s,size:r,mtimeMs:i,ino:a,reset:o});let c=Buffer.alloc(r-s),l=0;for(;l<c.length;){let{bytesRead:e}=await n.read(c,l,c.length-l,s+l);if(e===0)break;l+=e}return J({buf:l===c.length?c:c.subarray(0,l),start:s,size:r,mtimeMs:i,ino:a,reset:o})}catch(t){return t.code===`ENOENT`?Y:X(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{D(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}async function gF(e,t){return uF.run(async()=>{let n=null;try{n=await S(e,`r`);let{size:r}=await n.stat(),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let{bytesRead:e}=await n.read(a,o,a.length-o,i+o);if(e===0)break;o+=e}return J({buf:o===a.length?a:a.subarray(0,o),fromStart:i===0})}catch(t){return t.code===`ENOENT`?Y:X(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{D(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}const _F=/"(?:cache_read_input_tokens|cache_creation_input_tokens)":[1-9]/;function vF(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 yF(e){let t=await bF(e);return t.kind===`ok`?J(Math.floor((t.value+36e5)/1e3)):t}async function bF(e){for(let t of[65536,1048576]){let n=await gF(e,t);if(n.kind!==`ok`)return n;let r=xF(n.value.buf,n.value.fromStart);if(r!=null)return J(r);if(n.value.fromStart)return Y}return Y}function xF(e,t){let n=e.toString(`utf8`).split(`
|
|
183
|
+
`))}function hP(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 W(e,{style:t,end:``,overflow:`ignore`}),l=n>0?[c(`${n} more rows · `,s),a.kind===`file`?c(`open full text`,s.withLink(ae(a.path).href)):c(`full text unavailable: ${DN(a.reason)}`,s)]:[],u=o===null?[]:[c(`${l.length>0?` · `:``}open `,s),c(DN(o),s.withLink(ae(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=W.fromFragments([...d,...p]).truncate(r.width);return m.overflow=`ignore`,rP([m],r)}const gP=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function _P(e,t){return t.isSymbolicLink()?Buffer.from(r.readlinkSync(e)):r.readFileSync(e)}function vP(e,t){return r.readdirSync(t).filter(gP).sort().flatMap(n=>{let i=l.join(t,n),a=r.lstatSync(i,{throwIfNoEntry:!1});return a===void 0?[]:a.isDirectory()?vP(e,i):[[l.relative(e,i).split(l.sep).join(`/`),_P(i,a)]]})}function yP(e){let t=oe.createHash(`sha256`);for(let[n,r]of vP(e,e))t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}const bP=e=>e.slice(0,7);function xP(e){return l.dirname(l.dirname(e))}function SP(){return{version:ZA,digest:`79447496100f7946206744c0111ef6bf19c8e84730455362716cca6252a3709f`}}function CP(e){let t=JSON.parse(r.readFileSync(l.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${l.join(e,`package.json`)} has no version string`);return n}function wP(e,t){try{let n=xP(E(e)),i=l.join(n,`src`);if(!r.existsSync(i))return{kind:`not-source-checkout`};let a=t(),o=yP(i);return o===a.digest?{kind:`current`,root:n,stamp:a}:{kind:`stale`,root:n,source:{version:CP(n),digest:o},running:a}}catch(e){return{kind:`unchecked`,reason:e.message}}}var $=class extends Error{constructor(e){super(e),this.name=`BadVerbArgs`}};function TP(e){return e.op===`remove`?`remove:${e.target}`:`insert:${e.segment}:${e.anchor}:${e.relation}`}function EP(e){let t=e.split(`:`);return t[0]===`remove`&&t.length===2&&t[1]?{op:`remove`,target:t[1]}:t[0]===`insert`&&t.length===4&&t[1]&&t[2]&&(t[3]===`before`||t[3]===`after`)?{op:`insert`,segment:t[1],anchor:t[2],relation:t[3]}:null}function DP(e,t,n){let r=Su(e,new Set(n.map(xu).filter(e=>e.includes(t)).flat()));return r===e?{seg:e}:{seg:e,id:r}}const OP=/^-?\d+$/;function kP(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 AP(e){return t=>{if(!t)return{ok:!1,reason:`${e} value is required`};if(!OP.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 jP(e,t,n){return r=>r?OP.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 MP(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=>!OP.test(e));if(o.length>0)throw Error(`${n} action table: key "${e}" is an integer spec (a paged cursor or a bounded value) but a click writes non-integer value(s) to it (${o.join(`, `)}). A ${n} key has one key shape — point that click at a distinct key, or write an integer.`);if(i&&r.length>0)throw Error(`${n} action table: key "${e}" is declared as both a paged cursor (int) and a bounded value (range) — a ${n} key has one key shape. Use distinct keys.`);if(r.length>0){let t=Math.min(...r.map(e=>e.min)),i=Math.max(...r.map(e=>e.max)),o=a.filter(e=>{let n=parseInt(e,10);return n<t||n>i});if(o.length>0)throw Error(`${n} action table: key "${e}" is a bounded range [${t},${i}] but a click writes out-of-range value(s) to it (${o.join(`, `)}). The range gate would clamp them, storing a different value than the click renders — write an in-range integer, or point that click at a distinct key.`);return{kind:`range`,min:t,max:i}}return{kind:`int`}}function NP(e){return e===`config`?`set-config`:`set-state`}function PP(e,t,n){return t.kind===`int`?AP(`menu page "${e}"`):t.kind===`range`?jP(t.min,t.max,`${n} stepper "${e}"`):kP(t.allowed,`${n} "${e}"`,NP(n))}function FP(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:MP(e,n,t)}))}function IP(e,t,n,r){let i=new Map(Object.entries(e)),a=new Map,o=new Set(t.map(e=>e.key));for(let{key:e,spec:t}of n)if(o.has(e)&&t.kind!==`allow-list`)throw Error(`${r} gate: key "${e}" is written by the daemon's own links as one of a list of values, and cannot be declared as ${t.kind===`int`?`a paged cursor (int)`:`a bounded value (range)`}. Use a distinct key.`);let s=[...t.map(({key:e,allowed:t})=>({key:e,spec:{kind:`allow-list`,allowed:t}})),...n];for(let{key:t,spec:n}of FP(s,r)){if(!t)throw Error(`${r} gate: key is required`);if(t.includes(`/`))throw Error(`${r} gate: key "${t}" contains "/" — the wire shape splits on "/" so a slash-bearing key cannot be addressed. Use a slash-free key.`);if(Object.hasOwn(e,t))throw Error(`${r} gate: key "${t}" is a built-in ${r} key and cannot be re-claimed (built-in keys: ${Object.keys(e).join(`, `)})`);i.set(t,PP(t,n,r)),n.kind===`range`&&a.set(t,{min:n.min,max:n.max})}return{validate(e,t){let n=i.get(e);return n?n(t):{ok:!1,reason:`unknown ${r} key "${e}" (have: ${[...i.keys()].join(`, `)})`}},listKeys:()=>[...i.keys()],rangeParamsFor:e=>a.get(e)??null}}function LP(e,t,n){let r=[],i=0,a=new WeakMap;return{register(n,a){let o={key:n,allowed:a};IP(e,[o],[],t),r.push(o),i++;let s=!0;return()=>{s&&(s=!1,r.splice(r.indexOf(o),1),i++)}},gateFor(o){let s=a.get(o);if(s?.epoch===i)return s.gate;let c=IP(e,r,n(o),t);return a.set(o,{epoch:i,gate:c}),c}}}const RP=LP({},`config`,GP);function zP(e,t){return RP.register(e,t)}function BP(e){return RP.gateFor(e)}function VP(e,t){return`persist`in e?`to`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[e.to]}}]:`from`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:Tw(e.from,t).members}}]:`cycle`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:e.cycle}}]:`removeSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[TP({op:`remove`,target:e.removeSegment})]}}]:`insertSegment`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:[TP({op:`insert`,segment:e.insertSegment,anchor:e.anchor,relation:e.relation})]}}]:`insertSegmentFrom`in e?[{key:e.persist,spec:{kind:`allow-list`,allowed:Tw(e.insertSegmentFrom,t).members.map(t=>TP({op:`insert`,segment:t,anchor:e.anchor,relation:e.relation}))}}]:[{key:e.persist,spec:{kind:`range`,min:e.min,max:e.max}}]:[]}function HP(e,t){let n=Pf(e).get(t);return n===void 0?null:String(n)}function UP(e){let t=new Set;for(let n of Object.values(e.actions)){`reset`in n&&t.add(n.reset);let e=`persist`in n?Hw(n.persist):null;e?.scope===`preset-root`&&t.add(Rw(e.preset))}return[...t].map(e=>({key:e,spec:{kind:`allow-list`,allowed:[]}}))}function WP(e){let t=PD(e);return[...UP(e),...Object.values(e.actions).flatMap(e=>VP(e,t))]}function GP(e){return FP(WP(e),`config`)}const KP={},qP=jT(`commands.`),JP=GT(`autocompact.`,e=>`{{ template "formatTokenCount" ${e} }}`),YP=`trimPrefix "/" (trimPrefix .project_dir .current_dir)`,XP=`{{ \$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 (${YP}) (basename .project_dir) (ne (${YP}) "") }}{{ end }}{{ end }}{{ action "copyDir" (abbreviatePath \$dir) }}`,ZP=`{{ ${nT} }}`,QP={min:0,max:100,step:5},$P={warnAt:{label:`warning at %`,domain:QP,default:50},errorAt:{label:`error at %`,domain:{...QP,atLeast:`warnAt`},default:80}};function eF(e){return{budget:{label:`budget $`,domain:{min:0,max:1e4,step:5},default:e},warnAt:{label:`warning at %`,domain:QP,default:80}}}const tF={globals:{palette:`tokyo-night`},variables:{...qP.variables,...QC,current_dir:{kind:`input`,path:`workspace.current_dir`,default:`?`},"model.display_name":{kind:`input`,path:`model.display_name`,default:``},version:{kind:`input`,path:`version`,default:``},home:{kind:`input`,path:`home`,default:``},"tmux.session":{kind:`input`,path:`tmux.session`,default:``},"host.name":{kind:`input`,path:`host.name`,default:``},"host.user":{kind:`input`,path:`host.user`,default:``},"host.ssh":{kind:`input`,path:`host.ssh`,type:`boolean`,default:!1},"git.repoName":{kind:`input`,path:`git.repoName`,default:``},"git.branch":{kind:`input`,path:`git.branch`,default:``},"git.sha":{kind:`input`,path:`git.sha`,default:``},"git.ahead":{kind:`input`,path:`git.ahead`,type:`number`,default:0},"git.behind":{kind:`input`,path:`git.behind`,type:`number`,default:0},"git.staged":{kind:`input`,path:`git.staged`,type:`number`,default:0},"git.unstaged":{kind:`input`,path:`git.unstaged`,type:`number`,default:0},"git.untracked":{kind:`input`,path:`git.untracked`,type:`number`,default:0},"git.conflicts":{kind:`input`,path:`git.conflicts`,type:`number`,default:0},"git.upstream":{kind:`input`,path:`git.upstream`,default:``},"git.stash":{kind:`input`,path:`git.stash`,type:`number`,default:0},"git.status":{kind:`input`,path:`git.status`,default:`clean`},"git.operation":{kind:`input`,path:`git.operation`,default:``},"git.timeSinceCommit":{kind:`input`,path:`git.timeSinceCommit`,type:`number`,default:0},"git.color.branch":{kind:`literal`,value:`primary`},"git.color.staged":{kind:`literal`,value:`success`},"git.color.unstaged":{kind:`literal`,value:`warning`},"git.color.untracked":{kind:`literal`,value:`accent`},"git.color.conflicts":{kind:`literal`,value:`error`},"git.color.ahead":{kind:`literal`,value:`success`},"git.color.behind":{kind:`literal`,value:`warning`},"git.color.stash":{kind:`literal`,value:`accent`},"git.detail":{kind:`state`,key:`git-detail`,default:`collapsed`},"git.prNumber":{kind:`input`,path:`git.prNumber`,type:`number`,default:0},"git.prState":{kind:`input`,path:`git.prState`,default:``},"git.prUrl":{kind:`input`,path:`git.prUrl`,default:``},"git.prError":{kind:`input`,path:`git.prError`,default:``},"cache.expiresAt":{kind:`input`,path:`cache.expiresAt`,type:`number`,default:0},"session.cost":{kind:`input`,path:`session.cost`,type:`number`,default:0},"session.tokens":{kind:`input`,path:`session.tokens`,type:`number`,default:0},"today.cost":{kind:`input`,path:`today.cost`,type:`number`,default:0},"today.tokens":{kind:`input`,path:`today.tokens`,type:`number`,default:0},"block.nativeUtilization":{kind:`input`,path:`block.nativeUtilization`,type:`number`,default:0},"block.resetsAt":{kind:`input`,path:`block.resetsAt`,type:`number`,default:0},"weekly.percentage":{kind:`input`,path:`weekly.percentage`,type:`number`,default:0},"weekly.resetsAt":{kind:`input`,path:`weekly.resetsAt`,type:`number`,default:0},"burn.costPerHour":{kind:`input`,path:`burn.costPerHour`,type:`number`,default:-1},"block.etaMinutes":{kind:`input`,path:`block.etaMinutes`,type:`number`,default:-1},"weekly.etaMinutes":{kind:`input`,path:`weekly.etaMinutes`,type:`number`,default:-1},"speed.input":{kind:`input`,path:`speed.input`,type:`number`,default:-1},"speed.output":{kind:`input`,path:`speed.output`,type:`number`,default:-1},"speed.total":{kind:`input`,path:`speed.total`,type:`number`,default:-1},"speed.history":{kind:`input`,path:`speed.history`,type:`string`,default:``},"context.totalTokens":{kind:`input`,path:`context.totalTokens`,type:`number`,default:0},"context.contextLeft":{kind:`input`,path:`context.contextLeft`,type:`number`,default:100},"memento.ceiling":{kind:`input`,path:`memento.ceiling`,type:`number`,default:-1},"memento.off":{kind:`input`,path:`memento.off`,type:`boolean`,default:!1},"memento.session":{kind:`input`,path:`memento.session`,default:``},"memento.error":{kind:`input`,path:`memento.error`,default:``},"metrics.lastResponseTime":{kind:`input`,path:`metrics.lastResponseTime`,type:`number`,default:0},"metrics.responseTime":{kind:`input`,path:`metrics.responseTime`,type:`number`,default:0},"metrics.sessionDuration":{kind:`input`,path:`metrics.sessionDuration`,type:`number`,default:0},"metrics.messageCount":{kind:`input`,path:`metrics.messageCount`,type:`number`,default:0},"metrics.linesAdded":{kind:`input`,path:`metrics.linesAdded`,type:`number`,default:0},"metrics.linesRemoved":{kind:`input`,path:`metrics.linesRemoved`,type:`number`,default:0},"activity.command":{kind:`input`,path:`activity.command`,type:`string`,default:``},"activity.todo.total":{kind:`input`,path:`activity.todo.total`,type:`number`,default:0},"activity.todo.completed":{kind:`input`,path:`activity.todo.completed`,type:`number`,default:0},"activity.todo.position":{kind:`input`,path:`activity.todo.position`,type:`number`,default:0},"activity.todo.active":{kind:`input`,path:`activity.todo.active`,type:`string`,default:``},"activity.tool.running":{kind:`input`,path:`activity.tool.running`,type:`string`,default:``},"activity.tool.done":{kind:`input`,path:`activity.tool.done`,type:`string`,default:``}},segments:{directory:{group:`location`,description:"The current directory, shortened fish-style — `~` under home, project-relative inside the project. Click to copy the full path.",template:XP},model:{group:`model-context`,description:`The active model's display name.`,template:`✱ {{ formatModelName .model.display_name }}`,when:`{{ ne .model.display_name "" }}`},sessionId:{group:`session-tools`,description:`The session id, truncated to 8 characters.`,template:`⌗{{ trunc 8 .session.id }}`,when:`{{ ne .session.id "" }}`},version:{group:`model-context`,description:`The Claude Code version reported in the hook payload.`,template:`◈ v{{ .version }}`,when:`{{ ne .version "" }}`},tmux:{group:`location`,description:`The tmux session name; hidden when not inside tmux.`,template:`tmux:{{ .tmux.session | default "none" }}`,when:`{{ ne .tmux.session "" }}`},host:{group:`location`,description:`user@host on a warning background, shown only over SSH.`,template:`⇄ {{ .host.user | default "?" }}@{{ .host.name | default "?" }}`,bg:`warning`,when:`{{ .host.ssh }}`},gitaculous:{group:`git`,description:`The git state: a summary (branch, ahead/behind, S/U/? flags) that the arrow at its right edge expands to every fact — repo, in-progress operation, sha, upstream ±, stash count, time since the last commit.`,template:`{{ if eq .git.detail "expanded" }}{{ template "gitExpanded" . }}{{ else }}{{ template "gitCollapsed" . }}{{ end }} {{ action "gitDetail" "▸" "◂" }}`,fg:ZP,when:`{{ ne .git.branch "" }}`,settings:{aheadBehind:{label:`ahead/behind`,domain:`bool`,default:!0},flags:{label:`dirty flags`,domain:`bool`,default:!0},operation:{label:`operation`,domain:`bool`,default:!0},repo:{label:`repo name`,domain:`bool`,default:!0},sha:{label:`commit hash`,domain:`bool`,default:!0},stash:{label:`stash`,domain:`bool`,default:!0},upstream:{label:`upstream`,domain:`bool`,default:!0},age:{label:`time since commit`,domain:`bool`,default:!0}}},gitPr:{group:`git`,description:"The pull request open for this branch, as a link; `⚠ PR` when the forge lookup failed.",template:`{{ if ne .git.prUrl "" }}{{ link .git.prUrl (printf "⇆ #%v" .git.prNumber) }}{{ else }}⚠ PR{{ end }}`,when:`{{ or (ne .git.prUrl "") (ne .git.prError "") }}`},toolbar:{group:`session-tools`,description:`Quick actions: copy the session id, and open the project, transcript or repo.`,template:bT(``).template},commands:{group:`session-tools`,description:`Type /compact, /model or /clear into this session; /clear asks for a second click. Hidden when not inside tmux.`,template:qP.template,when:qP.when},themeSwitcher:{group:`session-tools`,description:"`◀ <theme> ▶`: the theme the bar is wearing; ◀ and ▶ switch this session to the previous or next theme, wrapping at the ends.",template:`{{ carousel "stepTheme" 0 }}`},session:{group:`cost-limits`,description:`This session's cost and token total, with a budget warning once a budget is configured.`,template:`§ {{ template "formatCost" .session.cost }} ({{ template "formatTokens" .session.tokens }}){{ template "budgetStatus" (dict "cost" .session.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:eF(0)},today:{group:`cost-limits`,description:`Today's cost and tokens across every session, with a budget warning once a budget is configured.`,template:`☉ {{ template "formatCost" .today.cost }} ({{ template "formatTokens" .today.tokens }}){{ template "budgetStatus" (dict "cost" .today.cost "budget" .settings.budget "warn" .settings.warnAt) }}`,settings:eF(50)},block:{group:`cost-limits`,description:`The 5-hour rate-limit block: percent used and time to reset, heating to warning then error.`,template:`◱ {{ round .block.nativeUtilization }}% ({{ template "formatResetCountdown" .block.resetsAt }})`,bg:`{{ ramp (round .block.nativeUtilization) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:$P,when:`{{ gt .block.resetsAt 0 }}`},weekly:{group:`cost-limits`,description:`The weekly rate-limit quota: percent used and time to reset, heating to warning then error.`,template:`◑ {{ round .weekly.percentage }}% ({{ template "formatResetCountdown" .weekly.resetsAt }})`,bg:`{{ ramp (round .weekly.percentage) "step" 0 (tint) .settings.warnAt "warning" .settings.errorAt "error" }}`,settings:$P,when:`{{ gt .weekly.resetsAt 0 }}`},burnrate:{group:`cost-limits`,description:`Spend per hour, with the projected time to the 5-hour and weekly limits.`,template:`⚡ {{ template "formatRate" .burn.costPerHour }} · {{ template "formatEta" .block.etaMinutes }} to 5h · {{ template "formatEta" .weekly.etaMinutes }} to wk`,bg:`{{ ramp .block.etaMinutes "step" -1 (tint) 0 "error" .settings.errorWithin "warning" .settings.warnWithin (tint) }}`,settings:{errorWithin:{label:`error within (min)`,domain:{min:0,max:300,step:5},default:30},warnWithin:{label:`warning within (min)`,domain:{min:0,max:300,step:5,atLeast:`errorWithin`},default:60}},when:`{{ or (gt .block.resetsAt 0) (gt .weekly.resetsAt 0) }}`},speed:{group:`activity`,description:`Token throughput for the latest exchange: output, input, and total.`,template:`⇅ out {{ template "formatSpeed" .speed.output }} · in {{ template "formatSpeed" .speed.input }} · tot {{ template "formatSpeed" .speed.total }}`,when:`{{ gt .session.tokens 0 }}`},tokenSparkline:{group:`activity`,description:`A sparkline of recent token throughput.`,template:`⚡ {{ sparkline .speed.history 24 }}`,when:`{{ ne .speed.history "" }}`},cacheTimer:{group:`activity`,description:"Minutes until the prompt cache expires, or `cold` once it has.",template:`◴ {{ if le (minutesUntilReset .cache.expiresAt) 0 }}cold{{ else }}{{ minutesUntilReset .cache.expiresAt }}m{{ end }}`,fg:`{{ readableOn (color (cascade (minutesUntilReset .cache.expiresAt) "0:error" "9:warning" "21:foreground")) (bgOf) ${tc} }}`,when:`{{ gt .cache.expiresAt 0 }}`},context:{group:`model-context`,description:`Context used, in tokens and percent remaining, heating as it fills.`,template:`◔ {{ formatInteger .context.totalTokens }} ({{ .context.contextLeft }}%)`,bg:`{{ ramp .context.contextLeft "step" 0 "error" 21 "warning" 41 (tint) }}`,when:`{{ gt .context.totalTokens 0 }}`},ceiling:{group:`model-context`,description:`The memento plugin's context ceiling for this session: − and + move it by 100K, ∞ lifts it, ↺ drops this session's own setting.`,template:`{{ if ne .memento.error "" }}⌈ ⚠ {{ .memento.error }} {{ action "ceiling.clear" "↺" }}{{ else }}⌈ {{ if .memento.off }}off{{ else }}{{ template "formatTokenCount" .memento.ceiling }} {{ action "ceiling.lower" "−" }} {{ action "ceiling.raise" "+" }} {{ action "ceiling.off" "∞" }}{{ end }}{{ if ne .memento.session "" }} {{ action "ceiling.clear" "↺" }}{{ end }}{{ end }}`,bg:`{{ if ne .memento.error "" }}{{ color "error" }}{{ else }}{{ tint }}{{ end }}`,when:`{{ or (ge .memento.ceiling 0) (ne .memento.error "") }}`},autocompact:{group:`model-context`,description:`Claude Code's auto-compact window: − and + move it by 100K, ↺ returns it to auto. Clicks type /autocompact into this session, so the controls show only inside tmux.`,template:JP.template,bg:JP.bg,when:JP.when},metrics:{group:`activity`,description:`Response times, session duration, message count, and lines added/removed.`,template:`{{ if .metrics.lastResponseTime }} Δ {{ template "formatResponseTime" .metrics.lastResponseTime }}{{ end }}{{ if .metrics.responseTime }} ⧖ {{ template "formatResponseTime" .metrics.responseTime }}{{ end }}{{ if .metrics.sessionDuration }} ⧗ {{ template "formatDuration" .metrics.sessionDuration }}{{ end }}{{ if .metrics.messageCount }} ◆ {{ .metrics.messageCount }}{{ end }}{{ if .metrics.linesAdded }} + {{ .metrics.linesAdded }}{{ end }}{{ if .metrics.linesRemoved }} - {{ .metrics.linesRemoved }}{{ end }} `,when:`{{ or (gt .metrics.lastResponseTime 0.0) (gt .metrics.responseTime 0.0) (gt .metrics.sessionDuration 0.0) (gt .metrics.messageCount 0) (gt .metrics.linesAdded 0) (gt .metrics.linesRemoved 0) }}`},activity:{group:`activity`,description:`What Claude is doing: the slash command that opened the turn, the in-progress todo, and the tools in flight.`,template:`{{ if .activity.command }} ⌘ {{ .activity.command }}{{ end }}{{ if .activity.todo.total }}{{ if .activity.todo.active }} ☐ {{ .activity.todo.position }}/{{ .activity.todo.total }} {{ abbrev 32 .activity.todo.active }}{{ else }} ☑ {{ .activity.todo.completed }}/{{ .activity.todo.total }}{{ end }}{{ end }}{{ if .activity.tool.running }} ⟳ {{ template "formatToolTally" .activity.tool.running }}{{ end }}{{ if .activity.tool.done }} ✓ {{ template "formatToolTally" .activity.tool.done }}{{ end }} `,when:`{{ or (ne .activity.command "") (gt .activity.todo.total 0) (ne .activity.tool.running "") (ne .activity.tool.done "") }}`}},root:{rows:{identity:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`}]},status:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`activity`}]}}},actions:{...bT(``).actions,...qP.actions,copyDir:{copy:`{{ .current_dir }}`},stepTheme:{set:`theme`,from:`themes`},gitDetail:{set:`git-detail`,cycle:[`collapsed`,`expanded`]},"ceiling.raise":{ceiling:`set`,to:`+100_000`},"ceiling.lower":{ceiling:`set`,to:`-100_000`},"ceiling.off":{ceiling:`set`,to:`off`},"ceiling.clear":{ceiling:`clear`},...JP.actions},styles:{none:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:0},vivid:{hueShift:0,chromaScale:1.35,lightnessScale:1,lightnessShift:0},muted:{hueShift:0,chromaScale:.55,lightnessScale:1,lightnessShift:0},dim:{hueShift:0,chromaScale:1,lightnessScale:.85,lightnessShift:0},bright:{hueShift:0,chromaScale:1,lightnessScale:1,lightnessShift:.08},inverted:{hueShift:0,chromaScale:1,lightnessScale:-1,lightnessShift:1}},themeDefaults:KP,presets:{default:{},compact:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`context`}]},globals:{padding:0}},verbose:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},zen:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`directory`},{kind:`segment`,name:`context`}]},globals:{endcaps:`plain`,style:`dim`}},git:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`gitPr`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`segment`,name:`context`},{kind:`segment`,name:`activity`}]}]}},usage:{root:{kind:`container`,direction:`vertical`,children:[{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`burnrate`}]},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`session`},{kind:`segment`,name:`today`},{kind:`segment`,name:`speed`},{kind:`segment`,name:`tokenSparkline`}]}]}},dense:{root:{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`host`},{kind:`segment`,name:`directory`},{kind:`segment`,name:`gitaculous`},{kind:`segment`,name:`model`},{kind:`container`,direction:`horizontal`,children:[{kind:`segment`,name:`context`},{kind:`segment`,name:`ceiling`},{kind:`segment`,name:`autocompact`}]},{kind:`segment`,name:`cacheTimer`},{kind:`segment`,name:`block`},{kind:`segment`,name:`weekly`},{kind:`segment`,name:`session`},{kind:`segment`,name:`activity`}]},globals:{padding:0}}},editGlobals:{endcaps:`plain`,default_separator:` | `},helpers:{gitPaint:`{{ fg (readableOn (color .color) (bgOf) ${tc}) .text }}`,gitCollapsed:`{{ template "gitBranch" . }}{{ template "gitAheadBehind" . }}{{ template "gitFlags" . }}`,gitExpanded:`(git){{ template "gitRepo" . }}{{ template "gitOperation" . }}{{ template "gitSha" . }}{{ template "gitFlags" . }} {{ template "gitBranch" . }}{{ template "gitUpstream" . }}{{ template "gitStash" . }}{{ template "gitAge" . }}`,gitBranch:`⎇ {{ template "gitPaint" (dict "color" .git.color.branch "text" .git.branch) }}`,gitRepo:`{{ if and .settings.repo (ne .git.repoName "") }} {{ .git.repoName }}{{ end }}`,gitOperation:`{{ if and .settings.operation (ne .git.operation "") }} [{{ .git.operation }}]{{ end }}`,gitSha:`{{ if and .settings.sha (ne .git.sha "") }} {{ .git.sha }}{{ end }}`,gitFlags:`{{ if and .settings.flags (or (gt .git.staged 0) (gt .git.unstaged 0) (gt .git.untracked 0) (gt .git.conflicts 0)) }} {{ if gt .git.staged 0 }}{{ template "gitPaint" (dict "color" .git.color.staged "text" "S") }}{{ end }}{{ if gt .git.unstaged 0 }}{{ template "gitPaint" (dict "color" .git.color.unstaged "text" "U") }}{{ end }}{{ if gt .git.untracked 0 }}{{ template "gitPaint" (dict "color" .git.color.untracked "text" "?") }}{{ end }}{{ if gt .git.conflicts 0 }}{{ template "gitPaint" (dict "color" .git.color.conflicts "text" (printf "!%v" .git.conflicts)) }}{{ end }}{{ end }}`,gitAheadBehind:`{{ if and .settings.aheadBehind (or (gt .git.ahead 0) (gt .git.behind 0)) }} {{ if gt .git.ahead 0 }}{{ template "gitPaint" (dict "color" .git.color.ahead "text" (printf "+%v" .git.ahead)) }}{{ end }}{{ if and (gt .git.ahead 0) (gt .git.behind 0) }}/{{ end }}{{ if gt .git.behind 0 }}{{ template "gitPaint" (dict "color" .git.color.behind "text" (printf "-%v" .git.behind)) }}{{ end }}{{ end }}`,gitUpstream:`{{ if and .settings.upstream (ne .git.upstream "") }} [{{ .git.upstream }}{{ template "gitAheadBehind" . }}]{{ end }}`,gitStash:`{{ if and .settings.stash (gt .git.stash 0) }} {{ template "gitPaint" (dict "color" .git.color.stash "text" (printf "(%v stashed)" .git.stash)) }}{{ end }}`,gitAge:`{{ if and .settings.age (gt .git.timeSinceCommit 0) }} ◷ {{ template "formatTimeSince" .git.timeSinceCommit }}{{ end }}`,formatCost:'{{ if lt . 0.01 }}<$0.01{{ else }}${{ printf "%.2f" . }}{{ end }}',formatTokenCount:KT(`.`),formatTokens:`{{ template "formatTokenCount" . }} tokens`,formatToolTally:`{{ $names := splitList "," . }}{{ range $i, $pair := $names }}{{ if lt $i 2 }}{{ if $i }} {{ end }}{{ $kv := splitList ":" $pair }}{{ index $kv 0 }}{{ if ne (index $kv 1) "1" }}×{{ index $kv 1 }}{{ end }}{{ end }}{{ end }}{{ if gt (len $names) 2 }} +{{ sub (len $names) 2 }}{{ end }}`,formatRate:`{{ if lt . 0 }}—/hr{{ else }}{{ template "formatCost" . }}/hr{{ end }}`,formatEta:`{{ if lt . 0 }}—{{ else }}{{ template "formatLongTimeRemaining" . }}{{ end }}`,formatSpeed:`{{ if lt . 0 }}—{{ else }}{{ template "formatTokenCount" (round .) }}/s{{ end }}`,formatTokenBreakdown:`{{ $first := true }}{{ if gt .input 0 }}{{ template "formatTokenCount" .input }} in{{ $first = false }}{{ end }}{{ if gt .output 0 }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" .output }} out{{ $first = false }}{{ end }}{{ if or (gt .cacheCreation 0) (gt .cacheRead 0) }}{{ if not $first }} + {{ end }}{{ template "formatTokenCount" (add .cacheCreation .cacheRead) }} cached{{ $first = false }}{{ end }}{{ if $first }}0 tokens{{ end }}`,budgetStatus:`{{ if or (le .budget 0) (lt .cost 0) }}{{ else }}{{ $pct := minf 100 (mulf (divf .cost .budget) 100) }}{{ $p := printf "%.0f%%" $pct }}{{ if ge $pct .warn }} !{{ $p }}{{ else }}{{ if ge $pct 50 }} +{{ $p }}{{ else }} {{ $p }}{{ end }}{{ end }}{{ end }}`,formatTimeSince:`{{ if lt . 60 }}{{ . }}s{{ else if lt . 3600 }}{{ div . 60 }}m{{ else if lt . 86400 }}{{ div . 3600 }}h{{ else if lt . 604800 }}{{ div . 86400 }}d{{ else }}{{ div . 604800 }}w{{ end }}`,formatDuration:`{{ if lt . 60 }}{{ printf "%.0f" . }}s{{ else if lt . 3600 }}{{ printf "%.0f" (divf . 60) }}m{{ else if lt . 86400 }}{{ printf "%.1f" (divf . 3600) }}h{{ else }}{{ printf "%.1f" (divf . 86400) }}d{{ end }}`,formatResponseTime:`{{ if lt . 60 }}{{ printf "%.1f" . }}s{{ else }}{{ printf "%.1f" (divf . 60) }}m{{ end }}`,formatLongTimeRemaining:`{{ if ge . 1440 }}{{ $d := div . 1440 }}{{ $h := div (mod . 1440) 60 }}{{ if gt $h 0 }}{{ $d }}d {{ $h }}h{{ else }}{{ $d }}d{{ end }}{{ else if ge . 60 }}{{ $h := div . 60 }}{{ $m := mod . 60 }}{{ if gt $m 0 }}{{ $h }}h {{ $m }}m{{ else }}{{ $h }}h{{ end }}{{ else }}{{ . }}m{{ end }}`,formatResetCountdown:`{{ template "formatLongTimeRemaining" (add 1 (minutesUntilReset .)) }}`}},nF=new Set([tF.globals.palette,...Object.keys(tF.themeDefaults),...Object.values(tF.segments).map(e=>e.palette)].filter(e=>e!==void 0)),rF=Id(wA(`<default>`,JSON.stringify(tF),nF),tF),iF=Nb(rF.presets);function aF(e){return iF.includes(e)}const oF=Object.freeze({});function sF(e,t){return e.kind===`decided`?t[e.name]??oF:oF}function cF(e,t){return{...e,...Object.fromEntries(ku.map(n=>[n,e[n]??t[n]]))}}function lF(e){if(!e)return 0;try{return s(e).mtimeMs}catch{return 0}}const uF=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 dF(e){return((...t)=>uF.run(()=>e(...t)))}const fF=dF(ee),pF=dF(C),mF=dF(w);async function hF(e,t){return uF.run(async()=>{let n=null;try{n=await S(e,`r`);let{size:r,mtimeMs:i,ino:a}=await n.stat(),o=t!==void 0&&(a!==t.ino||r<t.offset),s=o||t===void 0?0:t.offset;if(s>=r)return J({buf:Buffer.alloc(0),start:s,size:r,mtimeMs:i,ino:a,reset:o});let c=Buffer.alloc(r-s),l=0;for(;l<c.length;){let{bytesRead:e}=await n.read(c,l,c.length-l,s+l);if(e===0)break;l+=e}return J({buf:l===c.length?c:c.subarray(0,l),start:s,size:r,mtimeMs:i,ino:a,reset:o})}catch(t){return t.code===`ENOENT`?Y:X(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{D(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}async function gF(e,t){return uF.run(async()=>{let n=null;try{n=await S(e,`r`);let{size:r}=await n.stat(),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let{bytesRead:e}=await n.read(a,o,a.length-o,i+o);if(e===0)break;o+=e}return J({buf:o===a.length?a:a.subarray(0,o),fromStart:i===0})}catch(t){return t.code===`ENOENT`?Y:X(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{D(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}const _F=/"(?:cache_read_input_tokens|cache_creation_input_tokens)":[1-9]/;function vF(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 yF(e){let t=await bF(e);return t.kind===`ok`?J(Math.floor((t.value+36e5)/1e3)):t}async function bF(e){for(let t of[65536,1048576]){let n=await gF(e,t);if(n.kind!==`ok`)return n;let r=xF(n.value.buf,n.value.fromStart);if(r!=null)return J(r);if(n.value.fromStart)return Y}return Y}function xF(e,t){let n=e.toString(`utf8`).split(`
|
|
184
184
|
`),r=+!t;for(let e=n.length-1;e>=r;e--){let t=n[e];if(!t||!_F.test(t))continue;let r=vF(t);if(r!=null)return r}return null}function SF(e,t){return{...e,claudeConfigDir:NT(t.claudeConfigDir),env:t.mementoEnv}}const CF=l.join(`lib`,`ceiling_config.py`),wF=l.join(`skills`,`ceiling`,`bin`,`ceiling`);function TF(e,t){let n=typeof e==`object`&&e?e.plugins:void 0;if(typeof n!=`object`||!n)throw Error(`${t} has no "plugins" object`);return Object.entries(n).filter(([e])=>e.split(`@`)[0]===`memento`).flatMap(([e,n])=>{if(!Array.isArray(n))throw Error(`${t}: "${e}" is not a list of installs`);return n.map(n=>{let{scope:r,installPath:i,projectPath:a}=n??{};if(typeof r!=`string`||typeof i!=`string`)throw Error(`${t}: an install of "${e}" has no scope/path`);return typeof a==`string`?{key:e,scope:r,installPath:i,projectPath:a}:{key:e,scope:r,installPath:i}})})}function EF(e,t){let n=!0;for(let i of e){if(!r.existsSync(i))continue;let e;try{e=JSON.parse(r.readFileSync(i,`utf8`))?.enabledPlugins?.[t]}catch(e){return X(`memento lookup: ${i}: ${e.message}`)}typeof e==`boolean`&&(n=e)}return J(n)}function DF(e,t){if(!r.existsSync(e))return Y;let n;try{n=TF(JSON.parse(r.readFileSync(e,`utf8`)),e)}catch(e){return X(`memento lookup: ${e.message}`)}let i=n.find(e=>e.projectPath===t)??n.find(e=>e.scope===`user`);if(i===void 0)return Y;let a=EF([l.join(l.dirname(l.dirname(e)),`settings.json`),l.join(t,`.claude`,`settings.json`),l.join(t,`.claude`,`settings.local.json`)],i.key);if(a.kind!==`ok`)return a;if(!a.value)return Y;let o=[CF,wF].filter(e=>!r.existsSync(l.join(i.installPath,e)));return o.length===0?J(i.installPath):X(`memento at ${i.installPath} has no ${o.join(` or `)} — upgrade the plugin`)}function OF(e,t=process.env){let n=new Set([`CLAUDE_PROJECT_DIR`,`CLAUDE_CODE_SESSION_ID`,...e.env===void 0?[]:$e]);return{...Object.fromEntries(Object.entries(t).filter(([e])=>!n.has(e))),...e.env,CLAUDE_CODE_SESSION_ID:e.sessionId,CLAUDE_PROJECT_DIR:e.projectDir||e.cwd}}function kF(e){return e.stderr.trim()||e.error||`${e.reason}${e.exitCode===null?``:` (exit ${e.exitCode})`}`}function AF(e){let t;try{t=JSON.parse(e)}catch{return X(`memento read: not JSON: ${e.trim()}`)}let{ceiling:n,session:r}=t??{},i=n===`off`||typeof n==`number`&&n>=0?n:void 0;return i!==void 0&&(r===null||typeof r==`string`)?J({ceiling:i,session:r}):X(`memento read: unexpected answer: ${e.trim()}`)}async function jF(e,t){let n=await je({bin:`python3`,args:[`-c`,`
|
|
185
185
|
import json, math, sys
|
|
186
186
|
sys.path.insert(0, sys.argv[1])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptctl/cc-candybar",
|
|
3
|
-
"version": "1.129.
|
|
3
|
+
"version": "1.129.1",
|
|
4
4
|
"description": "Statusline renderer for Claude Code — a JSON5-configurable DSL with daemon-cached data sources, byte-clean palette-aware composition, and OSC8 click verbs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -101,9 +101,9 @@
|
|
|
101
101
|
"typescript": "^5.0.0"
|
|
102
102
|
},
|
|
103
103
|
"optionalDependencies": {
|
|
104
|
-
"@promptctl/cc-candybar-darwin-arm64": "1.129.
|
|
105
|
-
"@promptctl/cc-candybar-darwin-x64": "1.129.
|
|
106
|
-
"@promptctl/cc-candybar-linux-x64": "1.129.
|
|
107
|
-
"@promptctl/cc-candybar-linux-arm64": "1.129.
|
|
104
|
+
"@promptctl/cc-candybar-darwin-arm64": "1.129.1",
|
|
105
|
+
"@promptctl/cc-candybar-darwin-x64": "1.129.1",
|
|
106
|
+
"@promptctl/cc-candybar-linux-x64": "1.129.1",
|
|
107
|
+
"@promptctl/cc-candybar-linux-arm64": "1.129.1"
|
|
108
108
|
}
|
|
109
109
|
}
|