@gruum/cli 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/gruum.mjs +94 -86
  2. package/package.json +1 -1
package/gruum.mjs CHANGED
@@ -1,91 +1,99 @@
1
1
  #!/usr/bin/env node
2
- import{chmodSync as Ic,existsSync as je,rmSync as On}from"node:fs";import V from"node:path";import{createInterface as Dn}from"node:readline";var Eo=new Set(["display","position","inset","top","right","bottom","left","z-index","order","flex","flex-grow","flex-shrink","flex-basis","align-self","justify-self","align-items","justify-content","place-items","place-content","gap","text-align","min-width","max-width","overflow","white-space","cursor"]),jo=new Set(["page","index","layout","route","default"]);function Io(t){return Eo.has(t.property)||/^(margin|transition|grid-)/.test(t.property)?!0:(t.property==="width"||t.property==="height")&&/^(100%|auto)$/.test(t.value)}function Dt(t){return t.flatMap(e=>e.declarations.filter(n=>!Io(n)).map(n=>`${e.state}|${e.context}|${n.property}:${n.value}`)).sort().join(";")}function Lo(t){return Dt(t.states)}function Mo(t){return t.states.filter(e=>e.state==="default"&&e.context==="").flatMap(e=>e.declarations)}function Bn(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Po(t){let e=t.via?/^bg-([\w-]+?)(?:\/(\d+))?$/.exec(t.via):null;if(e){let s=e[1].replace(/-/g," ");return Bn(e[2]?`${s} ${e[2]}%`:s)}let n=/var\(\s*--(?:color-)?([\w-]+)/.exec(t.value)?.[1];return Bn((n??t.value).replace(/-/g," "))}function Oo(t){let e=Mo(t),n=u=>e.findLast(f=>f.property===u),s=n("background-color")??n("background"),r=s!==void 0&&!/^(transparent|none|initial|inherit)\b/.test(s.value),o=n("border-width")?.value,i=o!==void 0&&!/^0(px)?$/.test(o)&&n("border-style")?.value!=="none",a=n("width")?.value,l=a!==void 0&&a===n("height")?.value&&!/^(auto|100%|fit-content)$/.test(a);return n("inset")?.value==="0"?"Overlay":i?l?"Outline icon":"Outline":r?`${Po(s)} ${l?"icon":"fill"}`:l?"Icon":e.some(u=>u.property.startsWith("padding")||u.property==="border-radius"||u.property==="height"&&u.value!=="auto")?"Ghost":"Text"}function Do(t){let e=t.split("/"),n=(e.pop()??t).replace(/\.[^.]+$/,""),s=e.pop();return jo.has(n)&&s?`${s}/${n}`:n}function To(t){let e=[...new Set(t.map(s=>Do(s.path)))],n=e.slice(0,2).join(", ");return e.length>2?`${n} +${e.length-2}`:n}var Fn=(t,e)=>t.path.localeCompare(e.path)||t.line-e.line;function Un(t){let e=new Map;for(let r of t){let o=Oo(r.variant),i=e.get(o)??new Map,a=Lo(r.variant),l=i.get(a)??{looks:[],sites:[]};l.looks.push(r.variant),l.sites.push(...r.sites),i.set(a,l),e.set(o,i)}let n=[],s=new Map;for(let[r,o]of e){let i=[...o.values()];for(let b of i)b.sites.sort(Fn);i.sort((b,k)=>k.sites.length-b.sites.length||Fn(b.sites[0],k.sites[0]));let[a,...l]=i,c=a.looks[0],u=l.map(b=>To(b.sites)),f=l.map((b,k)=>{let C=b.looks[0],g={title:u.filter(p=>p===u[k]).length>1?`${u[k]} \xB7 line ${b.sites[0].line}`:u[k],selector:C.selector,path:b.sites[0].path,line:b.sites[0].line,element:C.element,usage:C.usage,states:C.states,alike:!0};return s.set(g,b.sites),g}),m={...c,title:r,axis:null,base:!1,path:a.sites[0].path,line:a.sites[0].line,markup:!0,...f.length?{modifiers:f}:{}};s.set(m,a.sites),n.push(m)}return{variants:n,sites:s}}var Gn=1,Hn=["style.new","state.changed","state.missing","token.unknown","value.hardcoded","native.element","prop.unknown","style.removed","guidance.rule"],De={"style.new":"block","state.changed":"block","state.missing":"block","token.unknown":"block","value.hardcoded":"block","native.element":"block","prop.unknown":"block","style.removed":"warn","guidance.rule":"warn"};function Te(t){let e=0;for(let n=0;n<t.length;n++)e=e*33+t.charCodeAt(n)>>>0;return e.toString(36)}function zn(t){let e=`${t.path}::${t.selector}`;return`v2-style-${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)}-${Te(e)}`}function ot(t){return t.context?`${t.state} @ ${t.context}`:t.state}var No=/var\(\s*(--[\w-]+)/g;function Vo(t){let e=new Set;for(let n of t)for(let s of n.declarations)for(let r of s.value.matchAll(No))e.add(r[1]);return[...e].sort()}function Bo(t){let e=new Map;for(let n of t)e.set(n.property,n.value.trim());return[...e].map(([n,s])=>({property:n,value:s})).sort((n,s)=>n.property.localeCompare(s.property))}function Fo(t){let e=new Map;for(let n of t){let s=ot(n),r=e.get(s),o=Bo([...r?.declarations??[],...n.declarations]);e.set(s,{state:n.state,context:n.context,declarations:o})}return[...e.values()]}function Kn(t){let e=new Map,n=(s,r,o)=>{let i=zn(s),a=e.get(i),l=Fo([...a?Uo(a.states):[],...r]),c=a?.stateLines??new Map;for(let u of r)c.has(ot(u))||c.set(ot(u),u.line);e.set(i,{...a??s,id:i,states:l,tokens:Vo(l),line:a?.line??o,stateLines:c})};for(let s of t){let r=zn(s);n({kind:"look",title:s.title,selector:s.selector,path:s.path,axis:s.axis,...s.usage.via?{selectedBy:s.usage.via}:{},...s.element?{element:s.element.tag}:{},...s.markup?{markup:!0}:{}},s.states,s.line);for(let o of s.modifiers??[])n({kind:"modifier",title:`${s.title} \xB7 ${o.title}`,selector:o.selector,path:o.path,hostId:r,...o.usage.via?{selectedBy:o.usage.via}:{},...o.element?{element:o.element.tag}:{},...o.alike?{markup:!0}:{}},o.states,o.line);for(let o of s.contexts??[])n({kind:"context",title:`${s.title} in ${o.selector}`,selector:o.selector,path:o.path,hostId:r,role:o.role,...o.element?{element:o.element.tag}:{}},o.states,o.line)}return e}function Uo(t){return t.map(e=>({state:e.state,context:e.context,line:0,declarations:e.declarations}))}function zo(t){let e=new Map,n=/^:root\{([^}]*)\}/.exec(t);if(!n)return e;for(let s of n[1].split(";")){let r=s.indexOf(":");if(r<=0)continue;let o=s.slice(0,r).trim();o.startsWith("--")&&e.set(o,s.slice(r+1).trim())}return e}var Wn=/^(\d+) native /;function Wo(t,e){if(t==="native")return`native:${e.refs[0]?.path??""}`;if(e.styles?.length){let n=[...new Set(e.refs.map(s=>s.path))].sort().join(",");return`${t}:${[...e.styles].sort().join(",")}:${n}`}return`${t}:${e.refs.map(n=>n.path).join(",")}:${e.message}`}var Xt={hardcoded:"value.hardcoded",native:"native.element",props:"prop.unknown"},Go=new Set(Object.values(Xt));var Ho={"value.hardcoded":()=>"Replace each literal with the spec token named, or with a spec token for that property.","native.element":t=>`Render ${t.components[0]??"the shared component"} instead of a raw <button>, or ask for an exception.`,"prop.unknown":()=>"Use one of the values listed, or ask for an exception to add the look."};function Jn(t){let e=[];for(let n of t.audit)if(n.status==="attention")for(let s of n.findings)e.push({check:n.id,finding:s,key:Wo(n.id,s)});return e}function Me(t){return`${t.path}#${Te(t.text.replace(/\s+/g," ").trim())}`}function Zn(t,e={}){let n=zo(t.previewCss),s=[...Kn(t.variants).values()].map(({line:i,stateLines:a,...l})=>l),r=new Set(t.tokens.map(i=>i.name)),o=[];for(let i of t.guidance.files)if(i.kind!=="record")for(let a of i.passages)a.rule&&o.push({path:a.path,headings:a.headings,text:a.text,styles:a.styles});return{schema:Gn,concept:t.concept,label:t.label,version:e.version??0,sourceRef:t.repo.ref,publishedAt:e.publishedAt??null,components:[...t.components].sort(),tokens:[...new Set([...t.tokens.map(i=>i.name),...s.flatMap(i=>i.tokens).filter(i=>!r.has(i))])].map(i=>{let a=n.get(i);return a===void 0?{name:i}:{name:i,value:a}}).sort((i,a)=>i.name.localeCompare(a.name)),styles:s,rules:o,content:t.content.map(i=>i.id),acceptedFindings:Jn(t).filter(({check:i})=>i in Xt).map(({check:i,finding:a,key:l})=>({check:i,key:l,message:a.message})),settings:{severity:{...De,...e.settings?.severity??{}}}}}function Ko(t,e){let n=new Map(t.map(o=>[o.property,o.value])),s=new Map(e.map(o=>[o.property,o.value])),r=[];for(let[o,i]of s){let a=n.get(o);a===void 0?r.push(`added ${o}: ${i}`):a!==i&&r.push(`${o}: ${a} \u2192 ${i}`)}for(let[o,i]of n)s.has(o)||r.push(`removed ${o}: ${i}`);return r}function Oe(t){return t.map(e=>`${e.property}: ${e.value}`).join("; ")}function Pe(t,e){return t.length>e?`${t.slice(0,e).join(", ")}, and ${t.length-e} more`:t.join(", ")}function Jo(t,e){let n=t.replace(/^--/,"").split("-")[0]??"",s=n?e.filter(r=>r.startsWith(`--${n}`)):[];return(s.length?s:e).slice(0,3)}function Xn(t,e){let n={...De,...e.settings.severity},s=[],r=(p,d="")=>{s.push({id:`${p.kind}:${Te(`${p.styleId??""}|${p.state??""}|${d}`)}`,severity:n[p.kind],...p})},o=Kn(t.variants),i=new Map(e.styles.map(p=>[p.id,p])),a=e.styles.filter(p=>p.kind==="look"),l=new Set([...e.tokens.map(p=>p.name),...e.styles.flatMap(p=>p.tokens)]),c=[...l],u=new Map;for(let p of e.styles)p.markup&&u.set(Dt(p.states),p);let f=new Map;for(let p of o.values()){if(!p.markup)continue;let d=u.get(Dt(p.states));d&&f.set(p.id,d)}let m=new Set([...f.values()].map(p=>p.id)),b=p=>p.markup?`${p.title} (as in ${p.path})`:p.selector;for(let p of o.values()){if(i.has(p.id)||f.has(p.id))continue;let d=p.hostId?i.get(p.hostId):void 0,y=p.markup?a.filter(j=>j.markup):a,w=y.filter(j=>j.path===p.path),x=(w.length?w:y).map(b),$=p.markup?`This one-off ${p.element??"button"} (${Pe((p.states[0]?.declarations??[]).map(j=>`${j.property}: ${j.value}`),3)})`:p.selector,I=p.markup?e.components.length?`render ${e.components[0]} with a spec look,`:x.length?`copy ${Pe(x,3)},`:"use a spec style,":d?`restyle ${d.selector} only through spec modifiers`:x.length?`use ${Pe(x,3)},`:"use a spec style,";r({kind:"style.new",styleId:p.id,title:`${p.title} is not in the spec`,baseline:null,observed:{declarations:p.states[0]?.declarations??[],states:p.states,...p.markup?{markup:!0}:{}},refs:[{path:p.path,line:p.line}],fix:`${$} is not in the spec; ${I} or ask for an exception.`},p.markup?Dt(p.states):p.selector)}for(let p of o.values()){let d=i.get(p.id);if(!d)continue;let y=new Map(d.states.map(w=>[ot(w),w]));for(let w of p.states){let x=ot(w),$=y.get(x),I=Ko($?.declarations??[],w.declarations);I.length!==0&&r({kind:"state.changed",styleId:p.id,title:$?`${p.title}: ${x} changed`:`${p.title}: new ${x} state`,state:x,baseline:$?{declarations:$.declarations}:null,observed:{declarations:w.declarations},refs:[{path:p.path,line:p.stateLines.get(x)??p.line}],fix:$?`Restore ${p.selector} ${x} to the spec (${I.slice(0,3).join("; ")}), or ask for an exception.`:`${x} is not a spec state of ${p.selector}; remove it, or ask for an exception.`},Oe(w.declarations))}}for(let p of o.values()){let d=i.get(p.id);if(!d)continue;let y=new Set(p.states.map(ot));for(let w of d.states){let x=ot(w);y.has(x)||r({kind:"state.missing",styleId:p.id,title:`${p.title}: ${x} state is missing`,state:x,baseline:{declarations:w.declarations},observed:null,refs:[{path:p.path,line:p.line}],fix:`Define ${p.selector} ${x} again: ${Oe(w.declarations)||"as in the spec"}.`})}}for(let p of o.values())for(let d of p.tokens){if(l.has(d))continue;let y=Jo(d,c);r({kind:"token.unknown",styleId:p.id,title:`${p.title} reads ${d}, which is not a spec token`,baseline:null,observed:{token:d},refs:[{path:p.path,line:p.line}],fix:y.length?`Use a spec token such as ${y.join(", ")} instead of ${d}, or ask for an exception.`:`${d} is not a spec token; ask for an exception to add it.`},d)}let k=new Map;for(let p of e.acceptedFindings)k.set(p.key,[...k.get(p.key)??[],p]);let C=Jn(t).filter(({check:p})=>p in Xt);for(let p of Hn)if(Go.has(p))for(let{check:d,finding:y,key:w}of C){if(Xt[d]!==p)continue;let x=k.get(w)??[];if(x.some(A=>!Zo(d,A.message,y.message)))continue;let $=x[0],I=y.styles?.[0],j=I?[...o.values()].find(A=>A.title===I):void 0;r({kind:p,styleId:j?.id??null,title:y.message,baseline:$?{message:$.message}:null,observed:{message:y.message,...p==="native.element"?{element:"button"}:{}},waiverKey:w,refs:y.refs.map(({path:A,line:R})=>({path:A,line:R})),fix:Ho[p](e)},w)}for(let p of e.styles)o.has(p.id)||m.has(p.id)||r({kind:"style.removed",styleId:p.id,title:p.markup?`${p.title} is in the spec but no longer written anywhere`:`${p.title} is in the spec but no longer in CSS`,baseline:{declarations:p.states[0]?.declarations??[]},observed:null,refs:[{path:p.path,line:0}],fix:p.markup?`Nothing renders ${p.title} any more; ask the designer to retire it from the spec if that is intended.`:`Restore ${p.selector} in ${p.path}, or ask the designer to retire it from the spec.`});let v=new Map(t.guidance.files.map(p=>[p.path,p])),g=new Set;for(let p of t.guidance.files)for(let d of p.passages)d.rule&&g.add(Me(d));for(let p of e.rules){if(g.has(Me(p)))continue;let d=v.get(p.path);d&&d.total>d.passages.length||r({kind:"guidance.rule",styleId:null,title:`A written rule in ${p.path} changed or was removed`,baseline:{text:p.text},observed:null,refs:[{path:p.path,line:0}],fix:`Restore the rule under ${p.headings.join(" \u203A ")||p.path}, or publish a new spec.`},Me(p))}return s}function Zo(t,e,n){if(e===n)return!1;if(t==="native"){let s=Wn.exec(e)?.[1],r=Wn.exec(n)?.[1];if(s&&r)return Number(r)>Number(s)}return!0}var Xo={product:"Gruum button spec",what:"The designer-published spec for this repository's buttons. Write buttons against it; drift from it is checked deterministically.",howToUse:["Use the components listed in `components`; do not render a raw <button> where a component exists.","Pick a look from `looks`. `selectedBy` says which prop or attribute value selects it.","Use only the tokens listed in `tokens`. Do not write a literal color or size a token already has.","Follow `rules`; they are the repository's written rules, quoted.","Do not add a look, modifier, or state, and do not change a state's declarations.","If the spec has no button for the job, ask for an exception with a reason instead of inventing one. Never edit generated Gruum files to make a check pass."]};function Ne(t){let e=(n,s)=>t.styles.filter(r=>r.hostId===n&&r.kind===s).map(r=>r.selector);return{about:{...Xo,drift:Hn.map(n=>({kind:n,severity:t.settings.severity[n]??De[n]}))},spec:{concept:t.concept,version:t.version,sourceRef:t.sourceRef,components:t.components,looks:t.styles.filter(n=>n.kind==="look").map(n=>({title:n.title,selector:n.selector,path:n.path,...n.selectedBy?{selectedBy:n.selectedBy}:{},tokens:n.tokens,states:Object.fromEntries(n.states.map(s=>[ot(s),Oe(s.declarations)])),modifiers:e(n.id,"modifier"),contexts:e(n.id,"context")})),tokens:t.tokens,rules:t.rules.map(n=>({path:n.path,under:n.headings.join(" \u203A "),text:n.text}))}}}function qt(t){if(!t||typeof t!="object")return null;let e=t;return e.schema!==Gn||typeof e.concept!="string"||!Array.isArray(e.styles)||!Array.isArray(e.tokens)||!Array.isArray(e.acceptedFindings)||!Array.isArray(e.rules)||!e.settings?.severity?null:e}function qo(t){let e=new Map;for(let n of t){let s=n.refs[0]?.path??"(no file)";e.set(s,[...e.get(s)??[],n])}return[...e].sort(([n],[s])=>n.localeCompare(s))}function Ve(t,e){if(e.length===0)return t;let n=new Set(e.map(s=>s.replace(/^\.\//,"")));return t.filter(s=>s.refs.some(r=>n.has(r.path)))}function qn(t,e,n={}){let s=[];if(t.length===0)return s.push(`No drift against spec v${e.baselineVersion} (${e.files} files indexed, ${e.skipped} skipped).`),s.join(`
3
- `);for(let[o,i]of qo(t)){s.push(o);for(let a of i){let l=a.refs[0]?.line,c=n[a.id],u=c?`${a.severity}, exception ${c}`:a.severity;s.push(` ${l?`${l}: `:""}[${u}] ${a.kind} ${a.title}`),s.push(` fix: ${a.fix}`)}s.push("")}let r=t.filter(o=>o.severity==="block").length;return s.push(`${t.length} drift item${t.length===1?"":"s"} against spec v${e.baselineVersion}: ${r} block, ${t.length-r} warn (${e.files} files indexed, ${e.skipped} skipped).`),s.join(`
4
- `)}function Yn(t){return{schema:1,checkedAt:t,baselineVersion:null,items:[],followups:{}}}function Qn(t,e){if(!t||typeof t!="object")return Yn(e);let n=t;return n.schema!==1||!Array.isArray(n.items)?Yn(e):{schema:1,checkedAt:typeof n.checkedAt=="string"?n.checkedAt:e,baselineVersion:typeof n.baselineVersion=="number"?n.baselineVersion:null,items:n.items,followups:n.followups&&typeof n.followups=="object"?n.followups:{}}}function Tt(t,e={}){return t.filter(n=>{if(n.severity!=="block")return!1;let s=e[n.id];return s!=="pending"&&s!=="accepted"})}var Ct={exceptions:!1,denyGit:["commit","push"],maxFollowups:2},Be=8;function ts(t){let e=t.slice(0,Be).map(n=>{let s=n.refs[0],r=s?` (${s.path}${s.line?`:${s.line}`:""})`:"";return`- ${n.title}${r}. ${n.fix}`});return t.length>Be&&e.push(`- and ${t.length-Be} more; run \`gruum check\`.`),e.join(`
5
- `)}function es(t){return t.exceptions?"Fix each to the spec (call gruum_button_spec), or call gruum_request_exception with a reason when the spec has no button for the job.":"Fix each to the spec (call gruum_button_spec). If the spec has no button for the job, stop and tell the developer which exception you need; do not invent a style."}function ns(t,e,n=Ct,s={}){let r=Tt(t.items,s),o=e.conversation_id??"",i=typeof e.loop_count=="number"?e.loop_count:t.followups[o]??0;return r.length===0||e.status==="aborted"?{output:{},ledger:t}:i>=n.maxFollowups?{output:{},ledger:t}:{output:{followup_message:`Gruum found ${r.length} button${r.length===1?"":"s"} that drift from the published spec:
2
+ import{chmodSync as Tc,existsSync as It,rmSync as Nn}from"node:fs";import V from"node:path";import{createInterface as Dn}from"node:readline";var Oo=new Set(["display","position","inset","top","right","bottom","left","z-index","order","flex","flex-grow","flex-shrink","flex-basis","align-self","justify-self","align-items","justify-content","place-items","place-content","gap","text-align","min-width","max-width","overflow","white-space","cursor"]),No=new Set(["page","index","layout","route","default"]);function Do(e){return Oo.has(e.property)||/^(margin|transition|grid-)/.test(e.property)?!0:(e.property==="width"||e.property==="height")&&/^(100%|auto)$/.test(e.value)}function Ne(e){return e.flatMap(t=>t.declarations.filter(n=>!Do(n)).map(n=>`${t.state}|${t.context}|${n.property}:${n.value}`)).sort().join(";")}function To(e){return Ne(e.states)}function Vo(e){return e.states.filter(t=>t.state==="default"&&t.context==="").flatMap(t=>t.declarations)}function Bn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Fo(e){let t=e.via?/^bg-([\w-]+?)(?:\/(\d+))?$/.exec(e.via):null;if(t){let s=t[1].replace(/-/g," ");return Bn(t[2]?`${s} ${t[2]}%`:s)}let n=/var\(\s*--(?:color-)?([\w-]+)/.exec(e.value)?.[1];return Bn((n??e.value).replace(/-/g," "))}function Bo(e){let t=Vo(e),n=u=>t.findLast(f=>f.property===u),s=n("background-color")??n("background"),r=s!==void 0&&!/^(transparent|none|initial|inherit)\b/.test(s.value),o=n("border-width")?.value,i=o!==void 0&&!/^0(px)?$/.test(o)&&n("border-style")?.value!=="none",a=n("width")?.value,l=a!==void 0&&a===n("height")?.value&&!/^(auto|100%|fit-content)$/.test(a);return n("inset")?.value==="0"?"Overlay":i?l?"Outline icon":"Outline":r?`${Fo(s)} ${l?"icon":"fill"}`:l?"Icon":t.some(u=>u.property.startsWith("padding")||u.property==="border-radius"||u.property==="height"&&u.value!=="auto")?"Ghost":"Text"}function Uo(e){let t=e.split("/"),n=(t.pop()??e).replace(/\.[^.]+$/,""),s=t.pop();return No.has(n)&&s?`${s}/${n}`:n}function zo(e){let t=[...new Set(e.map(s=>Uo(s.path)))],n=t.slice(0,2).join(", ");return t.length>2?`${n} +${t.length-2}`:n}var Un=(e,t)=>e.path.localeCompare(t.path)||e.line-t.line;function zn(e){let t=new Map;for(let r of e){let o=Bo(r.variant),i=t.get(o)??new Map,a=To(r.variant),l=i.get(a)??{looks:[],sites:[]};l.looks.push(r.variant),l.sites.push(...r.sites),i.set(a,l),t.set(o,i)}let n=[],s=new Map;for(let[r,o]of t){let i=[...o.values()];for(let b of i)b.sites.sort(Un);i.sort((b,w)=>w.sites.length-b.sites.length||Un(b.sites[0],w.sites[0]));let[a,...l]=i,c=a.looks[0],u=l.map(b=>zo(b.sites)),f=l.map((b,w)=>{let $=b.looks[0],g={title:u.filter(p=>p===u[w]).length>1?`${u[w]} \xB7 line ${b.sites[0].line}`:u[w],selector:$.selector,path:b.sites[0].path,line:b.sites[0].line,element:$.element,usage:$.usage,states:$.states,alike:!0};return s.set(g,b.sites),g}),m={...c,title:r,axis:null,base:!1,path:a.sites[0].path,line:a.sites[0].line,markup:!0,...f.length?{modifiers:f}:{}};s.set(m,a.sites),n.push(m)}return{variants:n,sites:s}}var Hn=1,Kn=["style.new","state.changed","state.missing","token.unknown","value.hardcoded","native.element","prop.unknown","style.removed","guidance.rule"],Nt={"style.new":"block","state.changed":"block","state.missing":"block","token.unknown":"block","value.hardcoded":"block","native.element":"block","prop.unknown":"block","style.removed":"warn","guidance.rule":"warn"};function Dt(e){let t=0;for(let n=0;n<e.length;n++)t=t*33+e.charCodeAt(n)>>>0;return t.toString(36)}function Wn(e){let t=`${e.path}::${e.selector}`;return`v2-style-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)}-${Dt(t)}`}function oe(e){return e.context?`${e.state} @ ${e.context}`:e.state}var Wo=/var\(\s*(--[\w-]+)/g;function Go(e){let t=new Set;for(let n of e)for(let s of n.declarations)for(let r of s.value.matchAll(Wo))t.add(r[1]);return[...t].sort()}function Ho(e){let t=new Map;for(let n of e)t.set(n.property,n.value.trim());return[...t].map(([n,s])=>({property:n,value:s})).sort((n,s)=>n.property.localeCompare(s.property))}function Ko(e){let t=new Map;for(let n of e){let s=oe(n),r=t.get(s),o=Ho([...r?.declarations??[],...n.declarations]);t.set(s,{state:n.state,context:n.context,declarations:o})}return[...t.values()]}function Jn(e){let t=new Map,n=(s,r,o)=>{let i=Wn(s),a=t.get(i),l=Ko([...a?Jo(a.states):[],...r]),c=a?.stateLines??new Map;for(let u of r)c.has(oe(u))||c.set(oe(u),u.line);t.set(i,{...a??s,id:i,states:l,tokens:Go(l),line:a?.line??o,stateLines:c})};for(let s of e){let r=Wn(s);n({kind:"look",title:s.title,selector:s.selector,path:s.path,axis:s.axis,...s.usage.via?{selectedBy:s.usage.via}:{},...s.element?{element:s.element.tag}:{},...s.markup?{markup:!0}:{}},s.states,s.line);for(let o of s.modifiers??[])n({kind:"modifier",title:`${s.title} \xB7 ${o.title}`,selector:o.selector,path:o.path,hostId:r,...o.usage.via?{selectedBy:o.usage.via}:{},...o.element?{element:o.element.tag}:{},...o.alike?{markup:!0}:{}},o.states,o.line);for(let o of s.contexts??[])n({kind:"context",title:`${s.title} in ${o.selector}`,selector:o.selector,path:o.path,hostId:r,role:o.role,...o.element?{element:o.element.tag}:{}},o.states,o.line)}return t}function Jo(e){return e.map(t=>({state:t.state,context:t.context,line:0,declarations:t.declarations}))}function Zo(e){let t=new Map,n=/^:root\{([^}]*)\}/.exec(e);if(!n)return t;for(let s of n[1].split(";")){let r=s.indexOf(":");if(r<=0)continue;let o=s.slice(0,r).trim();o.startsWith("--")&&t.set(o,s.slice(r+1).trim())}return t}var Gn=/^(\d+) native /;function Xo(e,t){if(e==="native")return`native:${t.refs[0]?.path??""}`;if(t.styles?.length){let n=[...new Set(t.refs.map(s=>s.path))].sort().join(",");return`${e}:${[...t.styles].sort().join(",")}:${n}`}return`${e}:${t.refs.map(n=>n.path).join(",")}:${t.message}`}var Xe={hardcoded:"value.hardcoded",native:"native.element",props:"prop.unknown"},qo=new Set(Object.values(Xe));var Yo={"value.hardcoded":()=>"Replace each literal with the spec token named, or with a spec token for that property.","native.element":e=>`Render ${e.components[0]??"the shared component"} instead of a raw <button>, or ask for an exception.`,"prop.unknown":()=>"Use one of the values listed, or ask for an exception to add the look."};function Zn(e){let t=[];for(let n of e.audit)if(n.status==="attention")for(let s of n.findings)t.push({check:n.id,finding:s,key:Xo(n.id,s)});return t}function Pt(e){return`${e.path}#${Dt(e.text.replace(/\s+/g," ").trim())}`}function Xn(e,t={}){let n=Zo(e.previewCss),s=[...Jn(e.variants).values()].map(({line:i,stateLines:a,...l})=>l),r=new Set(e.tokens.map(i=>i.name)),o=[];for(let i of e.guidance.files)if(i.kind!=="record")for(let a of i.passages)a.rule&&o.push({path:a.path,headings:a.headings,text:a.text,styles:a.styles});return{schema:Hn,concept:e.concept,label:e.label,version:t.version??0,sourceRef:e.repo.ref,publishedAt:t.publishedAt??null,components:[...e.components].sort(),tokens:[...new Set([...e.tokens.map(i=>i.name),...s.flatMap(i=>i.tokens).filter(i=>!r.has(i))])].map(i=>{let a=n.get(i);return a===void 0?{name:i}:{name:i,value:a}}).sort((i,a)=>i.name.localeCompare(a.name)),styles:s,rules:o,content:e.content.map(i=>i.id),acceptedFindings:Zn(e).filter(({check:i})=>i in Xe).map(({check:i,finding:a,key:l})=>({check:i,key:l,message:a.message})),settings:{severity:{...Nt,...t.settings?.severity??{}}}}}function Qo(e,t){let n=new Map(e.map(o=>[o.property,o.value])),s=new Map(t.map(o=>[o.property,o.value])),r=[];for(let[o,i]of s){let a=n.get(o);a===void 0?r.push(`added ${o}: ${i}`):a!==i&&r.push(`${o}: ${a} \u2192 ${i}`)}for(let[o,i]of n)s.has(o)||r.push(`removed ${o}: ${i}`);return r}function Ot(e){return e.map(t=>`${t.property}: ${t.value}`).join("; ")}function Mt(e,t){return e.length>t?`${e.slice(0,t).join(", ")}, and ${e.length-t} more`:e.join(", ")}function ei(e,t){let n=e.replace(/^--/,"").split("-")[0]??"",s=n?t.filter(r=>r.startsWith(`--${n}`)):[];return(s.length?s:t).slice(0,3)}function qn(e,t){let n={...Nt,...t.settings.severity},s=[],r=(p,d="")=>{s.push({id:`${p.kind}:${Dt(`${p.styleId??""}|${p.state??""}|${d}`)}`,severity:n[p.kind],...p})},o=Jn(e.variants),i=new Map(t.styles.map(p=>[p.id,p])),a=t.styles.filter(p=>p.kind==="look"),l=new Set([...t.tokens.map(p=>p.name),...t.styles.flatMap(p=>p.tokens)]),c=[...l],u=new Map;for(let p of t.styles)p.markup&&u.set(Ne(p.states),p);let f=new Map;for(let p of o.values()){if(!p.markup)continue;let d=u.get(Ne(p.states));d&&f.set(p.id,d)}let m=new Set([...f.values()].map(p=>p.id)),b=p=>p.markup?`${p.title} (as in ${p.path})`:p.selector;for(let p of o.values()){if(i.has(p.id)||f.has(p.id))continue;let d=p.hostId?i.get(p.hostId):void 0,y=p.markup?a.filter(I=>I.markup):a,v=y.filter(I=>I.path===p.path),x=(v.length?v:y).map(b),C=p.markup?`This one-off ${p.element??"button"} (${Mt((p.states[0]?.declarations??[]).map(I=>`${I.property}: ${I.value}`),3)})`:p.selector,j=p.markup?t.components.length?`render ${t.components[0]} with a spec look,`:x.length?`copy ${Mt(x,3)},`:"use a spec style,":d?`restyle ${d.selector} only through spec modifiers`:x.length?`use ${Mt(x,3)},`:"use a spec style,";r({kind:"style.new",styleId:p.id,title:`${p.title} is not in the spec`,baseline:null,observed:{declarations:p.states[0]?.declarations??[],states:p.states,...p.markup?{markup:!0}:{}},refs:[{path:p.path,line:p.line}],fix:`${C} is not in the spec; ${j} or ask for an exception.`},p.markup?Ne(p.states):p.selector)}for(let p of o.values()){let d=i.get(p.id);if(!d)continue;let y=new Map(d.states.map(v=>[oe(v),v]));for(let v of p.states){let x=oe(v),C=y.get(x),j=Qo(C?.declarations??[],v.declarations);j.length!==0&&r({kind:"state.changed",styleId:p.id,title:C?`${p.title}: ${x} changed`:`${p.title}: new ${x} state`,state:x,baseline:C?{declarations:C.declarations}:null,observed:{declarations:v.declarations},refs:[{path:p.path,line:p.stateLines.get(x)??p.line}],fix:C?`Restore ${p.selector} ${x} to the spec (${j.slice(0,3).join("; ")}), or ask for an exception.`:`${x} is not a spec state of ${p.selector}; remove it, or ask for an exception.`},Ot(v.declarations))}}for(let p of o.values()){let d=i.get(p.id);if(!d)continue;let y=new Set(p.states.map(oe));for(let v of d.states){let x=oe(v);y.has(x)||r({kind:"state.missing",styleId:p.id,title:`${p.title}: ${x} state is missing`,state:x,baseline:{declarations:v.declarations},observed:null,refs:[{path:p.path,line:p.line}],fix:`Define ${p.selector} ${x} again: ${Ot(v.declarations)||"as in the spec"}.`})}}for(let p of o.values())for(let d of p.tokens){if(l.has(d))continue;let y=ei(d,c);r({kind:"token.unknown",styleId:p.id,title:`${p.title} reads ${d}, which is not a spec token`,baseline:null,observed:{token:d},refs:[{path:p.path,line:p.line}],fix:y.length?`Use a spec token such as ${y.join(", ")} instead of ${d}, or ask for an exception.`:`${d} is not a spec token; ask for an exception to add it.`},d)}let w=new Map;for(let p of t.acceptedFindings)w.set(p.key,[...w.get(p.key)??[],p]);let $=Zn(e).filter(({check:p})=>p in Xe);for(let p of Kn)if(qo.has(p))for(let{check:d,finding:y,key:v}of $){if(Xe[d]!==p)continue;let x=w.get(v)??[];if(x.some(A=>!ti(d,A.message,y.message)))continue;let C=x[0],j=y.styles?.[0],I=j?[...o.values()].find(A=>A.title===j):void 0;r({kind:p,styleId:I?.id??null,title:y.message,baseline:C?{message:C.message}:null,observed:{message:y.message,...p==="native.element"?{element:"button"}:{}},waiverKey:v,refs:y.refs.map(({path:A,line:R})=>({path:A,line:R})),fix:Yo[p](t)},v)}for(let p of t.styles)o.has(p.id)||m.has(p.id)||r({kind:"style.removed",styleId:p.id,title:p.markup?`${p.title} is in the spec but no longer written anywhere`:`${p.title} is in the spec but no longer in CSS`,baseline:{declarations:p.states[0]?.declarations??[]},observed:null,refs:[{path:p.path,line:0}],fix:p.markup?`Nothing renders ${p.title} any more; ask the designer to retire it from the spec if that is intended.`:`Restore ${p.selector} in ${p.path}, or ask the designer to retire it from the spec.`});let k=new Map(e.guidance.files.map(p=>[p.path,p])),g=new Set;for(let p of e.guidance.files)for(let d of p.passages)d.rule&&g.add(Pt(d));for(let p of t.rules){if(g.has(Pt(p)))continue;let d=k.get(p.path);d&&d.total>d.passages.length||r({kind:"guidance.rule",styleId:null,title:`A written rule in ${p.path} changed or was removed`,baseline:{text:p.text},observed:null,refs:[{path:p.path,line:0}],fix:`Restore the rule under ${p.headings.join(" \u203A ")||p.path}, or publish a new spec.`},Pt(p))}return s}function ti(e,t,n){if(t===n)return!1;if(e==="native"){let s=Gn.exec(t)?.[1],r=Gn.exec(n)?.[1];if(s&&r)return Number(r)>Number(s)}return!0}var ni={product:"Gruum button spec",what:"The designer-published spec for this repository's buttons. Write buttons against it; drift from it is checked deterministically.",howToUse:["Use the components listed in `components`; do not render a raw <button> where a component exists.","Pick a look from `looks`. `selectedBy` says which prop or attribute value selects it.","Use only the tokens listed in `tokens`. Do not write a literal color or size a token already has.","Follow `rules`; they are the repository's written rules, quoted.","Do not add a look, modifier, or state, and do not change a state's declarations.","If the spec has no button for the job, ask for an exception with a reason instead of inventing one. Never edit generated Gruum files to make a check pass."]};function Tt(e){let t=(n,s)=>e.styles.filter(r=>r.hostId===n&&r.kind===s).map(r=>r.selector);return{about:{...ni,drift:Kn.map(n=>({kind:n,severity:e.settings.severity[n]??Nt[n]}))},spec:{concept:e.concept,version:e.version,sourceRef:e.sourceRef,components:e.components,looks:e.styles.filter(n=>n.kind==="look").map(n=>({title:n.title,selector:n.selector,path:n.path,...n.selectedBy?{selectedBy:n.selectedBy}:{},tokens:n.tokens,states:Object.fromEntries(n.states.map(s=>[oe(s),Ot(s.declarations)])),modifiers:t(n.id,"modifier"),contexts:t(n.id,"context")})),tokens:e.tokens,rules:e.rules.map(n=>({path:n.path,under:n.headings.join(" \u203A "),text:n.text}))}}}function qe(e){if(!e||typeof e!="object")return null;let t=e;return t.schema!==Hn||typeof t.concept!="string"||!Array.isArray(t.styles)||!Array.isArray(t.tokens)||!Array.isArray(t.acceptedFindings)||!Array.isArray(t.rules)||!t.settings?.severity?null:t}function si(e){let t=new Map;for(let n of e){let s=n.refs[0]?.path??"(no file)";t.set(s,[...t.get(s)??[],n])}return[...t].sort(([n],[s])=>n.localeCompare(s))}function Vt(e,t){if(t.length===0)return e;let n=new Set(t.map(s=>s.replace(/^\.\//,"")));return e.filter(s=>s.refs.some(r=>n.has(r.path)))}function Yn(e,t,n={}){let s=[];if(e.length===0)return s.push(`No drift against spec v${t.baselineVersion} (${t.files} files indexed, ${t.skipped} skipped).`),s.join(`
3
+ `);for(let[o,i]of si(e)){s.push(o);for(let a of i){let l=a.refs[0]?.line,c=n[a.id],u=c?`${a.severity}, exception ${c}`:a.severity;s.push(` ${l?`${l}: `:""}[${u}] ${a.kind} ${a.title}`),s.push(` fix: ${a.fix}`)}s.push("")}let r=e.filter(o=>o.severity==="block").length;return s.push(`${e.length} drift item${e.length===1?"":"s"} against spec v${t.baselineVersion}: ${r} block, ${e.length-r} warn (${t.files} files indexed, ${t.skipped} skipped).`),s.join(`
4
+ `)}function Qn(e){return{schema:1,checkedAt:e,baselineVersion:null,items:[],followups:{}}}function es(e,t){if(!e||typeof e!="object")return Qn(t);let n=e;return n.schema!==1||!Array.isArray(n.items)?Qn(t):{schema:1,checkedAt:typeof n.checkedAt=="string"?n.checkedAt:t,baselineVersion:typeof n.baselineVersion=="number"?n.baselineVersion:null,items:n.items,followups:n.followups&&typeof n.followups=="object"?n.followups:{}}}function De(e,t={}){return e.filter(n=>{if(n.severity!=="block")return!1;let s=t[n.id];return s!=="pending"&&s!=="accepted"})}var Ce={exceptions:!1,denyGit:["commit","push"],maxFollowups:2},Ft=8;function ts(e){let t=e.slice(0,Ft).map(n=>{let s=n.refs[0],r=s?` (${s.path}${s.line?`:${s.line}`:""})`:"";return`- ${n.title}${r}. ${n.fix}`});return e.length>Ft&&t.push(`- and ${e.length-Ft} more; run \`gruum check\`.`),t.join(`
5
+ `)}function ns(e){return e.exceptions?"Fix each to the spec (call gruum_button_spec), or call gruum_request_exception with a reason when the spec has no button for the job.":"Fix each to the spec (call gruum_button_spec). If the spec has no button for the job, stop and tell the developer which exception you need; do not invent a style."}function ss(e,t,n=Ce,s={}){let r=De(e.items,s),o=t.conversation_id??"",i=typeof t.loop_count=="number"?t.loop_count:e.followups[o]??0;return r.length===0||t.status==="aborted"?{output:{},ledger:e}:i>=n.maxFollowups?{output:{},ledger:e}:{output:{followup_message:`Gruum found ${r.length} button${r.length===1?"":"s"} that drift from the published spec:
6
6
  ${ts(r)}
7
7
 
8
- ${es(n)}`},ledger:{...t,followups:{...t.followups,[o]:i+1}}}}function Fe(t){let e=[];for(let n of t.split(/&&|\|\||[;|\n]/)){let s=n.trim().split(/\s+/).filter(Boolean),r=0;for(;r<s.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(s[r]);)r++;if((s[r]==="command"||s[r]==="exec")&&r++,!!/(^|\/)git$/.test(s[r]??"")){for(r++;r<s.length&&s[r].startsWith("-");){let o=s[r];r+=/^(-C|-c|--git-dir|--work-tree|--namespace)$/.test(o)?2:1}s[r]&&e.push(s[r])}}return e}function ss(t,e,n=Ct,s={}){let r=Fe(e.command??"").filter(i=>n.denyGit.includes(i));if(r.length===0)return{permission:"allow"};let o=Tt(t.items,s);return o.length===0?{permission:"allow"}:{permission:"deny",user_message:`Gruum blocked git ${r[0]}: ${o.length} button drift item${o.length===1?"":"s"} against the spec. Run \`gruum check\` for details.`,agent_message:`git ${r[0]} is blocked until button drift is resolved:
8
+ ${ns(n)}`},ledger:{...e,followups:{...e.followups,[o]:i+1}}}}function Bt(e){let t=[];for(let n of e.split(/&&|\|\||[;|\n]/)){let s=n.trim().split(/\s+/).filter(Boolean),r=0;for(;r<s.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(s[r]);)r++;if((s[r]==="command"||s[r]==="exec")&&r++,!!/(^|\/)git$/.test(s[r]??"")){for(r++;r<s.length&&s[r].startsWith("-");){let o=s[r];r+=/^(-C|-c|--git-dir|--work-tree|--namespace)$/.test(o)?2:1}s[r]&&t.push(s[r])}}return t}function rs(e,t,n=Ce,s={}){let r=Bt(t.command??"").filter(i=>n.denyGit.includes(i));if(r.length===0)return{permission:"allow"};let o=De(e.items,s);return o.length===0?{permission:"allow"}:{permission:"deny",user_message:`Gruum blocked git ${r[0]}: ${o.length} button drift item${o.length===1?"":"s"} against the spec. Run \`gruum check\` for details.`,agent_message:`git ${r[0]} is blocked until button drift is resolved:
9
9
  ${ts(o)}
10
10
 
11
- ${es(n)}`}}var Nt="npx --no-install @gruum/cli",rs={afterFileEdit:"after-file-edit",stop:"stop",beforeShellExecution:"before-shell"},Yo=/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+hook\s+(after-file-edit|stop|before-shell)\s*$/;function Ue(t){return typeof t=="string"&&Yo.test(t)}function Yt(t,e){if(t===null||t.trim()==="")return{ok:!0,value:{}};try{let n=JSON.parse(t);return!n||typeof n!="object"||Array.isArray(n)?{ok:!1,error:`${e} is not a JSON object; fix it or move it aside, then run init again.`}:{ok:!0,value:n}}catch{return{ok:!1,error:`${e} is not valid JSON; fix it or move it aside, then run init again.`}}}function Qt(t){return`${JSON.stringify(t,null,2)}
12
- `}function os(t,e=Nt){let n=".cursor/hooks.json",s=Yt(t,n);if(!s.ok)return s;let r=s.value;if(r.hooks!==void 0&&(typeof r.hooks!="object"||Array.isArray(r.hooks)||r.hooks===null))return{ok:!1,error:`${n} has a "hooks" value that is not an object.`};let o={...r.hooks??{}},i=t===null||t.trim()==="";for(let a of Object.keys(rs)){let l=o[a]??[];if(!Array.isArray(l))return{ok:!1,error:`${n} has a "${a}" value that is not an array.`};let c=`${e} hook ${rs[a]}`,u=l.filter(f=>Ue(f?.command));u.length===1&&u[0].command===c||(o[a]=[...l.filter(f=>!Ue(f?.command)),{command:c}],i=!0)}return i?{ok:!0,text:Qt({version:r.version??1,...r,hooks:o}),changed:!0}:{ok:!0,text:t,changed:!1}}function is(t){let e=".cursor/hooks.json";if(t===null)return{ok:!0,text:"",changed:!1};let n=Yt(t,e);if(!n.ok)return n;let s=n.value,r={...s.hooks??{}},o=!1;for(let a of Object.keys(r)){let l=r[a];if(!Array.isArray(l))continue;let c=l.filter(u=>!Ue(u?.command));c.length!==l.length&&(o=!0,c.length?r[a]=c:delete r[a])}if(!o)return{ok:!0,text:t,changed:!1};let i=Object.keys(s).every(a=>a==="version"||a==="hooks");return Object.keys(r).length===0&&i?{ok:!0,text:"",changed:!0}:{ok:!0,text:Qt({...s,hooks:r}),changed:!0}}function Qo(t){let[e,...n]=t.trim().split(/\s+/);return{command:e,args:[...n,"mcp"]}}function as(t,e=Nt){let n=".cursor/mcp.json",s=Yt(t,n);if(!s.ok)return s;let r=s.value,o=r.mcpServers??{};if(typeof o!="object"||Array.isArray(o)||o===null)return{ok:!1,error:`${n} has an "mcpServers" value that is not an object.`};let i=Qo(e),a=o.gruum;return JSON.stringify(a)===JSON.stringify(i)?{ok:!0,text:t,changed:!1}:{ok:!0,text:Qt({...r,mcpServers:{...o,gruum:i}}),changed:!0}}function ls(t){let e=".cursor/mcp.json";if(t===null)return{ok:!0,text:"",changed:!1};let n=Yt(t,e);if(!n.ok)return n;let s=n.value,r={...s.mcpServers??{}};return"gruum"in r?(delete r.gruum,Object.keys(r).length===0&&Object.keys(s).every(o=>o==="mcpServers")?{ok:!0,text:"",changed:!0}:{ok:!0,text:Qt({...s,mcpServers:r}),changed:!0}):{ok:!0,text:t,changed:!1}}var dt=".cursor/rules/gruum-buttons.mdc",cs="<!-- written by gruum init cursor -->",ti=20,ei=["**/*.css","**/*.scss","**/*.tsx","**/*.jsx"];function us(t){let e=(t?.findings??[]).filter(s=>s.role==="implements"||s.role==="styles").map(s=>s.path).filter(s=>!/[,"\n]/.test(s)),n=[...new Set(e)].sort().slice(0,ti);return n.length?n:ei}function ps(t){return["---","description: Buttons in this repository follow a spec published in Gruum.",`globs: ${t.join(",")}`,"alwaysApply: false","---",cs,"","The button spec for this repository lives in Gruum; call the `gruum_button_spec` tool before writing or restyling a button.","Run `gruum_check_buttons` before you stop, and fix every drift item it reports to the spec.","When the spec has no button for the job, ask for an exception with a reason rather than inventing a style, and never edit Gruum's generated files to make a check pass.",""].join(`
13
- `)}function fs(t){return t.includes(cs)}function ds(t){let e=t??"";if(e.split(/\r?\n/).some(r=>/^\/?\.gruum\/?(\*\*?)?$/.test(r.trim())))return{text:e,changed:!1};let s=e===""||e.endsWith(`
11
+ ${ns(n)}`}}var Te="npx --no-install @gruum/cli",os={afterFileEdit:"after-file-edit",stop:"stop",beforeShellExecution:"before-shell"},ri=/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+hook\s+(after-file-edit|stop|before-shell)\s*$/;function Ut(e){return typeof e=="string"&&ri.test(e)}function Ye(e,t){if(e===null||e.trim()==="")return{ok:!0,value:{}};try{let n=JSON.parse(e);return!n||typeof n!="object"||Array.isArray(n)?{ok:!1,error:`${t} is not a JSON object; fix it or move it aside, then run init again.`}:{ok:!0,value:n}}catch{return{ok:!1,error:`${t} is not valid JSON; fix it or move it aside, then run init again.`}}}function Qe(e){return`${JSON.stringify(e,null,2)}
12
+ `}function is(e,t=Te){let n=".cursor/hooks.json",s=Ye(e,n);if(!s.ok)return s;let r=s.value;if(r.hooks!==void 0&&(typeof r.hooks!="object"||Array.isArray(r.hooks)||r.hooks===null))return{ok:!1,error:`${n} has a "hooks" value that is not an object.`};let o={...r.hooks??{}},i=e===null||e.trim()==="";for(let a of Object.keys(os)){let l=o[a]??[];if(!Array.isArray(l))return{ok:!1,error:`${n} has a "${a}" value that is not an array.`};let c=`${t} hook ${os[a]}`,u=l.filter(f=>Ut(f?.command));u.length===1&&u[0].command===c||(o[a]=[...l.filter(f=>!Ut(f?.command)),{command:c}],i=!0)}return i?{ok:!0,text:Qe({version:r.version??1,...r,hooks:o}),changed:!0}:{ok:!0,text:e,changed:!1}}function as(e){let t=".cursor/hooks.json";if(e===null)return{ok:!0,text:"",changed:!1};let n=Ye(e,t);if(!n.ok)return n;let s=n.value,r={...s.hooks??{}},o=!1;for(let a of Object.keys(r)){let l=r[a];if(!Array.isArray(l))continue;let c=l.filter(u=>!Ut(u?.command));c.length!==l.length&&(o=!0,c.length?r[a]=c:delete r[a])}if(!o)return{ok:!0,text:e,changed:!1};let i=Object.keys(s).every(a=>a==="version"||a==="hooks");return Object.keys(r).length===0&&i?{ok:!0,text:"",changed:!0}:{ok:!0,text:Qe({...s,hooks:r}),changed:!0}}function oi(e){let[t,...n]=e.trim().split(/\s+/);return{command:t,args:[...n,"mcp"]}}function ls(e,t=Te){let n=".cursor/mcp.json",s=Ye(e,n);if(!s.ok)return s;let r=s.value,o=r.mcpServers??{};if(typeof o!="object"||Array.isArray(o)||o===null)return{ok:!1,error:`${n} has an "mcpServers" value that is not an object.`};let i=oi(t),a=o.gruum;return JSON.stringify(a)===JSON.stringify(i)?{ok:!0,text:e,changed:!1}:{ok:!0,text:Qe({...r,mcpServers:{...o,gruum:i}}),changed:!0}}function cs(e){let t=".cursor/mcp.json";if(e===null)return{ok:!0,text:"",changed:!1};let n=Ye(e,t);if(!n.ok)return n;let s=n.value,r={...s.mcpServers??{}};return"gruum"in r?(delete r.gruum,Object.keys(r).length===0&&Object.keys(s).every(o=>o==="mcpServers")?{ok:!0,text:"",changed:!0}:{ok:!0,text:Qe({...s,mcpServers:r}),changed:!0}):{ok:!0,text:e,changed:!1}}var de=".cursor/rules/gruum-buttons.mdc",us="<!-- written by gruum init cursor -->",ii=20,ai=["**/*.css","**/*.scss","**/*.tsx","**/*.jsx"];function ps(e){let t=(e?.findings??[]).filter(s=>s.role==="implements"||s.role==="styles").map(s=>s.path).filter(s=>!/[,"\n]/.test(s)),n=[...new Set(t)].sort().slice(0,ii);return n.length?n:ai}function fs(e){return["---","description: Buttons in this repository follow a spec published in Gruum.",`globs: ${e.join(",")}`,"alwaysApply: false","---",us,"","The button spec for this repository lives in Gruum; call the `gruum_button_spec` tool before writing or restyling a button.","Run `gruum_check_buttons` before you stop, and fix every drift item it reports to the spec.","When the spec has no button for the job, ask for an exception with a reason rather than inventing a style, and never edit Gruum's generated files to make a check pass.",""].join(`
13
+ `)}function ds(e){return e.includes(us)}function gs(e){let t=e??"";if(t.split(/\r?\n/).some(r=>/^\/?\.gruum\/?(\*\*?)?$/.test(r.trim())))return{text:t,changed:!1};let s=t===""||t.endsWith(`
14
14
  `)?"":`
15
- `;return{text:`${e}${s}# Gruum local state
15
+ `;return{text:`${t}${s}# Gruum local state
16
16
  .gruum/
17
- `,changed:!0}}function gs(t){if(t===null)return{text:"",changed:!1};let e=t.replace(/(^|\n)# Gruum local state\n\.gruum\/\n/,"$1");return{text:e,changed:e!==t}}var ni=t=>`${t} check --staged`;function ms(t,e=Nt){let n=ni(e);if(t.lefthook)return{kind:"print",reason:"lefthook config found; add this to the pre-commit commands",snippet:`pre-commit:
17
+ `,changed:!0}}function ms(e){if(e===null)return{text:"",changed:!1};let t=e.replace(/(^|\n)# Gruum local state\n\.gruum\/\n/,"$1");return{text:t,changed:t!==e}}var li=e=>`${e} check --staged`;function hs(e,t=Te){let n=li(t);if(e.lefthook)return{kind:"print",reason:"lefthook config found; add this to the pre-commit commands",snippet:`pre-commit:
18
18
  commands:
19
19
  gruum:
20
20
  run: ${n}
21
- `};let s=t.husky?"husky":t.gitHooksDir?"git":null;if(!s)return{kind:"print",reason:"no hook directory found; add this to your pre-commit hook",snippet:`${n}
22
- `};let r=t.husky?".husky/pre-commit":`${t.gitHooksDir}/pre-commit`,o=t.hookText;if(o!==null&&o.split(/\r?\n/).some(l=>hs(l)))return{kind:s,path:r,text:o,changed:!1};let i=o===null?s==="git"?`#!/bin/sh
21
+ `};let s=e.husky?"husky":e.gitHooksDir?"git":null;if(!s)return{kind:"print",reason:"no hook directory found; add this to your pre-commit hook",snippet:`${n}
22
+ `};let r=e.husky?".husky/pre-commit":`${e.gitHooksDir}/pre-commit`,o=e.hookText;if(o!==null&&o.split(/\r?\n/).some(l=>bs(l)))return{kind:s,path:r,text:o,changed:!1};let i=o===null?s==="git"?`#!/bin/sh
23
23
  `:"":o,a=i===""||i.endsWith(`
24
24
  `)?"":`
25
25
  `;return{kind:s,path:r,text:`${i}${a}${n}
26
- `,changed:!0}}function hs(t){return/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+check\s+--staged\s*$/.test(t.trim())}function bs(t){let e=t.split(`
27
- `),n=e.filter(o=>!hs(o)),s=n.length!==e.length,r=n.join(`
28
- `);return s&&/^(#!\/bin\/sh)?\s*$/.test(r)?{text:"",changed:s}:{text:r,changed:s}}var St=[{name:"login",args:[],blurb:"Sign this computer in",usage:"npx @gruum/cli login"},{name:"check",args:[],blurb:"Compare this checkout to the spec",usage:"npx @gruum/cli check"},{name:"baseline",args:["--write"],blurb:"Draft a local spec from this checkout",usage:"npx @gruum/cli baseline --write"}];function ys(t){let e=St.map((n,s)=>` ${s+1} ${n.name.padEnd(10)} ${n.blurb}`);return`gruum ${t}
26
+ `,changed:!0}}function bs(e){return/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+check\s+--staged\s*$/.test(e.trim())}function ys(e){let t=e.split(`
27
+ `),n=t.filter(o=>!bs(o)),s=n.length!==t.length,r=n.join(`
28
+ `);return s&&/^(#!\/bin\/sh)?\s*$/.test(r)?{text:"",changed:s}:{text:r,changed:s}}var Se=[{name:"login",args:[],blurb:"Sign this computer in",usage:"npx @gruum/cli login"},{name:"check",args:[],blurb:"Compare this checkout to the spec",usage:"npx @gruum/cli check"},{name:"baseline",args:["--write"],blurb:"Draft a local spec from this checkout",usage:"npx @gruum/cli baseline --write"}];function xs(e){let t=Se.map((n,s)=>` ${s+1} ${n.name.padEnd(10)} ${n.blurb}`);return`gruum ${e}
29
29
 
30
- ${e.join(`
30
+ ${t.join(`
31
31
  `)}
32
- `}var xs=`
33
- Choose 1\u20133, or press Enter to quit: `,ks=`
34
- Would you like to run a (c) check, (b) baseline, or (q) quit? `,ws=`
35
- You have no baseline. Would you like to run it? (b) baseline, (q) quit: `;function vs(t){let e=t.trim().toLowerCase();return!e||e==="q"||e==="quit"?"quit":e==="c"||e==="check"?"check":e==="b"||e==="baseline"?"baseline":null}function $s(t){let e=t.trim().toLowerCase();return!e||e==="q"||e==="quit"||e==="n"||e==="no"?"quit":e==="b"||e==="baseline"||e==="y"||e==="yes"?"baseline":null}function Cs(t){let e=t.trim().toLowerCase();if(!e)return"quit";let n=Number(e);return Number.isInteger(n)&&n>=1&&n<=St.length?St[n-1]:St.find(s=>s.name===e)??null}var si="2025-06-18",te="Check before you finish, fix to the spec when you can, ask for an exception with a reason when you cannot, and never edit Gruum's generated files to make a check pass.",ee={gruum_button_spec:`The designer-published button spec for this repository: components, looks and how to select them, tokens, and written rules. Read it before writing or restyling a button. ${te}`,gruum_check_buttons:`Check the working tree's buttons against the spec and list drift items with a one-line fix each. Run it before you stop. ${te}`,gruum_request_exception:`Ask a designer to allow one drift item the spec has no button for. Send the drift id from gruum_check_buttons and a reason. ${te}`,gruum_exception_status:`Pending, accepted, or rejected for this branch's exception requests. Pass an id to read one. ${te}`};function Ss(t){return[{name:"gruum_button_spec",description:ee.gruum_button_spec,inputSchema:{type:"object",properties:{},additionalProperties:!1},run:()=>t.spec()},{name:"gruum_check_buttons",description:ee.gruum_check_buttons,inputSchema:{type:"object",properties:{paths:{type:"array",items:{type:"string"},description:"Only report drift in these files (relative to the repository root). Omit to check everything."}},additionalProperties:!1},run:e=>{let n=Array.isArray(e.paths)?e.paths.filter(s=>typeof s=="string"):[];return t.check(n)}},{name:"gruum_request_exception",description:ee.gruum_request_exception,inputSchema:{type:"object",properties:{driftId:{type:"string",description:"The drift item id from gruum_check_buttons."},reason:{type:"string",description:"Why the spec has no button for this job."}},required:["driftId","reason"],additionalProperties:!1},run:e=>t.request(typeof e.driftId=="string"?e.driftId:"",typeof e.reason=="string"?e.reason:"")},{name:"gruum_exception_status",description:ee.gruum_exception_status,inputSchema:{type:"object",properties:{id:{type:"string",description:"One request id. Omit to list this branch."}},additionalProperties:!1},run:e=>t.status(typeof e.id=="string"?e.id:void 0)}]}function Vt(t,e){return{jsonrpc:"2.0",id:t,result:e}}function ne(t,e,n){return{jsonrpc:"2.0",id:t,error:{code:e,message:n}}}async function Rs(t,e,n){if(!t||typeof t!="object")return ne(null,-32600,"Invalid request");let s=t,r=!("id"in s),o=s.id??null;if(typeof s.method!="string")return r?null:ne(o,-32600,"Invalid request");let i=s.params??{};switch(s.method){case"initialize":{let a=i.protocolVersion;return Vt(o,{protocolVersion:typeof a=="string"?a:si,capabilities:{tools:{listChanged:!1}},serverInfo:n})}case"ping":return Vt(o,{});case"tools/list":return Vt(o,{tools:e.map(({name:a,description:l,inputSchema:c})=>({name:a,description:l,inputSchema:c}))});case"tools/call":{let a=e.find(c=>c.name===i.name);if(!a)return ne(o,-32602,`Unknown tool: ${String(i.name)}`);let l=i.arguments&&typeof i.arguments=="object"?i.arguments:{};try{let c=await a.run(l);return Vt(o,{content:[{type:"text",text:c.text}],isError:c.isError??!1})}catch(c){return Vt(o,{content:[{type:"text",text:c instanceof Error?c.message:String(c)}],isError:!0})}}default:return r?null:ne(o,-32601,`Method not found: ${s.method}`)}}var ri=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv)\//,oi=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$/,ii=/\.(png|jpe?g|gif|webp|avif|ico|icns|bmp|tiff?|svgz|woff2?|ttf|otf|eot|mp[34]|wav|ogg|webm|mov|zip|gz|tgz|bz2|7z|rar|jar|pdf|docx?|xlsx?|pptx?|exe|dll|so|dylib|wasm|bin|dat|sqlite|db|psd|ai|sketch|fig)$/i,ai=/(^|\/)\.gruum\//;function ze(t){return!ri.test(`${t}/`)&&!ai.test(`${t}/`)}function We(t,e){return oi.test(t)||ii.test(t)?!1:e<=3e5}function As(t){let e=Math.min(t.length,8e3);for(let n=0;n<e;n++)if(t[n]===0)return!0;return!1}var li=/\.(css|scss|sass|less|styl|tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?|mdx?|erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2|json)$/i;function _s(t){return li.test(t)}function Ge(t){return t.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function He(t,e){let n=Ge(e),s=t.replace(/\\/g,"/");return n?s.startsWith(`${n}/`)?s.slice(n.length+1):null:s}function Es(t,e,n){let s=new Map(t);for(let r of e){let o=He(r.path,n);o===null||!ze(o.split("/").slice(0,-1).join("/")||".")||(r.content===null?s.delete(o):We(o,r.content.length)&&s.set(o,r.content))}return s}function js(t){let e=t.split("\0").filter(Boolean),n=[];for(let s=0;s<e.length;s++){let r=e[s];if(/^[RC]/.test(r)){let i=e[++s],a=e[++s];r.startsWith("R")&&i&&n.push({path:i,deleted:!0}),a&&n.push({path:a,deleted:!1});continue}let o=e[++s];o&&n.push({path:o,deleted:r.startsWith("D")})}return n}function se(t){let e=/^(?:git@|ssh:\/\/git@|https?:\/\/(?:[^@/]+@)?)github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(t.trim());return e?`${e[1]}/${e[2]}`:null}var Is=t=>t.replace(/\\(.)/g,"$1");function ci(t){let e=t;for(;;){let n=/:(?:global|local)\(/i.exec(e);if(!n)break;let s=0,r=-1;for(let i=n.index+n[0].length-1;i<e.length;i++){let a=e[i];if(a==="(")s++;else if(a===")"&&--s===0){r=i;break}}if(r<0)break;let o=e.slice(n.index+n[0].length,r).trim();e=`${e.slice(0,n.index)}${o}${e.slice(r+1)}`}return e.replace(/:(?:global|local)(?=\s|$)/gi,"").trim()}var Ke=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function Ps(t){let e=[];Ke.lastIndex=0;let n=0;for(;n<t.length;){Ke.lastIndex=n;let s=Ke.exec(t);if(!s||s.index!==n)return null;let r=s[0];if(n+=r.length,r==="*")e.push({kind:"universal",raw:r});else if(s[1]!==void 0)e.push({kind:"class",raw:r,name:Is(s[1])});else if(s[2]!==void 0)e.push({kind:"id",raw:r,name:Is(s[2])});else if(s[3]!==void 0)e.push({kind:"attr",raw:r,name:s[3],op:s[4]??null,value:s[4]?s[5]??s[6]??s[7]??"":null});else if(s[8]!==void 0)e.push({kind:"pseudoElement",raw:r,name:s[8].toLowerCase()});else if(s[9]!==void 0){let o=s[9].toLowerCase();/^(?:before|after|first-line|first-letter)$/.test(o)?e.push({kind:"pseudoElement",raw:r,name:o}):e.push({kind:"pseudo",raw:r,name:o,args:s[10]?s[10].slice(1,-1).trim():null})}else if(e.length===0)e.push({kind:"tag",raw:r,name:r.toLowerCase()});else return null}return e.length?e:null}function X(t){let e=ci(t),n=[],s=0,r=0,o=null,i=!0,a=l=>{let c=e.slice(r,l).trim();if(!c)return!0;let u=Ps(c);return u?(n.push({combinator:i?null:o??" ",simples:u}),i=!1,o=null,!0):!1};for(let l=0;l<e.length;l++){let c=e[l];if(c==="("||c==="[")s++;else if(c===")"||c==="]")s=Math.max(0,s-1);else if(s===0&&(c===">"||c==="+"||c==="~")){if(!a(l)||o)return null;o=c,r=l+1}else if(s===0&&/\s/.test(c)){if(!a(l))return null;r=l+1}}return!a(e.length)||o?null:n.length?n:null}function Bt(t){return t.map(e=>e.raw).join("")}function Ft(t){return t.map((e,n)=>{let s=Bt(e.simples);return n===0?s:e.combinator===" "?` ${s}`:` ${e.combinator} ${s}`}).join("")}function z(t){let e=[],n=0,s=0;for(let r=0;r<t.length;r++){let o=t[r];o==="("||o==="["?n++:o===")"||o==="]"?n=Math.max(0,n-1):o===","&&n===0&&(e.push(t.slice(s,r).trim()),s=r+1)}return e.push(t.slice(s).trim()),e.filter(Boolean)}var Os=t=>t.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(e=>e.toLowerCase());function Ls(t,e){let n=t.toLowerCase();return e.some(s=>n.includes(s.toLowerCase()))}function Je(t,e){let n=e.excludeClassKeywords;if(!n?.length)return!1;let s=new Set(n.flatMap(r=>[r.toLowerCase(),`${r.toLowerCase()}s`]));return t.some(r=>r.kind==="class"&&Os(r.name).some(o=>s.has(o)))}var ui=new Set(["html","body"]),pi=new Set(["svg","path","use","img","picture","video","i","em","strong","b","small","kbd","sup","sub"]);function oe(t,e){for(let n of t)switch(n.kind){case"tag":if(e.elements.includes(n.name))return!0;break;case"class":if(Ls(n.name,e.classKeywords))return!0;break;case"attr":if(n.name==="role"&&n.value!==null&&e.roles.includes(n.value.toLowerCase())||n.name==="data-component"&&n.value!==null&&Ls(n.value,e.classKeywords))return!0;break;case"pseudo":if((n.name==="is"||n.name==="where")&&n.args){let s=z(n.args).map(X);if(s.length>0&&s.every(r=>r!==null&&oe(r[r.length-1].simples,e)))return!0}break;default:break}return!1}function Ds(t){return t.some(n=>n.kind==="universal")?t.length===1:t.some(n=>n.kind==="tag"&&ui.has(n.name))?!0:!t.some(n=>n.kind==="tag"||n.kind==="class"||n.kind==="attr"||n.kind==="id"||n.kind==="pseudo"&&(n.name==="is"||n.name==="where"))}function Ts(t){return t.some(e=>e.kind==="tag"&&pi.has(e.name))}var re=["hover","focus","active","selected","current","loading","disabled"],fi={hover:"hover",hovered:"hover",focus:"focus",focused:"focus","focus-visible":"focus","focus-within":"focus",active:"selected",pressed:"selected",selected:"selected",checked:"selected",on:"selected",current:"current",loading:"loading",busy:"loading",pending:"loading",disabled:"disabled"},di={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},gi={disabled:"disabled","aria-disabled":"disabled","data-disabled":"disabled","aria-pressed":"selected","aria-selected":"selected","aria-expanded":"selected","aria-checked":"selected","data-active":"selected","data-selected":"selected","data-pressed":"selected","data-checked":"selected","data-highlighted":"selected","aria-current":"current","aria-busy":"loading","data-loading":"loading","data-busy":"loading","data-hover":"hover","data-hovered":"hover","data-focus":"focus","data-focused":"focus","data-focus-visible":"focus","data-open":"open","data-expanded":"open"},mi=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),Ms=t=>fi[t.toLowerCase()]??t.toLowerCase(),it={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function Ns(t){if(t.kind==="pseudo"){let e=di[t.name];if(!e)return null;let n=it[e];return{state:e,marker:n?{classes:[n],attrs:{}}:{classes:[],attrs:{[t.name==="checked"?"checked":"disabled"]:""}}}}if(t.kind==="attr"){if(t.name==="data-state"&&t.value!==null)return{state:Ms(t.value),marker:{classes:[],attrs:{"data-state":t.value}}};let e=gi[t.name];if(!e||t.value!==null&&/^(?:false|off|0)$/i.test(t.value))return null;let n=t.value??(t.name.startsWith("aria-")?"true":"");return{state:e,marker:{classes:[],attrs:{[t.name]:n}}}}if(t.kind==="class"){let e=/^(?:is|has)-(.+)$/i.exec(t.name),n=e?e[1]:mi.has(t.name.toLowerCase())?t.name:null;return n?{state:Ms(n),marker:{classes:[t.name],attrs:{}}}:null}return null}function hi(t){return t.kind!=="pseudo"||t.name!=="not"||!t.args?!1:z(t.args).every(e=>{let n=Ps(e);return n!==null&&n.every(s=>Ns(s)!==null)})}function ie(t){let e=[],n=new Map;for(let o of t){if(hi(o))continue;let i=Ns(o);if(!i){e.push(o);continue}let a=n.get(i.state)??{classes:[],attrs:{}};for(let l of i.marker.classes)a.classes.includes(l)||a.classes.push(l);Object.assign(a.attrs,i.marker.attrs),n.set(i.state,a)}let s=[...n.keys()].sort((o,i)=>H(o)-H(i)||o.localeCompare(i)),r={classes:[],attrs:{}};for(let o of s){let i=n.get(o);r.classes.push(...i.classes),Object.assign(r.attrs,i.attrs)}return{identity:e,states:s,marker:r}}function H(t){if(t==="default")return-1;let e=re.indexOf(t);return e===-1?re.length:e}function gt(t){return t.length?t.join(" + "):"default"}function Ze(t){return t.replace(/:hover\b/g,`.${it.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${it.focus}`).replace(/:active\b/g,`.${it.active}`)}var bi=new Set(["background","background-color","background-image","background-position","background-size","background-repeat","background-clip","background-origin","background-attachment","color","border-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline","outline-color","outline-offset","box-shadow","filter","backdrop-filter","opacity","fill","stroke","caret-color","accent-color","text-decoration-color","mix-blend-mode"]),yi=new Set(["width","min-width","max-width","flex","flex-grow","flex-shrink","flex-basis","align-self","justify-self","order","margin","margin-top","margin-right","margin-bottom","margin-left","margin-inline","margin-block","margin-inline-start","margin-inline-end","margin-block-start","margin-block-end","position","inset","inset-inline","inset-block","top","right","bottom","left","z-index","float","clear","grid-column","grid-row","grid-area","place-self"]),xi=new Set(["cursor","user-select","pointer-events","transition","transition-property","transition-duration","transition-timing-function","transition-delay","will-change","touch-action","-webkit-tap-highlight-color","appearance","-webkit-appearance","scroll-margin","scroll-margin-top"]);function Ut(t){let e=t.toLowerCase();return bi.has(e)?"paint":yi.has(e)?"layout":xi.has(e)?"hint":"box"}var ki={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function Vs(t,e){let n=t.filter(o=>o.kind==="class");if(n.length!==1||t.length!==1)return!1;let s=Os(n[0].name)[0],r=s?ki[s]:void 0;return r?e.length>0&&e.every(o=>r.test(o.property.toLowerCase())):!1}var tu={hover:{classes:[it.hover],attrs:{}},focus:{classes:[it.focus],attrs:{}},active:{classes:[it.active],attrs:{}},selected:{classes:[],attrs:{"aria-pressed":"true"}},current:{classes:[],attrs:{"aria-current":"true"}},loading:{classes:[],attrs:{"aria-busy":"true"}},disabled:{classes:[],attrs:{disabled:""}}};var wi="data-gs-sheet";function Fs(t){return`[${wi}="${t.replace(/["\\]/g,"")}"]`}function Bs(t){return/\.module\.[a-z]+$/i.test(t)}var vi=new Set(["button","a","div","span","input","summary","label"]);function mt(t){let e=0,n=0;for(let s=0;s<t.length;s++){let r=t[s];r==="("||r==="["?e++:r===")"||r==="]"?e=Math.max(0,e-1):e===0&&/[\s>+~]/.test(r)&&(n=s+1)}return n}function $i(t){let e={tag:"",classes:[],attrs:{}};for(let n of t)switch(n.kind){case"pseudoElement":return null;case"tag":e.tag=n.name;break;case"class":e.classes.push(n.name);break;case"attr":e.attrs[n.name]=n.value??"";break;default:break}return e}function ae(t,e){let n=X(t);if(!n||n.some(c=>c.combinator==="+"||c.combinator==="~"))return null;let s=n.map(c=>$i(c.simples));if(s.some(c=>c===null))return null;let r=s,o=r[r.length-1],i=o.tag&&o.tag!=="*"?o.tag:"button";if(!vi.has(i)||o.classes.length===0&&Object.keys(o.attrs).length===0&&!o.tag)return null;let a=[...new Set([...e,...o.classes])],l=r.slice(0,-1).filter(c=>c.tag||c.classes.length||Object.keys(c.attrs).length).map(c=>({...c,tag:c.tag&&c.tag!=="*"?c.tag:"div"}));return{tag:i,classes:a,attrs:o.attrs,ancestors:l}}function Xe(t,e){let n="";for(let s of t)s.property.toLowerCase()===e&&(n=s.value.replace(/!important\s*$/i,"").trim());return n}function le(t){let e=Xe(t,"display");if(/^none\b/i.test(e))return"display: none";let n=Xe(t,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let s=Xe(t,"opacity");return/^(0|0\.0+)$/.test(s)?"opacity: 0":null}function Us(t,e){return t===e||!Bs(t)&&!Bs(e)}function et(t,e){if(/[<>]|@import|expression\(|javascript:|behavior\s*:/i.test(e))return!1;for(let n of e.matchAll(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi))if(!/^data:image\//i.test(n[2]))return!1;return/^-{0,2}[a-z][\w-]*$/i.test(t)}var Ci=40,q=(t,e)=>({path:t,line:e});function Y(t,e,n,s){return{...t,status:e.length===0?"ok":"attention",summary:e.length===0?n:s(e.length),findings:e.slice(0,Ci)}}function ht(t,e){return{...t,status:"na",summary:e,findings:[]}}var qe=t=>t.state.split(" + ");function Ks(t,e){if(!t.element||!e.element||t!==e&&!Us(t.path,e.path)||t.element.ancestors.length>0||t.element.tag!==e.element.tag)return!1;let n=new Set(e.element.classes);return t.element.classes.every(s=>n.has(s))?Object.entries(t.element.attrs).every(([s,r])=>e.element.attrs[s]===r):!1}function Js(t,e){return e.filter(n=>Ks(n,t)).flatMap(n=>n.states)}function Si(t,e,n){return Js(t,e).some(s=>qe(s).includes(n))||e.filter(s=>Ks(s,t)).some(s=>(s.parts??[]).some(r=>r.state.split(" + ").includes(n)))}var Ri=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function Ai(t){let e={id:"states",title:"Missing states",description:"Styles with no hover, focus, disabled, or active rule, counting rules they inherit from a shared base class."},n=t.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return ht(e,"No styles that can be drawn on their own.");let s=[];for(let{state:r,severity:o}of Ri){let i=n.filter(a=>!Si(a,t.variants,r));i.length!==0&&s.push({severity:o,message:i.length===n.length?`No style defines a ${r} state.`:`${i.length} of ${n.length} styles have no ${r} state.`,styles:i.length===n.length?void 0:i.map(a=>a.title),refs:i.slice(0,6).map(a=>q(a.path,a.line))})}return Y(e,s,"Every style has hover, focus, disabled, and active rules.",r=>`${r} state${r===1?"":"s"} missing on some styles.`)}var zs=new Set(["outline","outline-style","outline-width"]),Ws=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,_i=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function Ei(t){let e={id:"focus",title:"Focus indicator removed",description:"Styles that remove the outline and give keyboard focus nothing in its place."},n=t.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return ht(e,"No styles that can be drawn on their own.");let s=[];for(let r of n){let o=Js(r,t.variants),i=o.filter(l=>{let c=qe(l);return c.includes("default")||c.includes("focus")}).flatMap(l=>l.declarations.map(c=>({s:l,d:c}))).find(({d:l})=>zs.has(l.property)&&Ws.test(l.value.replace(/\s*!important/i,"")));!i||o.filter(l=>qe(l).includes("focus")).some(l=>l.declarations.some(c=>_i.test(c.property)&&!(zs.has(c.property)&&Ws.test(c.value))&&!/^(?:none|0|0px)$/i.test(c.value)&&!(c.property==="box-shadow"&&/^none$/i.test(c.value))))||s.push({severity:"issue",message:`${r.title} removes the outline (${i.d.property}: ${i.d.value}) and no focus rule replaces it.`,styles:[r.title],refs:[q(r.path,i.s.line)]})}return Y(e,s,"No style removes the outline without a focus replacement.",r=>`${r} style${r===1?"":"s"} lose the focus indicator.`)}function ji(t){let e={id:"tokens",title:"Undefined tokens",description:`Custom properties the ${t.noun} styles read that no scanned stylesheet defines.`};if(t.tokens.length===0)return ht(e,`The ${t.noun} styles read no custom properties.`);let s=t.tokens.filter(r=>r.definedIn.length===0&&!r.name.startsWith("--tw-")).map(r=>{let o=t.variants.filter(i=>i.states.some(a=>a.declarations.some(l=>l.value.includes(`var(${r.name}`)||new RegExp(`var\\(\\s*${r.name}\\b`).test(l.value))));return{severity:"note",message:`${r.name} is read but never defined here. It may be set outside the scanned files (a framework, a theme provider).`,styles:o.slice(0,8).map(i=>i.title),refs:o.slice(0,3).map(i=>q(i.path,i.line))}});return Y(e,s,`All ${t.tokens.length} tokens read are defined.`,r=>`${r} token${r===1?"":"s"} with no definition.`)}var Ii=/var\((?:[^()]|\([^()]*\))*\)/g,Gs=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,Li=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,Mi=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function Hs(t){let e=t.trim().toLowerCase().replace(/\s+/g,""),n=/^#([0-9a-f]{3})$/.exec(e);return n?`#${[...n[1]].map(s=>s+s).join("")}`:e}function Ye(t,e,n=0){return n>6?t:t.replace(/var\(\s*(--[\w-]+)\s*(?:,\s*([^)]*))?\)/g,(s,r,o)=>{let i=e.get(r);return i!==void 0?Ye(i,e,n+1):o!==void 0?Ye(o.trim(),e,n+1):s})}var Pi=[[/^(?:padding|margin|gap|row-gap|column-gap)/,/space|spacing|gap|pad|inset|gutter/i],[/height$/,/height|control|size/i],[/^border-radius/,/radius|round|corner/i],[/^font-size$/,/text|font|size|type/i],[/^letter-spacing$/,/tracking|letter|spacing/i]];function Oi(t,e){if(!e)return null;let n=Pi.find(([s])=>s.test(t))?.[1];return e.find(s=>!n||n.test(s))??null}function Di(t){let e={id:"hardcoded",title:"Hard-coded values",description:`Raw colors, and pixel sizes that exactly match a token, written into ${t.noun} styles instead of using the token.`},n=new Map,s=new Map;for(let[o,i]of t.tokenValues){let a=Ye(i,t.tokenValues).trim();if(new RegExp(`^(?:${Gs.source})$`,"i").test(a)){let l=Hs(a);n.set(l,[...n.get(l)??[],o])}else/^\d+(?:\.\d+)?px$/.test(a)&&s.set(a,[...s.get(a)??[],o])}if(n.size===0&&s.size===0)return ht(e,"No color or size tokens were found to compare against.");let r=[];for(let o of t.variants){let i=[],a=null;for(let c of o.states)for(let u of c.declarations){if(u.via)continue;let f=u.value.replace(Ii," ");for(let m of f.matchAll(Gs)){let b=n.get(Hs(m[0]));i.push(b?`${m[0]} in ${u.property} is the value of ${b[0]}`:`${m[0]} in ${u.property} is not a token`),a??=c}if(Li.test(u.property))for(let m of f.matchAll(Mi)){let b=Oi(u.property,s.get(`${m[1]}px`));!b||Number(m[1])<=1||(i.push(`${m[1]}px in ${u.property} is the value of ${b}`),a??=c)}}if(i.length===0||!a)continue;let l=[...new Set(i)];r.push({severity:"issue",message:`${o.title}: ${l.slice(0,4).join("; ")}${l.length>4?`; and ${l.length-4} more`:""}.`,styles:[o.title],refs:[q(o.path,a.line)]})}return Y(e,r,`No ${t.noun} style hard-codes a value a token already has.`,o=>`${o} style${o===1?"":"s"} hard-code values.`)}function Ti(t){let e={id:"unused",title:"Unused styles",description:"Styles defined in CSS that no component, page, or template references."},n=t.variants.filter(r=>r.element&&r.usage.status!=="unknown");if(n.length===0)return ht(e,"No styles with a class name to look for.");let s=[];for(let r of n)r.usage.status==="unreferenced"?s.push({severity:"issue",message:`${r.title} (${r.selector}) is defined but no reference to it was found.`,styles:[r.title],refs:[q(r.path,r.line)]}):r.usage.status==="dynamic"&&s.push({severity:"note",message:`${r.title} (${r.selector}) is built at runtime and nothing selects it by value.`,styles:[r.title],refs:[q(r.path,r.line),...r.usage.files.slice(0,2)]});return s.sort((r,o)=>+(o.severity==="issue")-+(r.severity==="issue")),Y(e,s,`All ${n.length} styles are referenced.`,r=>`${r} style${r===1?"":"s"} unreferenced or unconfirmed.`)}function Ni(t){let e={id:"duplicates",title:"Duplicate styles",description:"Different styles whose default declarations are identical."},n=new Map;for(let r of t.variants){if(!r.element)continue;let o=r.states.filter(a=>a.state==="default"&&a.context==="").flatMap(a=>a.declarations).map(a=>`${a.property}:${a.value.replace(/\s+/g," ").trim()}`);if(o.length<2)continue;let i=[...new Set(o)].sort().join(";");n.set(i,[...n.get(i)??[],r])}let s=[...n.values()].filter(r=>r.length>1).map(r=>({severity:"issue",message:`${r.map(o=>o.title).join(", ")} declare the same default styles (${r.map(o=>o.selector).join(", ")}).`,styles:r.map(o=>o.title),refs:r.map(o=>q(o.path,o.line))}));return Y(e,s,"No two styles share the same default declarations.",r=>`${r} group${r===1?"":"s"} of identical styles.`)}function Vi(t){let e={id:"native",title:`Native <${t.element}> instead of the component`,description:`Files that render a raw <${t.element}> although the repository has a shared ${t.element} component.`};if(!t.hasComponent)return ht(e,`No shared ${t.element} component was found, so native elements are expected.`);let n=t.nativeUses.map(s=>({severity:"issue",message:`${s.count} native <${t.element}> element${s.count===1?"":"s"} in ${s.path}.`,refs:[q(s.path,s.line)]}));return Y(e,n,`Every <${t.element}> goes through the component.`,s=>`${s} file${s===1?"":"s"} bypass the component.`)}function Bi(t){let e={id:"props",title:"Prop values with no look",description:`Calls to a ${t.element} component with a literal prop value the component has no style for.`};if(!t.hasComponent)return ht(e,`No shared ${t.element} component was found.`);let n=(t.unknownProps??[]).map(s=>({severity:"issue",message:`<${s.component} ${s.prop}="${s.value}"> in ${s.path}: ${s.component} has no ${s.prop} "${s.value}" (it has ${s.known.join(", ")}).`,refs:[q(s.path,s.line)]}));return Y(e,n,"Every literal prop value picks a look the component has.",s=>`${s} call${s===1?"":"s"} ask for a look the component does not have.`)}function Fi(t){let e={id:"undocumented",title:"Styles without written guidance",description:"Styles that no instruction file or doc names, so nothing written says how they should be used."},{guidance:n}=t;if(n.files.length===0)return{...e,status:"attention",summary:`Nothing in the repository mentions ${t.noun}.`,findings:[{severity:"note",message:`No instruction file or doc says how ${t.noun} should look or be built.`,refs:[]}]};if(n.undocumented.length===0)return Y(e,[],"Every style is named in written guidance.",()=>"");let s=t.variants.filter(r=>r.element&&n.undocumented.includes(r.title));return Y(e,[{severity:"note",message:`${n.undocumented.length} of ${n.documented.length+n.undocumented.length} styles are named in no guidance.`,styles:n.undocumented,refs:s.slice(0,6).map(r=>q(r.path,r.line))}],"",r=>`${r} finding${r===1?"":"s"}.`)}function Zs(t){return[Ai(t),Ei(t),Ti(t),Ni(t),ji(t),Di(t),Vi(t),Bi(t),Fi(t)]}var Ui=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,Xs=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,zi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Wi=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),Gi=new Set(["classNames","classnames","clsx","cn","cx"]),Hi=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function Qs(t,e){let n=1;for(let s=0;s<e&&s<t.length;s++)t[s]===`
36
- `&&n++;return n}function qs(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function tr(t){let e=t.filter(s=>s.trim()).map(s=>/^ */.exec(s)?.[0].length??0),n=e.length?Math.min(...e):0;return t.map(s=>{let r=s.slice(n);return r.length>200?`${r.slice(0,200)}\u2026`:r}).join(`
37
- `)}function Ki(t,e,n){let s=Math.max(0,Math.min(e,t.length)),r=Math.max(s,Math.min(n,t.length)),o=Qs(t,s),i=t.slice(s,r).split(`
38
- `).slice(0,12),a=t.slice(s,r).split(`
32
+ `}var ks=`
33
+ Choose 1\u20133, or press Enter to quit: `,ws=`
34
+ Would you like to run a (c) check, (b) baseline, or (q) quit? `,vs=`
35
+ You have no baseline. Would you like to run it? (b) baseline, (q) quit: `;function $s(e){let t=e.trim().toLowerCase();return!t||t==="q"||t==="quit"?"quit":t==="c"||t==="check"?"check":t==="b"||t==="baseline"?"baseline":null}function Cs(e){let t=e.trim().toLowerCase();return!t||t==="q"||t==="quit"||t==="n"||t==="no"?"quit":t==="b"||t==="baseline"||t==="y"||t==="yes"?"baseline":null}function Ss(e){let t=e.trim().toLowerCase();if(!t)return"quit";let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Se.length?Se[n-1]:Se.find(s=>s.name===t)??null}var ci="2025-06-18",et="Check before you finish, fix to the spec when you can, ask for an exception with a reason when you cannot, and never edit Gruum's generated files to make a check pass.",tt={gruum_button_spec:`The designer-published button spec for this repository: components, looks and how to select them, tokens, and written rules. Read it before writing or restyling a button. ${et}`,gruum_check_buttons:`Check the working tree's buttons against the spec and list drift items with a one-line fix each. Run it before you stop. ${et}`,gruum_request_exception:`Ask a designer to allow one drift item the spec has no button for. Send the drift id from gruum_check_buttons and a reason. ${et}`,gruum_exception_status:`Pending, accepted, or rejected for this branch's exception requests. Pass an id to read one. ${et}`};function Rs(e){return[{name:"gruum_button_spec",description:tt.gruum_button_spec,inputSchema:{type:"object",properties:{},additionalProperties:!1},run:()=>e.spec()},{name:"gruum_check_buttons",description:tt.gruum_check_buttons,inputSchema:{type:"object",properties:{paths:{type:"array",items:{type:"string"},description:"Only report drift in these files (relative to the repository root). Omit to check everything."}},additionalProperties:!1},run:t=>{let n=Array.isArray(t.paths)?t.paths.filter(s=>typeof s=="string"):[];return e.check(n)}},{name:"gruum_request_exception",description:tt.gruum_request_exception,inputSchema:{type:"object",properties:{driftId:{type:"string",description:"The drift item id from gruum_check_buttons."},reason:{type:"string",description:"Why the spec has no button for this job."}},required:["driftId","reason"],additionalProperties:!1},run:t=>e.request(typeof t.driftId=="string"?t.driftId:"",typeof t.reason=="string"?t.reason:"")},{name:"gruum_exception_status",description:tt.gruum_exception_status,inputSchema:{type:"object",properties:{id:{type:"string",description:"One request id. Omit to list this branch."}},additionalProperties:!1},run:t=>e.status(typeof t.id=="string"?t.id:void 0)}]}function Ve(e,t){return{jsonrpc:"2.0",id:e,result:t}}function nt(e,t,n){return{jsonrpc:"2.0",id:e,error:{code:t,message:n}}}async function As(e,t,n){if(!e||typeof e!="object")return nt(null,-32600,"Invalid request");let s=e,r=!("id"in s),o=s.id??null;if(typeof s.method!="string")return r?null:nt(o,-32600,"Invalid request");let i=s.params??{};switch(s.method){case"initialize":{let a=i.protocolVersion;return Ve(o,{protocolVersion:typeof a=="string"?a:ci,capabilities:{tools:{listChanged:!1}},serverInfo:n})}case"ping":return Ve(o,{});case"tools/list":return Ve(o,{tools:t.map(({name:a,description:l,inputSchema:c})=>({name:a,description:l,inputSchema:c}))});case"tools/call":{let a=t.find(c=>c.name===i.name);if(!a)return nt(o,-32602,`Unknown tool: ${String(i.name)}`);let l=i.arguments&&typeof i.arguments=="object"?i.arguments:{};try{let c=await a.run(l);return Ve(o,{content:[{type:"text",text:c.text}],isError:c.isError??!1})}catch(c){return Ve(o,{content:[{type:"text",text:c instanceof Error?c.message:String(c)}],isError:!0})}}default:return r?null:nt(o,-32601,`Method not found: ${s.method}`)}}var ui=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv)\//,pi=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$/,fi=/\.(png|jpe?g|gif|webp|avif|ico|icns|bmp|tiff?|svgz|woff2?|ttf|otf|eot|mp[34]|wav|ogg|webm|mov|zip|gz|tgz|bz2|7z|rar|jar|pdf|docx?|xlsx?|pptx?|exe|dll|so|dylib|wasm|bin|dat|sqlite|db|psd|ai|sketch|fig)$/i,di=/(^|\/)\.gruum\//;function zt(e){return!ui.test(`${e}/`)&&!di.test(`${e}/`)}function Wt(e,t){return pi.test(e)||fi.test(e)?!1:t<=3e5}function _s(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}var gi=/\.(css|scss|sass|less|styl|tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?|mdx?|erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2|json)$/i;function Es(e){return gi.test(e)}function Gt(e){return e.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function Ht(e,t){let n=Gt(t),s=e.replace(/\\/g,"/");return n?s.startsWith(`${n}/`)?s.slice(n.length+1):null:s}function Is(e,t,n){let s=new Map(e);for(let r of t){let o=Ht(r.path,n);o===null||!zt(o.split("/").slice(0,-1).join("/")||".")||(r.content===null?s.delete(o):Wt(o,r.content.length)&&s.set(o,r.content))}return s}function js(e){let t=e.split("\0").filter(Boolean),n=[];for(let s=0;s<t.length;s++){let r=t[s];if(/^[RC]/.test(r)){let i=t[++s],a=t[++s];r.startsWith("R")&&i&&n.push({path:i,deleted:!0}),a&&n.push({path:a,deleted:!1});continue}let o=t[++s];o&&n.push({path:o,deleted:r.startsWith("D")})}return n}function st(e){let t=/^(?:git@|ssh:\/\/git@|https?:\/\/(?:[^@/]+@)?)github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(e.trim());return t?`${t[1]}/${t[2]}`:null}var Ls=e=>e.replace(/\\(.)/g,"$1");function mi(e){let t=e;for(;;){let n=/:(?:global|local)\(/i.exec(t);if(!n)break;let s=0,r=-1;for(let i=n.index+n[0].length-1;i<t.length;i++){let a=t[i];if(a==="(")s++;else if(a===")"&&--s===0){r=i;break}}if(r<0)break;let o=t.slice(n.index+n[0].length,r).trim();t=`${t.slice(0,n.index)}${o}${t.slice(r+1)}`}return t.replace(/:(?:global|local)(?=\s|$)/gi,"").trim()}var Kt=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function Os(e){let t=[];Kt.lastIndex=0;let n=0;for(;n<e.length;){Kt.lastIndex=n;let s=Kt.exec(e);if(!s||s.index!==n)return null;let r=s[0];if(n+=r.length,r==="*")t.push({kind:"universal",raw:r});else if(s[1]!==void 0)t.push({kind:"class",raw:r,name:Ls(s[1])});else if(s[2]!==void 0)t.push({kind:"id",raw:r,name:Ls(s[2])});else if(s[3]!==void 0)t.push({kind:"attr",raw:r,name:s[3],op:s[4]??null,value:s[4]?s[5]??s[6]??s[7]??"":null});else if(s[8]!==void 0)t.push({kind:"pseudoElement",raw:r,name:s[8].toLowerCase()});else if(s[9]!==void 0){let o=s[9].toLowerCase();/^(?:before|after|first-line|first-letter)$/.test(o)?t.push({kind:"pseudoElement",raw:r,name:o}):t.push({kind:"pseudo",raw:r,name:o,args:s[10]?s[10].slice(1,-1).trim():null})}else if(t.length===0)t.push({kind:"tag",raw:r,name:r.toLowerCase()});else return null}return t.length?t:null}function X(e){let t=mi(e),n=[],s=0,r=0,o=null,i=!0,a=l=>{let c=t.slice(r,l).trim();if(!c)return!0;let u=Os(c);return u?(n.push({combinator:i?null:o??" ",simples:u}),i=!1,o=null,!0):!1};for(let l=0;l<t.length;l++){let c=t[l];if(c==="("||c==="[")s++;else if(c===")"||c==="]")s=Math.max(0,s-1);else if(s===0&&(c===">"||c==="+"||c==="~")){if(!a(l)||o)return null;o=c,r=l+1}else if(s===0&&/\s/.test(c)){if(!a(l))return null;r=l+1}}return!a(t.length)||o?null:n.length?n:null}function Fe(e){return e.map(t=>t.raw).join("")}function Be(e){return e.map((t,n)=>{let s=Fe(t.simples);return n===0?s:t.combinator===" "?` ${s}`:` ${t.combinator} ${s}`}).join("")}function z(e){let t=[],n=0,s=0;for(let r=0;r<e.length;r++){let o=e[r];o==="("||o==="["?n++:o===")"||o==="]"?n=Math.max(0,n-1):o===","&&n===0&&(t.push(e.slice(s,r).trim()),s=r+1)}return t.push(e.slice(s).trim()),t.filter(Boolean)}var Ns=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function Ps(e,t){let n=e.toLowerCase();return t.some(s=>n.includes(s.toLowerCase()))}function Jt(e,t){let n=t.excludeClassKeywords;if(!n?.length)return!1;let s=new Set(n.flatMap(r=>[r.toLowerCase(),`${r.toLowerCase()}s`]));return e.some(r=>r.kind==="class"&&Ns(r.name).some(o=>s.has(o)))}var hi=new Set(["html","body"]),bi=new Set(["svg","path","use","img","picture","video","i","em","strong","b","small","kbd","sup","sub"]);function ot(e,t){for(let n of e)switch(n.kind){case"tag":if(t.elements.includes(n.name))return!0;break;case"class":if(Ps(n.name,t.classKeywords))return!0;break;case"attr":if(n.name==="role"&&n.value!==null&&t.roles.includes(n.value.toLowerCase())||n.name==="data-component"&&n.value!==null&&Ps(n.value,t.classKeywords))return!0;break;case"pseudo":if((n.name==="is"||n.name==="where")&&n.args){let s=z(n.args).map(X);if(s.length>0&&s.every(r=>r!==null&&ot(r[r.length-1].simples,t)))return!0}break;default:break}return!1}function Ds(e){return e.some(n=>n.kind==="universal")?e.length===1:e.some(n=>n.kind==="tag"&&hi.has(n.name))?!0:!e.some(n=>n.kind==="tag"||n.kind==="class"||n.kind==="attr"||n.kind==="id"||n.kind==="pseudo"&&(n.name==="is"||n.name==="where"))}function Ts(e){return e.some(t=>t.kind==="tag"&&bi.has(t.name))}var rt=["hover","focus","active","selected","current","loading","disabled"],yi={hover:"hover",hovered:"hover",focus:"focus",focused:"focus","focus-visible":"focus","focus-within":"focus",active:"selected",pressed:"selected",selected:"selected",checked:"selected",on:"selected",current:"current",loading:"loading",busy:"loading",pending:"loading",disabled:"disabled"},xi={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},ki={disabled:"disabled","aria-disabled":"disabled","data-disabled":"disabled","aria-pressed":"selected","aria-selected":"selected","aria-expanded":"selected","aria-checked":"selected","data-active":"selected","data-selected":"selected","data-pressed":"selected","data-checked":"selected","data-highlighted":"selected","aria-current":"current","aria-busy":"loading","data-loading":"loading","data-busy":"loading","data-hover":"hover","data-hovered":"hover","data-focus":"focus","data-focused":"focus","data-focus-visible":"focus","data-open":"open","data-expanded":"open"},wi=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),Ms=e=>yi[e.toLowerCase()]??e.toLowerCase(),ie={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function Vs(e){if(e.kind==="pseudo"){let t=xi[e.name];if(!t)return null;let n=ie[t];return{state:t,marker:n?{classes:[n],attrs:{}}:{classes:[],attrs:{[e.name==="checked"?"checked":"disabled"]:""}}}}if(e.kind==="attr"){if(e.name==="data-state"&&e.value!==null)return{state:Ms(e.value),marker:{classes:[],attrs:{"data-state":e.value}}};let t=ki[e.name];if(!t||e.value!==null&&/^(?:false|off|0)$/i.test(e.value))return null;let n=e.value??(e.name.startsWith("aria-")?"true":"");return{state:t,marker:{classes:[],attrs:{[e.name]:n}}}}if(e.kind==="class"){let t=/^(?:is|has)-(.+)$/i.exec(e.name),n=t?t[1]:wi.has(e.name.toLowerCase())?e.name:null;return n?{state:Ms(n),marker:{classes:[e.name],attrs:{}}}:null}return null}function vi(e){return e.kind!=="pseudo"||e.name!=="not"||!e.args?!1:z(e.args).every(t=>{let n=Os(t);return n!==null&&n.every(s=>Vs(s)!==null)})}function it(e){let t=[],n=new Map;for(let o of e){if(vi(o))continue;let i=Vs(o);if(!i){t.push(o);continue}let a=n.get(i.state)??{classes:[],attrs:{}};for(let l of i.marker.classes)a.classes.includes(l)||a.classes.push(l);Object.assign(a.attrs,i.marker.attrs),n.set(i.state,a)}let s=[...n.keys()].sort((o,i)=>H(o)-H(i)||o.localeCompare(i)),r={classes:[],attrs:{}};for(let o of s){let i=n.get(o);r.classes.push(...i.classes),Object.assign(r.attrs,i.attrs)}return{identity:t,states:s,marker:r}}function H(e){if(e==="default")return-1;let t=rt.indexOf(e);return t===-1?rt.length:t}function ge(e){return e.length?e.join(" + "):"default"}function Zt(e){return e.replace(/:hover\b/g,`.${ie.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${ie.focus}`).replace(/:active\b/g,`.${ie.active}`)}var $i=new Set(["background","background-color","background-image","background-position","background-size","background-repeat","background-clip","background-origin","background-attachment","color","border-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline","outline-color","outline-offset","box-shadow","filter","backdrop-filter","opacity","fill","stroke","caret-color","accent-color","text-decoration-color","mix-blend-mode"]),Ci=new Set(["width","min-width","max-width","flex","flex-grow","flex-shrink","flex-basis","align-self","justify-self","order","margin","margin-top","margin-right","margin-bottom","margin-left","margin-inline","margin-block","margin-inline-start","margin-inline-end","margin-block-start","margin-block-end","position","inset","inset-inline","inset-block","top","right","bottom","left","z-index","float","clear","grid-column","grid-row","grid-area","place-self"]),Si=new Set(["cursor","user-select","pointer-events","transition","transition-property","transition-duration","transition-timing-function","transition-delay","will-change","touch-action","-webkit-tap-highlight-color","appearance","-webkit-appearance","scroll-margin","scroll-margin-top"]);function Ue(e){let t=e.toLowerCase();return $i.has(t)?"paint":Ci.has(t)?"layout":Si.has(t)?"hint":"box"}var Ri={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function Fs(e,t){let n=e.filter(o=>o.kind==="class");if(n.length!==1||e.length!==1)return!1;let s=Ns(n[0].name)[0],r=s?Ri[s]:void 0;return r?t.length>0&&t.every(o=>r.test(o.property.toLowerCase())):!1}var au={hover:{classes:[ie.hover],attrs:{}},focus:{classes:[ie.focus],attrs:{}},active:{classes:[ie.active],attrs:{}},selected:{classes:[],attrs:{"aria-pressed":"true"}},current:{classes:[],attrs:{"aria-current":"true"}},loading:{classes:[],attrs:{"aria-busy":"true"}},disabled:{classes:[],attrs:{disabled:""}}};var Ai="data-gs-sheet";function Us(e){return`[${Ai}="${e.replace(/["\\]/g,"")}"]`}function Bs(e){return/\.module\.[a-z]+$/i.test(e)}var _i=new Set(["button","a","div","span","input","summary","label"]);function me(e){let t=0,n=0;for(let s=0;s<e.length;s++){let r=e[s];r==="("||r==="["?t++:r===")"||r==="]"?t=Math.max(0,t-1):t===0&&/[\s>+~]/.test(r)&&(n=s+1)}return n}function Ei(e){let t={tag:"",classes:[],attrs:{}};for(let n of e)switch(n.kind){case"pseudoElement":return null;case"tag":t.tag=n.name;break;case"class":t.classes.push(n.name);break;case"attr":t.attrs[n.name]=n.value??"";break;default:break}return t}function at(e,t){let n=X(e);if(!n||n.some(c=>c.combinator==="+"||c.combinator==="~"))return null;let s=n.map(c=>Ei(c.simples));if(s.some(c=>c===null))return null;let r=s,o=r[r.length-1],i=o.tag&&o.tag!=="*"?o.tag:"button";if(!_i.has(i)||o.classes.length===0&&Object.keys(o.attrs).length===0&&!o.tag)return null;let a=[...new Set([...t,...o.classes])],l=r.slice(0,-1).filter(c=>c.tag||c.classes.length||Object.keys(c.attrs).length).map(c=>({...c,tag:c.tag&&c.tag!=="*"?c.tag:"div"}));return{tag:i,classes:a,attrs:o.attrs,ancestors:l}}function Xt(e,t){let n="";for(let s of e)s.property.toLowerCase()===t&&(n=s.value.replace(/!important\s*$/i,"").trim());return n}function lt(e){let t=Xt(e,"display");if(/^none\b/i.test(t))return"display: none";let n=Xt(e,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let s=Xt(e,"opacity");return/^(0|0\.0+)$/.test(s)?"opacity: 0":null}function zs(e,t){return e===t||!Bs(e)&&!Bs(t)}function ne(e,t){if(/[<>]|@import|expression\(|javascript:|behavior\s*:/i.test(t))return!1;for(let n of t.matchAll(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi))if(!/^data:image\//i.test(n[2]))return!1;return/^-{0,2}[a-z][\w-]*$/i.test(e)}var Ii=40,q=(e,t)=>({path:e,line:t});function Y(e,t,n,s){return{...e,status:t.length===0?"ok":"attention",summary:t.length===0?n:s(t.length),findings:t.slice(0,Ii)}}function he(e,t){return{...e,status:"na",summary:t,findings:[]}}var qt=e=>e.state.split(" + ");function Js(e,t){if(!e.element||!t.element||e!==t&&!zs(e.path,t.path)||e.element.ancestors.length>0||e.element.tag!==t.element.tag)return!1;let n=new Set(t.element.classes);return e.element.classes.every(s=>n.has(s))?Object.entries(e.element.attrs).every(([s,r])=>t.element.attrs[s]===r):!1}function Zs(e,t){return t.filter(n=>Js(n,e)).flatMap(n=>n.states)}function ji(e,t,n){return Zs(e,t).some(s=>qt(s).includes(n))||t.filter(s=>Js(s,e)).some(s=>(s.parts??[]).some(r=>r.state.split(" + ").includes(n)))}var Li=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function Pi(e){let t={id:"states",title:"Missing states",description:"Styles with no hover, focus, disabled, or active rule, counting rules they inherit from a shared base class."},n=e.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return he(t,"No styles that can be drawn on their own.");let s=[];for(let{state:r,severity:o}of Li){let i=n.filter(a=>!ji(a,e.variants,r));i.length!==0&&s.push({severity:o,message:i.length===n.length?`No style defines a ${r} state.`:`${i.length} of ${n.length} styles have no ${r} state.`,styles:i.length===n.length?void 0:i.map(a=>a.title),refs:i.slice(0,6).map(a=>q(a.path,a.line))})}return Y(t,s,"Every style has hover, focus, disabled, and active rules.",r=>`${r} state${r===1?"":"s"} missing on some styles.`)}var Ws=new Set(["outline","outline-style","outline-width"]),Gs=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,Mi=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function Oi(e){let t={id:"focus",title:"Focus indicator removed",description:"Styles that remove the outline and give keyboard focus nothing in its place."},n=e.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return he(t,"No styles that can be drawn on their own.");let s=[];for(let r of n){let o=Zs(r,e.variants),i=o.filter(l=>{let c=qt(l);return c.includes("default")||c.includes("focus")}).flatMap(l=>l.declarations.map(c=>({s:l,d:c}))).find(({d:l})=>Ws.has(l.property)&&Gs.test(l.value.replace(/\s*!important/i,"")));!i||o.filter(l=>qt(l).includes("focus")).some(l=>l.declarations.some(c=>Mi.test(c.property)&&!(Ws.has(c.property)&&Gs.test(c.value))&&!/^(?:none|0|0px)$/i.test(c.value)&&!(c.property==="box-shadow"&&/^none$/i.test(c.value))))||s.push({severity:"issue",message:`${r.title} removes the outline (${i.d.property}: ${i.d.value}) and no focus rule replaces it.`,styles:[r.title],refs:[q(r.path,i.s.line)]})}return Y(t,s,"No style removes the outline without a focus replacement.",r=>`${r} style${r===1?"":"s"} lose the focus indicator.`)}function Ni(e){let t={id:"tokens",title:"Undefined tokens",description:`Custom properties the ${e.noun} styles read that no scanned stylesheet defines.`};if(e.tokens.length===0)return he(t,`The ${e.noun} styles read no custom properties.`);let s=e.tokens.filter(r=>r.definedIn.length===0&&!r.name.startsWith("--tw-")).map(r=>{let o=e.variants.filter(i=>i.states.some(a=>a.declarations.some(l=>l.value.includes(`var(${r.name}`)||new RegExp(`var\\(\\s*${r.name}\\b`).test(l.value))));return{severity:"note",message:`${r.name} is read but never defined here. It may be set outside the scanned files (a framework, a theme provider).`,styles:o.slice(0,8).map(i=>i.title),refs:o.slice(0,3).map(i=>q(i.path,i.line))}});return Y(t,s,`All ${e.tokens.length} tokens read are defined.`,r=>`${r} token${r===1?"":"s"} with no definition.`)}var Di=/var\((?:[^()]|\([^()]*\))*\)/g,Hs=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,Ti=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,Vi=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function Ks(e){let t=e.trim().toLowerCase().replace(/\s+/g,""),n=/^#([0-9a-f]{3})$/.exec(t);return n?`#${[...n[1]].map(s=>s+s).join("")}`:t}function Yt(e,t,n=0){return n>6?e:e.replace(/var\(\s*(--[\w-]+)\s*(?:,\s*([^)]*))?\)/g,(s,r,o)=>{let i=t.get(r);return i!==void 0?Yt(i,t,n+1):o!==void 0?Yt(o.trim(),t,n+1):s})}var Fi=[[/^(?:padding|margin|gap|row-gap|column-gap)/,/space|spacing|gap|pad|inset|gutter/i],[/height$/,/height|control|size/i],[/^border-radius/,/radius|round|corner/i],[/^font-size$/,/text|font|size|type/i],[/^letter-spacing$/,/tracking|letter|spacing/i]];function Bi(e,t){if(!t)return null;let n=Fi.find(([s])=>s.test(e))?.[1];return t.find(s=>!n||n.test(s))??null}function Ui(e){let t={id:"hardcoded",title:"Hard-coded values",description:`Raw colors, and pixel sizes that exactly match a token, written into ${e.noun} styles instead of using the token.`},n=new Map,s=new Map;for(let[o,i]of e.tokenValues){let a=Yt(i,e.tokenValues).trim();if(new RegExp(`^(?:${Hs.source})$`,"i").test(a)){let l=Ks(a);n.set(l,[...n.get(l)??[],o])}else/^\d+(?:\.\d+)?px$/.test(a)&&s.set(a,[...s.get(a)??[],o])}if(n.size===0&&s.size===0)return he(t,"No color or size tokens were found to compare against.");let r=[];for(let o of e.variants){let i=[],a=null;for(let c of o.states)for(let u of c.declarations){if(u.via)continue;let f=u.value.replace(Di," ");for(let m of f.matchAll(Hs)){let b=n.get(Ks(m[0]));i.push(b?`${m[0]} in ${u.property} is the value of ${b[0]}`:`${m[0]} in ${u.property} is not a token`),a??=c}if(Ti.test(u.property))for(let m of f.matchAll(Vi)){let b=Bi(u.property,s.get(`${m[1]}px`));!b||Number(m[1])<=1||(i.push(`${m[1]}px in ${u.property} is the value of ${b}`),a??=c)}}if(i.length===0||!a)continue;let l=[...new Set(i)];r.push({severity:"issue",message:`${o.title}: ${l.slice(0,4).join("; ")}${l.length>4?`; and ${l.length-4} more`:""}.`,styles:[o.title],refs:[q(o.path,a.line)]})}return Y(t,r,`No ${e.noun} style hard-codes a value a token already has.`,o=>`${o} style${o===1?"":"s"} hard-code values.`)}function zi(e){let t={id:"unused",title:"Unused styles",description:"Styles defined in CSS that no component, page, or template references."},n=e.variants.filter(r=>r.element&&r.usage.status!=="unknown");if(n.length===0)return he(t,"No styles with a class name to look for.");let s=[];for(let r of n)r.usage.status==="unreferenced"?s.push({severity:"issue",message:`${r.title} (${r.selector}) is defined but no reference to it was found.`,styles:[r.title],refs:[q(r.path,r.line)]}):r.usage.status==="dynamic"&&s.push({severity:"note",message:`${r.title} (${r.selector}) is built at runtime and nothing selects it by value.`,styles:[r.title],refs:[q(r.path,r.line),...r.usage.files.slice(0,2)]});return s.sort((r,o)=>+(o.severity==="issue")-+(r.severity==="issue")),Y(t,s,`All ${n.length} styles are referenced.`,r=>`${r} style${r===1?"":"s"} unreferenced or unconfirmed.`)}function Wi(e){let t={id:"duplicates",title:"Duplicate styles",description:"Different styles whose default declarations are identical."},n=new Map;for(let r of e.variants){if(!r.element)continue;let o=r.states.filter(a=>a.state==="default"&&a.context==="").flatMap(a=>a.declarations).map(a=>`${a.property}:${a.value.replace(/\s+/g," ").trim()}`);if(o.length<2)continue;let i=[...new Set(o)].sort().join(";");n.set(i,[...n.get(i)??[],r])}let s=[...n.values()].filter(r=>r.length>1).map(r=>({severity:"issue",message:`${r.map(o=>o.title).join(", ")} declare the same default styles (${r.map(o=>o.selector).join(", ")}).`,styles:r.map(o=>o.title),refs:r.map(o=>q(o.path,o.line))}));return Y(t,s,"No two styles share the same default declarations.",r=>`${r} group${r===1?"":"s"} of identical styles.`)}function Gi(e){let t={id:"native",title:`Native <${e.element}> instead of the component`,description:`Files that render a raw <${e.element}> although the repository has a shared ${e.element} component.`};if(!e.hasComponent)return he(t,`No shared ${e.element} component was found, so native elements are expected.`);let n=e.nativeUses.map(s=>({severity:"issue",message:`${s.count} native <${e.element}> element${s.count===1?"":"s"} in ${s.path}.`,refs:[q(s.path,s.line)]}));return Y(t,n,`Every <${e.element}> goes through the component.`,s=>`${s} file${s===1?"":"s"} bypass the component.`)}function Hi(e){let t={id:"props",title:"Prop values with no look",description:`Calls to a ${e.element} component with a literal prop value the component has no style for.`};if(!e.hasComponent)return he(t,`No shared ${e.element} component was found.`);let n=(e.unknownProps??[]).map(s=>({severity:"issue",message:`<${s.component} ${s.prop}="${s.value}"> in ${s.path}: ${s.component} has no ${s.prop} "${s.value}" (it has ${s.known.join(", ")}).`,refs:[q(s.path,s.line)]}));return Y(t,n,"Every literal prop value picks a look the component has.",s=>`${s} call${s===1?"":"s"} ask for a look the component does not have.`)}function Ki(e){let t={id:"undocumented",title:"Styles without written guidance",description:"Styles that no instruction file or doc names, so nothing written says how they should be used."},{guidance:n}=e;if(n.files.length===0)return{...t,status:"attention",summary:`Nothing in the repository mentions ${e.noun}.`,findings:[{severity:"note",message:`No instruction file or doc says how ${e.noun} should look or be built.`,refs:[]}]};if(n.undocumented.length===0)return Y(t,[],"Every style is named in written guidance.",()=>"");let s=e.variants.filter(r=>r.element&&n.undocumented.includes(r.title));return Y(t,[{severity:"note",message:`${n.undocumented.length} of ${n.documented.length+n.undocumented.length} styles are named in no guidance.`,styles:n.undocumented,refs:s.slice(0,6).map(r=>q(r.path,r.line))}],"",r=>`${r} finding${r===1?"":"s"}.`)}function Xs(e){return[Pi(e),Oi(e),zi(e),Wi(e),Ni(e),Ui(e),Gi(e),Hi(e),Ki(e)]}var Ji=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,qs=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,Zi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Xi=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),qi=new Set(["classNames","classnames","clsx","cn","cx"]),Yi=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function er(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
36
+ `&&n++;return n}function Ys(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function tr(e){let t=e.filter(s=>s.trim()).map(s=>/^ */.exec(s)?.[0].length??0),n=t.length?Math.min(...t):0;return e.map(s=>{let r=s.slice(n);return r.length>200?`${r.slice(0,200)}\u2026`:r}).join(`
37
+ `)}function Qi(e,t,n){let s=Math.max(0,Math.min(t,e.length)),r=Math.max(s,Math.min(n,e.length)),o=er(e,s),i=e.slice(s,r).split(`
38
+ `).slice(0,12),a=e.slice(s,r).split(`
39
39
  `).length>12;return{source:tr(i)+(a?`
40
- \u2026`:""),startLine:o}}function Ji(t,e){let n=Qs(t,Math.max(0,e)),s=t.split(`
41
- `),r=Math.max(0,n-1);return{source:tr(s.slice(r,r+12)),startLine:r+1}}function Ys(t,e){return{kind:"other",...Ji(t,e)}}function fe(t,e){let n=Xs.exec(t.slice(e));if(!n)return null;let s=n[1],r=n[2]??"",o=e+n[0].length;if(/\/\s*$/.test(r)||zi.has(s.toLowerCase()))return{tag:s,attrs:r,openStart:e,openEnd:o,closeEnd:o,body:""};let a=1,l=o,c=Math.min(t.length,e+4e3);for(;l<c;){if(t[l]!=="<"){l++;continue}if(t.startsWith("</",l)){let f=/^<\/([A-Za-z][\w.-]*)\s*>/.exec(t.slice(l));if(f&&f[1].toLowerCase()===s.toLowerCase()){if(a--,a===0){let m=l+f[0].length;return{tag:s,attrs:r,openStart:e,openEnd:o,closeEnd:m,body:t.slice(o,l)}}l+=f?f[0].length:2;continue}l+=f?f[0].length:2;continue}let u=Xs.exec(t.slice(l));if(u&&u[1].toLowerCase()===s.toLowerCase()&&!/\/\s*$/.test(u[2]??"")&&(a++,a>6))return"too-big";l+=u?u[0].length:1}return l>=c&&o+(c-e)>=4e3?"too-big":null}function tn(t,e){let n=Math.max(0,e-8e3),s=Math.min(e,t.length-1);for(;s>=n;){let r=t.lastIndexOf("<",s);if(r<n)return null;if(t[r+1]==="/"||t[r+1]==="!"||t[r+1]==="?"){s=r-1;continue}let o=fe(t,r);if(o==="too-big")return"too-big";if(o&&e>=o.openStart&&e<o.closeEnd)return o;s=r-1}return null}function er(t){return t.replace(/([a-z\d])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function At(t){return t.split(/\s+/).filter(Boolean)}function at(t,e){let n=t[e];if(n!=='"'&&n!=="'"&&n!=="`")return null;let s="";for(let r=e+1;r<t.length;r++){let o=t[r];if(o==="\\"){s+=t[r+1]??"",r++;continue}if(n==="`"&&o==="$"&&t[r+1]==="{")return null;if(o===n)return{value:s,end:r+1};s+=o}return null}function nr(t){let e=[],n="",s=0,r=null;for(let o=0;o<t.length;o++){let i=t[o];if(r){if(n+=i,i==="\\"){n+=t[o+1]??"",o++;continue}i===r&&(r=null);continue}if(i==='"'||i==="'"||i==="`"){r=i,n+=i;continue}if(i==="("||i==="["||i==="{")s++;else if(i===")"||i==="]"||i==="}")s=Math.max(0,s-1);else if(i===","&&s===0){n.trim()&&e.push(n.trim()),n="";continue}n+=i}return n.trim()&&e.push(n.trim()),e}function ue(t=new Map,e=new Map){return{values:t,aliases:e,flags:new Set,strings:new Set,prefixes:new Map}}var Qe=/^[A-Za-z_$][\w$]*$/;function en(t,e){let n=0,s=null;for(let r=0;r<t.length;r++){let o=t[r];if(s){o==="\\"?r++:o===s&&(s=null);continue}if(o==='"'||o==="'"||o==="`"){s=o;continue}if(o==="("||o==="["||o==="{")n++;else if(o===")"||o==="]"||o==="}")n--;else if(n===0&&t.startsWith(e,r))return r}return-1}function nn(t){let e=t.trim();for(;e.startsWith("(")&&e.endsWith(")");){let n=0,s=!0;for(let r=0;r<e.length-1&&s;r++)e[r]==="("?n++:e[r]===")"&&n--,n===0&&(s=!1);if(!s)break;e=e.slice(1,-1).trim()}return e}function sr(t,e,n){if(t==="true")return!0;if(t==="false"||t==="undefined"||t==="null")return!1;let s=e.aliases.get(t);return s!==void 0&&!e.values.has(t)?_t(s,e,n+1):(e.flags.add(t),!!e.values.get(t))}function _t(t,e,n=0){if(n>4)return null;let s=nn(t);for(let c of["||","&&"]){let u=en(s,c);if(u<0)continue;let f=_t(s.slice(0,u),e,n+1),m=_t(s.slice(u+2),e,n+1);return f===null||m===null?null:c==="||"?f||m:f&&m}let r=/^(!\s*)?([A-Za-z_$][\w$]*)$/.exec(s);if(r){let c=sr(r[2],e,n);return c===null?null:r[1]?!c:c}let o=/^([A-Za-z_$][\w$]*)\s*(===|==|!==|!=)\s*(["'])(.*?)\3$/.exec(s);if(!o)return null;let i=e.values.get(o[1]);typeof i=="string"&&e.strings.add(o[1]);let a=typeof i=="string"?i:"";return o[2]==="==="||o[2]==="=="?a===o[4]:a!==o[4]}function rr(t){let e=0,n=null,s=-1;for(let r=0;r<t.length;r++){let o=t[r];if(n){o==="\\"?r++:o===n&&(n=null);continue}if(o==='"'||o==="'"||o==="`"){n=o;continue}if(o==="("||o==="["||o==="{")e++;else if(o===")"||o==="]"||o==="}")e--;else if(o==="?"&&e===0){s=r;break}}if(s<0)return null;e=0,n=null;for(let r=s+1;r<t.length;r++){let o=t[r];if(n){o==="\\"?r++:o===n&&(n=null);continue}if(o==='"'||o==="'"||o==="`"){n=o;continue}if(o==="("||o==="["||o==="{")e++;else if(o===")"||o==="]"||o==="}")e--;else if(o===":"&&e===0)return{condition:t.slice(0,s),yes:t.slice(s+1,r),no:t.slice(r+1)}}return null}function Rt(t,e=ue()){let n=nn(t);if(!n)return{classes:[],dynamic:!1};let s=rr(n);if(s){let c=_t(s.condition,e);return c===null?{classes:[],dynamic:!0}:Rt(c?s.yes:s.no,e)}let r=en(n,"&&");if(r>=0){let c=_t(n.slice(0,r),e);return c===null?{classes:[],dynamic:!0}:c?Rt(n.slice(r+2),e):{classes:[],dynamic:!1}}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))return{classes:At(n.slice(1,-1)),dynamic:!1};if(n.startsWith("`")&&n.endsWith("`")){let c=n.slice(1,-1),u="",f=0;for(;f<c.length;){let m=c.indexOf("${",f);if(m<0){u+=c.slice(f);break}u+=c.slice(f,m);let b=c.indexOf("}",m+2);if(b<0)return{classes:[],dynamic:!0};let k=c.slice(m+2,b).trim();if(Qe.test(k)){let C=e.values.get(k);if(typeof C!="string")return{classes:[],dynamic:!0};e.strings.add(k);let v=/[\w-]*$/.exec(u)?.[0];v&&e.prefixes.set(k,v),u+=C}else{let C=Rt(k,e);if(C.dynamic)return{classes:[],dynamic:!0};u+=C.classes.join(" ")}f=b+1}return{classes:At(u),dynamic:!1}}if(Qe.test(n)&&e.values.has(n)){let c=e.values.get(n);return typeof c!="string"?{classes:[],dynamic:!1}:(e.strings.add(n),{classes:At(c),dynamic:!1})}let o=/^(?:styles?|classes|css|cls)\.([A-Za-z_]\w*)$/.exec(n);if(o)return{classes:[er(o[1])],dynamic:!1};let i=/^(?:styles?|classes|css|cls)\[\s*["']([\w-]+)["']\s*\]$/.exec(n);if(i)return{classes:[i[1]],dynamic:!1};let a=/^(?:styles?|classes|css|cls)\[\s*(`[^`]*`)\s*\]$/.exec(n);if(a){let c=Rt(a[1],e);return c.dynamic||c.classes.length!==1?{classes:[],dynamic:!0}:c}let l=/^([A-Za-z_][\w]*)\s*\(([\s\S]*)\)$/.exec(n);if(l&&Gi.has(l[1])){let c=[];for(let u of nr(l[2])){let f=Rt(u,e);if(f.dynamic)return{classes:[],dynamic:!0};c.push(...f.classes)}return{classes:c,dynamic:!1}}return{classes:[],dynamic:!0}}function de(t){let e=[],n=!1,s=0;for(;s<t.length;){if(/\s/.test(t[s])){s++;continue}if(t[s]==="{"){let i=0,a=s;for(let l=s;l<t.length;l++)if(t[l]==="{")i++;else if(t[l]==="}"&&(i--,i===0)){s=l+1;break}s===a&&(s=t.length),/^\{\s*\.\.\./.test(t.slice(a))&&(n=!0);continue}let r=/^([A-Za-z_:][\w:.-]*)/.exec(t.slice(s));if(!r){s++;continue}for(s+=r[0].length;s<t.length&&/\s/.test(t[s]);)s++;if(t[s]!=="="){e.push({name:r[1]});continue}for(s++;s<t.length&&/\s/.test(t[s]);)s++;let o=at(t,s);if(o){e.push({name:r[1],value:o.value}),s=o.end;continue}if(t[s]==="{"){let i=0,a=s;for(let u=s;u<t.length;u++)if(t[u]==="{")i++;else if(t[u]==="}"&&(i--,i===0)){s=u+1;break}s===a&&(s=t.length);let l=t.slice(a+1,s-1).trim(),c=at(l,0);c&&c.end===l.length?e.push({name:r[1],value:c.value}):e.push({name:r[1],expr:l});continue}s++}return{list:e,spread:n}}function sn(t,e){let n=de(t).list.find(s=>s.name==="class"||s.name==="className");return n?n.value!==void 0?{classes:At(n.value),dynamic:!1}:n.expr===void 0?{classes:[],dynamic:!0}:Rt(n.expr,e):null}function or(t,e){return/[<>]/.test(e)?!1:t==="href"||t==="src"||t==="action"?/^(?:https?:|mailto:|\/|#)/i.test(e):!0}function Zi(t){return t==="class"||t==="className"?!1:!Hi.test(t)&&!/^on/i.test(t)}function ir(t){let e={};for(let n of de(t).list){if(!Zi(n.name)||n.expr!==void 0)continue;let s=n.value??"";or(n.name,s)&&(e[n.name]=s)}return e}var Xi=/^(?:data-[\w-]+|aria-[\w-]+|disabled|hidden)$/,qi=new Set(["disabled","hidden"]);function ce(t,e,n=0){if(n>4)return null;let s=nn(t),r=at(s,0);if(r&&r.end===s.length)return r.value;let o=rr(s);if(o){let l=_t(o.condition,e);return l===null?null:ce(l?o.yes:o.no,e,n+1)}let i=en(s,"||");if(i>=0){let l=ce(s.slice(0,i),e,n+1);return l===null?null:l!==void 0?l:ce(s.slice(i+2),e,n+1)}if(s==="undefined"||s==="null"||s==="false")return;if(s==="true")return"true";if(!Qe.test(s))return null;let a=e.values.get(s);if(typeof a=="string")return e.strings.add(s),a;if(typeof a=="boolean"||e.aliases.has(s)){let l=sr(s,e,n);return l===null?null:l?"true":void 0}return e.values.has(s)?void 0:null}function Yi(t,e){let n={};for(let s of de(t).list){if(s.expr===void 0||!Xi.test(s.name))continue;let r=ce(s.expr,e);if(r!=null){if(qi.has(s.name)){r!=="false"&&(n[s.name]="");continue}or(s.name,r)&&(n[s.name]=r)}}return n}function Qi(t,e){let n=/([A-Za-z_][\w-]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*["']([^"']*)["']\s*\})/g;for(let s of t.matchAll(n)){let r=s.index??0;if(e>=r&&e<r+s[0].length){let o=s[1];return o==="class"||o==="className"?{}:{prop:o,value:s[2]??s[3]??s[4]}}}return{}}function pe(t,e=0){if(e>6)return"";let n="",s=0;for(;s<t.length;){if(t[s]==="{"){let i=0,a=s;for(let u=s;u<t.length;u++)if(t[u]==="{")i++;else if(t[u]==="}"&&(i--,i===0)){a=u+1;break}if(a===s)break;let l=t.slice(s+1,a-1).trim();/^[A-Za-z_$][\w$]*$/.exec(l)?.[0]&&(n+='<span class="__gs-slot">Text</span>'),s=a;continue}if(t[s]==="<"){if(t.startsWith("<!--",s)){let l=t.indexOf("-->",s);s=l===-1?t.length:l+3;continue}if(t.startsWith("</",s)){let l=/^<\/[A-Za-z][\w.-]*\s*>/.exec(t.slice(s));s+=l?l[0].length:1;continue}let i=fe(t,s);if(!i||i==="too-big"){s++;continue}let a=i.tag.toLowerCase();if(/^[A-Z]/.test(i.tag))n+=pe(i.body,e+1);else if(Wi.has(a)){let l=sn(i.attrs),c=l&&!l.dynamic&&l.classes.length?` class="${qs(l.classes.join(" "))}"`:"",u=pe(i.body,e+1);n+=`<${a}${c}>${u}</${a}>`}s=i.closeEnd;continue}let r=t.slice(s).search(/[<{}]/),o=r===-1?t.length:s+r;n+=qs(t.slice(s,o)),s=o}return n}function ta(t){let e=sn(t.attrs);return!e||e.dynamic||e.classes.length===0?null:{tag:t.tag.toLowerCase(),classes:e.classes,attrs:ir(t.attrs)}}function ar(t,e){let n=[],s=e-1;for(;n.length<3&&s>=0;){let r=tn(t,s);if(!r||r==="too-big"||/^[A-Z]/.test(r.tag))break;let o=ta(r);if(!o)break;n.push(o),s=r.openStart-1}return n.reverse()}var ea=8;function na(t){let e=t.trim(),n=at(e,0);return n&&n.end===e.length?n.value:e==="true"?!0:e==="false"?!1:/^-?\d+(?:\.\d+)?$/.test(e)?e:null}function sa(t,e){let n=0,s=-1;for(let i=e;i<t.length&&i<e+2e3;i++){let a=t[i];if(a==='"'||a==="'"||a==="`"){let l=at(t,i);if(!l)return null;i=l.end-1;continue}if(a==="{")n++;else if(a==="}"&&(n--,n===0)){s=i;break}}if(s<0)return null;let r=t.slice(s+1).trimStart()[0];if(r!==")"&&r!==":")return null;let o=new Map;for(let i of nr(t.slice(e+1,s))){if(i.startsWith("..."))continue;let a=/^([A-Za-z_$][\w$]*)(?:\s*:\s*([A-Za-z_$][\w$]*))?(?:\s*=\s*([\s\S]+))?$/.exec(i);if(!a)continue;let l=a[2]??a[1];if(a[3]===void 0){o.set(l,void 0);continue}let c=na(a[3]);c!==null&&o.set(l,c)}return{values:o,end:s}}function ra(t,e){let n=new Set(e.attrs.match(/[A-Za-z_$][\w$]*/g)??[]),s=Math.max(0,e.openStart-8e3),o=[...t.slice(s,e.openStart).matchAll(/\(\s*\{/g)].reverse();for(let i of o){let a=s+(i.index??0)+i[0].length-1,l=sa(t,a);if(!l||![...l.values.keys()].some(f=>n.has(f)))continue;let c=new Map,u=t.slice(l.end,e.openStart);for(let f of u.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;\n]+);/g))n.has(f[1])&&c.set(f[1],f[2].trim());return ue(l.values,c)}return ue()}function oa(t,e){let n=new Map;for(let s of t.matchAll(/([\w-]+)\$\{\s*([A-Za-z_$][\w$]*)\s*\}/g)){let r=s[1],o=e.find(i=>i.startsWith(r)&&i.length>r.length);o&&n.set(s[2],o.slice(r.length))}return n}function ia(t,e,n,s){let r=Ki(t,e.openStart,e.closeEnd);if(/^[A-Z]/.test(e.tag)){let m=Qi(t.slice(e.openStart,e.openEnd),n-e.openStart);return{kind:"component",...r,component:{tag:e.tag,...m}}}let o=ra(t,e);for(let[m,b]of oa(e.attrs,s))o.values.set(m,b);let i={};for(let[m,b]of o.values)i[m]=b??null;let a={attrs:e.attrs,values:i,aliases:Object.fromEntries(o.aliases)},l=ue(new Map(o.values),o.aliases),c=aa(a.attrs,l);if(!c)return{kind:"dynamic",...r};let u={tag:e.tag.toLowerCase(),...c,ancestors:ar(t,e.openStart),bodyHtml:pe(e.body)},f=[...[...l.strings].filter(m=>typeof o.values.get(m)=="string").map(m=>({name:m,kind:"text",...l.prefixes.has(m)?{prefix:l.prefixes.get(m)}:{}})),...[...l.flags].slice(0,ea).map(m=>({name:m,kind:"flag"}))];return f.length===0?{kind:"markup",...r,element:u}:{kind:"markup",...r,element:u,params:f,redraw:a}}function aa(t,e){let n=sn(t,e);return n?.dynamic?null:{classes:n?.classes??[],attrs:{...ir(t),...Yi(t,e)}}}function rn(t,e,n,s){if(Ui.test(s))return Ys(t,e);let r=tn(t,e);return r==="too-big"||!r?Ys(t,e):ia(t,r,e,n)}function la(t){let e={},n=new Set,{list:s,spread:r}=de(t);for(let o of s)o.expr===void 0?e[o.name]=o.value??"true":o.expr==="true"||o.expr==="false"?e[o.name]=o.expr:n.add(o.name);return{literals:e,dynamic:n,spread:r}}function lr(t,e){let n=la(e),s=new Map,r=[],o=[],i=[],a=n.spread;for(let l of t.axes){if(l.opaque){a=!0;continue}if(!l.locked&&n.dynamic.has(l.prop)){a=!0;continue}let c=l.locked?l.defaultValue:n.literals[l.prop]??(n.spread?void 0:l.defaultValue);if(c===void 0)continue;s.set(l.prop,c);let u=!l.locked&&n.literals[l.prop]===c;if(l.prefix){o.push(`${l.prefix}${c}`),u&&c!==l.defaultValue&&i.push({prop:l.prop,value:c,known:l.defaultValue?[l.defaultValue]:[],cls:`${l.prefix}${c}`});continue}let f=l.values.find(m=>m.value===c);if(!f){a=!0,u&&l.values.length>0&&i.push({prop:l.prop,value:c,known:l.values.map(m=>m.value)});continue}for(let m of f.classes)m.startsWith("__gs-recipe-")&&r.push(m),o.push(m)}if(!a){for(let l of t.compounds)if(l.when.every(u=>s.get(u.prop)===u.value))for(let u of l.classes)u.startsWith("__gs-recipe-")&&r.push(u),o.push(u)}return t.classNameProp&&(n.dynamic.has("className")?a=!0:n.literals.className&&o.push(...At(n.literals.className))),{draw:a?null:[...t.staticClasses,...o],selects:r,unknown:i}}function on(t){let e=[],n=/import\s*\{([^}]+)\}\s*from\s*["']([^"']+)["']/g;for(let s of t.matchAll(n)){let r=s[2];for(let o of s[1].split(",")){let i=o.trim().split(/\s+as\s+/),a=i[0]?.trim(),l=(i[1]??i[0])?.trim();a&&l&&e.push({local:l,imported:a,spec:r})}}return e}function ca(t,e,n,s,r){for(let o of on(e)){if(o.local!==n)continue;let i=r(t,o.spec),a=s.find(l=>l.path===i&&l.component===o.imported);if(a)return a}return s.find(o=>o.path===t&&o.component===n)}function cr(t,e,n,s,r,o){if(t.kind!=="component"||!t.component||r.length===0)return t;let i=ca(s,e,t.component.tag,r,o);if(!i)return t;let a=tn(e,n),l=t.component.tag;if(!a||a==="too-big"||a.tag!==l&&a.tag!==i.component)return t;let c=lr(i,a.attrs);return c.draw?{kind:"markup",source:t.source,startLine:t.startLine,component:t.component,element:{tag:i.rootTag,classes:c.draw,attrs:{},ancestors:ar(e,a.openStart),bodyHtml:pe(a.body)}}:t}function ge(t,e,n,s){let r=[],o=new Set,i=(l,c)=>{let u=`${l}\0${c.path}`;o.has(u)||(o.add(u),r.push({local:l,binding:c}))};for(let l of on(e)){let c=s(t,l.spec),u=n.find(f=>f.path===c&&f.component===l.imported);u&&i(l.local,u)}for(let l of n)l.path===t&&i(l.component,l);let a=[];for(let{local:l,binding:c}of r){let u=0,f=`<${l}`;for(;u<e.length;){let m=e.indexOf(f,u);if(m<0)break;let b=e[m+f.length];if(b&&/[\w.]/.test(b)){u=m+f.length;continue}let k=fe(e,m);if(!k||k==="too-big"){u=m+f.length;continue}let C=lr(c,k.attrs);(C.selects.length||C.unknown.length)&&a.push({offset:m,component:l,selects:C.selects,unknown:C.unknown}),u=Math.max(k.closeEnd,m+f.length)}}return a}function ua(t,e){let n=t.slice(e,e+700),s=n.indexOf("{");if(s<0)return{};let r=n.indexOf("}",s),o=n.slice(s,r<0?s+400:r+1),i={};for(let a of o.matchAll(/([A-Za-z_$][\w$]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))i[a[1]]=a[2]??a[3]??"";return i}function pa(t){let e=/\bclassName\s*=\s*/.exec(t);if(!e)return null;let n=e.index+e[0].length,s=at(t,n);if(s)return s.value;if(t[n]!=="{")return null;let r=0;for(let o=n;o<t.length;o++)if(t[o]==="{")r++;else if(t[o]==="}"&&(r--,r===0))return t.slice(n+1,o);return null}function fa(t,e){let n=e+1;for(;n<t.length&&/\s/.test(t[n]);)n++;if(t[n]===")")return{rename:{},fixed:{},opaque:[]};if(t[n]!=="{")return null;let s={rename:{},fixed:{},opaque:[]};for(n++;n<t.length;){for(;n<t.length&&/[\s,]/.test(t[n]);)n++;if(t[n]==="}")return s;if(t.startsWith("...",n))return null;let r=/^[A-Za-z_$][\w$]*/.exec(t.slice(n));if(!r)return null;for(n+=r[0].length;n<t.length&&/\s/.test(t[n]);)n++;if(t[n]===","||t[n]==="}"){s.rename[r[0]]=r[0];continue}if(t[n]!==":")return null;for(n++;n<t.length&&/\s/.test(t[n]);)n++;let o=at(t,n);if(o){s.fixed[r[0]]=o.value,n=o.end;continue}let i=/^[A-Za-z_$][\w$]*/.exec(t.slice(n));if(i){s.rename[r[0]]=i[0],n+=i[0].length;continue}s.opaque.push(r[0]);let a=0;for(;n<t.length;){let l=t[n];if(l==='"'||l==="'"||l==="`"){let c=at(t,n);if(!c)return null;n=c.end;continue}if(l==="("||l==="["||l==="{")a++;else if(l===")"||l==="]"||l==="}"){if(a===0)break;a--}else if(l===","&&a===0)break;n++}}return null}function da(t,e,n,s){let r=[];for(let o of on(t)){let i=s(e,o.spec),a=n.find(l=>l.path===i&&l.name===o.imported);a&&r.push({local:o.local,recipe:a})}for(let o of n)o.path===e&&o.name&&r.push({local:o.name,recipe:o});return r}function ga(t){let e=[],n=/(?:styles?|classes|css|cls)\s*\.\s*([A-Za-z_]\w*)/g;for(let c of t.matchAll(n))e.push({at:c.index??0,kind:"static",text:er(c[1])});let s=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\]/g;for(let c of t.matchAll(s))e.push({at:c.index??0,kind:"static",text:c[1]});let r=/(?:styles?|classes|css|cls)\s*\[\s*`([^`$]*)\$\{\s*([A-Za-z_$][\w$]*)\s*\}`\s*\]/g;for(let c of t.matchAll(r))e.push({at:c.index??0,kind:"prefix",text:c[1],prop:c[2]});let o=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\+\s*([A-Za-z_$][\w$]*)\s*\]/g;for(let c of t.matchAll(o))e.push({at:c.index??0,kind:"prefix",text:c[1],prop:c[2]});/[[{(]/.test(t)||e.push({at:0,kind:"static",text:t.trim()}),e.sort((c,u)=>c.at-u.at);let i=[],a=[];for(let c of e)c.kind==="prefix"&&c.prop?a.push({prop:c.prop,prefix:c.text}):i.push(...At(c.text));let l=/(?:^|[(,\s])className\s*(?:[,)]|$)/.test(t);return{staticClasses:i,prefixes:a,classNameProp:l}}function ma(t,e,n,s,r){let o=l=>e.rename[l]??l,i=t.axes.map(l=>{let c=e.fixed[l.prop],u=o(l.prop);return{prop:u,values:c?l.values.filter(f=>f.value===c):l.values,defaultValue:c??n[u]??l.defaultValue,opaque:e.opaque.includes(l.prop),locked:!!c}}),a=t.compounds.map(l=>({classes:l.classes,when:l.when.map(c=>({prop:o(c.prop),value:e.fixed[c.prop]??c.value}))}));return{staticClasses:[...t.staticClasses,...s],axes:i,compounds:a,classNameProp:r}}function ur(t,e,n){let s=[];for(let r of t){let o=da(r.source,r.path,e,n);for(let i of r.names){let a=new RegExp(`(?:function\\s+${i}\\b|(?:const|let|var)\\s+${i}\\b)`,"g"),l=[...r.source.matchAll(a)],c=null;for(let u of l){let f=u.index??0,b=r.source.slice(f+u[0].length).search(/\nexport\s/),k=r.source.slice(f,f+u[0].length+(b<0?8e3:b)),C=ua(r.source,f),v=0;for(;v<k.length;){if(k[v]!=="<"||k[v+1]==="/"||k[v+1]==="!"){v++;continue}let g=fe(k,v);if(!g||g==="too-big"){v++;continue}if(v=g.openEnd,/^[A-Z]/.test(g.tag))continue;let p=pa(g.attrs);if(!p)continue;let d=ga(p),y=d.prefixes.length?2:d.staticClasses.length?1:0,w=null,x=o.find($=>new RegExp(`(?:^|[^\\w$])${$.local}\\s*\\(`).test(p));if(x){let $=p.search(new RegExp(`(?:^|[^\\w$])${x.local}\\s*\\(`)),I=p.indexOf("(",$),j=I<0?null:fa(p,I);if(j){y=3,w=ma(x.recipe,j,C,d.staticClasses,d.classNameProp);for(let A of d.prefixes)w.axes.push({prop:A.prop,values:[],prefix:A.prefix,defaultValue:C[A.prop]})}}!w&&(d.prefixes.length||d.staticClasses.length)&&(w={staticClasses:d.staticClasses,axes:d.prefixes.map($=>({prop:$.prop,values:[],prefix:$.prefix,defaultValue:C[$.prop]})),compounds:[],classNameProp:d.classNameProp}),w&&(!c||y>c.score)&&(c={score:y,tag:g.tag.toLowerCase(),body:w})}}c&&s.push({component:i,path:r.path,rootTag:c.tag,...c.body})}}return s}var ha=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,ba=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,ya=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),xa=new Set(["icon","glyph","svg"]),ka=new Set(["label","text","title","caption"]),wa=t=>t.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(e=>e.toLowerCase());function fr(t){let e=t.flatMap(wa);return e.some(n=>xa.has(n))?"icon":e.some(n=>ka.has(n))?"label":null}function va(t){let e=t.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g," "),n=[];for(let s of e.matchAll(ha)){let r=s[1];if(!ya.has(r.toLowerCase())||r!==r.toLowerCase())continue;let o=[...s[2].matchAll(ba)].map(a=>a[1]??a[2]),i=fr(o);i&&n.push({index:s.index??0,role:i,tag:r.toLowerCase(),classes:o})}return n}function $a(t,e,n){if(!e.some(r=>r.property.toLowerCase()==="display"&&/^none\b/i.test(r.value.trim()))||n.size===0)return null;for(let r of z(t)){let o=X(r);if(!o||o.length<2)continue;let i=o[o.length-1];if(i.combinator!==" "&&i.combinator!==">")continue;let a=i.simples.filter(m=>m.kind==="class");if(a.length!==1||a[0].kind!=="class"||!n.has(a[0].name))continue;let l=o[o.length-2];if(l.simples.filter(m=>m.kind!=="class"&&m.kind!=="attr"&&m.kind!=="tag").length>0)continue;let u=l.simples.filter(m=>m.kind==="class"),f=l.simples.filter(m=>m.kind==="attr");if(u.length===1&&f.length===0&&u[0].kind==="class"&&!/^(?:is|has)-/.test(u[0].name))return{classes:[u[0].name],attrs:{}};if(u.length===0&&f.length===1&&f[0].kind==="attr"&&f[0].value)return{classes:[],attrs:{[f[0].name]:f[0].value}}}return null}var Ca=["text","icon-start","icon-end","icon"],pr={text:"Text","icon-start":"Icon left","icon-end":"Icon right",icon:"Icon"};function Sa(t,e){let n=null,s=null;for(let i of e)i.index<t.index?n=i:s||(s=i);if(!n&&!s)return null;let r=n?t.index-n.index:1/0;return(s?s.index-t.index:1/0)<=r?"start":"end"}function Et(t){return{role:t.role,tag:t.tag,classes:t.classes}}function dr(t){let e=new Map,n=(s,r)=>{let o=e.get(s)??[];o.some(i=>i.path===r.path)||o.push(r),e.set(s,o)};for(let s of t){let r=s.sources.flatMap(va),o=r.filter(b=>b.role==="label"),i=r.filter(b=>b.role==="icon"),a=o[0];a&&n("text",{path:s.sheet,slots:[Et(a)],classes:[],attrs:{}});let l=new Set(o.flatMap(b=>b.classes.filter(k=>fr([k])==="label"))),c=null,u=null;for(let b of i){let k=Sa(b,o),C=o.reduce((v,g)=>{let p=Math.abs(g.index-b.index);return!v||p<v.dist?{hit:g,dist:p}:v},null);k==="start"&&C&&!c&&(c={icon:b,label:C.hit}),k==="end"&&C&&!u&&(u={icon:b,label:C.hit})}c&&n("icon-start",{path:s.sheet,slots:[Et(c.icon),Et(c.label)],classes:[],attrs:{}}),u&&n("icon-end",{path:s.sheet,slots:[Et(u.label),Et(u.icon)],classes:[],attrs:{}});let f=null;for(let b of s.rules)if(f=$a(b.selector,b.declarations,l),f)break;let m=c?.icon??u?.icon??i[0]??null;f&&m&&n("icon",{path:s.sheet,slots:[Et(m)],classes:f.classes,attrs:f.attrs})}return[{id:"text",label:pr.text,sheets:e.get("text")??[]},...Ca.filter(s=>s!=="text"&&e.has(s)).map(s=>({id:s,label:pr[s],sheets:e.get(s)??[]}))]}function Ra(t,e){if(!t)return e;let n=z(t);return z(e).flatMap(s=>n.map(r=>s.includes("&")?s.replaceAll("&",r):`${r} ${s}`)).join(", ")}var Aa=/^@(?:-\w+-)?(?:keyframes|font-face|property)\b/i;function bt(t){let e=t.replace(/\/\*[\s\S]*?\*\//g,i=>i.replace(/[^\n]/g," ")),n=[],s=[],r=0,o=1;for(let i=0;i<e.length;i++){let a=e[i];if(a===`
42
- `&&o++,a==="{"){let l=e.slice(r,i).trim(),c=s[s.length-1];c&&(c.own+=e.slice(c.segStart,r));let u=/^@theme\b/i.test(l),f=l.startsWith("@")&&!u,m=[...s].reverse().find(b=>!b.isAt)??null;s.push({selector:l,resolved:f?l:u?":root":Ra(m?.resolved??null,l),isAt:f,skip:(c?.skip??!1)||f&&Aa.test(l),start:i+1,line:o,own:"",segStart:i+1}),r=i+1}else if(a==="}"){let l=s.pop();if(l){l.own+=e.slice(l.segStart,i),!l.isAt&&!l.skip&&n.push({selector:l.resolved,body:e.slice(l.start,i),ownBody:l.own,line:l.line,context:s.filter(u=>u.isAt).map(u=>u.selector.replace(/\s+/g," ")).join(" \xB7 ")});let c=s[s.length-1];c&&(c.segStart=i+1)}r=i+1}else a===";"&&(r=i+1)}return n}function lt(t){let e=[],n=0,s=0,r=o=>{let i=o.indexOf(":");if(i<=0)return;let a=o.slice(0,i).trim(),l=o.slice(i+1).replace(/\s+/g," ").trim();/^-{0,2}[a-z][\w-]*$/i.test(a)&&l&&a!=="composes"&&e.push({property:a,value:l})};for(let o=0;o<t.length;o++){let i=t[o];i==="("?n++:i===")"?n=Math.max(0,n-1):i===";"&&n===0&&(r(t.slice(s,o)),s=o+1)}return r(t.slice(s)),e}var _a=25,Ea=12,gr=700,ja=/\b(?:must(?: not)?|never|always|should(?: not|n't)?|do not|don't|avoid|prefer|forbidden|not allowed|no more than)\b/i,nt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Ia(t){let e=t.split(`
43
- `),n=[],s=[],r=null,o=null,i=0;if(e[0]?.trim()==="---"){let l=e.findIndex((c,u)=>u>0&&c.trim()==="---");l>0&&(i=l+1)}let a=l=>{r&&(n.push({start:r.start,end:l,text:r.lines.join(`
44
- `).trimEnd(),headings:r.headings}),r=null)};for(;i<e.length;i++){let l=e[i],c=i+1,u=/^\s*(```|~~~)/.exec(l)?.[1];if(o){r.lines.push(l),u===o&&(o=null,a(c));continue}if(u){a(c-1),o=u,r={start:c,lines:[l],headings:[...s]};continue}let f=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(l);if(f){a(c-1),s=[...s.slice(0,f[1].length-1),f[2]];continue}if(l.trim()===""){a(c-1);continue}r??={start:c,lines:[],headings:[...s]},r.lines.push(l)}return a(e.length),n}function La(t,e){let n=t.map(nt).join("|"),s=t.map(r=>nt(r.charAt(0).toUpperCase()+r.slice(1))).join("|");return new RegExp(`${e.source}|\\b(?:${n})s?\\b|[a-z](?:${s})s?\\b|\\b(?:${n})[-_]|[-_](?:${n})\\b`,"i")}function Ma(t,e){let n=e.map(nt).join("|"),s=new Map;for(let r of t){if(r.base||r.title==="Unnamed"||r.title.startsWith("In ")||!r.element)continue;let i=s.get(r.title)??{title:r.title,tests:[],heading:null},a=r.selector.slice(mt(r.selector));for(let l of a.matchAll(/\.((?:\\.|[\w-])+)/g)){let c=l[1].replace(/\\(.)/g,"$1");if(e.includes(c.toLowerCase()))continue;let u=/[-_]|[a-z][A-Z]/.test(c);i.tests.push(new RegExp(u?`(?<![\\w-])${nt(c)}(?![\\w-])`:`(?:\\.|["'\`])${nt(c)}(?![\\w-])`))}if(!r.title.includes(" + ")){let l=r.title.toLowerCase().split(/\s+/).map(nt).join("[\\s_-]+");i.tests.push(new RegExp(`\\b${l}[\\s_-]+(?:${n})s?\\b|\\b(?:${n})s?[_-]+${l}\\b`,"i")),r.axis&&/^[a-z]+$/i.test(r.title)&&i.tests.push(new RegExp(`\\b${nt(r.axis)}\\s*[=:]\\s*\\{?\\s*["'\`]${nt(r.title.toLowerCase())}["'\`]`,"i")),i.heading=r.title.toLowerCase()}s.set(r.title,i)}return[...s.values()]}function Pa(t,e){return t.toLowerCase().replace(new RegExp(`\\b(?:${e.map(nt).join("|")})s?\\b`,"g")," ").replace(/[^a-z0-9]+/g," ").trim()}function Oa(t){return t.length>gr?`${t.slice(0,gr).trimEnd()}\u2026`:t}function mr(t,e,n,s){let r=La(n.classKeywords,n.prose),o=Ma(s,n.classKeywords),i=new Set,a=[];for(let u of e){let f=t.get(u.path);if(f===void 0)continue;let m=[];for(let b of Ia(f)){if(!r.test(b.text)&&!b.headings.some(v=>r.test(v)))continue;let k=b.headings.length?Pa(b.headings[b.headings.length-1],n.classKeywords):"",C=o.filter(v=>v.tests.some(g=>g.test(b.text))||k!==""&&v.heading===k).map(v=>v.title);for(let v of C)i.add(v);m.push({path:u.path,line:b.start,endLine:b.end,headings:b.headings,text:Oa(b.text),rule:ja.test(b.text),styles:C})}m.length!==0&&a.push({path:u.path,kind:u.kind,passages:m.slice(0,Ea),total:m.length,rules:m.filter(b=>b.rule).length})}let l={instruction:0,documentation:1,record:2};a.sort((u,f)=>l[u.kind]-l[f.kind]||f.rules-u.rules||f.total-u.total||u.path.localeCompare(f.path));let c=new Map;for(let u of s)u.element&&!u.base&&u.title!=="Unnamed"&&!u.title.startsWith("In ")&&c.set(u.title,!0);return{files:a.slice(0,_a).map(({rules:u,...f})=>f),documented:[...i].sort(),undocumented:[...c.keys()].filter(u=>!i.has(u))}}var hr=new Set(["tone","size","variant","kind","type","style","theme","color","colour","appearance","intent","emphasis","shape","level"]),Da=new Set(["is","has","js","c","component","comp","el","ui","the","root"]),Ta={xs:["extra","small"],sm:["small"],md:["medium"],lg:["large"],xl:["extra","large"],xxl:["extra","extra","large"]},Na=new Set(["cta","ui","ux","faq","cms","api","url","ios"]);function ln(t){return t.replace(/\\(.)/g,"$1").replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(e=>e.toLowerCase())}function Va(t){return new Set(t.flatMap(e=>[e,`${e}s`]))}function an(t){let e=t.map(n=>Na.has(n)?n.toUpperCase():n).join(" ");return e.charAt(0).toUpperCase()+e.slice(1)}function jt(t,e){let n=ln(t).filter(r=>!e.has(r)&&!Da.has(r)),s=null;return n.length>1&&hr.has(n[0])&&(s=n[0],n=n.slice(1)),{words:n.flatMap(r=>Ta[r]??[r]),axis:s}}var br=/\.((?:\\.|[\w-])+)/g,Ba=/\[\s*([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*))\s*\]/g;function Fa(t,e){let n=t.split("/"),s=(n.pop()??"").replace(/(\.module)?\.[a-z]+$/i,""),r=n.pop()??"";return ln(s).some(a=>e.has(a))||ln(r).some(a=>e.has(a))?jt(s,e).words:[]}function Ua(t,e){let n=[];for(let s of t.split(/[\s>+~]+/).filter(Boolean)){let r=[...s.matchAll(br)].map(o=>o[1]);if(r.length)for(let o of r)n.push(...jt(o,e).words);else{let o=/^[a-z][\w-]*/i.exec(s)?.[0]?.toLowerCase();o&&!["div","span","html","body"].includes(o)&&n.push(...jt(o,e).words)}}return n}function It(t,e){let n=Va(e),s=mt(t.selector),r=t.selector.slice(0,s),o=t.selector.slice(s),i=[...o.matchAll(br)].map(u=>jt(u[1],n));for(let u of o.matchAll(Ba)){let f=u[1].replace(/^data-/,"").toLowerCase();if(!hr.has(f))continue;let m=u[2]??u[3]??u[4]??"",b=jt(m,n);i.push({words:b.words,axis:f})}let a=i.filter(u=>u.words.length>0);if(a.length>0)return{title:a.map(u=>an(u.words)).join(" + "),axis:a.length===1?a[0].axis:null};let l=Ua(r,n);if(l.length>0)return{title:`In ${l.join(" ")}`,axis:null};let c=Fa(t.path,n);if(c.length>0)return{title:an(c),axis:null};if(t.base){let u=za(t.path,n);return u.length>0?{title:`${an(u)} Base`,axis:null}:{title:"Base",axis:null}}return{title:"Unnamed",axis:null}}function za(t,e){let n=t.split("/").pop()??"";if(!/\.module\.[a-z]+$/i.test(n))return[];let s=n.replace(/\.module\.[a-z]+$/i,"");return jt(s,e).words}var Wa=60;function zt(t,e,n){let s=X(t);if(!s)return null;let r=s.length-1,o=s[r].simples;if(Ds(o)||Je(o,e))return null;if(oe(o,e))return{compounds:s,at:r};for(let i=r-1;i>=0;i--){let a=s[i].simples;if(oe(a,e)&&!Je(a,e))return{compounds:s,at:i}}return!n||r===0&&Ts(o)?null:{compounds:s,at:0}}function yr(t,e,n){return Ft([...t,{combinator:t.length?e.combinator:null,simples:n}])}function xr(t,e){return t.kind!==e.kind?!1:t.kind==="attr"&&e.kind==="attr"?t.name===e.name&&t.op===e.op&&t.value===e.value:t.raw===e.raw}function Ga(t,e){return t.length>=e.length?!1:t.every(n=>e.some(s=>xr(n,s)))}function Ha(t,e){if(t.length!==1)return!1;let n=t[0];return n.kind==="tag"?e.elements.includes(n.name):n.kind==="class"?e.classKeywords.some(s=>s.toLowerCase()===n.name.toLowerCase()):!1}function Ka(t,e){for(let n of e.classes)t.classes.includes(n)||t.classes.push(n);Object.assign(t.attrs,e.attrs)}function kr(t){let e=new Set(t.map(n=>Ut(n.property)).filter(n=>n!=="hint"));return e.size===0||e.size===1&&e.has("layout")?"placement":e.size===1&&e.has("paint")?"effect":"override"}function Ja(t){let e=t.filter(o=>o.context===""),n=e.length?e:t;if(n.some(o=>o.state==="default"))return null;let r=[...n.map(o=>new Set(o.state.split(" + "))).reduce((o,i)=>o?new Set([...o].filter(a=>i.has(a))):i,null)??[]].filter(o=>H(o)===re.length);return r.length===1?r[0]:null}function cn(t){return t.sort((e,n)=>+(e.context!=="")-+(n.context!=="")||H(e.state.split(" + ")[0])-H(n.state.split(" + ")[0])||e.state.localeCompare(n.state))}function wr(t,e,n,s,r={parts:new Set,controls:new Set}){let o=new Map,i=[];for(let g of e)if(g.declarations.length!==0)for(let p of z(g.selector)){let d=zt(p,n,s);if(!d)continue;let{compounds:y,at:w}=d,x=y[w],$=ie(x.simples);if($.identity.length===0)continue;let I=y.slice(0,w),j=yr(I,x,$.identity),A=gt($.states);if(w<y.length-1){i.push({hostKey:j,part:{selector:Ft(y),path:t,line:g.line,state:A}});continue}if(Vs($.identity,g.declarations))continue;let R=o.get(j);if(!R){if(o.size>=Wa)continue;R={key:j,prefix:I,identity:$.identity,line:g.line,states:[],modifiers:[],contexts:[],parts:[],movedInto:null},o.set(j,R)}let L=R.states.find(T=>T.state===A&&T.context===g.context);L||(L={state:A,context:g.context,line:g.line,declarations:[]},$.states.length&&(L.marker={classes:[],attrs:{}}),R.states.push(L)),L.marker&&Ka(L.marker,$.marker),L.declarations.push(...g.declarations)}for(let[g,p]of o){let d=p.states.flatMap(x=>x.declarations),y=p.states.every(x=>le(x.declarations)),w=d.every(x=>Ut(x.property)==="hint");(y||w)&&o.delete(g)}let a=new Map;for(let g of o.values()){let p=Bt(g.identity);a.set(p,[...a.get(p)??[],g])}for(let g of a.values()){let p=g.map(x=>Ja(x.states)),d=p[0];if(!d||p.some(x=>x!==d))continue;let y=g.flatMap(x=>x.states).find(x=>x.marker&&x.state.split(" + ").includes(d))?.marker;if(!y)continue;let w=[...y.classes.map(x=>({kind:"class",raw:`.${x}`,name:x})),...Object.entries(y.attrs).map(([x,$])=>({kind:"attr",raw:`[${x}="${$}"]`,name:x,op:"=",value:$}))];for(let x of g){let $=[...x.identity,...w],I={combinator:x.prefix.length?" ":null,simples:$},j=yr(x.prefix,I,$);for(let A of x.states){let R=A.state.split(" + ").filter(L=>L!==d);if(A.state=gt(R),R.length===0)delete A.marker;else if(A.marker){A.marker.classes=A.marker.classes.filter(L=>!y.classes.includes(L));for(let L of Object.keys(y.attrs))delete A.marker.attrs[L]}}o.delete(x.key),o.set(j,{...x,key:j,identity:$})}}let l=()=>[...o.values()].filter(g=>g.prefix.length===0),c=g=>g.states.filter(p=>p.state==="default").reduce((p,d)=>p+d.declarations.length,0),u=l().find(g=>Ha(g.identity,n))??(s?l().filter(g=>{let p=g.identity.length===1?g.identity[0]:null;return p?.kind==="class"&&r.controls.has(p.name)}).sort((g,p)=>c(p)-c(g)||g.line-p.line)[0]??null:null),f=u&&u.identity[0].kind==="class"?[u.identity[0].name]:[],m=(g,p,d)=>{p[d].push(g),g.movedInto=p,o.delete(g.key)},b=[...o.values()],k=g=>{let p=b.find(d=>d.key===g)??null;for(;p?.movedInto;)p=p.movedInto;return p};for(let g of l()){let p=g.identity.length===1?g.identity[0]:null;if(!(p?.kind!=="class"||!r.parts.has(p.name))&&(o.delete(g.key),u&&g!==u)){g.movedInto=u;for(let d of g.states)u.parts.push({selector:g.key,path:t,line:d.line,state:d.state})}}let C=l().filter(g=>g.identity.filter(p=>p.kind!=="tag"&&p.kind!=="universal").length>=2).sort((g,p)=>g.identity.length-p.identity.length);for(let g of C){let p=b.filter(y=>y!==g&&y!==u&&y.prefix.length===0&&Ga(y.identity,g.identity));if(p.length===0)continue;p.sort((y,w)=>w.identity.length-y.identity.length||c(w)-c(y)||y.line-w.line);let d=k(p[0].key);d&&d!==g&&m(g,d,"modifiers")}for(let{hostKey:g,part:p}of i){let d=k(g)??(s?u:null);d&&o.has(d.key)&&d.parts.push(p)}let v=g=>{let p=g===u,d=ae(g.key,f);return{...It({selector:g.key,path:t,base:p},n.classKeywords),element:d,usage:{status:"unknown",files:[],fileCount:0},selector:g.key,path:t,line:g.line,base:p,states:cn(g.states),modifiers:g.modifiers.length?g.modifiers.map(y=>{let w=y.identity.filter(x=>!g.identity.some($=>xr($,x)));return{title:It({selector:w.map(x=>x.raw).join(""),path:t,base:!1},n.classKeywords).title,selector:y.key,path:t,line:y.line,element:ae(y.key,f),usage:{status:"unknown",files:[],fileCount:0},states:cn(y.states)}}):void 0,contexts:g.contexts.length?g.contexts.map(y=>{let w=kr(y.states.flatMap(x=>x.declarations));return{selector:y.key,path:t,line:y.line,role:w,element:w==="override"?ae(y.key,f):null,states:cn(y.states)}}):void 0,parts:g.parts.length?g.parts:void 0}};return[...o.values()].map(v)}function vr(t){let e=new Map;for(let i of t){let a=i.base?/^\.([\w-]+)$/.exec(i.selector):null;a&&e.set(i.path,[...e.get(i.path)??[],a[1]])}let n=i=>{let a=X(i.selector);if(!a)return null;let l=a[a.length-1].simples,c=e.get(i.path)??[],u=l.filter(f=>!(f.kind==="class"&&c.includes(f.name)));return{depth:a.length-1,subject:Bt(l),bareTag:!l.some(f=>f.kind==="class"||f.kind==="attr"||f.kind==="id"),bare:u.length&&u.length<l.length?Bt(u):null}},s=new Map(t.map(i=>[i,n(i)])),r=new Set,o=i=>{let a=s.get(i);if(!a||a.depth===0)return null;let l=t.filter(c=>{if(c===i||r.has(c))return!1;let u=s.get(c);return u!=null&&u.depth<a.depth&&(!a.bareTag||u.depth===0)&&(u.subject===a.subject||a.bare!==null&&u.subject===a.bare)});return l.sort((c,u)=>+(u.path===i.path)-+(c.path===i.path)||s.get(c).depth-s.get(u).depth),l[0]??null};for(let i of[...t].sort((a,l)=>(s.get(l)?.depth??0)-(s.get(a)?.depth??0))){let a=o(i);if(!a)continue;for(;r.has(a);)a=o(a)??a;let l=kr(i.states.flatMap(c=>c.declarations));a.contexts=[...a.contexts??[],{selector:i.selector,path:i.path,line:i.line,role:l,element:l==="override"?i.element:null,states:i.states}],i.parts?.length&&(a.parts=[...a.parts??[],...i.parts]),i.modifiers?.length&&(a.modifiers=[...a.modifiers??[],...i.modifiers]),r.add(i)}return t.filter(i=>!r.has(i))}var Za={slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}};function $r(t){let e=t.lastIndexOf("-");return e<=0?null:Za[t.slice(0,e)]?.[t.slice(e+1)]??null}var E=(t,e)=>({property:t,value:e});function gn(t){if(!t.startsWith("[")||!t.endsWith("]"))return null;let e=t.slice(1,-1).replace(/_/g," ").trim();return/^-?[\d.]+(?:px|rem|em|%|vh|vw)$/.test(e)||/^var\(\s*--[\w-]+\s*\)$/.test(e)?e.replace(/\s+/g,""):null}function dn(t){let e=gn(t);if(e)return e;if(t==="px")return"1px";if(!/^\d+(?:\.\d+)?$/.test(t))return null;let n=Number(t);if(n>96)return null;let s=Math.round(n*2);if(Math.abs(n*2-s)>1e-6)return null;if(s===0)return"0";let r=Math.floor(s/8),o=["",".125",".25",".375",".5",".625",".75",".875"][s%8];return r===0?`0${o}rem`:`${r}${o}rem`}function Xa(t){let e=/^(\d+)\/(\d+)$/.exec(t);if(!e)return null;let n=Number(e[1])/Number(e[2])*100;return Number.isFinite(n)?`${Number(n.toFixed(4))}%`:null}function Cr(t,e){return{full:"100%",screen:e==="w"?"100vw":"100vh",auto:"auto",fit:"fit-content",min:"min-content",max:"max-content"}[t]??Xa(t)??gn(t)??dn(t)}var qa={xs:{size:"0.75rem",leading:"1rem"},sm:{size:"0.875rem",leading:"1.25rem"},base:{size:"1rem",leading:"1.5rem"},lg:{size:"1.125rem",leading:"1.75rem"},xl:{size:"1.25rem",leading:"1.75rem"},"2xl":{size:"1.5rem",leading:"2rem"},"3xl":{size:"1.875rem",leading:"2.25rem"},"4xl":{size:"2.25rem",leading:"2.5rem"},"5xl":{size:"3rem",leading:"1"},"6xl":{size:"3.75rem",leading:"1"}},Ya={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},Qa={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},tl={none:"0",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},el={sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)","":"0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",xl:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)","2xl":"0 25px 50px -12px rgb(0 0 0 / 0.25)",inner:"inset 0 2px 4px 0 rgb(0 0 0 / 0.05)",none:"none"},nl={"":"3px",0:"0px",1:"1px",2:"2px",4:"4px",8:"8px"};function un(t,e){let n=null;if(t.startsWith("[")&&t.endsWith("]")){let r=t.slice(1,-1).replace(/_/g," ").trim();if(r.startsWith("--"))n=`var(${r})`;else if(/^var\(\s*--[\w-]+\s*\)$/.test(r))n=r.replace(/\s+/g,"");else if(/^#[0-9a-f]{3,8}$/i.test(r)||/^(?:rgb|hsl|oklch|oklab|color)\(/i.test(r))n=r;else return null}else t==="white"?n="#fff":t==="black"?n="#000":t==="transparent"?n="transparent":t==="current"?n="currentColor":t==="inherit"?n="inherit":n=$r(t)??(/^[a-z][\w-]*$/i.test(t)?`var(--${t}, var(--color-${t}))`:null);if(!n)return null;if(!e)return n;if(!/^\d+(?:\.\d+)?$/.test(e))return null;let s=Number(e)<=1?Number(e)*100:Number(e);return s<0||s>100?null:s===100?n:`color-mix(in srgb, ${n} ${s}%, transparent)`}function sl(t){let e=0,n=-1;for(let s=0;s<t.length;s++){let r=t[s];r==="["?e++:r==="]"?e=Math.max(0,e-1):r==="/"&&e===0&&(n=s)}return n<0?{body:t,opacity:null}:{body:t.slice(0,n),opacity:t.slice(n+1)}}function pn(){return E("box-shadow","0 0 0 var(--gs-ring-w, 3px) var(--gs-ring-c, currentColor)")}var rl={flex:"flex","inline-flex":"inline-flex",block:"block","inline-block":"inline-block",inline:"inline",grid:"grid","inline-grid":"inline-grid",hidden:"none",contents:"contents"},fn={start:"flex-start",end:"flex-end",center:"center",baseline:"baseline",stretch:"stretch",between:"space-between",around:"space-around",evenly:"space-evenly"};function Sr(t){let e=t.startsWith("-"),n=e?t.slice(1):t,{body:s,opacity:r}=sl(n),o=rl[s];if(o&&!e&&!r)return[E("display",o)];let i=/^flex-(row|col|row-reverse|col-reverse)$/.exec(s);if(i&&!e&&!r){let R=i[1]==="col"?"column":i[1]==="col-reverse"?"column-reverse":i[1];return[E("flex-direction",R)]}if(s==="flex-wrap"&&!e)return[E("flex-wrap","wrap")];if(s==="flex-nowrap"&&!e)return[E("flex-wrap","nowrap")];if(s==="flex-1"&&!e)return[E("flex","1 1 0%")];if(s==="shrink-0"&&!e)return[E("flex-shrink","0")];if(s==="grow-0"&&!e)return[E("flex-grow","0")];if(s==="grow"&&!e)return[E("flex-grow","1")];let a=/^items-(start|end|center|baseline|stretch)$/.exec(s);if(a&&!e)return[E("align-items",fn[a[1]])];let l=/^justify-(start|end|center|between|around|evenly)$/.exec(s);if(l&&!e)return[E("justify-content",fn[l[1]])];let c=/^self-(start|end|center|stretch|auto)$/.exec(s);if(c&&!e)return[E("align-self",c[1]==="auto"?"auto":fn[c[1]])];if(s==="whitespace-nowrap")return[E("white-space","nowrap")];if(s==="whitespace-normal")return[E("white-space","normal")];if(s==="truncate")return[E("overflow","hidden"),E("text-overflow","ellipsis"),E("white-space","nowrap")];if(s==="underline")return[E("text-decoration-line","underline")];if(s==="no-underline")return[E("text-decoration-line","none")];if(s==="line-through")return[E("text-decoration-line","line-through")];let u=/^(uppercase|lowercase|capitalize|normal-case)$/.exec(s);if(u)return[E("text-transform",u[1]==="normal-case"?"none":u[1])];let f=/^text-(left|center|right|justify|start|end)$/.exec(s);if(f&&!r)return[E("text-align",f[1])];let m=qa[s.replace(/^text-/,"")];if(s.startsWith("text-")&&m&&!r&&!e)return[E("font-size",m.size),E("line-height",m.leading)];let b=Ya[s.replace(/^font-/,"")];if(s.startsWith("font-")&&b&&!r)return[E("font-weight",b)];if(s.startsWith("leading-")&&!r){let R=s.slice(8),T=Qa[R]??dn(R);if(T)return[E("line-height",T)]}let k=/^cursor-(pointer|default|not-allowed|wait|text|move)$/.exec(s);if(k)return[E("cursor",k[1])];if(s==="pointer-events-none")return[E("pointer-events","none")];if(s==="pointer-events-auto")return[E("pointer-events","auto")];if(s==="select-none")return[E("user-select","none")];let C=/^opacity-(\d+)$/.exec(s);if(C&&!e)return[E("opacity",String(Number(C[1])/100))];if(s==="transition"||s==="transition-colors"||s==="transition-all")return[E("transition-property",s==="transition-colors"?"color, background-color, border-color, text-decoration-color, fill, stroke":s==="transition-all"?"all":"color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter"),E("transition-timing-function","cubic-bezier(0.4, 0, 0.2, 1)"),E("transition-duration","150ms")];let v=/^duration-(\d+)$/.exec(s);if(v)return[E("transition-duration",`${v[1]}ms`)];let g={linear:"linear",in:"cubic-bezier(0.4, 0, 1, 1)",out:"cubic-bezier(0, 0, 0.2, 1)","in-out":"cubic-bezier(0.4, 0, 0.2, 1)"};if(s.startsWith("ease-")&&g[s.slice(4)])return[E("transition-timing-function",g[s.slice(4)])];if(s==="outline-none")return[E("outline","2px solid transparent"),E("outline-offset","2px")];if(s==="outline")return[E("outline-style","solid")];let p=/^outline-(\d+)$/.exec(s);if(p)return[E("outline-width",`${p[1]}px`)];if(s==="shadow"||s.startsWith("shadow-")){let R=s==="shadow"?"":s.slice(7),L=el[R];if(L)return[E("box-shadow",L)]}if(s==="ring"||/^ring(?:-(?:0|1|2|4|8))?$/.test(s)){let R=s==="ring"?"":s.slice(5),L=nl[R];if(L)return[E("--gs-ring-w",L),pn()]}if(s.startsWith("ring-")&&r===null){let R=un(s.slice(5),null);if(R)return[E("--gs-ring-c",R),pn()]}if(s.startsWith("ring-")&&r){let R=un(s.slice(5),r);if(R)return[E("--gs-ring-c",R),pn()]}let d=s==="rounded"?"":s.startsWith("rounded-")?s.slice(8):null;if(d!==null&&!e){let R=/^(t|r|b|l|s|e|tl|tr|bl|br|ss|se)(?:-(.+))?$/.exec(d),L=R?R[2]??"":d,T=tl[L];if(!T)return null;if(!R)return[E("border-radius",T)];let Z={t:["border-top-left-radius","border-top-right-radius"],r:["border-top-right-radius","border-bottom-right-radius"],b:["border-bottom-left-radius","border-bottom-right-radius"],l:["border-top-left-radius","border-bottom-left-radius"],s:["border-start-start-radius","border-end-start-radius"],e:["border-start-end-radius","border-end-end-radius"],tl:["border-top-left-radius"],tr:["border-top-right-radius"],bl:["border-bottom-left-radius"],br:["border-bottom-right-radius"],ss:["border-start-start-radius"],se:["border-start-end-radius"]}[R[1]];return Z?Z.map(Zt=>E(Zt,T)):null}if(/^border(?:-[trblxy])?$/.test(s)&&!r)return[E("border-width","1px"),E("border-style","solid")];let y=/^border-(\d+)$/.exec(s);if(y&&!r)return[E("border-width",`${y[1]}px`),E("border-style","solid")];let w=/^border-(solid|dashed|dotted|double|none|hidden)$/.exec(s);if(w)return[E("border-style",w[1])];let x=/^(p|px|py|pt|pr|pb|pl|ps|pe|m|mx|my|mt|mr|mb|ml|ms|me|gap|gap-x|gap-y|w|h|min-w|min-h|max-w|max-h|size|inset|top|right|bottom|left)-(.+)$/.exec(s),$=x?.[1],I=x?.[2];if($&&I&&!r){let R=$==="w"||$==="min-w"||$==="max-w"?Cr(I,"w"):$==="h"||$==="min-h"||$==="max-h"?Cr(I,"h"):dn(I);if(!R)return null;let L=e?R==="0"?"0":`-${R}`:R,G={p:["padding"],px:["padding-inline"],py:["padding-block"],pt:["padding-top"],pr:["padding-right"],pb:["padding-bottom"],pl:["padding-left"],ps:["padding-inline-start"],pe:["padding-inline-end"],m:["margin"],mx:["margin-inline"],my:["margin-block"],mt:["margin-top"],mr:["margin-right"],mb:["margin-bottom"],ml:["margin-left"],ms:["margin-inline-start"],me:["margin-inline-end"],gap:["gap"],"gap-x":["column-gap"],"gap-y":["row-gap"],w:["width"],h:["height"],"min-w":["min-width"],"min-h":["min-height"],"max-w":["max-width"],"max-h":["max-height"],size:["width","height"],inset:["inset"],top:["top"],right:["right"],bottom:["bottom"],left:["left"]}[$];return G?G.map(Z=>E(Z,L)):null}let j={bg:"background-color",text:"color",border:"border-color",outline:"outline-color",decoration:"text-decoration-color",accent:"accent-color",caret:"caret-color",fill:"fill",stroke:"stroke"};for(let[R,L]of Object.entries(j))if(s===R||s.startsWith(`${R}-`)){let T=s===R?"":s.slice(R.length+1);if(!T||/^(?:gradient|clip|ellipsis|wrap|nowrap|balance|pretty|opacity)/.test(T))return null;if(R==="text"&&!e){let Z=gn(T);if(Z)return[E("font-size",Z)]}let G=un(T,r);return!G||e?null:[E(L,G)]}let A=/^\[([a-z-]+):(.+)\]$/i.exec(s);if(A&&!e&&!r){let R=A[1].toLowerCase(),L=A[2].replace(/_/g," ").trim();if(/^[a-z][\w-]*$/.test(R)&&L&&!/[<>]/.test(L))return[E(R,L)]}return null}var ol=48,il={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",disabled:"disabled"},al=new Set(["cn","clsx","classNames","classnames","cx","twMerge"]);function ct(t,e){let n=1;for(let s=0;s<e&&s<t.length;s++)t[s]===`
45
- `&&n++;return n}function ll(t){let e=n=>n.replace(/[^\n]/g," ");return t.replace(/\/\*[\s\S]*?\*\//g,e).replace(/(^|\s)\/\/[^\n]*/g,(n,s)=>s+e(n.slice(s.length)))}function W(t,e){for(;e<t.length&&/\s/.test(t[e]);)e++;return e}function me(t,e){let n=t[e];if(n!=='"'&&n!=="'"&&n!=="`")return null;let s="",r=!1;for(let o=e+1;o<t.length;o++){let i=t[o];if(i==="\\"){let a=t[o+1];if(a===void 0)return null;s+=a==="n"?`
46
- `:a,o++;continue}if(n==="`"&&i==="$"&&t[o+1]==="{"){r=!0;let a=1;for(o+=2;o<t.length&&a>0;o++)t[o]==="{"?a++:t[o]==="}"&&a--;o--;continue}if(i===n)return{v:r?null:s,end:o+1};s+=i}return null}function bn(t,e,n,s){let r=0;for(let o=e;o<t.length;o++){let i=t[o];if(i==='"'||i==="'"||i==="`"){let a=me(t,o);if(!a)return t.length;o=a.end-1;continue}if(i===n)r++;else if(i===s&&(r--,r===0))return o+1}return t.length}function cl(t,e){let n=0;for(let s=e;s<t.length;s++){let r=t[s];if(r==='"'||r==="'"||r==="`"){let o=me(t,s);if(!o)return t.length;s=o.end-1;continue}if(r==="("||r==="["||r==="{")n++;else if(r===")"||r==="]"||r==="}"){if(n===0)return s;n--}else if(r===","&&n===0)return s}return t.length}function Rr(t){if(t.t==="str")return t.v;if(t.t==="arr"){let e=[];for(let n of t.items){let s=Rr(n);s&&e.push(s)}return e.join(" ")||null}return t.t==="obj"&&t.entries.filter(n=>n.value.t==="bool"&&n.value.v).map(n=>n.key).join(" ")||null}function ul(t,e){let n=e+1,s=[];for(;n<t.length;){if(n=W(t,n),t[n]===")")return{v:s.join(" ").replace(/\s+/g," ").trim()||null,end:n+1};if(t[n]===","){n++;continue}let r=Q(t,n);if(!r)return null;let o=W(t,r.end);if(t[o]===","||t[o]===")"){let i=Rr(r.val);i&&s.push(i),n=r.end;continue}n=cl(t,n)}return null}function Q(t,e){if(e=W(t,e),e>=t.length)return null;let n=t[e];if(n==='"'||n==="'"||n==="`"){let r=me(t,e);return r?{val:{t:"str",v:r.v,at:e},end:r.end}:null}if(n==="["){let r=e+1,o=[];for(;r<t.length;){if(r=W(t,r),t[r]==="]")return{val:{t:"arr",items:o,at:e},end:r+1};if(t[r]===","){r++;continue}let i=Q(t,r);if(!i)return null;o.push(i.val),r=i.end}return null}if(n==="{"){let r=e+1,o=[];for(;r<t.length;){if(r=W(t,r),t[r]==="}")return{val:{t:"obj",entries:o,at:e},end:r+1};if(t[r]===","){r++;continue}if(t.slice(r,r+3)==="..."){let c=Q(t,r+3);if(!c)return null;r=c.end;continue}let i="",a=r;if(t[r]==='"'||t[r]==="'"||t[r]==="`"){let c=me(t,r);if(!c||c.v===null)return null;i=c.v,r=c.end}else if(/[\w$]/.test(t[r])){for(a=r;r<t.length&&/[\w$]/.test(t[r]);)r++;i=t.slice(a,r)}else return null;if(r=W(t,r),t[r]!==":"){t[r]==="("&&(r=bn(t,r,"(",")"));continue}let l=Q(t,r+1);if(!l)return null;o.push({key:i,at:a,value:l.val}),r=l.end}return null}let s=e;if(n==="."||n==="-"||/\d/.test(n)){let r=e+1;for(;r<t.length&&/[\d.]/.test(t[r]);)r++;let o=t.slice(e,r);if(/^-?\d+(?:\.\d+)?$/.test(o))return{val:{t:"num",v:Number(o),at:s},end:r};for(;r<t.length&&/[\w$.+-]/.test(t[r]);)r++;return{val:{t:"other",at:s},end:r}}if(/[\w$]/.test(n)){let r=e;for(;r<t.length&&/[\w$]/.test(t[r]);)r++;let o=t.slice(e,r),i=W(t,r);if(t[i]==="("){if(al.has(o)){let a=ul(t,i);return a?{val:{t:"str",v:a.v,at:s},end:a.end}:null}return{val:{t:"other",at:s},end:bn(t,i,"(",")")}}return o==="true"||o==="false"?{val:{t:"bool",v:o==="true",at:s},end:r}:{val:{t:"other",at:s},end:i}}return null}function he(t){if(t.t==="str")return t.v;if(t.t==="arr"){let e=[];for(let n of t.items){if(n.t!=="str"||n.v===null)return null;e.push(n.v)}return e.join(" ")}return null}function Ar(t){let e=[],n="",s=0;for(let r of t)r==="["?s++:r==="]"&&(s=Math.max(0,s-1)),/\s/.test(r)&&s===0?(n&&e.push(n),n=""):(!/\s/.test(r)||s>0)&&(n+=r);return n&&e.push(n),e}var mn={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function pl(t,e,n,s){let r=il[t];if(r)return e.includes(r)||e.push(r),!0;if(t==="dark")return s.on=!0,!0;if(mn[t])return n.min.push(mn[t]),!0;let o=/^max-(sm|md|lg|xl|2xl)$/.exec(t);if(o)return n.below.push(mn[o[1]]),!0;let i=/^min-\[([\d.]+(?:px|rem|em))\]$/.exec(t);if(i)return n.min.push(i[1]),!0;let a=/^max-\[([\d.]+(?:px|rem|em))\]$/.exec(t);return a?(n.max.push(a[1]),!0):!1}function fl(t,e){let n=[];for(let s of t.min)n.push(`(min-width: ${s})`);for(let s of t.max)n.push(`(max-width: ${s})`);for(let s of t.below)n.push(`not all and (min-width: ${s})`);return e&&n.push("(prefers-color-scheme: dark)"),n.length?`@media ${n.join(" and ")}`:""}function _r(t){let e=t.trim();if(!e)return null;let n=!1;e.startsWith("!")&&(n=!0,e=e.slice(1)),e.endsWith("!")&&(n=!0,e=e.slice(0,-1));let s=[],r="",o=0;for(let f of e)f==="["?o++:f==="]"&&(o=Math.max(0,o-1)),f===":"&&o===0?(s.push(r),r=""):r+=f;s.push(r);let i=s.pop()??"";if(!i)return null;let a=[],l={min:[],max:[],below:[]},c={on:!1};for(let f of s)if(!f||!pl(f,a,l,c))return null;a.sort((f,m)=>H(f)-H(m));let u=/^[\w-]+$/.test(i)?i:null;return{token:t,state:gt(a),context:fl(l,c.on),utility:i,important:n,stem:u}}function Er(t){let e=Sr(t.utility);return e?e.map(n=>({property:n.property,value:t.important?`${n.value} !important`:n.value,via:t.token})):[]}function dl(t){return t.some(e=>Ut(e.property)!=="hint")}function be(t){let e=[];for(let n of t.matchAll(/@apply\s+([^;{}]+)/g))for(let s of Ar(n[1])){let r=_r(s);if(!r)continue;let o=Er(r).filter(i=>et(i.property,i.value));o.length!==0&&e.push({state:r.state,context:r.context,declarations:o})}return e}function jr(t){return t==="default"?"":t.split(" + ").map(e=>e==="hover"?":hover":e==="focus"?":focus":e==="active"?":active":e==="disabled"?":disabled":"").join("")}function kn(t,e,n){let s=e.map(f=>`${f.property}:${f.value}`).join(";");if(!s)return[];let r=Ze(t),o=`${r}{${s}}`,i=n.split(" \xB7 ").map(f=>f.trim()).filter(f=>f&&!/^@layer\b/i.test(f));if(i.length===0)return[o];if(i.length!==1||!i[0].startsWith("@media"))return[];let a=i[0],l=[`${a}{${o}}`];if(!a.includes("prefers-color-scheme: dark"))return l;let c=a.replace(/^@media\s+/,"").split(/\s+and\s+/).filter(f=>!f.includes("prefers-color-scheme")).join(" and "),u=`html[data-theme="dark"] ${r}{${s}}`;return l.push(c?`@media ${c}{${u}}`:u),l}function gl(t,e){let n=t.slice(Math.max(0,e-160),e);return/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:await\s+)?$/.exec(n)?.[1]??null}function ml(t){if(t.t!=="obj")return{};let e=t.entries.find(s=>s.key==="defaultVariants")?.value;if(!e||e.t!=="obj")return{};let n={};for(let s of e.entries)s.value.t==="str"&&s.value.v?n[s.key]=s.value.v:s.value.t==="bool"&&(n[s.key]=s.value.v?"true":"false");return n}function hl(t,e,n,s,r){let o=Q(t,e),i={slots:[],defaults:{}};if(!o)return i;let a=he(o.val)??"",l=W(t,o.end);if(t[l]!==",")return a.trim()?{slots:[hn(a,ct(t,e),r)],defaults:{}}:i;let c=Q(t,l+1);if(!c||c.val.t!=="obj")return a.trim()?{slots:[hn(a,ct(t,e),r)],defaults:{}}:i;let u=c.val.entries.find(b=>b.key==="variants")?.value,f=[],m=new Map;if(a.trim()&&f.push(hn(a,ct(t,e),r)),u&&u.t==="obj"){for(let b of u.entries)if(b.value.t==="obj")for(let k of b.value.entries){let C=he(k.value);if(!C||!C.trim()||k.key==="false")continue;m.set(`${b.key}\0${k.key}`,C);let v=k.key==="true"?`.${b.key}`:`.${b.key}-${k.key}`,g=It({selector:v,path:s,base:!1},n.classKeywords);f.push({title:g.title,axis:k.key==="true"?b.key:g.axis??b.key,base:!1,classes:`${a} ${C}`.trim(),line:ct(t,k.at),group:r,prop:b.key,value:k.key})}}return f.push(...bl(c.val,a,m,n,s,t,r)),{slots:f,defaults:ml(c.val)}}function Ir(t){if(t.t==="str"&&t.v)return[t.v];if(t.t==="bool")return[t.v?"true":"false"];if(t.t==="arr"){let e=[];for(let n of t.items){let s=Ir(n);if(!s||s.length!==1)return null;e.push(s[0])}return e.length?e:null}return null}function bl(t,e,n,s,r,o,i){let a=t.entries.find(c=>c.key==="compoundVariants")?.value;if(!a||a.t!=="arr")return[];let l=[];for(let c of a.items){if(c.t!=="obj")continue;let u=[],f="",m=c.at,b=!1;for(let C of c.entries){if(C.key==="class"||C.key==="className"){f=he(C.value)??"",m=C.at,C.value.t!=="str"&&C.value.t!=="arr"&&f===""&&(b=!0);continue}let v=Ir(C.value);if(!v){b=!0;break}u.push({axis:C.key,values:v})}if(b)continue;let k=[[]];for(let C of u){let v=[];for(let g of k){for(let p of C.values)if(v.push([...g,{axis:C.axis,value:p}]),v.length>=8)break;if(v.length>=8)break}k=v}for(let C of k){if(C.length<2&&!f.trim())continue;let v=[e],g=[];for(let y of C){let w=n.get(`${y.axis}\0${y.value}`);w&&v.push(w),g.push(y.value==="true"?y.axis:y.value)}f.trim()&&v.push(f);let p=v.join(" ").replace(/\s+/g," ").trim();if(!p)continue;let d=It({selector:`.${g.join("-")}`,path:r,base:!1},s.classKeywords);l.push({title:d.title,axis:d.axis,base:!1,classes:p,line:ct(o,m),group:i,when:C.map(y=>({prop:y.axis,value:y.value}))})}}return l}function hn(t,e,n){return{title:"Base",axis:null,base:!0,classes:t,line:e,group:n}}function Lr(t,e){return e.elements.includes(t.toLowerCase())?!0:e.identifier.test(t)}function yl(t){let e=t.match(/\bclassName\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*"([^"]*)"\s*\}|\{\s*'([^']*)'\s*\})/);return e?.[1]??e?.[2]??e?.[3]??e?.[4]??null}var xl=new Set(["opacity","z-index","font-weight","line-height","flex","flex-grow","flex-shrink","order","zoom"]);function kl(t){return t.replace(/^[A-Z]/,e=>`-${e.toLowerCase()}`).replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function wl(t,e){return e.t==="str"?e.v:e.t==="num"?xl.has(t)?String(e.v):`${e.v}px`:null}function ye(t,e){if(t.t!=="obj")return[];let n=[],s=[];for(let o of t.entries){if(o.value.t==="obj"){let l=o.key.replace(/^&/,""),c=l===":hover"?"hover":l===":focus"||l===":focus-visible"?"focus":l===":active"?"active":l===":disabled"?"disabled":null;c&&s.push(...ye(o.value,c));continue}let i=kl(o.key),a=wl(i,o.value);!a||!et(i,a)||n.push({property:i,value:a,via:"style"})}return[...n.length?[{state:e,context:"",declarations:n}]:[],...s]}function yn(t,e){if(t[e]!=="`")return null;let n="";for(let s=e+1;s<t.length;s++){let r=t[s];if(r==="\\"){let o=t[s+1];if(o===void 0)return null;n+=o==="n"?`
47
- `:o,s++;continue}if(r==="$"&&t[s+1]==="{"){let o=1;for(s+=2;s<t.length&&o>0;s++)t[s]==="{"?o++:t[s]==="}"&&o--;s--,n+=" ";continue}if(r==="`")return{css:n,end:s+1};n+=r}return null}function vl(t,e){if(t==="default")return e;if(e==="default")return t;let n=[...new Set([...t.split(" + "),...e.split(" + ")])];return n.sort((s,r)=>H(s)-H(r)||s.localeCompare(r)),gt(n)}function xn(t){let e=[];for(let n of bt(`.__gs {
48
- ${t}
49
- }`)){let s=X(n.selector),r=s?.[s.length-1];if(!r)continue;let o=ie(r.simples),i=gt(o.states),a=lt(n.ownBody).filter(l=>et(l.property,l.value));a.length&&e.push({state:i,context:n.context,declarations:a});for(let l of be(n.ownBody))e.push({state:vl(i,l.state),context:[n.context,l.context].filter(Boolean).join(" \xB7 "),declarations:l.declarations})}return e}function $l(t){let e=t.match(/\bstyle\s*=\s*"([^"]*)"/);if(e){let i=lt(e[1]).filter(a=>et(a.property,a.value));return i.length?[{state:"default",context:"",declarations:i}]:[]}let n=t.search(/\bstyle\s*=\s*\{/);if(n<0)return[];let s=t.indexOf("{",n),r=W(t,s+1);t[r]==="{"&&(s=r);let o=Q(t,s);return o?ye(o.val,"default"):[]}function Cl(t){let e=yl(t);if(e)return{classes:e,painted:[]};let n=t.search(/\bclassName\s*=\s*\{/);if(n<0)return{classes:"",painted:[]};let s=t.indexOf("{",n),r=W(t,s+1);if(t.startsWith("css",r)&&!/[\w$]/.test(t[r+3]??"")){let i=W(t,r+3);if(t[i]==="`"){let a=yn(t,i);return{classes:"",painted:a?xn(a.css):[]}}if(t[i]==="("){let a=Q(t,i+1);return{classes:"",painted:a?ye(a.val,"default"):[]}}}let o=Q(t,r);return o?{classes:he(o.val)??"",painted:[]}:{classes:"",painted:[]}}function Sl(t,e){if(e.identifier.test(t))return!0;let n=t.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return e.classKeywords.some(s=>n.includes(s.toLowerCase()))}function Rl(t,e){let n=[],s=/(?:^|[^\w$])styled(?:\.([A-Za-z][\w]*)|\(\s*(?:["']([A-Za-z][\w]*)["']|([A-Za-z][\w]*))\s*\))/g;for(let o of t.matchAll(s)){let i=o[1]??o[2]??o[3]??"";if(!Lr(i,e))continue;let a=W(t,(o.index??0)+o[0].length);t.startsWith(".attrs",a)&&(a=W(t,a+6),t[a]==="("&&(a=bn(t,a,"(",")")),a=W(t,a));let l=[];if(t[a]==="`"){let c=yn(t,a);c&&(l=xn(c.css))}else if(t[a]==="("){let c=Q(t,a+1);c&&(l=ye(c.val,"default"))}l.length!==0&&n.push({title:"Styled",axis:null,base:!0,classes:"",line:ct(t,o.index??0),painted:l})}let r=/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*css\s*`/g;for(let o of t.matchAll(r)){let i=o[1]??"";if(!Sl(i,e))continue;let a=t.indexOf("`",o.index??0),l=a<0?null:yn(t,a);if(!l)continue;let c=xn(l.css);c.length!==0&&n.push({title:"Css",axis:null,base:!0,classes:"",line:ct(t,o.index??0),painted:c})}return n}function Al(t,e){if(e==="default")return`.${t}`;let n=`.${t}`;for(let s of e.split(" + "))s==="hover"?n+=":hover":s==="focus"?n+=":focus":s==="active"?n+=":active":s==="disabled"&&(n+=":disabled");return n}function _l(t,e,n,s,r){let o=Ar(t.classes).map(_r).filter(d=>d!==null),i=o.filter(d=>d.stem===null||!s.has(d.stem)),a=(t.painted??[]).filter(d=>d.declarations.length>0);if(i.length===0&&a.length===0)return null;let l=new Map,c=(d,y,w)=>{if(w.length===0)return;let x=`${d}\0${y}`,$=l.get(x)??{state:d,context:y,declarations:[]};$.declarations.push(...w),l.set(x,$)},u=[r];for(let d of o){let y=Er(d).filter(w=>et(w.property,w.value));c(d.state,d.context,y),d.state==="default"&&d.context===""&&d.stem&&u.push(d.stem)}for(let d of a)c(d.state,d.context,d.declarations);let f=[...l.values()].flatMap(d=>d.declarations);if(!dl(f))return null;let m=l.get("default\0")?.declarations??[];if(le(m))return null;let b=[...l.values()].map(d=>({state:d.state,context:d.context,line:t.line,declarations:d.declarations})).sort((d,y)=>d.state!==y.state?d.state==="default"?-1:y.state==="default"?1:H(d.state.split(" + ")[0])-H(y.state.split(" + ")[0])||d.state.localeCompare(y.state):d.context===""?-1:y.context===""?1:d.context.localeCompare(y.context)),k=[...new Set(o.map(d=>d.stem).filter(d=>d!==null))],C=k.length?k.map(d=>`.${d}`).join(""):n.elements[0]??"button",v=b.flatMap(d=>kn(Al(r,d.state),d.declarations,d.context)),g=n.elements[0]??"button";return{variant:{title:t.title,axis:t.axis,element:{tag:g,classes:u,attrs:{},ancestors:[]},usage:{status:"unknown",files:[],fileCount:0},selector:C,path:e,line:t.line,base:t.base,states:b},rules:v}}function Mr(t,e,n,s,r){let o=ll(e),i=[],a=[],l=/(?:^|[^\w$])(cva|tv)\s*\(/g;for(let p of o.matchAll(l)){let d=(p.index??0)+Math.max(0,p[0].indexOf(p[1])),y=(p.index??0)+p[0].length,w=a.length,x=hl(o,y,n,t,w);a.push({name:gl(o,d),defaults:x.defaults}),i.push(...x.slots)}i.push(...Rl(o,n));let c=/<([A-Za-z][\w.]*)\b([^>]*?)>/g;for(let p of o.matchAll(c)){let d=p[1];if(!Lr(d,n))continue;let y=p[2]??"",w=Cl(y),x=[...w.painted,...$l(y)],$=w.classes.trim();if(!$&&x.length===0)continue;let I=p.index??0,j=ct(o,I);i.push({title:$?"Base":w.painted.length?"Css":"Inline",axis:null,base:!0,classes:$,line:j,painted:x,...$&&x.length===0?{site:{path:t,line:j,offset:I}}:{}})}let u=[],f=[],m=new Map,b=[],k=new Map,C=new Map,v=r;for(let p=0;p<i.length;p++){let d=i[p];if(u.length+f.length>=ol)break;let y=(d.painted??[]).map(j=>`${j.state}|${j.context}|${j.declarations.map(A=>`${A.property}:${A.value}`).join(";")}`).join("||"),w=`${d.classes.replace(/\s+/g," ").trim()}##${y}`,x=k.get(w);if(x){d.group!==void 0&&C.set(p,x),d.site&&m.get(x)?.sites.push(d.site);continue}v+=1;let $=`__gs-recipe-${v}`,I=_l(d,t,n,s,$);if(I){if(k.set(w,$),d.group!==void 0&&C.set(p,$),d.site){let j={variant:I.variant,sites:[d.site]};m.set($,j),f.push(j)}else u.push(I.variant);b.push(...I.rules)}}let g=[];for(let p=0;p<a.length;p++){let d=a[p],y={path:t,name:d.name,staticClasses:[],axes:[],compounds:[]},w=new Map;for(let x=0;x<i.length;x++){let $=i[x];if($.group!==p)continue;let I=C.get(x);if(!I)continue;if(!$.prop&&!$.when){y.staticClasses.push(I);continue}if($.when){y.compounds.push({when:$.when,classes:[I]});continue}let j=w.get($.prop)??[];j.push({value:$.value,classes:[I]}),w.set($.prop,j)}for(let[x,$]of w)y.axes.push({prop:x,values:$,...d.defaults[x]?{defaultValue:d.defaults[x]}:{}});(y.staticClasses.length||y.axes.length||y.compounds.length)&&g.push(y)}return{variants:u,inline:f,previewRules:b,nextId:v,recipes:g}}function Pr(t,e){let s=(t.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return e.some(r=>{let o=r.toLowerCase();return s.includes(o)||s.includes(`${o}s`)})}var wn=6,El=/"([^"\\\n]{0,400})"|'([^'\\\n]{0,400})'|`([^`\\]{0,400})`/g,jl=/\bclass(?:Name)?\s*=\s*(?:"([^"]*)"|'([^']*)')/g,Il=/\b(?:styles?|classes|css|cls|s)\.([A-Za-z_]\w*)/g,Wt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Ll(t){let e=n=>n.replace(/[^\n]/g," ");return t.replace(/\/\*[\s\S]*?\*\//g,e).replace(/<!--[\s\S]*?-->/g,e).replace(/(^|\s)\/\/[^\n]*/g,(n,s)=>s+e(n.slice(s.length)))}function Ml(t,e){let n=Ll(e),s=new Map,r=new Map,o=(a,l,c)=>{let u=a.get(l);u?u.push(c):a.set(l,[c])},i=(a,l)=>{for(let c of a.matchAll(/[\w-]+/g))o(s,c[0],l)};for(let a of n.matchAll(El))i(a[1]??a[2]??a[3]??"",a.index);for(let a of n.matchAll(jl))i(a[1]??a[2]??"",a.index);for(let a of n.matchAll(Il))o(r,a[1],a.index);return{path:t,text:n,original:e,words:s,ids:r}}function Or(t,e){let n=1;for(let s=t.indexOf(`
50
- `);s!==-1&&s<e;)n++,s=t.indexOf(`
51
- `,s+1);return n}var Pl=t=>t.replace(/[-_]+(\w)/g,(e,n)=>n.toUpperCase()),Ol=/\[\s*([\w-]+)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*\]/g,Dl=new Set(["data-component","data-slot","role"]);function Tl(t,e){return[...t.slice(mt(t)).matchAll(Ol)].map(s=>({name:s[1],value:s[2]??s[3]??s[4]??null})).filter(s=>!Dl.has(s.name)&&!(s.value!==null&&e.has(s.value.toLowerCase())))}function Nl(t){return[...t.slice(mt(t)).matchAll(/\.((?:\\.|[\w-])+)/g)].map(n=>n[1].replace(/\\(.)/g,"$1"))}function vn(t,e,n,s,r=!1,o=[],i=()=>null){let a=null,l=()=>a??=e.map(g=>Ml(g,t.get(g)??"")),c=new Map,u=g=>{let p=c.get(g);if(!p){let d=new RegExp(`["'\`]${Wt(g)}["'\`]\\s*\\+`);p=l().filter(y=>y.text.includes(`${g}\${`)||d.test(y.text)),c.set(g,p)}return p},f=(g,p,d)=>cr(rn(g.original,p,d,g.path),g.original,p,g.path,o,i),m=(g,p)=>({files:g.slice(0,wn).map(({file:d,offset:y,example:w})=>({path:d.path,line:Or(d.text,y),...r?{example:w??f(d,y,p)}:{}})),fileCount:g.length}),b=(g,p)=>{let d=[],y=Pl(g);for(let w of l()){let x=[...s.has(g)?[]:w.words.get(g)??[],...w.ids.get(y)??w.ids.get(g)??[]],$=x[0];if($===void 0)continue;let I=$,j;if(r)for(let A of x){let R=f(w,A,p);if(R.kind!=="other"){I=A,j=R;break}}d.push({file:w,offset:I,example:j})}if(d.length)return{status:"used",...m(d,p)};for(let w=g.length-1;w>0;w--){if(g[w]!=="-"&&g[w]!=="_")continue;let x=g.slice(0,w+1),$=g.slice(w+1),I=u(x);if(I.length===0||!$)continue;let j=x.slice(0,-1),A=new RegExp(`\\b${Wt(j)}\\s*[=:]\\s*\\{?\\s*["'\`]${Wt($)}["'\`]`),R=[];for(let L of l()){let T=A.exec(L.text);T&&R.push({file:L,offset:T.index})}return R.length?{status:"used",via:`via ${j} prop`,...m(R,p)}:{status:"dynamic",via:`built as ${x}\${\u2026}`,...m(I.map(L=>({file:L,offset:0})),p)}}return{status:"unreferenced",files:[],fileCount:0}},k=(g,p)=>{let d=Wt(g.name),y=g.value===null?new RegExp(`\\b${d}\\b`):new RegExp(`\\b${d}\\s*[=:]\\s*\\{?\\s*["'\`]${Wt(g.value)}["'\`]`),w=[];for(let I of l()){let j=y.exec(I.text);j&&w.push({file:I,offset:j.index})}if(w.length)return{status:"used",via:`via ${g.name} attribute`,...m(w,p)};let x=new RegExp(`\\b${d}\\s*=\\s*\\{(?!\\s*["'\`])`),$=[];for(let I of l()){let j=x.exec(I.text);j&&$.push({file:I,offset:j.index})}return $.length?{status:"dynamic",via:`${g.name} is set from a variable`,...m($,p)}:{status:"unreferenced",files:[],fileCount:0}},C=new Map;if(r&&o.length>0)for(let g of l())for(let p of ge(g.path,g.text,o,i))for(let d of p.selects){let y=C.get(d)??[];y.push({file:g,offset:p.offset}),C.set(d,y)}let v={used:0,unknown:0,dynamic:1,unreferenced:2};for(let g of n){let p=Nl(g.selector),d=Tl(g.selector,s);if(p.length===0&&d.length===0){g.usage={status:"unknown",files:[],fileCount:0};continue}let y=[...p.map(A=>b(A,p)),...d.map(A=>k(A,p))];g.usage=y.reduce((A,R)=>v[R.status]>=v[A.status]?R:A);let w=g.element?.classes.find(A=>A.startsWith("__gs-recipe-")),x=w?C.get(w):void 0;if(!x||x.length===0)continue;let $=new Set(g.usage.files.map(A=>A.path)),I=g.usage.fileCount,j=[...g.usage.files];for(let A of x)$.has(A.file.path)||($.add(A.file.path),I+=1,!(j.length>=wn)&&j.push({path:A.file.path,line:Or(A.file.text,A.offset),...r?{example:f(A.file,A.offset,[])}:{}}));g.usage={...g.usage,status:g.usage.status==="unknown"?"unknown":"used",files:j,fileCount:I}}}function Dr(t,e,n){let s=[],r=new Set;for(let o of e)r.has(o.path)||(r.add(o.path),!(s.length>=wn)&&s.push({path:o.path,line:o.line,...n?{example:rn(t.get(o.path)??"",o.offset,[],o.path)}:{}}));return{status:"used",files:s,fileCount:r.size}}var Vl={id:"button",label:"Buttons",identifier:/^[A-Z][A-Za-z0-9]*Button[A-Za-z0-9]*$|^Button[A-Za-z0-9]*$/,elements:["button"],roles:["button"],classKeywords:["btn","button"],excludeClassKeywords:["switch","switcher"],prose:/\bbuttons?\b/i},Ur={button:Vl},zr=12,Cn=200,yt=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i,Tr=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?|mdx|erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,Gt=/\.(css|scss|sass|less|styl)$/i,Nr=/\.(mdx?|markdown|txt|rst|adoc)$/i,Vr=/(^|\/)(tokens?|design-tokens?|theme)[^/]*\.json$/i,J=/(^|\/)(__tests__|tests?|spec|e2e|cypress|playwright)(\/|$)|\.(test|spec)\.[a-z]+$/i,Bl=/(^|\/)(plans?|results?|changelogs?|history|archive)(\/|\.|$)|(^|\/)CHANGELOG/i;function Fl(t){return xe.test(t)&&!/(^|\/)README\.md$/i.test(t)?"instruction":Bl.test(t)?"record":"documentation"}var xe=/(^|\/)(AGENTS|CLAUDE|CONTRIBUTING|README|GUIDELINES?)\.md$|(^|\/)(eslint|stylelint|\.eslintrc|\.stylelintrc)[^/]*$|(^|\/)\.cursor\/|(^|\/)\.claude\//i;function ut(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ul(t){return(t.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"")}function Br(t,e){let n=Ul(t).toLowerCase();return e.some(s=>{let r=s.toLowerCase();return n===r||n===`${r}s`})}function zl(t,e){let n=1;for(let s=0;s<e;s++)t.charCodeAt(s)===10&&n++;return n}function pt(t,e){let n=t.split(`
52
- `),s=0,r=[];for(let o=0;o<n.length;o++){let i=n[o];if(e.lastIndex=0,!!e.test(i)&&(s++,r.length<zr)){let a=i.trim();r.push({line:o+1,text:a.length>Cn?`${a.slice(0,Cn)}\u2026`:a})}}return{count:s,lines:r}}function Wr(t){let e=t.lastIndexOf("/");return e<0?"":t.slice(0,e)}function Gr(t){let e=[];for(let n of t.split("/"))!n||n==="."||(n===".."?e.pop():e.push(n));return e.join("/")}var Wl=["",".tsx",".ts",".jsx",".js",".mjs",".vue",".svelte",".css",".module.css",".scss","/index.tsx","/index.ts","/index.js"];function xt(t,e,n){let s;if(e.startsWith("."))s=Gr(`${Wr(t)}/${e}`);else if(e.startsWith("@/"))s=e.slice(2);else if(e.startsWith("~/"))s=e.slice(2);else if(e.startsWith("/"))s=e.slice(1);else return null;for(let r of Wl)if(n(s+r))return s+r;return null}var Gl=/import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\)|@import\s+(?:url\()?['"]([^'"]+)['"]/g;function $n(t){let e=[];for(let n of t.matchAll(Gl)){let s=n[1]??n[2]??n[3];s&&e.push(s)}return e}var Hl=/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class|var)\s+([A-Za-z_$][\w$]*)|export\s*\{([^}]*)\}/g;function Fr(t){let e=new Set;for(let n of t.matchAll(Hl))if(n[1]&&e.add(n[1]),n[2])for(let s of n[2].split(",")){let r=s.trim().split(/\s+as\s+/).pop()?.trim();r&&e.add(r)}return[...e]}var Sn=/var\(\s*(--[\w-]+)/g;function ke(t){return t.split(" \xB7 ").every(e=>e===""||/^@layer\b/i.test(e))}function Hr(t){let e=[];for(let n of t.matchAll(/(?:^|[;{}])\s*composes\s*:\s*([^;]+)/g)){let s=n[1].trim(),r=/^(.*?)\s+from\s+(['"]?)([^'"]+)\2\s*$/.exec(s);r?e.push({names:r[1].split(/\s+/).filter(Boolean),from:r[3]}):e.push({names:s.split(/\s+/).filter(Boolean),from:null})}return e}function Kl(t,e,n){let s=e.startsWith(".")?Gr(`${Wr(t)}/${e}`):e.startsWith("@/")?e.slice(2):e.startsWith("~/")||e.startsWith("/")?e.replace(/^~?\//,""):null;return s&&n(s)?s:xt(t,e.replace(/\.(?:module\.)?(?:css|scss|sass|less)$/i,""),n)}function Jl(t){let e=new Map;for(let[n,s]of t)if(Gt.test(n)){for(let r of bt(s))if(ke(r.context))for(let o of z(r.selector)){let i=/^\.([\w-]+)$/.exec(o.trim())?.[1];if(!i)continue;let a=`${n}\0${i}`,l=e.get(a)??{decls:[],composes:[]};l.decls.push(...lt(r.ownBody));for(let c of be(r.ownBody))c.state==="default"&&c.context===""&&l.decls.push(...c.declarations);l.composes.push(...Hr(r.ownBody)),e.set(a,l)}}return e}function Zl(t,e,n,s){let r=[],o=new Set,i=(l,c,u)=>{if(u>4)return;let f=`${l}\0${c}`;if(o.has(f))return;o.add(f);let m=n.get(f);if(m){for(let b of m.composes)a(l,b,u+1);r.push(...m.decls)}},a=(l,c,u)=>{for(let f of c.names)if(c.from==="global")for(let m of n.keys()){let b=m.indexOf("\0"),k=m.slice(0,b);m.slice(b+1)!==f||/\.module\./i.test(k)||i(k,f,u)}else if(c.from){let m=Kl(l,c.from,s);m&&i(m,f,u)}else i(l,f,u)};for(let l of Hr(e))a(t,l,0);return r}function Xl(t,e){let n=jr(e);return n?z(t).map(s=>{let r=Math.max(s.lastIndexOf(" "),s.lastIndexOf(">"),s.lastIndexOf("+"),s.lastIndexOf("~"));return r<0?`${s}${n}`:`${s.slice(0,r+1)}${s.slice(r+1)}${n}`}).join(", "):t}var ql=/^(?::root|html|body|\*)$/i,Yl=25e4,Ql=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,tc=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,ec=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]);function nc(t){let e=new Set,n=new Set;for(let s of t.matchAll(Ql)){let r=s[1],o=ec.has(r.toLowerCase())&&r===r.toLowerCase()?e:n;for(let i of s[2].matchAll(tc))o.add(i[1]??i[2])}return{parts:new Set([...e].filter(s=>!n.has(s))),controls:n}}function sc(t,e){let n=new Map;for(let s of e)if(Gt.test(s)){for(let r of bt(t.get(s)))if(ke(r.context)&&z(r.selector).some(o=>ql.test(o)))for(let o of lt(r.ownBody))o.property.startsWith("--")&&!n.has(o.property)&&n.set(o.property,o.value)}return n}function rc(t,e){let n=new Set,s=[],r=a=>{for(let l of a.matchAll(Sn))n.has(l[1])||(n.add(l[1]),s.push(l[1]))};for(let a of e)r(a);let o=[];for(let a=s.shift();a;a=s.shift()){let l=t.get(a);l===void 0||!et(a,l)||(o.push(`${a}:${l}`),r(l))}return`${o.length?`:root{${o.join(";")}}
53
- `:""}${e.join(`
54
- `)}`.slice(0,Yl)}function Kr(t,e){let n=[...t.keys()].sort(),s=h=>t.has(h),r=new Map,o=(h,S,_,M)=>{let O=`${S}:${h}`,B=r.get(O);if(B){B.note.includes(_)||(B.note+=`; ${_}`);return}r.set(O,{path:h,role:S,note:_,matches:M.count,lines:M.lines})},i=new Set,a=new Set;for(let h of n){if(!yt.test(h)||J.test(h))continue;let S=t.get(h),_=Fr(S).filter(P=>e.identifier.test(P)),M=h.split("/").pop()??"",O=new RegExp(e.classKeywords.join("|"),"i").test(M);if(_.length===0&&!O)continue;for(let P of _)i.add(P);a.add(h);let B=_.length?new RegExp(`\\b(?:${_.map(ut).join("|")})\\b`,"g"):e.prose;o(h,"implements",_.length?`exports ${_.join(", ")}`:"named for the concept",pt(S,B))}let l=new Set,c=[],u=[],f=new Map,m=h=>Br(h,e.classKeywords)||/\.module\.[a-z]+$/i.test(h)&&f.has(h),b=null,k=()=>b??=Jl(t),C=h=>{let S=m(h),_=[],M=0;for(let P of bt(t.get(h))){let F=z(P.selector).filter(D=>zt(D,e,S));if(F.length===0)continue;M+=1;for(let D of P.ownBody.matchAll(Sn))l.add(D[1]);let U=be(P.ownBody),rt=[...Zl(h,P.ownBody,k(),s),...lt(P.ownBody),...U.filter(D=>D.state==="default"&&D.context==="").flatMap(D=>D.declarations)];for(let D of rt)for(let K of D.value.matchAll(Sn))l.add(K[1]);_.push({block:P,parts:F,declarations:rt,previewContext:ke(P.context)?"":null,listed:!0});for(let D of U){if(D.state==="default"&&D.context==="")continue;let K=Xl(F.join(", "),D.state),Ot=z(K).filter(_o=>zt(_o,e,S));if(Ot.length===0)continue;let Ao=[P.context,D.context].filter(Boolean).join(" \xB7 ");_.push({block:{...P,selector:K,context:Ao},parts:Ot,declarations:D.declarations,previewContext:ke(P.context)?D.context:null,listed:!1})}}let O={parts:new Set,controls:new Set};for(let P of f.get(h)??[]){let F=nc(t.get(P)??"");for(let U of F.parts)O.parts.add(U);for(let U of F.controls)O.controls.add(U)}c.push(...wr(h,_.map(({block:P,parts:F,declarations:U})=>({selector:F.join(", "),declarations:U,line:P.line,context:P.context})),e,S,O));let B=/\.module\.[a-z]+$/i.test(h)?`${Fs(h)} `:"";for(let{parts:P,declarations:F,previewContext:U}of _){if(U===null)continue;let rt=P.flatMap(K=>{let Ot=zt(K,e,S);return Ot?[`${B}${Ft(Ot.compounds)}`]:[]}),D=F.filter(K=>et(K.property,K.value));if(!(rt.length===0||D.length===0))for(let K of rt)u.push(...kn(K,D,U))}return{count:M,lines:_.filter(P=>P.listed).slice(0,zr).map(({block:P})=>({line:P.line,text:P.selector.replace(/\s+/g," ").slice(0,Cn)}))}},v=new Map;for(let h of a)for(let S of $n(t.get(h))){let _=xt(h,S,s);if(_&&Gt.test(_)){let M=v.get(_)??[];M.push(h.split("/").pop()??h),v.set(_,M),Br(h,e.classKeywords)&&f.set(_,[...f.get(_)??[],h])}}for(let h of n){if(!Gt.test(h))continue;let S=C(h),_=v.get(h);if(S.count===0)continue;let M=[];_&&M.push(`imported by ${_.join(", ")}`),S.count>0&&M.push(`${S.count} matching rule${S.count===1?"":"s"}`),o(h,"styles",M.join("; "),S)}let g=new Set;for(let h of c)for(let S of h.selector.matchAll(/\.((?:\\.|[\w-])+)/g))g.add(S[1].replace(/\\(.)/g,"$1"));let p=new Set(a),d=new RegExp([...e.elements.map(h=>`<${ut(h)}\\b`),...e.roles.map(h=>`role=["']${ut(h)}["']`)].join("|"));for(let h of n)!yt.test(h)||J.test(h)||d.test(t.get(h)??"")&&p.add(h);for(let h of a)for(let S of $n(t.get(h))){let _=xt(h,S,s);!_||!yt.test(_)||J.test(_)||Pr(_,e.classKeywords)&&p.add(_)}let y=0,w=[],x=[];for(let h of p){let S=Mr(h,t.get(h)??"",e,g,y);y=S.nextId,w.push(...S.recipes),c.push(...S.variants),x.push(...S.inline),u.push(...S.previewRules)}let $=Un(x);c.push(...$.variants);let I=ur([...a].map(h=>({path:h,source:t.get(h)??"",names:Fr(t.get(h)??"").filter(S=>e.identifier.test(S))})),w,(h,S)=>xt(h,S,s)),j=[];if(l.size>0){let h=new RegExp(`(?:^|[\\s{;])(${[...l].map(ut).join("|")})\\s*:`),S=new Map;for(let _ of n){if(!Gt.test(_)&&!Vr.test(_))continue;let M=t.get(_),O=pt(M,h);if(O.count!==0){for(let B of M.matchAll(new RegExp(h.source,"gm"))){let P=S.get(B[1])??[];P.includes(_)||P.push(_),S.set(B[1],P)}o(_,"tokens",`defines ${O.count} token${O.count===1?"":"s"} read by ${e.label.toLowerCase()} styles`,O)}}for(let _ of[...l].sort())j.push({name:_,definedIn:S.get(_)??[]})}for(let h of n){if(!Vr.test(h))continue;let S=pt(t.get(h),e.prose);S.count>0&&o(h,"tokens","token file mentions the concept",S)}let A=[...i],R=new RegExp([...A.length?[`<(?:${A.map(ut).join("|")})\\b`]:[],...e.elements.map(h=>`<${ut(h)}\\b`),...e.roles.map(h=>`role=["']${ut(h)}["']`)].join("|"));for(let h of n){if(!yt.test(h)||a.has(h))continue;let S=t.get(h),_=J.test(h),M=pt(S,R),O=$n(S).some(P=>{let F=xt(h,P,s);return F!=null&&a.has(F)});if(M.count===0&&!O)continue;let B=M.count>0?`${M.count} render${M.count===1?"":"s"}`:"imports a button component";o(h,_?"tests":"uses",B,M.count?M:pt(S,e.prose))}for(let h of n){if(!(Nr.test(h)||xe.test(h)))continue;let _=t.get(h),M=pt(_,e.prose);M.count!==0&&o(h,J.test(h)?"tests":"describes",xe.test(h)?"repo rules / instructions":"documentation",M)}for(let h of n){if(!J.test(h)||r.has(`tests:${h}`)||!yt.test(h))continue;let S=pt(t.get(h),e.prose);S.count>0&&o(h,"tests","mentions the concept",S)}let L=[...r.values()].sort((h,S)=>S.matches-h.matches||h.path.localeCompare(S.path)),T={implements:0,styles:0,tokens:0,uses:0,describes:0,tests:0};for(let h of L)T[h.role]++;let G=vr(c);vn(t,n.filter(h=>Tr.test(h)&&!J.test(h)),G,new Set(e.elements),!0,I,(h,S)=>xt(h,S,s)),vn(t,n.filter(h=>Tr.test(h)&&!J.test(h)),G.flatMap(h=>h.modifiers??[]),new Set(e.elements));for(let[h,S]of $.sites)h.usage=Dr(t,S,!("alike"in h));let Z=sc(t,n),Zt=[];if(i.size>0){let h=new RegExp(e.elements.map(S=>`<${ut(S)}\\b`).join("|"),"g");for(let S of n){if(!yt.test(S)||J.test(S)||a.has(S))continue;let _=t.get(S),M=(_.match(h)??[]).length;if(M===0)continue;let O=pt(_,new RegExp(h.source));Zt.push({path:S,line:O.lines[0]?.line??1,count:M})}}let Tn=[],Nn=new Set;for(let h of n){if(!yt.test(h)||J.test(h))continue;let S=t.get(h),_=ge(h,S,I,(M,O)=>xt(M,O,s));for(let M of _)for(let O of M.unknown){let B=[...O.known].sort();if(O.cls!==void 0){if(g.has(O.cls))continue;let U=O.cls.slice(0,O.cls.length-O.value.length),rt=[...g].filter(D=>D.startsWith(U)&&D.length>U.length).map(D=>D.slice(U.length));if(rt.length===0)continue;B=[...new Set([...O.known,...rt])].sort()}if(B.length===0)continue;let P=zl(S,M.offset),F=`${h}\0${M.component}\0${O.prop}\0${O.value}`;Nn.has(F)||(Nn.add(F),Tn.push({path:h,line:P,component:M.component,prop:O.prop,value:O.value,known:B}))}}let So=n.filter(h=>(Nr.test(h)||xe.test(h))&&!J.test(h)).map(h=>({path:h,kind:Fl(h)}));G.sort((h,S)=>Number(S.base)-Number(h.base)||h.path.localeCompare(S.path)||h.line-S.line);let Vn=mr(t,So,e,G),Ro=dr([...f.entries()].map(([h,S])=>({sheet:h,sources:S.map(_=>t.get(_)??""),rules:bt(t.get(h)??"").map(_=>({selector:_.selector,declarations:lt(_.ownBody)}))})));return{components:A.sort(),tokens:j,findings:L,variants:G,audit:Zs({variants:G,tokens:j,tokenValues:Z,hasComponent:i.size>0,nativeUses:Zt,unknownProps:Tn,guidance:Vn,noun:e.label.toLowerCase(),element:e.elements[0]??e.id}),guidance:Vn,content:Ro,previewCss:rc(Z,u),counts:T}}import{execFileSync as ic}from"node:child_process";import{readdirSync as ac,readFileSync as lc,statSync as cc}from"node:fs";import we from"node:path";function kt(t,e){try{return ic("git",e,{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch{return null}}function Rn(t,e=""){let s=kt(t,["rev-parse","--show-toplevel"])?.trim()||t;return{repoDir:s,root:Ge(e),stateDir:we.join(s,".gruum")}}function ve(t){let e=we.join(t.repoDir,t.root),n=new Map,s=new TextDecoder("utf-8",{fatal:!1}),r=0,o=0,i=!1,a=(l,c)=>{if(i)return;let u;try{u=ac(l).sort()}catch{return}for(let f of u){let m=c?`${c}/${f}`:f,b=we.join(l,f),k;try{k=cc(b)}catch{continue}if(k.isDirectory()){ze(m)&&a(b,m);continue}if(!k.isFile())continue;if(!We(m,k.size)){o++;continue}let C=lc(b);if(As(C)){o++;continue}if(r+C.length>4e7){i=!0;return}r+=C.length,n.set(m,s.decode(C))}};return a(e,""),{files:n,truncated:i,skipped:o}}function Jr(t,e){let n=kt(t.repoDir,["diff","--cached","--name-status","-z"]);if(n===null)return e;let s=js(n).map(({path:r,deleted:o})=>({path:r,content:o?null:kt(t.repoDir,["show",`:${r}`])}));return{...e,files:Es(e.files,s,t.root)}}function Zr(t){let e=kt(t.repoDir,["remote","get-url","origin"])?.trim()??"",n=se(e)??we.basename(t.repoDir),s=kt(t.repoDir,["rev-parse","HEAD"])?.trim()||"working-tree";return{fullName:n,ref:s,rootPath:t.root,htmlUrl:n.includes("/")?`https://github.com/${n}`:""}}function Xr(t){let e=kt(t.repoDir,["config","--get","core.hooksPath"])?.trim();return e||kt(t.repoDir,["rev-parse","--git-path","hooks"])?.trim()||null}function $e(t,e={}){let n=Ur[e.concept??"button"],s=ve(t);return e.staged&&(s=Jr(t,s)),{concept:n.id,label:n.label,...Kr(s.files,n),repo:Zr(t),index:{files:s.files.size,truncated:s.truncated,skipped:s.skipped}}}function wt(t,e,n={}){let s=$e(t,{concept:e.concept,...n});return{result:s,baseline:e,items:Xn(s,e)}}import{mkdirSync as uc,readFileSync as pc,writeFileSync as fc}from"node:fs";import Lt from"node:path";function Ce(t){try{return pc(t,"utf8")}catch{return null}}function Se(t){let e=Ce(t);if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function vt(t,e){uc(Lt.dirname(t),{recursive:!0}),fc(t,e)}function $t(t,e){vt(t,`${JSON.stringify(e,null,2)}
55
- `)}var Ht=t=>Lt.join(t.stateDir,"baseline.json"),qr=t=>Lt.join(t.stateDir,"drift.json"),An=t=>Lt.join(t.stateDir,"exceptions.json"),dc=t=>Lt.join(t.stateDir,"config.json");function ft(t,e){return qt(Se(e?Lt.resolve(e):Ht(t)))}function Re(t){return Qn(Se(qr(t)),new Date().toISOString())}function _n(t,e){$t(qr(t),e)}function gc(t){if(!t||typeof t!="object")return{};let e={};for(let[n,s]of Object.entries(t))(s==="pending"||s==="accepted"||s==="rejected")&&(e[n]=s);return e}function Ae(t){return gc(Se(An(t)))}function En(t){let e=Se(dc(t)),n=Array.isArray(e?.denyGit)?e.denyGit.filter(r=>r==="commit"||r==="push"):Ct.denyGit,s=typeof e?.maxFollowups=="number"&&e.maxFollowups>=0?Math.floor(e.maxFollowups):Ct.maxFollowups;return{...typeof e?.root=="string"?{root:e.root}:{},hooks:{...Ct,denyGit:n,maxFollowups:s}}}import{chmodSync as xc,mkdirSync as kc,readFileSync as ao,writeFileSync as wc}from"node:fs";import{hostname as vc,homedir as $c}from"node:os";import In from"node:path";import{createInterface as Cc}from"node:readline/promises";function Yr(t){return`/v2/projects/${encodeURIComponent(t)}`}function Qr(t,e){if(t.length===0)return null;if(t.length===1)return t[0];let n=e.replace(/^\/+|\/+$/g,""),s=t.filter(r=>r.rootPath===n);if(s.length===1)return s[0];if(!n){let r=t.filter(o=>o.rootPath==="");if(r.length===1)return r[0]}return null}function to(t){if(typeof t!="string")return{error:"Send a URL."};let e=t.trim();if(!e)return{error:"Enter a live URL."};if(!/^https:\/\//i.test(e))return{error:"URL must start with https://"};let n;try{n=new URL(e)}catch{return{error:"That doesn\u2019t look like a URL."}}if(n.protocol!=="https:")return{error:"URL must start with https://"};if(n.username||n.password)return{error:"That doesn\u2019t look like a URL."};let s=n.hostname.toLowerCase().replace(/^www\./,"");return!s||!s.includes(".")?{error:"That doesn\u2019t look like a URL."}:s==="localhost"||s==="127.0.0.1"?{error:"Public hosts only for Live URL (localhost needs the extension later)."}:{value:s}}var mc="http://localhost:3000",hc=/(^|\.)(github\.com|githubusercontent\.com|gitlab\.com|bitbucket\.org|npmjs\.com|npmjs\.org|unpkg\.com|jsdelivr\.net|googleapis\.com|gstatic\.com|google\.com|schema\.org|w3\.org|mozilla\.org|wikipedia\.org|example\.com|example\.org|sentry\.io|vercel\.com|cloudflare\.com|amazonaws\.com)$/i;function eo(t){return`https://${(t.split("/").pop()||t).toLowerCase().replace(/\.git$/,"").replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"")||"example"}.com`}function no(t){return`
40
+ \u2026`:""),startLine:o}}function ea(e,t){let n=er(e,Math.max(0,t)),s=e.split(`
41
+ `),r=Math.max(0,n-1);return{source:tr(s.slice(r,r+12)),startLine:r+1}}function Qs(e,t){return{kind:"other",...ea(e,t)}}function ft(e,t){let n=qs.exec(e.slice(t));if(!n)return null;let s=n[1],r=n[2]??"",o=t+n[0].length;if(/\/\s*$/.test(r)||Zi.has(s.toLowerCase()))return{tag:s,attrs:r,openStart:t,openEnd:o,closeEnd:o,body:""};let a=1,l=o,c=Math.min(e.length,t+4e3);for(;l<c;){if(e[l]!=="<"){l++;continue}if(e.startsWith("</",l)){let f=/^<\/([A-Za-z][\w.-]*)\s*>/.exec(e.slice(l));if(f&&f[1].toLowerCase()===s.toLowerCase()){if(a--,a===0){let m=l+f[0].length;return{tag:s,attrs:r,openStart:t,openEnd:o,closeEnd:m,body:e.slice(o,l)}}l+=f?f[0].length:2;continue}l+=f?f[0].length:2;continue}let u=qs.exec(e.slice(l));if(u&&u[1].toLowerCase()===s.toLowerCase()&&!/\/\s*$/.test(u[2]??"")&&(a++,a>6))return"too-big";l+=u?u[0].length:1}return l>=c&&o+(c-t)>=4e3?"too-big":null}function en(e,t){let n=Math.max(0,t-8e3),s=Math.min(t,e.length-1);for(;s>=n;){let r=e.lastIndexOf("<",s);if(r<n)return null;if(e[r+1]==="/"||e[r+1]==="!"||e[r+1]==="?"){s=r-1;continue}let o=ft(e,r);if(o==="too-big")return"too-big";if(o&&t>=o.openStart&&t<o.closeEnd)return o;s=r-1}return null}function nr(e){return e.replace(/([a-z\d])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function Ae(e){return e.split(/\s+/).filter(Boolean)}function ae(e,t){let n=e[t];if(n!=='"'&&n!=="'"&&n!=="`")return null;let s="";for(let r=t+1;r<e.length;r++){let o=e[r];if(o==="\\"){s+=e[r+1]??"",r++;continue}if(n==="`"&&o==="$"&&e[r+1]==="{")return null;if(o===n)return{value:s,end:r+1};s+=o}return null}function sr(e){let t=[],n="",s=0,r=null;for(let o=0;o<e.length;o++){let i=e[o];if(r){if(n+=i,i==="\\"){n+=e[o+1]??"",o++;continue}i===r&&(r=null);continue}if(i==='"'||i==="'"||i==="`"){r=i,n+=i;continue}if(i==="("||i==="["||i==="{")s++;else if(i===")"||i==="]"||i==="}")s=Math.max(0,s-1);else if(i===","&&s===0){n.trim()&&t.push(n.trim()),n="";continue}n+=i}return n.trim()&&t.push(n.trim()),t}function ut(e=new Map,t=new Map){return{values:e,aliases:t,flags:new Set,strings:new Set,prefixes:new Map}}var Qt=/^[A-Za-z_$][\w$]*$/;function tn(e,t){let n=0,s=null;for(let r=0;r<e.length;r++){let o=e[r];if(s){o==="\\"?r++:o===s&&(s=null);continue}if(o==='"'||o==="'"||o==="`"){s=o;continue}if(o==="("||o==="["||o==="{")n++;else if(o===")"||o==="]"||o==="}")n--;else if(n===0&&e.startsWith(t,r))return r}return-1}function nn(e){let t=e.trim();for(;t.startsWith("(")&&t.endsWith(")");){let n=0,s=!0;for(let r=0;r<t.length-1&&s;r++)t[r]==="("?n++:t[r]===")"&&n--,n===0&&(s=!1);if(!s)break;t=t.slice(1,-1).trim()}return t}function rr(e,t,n){if(e==="true")return!0;if(e==="false"||e==="undefined"||e==="null")return!1;let s=t.aliases.get(e);return s!==void 0&&!t.values.has(e)?_e(s,t,n+1):(t.flags.add(e),!!t.values.get(e))}function _e(e,t,n=0){if(n>4)return null;let s=nn(e);for(let c of["||","&&"]){let u=tn(s,c);if(u<0)continue;let f=_e(s.slice(0,u),t,n+1),m=_e(s.slice(u+2),t,n+1);return f===null||m===null?null:c==="||"?f||m:f&&m}let r=/^(!\s*)?([A-Za-z_$][\w$]*)$/.exec(s);if(r){let c=rr(r[2],t,n);return c===null?null:r[1]?!c:c}let o=/^([A-Za-z_$][\w$]*)\s*(===|==|!==|!=)\s*(["'])(.*?)\3$/.exec(s);if(!o)return null;let i=t.values.get(o[1]);typeof i=="string"&&t.strings.add(o[1]);let a=typeof i=="string"?i:"";return o[2]==="==="||o[2]==="=="?a===o[4]:a!==o[4]}function or(e){let t=0,n=null,s=-1;for(let r=0;r<e.length;r++){let o=e[r];if(n){o==="\\"?r++:o===n&&(n=null);continue}if(o==='"'||o==="'"||o==="`"){n=o;continue}if(o==="("||o==="["||o==="{")t++;else if(o===")"||o==="]"||o==="}")t--;else if(o==="?"&&t===0){s=r;break}}if(s<0)return null;t=0,n=null;for(let r=s+1;r<e.length;r++){let o=e[r];if(n){o==="\\"?r++:o===n&&(n=null);continue}if(o==='"'||o==="'"||o==="`"){n=o;continue}if(o==="("||o==="["||o==="{")t++;else if(o===")"||o==="]"||o==="}")t--;else if(o===":"&&t===0)return{condition:e.slice(0,s),yes:e.slice(s+1,r),no:e.slice(r+1)}}return null}function Re(e,t=ut()){let n=nn(e);if(!n)return{classes:[],dynamic:!1};let s=or(n);if(s){let c=_e(s.condition,t);return c===null?{classes:[],dynamic:!0}:Re(c?s.yes:s.no,t)}let r=tn(n,"&&");if(r>=0){let c=_e(n.slice(0,r),t);return c===null?{classes:[],dynamic:!0}:c?Re(n.slice(r+2),t):{classes:[],dynamic:!1}}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))return{classes:Ae(n.slice(1,-1)),dynamic:!1};if(n.startsWith("`")&&n.endsWith("`")){let c=n.slice(1,-1),u="",f=0;for(;f<c.length;){let m=c.indexOf("${",f);if(m<0){u+=c.slice(f);break}u+=c.slice(f,m);let b=c.indexOf("}",m+2);if(b<0)return{classes:[],dynamic:!0};let w=c.slice(m+2,b).trim();if(Qt.test(w)){let $=t.values.get(w);if(typeof $!="string")return{classes:[],dynamic:!0};t.strings.add(w);let k=/[\w-]*$/.exec(u)?.[0];k&&t.prefixes.set(w,k),u+=$}else{let $=Re(w,t);if($.dynamic)return{classes:[],dynamic:!0};u+=$.classes.join(" ")}f=b+1}return{classes:Ae(u),dynamic:!1}}if(Qt.test(n)&&t.values.has(n)){let c=t.values.get(n);return typeof c!="string"?{classes:[],dynamic:!1}:(t.strings.add(n),{classes:Ae(c),dynamic:!1})}let o=/^(?:styles?|classes|css|cls)\.([A-Za-z_]\w*)$/.exec(n);if(o)return{classes:[nr(o[1])],dynamic:!1};let i=/^(?:styles?|classes|css|cls)\[\s*["']([\w-]+)["']\s*\]$/.exec(n);if(i)return{classes:[i[1]],dynamic:!1};let a=/^(?:styles?|classes|css|cls)\[\s*(`[^`]*`)\s*\]$/.exec(n);if(a){let c=Re(a[1],t);return c.dynamic||c.classes.length!==1?{classes:[],dynamic:!0}:c}let l=/^([A-Za-z_][\w]*)\s*\(([\s\S]*)\)$/.exec(n);if(l&&qi.has(l[1])){let c=[];for(let u of sr(l[2])){let f=Re(u,t);if(f.dynamic)return{classes:[],dynamic:!0};c.push(...f.classes)}return{classes:c,dynamic:!1}}return{classes:[],dynamic:!0}}function dt(e){let t=[],n=!1,s=0;for(;s<e.length;){if(/\s/.test(e[s])){s++;continue}if(e[s]==="{"){let i=0,a=s;for(let l=s;l<e.length;l++)if(e[l]==="{")i++;else if(e[l]==="}"&&(i--,i===0)){s=l+1;break}s===a&&(s=e.length),/^\{\s*\.\.\./.test(e.slice(a))&&(n=!0);continue}let r=/^([A-Za-z_:][\w:.-]*)/.exec(e.slice(s));if(!r){s++;continue}for(s+=r[0].length;s<e.length&&/\s/.test(e[s]);)s++;if(e[s]!=="="){t.push({name:r[1]});continue}for(s++;s<e.length&&/\s/.test(e[s]);)s++;let o=ae(e,s);if(o){t.push({name:r[1],value:o.value}),s=o.end;continue}if(e[s]==="{"){let i=0,a=s;for(let u=s;u<e.length;u++)if(e[u]==="{")i++;else if(e[u]==="}"&&(i--,i===0)){s=u+1;break}s===a&&(s=e.length);let l=e.slice(a+1,s-1).trim(),c=ae(l,0);c&&c.end===l.length?t.push({name:r[1],value:c.value}):t.push({name:r[1],expr:l});continue}s++}return{list:t,spread:n}}function sn(e,t){let n=dt(e).list.find(s=>s.name==="class"||s.name==="className");return n?n.value!==void 0?{classes:Ae(n.value),dynamic:!1}:n.expr===void 0?{classes:[],dynamic:!0}:Re(n.expr,t):null}function ir(e,t){return/[<>]/.test(t)?!1:e==="href"||e==="src"||e==="action"?/^(?:https?:|mailto:|\/|#)/i.test(t):!0}function ta(e){return e==="class"||e==="className"?!1:!Yi.test(e)&&!/^on/i.test(e)}function ar(e){let t={};for(let n of dt(e).list){if(!ta(n.name)||n.expr!==void 0)continue;let s=n.value??"";ir(n.name,s)&&(t[n.name]=s)}return t}var na=/^(?:data-[\w-]+|aria-[\w-]+|disabled|hidden)$/,sa=new Set(["disabled","hidden"]);function ct(e,t,n=0){if(n>4)return null;let s=nn(e),r=ae(s,0);if(r&&r.end===s.length)return r.value;let o=or(s);if(o){let l=_e(o.condition,t);return l===null?null:ct(l?o.yes:o.no,t,n+1)}let i=tn(s,"||");if(i>=0){let l=ct(s.slice(0,i),t,n+1);return l===null?null:l!==void 0?l:ct(s.slice(i+2),t,n+1)}if(s==="undefined"||s==="null"||s==="false")return;if(s==="true")return"true";if(!Qt.test(s))return null;let a=t.values.get(s);if(typeof a=="string")return t.strings.add(s),a;if(typeof a=="boolean"||t.aliases.has(s)){let l=rr(s,t,n);return l===null?null:l?"true":void 0}return t.values.has(s)?void 0:null}function ra(e,t){let n={};for(let s of dt(e).list){if(s.expr===void 0||!na.test(s.name))continue;let r=ct(s.expr,t);if(r!=null){if(sa.has(s.name)){r!=="false"&&(n[s.name]="");continue}ir(s.name,r)&&(n[s.name]=r)}}return n}function oa(e,t){let n=/([A-Za-z_][\w-]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*["']([^"']*)["']\s*\})/g;for(let s of e.matchAll(n)){let r=s.index??0;if(t>=r&&t<r+s[0].length){let o=s[1];return o==="class"||o==="className"?{}:{prop:o,value:s[2]??s[3]??s[4]}}}return{}}function pt(e,t=0){if(t>6)return"";let n="",s=0;for(;s<e.length;){if(e[s]==="{"){let i=0,a=s;for(let u=s;u<e.length;u++)if(e[u]==="{")i++;else if(e[u]==="}"&&(i--,i===0)){a=u+1;break}if(a===s)break;let l=e.slice(s+1,a-1).trim();/^[A-Za-z_$][\w$]*$/.exec(l)?.[0]&&(n+='<span class="__gs-slot">Text</span>'),s=a;continue}if(e[s]==="<"){if(e.startsWith("<!--",s)){let l=e.indexOf("-->",s);s=l===-1?e.length:l+3;continue}if(e.startsWith("</",s)){let l=/^<\/[A-Za-z][\w.-]*\s*>/.exec(e.slice(s));s+=l?l[0].length:1;continue}let i=ft(e,s);if(!i||i==="too-big"){s++;continue}let a=i.tag.toLowerCase();if(/^[A-Z]/.test(i.tag))n+=pt(i.body,t+1);else if(Xi.has(a)){let l=sn(i.attrs),c=l&&!l.dynamic&&l.classes.length?` class="${Ys(l.classes.join(" "))}"`:"",u=pt(i.body,t+1);n+=`<${a}${c}>${u}</${a}>`}s=i.closeEnd;continue}let r=e.slice(s).search(/[<{}]/),o=r===-1?e.length:s+r;n+=Ys(e.slice(s,o)),s=o}return n}function ia(e){let t=sn(e.attrs);return!t||t.dynamic||t.classes.length===0?null:{tag:e.tag.toLowerCase(),classes:t.classes,attrs:ar(e.attrs)}}function lr(e,t){let n=[],s=t-1;for(;n.length<3&&s>=0;){let r=en(e,s);if(!r||r==="too-big"||/^[A-Z]/.test(r.tag))break;let o=ia(r);if(!o)break;n.push(o),s=r.openStart-1}return n.reverse()}var aa=8;function la(e){let t=e.trim(),n=ae(t,0);return n&&n.end===t.length?n.value:t==="true"?!0:t==="false"?!1:/^-?\d+(?:\.\d+)?$/.test(t)?t:null}function ca(e,t){let n=0,s=-1;for(let i=t;i<e.length&&i<t+2e3;i++){let a=e[i];if(a==='"'||a==="'"||a==="`"){let l=ae(e,i);if(!l)return null;i=l.end-1;continue}if(a==="{")n++;else if(a==="}"&&(n--,n===0)){s=i;break}}if(s<0)return null;let r=e.slice(s+1).trimStart()[0];if(r!==")"&&r!==":")return null;let o=new Map;for(let i of sr(e.slice(t+1,s))){if(i.startsWith("..."))continue;let a=/^([A-Za-z_$][\w$]*)(?:\s*:\s*([A-Za-z_$][\w$]*))?(?:\s*=\s*([\s\S]+))?$/.exec(i);if(!a)continue;let l=a[2]??a[1];if(a[3]===void 0){o.set(l,void 0);continue}let c=la(a[3]);c!==null&&o.set(l,c)}return{values:o,end:s}}function ua(e,t){let n=new Set(t.attrs.match(/[A-Za-z_$][\w$]*/g)??[]),s=Math.max(0,t.openStart-8e3),o=[...e.slice(s,t.openStart).matchAll(/\(\s*\{/g)].reverse();for(let i of o){let a=s+(i.index??0)+i[0].length-1,l=ca(e,a);if(!l||![...l.values.keys()].some(f=>n.has(f)))continue;let c=new Map,u=e.slice(l.end,t.openStart);for(let f of u.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;\n]+);/g))n.has(f[1])&&c.set(f[1],f[2].trim());return ut(l.values,c)}return ut()}function pa(e,t){let n=new Map;for(let s of e.matchAll(/([\w-]+)\$\{\s*([A-Za-z_$][\w$]*)\s*\}/g)){let r=s[1],o=t.find(i=>i.startsWith(r)&&i.length>r.length);o&&n.set(s[2],o.slice(r.length))}return n}function fa(e,t,n,s){let r=Qi(e,t.openStart,t.closeEnd);if(/^[A-Z]/.test(t.tag)){let m=oa(e.slice(t.openStart,t.openEnd),n-t.openStart);return{kind:"component",...r,component:{tag:t.tag,...m}}}let o=ua(e,t);for(let[m,b]of pa(t.attrs,s))o.values.set(m,b);let i={};for(let[m,b]of o.values)i[m]=b??null;let a={attrs:t.attrs,values:i,aliases:Object.fromEntries(o.aliases)},l=ut(new Map(o.values),o.aliases),c=da(a.attrs,l);if(!c)return{kind:"dynamic",...r};let u={tag:t.tag.toLowerCase(),...c,ancestors:lr(e,t.openStart),bodyHtml:pt(t.body)},f=[...[...l.strings].filter(m=>typeof o.values.get(m)=="string").map(m=>({name:m,kind:"text",...l.prefixes.has(m)?{prefix:l.prefixes.get(m)}:{}})),...[...l.flags].slice(0,aa).map(m=>({name:m,kind:"flag"}))];return f.length===0?{kind:"markup",...r,element:u}:{kind:"markup",...r,element:u,params:f,redraw:a}}function da(e,t){let n=sn(e,t);return n?.dynamic?null:{classes:n?.classes??[],attrs:{...ar(e),...ra(e,t)}}}function rn(e,t,n,s){if(Ji.test(s))return Qs(e,t);let r=en(e,t);return r==="too-big"||!r?Qs(e,t):fa(e,r,t,n)}function ga(e){let t={},n=new Set,{list:s,spread:r}=dt(e);for(let o of s)o.expr===void 0?t[o.name]=o.value??"true":o.expr==="true"||o.expr==="false"?t[o.name]=o.expr:n.add(o.name);return{literals:t,dynamic:n,spread:r}}function cr(e,t){let n=ga(t),s=new Map,r=[],o=[],i=[],a=n.spread;for(let l of e.axes){if(l.opaque){a=!0;continue}if(!l.locked&&n.dynamic.has(l.prop)){a=!0;continue}let c=l.locked?l.defaultValue:n.literals[l.prop]??(n.spread?void 0:l.defaultValue);if(c===void 0)continue;s.set(l.prop,c);let u=!l.locked&&n.literals[l.prop]===c;if(l.prefix){o.push(`${l.prefix}${c}`),u&&c!==l.defaultValue&&i.push({prop:l.prop,value:c,known:l.defaultValue?[l.defaultValue]:[],cls:`${l.prefix}${c}`});continue}let f=l.values.find(m=>m.value===c);if(!f){a=!0,u&&l.values.length>0&&i.push({prop:l.prop,value:c,known:l.values.map(m=>m.value)});continue}for(let m of f.classes)m.startsWith("__gs-recipe-")&&r.push(m),o.push(m)}if(!a){for(let l of e.compounds)if(l.when.every(u=>s.get(u.prop)===u.value))for(let u of l.classes)u.startsWith("__gs-recipe-")&&r.push(u),o.push(u)}return e.classNameProp&&(n.dynamic.has("className")?a=!0:n.literals.className&&o.push(...Ae(n.literals.className))),{draw:a?null:[...e.staticClasses,...o],selects:r,unknown:i}}function on(e){let t=[],n=/import\s*\{([^}]+)\}\s*from\s*["']([^"']+)["']/g;for(let s of e.matchAll(n)){let r=s[2];for(let o of s[1].split(",")){let i=o.trim().split(/\s+as\s+/),a=i[0]?.trim(),l=(i[1]??i[0])?.trim();a&&l&&t.push({local:l,imported:a,spec:r})}}return t}function ma(e,t,n,s,r){for(let o of on(t)){if(o.local!==n)continue;let i=r(e,o.spec),a=s.find(l=>l.path===i&&l.component===o.imported);if(a)return a}return s.find(o=>o.path===e&&o.component===n)}function ur(e,t,n,s,r,o){if(e.kind!=="component"||!e.component||r.length===0)return e;let i=ma(s,t,e.component.tag,r,o);if(!i)return e;let a=en(t,n),l=e.component.tag;if(!a||a==="too-big"||a.tag!==l&&a.tag!==i.component)return e;let c=cr(i,a.attrs);return c.draw?{kind:"markup",source:e.source,startLine:e.startLine,component:e.component,element:{tag:i.rootTag,classes:c.draw,attrs:{},ancestors:lr(t,a.openStart),bodyHtml:pt(a.body)}}:e}function gt(e,t,n,s){let r=[],o=new Set,i=(l,c)=>{let u=`${l}\0${c.path}`;o.has(u)||(o.add(u),r.push({local:l,binding:c}))};for(let l of on(t)){let c=s(e,l.spec),u=n.find(f=>f.path===c&&f.component===l.imported);u&&i(l.local,u)}for(let l of n)l.path===e&&i(l.component,l);let a=[];for(let{local:l,binding:c}of r){let u=0,f=`<${l}`;for(;u<t.length;){let m=t.indexOf(f,u);if(m<0)break;let b=t[m+f.length];if(b&&/[\w.]/.test(b)){u=m+f.length;continue}let w=ft(t,m);if(!w||w==="too-big"){u=m+f.length;continue}let $=cr(c,w.attrs);($.selects.length||$.unknown.length)&&a.push({offset:m,component:l,selects:$.selects,unknown:$.unknown}),u=Math.max(w.closeEnd,m+f.length)}}return a}function ha(e,t){let n=e.slice(t,t+700),s=n.indexOf("{");if(s<0)return{};let r=n.indexOf("}",s),o=n.slice(s,r<0?s+400:r+1),i={};for(let a of o.matchAll(/([A-Za-z_$][\w$]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))i[a[1]]=a[2]??a[3]??"";return i}function ba(e){let t=/\bclassName\s*=\s*/.exec(e);if(!t)return null;let n=t.index+t[0].length,s=ae(e,n);if(s)return s.value;if(e[n]!=="{")return null;let r=0;for(let o=n;o<e.length;o++)if(e[o]==="{")r++;else if(e[o]==="}"&&(r--,r===0))return e.slice(n+1,o);return null}function ya(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]===")")return{rename:{},fixed:{},opaque:[]};if(e[n]!=="{")return null;let s={rename:{},fixed:{},opaque:[]};for(n++;n<e.length;){for(;n<e.length&&/[\s,]/.test(e[n]);)n++;if(e[n]==="}")return s;if(e.startsWith("...",n))return null;let r=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(!r)return null;for(n+=r[0].length;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]===","||e[n]==="}"){s.rename[r[0]]=r[0];continue}if(e[n]!==":")return null;for(n++;n<e.length&&/\s/.test(e[n]);)n++;let o=ae(e,n);if(o){s.fixed[r[0]]=o.value,n=o.end;continue}let i=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(i){s.rename[r[0]]=i[0],n+=i[0].length;continue}s.opaque.push(r[0]);let a=0;for(;n<e.length;){let l=e[n];if(l==='"'||l==="'"||l==="`"){let c=ae(e,n);if(!c)return null;n=c.end;continue}if(l==="("||l==="["||l==="{")a++;else if(l===")"||l==="]"||l==="}"){if(a===0)break;a--}else if(l===","&&a===0)break;n++}}return null}function xa(e,t,n,s){let r=[];for(let o of on(e)){let i=s(t,o.spec),a=n.find(l=>l.path===i&&l.name===o.imported);a&&r.push({local:o.local,recipe:a})}for(let o of n)o.path===t&&o.name&&r.push({local:o.name,recipe:o});return r}function ka(e){let t=[],n=/(?:styles?|classes|css|cls)\s*\.\s*([A-Za-z_]\w*)/g;for(let c of e.matchAll(n))t.push({at:c.index??0,kind:"static",text:nr(c[1])});let s=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\]/g;for(let c of e.matchAll(s))t.push({at:c.index??0,kind:"static",text:c[1]});let r=/(?:styles?|classes|css|cls)\s*\[\s*`([^`$]*)\$\{\s*([A-Za-z_$][\w$]*)\s*\}`\s*\]/g;for(let c of e.matchAll(r))t.push({at:c.index??0,kind:"prefix",text:c[1],prop:c[2]});let o=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\+\s*([A-Za-z_$][\w$]*)\s*\]/g;for(let c of e.matchAll(o))t.push({at:c.index??0,kind:"prefix",text:c[1],prop:c[2]});/[[{(]/.test(e)||t.push({at:0,kind:"static",text:e.trim()}),t.sort((c,u)=>c.at-u.at);let i=[],a=[];for(let c of t)c.kind==="prefix"&&c.prop?a.push({prop:c.prop,prefix:c.text}):i.push(...Ae(c.text));let l=/(?:^|[(,\s])className\s*(?:[,)]|$)/.test(e);return{staticClasses:i,prefixes:a,classNameProp:l}}function wa(e,t,n,s,r){let o=l=>t.rename[l]??l,i=e.axes.map(l=>{let c=t.fixed[l.prop],u=o(l.prop);return{prop:u,values:c?l.values.filter(f=>f.value===c):l.values,defaultValue:c??n[u]??l.defaultValue,opaque:t.opaque.includes(l.prop),locked:!!c}}),a=e.compounds.map(l=>({classes:l.classes,when:l.when.map(c=>({prop:o(c.prop),value:t.fixed[c.prop]??c.value}))}));return{staticClasses:[...e.staticClasses,...s],axes:i,compounds:a,classNameProp:r}}function pr(e,t,n){let s=[];for(let r of e){let o=xa(r.source,r.path,t,n);for(let i of r.names){let a=new RegExp(`(?:function\\s+${i}\\b|(?:const|let|var)\\s+${i}\\b)`,"g"),l=[...r.source.matchAll(a)],c=null;for(let u of l){let f=u.index??0,b=r.source.slice(f+u[0].length).search(/\nexport\s/),w=r.source.slice(f,f+u[0].length+(b<0?8e3:b)),$=ha(r.source,f),k=0;for(;k<w.length;){if(w[k]!=="<"||w[k+1]==="/"||w[k+1]==="!"){k++;continue}let g=ft(w,k);if(!g||g==="too-big"){k++;continue}if(k=g.openEnd,/^[A-Z]/.test(g.tag))continue;let p=ba(g.attrs);if(!p)continue;let d=ka(p),y=d.prefixes.length?2:d.staticClasses.length?1:0,v=null,x=o.find(C=>new RegExp(`(?:^|[^\\w$])${C.local}\\s*\\(`).test(p));if(x){let C=p.search(new RegExp(`(?:^|[^\\w$])${x.local}\\s*\\(`)),j=p.indexOf("(",C),I=j<0?null:ya(p,j);if(I){y=3,v=wa(x.recipe,I,$,d.staticClasses,d.classNameProp);for(let A of d.prefixes)v.axes.push({prop:A.prop,values:[],prefix:A.prefix,defaultValue:$[A.prop]})}}!v&&(d.prefixes.length||d.staticClasses.length)&&(v={staticClasses:d.staticClasses,axes:d.prefixes.map(C=>({prop:C.prop,values:[],prefix:C.prefix,defaultValue:$[C.prop]})),compounds:[],classNameProp:d.classNameProp}),v&&(!c||y>c.score)&&(c={score:y,tag:g.tag.toLowerCase(),body:v})}}c&&s.push({component:i,path:r.path,rootTag:c.tag,...c.body})}}return s}var va=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,$a=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,Ca=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),Sa=new Set(["icon","glyph","svg"]),Ra=new Set(["label","text","title","caption"]),Aa=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function dr(e){let t=e.flatMap(Aa);return t.some(n=>Sa.has(n))?"icon":t.some(n=>Ra.has(n))?"label":null}function _a(e){let t=e.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g," "),n=[];for(let s of t.matchAll(va)){let r=s[1];if(!Ca.has(r.toLowerCase())||r!==r.toLowerCase())continue;let o=[...s[2].matchAll($a)].map(a=>a[1]??a[2]),i=dr(o);i&&n.push({index:s.index??0,role:i,tag:r.toLowerCase(),classes:o})}return n}function Ea(e,t,n){if(!t.some(r=>r.property.toLowerCase()==="display"&&/^none\b/i.test(r.value.trim()))||n.size===0)return null;for(let r of z(e)){let o=X(r);if(!o||o.length<2)continue;let i=o[o.length-1];if(i.combinator!==" "&&i.combinator!==">")continue;let a=i.simples.filter(m=>m.kind==="class");if(a.length!==1||a[0].kind!=="class"||!n.has(a[0].name))continue;let l=o[o.length-2];if(l.simples.filter(m=>m.kind!=="class"&&m.kind!=="attr"&&m.kind!=="tag").length>0)continue;let u=l.simples.filter(m=>m.kind==="class"),f=l.simples.filter(m=>m.kind==="attr");if(u.length===1&&f.length===0&&u[0].kind==="class"&&!/^(?:is|has)-/.test(u[0].name))return{classes:[u[0].name],attrs:{}};if(u.length===0&&f.length===1&&f[0].kind==="attr"&&f[0].value)return{classes:[],attrs:{[f[0].name]:f[0].value}}}return null}var Ia=["text","icon-start","icon-end","icon"],fr={text:"Text","icon-start":"Icon left","icon-end":"Icon right",icon:"Icon"};function ja(e,t){let n=null,s=null;for(let i of t)i.index<e.index?n=i:s||(s=i);if(!n&&!s)return null;let r=n?e.index-n.index:1/0;return(s?s.index-e.index:1/0)<=r?"start":"end"}function Ee(e){return{role:e.role,tag:e.tag,classes:e.classes}}function gr(e){let t=new Map,n=(s,r)=>{let o=t.get(s)??[];o.some(i=>i.path===r.path)||o.push(r),t.set(s,o)};for(let s of e){let r=s.sources.flatMap(_a),o=r.filter(b=>b.role==="label"),i=r.filter(b=>b.role==="icon"),a=o[0];a&&n("text",{path:s.sheet,slots:[Ee(a)],classes:[],attrs:{}});let l=new Set(o.flatMap(b=>b.classes.filter(w=>dr([w])==="label"))),c=null,u=null;for(let b of i){let w=ja(b,o),$=o.reduce((k,g)=>{let p=Math.abs(g.index-b.index);return!k||p<k.dist?{hit:g,dist:p}:k},null);w==="start"&&$&&!c&&(c={icon:b,label:$.hit}),w==="end"&&$&&!u&&(u={icon:b,label:$.hit})}c&&n("icon-start",{path:s.sheet,slots:[Ee(c.icon),Ee(c.label)],classes:[],attrs:{}}),u&&n("icon-end",{path:s.sheet,slots:[Ee(u.label),Ee(u.icon)],classes:[],attrs:{}});let f=null;for(let b of s.rules)if(f=Ea(b.selector,b.declarations,l),f)break;let m=c?.icon??u?.icon??i[0]??null;f&&m&&n("icon",{path:s.sheet,slots:[Ee(m)],classes:f.classes,attrs:f.attrs})}return[{id:"text",label:fr.text,sheets:t.get("text")??[]},...Ia.filter(s=>s!=="text"&&t.has(s)).map(s=>({id:s,label:fr[s],sheets:t.get(s)??[]}))]}function La(e,t){if(!e)return t;let n=z(e);return z(t).flatMap(s=>n.map(r=>s.includes("&")?s.replaceAll("&",r):`${r} ${s}`)).join(", ")}var Pa=/^@(?:-\w+-)?(?:keyframes|font-face|property)\b/i;function be(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,i=>i.replace(/[^\n]/g," ")),n=[],s=[],r=0,o=1;for(let i=0;i<t.length;i++){let a=t[i];if(a===`
42
+ `&&o++,a==="{"){let l=t.slice(r,i).trim(),c=s[s.length-1];c&&(c.own+=t.slice(c.segStart,r));let u=/^@theme\b/i.test(l),f=l.startsWith("@")&&!u,m=[...s].reverse().find(b=>!b.isAt)??null;s.push({selector:l,resolved:f?l:u?":root":La(m?.resolved??null,l),isAt:f,skip:(c?.skip??!1)||f&&Pa.test(l),start:i+1,line:o,own:"",segStart:i+1}),r=i+1}else if(a==="}"){let l=s.pop();if(l){l.own+=t.slice(l.segStart,i),!l.isAt&&!l.skip&&n.push({selector:l.resolved,body:t.slice(l.start,i),ownBody:l.own,line:l.line,context:s.filter(u=>u.isAt).map(u=>u.selector.replace(/\s+/g," ")).join(" \xB7 ")});let c=s[s.length-1];c&&(c.segStart=i+1)}r=i+1}else a===";"&&(r=i+1)}return n}function le(e){let t=[],n=0,s=0,r=o=>{let i=o.indexOf(":");if(i<=0)return;let a=o.slice(0,i).trim(),l=o.slice(i+1).replace(/\s+/g," ").trim();/^-{0,2}[a-z][\w-]*$/i.test(a)&&l&&a!=="composes"&&t.push({property:a,value:l})};for(let o=0;o<e.length;o++){let i=e[o];i==="("?n++:i===")"?n=Math.max(0,n-1):i===";"&&n===0&&(r(e.slice(s,o)),s=o+1)}return r(e.slice(s)),t}var Ma=25,Oa=12,mr=700,Na=/\b(?:must(?: not)?|never|always|should(?: not|n't)?|do not|don't|avoid|prefer|forbidden|not allowed|no more than)\b/i,se=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Da(e){let t=e.split(`
43
+ `),n=[],s=[],r=null,o=null,i=0;if(t[0]?.trim()==="---"){let l=t.findIndex((c,u)=>u>0&&c.trim()==="---");l>0&&(i=l+1)}let a=l=>{r&&(n.push({start:r.start,end:l,text:r.lines.join(`
44
+ `).trimEnd(),headings:r.headings}),r=null)};for(;i<t.length;i++){let l=t[i],c=i+1,u=/^\s*(```|~~~)/.exec(l)?.[1];if(o){r.lines.push(l),u===o&&(o=null,a(c));continue}if(u){a(c-1),o=u,r={start:c,lines:[l],headings:[...s]};continue}let f=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(l);if(f){a(c-1),s=[...s.slice(0,f[1].length-1),f[2]];continue}if(l.trim()===""){a(c-1);continue}r??={start:c,lines:[],headings:[...s]},r.lines.push(l)}return a(t.length),n}function Ta(e,t){let n=e.map(se).join("|"),s=e.map(r=>se(r.charAt(0).toUpperCase()+r.slice(1))).join("|");return new RegExp(`${t.source}|\\b(?:${n})s?\\b|[a-z](?:${s})s?\\b|\\b(?:${n})[-_]|[-_](?:${n})\\b`,"i")}function Va(e,t){let n=t.map(se).join("|"),s=new Map;for(let r of e){if(r.base||r.title==="Unnamed"||r.title.startsWith("In ")||!r.element)continue;let i=s.get(r.title)??{title:r.title,tests:[],heading:null},a=r.selector.slice(me(r.selector));for(let l of a.matchAll(/\.((?:\\.|[\w-])+)/g)){let c=l[1].replace(/\\(.)/g,"$1");if(t.includes(c.toLowerCase()))continue;let u=/[-_]|[a-z][A-Z]/.test(c);i.tests.push(new RegExp(u?`(?<![\\w-])${se(c)}(?![\\w-])`:`(?:\\.|["'\`])${se(c)}(?![\\w-])`))}if(!r.title.includes(" + ")){let l=r.title.toLowerCase().split(/\s+/).map(se).join("[\\s_-]+");i.tests.push(new RegExp(`\\b${l}[\\s_-]+(?:${n})s?\\b|\\b(?:${n})s?[_-]+${l}\\b`,"i")),r.axis&&/^[a-z]+$/i.test(r.title)&&i.tests.push(new RegExp(`\\b${se(r.axis)}\\s*[=:]\\s*\\{?\\s*["'\`]${se(r.title.toLowerCase())}["'\`]`,"i")),i.heading=r.title.toLowerCase()}s.set(r.title,i)}return[...s.values()]}function Fa(e,t){return e.toLowerCase().replace(new RegExp(`\\b(?:${t.map(se).join("|")})s?\\b`,"g")," ").replace(/[^a-z0-9]+/g," ").trim()}function Ba(e){return e.length>mr?`${e.slice(0,mr).trimEnd()}\u2026`:e}function hr(e,t,n,s){let r=Ta(n.classKeywords,n.prose),o=Va(s,n.classKeywords),i=new Set,a=[];for(let u of t){let f=e.get(u.path);if(f===void 0)continue;let m=[];for(let b of Da(f)){if(!r.test(b.text)&&!b.headings.some(k=>r.test(k)))continue;let w=b.headings.length?Fa(b.headings[b.headings.length-1],n.classKeywords):"",$=o.filter(k=>k.tests.some(g=>g.test(b.text))||w!==""&&k.heading===w).map(k=>k.title);for(let k of $)i.add(k);m.push({path:u.path,line:b.start,endLine:b.end,headings:b.headings,text:Ba(b.text),rule:Na.test(b.text),styles:$})}m.length!==0&&a.push({path:u.path,kind:u.kind,passages:m.slice(0,Oa),total:m.length,rules:m.filter(b=>b.rule).length})}let l={instruction:0,documentation:1,record:2};a.sort((u,f)=>l[u.kind]-l[f.kind]||f.rules-u.rules||f.total-u.total||u.path.localeCompare(f.path));let c=new Map;for(let u of s)u.element&&!u.base&&u.title!=="Unnamed"&&!u.title.startsWith("In ")&&c.set(u.title,!0);return{files:a.slice(0,Ma).map(({rules:u,...f})=>f),documented:[...i].sort(),undocumented:[...c.keys()].filter(u=>!i.has(u))}}var br=new Set(["tone","size","variant","kind","type","style","theme","color","colour","appearance","intent","emphasis","shape","level"]),Ua=new Set(["is","has","js","c","component","comp","el","ui","the","root"]),za={xs:["extra","small"],sm:["small"],md:["medium"],lg:["large"],xl:["extra","large"],xxl:["extra","extra","large"]},Wa=new Set(["cta","ui","ux","faq","cms","api","url","ios"]);function ln(e){return e.replace(/\\(.)/g,"$1").replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>t.toLowerCase())}function Ga(e){return new Set(e.flatMap(t=>[t,`${t}s`]))}function an(e){let t=e.map(n=>Wa.has(n)?n.toUpperCase():n).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function Ie(e,t){let n=ln(e).filter(r=>!t.has(r)&&!Ua.has(r)),s=null;return n.length>1&&br.has(n[0])&&(s=n[0],n=n.slice(1)),{words:n.flatMap(r=>za[r]??[r]),axis:s}}var yr=/\.((?:\\.|[\w-])+)/g,Ha=/\[\s*([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*))\s*\]/g;function Ka(e,t){let n=e.split("/"),s=(n.pop()??"").replace(/(\.module)?\.[a-z]+$/i,""),r=n.pop()??"";return ln(s).some(a=>t.has(a))||ln(r).some(a=>t.has(a))?Ie(s,t).words:[]}function Ja(e,t){let n=[];for(let s of e.split(/[\s>+~]+/).filter(Boolean)){let r=[...s.matchAll(yr)].map(o=>o[1]);if(r.length)for(let o of r)n.push(...Ie(o,t).words);else{let o=/^[a-z][\w-]*/i.exec(s)?.[0]?.toLowerCase();o&&!["div","span","html","body"].includes(o)&&n.push(...Ie(o,t).words)}}return n}function je(e,t){let n=Ga(t),s=me(e.selector),r=e.selector.slice(0,s),o=e.selector.slice(s),i=[...o.matchAll(yr)].map(u=>Ie(u[1],n));for(let u of o.matchAll(Ha)){let f=u[1].replace(/^data-/,"").toLowerCase();if(!br.has(f))continue;let m=u[2]??u[3]??u[4]??"",b=Ie(m,n);i.push({words:b.words,axis:f})}let a=i.filter(u=>u.words.length>0);if(a.length>0)return{title:a.map(u=>an(u.words)).join(" + "),axis:a.length===1?a[0].axis:null};let l=Ja(r,n);if(l.length>0)return{title:`In ${l.join(" ")}`,axis:null};let c=Ka(e.path,n);if(c.length>0)return{title:an(c),axis:null};if(e.base){let u=Za(e.path,n);return u.length>0?{title:`${an(u)} Base`,axis:null}:{title:"Base",axis:null}}return{title:"Unnamed",axis:null}}function Za(e,t){let n=e.split("/").pop()??"";if(!/\.module\.[a-z]+$/i.test(n))return[];let s=n.replace(/\.module\.[a-z]+$/i,"");return Ie(s,t).words}var Xa=60;function ze(e,t,n){let s=X(e);if(!s)return null;let r=s.length-1,o=s[r].simples;if(Ds(o)||Jt(o,t))return null;if(ot(o,t))return{compounds:s,at:r};for(let i=r-1;i>=0;i--){let a=s[i].simples;if(ot(a,t)&&!Jt(a,t))return{compounds:s,at:i}}return!n||r===0&&Ts(o)?null:{compounds:s,at:0}}function xr(e,t,n){return Be([...e,{combinator:e.length?t.combinator:null,simples:n}])}function kr(e,t){return e.kind!==t.kind?!1:e.kind==="attr"&&t.kind==="attr"?e.name===t.name&&e.op===t.op&&e.value===t.value:e.raw===t.raw}function qa(e,t){return e.length>=t.length?!1:e.every(n=>t.some(s=>kr(n,s)))}function Ya(e,t){if(e.length!==1)return!1;let n=e[0];return n.kind==="tag"?t.elements.includes(n.name):n.kind==="class"?t.classKeywords.some(s=>s.toLowerCase()===n.name.toLowerCase()):!1}function Qa(e,t){for(let n of t.classes)e.classes.includes(n)||e.classes.push(n);Object.assign(e.attrs,t.attrs)}function wr(e){let t=new Set(e.map(n=>Ue(n.property)).filter(n=>n!=="hint"));return t.size===0||t.size===1&&t.has("layout")?"placement":t.size===1&&t.has("paint")?"effect":"override"}function el(e){let t=e.filter(o=>o.context===""),n=t.length?t:e;if(n.some(o=>o.state==="default"))return null;let r=[...n.map(o=>new Set(o.state.split(" + "))).reduce((o,i)=>o?new Set([...o].filter(a=>i.has(a))):i,null)??[]].filter(o=>H(o)===rt.length);return r.length===1?r[0]:null}function cn(e){return e.sort((t,n)=>+(t.context!=="")-+(n.context!=="")||H(t.state.split(" + ")[0])-H(n.state.split(" + ")[0])||t.state.localeCompare(n.state))}function vr(e,t,n,s,r={parts:new Set,controls:new Set}){let o=new Map,i=[];for(let g of t)if(g.declarations.length!==0)for(let p of z(g.selector)){let d=ze(p,n,s);if(!d)continue;let{compounds:y,at:v}=d,x=y[v],C=it(x.simples);if(C.identity.length===0)continue;let j=y.slice(0,v),I=xr(j,x,C.identity),A=ge(C.states);if(v<y.length-1){i.push({hostKey:I,part:{selector:Be(y),path:e,line:g.line,state:A}});continue}if(Fs(C.identity,g.declarations))continue;let R=o.get(I);if(!R){if(o.size>=Xa)continue;R={key:I,prefix:j,identity:C.identity,line:g.line,states:[],modifiers:[],contexts:[],parts:[],movedInto:null},o.set(I,R)}let L=R.states.find(D=>D.state===A&&D.context===g.context);L||(L={state:A,context:g.context,line:g.line,declarations:[]},C.states.length&&(L.marker={classes:[],attrs:{}}),R.states.push(L)),L.marker&&Qa(L.marker,C.marker),L.declarations.push(...g.declarations)}for(let[g,p]of o){let d=p.states.flatMap(x=>x.declarations),y=p.states.every(x=>lt(x.declarations)),v=d.every(x=>Ue(x.property)==="hint");(y||v)&&o.delete(g)}let a=new Map;for(let g of o.values()){let p=Fe(g.identity);a.set(p,[...a.get(p)??[],g])}for(let g of a.values()){let p=g.map(x=>el(x.states)),d=p[0];if(!d||p.some(x=>x!==d))continue;let y=g.flatMap(x=>x.states).find(x=>x.marker&&x.state.split(" + ").includes(d))?.marker;if(!y)continue;let v=[...y.classes.map(x=>({kind:"class",raw:`.${x}`,name:x})),...Object.entries(y.attrs).map(([x,C])=>({kind:"attr",raw:`[${x}="${C}"]`,name:x,op:"=",value:C}))];for(let x of g){let C=[...x.identity,...v],j={combinator:x.prefix.length?" ":null,simples:C},I=xr(x.prefix,j,C);for(let A of x.states){let R=A.state.split(" + ").filter(L=>L!==d);if(A.state=ge(R),R.length===0)delete A.marker;else if(A.marker){A.marker.classes=A.marker.classes.filter(L=>!y.classes.includes(L));for(let L of Object.keys(y.attrs))delete A.marker.attrs[L]}}o.delete(x.key),o.set(I,{...x,key:I,identity:C})}}let l=()=>[...o.values()].filter(g=>g.prefix.length===0),c=g=>g.states.filter(p=>p.state==="default").reduce((p,d)=>p+d.declarations.length,0),u=l().find(g=>Ya(g.identity,n))??(s?l().filter(g=>{let p=g.identity.length===1?g.identity[0]:null;return p?.kind==="class"&&r.controls.has(p.name)}).sort((g,p)=>c(p)-c(g)||g.line-p.line)[0]??null:null),f=u&&u.identity[0].kind==="class"?[u.identity[0].name]:[],m=(g,p,d)=>{p[d].push(g),g.movedInto=p,o.delete(g.key)},b=[...o.values()],w=g=>{let p=b.find(d=>d.key===g)??null;for(;p?.movedInto;)p=p.movedInto;return p};for(let g of l()){let p=g.identity.length===1?g.identity[0]:null;if(!(p?.kind!=="class"||!r.parts.has(p.name))&&(o.delete(g.key),u&&g!==u)){g.movedInto=u;for(let d of g.states)u.parts.push({selector:g.key,path:e,line:d.line,state:d.state})}}let $=l().filter(g=>g.identity.filter(p=>p.kind!=="tag"&&p.kind!=="universal").length>=2).sort((g,p)=>g.identity.length-p.identity.length);for(let g of $){let p=b.filter(y=>y!==g&&y!==u&&y.prefix.length===0&&qa(y.identity,g.identity));if(p.length===0)continue;p.sort((y,v)=>v.identity.length-y.identity.length||c(v)-c(y)||y.line-v.line);let d=w(p[0].key);d&&d!==g&&m(g,d,"modifiers")}for(let{hostKey:g,part:p}of i){let d=w(g)??(s?u:null);d&&o.has(d.key)&&d.parts.push(p)}let k=g=>{let p=g===u,d=at(g.key,f);return{...je({selector:g.key,path:e,base:p},n.classKeywords),element:d,usage:{status:"unknown",files:[],fileCount:0},selector:g.key,path:e,line:g.line,base:p,states:cn(g.states),modifiers:g.modifiers.length?g.modifiers.map(y=>{let v=y.identity.filter(x=>!g.identity.some(C=>kr(C,x)));return{title:je({selector:v.map(x=>x.raw).join(""),path:e,base:!1},n.classKeywords).title,selector:y.key,path:e,line:y.line,element:at(y.key,f),usage:{status:"unknown",files:[],fileCount:0},states:cn(y.states)}}):void 0,contexts:g.contexts.length?g.contexts.map(y=>{let v=wr(y.states.flatMap(x=>x.declarations));return{selector:y.key,path:e,line:y.line,role:v,element:v==="override"?at(y.key,f):null,states:cn(y.states)}}):void 0,parts:g.parts.length?g.parts:void 0}};return[...o.values()].map(k)}function $r(e){let t=new Map;for(let i of e){let a=i.base?/^\.([\w-]+)$/.exec(i.selector):null;a&&t.set(i.path,[...t.get(i.path)??[],a[1]])}let n=i=>{let a=X(i.selector);if(!a)return null;let l=a[a.length-1].simples,c=t.get(i.path)??[],u=l.filter(f=>!(f.kind==="class"&&c.includes(f.name)));return{depth:a.length-1,subject:Fe(l),bareTag:!l.some(f=>f.kind==="class"||f.kind==="attr"||f.kind==="id"),bare:u.length&&u.length<l.length?Fe(u):null}},s=new Map(e.map(i=>[i,n(i)])),r=new Set,o=i=>{let a=s.get(i);if(!a||a.depth===0)return null;let l=e.filter(c=>{if(c===i||r.has(c))return!1;let u=s.get(c);return u!=null&&u.depth<a.depth&&(!a.bareTag||u.depth===0)&&(u.subject===a.subject||a.bare!==null&&u.subject===a.bare)});return l.sort((c,u)=>+(u.path===i.path)-+(c.path===i.path)||s.get(c).depth-s.get(u).depth),l[0]??null};for(let i of[...e].sort((a,l)=>(s.get(l)?.depth??0)-(s.get(a)?.depth??0))){let a=o(i);if(!a)continue;for(;r.has(a);)a=o(a)??a;let l=wr(i.states.flatMap(c=>c.declarations));a.contexts=[...a.contexts??[],{selector:i.selector,path:i.path,line:i.line,role:l,element:l==="override"?i.element:null,states:i.states}],i.parts?.length&&(a.parts=[...a.parts??[],...i.parts]),i.modifiers?.length&&(a.modifiers=[...a.modifiers??[],...i.modifiers]),r.add(i)}return e.filter(i=>!r.has(i))}var tl={slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}};function Cr(e){let t=e.lastIndexOf("-");return t<=0?null:tl[e.slice(0,t)]?.[e.slice(t+1)]??null}var E=(e,t)=>({property:e,value:t});function gn(e){if(!e.startsWith("[")||!e.endsWith("]"))return null;let t=e.slice(1,-1).replace(/_/g," ").trim();return/^-?[\d.]+(?:px|rem|em|%|vh|vw)$/.test(t)||/^var\(\s*--[\w-]+\s*\)$/.test(t)?t.replace(/\s+/g,""):null}function dn(e){let t=gn(e);if(t)return t;if(e==="px")return"1px";if(!/^\d+(?:\.\d+)?$/.test(e))return null;let n=Number(e);if(n>96)return null;let s=Math.round(n*2);if(Math.abs(n*2-s)>1e-6)return null;if(s===0)return"0";let r=Math.floor(s/8),o=["",".125",".25",".375",".5",".625",".75",".875"][s%8];return r===0?`0${o}rem`:`${r}${o}rem`}function nl(e){let t=/^(\d+)\/(\d+)$/.exec(e);if(!t)return null;let n=Number(t[1])/Number(t[2])*100;return Number.isFinite(n)?`${Number(n.toFixed(4))}%`:null}function Sr(e,t){return{full:"100%",screen:t==="w"?"100vw":"100vh",auto:"auto",fit:"fit-content",min:"min-content",max:"max-content"}[e]??nl(e)??gn(e)??dn(e)}var sl={xs:{size:"0.75rem",leading:"1rem"},sm:{size:"0.875rem",leading:"1.25rem"},base:{size:"1rem",leading:"1.5rem"},lg:{size:"1.125rem",leading:"1.75rem"},xl:{size:"1.25rem",leading:"1.75rem"},"2xl":{size:"1.5rem",leading:"2rem"},"3xl":{size:"1.875rem",leading:"2.25rem"},"4xl":{size:"2.25rem",leading:"2.5rem"},"5xl":{size:"3rem",leading:"1"},"6xl":{size:"3.75rem",leading:"1"}},rl={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},ol={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},il={none:"0",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},al={sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)","":"0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",xl:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)","2xl":"0 25px 50px -12px rgb(0 0 0 / 0.25)",inner:"inset 0 2px 4px 0 rgb(0 0 0 / 0.05)",none:"none"},ll={"":"3px",0:"0px",1:"1px",2:"2px",4:"4px",8:"8px"};function un(e,t){let n=null;if(e.startsWith("[")&&e.endsWith("]")){let r=e.slice(1,-1).replace(/_/g," ").trim();if(r.startsWith("--"))n=`var(${r})`;else if(/^var\(\s*--[\w-]+\s*\)$/.test(r))n=r.replace(/\s+/g,"");else if(/^#[0-9a-f]{3,8}$/i.test(r)||/^(?:rgb|hsl|oklch|oklab|color)\(/i.test(r))n=r;else return null}else e==="white"?n="#fff":e==="black"?n="#000":e==="transparent"?n="transparent":e==="current"?n="currentColor":e==="inherit"?n="inherit":n=Cr(e)??(/^[a-z][\w-]*$/i.test(e)?`var(--${e}, var(--color-${e}))`:null);if(!n)return null;if(!t)return n;if(!/^\d+(?:\.\d+)?$/.test(t))return null;let s=Number(t)<=1?Number(t)*100:Number(t);return s<0||s>100?null:s===100?n:`color-mix(in srgb, ${n} ${s}%, transparent)`}function cl(e){let t=0,n=-1;for(let s=0;s<e.length;s++){let r=e[s];r==="["?t++:r==="]"?t=Math.max(0,t-1):r==="/"&&t===0&&(n=s)}return n<0?{body:e,opacity:null}:{body:e.slice(0,n),opacity:e.slice(n+1)}}function pn(){return E("box-shadow","0 0 0 var(--gs-ring-w, 3px) var(--gs-ring-c, currentColor)")}var ul={flex:"flex","inline-flex":"inline-flex",block:"block","inline-block":"inline-block",inline:"inline",grid:"grid","inline-grid":"inline-grid",hidden:"none",contents:"contents"},fn={start:"flex-start",end:"flex-end",center:"center",baseline:"baseline",stretch:"stretch",between:"space-between",around:"space-around",evenly:"space-evenly"};function Rr(e){let t=e.startsWith("-"),n=t?e.slice(1):e,{body:s,opacity:r}=cl(n),o=ul[s];if(o&&!t&&!r)return[E("display",o)];let i=/^flex-(row|col|row-reverse|col-reverse)$/.exec(s);if(i&&!t&&!r){let R=i[1]==="col"?"column":i[1]==="col-reverse"?"column-reverse":i[1];return[E("flex-direction",R)]}if(s==="flex-wrap"&&!t)return[E("flex-wrap","wrap")];if(s==="flex-nowrap"&&!t)return[E("flex-wrap","nowrap")];if(s==="flex-1"&&!t)return[E("flex","1 1 0%")];if(s==="shrink-0"&&!t)return[E("flex-shrink","0")];if(s==="grow-0"&&!t)return[E("flex-grow","0")];if(s==="grow"&&!t)return[E("flex-grow","1")];let a=/^items-(start|end|center|baseline|stretch)$/.exec(s);if(a&&!t)return[E("align-items",fn[a[1]])];let l=/^justify-(start|end|center|between|around|evenly)$/.exec(s);if(l&&!t)return[E("justify-content",fn[l[1]])];let c=/^self-(start|end|center|stretch|auto)$/.exec(s);if(c&&!t)return[E("align-self",c[1]==="auto"?"auto":fn[c[1]])];if(s==="whitespace-nowrap")return[E("white-space","nowrap")];if(s==="whitespace-normal")return[E("white-space","normal")];if(s==="truncate")return[E("overflow","hidden"),E("text-overflow","ellipsis"),E("white-space","nowrap")];if(s==="underline")return[E("text-decoration-line","underline")];if(s==="no-underline")return[E("text-decoration-line","none")];if(s==="line-through")return[E("text-decoration-line","line-through")];let u=/^(uppercase|lowercase|capitalize|normal-case)$/.exec(s);if(u)return[E("text-transform",u[1]==="normal-case"?"none":u[1])];let f=/^text-(left|center|right|justify|start|end)$/.exec(s);if(f&&!r)return[E("text-align",f[1])];let m=sl[s.replace(/^text-/,"")];if(s.startsWith("text-")&&m&&!r&&!t)return[E("font-size",m.size),E("line-height",m.leading)];let b=rl[s.replace(/^font-/,"")];if(s.startsWith("font-")&&b&&!r)return[E("font-weight",b)];if(s.startsWith("leading-")&&!r){let R=s.slice(8),D=ol[R]??dn(R);if(D)return[E("line-height",D)]}let w=/^cursor-(pointer|default|not-allowed|wait|text|move)$/.exec(s);if(w)return[E("cursor",w[1])];if(s==="pointer-events-none")return[E("pointer-events","none")];if(s==="pointer-events-auto")return[E("pointer-events","auto")];if(s==="select-none")return[E("user-select","none")];let $=/^opacity-(\d+)$/.exec(s);if($&&!t)return[E("opacity",String(Number($[1])/100))];if(s==="transition"||s==="transition-colors"||s==="transition-all")return[E("transition-property",s==="transition-colors"?"color, background-color, border-color, text-decoration-color, fill, stroke":s==="transition-all"?"all":"color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter"),E("transition-timing-function","cubic-bezier(0.4, 0, 0.2, 1)"),E("transition-duration","150ms")];let k=/^duration-(\d+)$/.exec(s);if(k)return[E("transition-duration",`${k[1]}ms`)];let g={linear:"linear",in:"cubic-bezier(0.4, 0, 1, 1)",out:"cubic-bezier(0, 0, 0.2, 1)","in-out":"cubic-bezier(0.4, 0, 0.2, 1)"};if(s.startsWith("ease-")&&g[s.slice(4)])return[E("transition-timing-function",g[s.slice(4)])];if(s==="outline-none")return[E("outline","2px solid transparent"),E("outline-offset","2px")];if(s==="outline")return[E("outline-style","solid")];let p=/^outline-(\d+)$/.exec(s);if(p)return[E("outline-width",`${p[1]}px`)];if(s==="shadow"||s.startsWith("shadow-")){let R=s==="shadow"?"":s.slice(7),L=al[R];if(L)return[E("box-shadow",L)]}if(s==="ring"||/^ring(?:-(?:0|1|2|4|8))?$/.test(s)){let R=s==="ring"?"":s.slice(5),L=ll[R];if(L)return[E("--gs-ring-w",L),pn()]}if(s.startsWith("ring-")&&r===null){let R=un(s.slice(5),null);if(R)return[E("--gs-ring-c",R),pn()]}if(s.startsWith("ring-")&&r){let R=un(s.slice(5),r);if(R)return[E("--gs-ring-c",R),pn()]}let d=s==="rounded"?"":s.startsWith("rounded-")?s.slice(8):null;if(d!==null&&!t){let R=/^(t|r|b|l|s|e|tl|tr|bl|br|ss|se)(?:-(.+))?$/.exec(d),L=R?R[2]??"":d,D=il[L];if(!D)return null;if(!R)return[E("border-radius",D)];let Z={t:["border-top-left-radius","border-top-right-radius"],r:["border-top-right-radius","border-bottom-right-radius"],b:["border-bottom-left-radius","border-bottom-right-radius"],l:["border-top-left-radius","border-bottom-left-radius"],s:["border-start-start-radius","border-end-start-radius"],e:["border-start-end-radius","border-end-end-radius"],tl:["border-top-left-radius"],tr:["border-top-right-radius"],bl:["border-bottom-left-radius"],br:["border-bottom-right-radius"],ss:["border-start-start-radius"],se:["border-start-end-radius"]}[R[1]];return Z?Z.map(Ze=>E(Ze,D)):null}if(/^border(?:-[trblxy])?$/.test(s)&&!r)return[E("border-width","1px"),E("border-style","solid")];let y=/^border-(\d+)$/.exec(s);if(y&&!r)return[E("border-width",`${y[1]}px`),E("border-style","solid")];let v=/^border-(solid|dashed|dotted|double|none|hidden)$/.exec(s);if(v)return[E("border-style",v[1])];let x=/^(p|px|py|pt|pr|pb|pl|ps|pe|m|mx|my|mt|mr|mb|ml|ms|me|gap|gap-x|gap-y|w|h|min-w|min-h|max-w|max-h|size|inset|top|right|bottom|left)-(.+)$/.exec(s),C=x?.[1],j=x?.[2];if(C&&j&&!r){let R=C==="w"||C==="min-w"||C==="max-w"?Sr(j,"w"):C==="h"||C==="min-h"||C==="max-h"?Sr(j,"h"):dn(j);if(!R)return null;let L=t?R==="0"?"0":`-${R}`:R,G={p:["padding"],px:["padding-inline"],py:["padding-block"],pt:["padding-top"],pr:["padding-right"],pb:["padding-bottom"],pl:["padding-left"],ps:["padding-inline-start"],pe:["padding-inline-end"],m:["margin"],mx:["margin-inline"],my:["margin-block"],mt:["margin-top"],mr:["margin-right"],mb:["margin-bottom"],ml:["margin-left"],ms:["margin-inline-start"],me:["margin-inline-end"],gap:["gap"],"gap-x":["column-gap"],"gap-y":["row-gap"],w:["width"],h:["height"],"min-w":["min-width"],"min-h":["min-height"],"max-w":["max-width"],"max-h":["max-height"],size:["width","height"],inset:["inset"],top:["top"],right:["right"],bottom:["bottom"],left:["left"]}[C];return G?G.map(Z=>E(Z,L)):null}let I={bg:"background-color",text:"color",border:"border-color",outline:"outline-color",decoration:"text-decoration-color",accent:"accent-color",caret:"caret-color",fill:"fill",stroke:"stroke"};for(let[R,L]of Object.entries(I))if(s===R||s.startsWith(`${R}-`)){let D=s===R?"":s.slice(R.length+1);if(!D||/^(?:gradient|clip|ellipsis|wrap|nowrap|balance|pretty|opacity)/.test(D))return null;if(R==="text"&&!t){let Z=gn(D);if(Z)return[E("font-size",Z)]}let G=un(D,r);return!G||t?null:[E(L,G)]}let A=/^\[([a-z-]+):(.+)\]$/i.exec(s);if(A&&!t&&!r){let R=A[1].toLowerCase(),L=A[2].replace(/_/g," ").trim();if(/^[a-z][\w-]*$/.test(R)&&L&&!/[<>]/.test(L))return[E(R,L)]}return null}var pl=48,fl={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",disabled:"disabled"},dl=new Set(["cn","clsx","classNames","classnames","cx","twMerge"]);function ce(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
45
+ `&&n++;return n}function gl(e){let t=n=>n.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,t).replace(/(^|\s)\/\/[^\n]*/g,(n,s)=>s+t(n.slice(s.length)))}function W(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function mt(e,t){let n=e[t];if(n!=='"'&&n!=="'"&&n!=="`")return null;let s="",r=!1;for(let o=t+1;o<e.length;o++){let i=e[o];if(i==="\\"){let a=e[o+1];if(a===void 0)return null;s+=a==="n"?`
46
+ `:a,o++;continue}if(n==="`"&&i==="$"&&e[o+1]==="{"){r=!0;let a=1;for(o+=2;o<e.length&&a>0;o++)e[o]==="{"?a++:e[o]==="}"&&a--;o--;continue}if(i===n)return{v:r?null:s,end:o+1};s+=i}return null}function bn(e,t,n,s){let r=0;for(let o=t;o<e.length;o++){let i=e[o];if(i==='"'||i==="'"||i==="`"){let a=mt(e,o);if(!a)return e.length;o=a.end-1;continue}if(i===n)r++;else if(i===s&&(r--,r===0))return o+1}return e.length}function ml(e,t){let n=0;for(let s=t;s<e.length;s++){let r=e[s];if(r==='"'||r==="'"||r==="`"){let o=mt(e,s);if(!o)return e.length;s=o.end-1;continue}if(r==="("||r==="["||r==="{")n++;else if(r===")"||r==="]"||r==="}"){if(n===0)return s;n--}else if(r===","&&n===0)return s}return e.length}function Ar(e){if(e.t==="str")return e.v;if(e.t==="arr"){let t=[];for(let n of e.items){let s=Ar(n);s&&t.push(s)}return t.join(" ")||null}return e.t==="obj"&&e.entries.filter(n=>n.value.t==="bool"&&n.value.v).map(n=>n.key).join(" ")||null}function hl(e,t){let n=t+1,s=[];for(;n<e.length;){if(n=W(e,n),e[n]===")")return{v:s.join(" ").replace(/\s+/g," ").trim()||null,end:n+1};if(e[n]===","){n++;continue}let r=Q(e,n);if(!r)return null;let o=W(e,r.end);if(e[o]===","||e[o]===")"){let i=Ar(r.val);i&&s.push(i),n=r.end;continue}n=ml(e,n)}return null}function Q(e,t){if(t=W(e,t),t>=e.length)return null;let n=e[t];if(n==='"'||n==="'"||n==="`"){let r=mt(e,t);return r?{val:{t:"str",v:r.v,at:t},end:r.end}:null}if(n==="["){let r=t+1,o=[];for(;r<e.length;){if(r=W(e,r),e[r]==="]")return{val:{t:"arr",items:o,at:t},end:r+1};if(e[r]===","){r++;continue}let i=Q(e,r);if(!i)return null;o.push(i.val),r=i.end}return null}if(n==="{"){let r=t+1,o=[];for(;r<e.length;){if(r=W(e,r),e[r]==="}")return{val:{t:"obj",entries:o,at:t},end:r+1};if(e[r]===","){r++;continue}if(e.slice(r,r+3)==="..."){let c=Q(e,r+3);if(!c)return null;r=c.end;continue}let i="",a=r;if(e[r]==='"'||e[r]==="'"||e[r]==="`"){let c=mt(e,r);if(!c||c.v===null)return null;i=c.v,r=c.end}else if(/[\w$]/.test(e[r])){for(a=r;r<e.length&&/[\w$]/.test(e[r]);)r++;i=e.slice(a,r)}else return null;if(r=W(e,r),e[r]!==":"){e[r]==="("&&(r=bn(e,r,"(",")"));continue}let l=Q(e,r+1);if(!l)return null;o.push({key:i,at:a,value:l.val}),r=l.end}return null}let s=t;if(n==="."||n==="-"||/\d/.test(n)){let r=t+1;for(;r<e.length&&/[\d.]/.test(e[r]);)r++;let o=e.slice(t,r);if(/^-?\d+(?:\.\d+)?$/.test(o))return{val:{t:"num",v:Number(o),at:s},end:r};for(;r<e.length&&/[\w$.+-]/.test(e[r]);)r++;return{val:{t:"other",at:s},end:r}}if(/[\w$]/.test(n)){let r=t;for(;r<e.length&&/[\w$]/.test(e[r]);)r++;let o=e.slice(t,r),i=W(e,r);if(e[i]==="("){if(dl.has(o)){let a=hl(e,i);return a?{val:{t:"str",v:a.v,at:s},end:a.end}:null}return{val:{t:"other",at:s},end:bn(e,i,"(",")")}}return o==="true"||o==="false"?{val:{t:"bool",v:o==="true",at:s},end:r}:{val:{t:"other",at:s},end:i}}return null}function ht(e){if(e.t==="str")return e.v;if(e.t==="arr"){let t=[];for(let n of e.items){if(n.t!=="str"||n.v===null)return null;t.push(n.v)}return t.join(" ")}return null}function _r(e){let t=[],n="",s=0;for(let r of e)r==="["?s++:r==="]"&&(s=Math.max(0,s-1)),/\s/.test(r)&&s===0?(n&&t.push(n),n=""):(!/\s/.test(r)||s>0)&&(n+=r);return n&&t.push(n),t}var mn={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function bl(e,t,n,s){let r=fl[e];if(r)return t.includes(r)||t.push(r),!0;if(e==="dark")return s.on=!0,!0;if(mn[e])return n.min.push(mn[e]),!0;let o=/^max-(sm|md|lg|xl|2xl)$/.exec(e);if(o)return n.below.push(mn[o[1]]),!0;let i=/^min-\[([\d.]+(?:px|rem|em))\]$/.exec(e);if(i)return n.min.push(i[1]),!0;let a=/^max-\[([\d.]+(?:px|rem|em))\]$/.exec(e);return a?(n.max.push(a[1]),!0):!1}function yl(e,t){let n=[];for(let s of e.min)n.push(`(min-width: ${s})`);for(let s of e.max)n.push(`(max-width: ${s})`);for(let s of e.below)n.push(`not all and (min-width: ${s})`);return t&&n.push("(prefers-color-scheme: dark)"),n.length?`@media ${n.join(" and ")}`:""}function Er(e){let t=e.trim();if(!t)return null;let n=!1;t.startsWith("!")&&(n=!0,t=t.slice(1)),t.endsWith("!")&&(n=!0,t=t.slice(0,-1));let s=[],r="",o=0;for(let f of t)f==="["?o++:f==="]"&&(o=Math.max(0,o-1)),f===":"&&o===0?(s.push(r),r=""):r+=f;s.push(r);let i=s.pop()??"";if(!i)return null;let a=[],l={min:[],max:[],below:[]},c={on:!1};for(let f of s)if(!f||!bl(f,a,l,c))return null;a.sort((f,m)=>H(f)-H(m));let u=/^[\w-]+$/.test(i)?i:null;return{token:e,state:ge(a),context:yl(l,c.on),utility:i,important:n,stem:u}}function Ir(e){let t=Rr(e.utility);return t?t.map(n=>({property:n.property,value:e.important?`${n.value} !important`:n.value,via:e.token})):[]}function xl(e){return e.some(t=>Ue(t.property)!=="hint")}function bt(e){let t=[];for(let n of e.matchAll(/@apply\s+([^;{}]+)/g))for(let s of _r(n[1])){let r=Er(s);if(!r)continue;let o=Ir(r).filter(i=>ne(i.property,i.value));o.length!==0&&t.push({state:r.state,context:r.context,declarations:o})}return t}function jr(e){return e==="default"?"":e.split(" + ").map(t=>t==="hover"?":hover":t==="focus"?":focus":t==="active"?":active":t==="disabled"?":disabled":"").join("")}function kn(e,t,n){let s=t.map(f=>`${f.property}:${f.value}`).join(";");if(!s)return[];let r=Zt(e),o=`${r}{${s}}`,i=n.split(" \xB7 ").map(f=>f.trim()).filter(f=>f&&!/^@layer\b/i.test(f));if(i.length===0)return[o];if(i.length!==1||!i[0].startsWith("@media"))return[];let a=i[0],l=[`${a}{${o}}`];if(!a.includes("prefers-color-scheme: dark"))return l;let c=a.replace(/^@media\s+/,"").split(/\s+and\s+/).filter(f=>!f.includes("prefers-color-scheme")).join(" and "),u=`html[data-theme="dark"] ${r}{${s}}`;return l.push(c?`@media ${c}{${u}}`:u),l}function kl(e,t){let n=e.slice(Math.max(0,t-160),t);return/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:await\s+)?$/.exec(n)?.[1]??null}function wl(e){if(e.t!=="obj")return{};let t=e.entries.find(s=>s.key==="defaultVariants")?.value;if(!t||t.t!=="obj")return{};let n={};for(let s of t.entries)s.value.t==="str"&&s.value.v?n[s.key]=s.value.v:s.value.t==="bool"&&(n[s.key]=s.value.v?"true":"false");return n}function vl(e,t,n,s,r){let o=Q(e,t),i={slots:[],defaults:{}};if(!o)return i;let a=ht(o.val)??"",l=W(e,o.end);if(e[l]!==",")return a.trim()?{slots:[hn(a,ce(e,t),r)],defaults:{}}:i;let c=Q(e,l+1);if(!c||c.val.t!=="obj")return a.trim()?{slots:[hn(a,ce(e,t),r)],defaults:{}}:i;let u=c.val.entries.find(b=>b.key==="variants")?.value,f=[],m=new Map;if(a.trim()&&f.push(hn(a,ce(e,t),r)),u&&u.t==="obj"){for(let b of u.entries)if(b.value.t==="obj")for(let w of b.value.entries){let $=ht(w.value);if(!$||!$.trim()||w.key==="false")continue;m.set(`${b.key}\0${w.key}`,$);let k=w.key==="true"?`.${b.key}`:`.${b.key}-${w.key}`,g=je({selector:k,path:s,base:!1},n.classKeywords);f.push({title:g.title,axis:w.key==="true"?b.key:g.axis??b.key,base:!1,classes:`${a} ${$}`.trim(),line:ce(e,w.at),group:r,prop:b.key,value:w.key})}}return f.push(...$l(c.val,a,m,n,s,e,r)),{slots:f,defaults:wl(c.val)}}function Lr(e){if(e.t==="str"&&e.v)return[e.v];if(e.t==="bool")return[e.v?"true":"false"];if(e.t==="arr"){let t=[];for(let n of e.items){let s=Lr(n);if(!s||s.length!==1)return null;t.push(s[0])}return t.length?t:null}return null}function $l(e,t,n,s,r,o,i){let a=e.entries.find(c=>c.key==="compoundVariants")?.value;if(!a||a.t!=="arr")return[];let l=[];for(let c of a.items){if(c.t!=="obj")continue;let u=[],f="",m=c.at,b=!1;for(let $ of c.entries){if($.key==="class"||$.key==="className"){f=ht($.value)??"",m=$.at,$.value.t!=="str"&&$.value.t!=="arr"&&f===""&&(b=!0);continue}let k=Lr($.value);if(!k){b=!0;break}u.push({axis:$.key,values:k})}if(b)continue;let w=[[]];for(let $ of u){let k=[];for(let g of w){for(let p of $.values)if(k.push([...g,{axis:$.axis,value:p}]),k.length>=8)break;if(k.length>=8)break}w=k}for(let $ of w){if($.length<2&&!f.trim())continue;let k=[t],g=[];for(let y of $){let v=n.get(`${y.axis}\0${y.value}`);v&&k.push(v),g.push(y.value==="true"?y.axis:y.value)}f.trim()&&k.push(f);let p=k.join(" ").replace(/\s+/g," ").trim();if(!p)continue;let d=je({selector:`.${g.join("-")}`,path:r,base:!1},s.classKeywords);l.push({title:d.title,axis:d.axis,base:!1,classes:p,line:ce(o,m),group:i,when:$.map(y=>({prop:y.axis,value:y.value}))})}}return l}function hn(e,t,n){return{title:"Base",axis:null,base:!0,classes:e,line:t,group:n}}function Pr(e,t){return t.elements.includes(e.toLowerCase())?!0:t.identifier.test(e)}function Cl(e){let t=e.match(/\bclassName\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*"([^"]*)"\s*\}|\{\s*'([^']*)'\s*\})/);return t?.[1]??t?.[2]??t?.[3]??t?.[4]??null}var Sl=new Set(["opacity","z-index","font-weight","line-height","flex","flex-grow","flex-shrink","order","zoom"]);function Rl(e){return e.replace(/^[A-Z]/,t=>`-${t.toLowerCase()}`).replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Al(e,t){return t.t==="str"?t.v:t.t==="num"?Sl.has(e)?String(t.v):`${t.v}px`:null}function yt(e,t){if(e.t!=="obj")return[];let n=[],s=[];for(let o of e.entries){if(o.value.t==="obj"){let l=o.key.replace(/^&/,""),c=l===":hover"?"hover":l===":focus"||l===":focus-visible"?"focus":l===":active"?"active":l===":disabled"?"disabled":null;c&&s.push(...yt(o.value,c));continue}let i=Rl(o.key),a=Al(i,o.value);!a||!ne(i,a)||n.push({property:i,value:a,via:"style"})}return[...n.length?[{state:t,context:"",declarations:n}]:[],...s]}function yn(e,t){if(e[t]!=="`")return null;let n="";for(let s=t+1;s<e.length;s++){let r=e[s];if(r==="\\"){let o=e[s+1];if(o===void 0)return null;n+=o==="n"?`
47
+ `:o,s++;continue}if(r==="$"&&e[s+1]==="{"){let o=1;for(s+=2;s<e.length&&o>0;s++)e[s]==="{"?o++:e[s]==="}"&&o--;s--,n+=" ";continue}if(r==="`")return{css:n,end:s+1};n+=r}return null}function _l(e,t){if(e==="default")return t;if(t==="default")return e;let n=[...new Set([...e.split(" + "),...t.split(" + ")])];return n.sort((s,r)=>H(s)-H(r)||s.localeCompare(r)),ge(n)}function xn(e){let t=[];for(let n of be(`.__gs {
48
+ ${e}
49
+ }`)){let s=X(n.selector),r=s?.[s.length-1];if(!r)continue;let o=it(r.simples),i=ge(o.states),a=le(n.ownBody).filter(l=>ne(l.property,l.value));a.length&&t.push({state:i,context:n.context,declarations:a});for(let l of bt(n.ownBody))t.push({state:_l(i,l.state),context:[n.context,l.context].filter(Boolean).join(" \xB7 "),declarations:l.declarations})}return t}function El(e){let t=e.match(/\bstyle\s*=\s*"([^"]*)"/);if(t){let i=le(t[1]).filter(a=>ne(a.property,a.value));return i.length?[{state:"default",context:"",declarations:i}]:[]}let n=e.search(/\bstyle\s*=\s*\{/);if(n<0)return[];let s=e.indexOf("{",n),r=W(e,s+1);e[r]==="{"&&(s=r);let o=Q(e,s);return o?yt(o.val,"default"):[]}function Il(e){let t=Cl(e);if(t)return{classes:t,painted:[]};let n=e.search(/\bclassName\s*=\s*\{/);if(n<0)return{classes:"",painted:[]};let s=e.indexOf("{",n),r=W(e,s+1);if(e.startsWith("css",r)&&!/[\w$]/.test(e[r+3]??"")){let i=W(e,r+3);if(e[i]==="`"){let a=yn(e,i);return{classes:"",painted:a?xn(a.css):[]}}if(e[i]==="("){let a=Q(e,i+1);return{classes:"",painted:a?yt(a.val,"default"):[]}}}let o=Q(e,r);return o?{classes:ht(o.val)??"",painted:[]}:{classes:"",painted:[]}}function jl(e,t){if(t.identifier.test(e))return!0;let n=e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return t.classKeywords.some(s=>n.includes(s.toLowerCase()))}function Ll(e,t){let n=[],s=/(?:^|[^\w$])styled(?:\.([A-Za-z][\w]*)|\(\s*(?:["']([A-Za-z][\w]*)["']|([A-Za-z][\w]*))\s*\))/g;for(let o of e.matchAll(s)){let i=o[1]??o[2]??o[3]??"";if(!Pr(i,t))continue;let a=W(e,(o.index??0)+o[0].length);e.startsWith(".attrs",a)&&(a=W(e,a+6),e[a]==="("&&(a=bn(e,a,"(",")")),a=W(e,a));let l=[];if(e[a]==="`"){let c=yn(e,a);c&&(l=xn(c.css))}else if(e[a]==="("){let c=Q(e,a+1);c&&(l=yt(c.val,"default"))}l.length!==0&&n.push({title:"Styled",axis:null,base:!0,classes:"",line:ce(e,o.index??0),painted:l})}let r=/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*css\s*`/g;for(let o of e.matchAll(r)){let i=o[1]??"";if(!jl(i,t))continue;let a=e.indexOf("`",o.index??0),l=a<0?null:yn(e,a);if(!l)continue;let c=xn(l.css);c.length!==0&&n.push({title:"Css",axis:null,base:!0,classes:"",line:ce(e,o.index??0),painted:c})}return n}function Pl(e,t){if(t==="default")return`.${e}`;let n=`.${e}`;for(let s of t.split(" + "))s==="hover"?n+=":hover":s==="focus"?n+=":focus":s==="active"?n+=":active":s==="disabled"&&(n+=":disabled");return n}function Ml(e,t,n,s,r){let o=_r(e.classes).map(Er).filter(d=>d!==null),i=o.filter(d=>d.stem===null||!s.has(d.stem)),a=(e.painted??[]).filter(d=>d.declarations.length>0);if(i.length===0&&a.length===0)return null;let l=new Map,c=(d,y,v)=>{if(v.length===0)return;let x=`${d}\0${y}`,C=l.get(x)??{state:d,context:y,declarations:[]};C.declarations.push(...v),l.set(x,C)},u=[r];for(let d of o){let y=Ir(d).filter(v=>ne(v.property,v.value));c(d.state,d.context,y),d.state==="default"&&d.context===""&&d.stem&&u.push(d.stem)}for(let d of a)c(d.state,d.context,d.declarations);let f=[...l.values()].flatMap(d=>d.declarations);if(!xl(f))return null;let m=l.get("default\0")?.declarations??[];if(lt(m))return null;let b=[...l.values()].map(d=>({state:d.state,context:d.context,line:e.line,declarations:d.declarations})).sort((d,y)=>d.state!==y.state?d.state==="default"?-1:y.state==="default"?1:H(d.state.split(" + ")[0])-H(y.state.split(" + ")[0])||d.state.localeCompare(y.state):d.context===""?-1:y.context===""?1:d.context.localeCompare(y.context)),w=[...new Set(o.map(d=>d.stem).filter(d=>d!==null))],$=w.length?w.map(d=>`.${d}`).join(""):n.elements[0]??"button",k=b.flatMap(d=>kn(Pl(r,d.state),d.declarations,d.context)),g=n.elements[0]??"button";return{variant:{title:e.title,axis:e.axis,element:{tag:g,classes:u,attrs:{},ancestors:[]},usage:{status:"unknown",files:[],fileCount:0},selector:$,path:t,line:e.line,base:e.base,states:b},rules:k}}function Mr(e,t,n,s,r){let o=gl(t),i=[],a=[],l=/(?:^|[^\w$])(cva|tv)\s*\(/g;for(let p of o.matchAll(l)){let d=(p.index??0)+Math.max(0,p[0].indexOf(p[1])),y=(p.index??0)+p[0].length,v=a.length,x=vl(o,y,n,e,v);a.push({name:kl(o,d),defaults:x.defaults}),i.push(...x.slots)}i.push(...Ll(o,n));let c=/<([A-Za-z][\w.]*)\b([^>]*?)>/g;for(let p of o.matchAll(c)){let d=p[1];if(!Pr(d,n))continue;let y=p[2]??"",v=Il(y),x=[...v.painted,...El(y)],C=v.classes.trim();if(!C&&x.length===0)continue;let j=p.index??0,I=ce(o,j);i.push({title:C?"Base":v.painted.length?"Css":"Inline",axis:null,base:!0,classes:C,line:I,painted:x,...C&&x.length===0?{site:{path:e,line:I,offset:j}}:{}})}let u=[],f=[],m=new Map,b=[],w=new Map,$=new Map,k=r;for(let p=0;p<i.length;p++){let d=i[p];if(u.length+f.length>=pl)break;let y=(d.painted??[]).map(I=>`${I.state}|${I.context}|${I.declarations.map(A=>`${A.property}:${A.value}`).join(";")}`).join("||"),v=`${d.classes.replace(/\s+/g," ").trim()}##${y}`,x=w.get(v);if(x){d.group!==void 0&&$.set(p,x),d.site&&m.get(x)?.sites.push(d.site);continue}k+=1;let C=`__gs-recipe-${k}`,j=Ml(d,e,n,s,C);if(j){if(w.set(v,C),d.group!==void 0&&$.set(p,C),d.site){let I={variant:j.variant,sites:[d.site]};m.set(C,I),f.push(I)}else u.push(j.variant);b.push(...j.rules)}}let g=[];for(let p=0;p<a.length;p++){let d=a[p],y={path:e,name:d.name,staticClasses:[],axes:[],compounds:[]},v=new Map;for(let x=0;x<i.length;x++){let C=i[x];if(C.group!==p)continue;let j=$.get(x);if(!j)continue;if(!C.prop&&!C.when){y.staticClasses.push(j);continue}if(C.when){y.compounds.push({when:C.when,classes:[j]});continue}let I=v.get(C.prop)??[];I.push({value:C.value,classes:[j]}),v.set(C.prop,I)}for(let[x,C]of v)y.axes.push({prop:x,values:C,...d.defaults[x]?{defaultValue:d.defaults[x]}:{}});(y.staticClasses.length||y.axes.length||y.compounds.length)&&g.push(y)}return{variants:u,inline:f,previewRules:b,nextId:k,recipes:g}}function Or(e,t){let s=(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return t.some(r=>{let o=r.toLowerCase();return s.includes(o)||s.includes(`${o}s`)})}var wn=6,Ol=/"([^"\\\n]{0,400})"|'([^'\\\n]{0,400})'|`([^`\\]{0,400})`/g,Nl=/\bclass(?:Name)?\s*=\s*(?:"([^"]*)"|'([^']*)')/g,Dl=/\b(?:styles?|classes|css|cls|s)\.([A-Za-z_]\w*)/g,We=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Tl(e){let t=n=>n.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,t).replace(/<!--[\s\S]*?-->/g,t).replace(/(^|\s)\/\/[^\n]*/g,(n,s)=>s+t(n.slice(s.length)))}function Vl(e,t){let n=Tl(t),s=new Map,r=new Map,o=(a,l,c)=>{let u=a.get(l);u?u.push(c):a.set(l,[c])},i=(a,l)=>{for(let c of a.matchAll(/[\w-]+/g))o(s,c[0],l)};for(let a of n.matchAll(Ol))i(a[1]??a[2]??a[3]??"",a.index);for(let a of n.matchAll(Nl))i(a[1]??a[2]??"",a.index);for(let a of n.matchAll(Dl))o(r,a[1],a.index);return{path:e,text:n,original:t,words:s,ids:r}}function Nr(e,t){let n=1;for(let s=e.indexOf(`
50
+ `);s!==-1&&s<t;)n++,s=e.indexOf(`
51
+ `,s+1);return n}var Fl=e=>e.replace(/[-_]+(\w)/g,(t,n)=>n.toUpperCase()),Bl=/\[\s*([\w-]+)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*\]/g,Ul=new Set(["data-component","data-slot","role"]);function zl(e,t){return[...e.slice(me(e)).matchAll(Bl)].map(s=>({name:s[1],value:s[2]??s[3]??s[4]??null})).filter(s=>!Ul.has(s.name)&&!(s.value!==null&&t.has(s.value.toLowerCase())))}function Wl(e){return[...e.slice(me(e)).matchAll(/\.((?:\\.|[\w-])+)/g)].map(n=>n[1].replace(/\\(.)/g,"$1"))}function vn(e,t,n,s,r=!1,o=[],i=()=>null){let a=null,l=()=>a??=t.map(g=>Vl(g,e.get(g)??"")),c=new Map,u=g=>{let p=c.get(g);if(!p){let d=new RegExp(`["'\`]${We(g)}["'\`]\\s*\\+`);p=l().filter(y=>y.text.includes(`${g}\${`)||d.test(y.text)),c.set(g,p)}return p},f=(g,p,d)=>ur(rn(g.original,p,d,g.path),g.original,p,g.path,o,i),m=(g,p)=>({files:g.slice(0,wn).map(({file:d,offset:y,example:v})=>({path:d.path,line:Nr(d.text,y),...r?{example:v??f(d,y,p)}:{}})),fileCount:g.length}),b=(g,p)=>{let d=[],y=Fl(g);for(let v of l()){let x=[...s.has(g)?[]:v.words.get(g)??[],...v.ids.get(y)??v.ids.get(g)??[]],C=x[0];if(C===void 0)continue;let j=C,I;if(r)for(let A of x){let R=f(v,A,p);if(R.kind!=="other"){j=A,I=R;break}}d.push({file:v,offset:j,example:I})}if(d.length)return{status:"used",...m(d,p)};for(let v=g.length-1;v>0;v--){if(g[v]!=="-"&&g[v]!=="_")continue;let x=g.slice(0,v+1),C=g.slice(v+1),j=u(x);if(j.length===0||!C)continue;let I=x.slice(0,-1),A=new RegExp(`\\b${We(I)}\\s*[=:]\\s*\\{?\\s*["'\`]${We(C)}["'\`]`),R=[];for(let L of l()){let D=A.exec(L.text);D&&R.push({file:L,offset:D.index})}return R.length?{status:"used",via:`via ${I} prop`,...m(R,p)}:{status:"dynamic",via:`built as ${x}\${\u2026}`,...m(j.map(L=>({file:L,offset:0})),p)}}return{status:"unreferenced",files:[],fileCount:0}},w=(g,p)=>{let d=We(g.name),y=g.value===null?new RegExp(`\\b${d}\\b`):new RegExp(`\\b${d}\\s*[=:]\\s*\\{?\\s*["'\`]${We(g.value)}["'\`]`),v=[];for(let j of l()){let I=y.exec(j.text);I&&v.push({file:j,offset:I.index})}if(v.length)return{status:"used",via:`via ${g.name} attribute`,...m(v,p)};let x=new RegExp(`\\b${d}\\s*=\\s*\\{(?!\\s*["'\`])`),C=[];for(let j of l()){let I=x.exec(j.text);I&&C.push({file:j,offset:I.index})}return C.length?{status:"dynamic",via:`${g.name} is set from a variable`,...m(C,p)}:{status:"unreferenced",files:[],fileCount:0}},$=new Map;if(r&&o.length>0)for(let g of l())for(let p of gt(g.path,g.text,o,i))for(let d of p.selects){let y=$.get(d)??[];y.push({file:g,offset:p.offset}),$.set(d,y)}let k={used:0,unknown:0,dynamic:1,unreferenced:2};for(let g of n){let p=Wl(g.selector),d=zl(g.selector,s);if(p.length===0&&d.length===0){g.usage={status:"unknown",files:[],fileCount:0};continue}let y=[...p.map(A=>b(A,p)),...d.map(A=>w(A,p))];g.usage=y.reduce((A,R)=>k[R.status]>=k[A.status]?R:A);let v=g.element?.classes.find(A=>A.startsWith("__gs-recipe-")),x=v?$.get(v):void 0;if(!x||x.length===0)continue;let C=new Set(g.usage.files.map(A=>A.path)),j=g.usage.fileCount,I=[...g.usage.files];for(let A of x)C.has(A.file.path)||(C.add(A.file.path),j+=1,!(I.length>=wn)&&I.push({path:A.file.path,line:Nr(A.file.text,A.offset),...r?{example:f(A.file,A.offset,[])}:{}}));g.usage={...g.usage,status:g.usage.status==="unknown"?"unknown":"used",files:I,fileCount:j}}}function Dr(e,t,n){let s=[],r=new Set;for(let o of t)r.has(o.path)||(r.add(o.path),!(s.length>=wn)&&s.push({path:o.path,line:o.line,...n?{example:rn(e.get(o.path)??"",o.offset,[],o.path)}:{}}));return{status:"used",files:s,fileCount:r.size}}var Gl={id:"button",label:"Buttons",identifier:/^[A-Z][A-Za-z0-9]*Button[A-Za-z0-9]*$|^Button[A-Za-z0-9]*$/,elements:["button"],roles:["button"],classKeywords:["btn","button"],excludeClassKeywords:["switch","switcher"],prose:/\bbuttons?\b/i},zr={button:Gl},Wr=12,Cn=200,ye=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i,Tr=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?|mdx|erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,Ge=/\.(css|scss|sass|less|styl)$/i,Vr=/\.(mdx?|markdown|txt|rst|adoc)$/i,Fr=/(^|\/)(tokens?|design-tokens?|theme)[^/]*\.json$/i,J=/(^|\/)(__tests__|tests?|spec|e2e|cypress|playwright)(\/|$)|\.(test|spec)\.[a-z]+$/i,Hl=/(^|\/)(plans?|results?|changelogs?|history|archive)(\/|\.|$)|(^|\/)CHANGELOG/i;function Kl(e){return xt.test(e)&&!/(^|\/)README\.md$/i.test(e)?"instruction":Hl.test(e)?"record":"documentation"}var xt=/(^|\/)(AGENTS|CLAUDE|CONTRIBUTING|README|GUIDELINES?)\.md$|(^|\/)(eslint|stylelint|\.eslintrc|\.stylelintrc)[^/]*$|(^|\/)\.cursor\/|(^|\/)\.claude\//i;function ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jl(e){return(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"")}function Br(e,t){let n=Jl(e).toLowerCase();return t.some(s=>{let r=s.toLowerCase();return n===r||n===`${r}s`})}function Zl(e,t){let n=1;for(let s=0;s<t;s++)e.charCodeAt(s)===10&&n++;return n}function pe(e,t){let n=e.split(`
52
+ `),s=0,r=[];for(let o=0;o<n.length;o++){let i=n[o];if(t.lastIndex=0,!!t.test(i)&&(s++,r.length<Wr)){let a=i.trim();r.push({line:o+1,text:a.length>Cn?`${a.slice(0,Cn)}\u2026`:a})}}return{count:s,lines:r}}function Gr(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function Hr(e){let t=[];for(let n of e.split("/"))!n||n==="."||(n===".."?t.pop():t.push(n));return t.join("/")}var Xl=["",".tsx",".ts",".jsx",".js",".mjs",".vue",".svelte",".css",".module.css",".scss","/index.tsx","/index.ts","/index.js"];function xe(e,t,n){let s;if(t.startsWith("."))s=Hr(`${Gr(e)}/${t}`);else if(t.startsWith("@/"))s=t.slice(2);else if(t.startsWith("~/"))s=t.slice(2);else if(t.startsWith("/"))s=t.slice(1);else return null;for(let r of Xl)if(n(s+r))return s+r;return null}var ql=/import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\)|@import\s+(?:url\()?['"]([^'"]+)['"]/g;function $n(e){let t=[];for(let n of e.matchAll(ql)){let s=n[1]??n[2]??n[3];s&&t.push(s)}return t}var Yl=/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class|var)\s+([A-Za-z_$][\w$]*)|export\s*\{([^}]*)\}/g;function Ur(e){let t=new Set;for(let n of e.matchAll(Yl))if(n[1]&&t.add(n[1]),n[2])for(let s of n[2].split(",")){let r=s.trim().split(/\s+as\s+/).pop()?.trim();r&&t.add(r)}return[...t]}var Sn=/var\(\s*(--[\w-]+)/g;function kt(e){return e.split(" \xB7 ").every(t=>t===""||/^@layer\b/i.test(t))}function Kr(e){let t=[];for(let n of e.matchAll(/(?:^|[;{}])\s*composes\s*:\s*([^;]+)/g)){let s=n[1].trim(),r=/^(.*?)\s+from\s+(['"]?)([^'"]+)\2\s*$/.exec(s);r?t.push({names:r[1].split(/\s+/).filter(Boolean),from:r[3]}):t.push({names:s.split(/\s+/).filter(Boolean),from:null})}return t}function Ql(e,t,n){let s=t.startsWith(".")?Hr(`${Gr(e)}/${t}`):t.startsWith("@/")?t.slice(2):t.startsWith("~/")||t.startsWith("/")?t.replace(/^~?\//,""):null;return s&&n(s)?s:xe(e,t.replace(/\.(?:module\.)?(?:css|scss|sass|less)$/i,""),n)}function ec(e){let t=new Map;for(let[n,s]of e)if(Ge.test(n)){for(let r of be(s))if(kt(r.context))for(let o of z(r.selector)){let i=/^\.([\w-]+)$/.exec(o.trim())?.[1];if(!i)continue;let a=`${n}\0${i}`,l=t.get(a)??{decls:[],composes:[]};l.decls.push(...le(r.ownBody));for(let c of bt(r.ownBody))c.state==="default"&&c.context===""&&l.decls.push(...c.declarations);l.composes.push(...Kr(r.ownBody)),t.set(a,l)}}return t}function tc(e,t,n,s){let r=[],o=new Set,i=(l,c,u)=>{if(u>4)return;let f=`${l}\0${c}`;if(o.has(f))return;o.add(f);let m=n.get(f);if(m){for(let b of m.composes)a(l,b,u+1);r.push(...m.decls)}},a=(l,c,u)=>{for(let f of c.names)if(c.from==="global")for(let m of n.keys()){let b=m.indexOf("\0"),w=m.slice(0,b);m.slice(b+1)!==f||/\.module\./i.test(w)||i(w,f,u)}else if(c.from){let m=Ql(l,c.from,s);m&&i(m,f,u)}else i(l,f,u)};for(let l of Kr(t))a(e,l,0);return r}function nc(e,t){let n=jr(t);return n?z(e).map(s=>{let r=Math.max(s.lastIndexOf(" "),s.lastIndexOf(">"),s.lastIndexOf("+"),s.lastIndexOf("~"));return r<0?`${s}${n}`:`${s.slice(0,r+1)}${s.slice(r+1)}${n}`}).join(", "):e}var sc=/^(?::root|html|body|\*)$/i,rc=25e4,oc=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,ic=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,ac=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]);function lc(e){let t=new Set,n=new Set;for(let s of e.matchAll(oc)){let r=s[1],o=ac.has(r.toLowerCase())&&r===r.toLowerCase()?t:n;for(let i of s[2].matchAll(ic))o.add(i[1]??i[2])}return{parts:new Set([...t].filter(s=>!n.has(s))),controls:n}}function cc(e,t){let n=new Map;for(let s of t)if(Ge.test(s)){for(let r of be(e.get(s)))if(kt(r.context)&&z(r.selector).some(o=>sc.test(o)))for(let o of le(r.ownBody))o.property.startsWith("--")&&!n.has(o.property)&&n.set(o.property,o.value)}return n}function uc(e,t){let n=new Set,s=[],r=a=>{for(let l of a.matchAll(Sn))n.has(l[1])||(n.add(l[1]),s.push(l[1]))};for(let a of t)r(a);let o=[];for(let a=s.shift();a;a=s.shift()){let l=e.get(a);l===void 0||!ne(a,l)||(o.push(`${a}:${l}`),r(l))}return`${o.length?`:root{${o.join(";")}}
53
+ `:""}${t.join(`
54
+ `)}`.slice(0,rc)}function Jr(e,t){let n=[...e.keys()].sort(),s=h=>e.has(h),r=new Map,o=(h,S,_,P)=>{let O=`${S}:${h}`,F=r.get(O);if(F){F.note.includes(_)||(F.note+=`; ${_}`);return}r.set(O,{path:h,role:S,note:_,matches:P.count,lines:P.lines})},i=new Set,a=new Set;for(let h of n){if(!ye.test(h)||J.test(h))continue;let S=e.get(h),_=Ur(S).filter(M=>t.identifier.test(M)),P=h.split("/").pop()??"",O=new RegExp(t.classKeywords.join("|"),"i").test(P);if(_.length===0&&!O)continue;for(let M of _)i.add(M);a.add(h);let F=_.length?new RegExp(`\\b(?:${_.map(ue).join("|")})\\b`,"g"):t.prose;o(h,"implements",_.length?`exports ${_.join(", ")}`:"named for the concept",pe(S,F))}let l=new Set,c=[],u=[],f=new Map,m=h=>Br(h,t.classKeywords)||/\.module\.[a-z]+$/i.test(h)&&f.has(h),b=null,w=()=>b??=ec(e),$=h=>{let S=m(h),_=[],P=0;for(let M of be(e.get(h))){let B=z(M.selector).filter(N=>ze(N,t,S));if(B.length===0)continue;P+=1;for(let N of M.ownBody.matchAll(Sn))l.add(N[1]);let U=bt(M.ownBody),re=[...tc(h,M.ownBody,w(),s),...le(M.ownBody),...U.filter(N=>N.state==="default"&&N.context==="").flatMap(N=>N.declarations)];for(let N of re)for(let K of N.value.matchAll(Sn))l.add(K[1]);_.push({block:M,parts:B,declarations:re,previewContext:kt(M.context)?"":null,listed:!0});for(let N of U){if(N.state==="default"&&N.context==="")continue;let K=nc(B.join(", "),N.state),Oe=z(K).filter(Mo=>ze(Mo,t,S));if(Oe.length===0)continue;let Po=[M.context,N.context].filter(Boolean).join(" \xB7 ");_.push({block:{...M,selector:K,context:Po},parts:Oe,declarations:N.declarations,previewContext:kt(M.context)?N.context:null,listed:!1})}}let O={parts:new Set,controls:new Set};for(let M of f.get(h)??[]){let B=lc(e.get(M)??"");for(let U of B.parts)O.parts.add(U);for(let U of B.controls)O.controls.add(U)}c.push(...vr(h,_.map(({block:M,parts:B,declarations:U})=>({selector:B.join(", "),declarations:U,line:M.line,context:M.context})),t,S,O));let F=/\.module\.[a-z]+$/i.test(h)?`${Us(h)} `:"";for(let{parts:M,declarations:B,previewContext:U}of _){if(U===null)continue;let re=M.flatMap(K=>{let Oe=ze(K,t,S);return Oe?[`${F}${Be(Oe.compounds)}`]:[]}),N=B.filter(K=>ne(K.property,K.value));if(!(re.length===0||N.length===0))for(let K of re)u.push(...kn(K,N,U))}return{count:P,lines:_.filter(M=>M.listed).slice(0,Wr).map(({block:M})=>({line:M.line,text:M.selector.replace(/\s+/g," ").slice(0,Cn)}))}},k=new Map;for(let h of a)for(let S of $n(e.get(h))){let _=xe(h,S,s);if(_&&Ge.test(_)){let P=k.get(_)??[];P.push(h.split("/").pop()??h),k.set(_,P),Br(h,t.classKeywords)&&f.set(_,[...f.get(_)??[],h])}}for(let h of n){if(!Ge.test(h))continue;let S=$(h),_=k.get(h);if(S.count===0)continue;let P=[];_&&P.push(`imported by ${_.join(", ")}`),S.count>0&&P.push(`${S.count} matching rule${S.count===1?"":"s"}`),o(h,"styles",P.join("; "),S)}let g=new Set;for(let h of c)for(let S of h.selector.matchAll(/\.((?:\\.|[\w-])+)/g))g.add(S[1].replace(/\\(.)/g,"$1"));let p=new Set(a),d=new RegExp([...t.elements.map(h=>`<${ue(h)}\\b`),...t.roles.map(h=>`role=["']${ue(h)}["']`)].join("|"));for(let h of n)!ye.test(h)||J.test(h)||d.test(e.get(h)??"")&&p.add(h);for(let h of a)for(let S of $n(e.get(h))){let _=xe(h,S,s);!_||!ye.test(_)||J.test(_)||Or(_,t.classKeywords)&&p.add(_)}let y=0,v=[],x=[];for(let h of p){let S=Mr(h,e.get(h)??"",t,g,y);y=S.nextId,v.push(...S.recipes),c.push(...S.variants),x.push(...S.inline),u.push(...S.previewRules)}let C=zn(x);c.push(...C.variants);let j=pr([...a].map(h=>({path:h,source:e.get(h)??"",names:Ur(e.get(h)??"").filter(S=>t.identifier.test(S))})),v,(h,S)=>xe(h,S,s)),I=[];if(l.size>0){let h=new RegExp(`(?:^|[\\s{;])(${[...l].map(ue).join("|")})\\s*:`),S=new Map;for(let _ of n){if(!Ge.test(_)&&!Fr.test(_))continue;let P=e.get(_),O=pe(P,h);if(O.count!==0){for(let F of P.matchAll(new RegExp(h.source,"gm"))){let M=S.get(F[1])??[];M.includes(_)||M.push(_),S.set(F[1],M)}o(_,"tokens",`defines ${O.count} token${O.count===1?"":"s"} read by ${t.label.toLowerCase()} styles`,O)}}for(let _ of[...l].sort())I.push({name:_,definedIn:S.get(_)??[]})}for(let h of n){if(!Fr.test(h))continue;let S=pe(e.get(h),t.prose);S.count>0&&o(h,"tokens","token file mentions the concept",S)}let A=[...i],R=new RegExp([...A.length?[`<(?:${A.map(ue).join("|")})\\b`]:[],...t.elements.map(h=>`<${ue(h)}\\b`),...t.roles.map(h=>`role=["']${ue(h)}["']`)].join("|"));for(let h of n){if(!ye.test(h)||a.has(h))continue;let S=e.get(h),_=J.test(h),P=pe(S,R),O=$n(S).some(M=>{let B=xe(h,M,s);return B!=null&&a.has(B)});if(P.count===0&&!O)continue;let F=P.count>0?`${P.count} render${P.count===1?"":"s"}`:"imports a button component";o(h,_?"tests":"uses",F,P.count?P:pe(S,t.prose))}for(let h of n){if(!(Vr.test(h)||xt.test(h)))continue;let _=e.get(h),P=pe(_,t.prose);P.count!==0&&o(h,J.test(h)?"tests":"describes",xt.test(h)?"repo rules / instructions":"documentation",P)}for(let h of n){if(!J.test(h)||r.has(`tests:${h}`)||!ye.test(h))continue;let S=pe(e.get(h),t.prose);S.count>0&&o(h,"tests","mentions the concept",S)}let L=[...r.values()].sort((h,S)=>S.matches-h.matches||h.path.localeCompare(S.path)),D={implements:0,styles:0,tokens:0,uses:0,describes:0,tests:0};for(let h of L)D[h.role]++;let G=$r(c);vn(e,n.filter(h=>Tr.test(h)&&!J.test(h)),G,new Set(t.elements),!0,j,(h,S)=>xe(h,S,s)),vn(e,n.filter(h=>Tr.test(h)&&!J.test(h)),G.flatMap(h=>h.modifiers??[]),new Set(t.elements));for(let[h,S]of C.sites)h.usage=Dr(e,S,!("alike"in h));let Z=cc(e,n),Ze=[];if(i.size>0){let h=new RegExp(t.elements.map(S=>`<${ue(S)}\\b`).join("|"),"g");for(let S of n){if(!ye.test(S)||J.test(S)||a.has(S))continue;let _=e.get(S),P=(_.match(h)??[]).length;if(P===0)continue;let O=pe(_,new RegExp(h.source));Ze.push({path:S,line:O.lines[0]?.line??1,count:P})}}let Tn=[],Vn=new Set;for(let h of n){if(!ye.test(h)||J.test(h))continue;let S=e.get(h),_=gt(h,S,j,(P,O)=>xe(P,O,s));for(let P of _)for(let O of P.unknown){let F=[...O.known].sort();if(O.cls!==void 0){if(g.has(O.cls))continue;let U=O.cls.slice(0,O.cls.length-O.value.length),re=[...g].filter(N=>N.startsWith(U)&&N.length>U.length).map(N=>N.slice(U.length));if(re.length===0)continue;F=[...new Set([...O.known,...re])].sort()}if(F.length===0)continue;let M=Zl(S,P.offset),B=`${h}\0${P.component}\0${O.prop}\0${O.value}`;Vn.has(B)||(Vn.add(B),Tn.push({path:h,line:M,component:P.component,prop:O.prop,value:O.value,known:F}))}}let jo=n.filter(h=>(Vr.test(h)||xt.test(h))&&!J.test(h)).map(h=>({path:h,kind:Kl(h)}));G.sort((h,S)=>Number(S.base)-Number(h.base)||h.path.localeCompare(S.path)||h.line-S.line);let Fn=hr(e,jo,t,G),Lo=gr([...f.entries()].map(([h,S])=>({sheet:h,sources:S.map(_=>e.get(_)??""),rules:be(e.get(h)??"").map(_=>({selector:_.selector,declarations:le(_.ownBody)}))})));return{components:A.sort(),tokens:I,findings:L,variants:G,audit:Xs({variants:G,tokens:I,tokenValues:Z,hasComponent:i.size>0,nativeUses:Ze,unknownProps:Tn,guidance:Fn,noun:t.label.toLowerCase(),element:t.elements[0]??t.id}),guidance:Fn,content:Lo,previewCss:uc(Z,u),counts:D}}import{execFileSync as fc}from"node:child_process";import{readdirSync as dc,readFileSync as gc,statSync as mc}from"node:fs";import wt from"node:path";function ke(e,t){try{return fc("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch{return null}}function Rn(e,t=""){let s=ke(e,["rev-parse","--show-toplevel"])?.trim()||e;return{repoDir:s,root:Gt(t),stateDir:wt.join(s,".gruum")}}function vt(e){let t=wt.join(e.repoDir,e.root),n=new Map,s=new TextDecoder("utf-8",{fatal:!1}),r=0,o=0,i=!1,a=(l,c)=>{if(i)return;let u;try{u=dc(l).sort()}catch{return}for(let f of u){let m=c?`${c}/${f}`:f,b=wt.join(l,f),w;try{w=mc(b)}catch{continue}if(w.isDirectory()){zt(m)&&a(b,m);continue}if(!w.isFile())continue;if(!Wt(m,w.size)){o++;continue}let $=gc(b);if(_s($)){o++;continue}if(r+$.length>4e7){i=!0;return}r+=$.length,n.set(m,s.decode($))}};return a(t,""),{files:n,truncated:i,skipped:o}}function Zr(e,t){let n=ke(e.repoDir,["diff","--cached","--name-status","-z"]);if(n===null)return t;let s=js(n).map(({path:r,deleted:o})=>({path:r,content:o?null:ke(e.repoDir,["show",`:${r}`])}));return{...t,files:Is(t.files,s,e.root)}}function Xr(e){let t=ke(e.repoDir,["remote","get-url","origin"])?.trim()??"",n=st(t)??wt.basename(e.repoDir),s=ke(e.repoDir,["rev-parse","HEAD"])?.trim()||"working-tree";return{fullName:n,ref:s,rootPath:e.root,htmlUrl:n.includes("/")?`https://github.com/${n}`:""}}function qr(e){let t=ke(e.repoDir,["config","--get","core.hooksPath"])?.trim();return t||ke(e.repoDir,["rev-parse","--git-path","hooks"])?.trim()||null}function $t(e,t={}){let n=zr[t.concept??"button"],s=vt(e);return t.staged&&(s=Zr(e,s)),{concept:n.id,label:n.label,...Jr(s.files,n),repo:Xr(e),index:{files:s.files.size,truncated:s.truncated,skipped:s.skipped}}}function we(e,t,n={}){let s=$t(e,{concept:t.concept,...n});return{result:s,baseline:t,items:qn(s,t)}}import{mkdirSync as hc,readFileSync as bc,writeFileSync as yc}from"node:fs";import Le from"node:path";function Ct(e){try{return bc(e,"utf8")}catch{return null}}function St(e){let t=Ct(e);if(t===null)return null;try{return JSON.parse(t)}catch{return null}}function ve(e,t){hc(Le.dirname(e),{recursive:!0}),yc(e,t)}function $e(e,t){ve(e,`${JSON.stringify(t,null,2)}
55
+ `)}var He=e=>Le.join(e.stateDir,"baseline.json"),Yr=e=>Le.join(e.stateDir,"drift.json"),An=e=>Le.join(e.stateDir,"exceptions.json"),xc=e=>Le.join(e.stateDir,"config.json");function fe(e,t){return qe(St(t?Le.resolve(t):He(e)))}function Rt(e){return es(St(Yr(e)),new Date().toISOString())}function _n(e,t){$e(Yr(e),t)}function kc(e){if(!e||typeof e!="object")return{};let t={};for(let[n,s]of Object.entries(e))(s==="pending"||s==="accepted"||s==="rejected")&&(t[n]=s);return t}function At(e){return kc(St(An(e)))}function En(e){let t=St(xc(e)),n=Array.isArray(t?.denyGit)?t.denyGit.filter(r=>r==="commit"||r==="push"):Ce.denyGit,s=typeof t?.maxFollowups=="number"&&t.maxFollowups>=0?Math.floor(t.maxFollowups):Ce.maxFollowups;return{...typeof t?.root=="string"?{root:t.root}:{},hooks:{...Ce,denyGit:n,maxFollowups:s}}}import{chmodSync as Sc,mkdirSync as Rc,readFileSync as fo,writeFileSync as Ac}from"node:fs";import{hostname as _c,homedir as Ec}from"node:os";import Ln from"node:path";import{createInterface as go}from"node:readline/promises";function Qr(e){return`/v2/projects/${encodeURIComponent(e)}`}function eo(e,t){if(e.length===0)return null;if(e.length===1)return e[0];let n=t.replace(/^\/+|\/+$/g,""),s=e.filter(r=>r.rootPath===n);if(s.length===1)return s[0];if(!n){let r=e.filter(o=>o.rootPath==="");if(r.length===1)return r[0]}return null}function to(e){if(typeof e!="string")return{error:"Send a URL."};let t=e.trim();if(!t)return{error:"Enter a live URL."};if(!/^https:\/\//i.test(t))return{error:"URL must start with https://"};let n;try{n=new URL(t)}catch{return{error:"That doesn\u2019t look like a URL."}}if(n.protocol!=="https:")return{error:"URL must start with https://"};if(n.username||n.password)return{error:"That doesn\u2019t look like a URL."};let s=n.hostname.toLowerCase().replace(/^www\./,"");return!s||!s.includes(".")?{error:"That doesn\u2019t look like a URL."}:s==="localhost"||s==="127.0.0.1"?{error:"Public hosts only for Live URL (localhost needs the extension later)."}:{value:s}}var wc="http://localhost:3000",vc=/(^|\.)(github\.com|githubusercontent\.com|gitlab\.com|bitbucket\.org|npmjs\.com|npmjs\.org|unpkg\.com|jsdelivr\.net|googleapis\.com|gstatic\.com|google\.com|schema\.org|w3\.org|mozilla\.org|wikipedia\.org|example\.com|example\.org|sentry\.io|vercel\.com|cloudflare\.com|amazonaws\.com)$/i;function no(e){return`https://${(e.split("/").pop()||e).toLowerCase().replace(/\.git$/,"").replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"")||"example"}.com`}function so(e){return`
56
56
  Live URL for this repo.
57
- For example: ${mc} or ${t}.
57
+ For example: ${wc} or ${e}.
58
58
  You may not use wildcards.
59
59
 
60
- URL: `}function so(t){let e=/https:\/\/[^\s"'<>)\]]+/gi;for(let n of t.matchAll(e)){let s;try{s=new URL(n[0])}catch{continue}let r=s.hostname.toLowerCase();if(!(!r.includes(".")||r.includes("*"))&&!(r==="localhost"||r==="127.0.0.1")&&!hc.test(r))return`https://${r}`}return null}function bc(t){let e=t.toLowerCase().replace(/:\d+$/,"");return e==="localhost"||e==="127.0.0.1"}function ro(t){if(typeof t!="string")return{error:"Enter a live URL."};let e=t.trim();if(!e)return{error:"Enter a live URL."};if(e.includes("*"))return{error:"You may not use wildcards."};let n=yc(e);return n||to(e)}function yc(t){let e=/^https?:\/\//i.test(t)?t:`http://${t}`,n;try{n=new URL(e)}catch{return null}let s=n.hostname.toLowerCase();if(s!=="localhost"&&s!=="127.0.0.1")return null;if(n.username||n.password)return{error:"That doesn\u2019t look like a URL."};let r=n.port;return{value:r&&r!=="80"&&r!=="443"?`${s}:${r}`:s}}function oo(t){return bc(t)?`http://${t}`:`https://${t}`}import{spawnSync as Sc}from"node:child_process";var Mt="https://app.getgruum.com",lo=()=>In.join($c(),".config","gruum","credentials.json");function co(){let t=process.env.GRUUM_TOKEN?.trim();if(t)return{token:t,apiOrigin:process.env.GRUUM_API_ORIGIN?.trim()||Mt};try{let e=JSON.parse(ao(lo(),"utf8"));return typeof e.token!="string"||!e.token?null:{token:e.token,apiOrigin:typeof e.apiOrigin=="string"&&e.apiOrigin?e.apiOrigin:Mt}}catch{return null}}function Rc(t){let e=lo();kc(In.dirname(e),{recursive:!0}),wc(e,`${JSON.stringify(t,null,2)}
61
- `,{mode:384}),xc(e,384)}function Ln(t){return(t?.apiOrigin||Mt).replace(/\/$/,"")}async function st(t,e,n={}){let s=new Headers(n.headers);return t&&s.set("Authorization",`Bearer ${t.token}`),n.body&&!s.has("Content-Type")&&s.set("Content-Type","application/json"),fetch(`${Ln(t)}${e}`,{...n,headers:s})}function Mn(t,e){let n=Sc("git",e,{cwd:t,encoding:"utf8"});return n.status!==0?null:n.stdout.trim()||null}function Ac(t){let e=Mn(t,["remote","get-url","origin"]);return e?se(e):null}function _e(t){let e=Mn(t,["rev-parse","--abbrev-ref","HEAD"]);return e&&e!=="HEAD"?e:""}function uo(t){return Mn(t,["rev-parse","HEAD"])}function po(t){return In.join(t.stateDir,"project.json")}function _c(t){try{let e=JSON.parse(ao(po(t),"utf8"));return typeof e.id!="string"||typeof e.repo!="string"||!("host"in e)?null:{id:e.id,name:typeof e.name=="string"?e.name:e.repo,repo:e.repo,rootPath:typeof e.rootPath=="string"?e.rootPath:"",host:typeof e.host=="string"&&e.host?e.host:null,hostDeclined:e.hostDeclined===!0}}catch{return null}}function fo(t,e){return`${t}${Yr(e)}`}function io(t,e,n){let s=fo(t,e.id);process.stderr.write(n?`Created a Gruum project for ${e.repo}.
62
- ${s}
63
- `:`Gruum project: ${s}
64
- `)}function Ec(t,e){let n=ve(t);for(let s of n.files.values()){let r=so(s);if(r)return r}return eo(e)}async function jc(t,e){let n=no(Ec(t,e)),s=Cc({input:process.stdin,output:process.stderr});try{for(;;){let r=(await s.question(n)).trim(),o=ro(r);if("error"in o){process.stderr.write(`gruum: ${o.error}
65
- `);continue}return o.value}}finally{s.close()}}async function go(){let t=`Cursor on ${vc()}`,e=await st(null,"/api/cli/pair/start",{method:"POST",body:JSON.stringify({label:t})});if(!e.ok)return process.stderr.write(`gruum: couldn't start sign-in (${e.status}). Is Gruum running at ${Mt}?
66
- `),1;let n=await e.json(),s=`${Mt}/extension/connect?code=${encodeURIComponent(n.userCode)}`;process.stdout.write(`Sign in to Gruum to connect this CLI.
60
+ URL: `}function ro(e){let t=/https:\/\/[^\s"'<>)\]]+/gi;for(let n of e.matchAll(t)){let s;try{s=new URL(n[0])}catch{continue}let r=s.hostname.toLowerCase();if(!(!r.includes(".")||r.includes("*"))&&!(r==="localhost"||r==="127.0.0.1")&&!vc.test(r))return`https://${r}`}return null}function $c(e){let t=e.toLowerCase().replace(/:\d+$/,"");return t==="localhost"||t==="127.0.0.1"}function oo(e){if(typeof e!="string")return{error:"Enter a live URL."};let t=e.trim();if(!t)return{error:"Enter a live URL."};if(t.includes("*"))return{error:"You may not use wildcards."};let n=Cc(t);return n||to(t)}function Cc(e){let t=/^https?:\/\//i.test(e)?e:`http://${e}`,n;try{n=new URL(t)}catch{return null}let s=n.hostname.toLowerCase();if(s!=="localhost"&&s!=="127.0.0.1")return null;if(n.username||n.password)return{error:"That doesn\u2019t look like a URL."};let r=n.port;return{value:r&&r!=="80"&&r!=="443"?`${s}:${r}`:s}}function io(e){return $c(e)?`http://${e}`:`https://${e}`}function ao(e,t){let n=e.filter(r=>r.workspaces.length>0);if(n.length===0)return{step:"none"};if(t){let r=n.find(o=>o.id===t);if(!r)return{step:"none"};if(r.workspaces.length===1){let o=r.workspaces[0];return{step:"use",workspaceId:o.id,orgName:r.name,workspaceName:o.name}}return{step:"workspace",orgName:r.name,workspaces:r.workspaces}}if(n.reduce((r,o)=>r+o.workspaces.length,0)===1){let r=n[0],o=r.workspaces[0];return{step:"use",workspaceId:o.id,orgName:r.name,workspaceName:o.name}}if(n.length===1){let r=n[0];return{step:"workspace",orgName:r.name,workspaces:r.workspaces}}return{step:"org",orgs:n.map(r=>({id:r.id,name:r.name}))}}function In(e,t,n){let s=t.map((r,o)=>` ${o+1} ${r.name}`);return`
61
+ ${e}
62
+ ${s.join(`
63
+ `)}
64
+
65
+ Which ${n} should this project live in? `}function lo(e,t){let n=e.trim().toLowerCase();if(!n)return null;let s=Number(n);if(Number.isInteger(s)&&s>=1&&s<=t.length)return s-1;let r=t.flatMap((o,i)=>o.name.trim().toLowerCase()===n?[i]:[]);return r.length===1?r[0]:null}function co(e){return`/workspace/${encodeURIComponent(e)}`}import{spawnSync as Ic}from"node:child_process";var Pe="https://app.getgruum.com",mo=()=>Ln.join(Ec(),".config","gruum","credentials.json");function ho(){let e=process.env.GRUUM_TOKEN?.trim();if(e)return{token:e,apiOrigin:process.env.GRUUM_API_ORIGIN?.trim()||Pe};try{let t=JSON.parse(fo(mo(),"utf8"));return typeof t.token!="string"||!t.token?null:{token:t.token,apiOrigin:typeof t.apiOrigin=="string"&&t.apiOrigin?t.apiOrigin:Pe}}catch{return null}}function jc(e){let t=mo();Rc(Ln.dirname(t),{recursive:!0}),Ac(t,`${JSON.stringify(e,null,2)}
66
+ `,{mode:384}),Sc(t,384)}function Pn(e){return(e?.apiOrigin||Pe).replace(/\/$/,"")}async function ee(e,t,n={}){let s=new Headers(n.headers);return e&&s.set("Authorization",`Bearer ${e.token}`),n.body&&!s.has("Content-Type")&&s.set("Content-Type","application/json"),fetch(`${Pn(e)}${t}`,{...n,headers:s})}function Mn(e,t){let n=Ic("git",t,{cwd:e,encoding:"utf8"});return n.status!==0?null:n.stdout.trim()||null}function Lc(e){let t=Mn(e,["remote","get-url","origin"]);return t?st(t):null}function _t(e){let t=Mn(e,["rev-parse","--abbrev-ref","HEAD"]);return t&&t!=="HEAD"?t:""}function bo(e){return Mn(e,["rev-parse","HEAD"])}function yo(e){return Ln.join(e.stateDir,"project.json")}function Pc(e){try{let t=JSON.parse(fo(yo(e),"utf8"));return typeof t.id!="string"||typeof t.repo!="string"||!("host"in t)?null:{id:t.id,name:typeof t.name=="string"?t.name:t.repo,repo:t.repo,rootPath:typeof t.rootPath=="string"?t.rootPath:"",host:typeof t.host=="string"&&t.host?t.host:null,workspaceId:typeof t.workspaceId=="string"&&t.workspaceId?t.workspaceId:null,hostDeclined:t.hostDeclined===!0}}catch{return null}}function xo(e,t){return`${e}${Qr(t)}`}function uo(e,t,n,s){let r=xo(e,t.id),o=s?` in ${s}`:"",i=t.workspaceId?`${e}${co(t.workspaceId)}
67
+ `:"";process.stderr.write(n?`Created a Gruum project for ${t.repo}${o}.
68
+ ${i}${r}
69
+ `:`Gruum project: ${r}
70
+ ${i}`)}function Mc(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!="object")continue;let s=n;if(typeof s.id!="string"||typeof s.name!="string")continue;let r=Array.isArray(s.workspaces)?s.workspaces.flatMap(o=>{if(!o||typeof o!="object")return[];let i=o;return typeof i.id!="string"||typeof i.name!="string"?[]:[{id:i.id,name:i.name}]}):[];t.push({id:s.id,name:s.name,workspaces:r})}return t}async function po(e,t){let n=go({input:process.stdin,output:process.stderr});try{for(;;){let s=lo(await n.question(e),t);if(s!=null)return s;process.stderr.write(`gruum: enter one of the numbers.
71
+ `)}}finally{n.close()}}async function Oc(e,t){let n=await ee(e,"/api/v2/cli/workspaces");if(n.status===401)return process.stderr.write("gruum: sign-in expired. Run `npx @gruum/cli login` again.\n"),null;if(!n.ok)return process.stderr.write(`gruum: couldn't list workspaces (${n.status}).
72
+ `),null;let s=await n.json(),r=Mc(s.orgs),o=null;for(;;){let i=ao(r,o);if(i.step==="none")return{workspaceId:"",label:""};if(i.step==="use")return{workspaceId:i.workspaceId,label:`${i.orgName} / ${i.workspaceName}`};if(!t)return process.stderr.write("gruum: this account has more than one workspace. Run `npx @gruum/cli check` in a terminal and choose where the project should live.\n"),null;if(i.step==="org"){let c=await po(In("This account has more than one organization.",i.orgs,"organization"),i.orgs);o=i.orgs[c].id;continue}let a=await po(In(`${i.orgName} has more than one workspace.`,i.workspaces,"workspace"),i.workspaces),l=i.workspaces[a];return{workspaceId:l.id,label:`${i.orgName} / ${l.name}`}}}function Nc(e,t){let n=vt(e);for(let s of n.files.values()){let r=ro(s);if(r)return r}return no(t)}async function Dc(e,t){let n=so(Nc(e,t)),s=go({input:process.stdin,output:process.stderr});try{for(;;){let r=(await s.question(n)).trim(),o=oo(r);if("error"in o){process.stderr.write(`gruum: ${o.error}
73
+ `);continue}return o.value}}finally{s.close()}}async function ko(){let e=`Cursor on ${_c()}`,t=await ee(null,"/api/cli/pair/start",{method:"POST",body:JSON.stringify({label:e})});if(!t.ok)return process.stderr.write(`gruum: couldn't start sign-in (${t.status}). Is Gruum running at ${Pe}?
74
+ `),1;let n=await t.json(),s=`${Pe}/extension/connect?code=${encodeURIComponent(n.userCode)}`;process.stdout.write(`Sign in to Gruum to connect this CLI.
67
75
 
68
76
  Code: ${n.userCode}
69
77
  ${s}
70
78
 
71
79
  Waiting for confirmation\u2026
72
- `);let r=Date.now()+600*1e3;for(;Date.now()<r;){await new Promise(a=>setTimeout(a,2e3));let o=await st(null,`/api/cli/pair/poll?pairingId=${encodeURIComponent(n.pairingId)}&verifier=${encodeURIComponent(n.verifier)}`);if(!o.ok)continue;let i=await o.json();if(i.status==="expired")return process.stderr.write("gruum: that code expired. Run `npx @gruum/cli login` again.\n"),1;if(i.status==="connected"&&i.token)return Rc({token:i.token,apiOrigin:Mt}),process.stdout.write(`Signed in. This CLI can read specs for your projects.
73
- `),0}return process.stderr.write("gruum: sign-in timed out. Run `npx @gruum/cli login` again.\n"),1}function jn(t){if(!t||typeof t!="object")return null;let e=t;return typeof e.id!="string"||typeof e.repo!="string"?null:{id:e.id,name:typeof e.name=="string"?e.name:e.repo,repo:e.repo,rootPath:typeof e.rootPath=="string"?e.rootPath:"",host:typeof e.host=="string"&&e.host?e.host:null}}async function mo(t,e){let n=Ac(t.repoDir);if(!n)return process.stderr.write(`gruum: this folder has no GitHub origin, so it can't be matched to a Gruum project.
74
- `),null;let s=!!process.stdin.isTTY,r=_c(t);if(r&&r.repo===n&&(r.host||!s))return r;let o=Ln(e),i=await st(e,`/api/v2/cli/projects?repo=${encodeURIComponent(n)}`);if(i.status===401)return process.stderr.write("gruum: sign-in expired. Run `npx @gruum/cli login` again.\n"),null;if(!i.ok)return null;let a=await i.json(),l=Array.isArray(a.projects)?a.projects.map(jn).filter(b=>b!==null):[],c=!1;if(l.length===0){let b=await st(e,"/api/v2/cli/projects",{method:"POST",body:JSON.stringify({repo:n,rootPath:t.root})}),k=await b.json().catch(()=>({})),C=jn(k.project);if(c=k.created!==!1,!b.ok||!C){let v=typeof k.path=="string"?k.path:"";return process.stderr.write(`gruum: ${k.error||`couldn't create a project (${b.status})`}
75
- `),v&&process.stderr.write(`${o}${v}
76
- `),null}l=[C]}let u=Qr(l,t.root);if(!u){let b=l.map(k=>` ${k.name}${k.rootPath?` #${k.rootPath}`:""}
77
- ${fo(o,k.id)}`).join(`
80
+ `);let r=Date.now()+600*1e3;for(;Date.now()<r;){await new Promise(a=>setTimeout(a,2e3));let o=await ee(null,`/api/cli/pair/poll?pairingId=${encodeURIComponent(n.pairingId)}&verifier=${encodeURIComponent(n.verifier)}`);if(!o.ok)continue;let i=await o.json();if(i.status==="expired")return process.stderr.write("gruum: that code expired. Run `npx @gruum/cli login` again.\n"),1;if(i.status==="connected"&&i.token)return jc({token:i.token,apiOrigin:Pe}),process.stdout.write(`Signed in. This CLI can read specs for your projects.
81
+ `),0}return process.stderr.write("gruum: sign-in timed out. Run `npx @gruum/cli login` again.\n"),1}function jn(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.id!="string"||typeof t.repo!="string"?null:{id:t.id,name:typeof t.name=="string"?t.name:t.repo,repo:t.repo,rootPath:typeof t.rootPath=="string"?t.rootPath:"",host:typeof t.host=="string"&&t.host?t.host:null,workspaceId:typeof t.workspaceId=="string"&&t.workspaceId?t.workspaceId:null}}async function wo(e,t){let n=Lc(e.repoDir);if(!n)return process.stderr.write(`gruum: this folder has no GitHub origin, so it can't be matched to a Gruum project.
82
+ `),null;let s=!!process.stdin.isTTY,r=Pc(e);if(r&&r.repo===n&&r.workspaceId&&(r.host||!s))return r;let o=Pn(t),i=await ee(t,`/api/v2/cli/projects?repo=${encodeURIComponent(n)}`);if(i.status===401)return process.stderr.write("gruum: sign-in expired. Run `npx @gruum/cli login` again.\n"),null;if(!i.ok)return null;let a=await i.json(),l=Array.isArray(a.projects)?a.projects.map(jn).filter(w=>w!==null):[],c=!1,u="";if(l.length===0){let w=await Oc(t,s);if(!w)return null;let $=await ee(t,"/api/v2/cli/projects",{method:"POST",body:JSON.stringify({repo:n,rootPath:e.root,...w.workspaceId?{workspaceId:w.workspaceId}:{}})}),k=await $.json().catch(()=>({}));typeof k.place?.org=="string"&&typeof k.place.workspace=="string"?u=`${k.place.org} / ${k.place.workspace}`:u=w.label;let g=jn(k.project);if(c=k.created!==!1,!$.ok||!g){let p=typeof k.path=="string"?k.path:"";return process.stderr.write(`gruum: ${k.error||`couldn't create a project (${$.status})`}
83
+ `),p&&process.stderr.write(`${o}${p}
84
+ `),null}l=[g]}let f=eo(l,e.root);if(!f){let w=l.map($=>` ${$.name}${$.rootPath?` #${$.rootPath}`:""}
85
+ ${xo(o,$.id)}`).join(`
78
86
  `);return process.stderr.write(`gruum: ${n} matches more than one project. Set "root" in .gruum/config.json to the folder alias, then run \`npx @gruum/cli check\` again.
79
- ${b}
80
- `),null}let f=u.host??null;if(!f&&s)for(io(o,{...u,host:f},c);!f;){let b=await jc(t,n),k=await st(e,`/api/v2/cli/projects/${encodeURIComponent(u.id)}/url`,{method:"POST",body:JSON.stringify({url:b})}),C=await k.json().catch(()=>({})),v=jn(C.project);if(!k.ok||!v?.host){process.stderr.write(`gruum: ${C.error||`couldn't save that URL (${k.status})`}
81
- `);continue}f=v.host,process.stderr.write(`Live URL set to ${oo(f)}.
82
- `)}else io(o,{...u,host:f},c),!f&&!s&&process.stderr.write(`No live URL yet. Add one on that page.
83
- `);let m={...u,host:f,hostDeclined:!1};return $t(po(t),m),m}async function Ee(t,e){if(e)return"local";let n=co();if(!n)return"local";try{let s=await mo(t,n);if(!s)return"local";let r=_e(t.repoDir),o=await st(n,`/api/v2/cli/projects/${encodeURIComponent(s.id)}/baseline?concept=button&branch=${encodeURIComponent(r)}`);if(o.status===404||!o.ok)return"local";let i=await o.json(),a=qt(i.baseline);return a?($t(Ht(t),a),$t(An(t),i.exceptions??{}),"remote"):"local"}catch{return process.stderr.write(`gruum: couldn't reach Gruum. Checking the spec cached in .gruum/baseline.json.
84
- `),"local"}}async function Pn(t){let e=co();if(!e)return null;let n=await mo(t,e);return n?{credentials:e,project:n}:null}async function ho(t,e,n,s){let r=await Pn(t);if(!r)return;let o=_e(t.repoDir);if(o)try{let i=await st(r.credentials,`/api/v2/cli/projects/${encodeURIComponent(r.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"observe",concept:"button",branch:o,commit:uo(t.repoDir),baselineVersion:n,source:s,items:e})});i.ok||process.stderr.write(`gruum: couldn't report this check (${i.status}). The local result still stands.
87
+ ${w}
88
+ `),null}let m=f.host??null;if(!m&&s)for(uo(o,{...f,host:m},c,u);!m;){let w=await Dc(e,n),$=await ee(t,`/api/v2/cli/projects/${encodeURIComponent(f.id)}/url`,{method:"POST",body:JSON.stringify({url:w})}),k=await $.json().catch(()=>({})),g=jn(k.project);if(!$.ok||!g?.host){process.stderr.write(`gruum: ${k.error||`couldn't save that URL (${$.status})`}
89
+ `);continue}m=g.host,process.stderr.write(`Live URL set to ${io(m)}.
90
+ `)}else uo(o,{...f,host:m},c,u),!m&&!s&&process.stderr.write(`No live URL yet. Add one on that page.
91
+ `);let b={...f,host:m,workspaceId:f.workspaceId??null,hostDeclined:!1};return $e(yo(e),b),b}async function Et(e,t){if(t)return"local";let n=ho();if(!n)return"local";try{let s=await wo(e,n);if(!s)return"local";let r=_t(e.repoDir),o=await ee(n,`/api/v2/cli/projects/${encodeURIComponent(s.id)}/baseline?concept=button&branch=${encodeURIComponent(r)}`);if(o.status===404||!o.ok)return"local";let i=await o.json(),a=qe(i.baseline);return a?($e(He(e),a),$e(An(e),i.exceptions??{}),"remote"):"local"}catch{return process.stderr.write(`gruum: couldn't reach Gruum. Checking the spec cached in .gruum/baseline.json.
92
+ `),"local"}}async function On(e){let t=ho();if(!t)return null;let n=await wo(e,t);return n?{credentials:t,project:n}:null}async function vo(e,t,n,s){let r=await On(e);if(!r)return;let o=_t(e.repoDir);if(o)try{let i=await ee(r.credentials,`/api/v2/cli/projects/${encodeURIComponent(r.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"observe",concept:"button",branch:o,commit:bo(e.repoDir),baselineVersion:n,source:s,items:t})});i.ok||process.stderr.write(`gruum: couldn't report this check (${i.status}). The local result still stands.
85
93
  `)}catch{process.stderr.write(`gruum: couldn't reach Gruum to report this check. The local result still stands.
86
- `)}}async function bo(t,e,n){let s=await Pn(t);if(!s)return{ok:!1,text:"Sign in with gruum login before requesting an exception."};let r=_e(t.repoDir);if(!r)return{ok:!1,text:"This folder is not on a named git branch."};try{let o=await st(s.credentials,`/api/v2/cli/projects/${encodeURIComponent(s.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"request",concept:"button",branch:r,commit:uo(t.repoDir),reason:n,item:e})}),i=await o.json().catch(()=>({}));if(!o.ok)return{ok:!1,text:i.error||`Request failed (${o.status}).`};let a=i.reviewUrl?`${Ln(s.credentials)}${i.reviewUrl}`:"",l=i.created?`Exception request ${i.id} is pending review.`:`An exception for this change is already pending (${i.id}).`;return{ok:!0,text:a?`${l}
87
- ${a}`:l}}catch{return{ok:!1,text:"Couldn't reach Gruum to request an exception."}}}async function yo(t,e){let n=await Pn(t);if(!n)return{ok:!1,text:"Sign in with gruum login to see exception status."};let s=_e(t.repoDir);try{let r=await st(n.credentials,`/api/v2/cli/projects/${encodeURIComponent(n.project.id)}/drift?concept=button&branch=${encodeURIComponent(s)}`);if(!r.ok)return{ok:!1,text:`Couldn't load exceptions (${r.status}).`};let o=await r.json(),i=Array.isArray(o.requests)?o.requests:[],a=e?i.filter(l=>l.id===e):i;return a.length===0?{ok:!0,text:e?`No exception request ${e} on ${s||"this branch"}.`:`No exception requests on ${s||"this branch"}.`}:{ok:!0,text:a.map(l=>`${l.id} ${l.status} ${l.title} (${l.branch})`).join(`
88
- `)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var Le="0.1.8",xo=`gruum ${Le}: keep buttons on the Gruum spec
94
+ `)}}async function $o(e,t,n){let s=await On(e);if(!s)return{ok:!1,text:"Sign in with gruum login before requesting an exception."};let r=_t(e.repoDir);if(!r)return{ok:!1,text:"This folder is not on a named git branch."};try{let o=await ee(s.credentials,`/api/v2/cli/projects/${encodeURIComponent(s.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"request",concept:"button",branch:r,commit:bo(e.repoDir),reason:n,item:t})}),i=await o.json().catch(()=>({}));if(!o.ok)return{ok:!1,text:i.error||`Request failed (${o.status}).`};let a=i.reviewUrl?`${Pn(s.credentials)}${i.reviewUrl}`:"",l=i.created?`Exception request ${i.id} is pending review.`:`An exception for this change is already pending (${i.id}).`;return{ok:!0,text:a?`${l}
95
+ ${a}`:l}}catch{return{ok:!1,text:"Couldn't reach Gruum to request an exception."}}}async function Co(e,t){let n=await On(e);if(!n)return{ok:!1,text:"Sign in with gruum login to see exception status."};let s=_t(e.repoDir);try{let r=await ee(n.credentials,`/api/v2/cli/projects/${encodeURIComponent(n.project.id)}/drift?concept=button&branch=${encodeURIComponent(s)}`);if(!r.ok)return{ok:!1,text:`Couldn't load exceptions (${r.status}).`};let o=await r.json(),i=Array.isArray(o.requests)?o.requests:[],a=t?i.filter(l=>l.id===t):i;return a.length===0?{ok:!0,text:t?`No exception request ${t} on ${s||"this branch"}.`:`No exception requests on ${s||"this branch"}.`}:{ok:!0,text:a.map(l=>`${l.id} ${l.status} ${l.title} (${l.branch})`).join(`
96
+ `)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var Lt="0.1.10",So=`gruum ${Lt}: keep buttons on the Gruum spec
89
97
 
90
98
  Run it as \`npx @gruum/cli <command>\`.
91
99
 
@@ -114,36 +122,36 @@ Usage:
114
122
  gruum mcp
115
123
  Stdio MCP server: gruum_button_spec, gruum_check_buttons,
116
124
  gruum_request_exception, and gruum_exception_status.
117
- `,Lc=new Set(["--baseline","--root","--out","--cli","--files"]);function wo(t){let e=[],n=new Map;for(let s=0;s<t.length;s++){let r=t[s];if(!r.startsWith("--")){e.push(r);continue}let o=r.indexOf("="),i=o===-1?r:r.slice(0,o),a=o===-1?void 0:r.slice(o+1),l=n.get(i)??[];if(a!==void 0)l.push(a);else if(i==="--files")for(;t[s+1]&&!t[s+1].startsWith("--");)l.push(t[++s]);else Lc.has(i)&&t[s+1]!==void 0&&l.push(t[++s]);n.set(i,l)}return{positional:e,flags:n}}var N=(t,e)=>t.flags.has(e),tt=(t,e)=>t.flags.get(e)?.[0];function Pt(t,e=process.cwd()){let n=Rn(e),s=tt(t,"--root")??En(n).root??"";return Rn(e,s)}var Kt="No spec found. Publish one from Gruum, or draft one locally with `npx @gruum/cli baseline --write`.";function Mc(t,e){let n=ft(t,tt(e,"--baseline"));return n||process.stderr.write(`gruum: ${Kt}
118
- `),n}function Jt(t,e,n){let s={...e,checkedAt:new Date().toISOString(),baselineVersion:n.baseline.version,items:n.items};return _n(t,s),s}async function vo(t,e){let n=Dn({input:process.stdin,output:process.stdout});try{for(;;){let s=await new Promise(o=>{n.question(t,o)}),r=e(s);if(r)return r;process.stdout.write(`Enter one of the letters in the question.
119
- `)}}finally{n.close()}}function Pc(t){return!!process.stdin.isTTY&&!N(t,"--ci")&&!N(t,"--json")&&!N(t,"--staged")}async function $o(t,e=!1){let n=Pt(t);await Ee(n,N(t,"--baseline"));let s=ft(n,tt(t,"--baseline"));if(!s){if(!e&&Pc(t)){if(await vo(ws,$s)!=="baseline")return 0;let u=["baseline","--write"],f=tt(t,"--root");f&&u.push("--root",f);let m=Co(wo(u));return m!==0?m:$o(t,!0)}return process.stderr.write(`gruum: ${Kt}
120
- `),0}let r=wt(n,s,{staged:N(t,"--staged")});N(t,"--staged")||Jt(n,Re(n),r);let o=(t.flags.get("--files")??[]).map(c=>V.relative(V.join(n.repoDir,n.root),V.resolve(c)).split(V.sep).join("/")),i=Ve(r.items,o),a=Ae(n);(N(t,"--ci")||N(t,"--report"))&&await ho(n,i,s.version,N(t,"--ci")?"ci":"local"),N(t,"--json")?process.stdout.write(`${JSON.stringify({baselineVersion:s.version,items:i,exceptions:a},null,2)}
121
- `):process.stdout.write(`${qn(i,{baselineVersion:s.version,files:r.result.index.files,skipped:r.result.index.skipped},a)}
122
- `);let l=Tt(i,a);if(N(t,"--strict")){let c=i.some(u=>u.severity==="block"&&a[u.id]==="pending");return l.length>0||c?1:0}if(N(t,"--ci")&&l.length===0){let c=i.filter(u=>a[u.id]==="pending");c.length>0&&process.stdout.write(`${c.length} pending exception${c.length===1?"":"s"}; this run does not fail on them.
123
- `)}return l.length>0?1:0}async function Oc(t){let e=Pt(t);await Ee(e,N(t,"--baseline"));let n=Mc(e,t);return n?(process.stdout.write(`${JSON.stringify(Ne(n),null,2)}
124
- `),0):1}function Co(t){if(!N(t,"--write"))return process.stderr.write(`gruum: pass --write to draft a local spec from the working tree.
125
- `),2;let e=Pt(t),n=$e(e),s=Zn(n,{version:0}),r=tt(t,"--out")?V.resolve(tt(t,"--out")):Ht(e);return $t(r,s),process.stdout.write(`Drafted a local spec (v0) from ${n.index.files} files: ${s.styles.length} styles, ${s.tokens.length} tokens, ${s.rules.length} rules, ${s.acceptedFindings.length} accepted findings.
125
+ `,Vc=new Set(["--baseline","--root","--out","--cli","--files"]);function Ao(e){let t=[],n=new Map;for(let s=0;s<e.length;s++){let r=e[s];if(!r.startsWith("--")){t.push(r);continue}let o=r.indexOf("="),i=o===-1?r:r.slice(0,o),a=o===-1?void 0:r.slice(o+1),l=n.get(i)??[];if(a!==void 0)l.push(a);else if(i==="--files")for(;e[s+1]&&!e[s+1].startsWith("--");)l.push(e[++s]);else Vc.has(i)&&e[s+1]!==void 0&&l.push(e[++s]);n.set(i,l)}return{positional:t,flags:n}}var T=(e,t)=>e.flags.has(t),te=(e,t)=>e.flags.get(t)?.[0];function Me(e,t=process.cwd()){let n=Rn(t),s=te(e,"--root")??En(n).root??"";return Rn(t,s)}var Ke="No spec found. Publish one from Gruum, or draft one locally with `npx @gruum/cli baseline --write`.";function Fc(e,t){let n=fe(e,te(t,"--baseline"));return n||process.stderr.write(`gruum: ${Ke}
126
+ `),n}function Je(e,t,n){let s={...t,checkedAt:new Date().toISOString(),baselineVersion:n.baseline.version,items:n.items};return _n(e,s),s}async function _o(e,t){let n=Dn({input:process.stdin,output:process.stdout});try{for(;;){let s=await new Promise(o=>{n.question(e,o)}),r=t(s);if(r)return r;process.stdout.write(`Enter one of the letters in the question.
127
+ `)}}finally{n.close()}}function Bc(e){return!!process.stdin.isTTY&&!T(e,"--ci")&&!T(e,"--json")&&!T(e,"--staged")}async function Eo(e,t=!1){let n=Me(e);await Et(n,T(e,"--baseline"));let s=fe(n,te(e,"--baseline"));if(!s){if(!t&&Bc(e)){if(await _o(vs,Cs)!=="baseline")return 0;let u=["baseline","--write"],f=te(e,"--root");f&&u.push("--root",f);let m=Io(Ao(u));return m!==0?m:Eo(e,!0)}return process.stderr.write(`gruum: ${Ke}
128
+ `),0}let r=we(n,s,{staged:T(e,"--staged")});T(e,"--staged")||Je(n,Rt(n),r);let o=(e.flags.get("--files")??[]).map(c=>V.relative(V.join(n.repoDir,n.root),V.resolve(c)).split(V.sep).join("/")),i=Vt(r.items,o),a=At(n);(T(e,"--ci")||T(e,"--report"))&&await vo(n,i,s.version,T(e,"--ci")?"ci":"local"),T(e,"--json")?process.stdout.write(`${JSON.stringify({baselineVersion:s.version,items:i,exceptions:a},null,2)}
129
+ `):process.stdout.write(`${Yn(i,{baselineVersion:s.version,files:r.result.index.files,skipped:r.result.index.skipped},a)}
130
+ `);let l=De(i,a);if(T(e,"--strict")){let c=i.some(u=>u.severity==="block"&&a[u.id]==="pending");return l.length>0||c?1:0}if(T(e,"--ci")&&l.length===0){let c=i.filter(u=>a[u.id]==="pending");c.length>0&&process.stdout.write(`${c.length} pending exception${c.length===1?"":"s"}; this run does not fail on them.
131
+ `)}return l.length>0?1:0}async function Uc(e){let t=Me(e);await Et(t,T(e,"--baseline"));let n=Fc(t,e);return n?(process.stdout.write(`${JSON.stringify(Tt(n),null,2)}
132
+ `),0):1}function Io(e){if(!T(e,"--write"))return process.stderr.write(`gruum: pass --write to draft a local spec from the working tree.
133
+ `),2;let t=Me(e),n=$t(t),s=Xn(n,{version:0}),r=te(e,"--out")?V.resolve(te(e,"--out")):He(t);return $e(r,s),process.stdout.write(`Drafted a local spec (v0) from ${n.index.files} files: ${s.styles.length} styles, ${s.tokens.length} tokens, ${s.rules.length} rules, ${s.acceptedFindings.length} accepted findings.
126
134
  Wrote ${V.relative(process.cwd(),r)||r}.
127
- `),0}function ko(t,e,n,s){if(!n.ok)return process.stderr.write(`gruum: ${n.error}
128
- `),!1;if(!n.changed)return s.push(`unchanged ${e}`),!0;let r=V.join(t.repoDir,e);return n.text===""?(On(r,{force:!0}),s.push(`removed ${e}`)):(vt(r,n.text),s.push(`wrote ${e}`)),!0}function Dc(t){if(t.positional[1]!=="cursor")return process.stderr.write(`gruum: usage: gruum init cursor [--remove] [--force] [--cli "<command>"]
129
- `),2;let e=Pt(t),n=tt(t,"--cli")??Nt,s=N(t,"--remove"),r=v=>Ce(V.join(e.repoDir,v)),o=[],i=s?is(r(".cursor/hooks.json")):os(r(".cursor/hooks.json"),n),a=s?ls(r(".cursor/mcp.json")):as(r(".cursor/mcp.json"),n);for(let v of[i,a])if(!v.ok)return process.stderr.write(`gruum: ${v.error}
130
- `),1;ko(e,".cursor/hooks.json",i,o),ko(e,".cursor/mcp.json",a,o);let l=r(dt);if(s)l!==null&&fs(l)&&(On(V.join(e.repoDir,dt)),o.push(`removed ${dt}`));else if(l===null||N(t,"--force")){let v=ft(e,tt(t,"--baseline")),g=us(v?null:Tc(e)),p=v?[...new Set(v.styles.map(d=>d.path))].sort():[];vt(V.join(e.repoDir,dt),ps(p.length?p:g)),o.push(`wrote ${dt}`)}else o.push(`kept ${dt} (exists; --force replaces it)`);let c=s?gs(r(".gitignore")):ds(r(".gitignore"));c.changed&&(vt(V.join(e.repoDir,".gitignore"),c.text),o.push("wrote .gitignore"));let u=je(V.join(e.repoDir,".husky")),f=["lefthook.yml","lefthook.yaml",".lefthook.yml"].some(v=>je(V.join(e.repoDir,v))),m=Xr(e),b=u?".husky/pre-commit":m?`${m}/pre-commit`:null,k=b?V.resolve(e.repoDir,b):null,C=k?Ce(k):null;if(s){if(k&&C!==null){let v=bs(C);v.changed&&v.text===""?(On(k,{force:!0}),o.push(`removed ${b}`)):v.changed&&(vt(k,v.text),o.push(`edited ${b}`))}}else{let v=ms({husky:u,lefthook:f,hookText:C,gitHooksDir:m},n);if(v.kind==="print")o.push(`pre-commit ${v.reason}:
131
- ${v.snippet}`);else if(v.changed&&k){if(vt(k,v.text),v.kind==="git")try{Ic(k,493)}catch{}o.push(`wrote ${b}${v.kind==="git"?" (local only; not shared through git)":""}`)}else o.push(`unchanged ${b}`)}return process.stdout.write(`${o.join(`
135
+ `),0}function Ro(e,t,n,s){if(!n.ok)return process.stderr.write(`gruum: ${n.error}
136
+ `),!1;if(!n.changed)return s.push(`unchanged ${t}`),!0;let r=V.join(e.repoDir,t);return n.text===""?(Nn(r,{force:!0}),s.push(`removed ${t}`)):(ve(r,n.text),s.push(`wrote ${t}`)),!0}function zc(e){if(e.positional[1]!=="cursor")return process.stderr.write(`gruum: usage: gruum init cursor [--remove] [--force] [--cli "<command>"]
137
+ `),2;let t=Me(e),n=te(e,"--cli")??Te,s=T(e,"--remove"),r=k=>Ct(V.join(t.repoDir,k)),o=[],i=s?as(r(".cursor/hooks.json")):is(r(".cursor/hooks.json"),n),a=s?cs(r(".cursor/mcp.json")):ls(r(".cursor/mcp.json"),n);for(let k of[i,a])if(!k.ok)return process.stderr.write(`gruum: ${k.error}
138
+ `),1;Ro(t,".cursor/hooks.json",i,o),Ro(t,".cursor/mcp.json",a,o);let l=r(de);if(s)l!==null&&ds(l)&&(Nn(V.join(t.repoDir,de)),o.push(`removed ${de}`));else if(l===null||T(e,"--force")){let k=fe(t,te(e,"--baseline")),g=ps(k?null:Wc(t)),p=k?[...new Set(k.styles.map(d=>d.path))].sort():[];ve(V.join(t.repoDir,de),fs(p.length?p:g)),o.push(`wrote ${de}`)}else o.push(`kept ${de} (exists; --force replaces it)`);let c=s?ms(r(".gitignore")):gs(r(".gitignore"));c.changed&&(ve(V.join(t.repoDir,".gitignore"),c.text),o.push("wrote .gitignore"));let u=It(V.join(t.repoDir,".husky")),f=["lefthook.yml","lefthook.yaml",".lefthook.yml"].some(k=>It(V.join(t.repoDir,k))),m=qr(t),b=u?".husky/pre-commit":m?`${m}/pre-commit`:null,w=b?V.resolve(t.repoDir,b):null,$=w?Ct(w):null;if(s){if(w&&$!==null){let k=ys($);k.changed&&k.text===""?(Nn(w,{force:!0}),o.push(`removed ${b}`)):k.changed&&(ve(w,k.text),o.push(`edited ${b}`))}}else{let k=hs({husky:u,lefthook:f,hookText:$,gitHooksDir:m},n);if(k.kind==="print")o.push(`pre-commit ${k.reason}:
139
+ ${k.snippet}`);else if(k.changed&&w){if(ve(w,k.text),k.kind==="git")try{Tc(w,493)}catch{}o.push(`wrote ${b}${k.kind==="git"?" (local only; not shared through git)":""}`)}else o.push(`unchanged ${b}`)}return process.stdout.write(`${o.join(`
132
140
  `)}
133
141
  `),s||process.stdout.write(`
134
142
  Commit the .cursor/ files so teammates get the same guardrails. Tokens never go in the repository.
135
- `),0}function Tc(t){try{return $e(t)}catch{return null}}async function Nc(){if(process.stdin.isTTY)return{};let t=[];for await(let e of process.stdin)t.push(e);try{let e=JSON.parse(Buffer.concat(t).toString("utf8")||"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function Vc(t){let e=t.workspace_roots,n=Array.isArray(e)&&typeof e[0]=="string"&&je(e[0])?e[0]:typeof t.cwd=="string"&&je(t.cwd)?t.cwd:process.cwd();return Pt({positional:[],flags:new Map},n)}async function Bc(t){let e=t.positional[1],n=await Nc(),s=e==="before-shell"?{permission:"allow"}:{};try{let r=Vc(n),o=En(r),i={...o.hooks,exceptions:!0},a=ft(r),l=Re(r),c=Ae(r),u=s;if(e==="after-file-edit"){let f=typeof n.file_path=="string"?n.file_path:"",m=He(V.relative(r.repoDir,V.resolve(r.repoDir,f)).split(V.sep).join("/"),r.root);a&&m!==null&&_s(m)&&Jt(r,l,wt(r,a))}else if(e==="stop"){if(a){let f=Jt(r,l,wt(r,a)),m=ns(f,n,i,c);_n(r,m.ledger),u=m.output}}else if(e==="before-shell"){let f=typeof n.command=="string"?n.command:"",m=Fe(f).some(b=>o.hooks.denyGit.includes(b));if(a&&m){let b=Jt(r,l,wt(r,a));u=ss(b,n,i,c)}}else return process.stderr.write(`gruum: unknown hook ${String(e)}
143
+ `),0}function Wc(e){try{return $t(e)}catch{return null}}async function Gc(){if(process.stdin.isTTY)return{};let e=[];for await(let t of process.stdin)e.push(t);try{let t=JSON.parse(Buffer.concat(e).toString("utf8")||"{}");return t&&typeof t=="object"?t:{}}catch{return{}}}function Hc(e){let t=e.workspace_roots,n=Array.isArray(t)&&typeof t[0]=="string"&&It(t[0])?t[0]:typeof e.cwd=="string"&&It(e.cwd)?e.cwd:process.cwd();return Me({positional:[],flags:new Map},n)}async function Kc(e){let t=e.positional[1],n=await Gc(),s=t==="before-shell"?{permission:"allow"}:{};try{let r=Hc(n),o=En(r),i={...o.hooks,exceptions:!0},a=fe(r),l=Rt(r),c=At(r),u=s;if(t==="after-file-edit"){let f=typeof n.file_path=="string"?n.file_path:"",m=Ht(V.relative(r.repoDir,V.resolve(r.repoDir,f)).split(V.sep).join("/"),r.root);a&&m!==null&&Es(m)&&Je(r,l,we(r,a))}else if(t==="stop"){if(a){let f=Je(r,l,we(r,a)),m=ss(f,n,i,c);_n(r,m.ledger),u=m.output}}else if(t==="before-shell"){let f=typeof n.command=="string"?n.command:"",m=Bt(f).some(b=>o.hooks.denyGit.includes(b));if(a&&m){let b=Je(r,l,we(r,a));u=rs(b,n,i,c)}}else return process.stderr.write(`gruum: unknown hook ${String(t)}
136
144
  `),2;process.stdout.write(`${JSON.stringify(u)}
137
- `)}catch(r){process.stderr.write(`gruum hook ${e}: ${r instanceof Error?r.message:String(r)}
145
+ `)}catch(r){process.stderr.write(`gruum hook ${t}: ${r instanceof Error?r.message:String(r)}
138
146
  `),process.stdout.write(`${JSON.stringify(s)}
139
- `)}return 0}async function Fc(t){let e=Pt(t),n=Ss({spec:async()=>{let o=ft(e,tt(t,"--baseline"));return o?{text:JSON.stringify(Ne(o),null,2)}:{text:Kt,isError:!0}},check:async o=>{let i=ft(e,tt(t,"--baseline"));if(!i)return{text:Kt,isError:!0};let a=wt(e,i);Jt(e,Re(e),a);let l=Ve(a.items,o);return{text:JSON.stringify({baselineVersion:i.version,blocking:Tt(l,Ae(e)).length,items:l},null,2)}},request:async(o,i)=>{await Ee(e,!1);let a=ft(e);if(!a)return{text:Kt,isError:!0};let c=wt(e,a).items.find(f=>f.id===o);if(!c)return{text:`No drift item ${o}. Run gruum_check_buttons and use an id from that list.`,isError:!0};let u=await bo(e,c,i);return{text:u.text,isError:!u.ok}},status:async o=>{let i=await yo(e,o);return{text:i.text,isError:!i.ok}}}),s={name:"gruum",version:Le},r=Dn({input:process.stdin,crlfDelay:1/0});for await(let o of r){if(!o.trim())continue;let i;try{i=JSON.parse(o)}catch{process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Parse error"}})}
140
- `);continue}let a=await Rs(i,n,s);a&&process.stdout.write(`${JSON.stringify(a)}
141
- `)}return 0}async function Uc(){if(process.stdout.write(ys(Le)),!process.stdin.isTTY)return process.stdout.write(`
142
- ${St.map(n=>n.usage).join(`
147
+ `)}return 0}async function Jc(e){let t=Me(e),n=Rs({spec:async()=>{let o=fe(t,te(e,"--baseline"));return o?{text:JSON.stringify(Tt(o),null,2)}:{text:Ke,isError:!0}},check:async o=>{let i=fe(t,te(e,"--baseline"));if(!i)return{text:Ke,isError:!0};let a=we(t,i);Je(t,Rt(t),a);let l=Vt(a.items,o);return{text:JSON.stringify({baselineVersion:i.version,blocking:De(l,At(t)).length,items:l},null,2)}},request:async(o,i)=>{await Et(t,!1);let a=fe(t);if(!a)return{text:Ke,isError:!0};let c=we(t,a).items.find(f=>f.id===o);if(!c)return{text:`No drift item ${o}. Run gruum_check_buttons and use an id from that list.`,isError:!0};let u=await $o(t,c,i);return{text:u.text,isError:!u.ok}},status:async o=>{let i=await Co(t,o);return{text:i.text,isError:!i.ok}}}),s={name:"gruum",version:Lt},r=Dn({input:process.stdin,crlfDelay:1/0});for await(let o of r){if(!o.trim())continue;let i;try{i=JSON.parse(o)}catch{process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Parse error"}})}
148
+ `);continue}let a=await As(i,n,s);a&&process.stdout.write(`${JSON.stringify(a)}
149
+ `)}return 0}async function Zc(){if(process.stdout.write(xs(Lt)),!process.stdin.isTTY)return process.stdout.write(`
150
+ ${Se.map(n=>n.usage).join(`
143
151
  `)}
144
- `),0;let t=Dn({input:process.stdin,output:process.stdout}),e=null;try{for(;;){let n=await new Promise(s=>{t.question(xs,s)});if(e=Cs(n),e==="quit"||e)break;process.stdout.write(`Enter 1, 2, or 3.
145
- `)}}finally{t.close()}return!e||e==="quit"?0:Ie([e.name,...e.args])}async function Ie(t){let e=wo(t),n=e.positional[0];if(N(e,"--version"))return process.stdout.write(`${Le}
146
- `),0;if(N(e,"--help")||n==="help")return process.stdout.write(xo),0;switch(n){case"login":{let s=await go();if(s!==0||!process.stdin.isTTY)return s;let r=await vo(ks,vs);return r==="check"?Ie(["check"]):r==="baseline"?Ie(["baseline","--write"]):0}case"check":return $o(e);case"spec":return Oc(e);case"baseline":return Co(e);case"init":return Dc(e);case"hook":return Bc(e);case"mcp":return Fc(e);case void 0:return Uc();default:return process.stderr.write(`gruum: unknown command ${n}
152
+ `),0;let e=Dn({input:process.stdin,output:process.stdout}),t=null;try{for(;;){let n=await new Promise(s=>{e.question(ks,s)});if(t=Ss(n),t==="quit"||t)break;process.stdout.write(`Enter 1, 2, or 3.
153
+ `)}}finally{e.close()}return!t||t==="quit"?0:jt([t.name,...t.args])}async function jt(e){let t=Ao(e),n=t.positional[0];if(T(t,"--version"))return process.stdout.write(`${Lt}
154
+ `),0;if(T(t,"--help")||n==="help")return process.stdout.write(So),0;switch(n){case"login":{let s=await ko();if(s!==0||!process.stdin.isTTY)return s;let r=await _o(ws,$s);return r==="check"?jt(["check"]):r==="baseline"?jt(["baseline","--write"]):0}case"check":return Eo(t);case"spec":return Uc(t);case"baseline":return Io(t);case"init":return zc(t);case"hook":return Kc(t);case"mcp":return Jc(t);case void 0:return Zc();default:return process.stderr.write(`gruum: unknown command ${n}
147
155
 
148
- ${xo}`),2}}Ie(process.argv.slice(2)).then(t=>{process.exitCode=t},t=>{process.stderr.write(`gruum: ${t instanceof Error?t.message:String(t)}
156
+ ${So}`),2}}jt(process.argv.slice(2)).then(e=>{process.exitCode=e},e=>{process.stderr.write(`gruum: ${e instanceof Error?e.message:String(e)}
149
157
  `),process.exitCode=1});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gruum/cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Keep buttons on the Gruum spec: a local drift check, Cursor hooks, and an MCP server.",
5
5
  "type": "module",
6
6
  "bin": {